about summary refs log tree commit diff stats
path: root/.emacs.d/lisp
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2023-11-11 13:34:29 +0000
committerDavid Morgan <djm_uk@protonmail.com>2023-11-11 13:34:29 +0000
commit3f288c5c2bbcba1ebdb478bd67c1366045679037 (patch)
tree1ab88d0156c43f03821240ac1d17e2c4ae4ef1b4 /.emacs.d/lisp
parentf9bedbaff6992c29a4c65d591cfbfe916df5afcd (diff)
downloaddotfiles-3f288c5c2bbcba1ebdb478bd67c1366045679037.tar.gz
Add view-mode config
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r--.emacs.d/lisp/init-ui.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/.emacs.d/lisp/init-ui.el b/.emacs.d/lisp/init-ui.el
index cb3d05b..297540a 100644
--- a/.emacs.d/lisp/init-ui.el
+++ b/.emacs.d/lisp/init-ui.el
@@ -20,6 +20,32 @@
 
                          (add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
                          (load-theme 'non-modo t)))
+  ;; http://yummymelon.com/devnull/enhancing-navigation-in-emacs-view-mode.html
+  (view-mode . (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 'emacs-lisp-mode)
+                        (define-key view-mode-map (kbd "p") 'backward-sexp)
+                        (define-key view-mode-map (kbd "n") 'forward-sexp))
+                       ((derived-mode-p 'clojure-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)))))
   :config
   ;; https://github.com/rougier/elegant-emacs/blob/master/sanity.el
   (setq inhibit-startup-screen t