From: Dmitry Galinsky <dima.exe@gmail.com>
To: emacs-devel@gnu.org
Subject: Some feature requests.
Date: Sat, 31 Mar 2007 18:04:19 +0400 [thread overview]
Message-ID: <eulpp2$oj0$1@sea.gmane.org> (raw)
Hello,
I am developer of the emacs-rails, had arose some feature requests at
time of work.
== New event based management of key binding and hooks (like a
modern web-browser).
Will have replaced functions `define-key', `add-hook' to new equivalent:
---- code ---
(bind-event type value &optional basket position position-value
"Create a new event with
TYPE must be :key or :hook
VALUE
BASKET must be :pre, :default, :post
POSITION must be :bottom, :top, :after, :before")
(stop-event event
"Stop the EVENT processing")
---- code ---
and will have made the `event-struct'
---- code ---
(defstruct event-struct
type ; :key or :hook
value ; key code or hook
pre-basket ;
default-basket ;
post-basket ;)
---- code ---
Example, I had this ugly code:
---- code ---
(defun indent-or-complete ()
"Complete if point is at end of left a leave word, otherwise indent
line."
(interactive)
(cond
;; if inside snippet, do stuff
....
;; if available completion-ui, do stuff
....
;; if before point a word do hippie-expand
....
;; otherwise run default indent command
(t (indent-for-tab-command))))
(define-key "\t" 'indent-or-complete)
--- code ---
I could write it on another:
--- code ---
;; in any major mode
(bind-event :key "\t" 'indent)
;; in my setup file
(defun complete-snippet (event)
(when inside-a-snippet
...
(stop-event event))) ; stop the event processing
...
(bind-event :key "\t" 'complete-snippet :pre :bottom)
(bind-event :key "\t" 'complete-ui :pre :after 'complete-snippet)
(bind-event :key "\t" 'complete-abbrev :pre :after 'complete-ui)
--- code ---
Example of new event processing:
1. Run all functions in a 'pre-basket' list.
2. Run all functions in a 'default-basket' list.
3. Run all functions in a 'post-basket' list.
If called `stop-event' inside any event function, stop the processing of
this event, and can't run remaining functions.
The all special modes and user hacks put keys and hooks in :pre and
:post basket, all other put in :default basket.
== The new way solved some problems:
* Key redefinition and conflicts between major and minor modes.
* Stevey Yegge wrote "Some modes insist on re-binding Alt-r and Alt-s,
which is annoying, and I have a bunch of per-mode hacks to re-bind them,
but I don't have all modes covered."
To fix it (bind-event "M-r" :pre :bottom)
reply other threads:[~2007-03-31 14:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='eulpp2$oj0$1@sea.gmane.org' \
--to=dima.exe@gmail.com \
--cc=emacs-devel@gnu.org \
/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.