prelude icon indicating copy to clipboard operation
prelude copied to clipboard

Org mode windmove disable

Open tesujimath opened this issue 1 year ago • 2 comments

Because of keybinding clash.

Fixes #1364


Before submitting the PR make sure the following things have been done (and denote this by checking the relevant checkboxes):

  • [X] The commits are consistent with our contribution guidelines
  • [X] You've updated the changelog (if adding/changing user-visible functionality)

Thanks!

tesujimath avatar Jan 13 '25 04:01 tesujimath

@tesujimath I have been trying this solution to have org mode shift keybindings take precedence over windmove:

;; Advice to redirect windmove commands to org-mode functions in org buffers
(defun ap/windmove-left-advice (orig-fun &rest args)
  "Use org-mode shift-left in org buffers, windmove-left elsewhere."
  (if (derived-mode-p 'org-mode)
      (org-shiftleft)
    (apply orig-fun args)))

(defun ap/windmove-right-advice (orig-fun &rest args)
  "Use org-mode shift-right in org buffers, windmove-right elsewhere."
  (if (derived-mode-p 'org-mode)
      (org-shiftright)
    (apply orig-fun args)))

(defun ap/windmove-up-advice (orig-fun &rest args)
  "Use org-mode shift-up in org buffers, windmove-up elsewhere."
  (if (derived-mode-p 'org-mode)
      (org-shiftup)
    (apply orig-fun args)))

(defun ap/windmove-down-advice (orig-fun &rest args)
  "Use org-mode shift-down in org buffers, windmove-down elsewhere."
  (if (derived-mode-p 'org-mode)
      (org-shiftdown)
    (apply orig-fun args)))

;; Apply advice to all windmove functions
(advice-add 'windmove-left :around #'ap/windmove-left-advice)
(advice-add 'windmove-right :around #'ap/windmove-right-advice)
(advice-add 'windmove-up :around #'ap/windmove-up-advice)
(advice-add 'windmove-down :around #'ap/windmove-down-advice)

Does this achieve the results you are looking for?

If so I can try to make a PR.

planetmcd avatar Aug 09 '25 19:08 planetmcd

I will try that, but not imminently sorry, am away from my computer. Thanks for posting!

tesujimath avatar Aug 09 '25 20:08 tesujimath