Created
August 8, 2012 06:19
-
-
Save joshwnj/3292750 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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) | |
(progn | |
(linum-mode 1) | |
(let ((line (read-number "Line: "))) | |
(goto-line line)) | |
(linum-mode -1)))) | |
(global-set-key (kbd "C-l") 'goto-line-with-feedback) |
You can use unwind-protect:
(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)
(let ((line (read-number "Line: ")))
(goto-line line)))
(linum-mode -1))))
@pragdave Why are you using linum-mode
, instead of the built-in line numbers that Eli Z. implemented starting from Emacs 26 and forwards? linum-mode
is officially deprecated. The replacement is display-line-numbers-mode
/ global-display-line-numbers-mode
: https://www.gnu.org/software/emacs/manual/html_node/emacs/Display-Custom.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To do: