Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### New features

- [PR 1443] (https://github.com/bbatsov/prelude/pull/1443): Add user configuration for `org-mode` specfic `S-[arrow]` bindings.
- [PR 1432](https://github.com/bbatsov/prelude/pull/1432): Allow directories of custom Emacs Lisp files in `personal/preload`.
- Enable `org-habits`.
- Neatly track `TODO` state changes in a drawer (LOGBOOK), thereby improving readability.
Expand Down
16 changes: 16 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,19 @@ to disable this behaviour, set the following variable to nil before loading prel
```emacs-lisp
(setq prelude-override-package-user-dir nil)
```

### Enable org-mode shift arrow Keybindings

By default, windmove keybindings take precedence for binding to the S+[arrow] keys.
Org-mode keybindings are overridden. This is a [know issue][1] described in org-mode's
manual.

[1]: https://orgmode.org/manual/Conflicts.html

To have org-mode S+[arrow key] keybindings in org buffers, add this to your configs:

```lisp
(prelude-enable-org-mode-shift-bindings)
```

Other buffers should continue to be bound to windmove keybindings.
12 changes: 12 additions & 0 deletions docs/modules/orgmode.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ It establishes a few extra keybidings:
- `C-c a` (`org-agenda`)
- `C-c b` (`org-switchb`)

### Shift-arrow keybinding conflicts

Windmove arrow keybindings are the defualt for Prelude, but org-mode has some
specific bindings for ath S-[arrow keys].

If a user adds the following code, org-mode buffers will have standard org-mode
bindings, but other buffers will use windmove bindings.

```lisp
(prelude-enable-org-mode-shift-bindings)
```

## org-habits

It enables [org-habits](https://orgmode.org/manual/Tracking-your-habits.html "org-habits") and [tracks TODO state changes](https://orgmode.org/manual/Tracking-TODO-state-changes.html "todo-state-changes") into a
Expand Down
36 changes: 36 additions & 0 deletions modules/prelude-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,42 @@

(add-hook 'org-mode-hook (lambda () (run-hooks 'prelude-org-mode-hook)))

(defun prelude-enable-org-mode-shift-bindings ()
"Enable `windmove' advice to use `org-mode' shift functions in org buffers."
(interactive)
(message "Prelude: Installing org-mode shift key bindings to supersede windmove bindings")

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

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

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

(defun ap/windmove-down-advice (orig-fun &rest args)
"Use `org-shiftdown' in org buffers, ORIG-FUN with ARGS 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))

(provide 'prelude-org)

;;; prelude-org.el ends here