summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-03-04 12:16:30 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-03-04 14:01:57 -0700
commit0f824e06ba965fab95c842b893b9962a3a2587e7 (patch)
treeec2192f88f2002040499b3bc1099bb3de8305114
parent9be41ec856629f82c04b67c8a0257b729f972555 (diff)
downloaddotfiles-0f824e06ba965fab95c842b893b9962a3a2587e7.tar.gz
spw/scratch-paredit-mode: don't defer to higher priority minor modes
-rw-r--r--.emacs.d/init.el21
1 files changed, 15 insertions, 6 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index da0bdbea..85a828ce 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -4630,12 +4630,21 @@ likely to keep parentheses balanced."
keymap)
into))
(with-current-buffer (get-buffer-create "*scratch*")
- ;; Handle situation in which Paredit is somehow turned on too.
- ;; We don't need to turn the mode off because we know we are earlier in
- ;; `minor-mode-map-alist' as we require the `paredit' feature, and
- ;; `paredit-mode-map' is our parent, so lookup can't ever fail in our
- ;; map but then succeed in `paredit-mode-map'.
- (let (paredit-mode spw/scratch-paredit-mode)
+ (let (;; Bind `minor-mode-map-alist' such that our call to `key-binding'
+ ;; ignores the bindings of minor modes that have priority over us.
+ ;; This avoids an infinite loop if one of those minor modes wants
+ ;; to defer to our binding, e.g. in the way `orgtbl-mode' does.
+ (minor-mode-map-alist
+ (or (cdr
+ (cl-member 'spw/scratch-paredit-mode minor-mode-map-alist
+ :key #'car))
+ minor-mode-map-alist))
+ ;; Also ensure that `key-binding' ignores `paredit-mode-map'.
+ ;; We don't need to turn the mode off because we know we are
+ ;; earlier in `minor-mode-map-alist' as we require the `paredit'
+ ;; feature, and `paredit-mode-map' is our parent, so lookup can't
+ ;; ever fail in our map but then succeed in `paredit-mode-map'.
+ paredit-mode)
(let ((map (define-keys paredit-mode-map (make-sparse-keymap) [])))
(set-keymap-parent map paredit-mode-map)
map))))