unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Some feature requests.
@ 2007-03-31 14:04 Dmitry Galinsky
  0 siblings, 0 replies; only message in thread
From: Dmitry Galinsky @ 2007-03-31 14:04 UTC (permalink / raw)
  To: emacs-devel

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)

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

only message in thread, other threads:[~2007-03-31 14:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-31 14:04 Some feature requests Dmitry Galinsky

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).