Emacs: M-y as helm-show-kill-ring

This entry is part 1 of 4 in the series Emacs Kaizen

After realizing that I barely scratched the surface of Helm’s awesomeness (really, I basically use it as an ido-vertical-mode), I made a concerted effort to explore more of the interesting things in the Helm toolkit. helm-show-kill-ring is one such thing. I’ve bound it to M-y, which I had previously configured to be browse-kill-ring, but helm-show-kill-ring is much cooler because it makes it easy to dynamically filter your kill ring. Also, Kcode>M-y works better for me than C-y does because I know when I want the last thing I killed, but going beyond that is a little annoying.

That said, browse-kill-ring does make it easy to edit a kill ring entry. Maybe I should learn how to modify Helm’s behaviour so that I can add an edit action. There’s already a delete action. Besides, I haven’t used that feature in browse-kill-ring yet, so I can probably get by even without it.

ido fans: you can use helm-show-kill-ring without activating helm-mode, if you want.

On a related note, I like how rebinding M-x (execute-extended-comand) to helm-M-x shows me keybindings as I search for commands. You do have to get used to the quirk of typing C-u and other prefixes after M-x instead of before, but I haven’t had a problem with this yet. This is mostly because I haven’t dug into just how many commands do awesome things when given a prefix argument. I know about using C-u C-c C-w (org-refile) to jump to places instead of refiling notes, but that’s about it. I haven’t gone anywhere close to C-u C-u. Does anyone have a favourite command they use that does really smart things when given that prefix? =)

This Helm intro has animated GIFs and a few other useful commands. Check it out!

Series Navigation« Emacs kaizen: ace-jump-zap lets you use C-u to zap to any characterEmacs kaizen: helm-swoop and editing »
  • mbork

    Two examples of useful C-u C-u, off the top of my head: org-capture and my own switch-bury-or-kill-buffer (see http://mbork.pl/2014-04-04_Fast_buffer_switching_and_friends).

    And, what is it about helm/ido that Icicles doesn’t have?

    • mbork

      Also, magit-status.

    • I hadn’t noticed that org-capture had such useful C-u and C-u C-u behaviours. Thanks! I often find myself wanting to go to my current journal note, so C-u C-u will come in handy.

      I haven’t used Icicles enough to tell you what the significant differences are, but maybe someone else can! =)

    • NoonianAtall

      I used to use Icicles, but one look at its emacswiki page is enough to send anyone running, I think. Trying to understand and configure it is nearly an unsurmountable task.

      But helm is quick and easy to use by comparison, and yet very powerful. If you’ve mastered Icicles, maybe you won’t see the point in switching (though I don’t know if Icicles can do /everything/ Helm does), but otherwise, you should give it a try. :)

    • I hadn’t noticed that org-capture had such useful C-u and C-u C-u behaviours. Thanks! I often find myself wanting to go to my current journal note, so C-u C-u will come in handy.

      I haven’t used Icicles enough to tell you what the significant differences are, but maybe someone else can. =)

      • NoonianAtall

        I’m sure you could make this yourself, but just in case you might find this useful, here’s what I use to jump to the current date in my log.org datetree file (too bad about the formatting :( ):

        ;; Go to current day in datetree
        (defun me/org-goto-current-datetree-entry ()
        (interactive)
        (me/start-org-if-necessary)
        (switch-to-buffer “log.org”)
        (org-set-startup-visibility)

        ;; This doesn’t reveal the node
        (org-datetree-find-date-create (list (string-to-number (format-time-string “%m”))
        (string-to-number (format-time-string “%d”))
        (string-to-number (format-time-string “%Y”))))
        (org-reveal ‘(4))
        (org-cycle))
        (global-set-key (kbd “”) ‘me/org-goto-current-datetree-entry)

        (defun me/start-org-if-necessary ()
        “If the ‘main.org’ buffer isn’t open, open the agenda, which will cause all the agenda buffers to load.”
        (when (not (get-buffer “main.org”))
        (org-agenda-list)))

        • NoonianAtall: Oh! So I tried out C-u org-capture to jump to the appropriate part of my date-tree. Then I switched to using :unnarrowed t as part of my org-capture-templates entry for the journal, which was even more convenient. =) So I don’t need to use a special function to navigate to a datetree, since org-capture takes care of that for me.

  • xoo

    there’s also helm-mark-ring

    • I have C-x c SPC as helm-all-mark-rings which looks really useful, but M-x helm-mark-ring just prompts for a pattern and then doesn’t seem to do anything. I’m probably missing something here! =)

    • I have C-x c SPC as helm-all-mark-rings which looks really useful, but M-x helm-mark-ring just prompts for a pattern and then doesn’t seem to do anything. I’m probably missing something here! =)

  • Helllo

    C-u C-SPC
    C-u C-CPC C-SPC C-SPC…

    • Helllo: Ah yes, pop-to-mark-command with set-mark-command-repeat-pop set to non-nil!

    • Helllo: Ah yes, pop-to-mark-command with set-mark-command-repeat-pop set to non-nil. That one’s handy. =)

  • RafaelGP

    If you’re looking for more Helm’s awesomeness, don’t miss “helm-apropos”
    It allows you to search dynamically Commands, Functions, Variables and Faces. All at once!
    One command to rule them all:
    – apropos-command
    – describe-function
    – describe-variable
    – describe-font

    • RafaelGP: Indeed! I’ve bound that to C-h a.

    • RafaelGP: Indeed! I’ve bound that to C-h a.

  • NoonianAtall

    Sacha, I’ve been using Helm and even helm-show-kill-ring for a while now…but somehow it never hit me that that means I can filter the kill ring candidates, just like everything else in Helm. *facepalm* Right under my nose! :D

    • I know, right! Just the other week, I found out that helm-swoop is editable. And it even says so, right there.

    • I know, right! Just the other week, I found out that helm-swoop is editable. And it even says so, right there.

      • NoonianAtall

        …You just did it again. :) (Though I think I vaguely recall reading about that ability when I first learned about Helm…but then immediately forgot about it.) This is really neat when used with iedit-mode, almost like a lightweight refactoring mode.

        I just wish that Helm were a bit easier to expand on. For an elisp newbie like me, trying to follow the Helm code and figure out how to add my own files source is…well, I haven’t succeeded, yet, haha.

        • NoonianAtall: I haven’t even tried adding sources yet. I’ll get to that someday. =)

  • Kyle

    I recently started using registers to store my window configuration after I discovered helm-registers to view and filter them. I was afraid of registers because they were invisible.

  • > And, what is it about helm/ido that Icicles doesn’t have?

    Many 3rd party packages use Helm/Ido. I tried Icicles long ago, but performance is the that prevented me to use it. When you have like 50 packages, M-x with Icicles starts getting slow. It gets worse the more packages you have.

    With Helm, it’s fast. I can filter from even one hundred thousand candidates easily (i.e. I once enabled Projectile with my home directory). And it has Projectile integration: http://tuhdo.github.io/helm-projectile.html

    With Helm, it does not hide anything. With stock Emacs, if you have something to complete, you have to press TAB to get the list. Helm always makes it visible by showing you in a nice menu without doing anything.

    Helm has cool 3rd party packages like `helm-grep/ack/ag` that provides interactive ag, see results as you type. This is only available in Helm and nowhere else.

  • summaminutiae

    Thanks for this! I used to have M-y bound to some kill-ring list thing and lost it somewhere along the way. This is even better that the one I used to use.