emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Some feature requests.


From: Dmitry Galinsky
Subject: Some feature requests.
Date: Sat, 31 Mar 2007 18:04:19 +0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.6) Gecko/20050317 Thunderbird/1.0.2 Mnenhy/0.7.2.0

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 via email to

[Prev in Thread] Current Thread [Next in Thread]