unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to handle both minor mode and major mode remapping a command? (was: Bug: org-kill-line shouldn't assume visual-line-mode means kill-visual-line)
       [not found] <CAO8RVvdAJg-RqXMmBCzyAQiLhXRm=KehJsk7x-aGnee6EGRB8A@mail.gmail.com>
@ 2024-12-15 10:48 ` Ihor Radchenko
  0 siblings, 0 replies; only message in thread
From: Ihor Radchenko @ 2024-12-15 10:48 UTC (permalink / raw)
  To: Nathan Collins; +Cc: emacs-orgmode, emacs-devel

Hi,

We have the following situation in Org mode:

1. Org mode remaps `kill-line' to `org-kill-line'
2. `org-kill-line' performs special action when point is on a heading
   and otherwise falls back to `kill-line'
3. visual-line-mode, if active, sets up minor mode map remapping
   `kill-line' to `kill-visual-line'

In the past, activating `visual-line-mode' caused Org mode binding to be
completely shadowed.

Later, we tried to fix the problem by
1. Overriding `visual-line-mode' remapping by force
2. Hard-coding a special case for `visual-line-mode' to call
   `kill-visual-line' instead of `kill-line' as a fallback in
   `org-kill-line'

However, the situation is not ideal.
Below is a recent bug report where user changed the default
remapping in `visual-line-mode-map' to something else (not considered by
Org)

I am wondering if there is some canonical way to handle similar scenarios
recommended for major modes.

Any suggestions?

Nathan Collins <nathan.collins@gmail.com> writes:

> Hello,
>
> In the latest version of org.el, at line 21367 [1], inside `defun
> org-kill-line`, we have
>
>      (if (bound-and-true-p visual-line-mode) 'kill-visual-line 'kill-line)))
>
> but I think instead this should just call whatever `kill-line` is
> bound to in `visual-line-mode-map`. By default, `visual-line-mode-map`
> remaps `kill-line` to `kill-visual-line`, but I remove this remap
> because I prefer the default `C-k` behavior. But in org-mode, I can't
> figure out a way to disable this behavior of `org-kill-line`, except
> by removing org-mode's remap of `kill-line` to `org-kill-line`, which
> loses the other fancy logic of `org-kill-line`.
>
> Cheers,
>
> -nathan
>
> [1]: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org.el#n213667
>

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-15 10:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAO8RVvdAJg-RqXMmBCzyAQiLhXRm=KehJsk7x-aGnee6EGRB8A@mail.gmail.com>
2024-12-15 10:48 ` How to handle both minor mode and major mode remapping a command? (was: Bug: org-kill-line shouldn't assume visual-line-mode means kill-visual-line) Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).