|
58 | 58 |
|
59 | 59 | (add-hook 'org-mode-hook (lambda () (run-hooks 'prelude-org-mode-hook))) |
60 | 60 |
|
| 61 | +(defun prelude-enable-org-mode-shift-bindings () |
| 62 | + "Enable windmove advice to use org-mode shift functions in org buffers." |
| 63 | + (interactive) |
| 64 | + (message "Prelude: Installing org-mode shift key bindings to superced windmove bindings") |
| 65 | + |
| 66 | +;; Advice to redirect windmove commands to org-mode functions in org buffers |
| 67 | +(defun ap/windmove-left-advice (orig-fun &rest args) |
| 68 | + "Use org-mode shift-left in org buffers, windmove-left elsewhere." |
| 69 | + (if (derived-mode-p 'org-mode) |
| 70 | + (org-shiftleft) |
| 71 | + (apply orig-fun args))) |
| 72 | + |
| 73 | +(defun ap/windmove-right-advice (orig-fun &rest args) |
| 74 | + "Use org-mode shift-right in org buffers, windmove-right elsewhere." |
| 75 | + (if (derived-mode-p 'org-mode) |
| 76 | + (org-shiftright) |
| 77 | + (apply orig-fun args))) |
| 78 | + |
| 79 | +(defun ap/windmove-up-advice (orig-fun &rest args) |
| 80 | + "Use org-mode shift-up in org buffers, windmove-up elsewhere." |
| 81 | + (if (derived-mode-p 'org-mode) |
| 82 | + (org-shiftup) |
| 83 | + (apply orig-fun args))) |
| 84 | + |
| 85 | +(defun ap/windmove-down-advice (orig-fun &rest args) |
| 86 | + "Use org-mode shift-down in org buffers, windmove-down elsewhere." |
| 87 | + (if (derived-mode-p 'org-mode) |
| 88 | + (org-shiftdown) |
| 89 | + (apply orig-fun args))) |
| 90 | + |
| 91 | +;; Apply advice to all windmove functions |
| 92 | +(advice-add 'windmove-left :around #'ap/windmove-left-advice) |
| 93 | +(advice-add 'windmove-right :around #'ap/windmove-right-advice) |
| 94 | +(advice-add 'windmove-up :around #'ap/windmove-up-advice) |
| 95 | +(advice-add 'windmove-down :around #'ap/windmove-down-advice)) |
| 96 | + |
61 | 97 | (provide 'prelude-org) |
62 | 98 |
|
63 | 99 | ;;; prelude-org.el ends here |
0 commit comments