Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; If the buffer is narrowed, the normal mapping of M-g g calls
- ;; `goto-line', which widens the buffer. Default behavior reguires the
- ;; user to remember to call `goto-line-relative'. This function honors
- ;; narrowing, if in place. Binding to M-g g lets the user have normal
- ;; work flow without being concerned with narrow/wide status.
- (defun goto-line-dwim (line)
- "Go to line, do what I mean. Call `goto-line' or
- `goto-line-relative', depending on whether the buffer is narrowed
- or not."
- (interactive "p")
- (call-interactively
- (if (not (buffer-narrowed-p))
- #'goto-line
- #'goto-line-relative)))
- (global-set-key (kbd "M-g g") #'goto-line-dwim)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement