Skip to content

Instantly share code, notes, and snippets.

@magnars
Forked from joshwnj/goto-line-with-feedback.el
Created August 8, 2012 06:42
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save magnars/3292872 to your computer and use it in GitHub Desktop.
Save magnars/3292872 to your computer and use it in GitHub Desktop.
Emacs: Show line numbers temporarily, while prompting for the line number input
;; turn line numbers off by default
(global-linum-mode -1)
(defun goto-line-with-feedback (&optional line)
"Show line numbers temporarily, while prompting for the line number input"
(interactive "P")
(if line
(goto-line line)
(unwind-protect
(progn
(linum-mode 1)
(goto-line (read-number "Goto line: ")))
(linum-mode -1))))
;; bind to specific key
(global-set-key (kbd "C-l") 'goto-line-with-feedback)
;; or replace all goto-line
(global-set-key (vector 'remap 'goto-line) 'goto-line-with-feedback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment