| 
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 supersede 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-shiftleft' in org buffers, ORIG-FUN with ARGS 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-shiftright' in org buffers, ORIG-FUN with ARGS 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-shiftup' in org buffers, ORIG-FUN with ARGS 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-shiftdown' in org buffers, ORIG-FUN with ARGS 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