Skip to content

Instantly share code, notes, and snippets.

@magnars
Created April 10, 2012 10:50
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save magnars/2350388 to your computer and use it in GitHub Desktop.
Save magnars/2350388 to your computer and use it in GitHub Desktop.
Push mark when using ido-imenu
;; Push mark when using ido-imenu
(defvar push-mark-before-goto-char nil)
(defadvice goto-char (before push-mark-first activate)
(when push-mark-before-goto-char
(push-mark)))
(defun ido-imenu-push-mark ()
(interactive)
(let ((push-mark-before-goto-char t))
(ido-imenu)))
@magnars
Copy link
Author

magnars commented Apr 11, 2012

It turns out that the ido-imenu command in use in the screencast is not in Emacs 24. I have no idea where it came from either, but here's the code for that aswell: https://gist.github.com/2360578

@blais
Copy link

blais commented Aug 19, 2012

Why not just advice ido-imenu?

  (defadvice ido-imenu (before push-mark activate)
    (push-mark))

@kini
Copy link

kini commented Nov 21, 2016

Good question -- isn't advicing goto-char a bit risky performance-wise since it's called by so much other code, even non-interactive code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment