From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Re: [REQUEST] orgtbl-ctrl-c-ctrl-c-hook Date: Wed, 17 Nov 2010 10:30:09 +0100 Message-ID: References: <2F4D54FD-C457-4372-8871-2F1A022FF082@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=50444 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PIeLM-0002hv-Od for emacs-orgmode@gnu.org; Wed, 17 Nov 2010 04:30:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIeLE-0004fU-Tn for emacs-orgmode@gnu.org; Wed, 17 Nov 2010 04:30:19 -0500 Received: from mail-ew0-f41.google.com ([209.85.215.41]:33141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PIeLE-0004f5-NR for emacs-orgmode@gnu.org; Wed, 17 Nov 2010 04:30:12 -0500 Received: by ewy25 with SMTP id 25so958295ewy.0 for ; Wed, 17 Nov 2010 01:30:11 -0800 (PST) In-Reply-To: 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: Seweryn Kokot Cc: emacs-orgmode@gnu.org Hi Seweryn, On Nov 17, 2010, at 10:10 AM, Seweryn Kokot wrote: > Carsten Dominik gmail.com> writes: > >> >> >> On Nov 17, 2010, at 9:19 AM, Seweryn Kokot wrote: >> >>> Hi, >>> >>> It need to attach a function to C-c C-c keybinding when exporting a >>> table in >>> orgtbl-mode so would be nice to have orgtbl-ctrl-c-ctrl-c-hook >>> similar to >>> org-ctrl-c-ctrl-c-hook. >> >> This is a reasonable request - please make me a patch. > > See the following patch. It seems to work in my case, but please > correct it if > necessary because I don't know if (run-hook-with-args-until-success > 'orgtbl- > ctrl-c-ctrl-c-hook) line is in the right place. > > Regards, > Seweryn > > --- h:/org-mode/lisp/org-table.el 2010-11-16 11:17:36.000000000 +0100 > +++ h:/org-mode/lisp/org-table-new.el 2010-11-17 10:07:34.000000000 > +0100 > @@ -48,6 +48,15 @@ > (defvar org-export-html-table-tag) ; defined in org-exp.el > (defvar constants-unit-system) > > +(defvar orgtbl-ctrl-c-ctrl-c-hook nil > + "Hook for functions attaching themselves to `C-c C-c'. > +This can be used to add additional functionality to the C-c C-c key > which > +executes context-dependent commands. > +Each function will be called with no arguments. The function must > check > +if the context is appropriate for it to act. If yes, it should do > its > +thing and then return a non-nil value. If the context is wrong, > +just do nothing and return nil.") > + > (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized) > "Non-nil means use the optimized table editor version for `orgtbl- > mode'. > In the optimized version, the table editor takes over all simple > keys that > @@ -3729,7 +3738,8 @@ > (call-interactively 'org-table-recalculate) > (org-table-maybe-recalculate-line)) > (call-interactively 'org-table-align) > - (orgtbl-send-table 'maybe)) > + (orgtbl-send-table 'maybe) > + (run-hook-with-args-until-success 'orgtbl-ctrl-c-ctrl-c-hook)) > ((eq action 'recalc) > (save-excursion > (beginning-of-line 1) I am a bit confused by this patch. You do call the hook after C-c C-c has done its thing. Which is OK, but this is not what the documentation in your hook variable says. That documentation seems to have been copied from the normal ctrl-c-ctrl-c hook, and these hooks are used in a different way: They establish *alternative* functionality to the normal C-c C-c actions. So if any of the hook functions returns a non-nil value, the normal C-c C-c functionality will *not* be executed. So what are your true intentions, and can you make code and documentation macht up? Thanks - Carsten > > , and finished. Wed Nov 17 10:08:00 2010 > > > > _______________________________________________ > 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