[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Preventing successive remappings of a key?
From: |
Bastien |
Subject: |
Preventing successive remappings of a key? |
Date: |
Tue, 08 Sep 2020 18:55:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
For example, org-mode performs this remapping (in org-keys.el):
(org-remap org-mode-map
'kill-line 'org-kill-line
'move-beginning-of-line 'org-beginning-of-line
'move-end-of-line 'org-end-of-line)
... and a few more in fact. Also, simple.el have this:
(defvar visual-line-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [remap kill-line] 'kill-visual-line)
(define-key map [remap move-beginning-of-line] 'beginning-of-visual-line)
(define-key map [remap move-end-of-line] 'end-of-visual-line)
map))
So, when a user opens an org buffer and calls M-x visual-line-mode RET
he finds himself with C-k bound to kill-visual-line while the behavior
of org-kill-line is safer, and might be the one he wants.
Is it possible to prevent the second remapping from happening?
I guess hardcoding fundamental keybindings is Forbidden™.
;;; DON'T DO THIS!
(org-defkey org-mode-map (kbd "C-a") #'org-beginning-of-line)
I can see these solutions:
- Tell the user to turn off visual-line-mode if he does not want the
second remapping.
- Have a mechanism for detecting successive remappings and an option
to let the user accept only one remapping, which would prevent the
visual-line-mode remapping in this case.
The first one feels non-emacsy, the second one too hackish (if even
possible), and I cannot seem to think of anything useful here.
Any idea?
--
Bastien
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Preventing successive remappings of a key?,
Bastien <=