From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Re: [BABEL] Speed keys Date: Tue, 21 Sep 2010 14:36:44 +0200 Message-ID: <397180EF-5C84-4D4B-A163-1D4A1B4AB089@gmail.com> References: <814oe53co3.fsf@gmail.com> <8762yleei5.fsf@gmail.com> <81vd6iqy43.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=47265 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy25o-0005He-5D for emacs-orgmode@gnu.org; Tue, 21 Sep 2010 08:37:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oy25i-0006p0-Gi for emacs-orgmode@gnu.org; Tue, 21 Sep 2010 08:37:04 -0400 Received: from mail-ey0-f169.google.com ([209.85.215.169]:39094) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oy25i-0006oj-3r for emacs-orgmode@gnu.org; Tue, 21 Sep 2010 08:36:58 -0400 Received: by eyh5 with SMTP id 5so2393528eyh.0 for ; Tue, 21 Sep 2010 05:36:57 -0700 (PDT) In-Reply-To: <81vd6iqy43.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Jambunathan K , Eric Schulte Cc: emacs org-mode mailing list Hi Eric, could I ask you to take a look at this? Thanks - Carsten On Sep 7, 2010, at 12:57 AM, Jambunathan K wrote: > >>> Is it possible Speed Keys (Refer Org Manual - Sec. 15.3) for Babel >>> blocks? > > Attached patch extends the speed key functionality. > > Usage notes: > > After applying the patch, use variant-1 or variant-2 to enable speed > keys within a babel block. > > variant-1: > > (defun org-babel-speed-command-hook (keys) > (when (org-babel-where-is-src-block-head) > (cdr (assoc keys org-babel-key-bindings)))) > > variant-2: > > (defun org-babel-speed-command-hook (keys) > (when (and (bolp) (looking-at org-babel-src-block-regexp)) > (cdr (assoc keys org-babel-key-bindings)))) > > (add-hook 'org-speed-command-hook 'org-babel-speed-command-hook > 'append) > > > Use this hook with caution. > > (defun org-speed-command-catch-all-hook (keys) > 'ignore) > > (add-hook 'org-speed-command-hook 'org-babel-speed-command-hook > 'append) > > Jambunathan K. > > > From 2fca952e923d44bec554b8b4e7dafc355e068f32 Mon Sep 17 00:00:00 2001 > From: Jambunathan K > Date: Tue, 7 Sep 2010 04:01:16 +0530 > Subject: [PATCH 2/2] Support for user-extensible speed commands. > > * lisp/org.el (org-speed-command-hook): New. Hook for installing > additional speed commands. Use this for enabling speed commands on > src blocks. > (org-speed-command-default-hook): The default hook for > org-speed-command-hook. Factored out from org-self-insert-command > and mimics existing behaviour. > (org-self-insert-command): Modified to use org-speed-command-hook. > > TINYCHANGE. > --- > lisp/org.el | 38 +++++++++++++++++++++++++++++++------- > 1 files changed, 31 insertions(+), 7 deletions(-) > > diff --git a/lisp/org.el b/lisp/org.el > index 09281cc..ead91a3 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -16494,6 +16494,34 @@ If not, return to the original position and > throw an error." > > (defvar org-table-auto-blank-field) ; defined in org-table.el > (defvar org-speed-command nil) > + > +(defun org-speed-command-default-hook (keys) > + "Hook for activating single-letter speed commands. > +`org-speed-commands-default' specifies a minimal command set. Use > +`org-speed-commands-user' for further customization." > + (when (or (and (bolp) (looking-at outline-regexp)) > + (and (functionp org-use-speed-commands) > + (funcall org-use-speed-commands))) > + (cdr (assoc keys (append org-speed-commands-user > + org-speed-commands-default))))) > + > +(defcustom org-speed-command-hook 'org-speed-command-default-hook > + "Hook for activating speed commands at strategic locations. > +Hook functions are called in sequence until a valid handler is > +found. > + > +Each hook takes a single argument, a user-pressed command key > +which is also a `self-insert-command' from the global map. > + > +Within the hook, examine the cursor position and the command key > +and return nil or a valid handler as appropriate. Handler could > +be one of an interactive command, a function, or a form. > + > +Set `org-use-speed-commands' to non-nil value to enable this > +hook. The default setting is `org-speed-command-default-hook'." > + :group 'org-structure > + :type 'hook) > + > (defun org-self-insert-command (N) > "Like `self-insert-command', use overwrite-mode for whitespace in > tables. > If the cursor is in a table looking at whitespace, the whitespace is > @@ -16501,13 +16529,9 @@ overwritten, and the table is not marked as > requiring realignment." > (interactive "p") > (cond > ((and org-use-speed-commands > - (or (and (bolp) (looking-at outline-regexp)) > - (and (functionp org-use-speed-commands) > - (funcall org-use-speed-commands))) > - (setq > - org-speed-command > - (or (cdr (assoc (this-command-keys) org-speed-commands-user)) > - (cdr (assoc (this-command-keys) org-speed-commands- > default))))) > + (setq org-speed-command > + (run-hook-with-args-until-success > + 'org-speed-command-hook (this-command-keys)))) > (cond > ((commandp org-speed-command) > (setq this-command org-speed-command) > -- > 1.7.0.4 > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode - Carsten