From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Galinsky Newsgroups: gmane.emacs.devel Subject: Some feature requests. Date: Sat, 31 Mar 2007 18:04:19 +0400 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1175350220 27094 80.91.229.12 (31 Mar 2007 14:10:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 31 Mar 2007 14:10:20 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 31 16:10:13 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HXeHU-0003ab-VR for ged-emacs-devel@m.gmane.org; Sat, 31 Mar 2007 16:10:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HXeKJ-0004eG-1d for ged-emacs-devel@m.gmane.org; Sat, 31 Mar 2007 09:13:07 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HXeKF-0004Zp-JY for emacs-devel@gnu.org; Sat, 31 Mar 2007 10:13:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HXeKE-0004Xa-4e for emacs-devel@gnu.org; Sat, 31 Mar 2007 10:13:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HXeKE-0004XO-2L for emacs-devel@gnu.org; Sat, 31 Mar 2007 09:13:02 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HXeHP-0002qo-4I for emacs-devel@gnu.org; Sat, 31 Mar 2007 10:10:07 -0400 Original-Received: from root by ciao.gmane.org with local (Exim 4.43) id 1HXeHK-0001I5-Bf for emacs-devel@gnu.org; Sat, 31 Mar 2007 16:10:02 +0200 Original-Received: from 89.184.226.84 ([89.184.226.84]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 31 Mar 2007 16:10:02 +0200 Original-Received: from dima.exe by 89.184.226.84 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 31 Mar 2007 16:10:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 94 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 89.184.226.84 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 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:68837 Archived-At: 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)