commit ce344ebf8f5165e68daa66f169d770f9d2d41742 parent 9d45d77f72c748573a51b45a7b2ff9b71bd9bb74 Author: Vincent Demeester <vincent@sbr.pm> Date: Mon, 19 Aug 2024 23:28:44 +0200 tools/emacs: add some view-mode stuff From http://yummymelon.com/devnull/enhancing-navigation-in-emacs-view-mode.html Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
M | tools/emacs/config/config-navigating.el | | | 31 | +++++++++++++++++++++++++++++++ |
1 file changed, 31 insertions(+), 0 deletions(-)
diff --git a/tools/emacs/config/config-navigating.el b/tools/emacs/config/config-navigating.el @@ -156,5 +156,36 @@ (dolist (cmd '(next-line previous-line forward-word backward-word scroll-up-command scroll-down-command)) (put cmd 'repeat-map 'buffer-navigation-map))) +(require 'view) + +(add-hook + 'view-mode-hook + (lambda () + (cond ((derived-mode-p 'org-mode) + (define-key view-mode-map (kbd "p") 'org-previous-visible-heading) + (define-key view-mode-map (kbd "n") 'org-next-visible-heading)) + ((derived-mode-p 'markdown-mode) + (define-key view-mode-map (kbd "p") 'markdown-outline-previous) + (define-key view-mode-map (kbd "n") 'markdown-outline-next)) + ((derived-mode-p 'html-mode) + (define-key view-mode-map (kbd "p") 'sgml-skip-tag-backward) + (define-key view-mode-map (kbd "n") 'sgml-skip-tag-forward)) + ((derived-mode-p 'python-mode) + (define-key view-mode-map (kbd "p") 'python-nav-backward-block) + (define-key view-mode-map (kbd "n") 'python-nav-forward-block)) + ((derived-mode-p 'emacs-lisp-mode) + (define-key view-mode-map (kbd "p") 'backward-sexp) + (define-key view-mode-map (kbd "n") 'forward-sexp)) + ((derived-mode-p 'makefile-mode) + (define-key view-mode-map (kbd "p") 'makefile-previous-dependency) + (define-key view-mode-map (kbd "n") 'makefile-next-dependency)) + ((derived-mode-p 'c-mode) + (define-key view-mode-map (kbd "p") 'c-beginning-of-defun) + (define-key view-mode-map (kbd "n") 'c-end-of-defun)) + (t + (define-key view-mode-map (kbd "p") 'scroll-down-command) + (define-key view-mode-map (kbd "n") 'scroll-up-command))))) + + (provide 'config-navigating) ;;; config-navigating.el ends here