From: Ihor Radchenko <yantar92@posteo.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Psionic K <psionik@positron.solutions>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: Delegating user-reserved key binding space definition to users
Date: Sat, 26 Nov 2022 06:44:09 +0000 [thread overview]
Message-ID: <877czikyfa.fsf@localhost> (raw)
In-Reply-To: <jwv5yf3jcc0.fsf-monnier+emacs@gnu.org>
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> The problem I'm working to reach is allowing packages to correctly shadow
>> the user's bindings (and not incorrectly shadow) instead of ad-hoc
>> imitation of the global map defaults. Ad-hoc imitation makes it very
>> tedious to, for instance, change the key sequence for expressing "next"
>> without losing coherence among all packages with a corresponding "next"
>> concept.
>
> I don't think anyone doubts that it's desirable.
> The question is how to get that.
I suggest introducing a notion of "generalized" commands. Such commands
will represent common actions executed by users (like move to
next/previous element). Major and minor modes can then define specific
implementation of the actions.
In terms of OOP, I am talking about virtual methods and major/minor modes
providing the implementations. The implementations will be chosen
according to the current major mode or maybe some other condition.
Default implementation (like `next-line') can also be provided.
The generalized commands can then be freely re-bound by users with
immediate effect on all the major modes.
An example (not very clean) implementation of this concept is available
at
https://github.com/yantar92/meta-functions/blob/master/meta-functions.el:
; Quick implementation of meta-functions, which allows running multiple
;; functions, which do similar logical operations by one single "meta"
;; function in different major modes. For example, one may want to define
;; meta-next-line to call `next-line' normally, but
;; `org-agenda-next-line' in org-agenda mode. Both can be bound to, say
;; "M-j", without a need to change the key-bindings on both fundamental
;; and org-agenda modes.
;; Example usage:
;; (use-package meta-functions
;; :config
;; (meta-defun meta-next-element ()
;; "Go to next element."
;; :mode org-agenda-mode (org-agenda-next-item 1) ; call org-agenda-next-item in org-agenda
;; :cond (lambda () (and (eq major-mode 'org-mode) (org-at-heading-p))) (org-next-visible-heading 1) ; call org-next-visible-headting when at heading in org-mode
;; (next-line)) ; call-next line in any other case
;; )
;; or the same can be written as
;; (meta-defun meta-next-element "Go to next element." next-line)
;; (meta-defun meta-next-element :mode org-agenda-mode (org-agenda-next-item 1))
;; (meta-defun meta-next-element :mode org-mode :cond org-at-heading-p (org-next-visible-heading 1))
;;
;; Similar packages:
;; https://gitlab.com/jjzmajic/handle implements similar functionality to unify functions across major modes
;; However, handle is very major-mode centric. meta-functions is more function-centric
;; Also, meta-functions is not only limited to current major mode defining which function to call.
--
Ihor Radchenko // yantar92,
Org mode contributor,
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>
next prev parent reply other threads:[~2022-11-26 6:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 14:40 Delegating user-reserved key binding space definition to users Psionic K
2022-11-21 19:37 ` Stefan Monnier
2022-11-22 2:07 ` Phil Sainty
2022-11-25 2:48 ` Psionic K
2022-11-25 3:31 ` Ihor Radchenko
2022-11-25 13:53 ` xenodasein--- via Emacs development discussions.
2022-11-25 15:16 ` Stefan Monnier
2022-11-26 6:44 ` Ihor Radchenko [this message]
2022-11-26 17:29 ` Stefan Monnier
2022-11-27 5:45 ` Ihor Radchenko
2022-11-27 11:26 ` Psionic K
2022-11-27 11:53 ` Psionic K
2022-11-28 18:15 ` Stefan Monnier
2022-11-28 18:37 ` Eli Zaretskii
2022-11-29 2:38 ` Psionic K
2022-11-29 4:01 ` Stefan Monnier
2022-11-29 5:22 ` Psionic K
2022-11-29 13:03 ` Eli Zaretskii
2022-11-30 6:23 ` Psionic K
2022-11-30 9:01 ` xenodasein--- via Emacs development discussions.
2022-11-30 13:44 ` Eli Zaretskii
2022-11-29 11:54 ` John Yates
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877czikyfa.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=psionik@positron.solutions \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.