Emacs tips and tricks

Forum rules
Share your brain ;)
User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: Emacs tips and tricks

Unread post by franksinistra » Wed Feb 03, 2016 5:44 am

Bozhidar Batsov's crux (collection of ridiculously useful extension): https://github.com/bbatsov/crux

more like collection of useful functions, but it's indeed useful.
rice no more.

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: Emacs tips and tricks

Unread post by franksinistra » Sun Feb 07, 2016 6:07 am

Long holiday = New emacs theme

here you go https://github.com/franksn/omtose-phellack-theme
rice no more.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Sun Feb 07, 2016 10:09 am

^ Impressive work, you already support tons of mode.

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: Emacs tips and tricks

Unread post by franksinistra » Sun Feb 07, 2016 10:56 am

^ courtesy of long weekend and CNY... LoL :)

Oh i almost forgot... GP do you know any cleaner way of defining colors in emacs theme? Mine is a bit cluttered ( two color-classes, the codes are too verbose and hard to debug)

Guess I'm not good at all in e-lisp... :(
rice no more.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Sun Feb 07, 2016 5:07 pm

^ I'd take a look at solarized-emacs, zenburn-emacs and darktooth. I'm no expert here, but they are great themes widely used.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Sat Feb 20, 2016 10:18 am

As I much as I like Helm (and I do, really), after months I felt like it was really taking over my configuration. Not that is bad per se, but I found myself relying on Helm for the simplest things. Helm is quite a beast, and if I'm familiar with its bloated GUI now, I still don't like how it slows down my Emacs startup time.

Enter Ivy. Ivy comes with Swiper, which is a very fine replacement for Isearch (and helm-swoop), but it is also an entirely new completion system. It is similar to Ido, but lighter and, apparently, easier to extend. In fact, what really took over my Helm configuration is Counsel, a set of functions based upon Ivy.

Ok, enough with the talking, here's my setup:

Code: Select all

(use-package swiper                     ; Isearch with an overview
  :ensure t
  :bind ("C-s" . swiper))

(use-package ivy                        ; Incremental Vertical completYon
  :ensure swiper
  :bind (("C-c C-r" . ivy-resume)
         ("C-x C-r" . ivy-switch-buffer))
  :init (ivy-mode 1)
  :config
  (progn
    ;; Show recently killed buffers when calling `ivy-switch-buffer'
    (setq ivy-use-virtual-buffers t
          ivy-count-format ""           ; Do not show counter
          ivy-virtual-abbreviate 'full  ; Show full file path
          ivy-re-builders-alist '((t . ivy--regex-plus))))
  :diminish ivy-mode)

(use-package counsel                    ; Completion functions with Ivy
  :ensure t
  :bind (("C-x C-f" . counsel-find-file)
         ("M-x"     . counsel-M-x)
         ("C-h v"   . counsel-describe-variable)
         ("C-h f"   . counsel-describe-function)
         ("C-h S"   . counsel-info-lookup-symbol)
         ("C-c u"   . counsel-unicode-char)
         ("C-c g"   . counsel-git)
         ("C-c G"   . counsel-git-grep)
         ("C-c k"   . counsel-ag)
         ("C-x l"   . counsel-locate)
         ("C-x i"   . counsel-imenu)
         ("M-y"     . counsel-yank-pop))
  :config
  (progn
    (setq counsel-find-file-at-point t
          counsel-find-file-ignore-regexp
          (concat
           ;; file names beginning with # or .
           "\\(?:\\`[#.]\\)"
           ;; file names ending with # or ~
           "\\|\\(?:\\`.+?[#~]\\'\\)"))

    (ivy-set-actions
     'counsel-find-file
     `(("x"
        (lambda (x) (delete-file (expand-file-name x ivy--directory)))
        ,(propertize "delete" 'face 'font-lock-warning-face))))))
As you can see, Counsel provides functions for find-files and your friend M-x. I've just setup this thingy (I made the setup above last night), and I plan to use it for a week before deciding if Helm is my saviour or not.

As reference, this answer by swiper/ivy/counsel's author got me into trying his packages out: https://www.reddit.com/r/emacs/comments ... oo/d05pdow

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: Emacs tips and tricks

Unread post by franksinistra » Mon Feb 22, 2016 7:42 am

Been trying ivy, and still figuring out how to create the same environment helm-ag does. Thanks for the tip GP
rice no more.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Mon Feb 22, 2016 4:08 pm

^ What does helm-ag do more than plain ag.el? I'm asking because I used to have both of them installed but ag.el works so good for me I completely forgot about helm-ag.

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: Emacs tips and tricks

Unread post by franksinistra » Mon Feb 22, 2016 4:49 pm

Support for other backends (i use pt in some of my faster machine), ah and i am pretty used to 'helm-do-yadda-yadda' that not having them feels kinda weird... But yeah, you're right. I can live without them anyway, for the sake of simpler thing. I had 22 helm-* packages installed (yeah i know), now i have 4 ivy related packages, so.... Cool
rice no more.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Mon Feb 22, 2016 4:51 pm

^ Exactly! I have removed all helm-* packages from my setup. I know Ivy/Counsel is still young and not as powerful as Helm, but for my daily workflow is enough. Plus, the GUI is really a winner for me.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Wed Feb 24, 2016 10:40 am

I've been using this workflow lately when I need to refactor different files quickly: https://emacs.stackexchange.com/a/243/5514
It combines ag.el, wgrep-ag and multiple-cursors. It is really a blessing, saves me so much time.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Thu Mar 03, 2016 9:58 am

Almost 2 weeks without Helm and I can honestly say I'm not missing it: Ivy and Counsel are just what I need.

It's also easy to use Ivy for your own needs. For instance, I love having Eshell history ready to browse. I used to do it with Helm, and now with Ivy:

Code: Select all

(defun mu-counsel-esh-history ()
      "Browse Eshell history."
      (interactive)
      (setq ivy-completion-beg (point))
      (setq ivy-completion-end (point))
      (ivy-read "Symbol name: "
                (delete-dups
                 (ring-elements eshell-history-ring))
                :action #'ivy-completion-in-region-action))

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Mon Mar 07, 2016 4:59 pm

Another neat feature of Swiper and Ivy.

When in Swiper, hit C-c C-o to run ivy-occur. Now, if you have wgrep install, you can use it to edit the multiple occurrences you were looking for in a dedicated buffer. Very nice.

To make it easier for my memory, I bound wgrep to the same bindings I use in Dired to turn a Dired buffer editable.

Code: Select all

(use-package wgrep                      ; Editable grep buffer
  :ensure t
  :defer t
  :config
  (progn
    (with-eval-after-load 'grep
      (bind-key "C-x C-q" #'wgrep-change-to-wgrep-mode grep-mode-map))

    (with-eval-after-load 'wgrep
      (bind-key "C-c C-c" #'wgrep-finish-edit grep-mode-map))))

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Wed Mar 09, 2016 3:40 pm

Looking for a replacement for Solarized Light, I found this: https://github.com/wasamasa/punpun-theme

I respect the author very much (he's the author of Emacs Horrors and Emacs Ninja), so I'm always eager to follow his new experiments. This minimal, simple theme might be a win for me.

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: Emacs tips and tricks

Unread post by franksinistra » Wed Mar 09, 2016 4:46 pm

Pretty good for monochrome looks, but i still prefer his gotham theme, especially under dark environment.
rice no more.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Wed Mar 09, 2016 4:55 pm

^ Yes, definitely a fine dark theme. Thing is my eyes (which are not that good) struggle with dark themes, especially after long sessions of editing and writing. I find light themes more comfortable. :-)

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: Emacs tips and tricks

Unread post by franksinistra » Fri Mar 11, 2016 2:45 am

^ Yup, it was the same reason that i moved from dark, low contrast anything to something a bit less so. I mainly use light themes at work, farmhouse, silkworm, and leuven have been my recent favorite, or my own majapahit if i were to use emacs in no-X.
rice no more.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Emacs tips and tricks

Unread post by machinebacon » Fri Mar 11, 2016 4:00 am

leuven here, too.
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Fri Mar 11, 2016 11:31 am

I know Leuven should work particularly well with Org, but I've never been happy with it.
One thing for sure: good light themes are hard to find.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Mon Mar 14, 2016 11:49 am

Got an error today about my package.el setup. This now works:

Code: Select all

(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '())
(package-initialize)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
             '("gnu" . "https://elpa.gnu.org/packages/"))
Don't know whether it can be helpful, maybe it's me playing cool with the bleeding edge and getting hurt.

Note aside: punpun-theme is now on MELPA. So I'm happy.

Post Reply