From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Sexton Subject: Customising C-c C-c behaviour Date: Fri, 15 Jul 2011 00:07:42 +0000 (UTC) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:57962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhVwp-0007iK-BA for emacs-orgmode@gnu.org; Thu, 14 Jul 2011 20:08:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhVwo-0005f1-EA for emacs-orgmode@gnu.org; Thu, 14 Jul 2011 20:08:03 -0400 Received: from lo.gmane.org ([80.91.229.12]:47734) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhVwo-0005es-3I for emacs-orgmode@gnu.org; Thu, 14 Jul 2011 20:08:02 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QhVwf-0004VM-KR for emacs-orgmode@gnu.org; Fri, 15 Jul 2011 02:07:58 +0200 Received: from rp.young.med.auckland.ac.nz ([130.216.140.20]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Jul 2011 02:07:53 +0200 Received: from psexton by rp.young.med.auckland.ac.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Jul 2011 02:07:53 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi, I would like to customise the behaviour of C-c C-c on plain text (specifically I would like to make it alter the tags, as if the cursor were on the item header). A variable exists called org-ctrl-c-ctrl-c-hook, but if any function contained in that variable runs, it overrides all other C-c C-c behaviour. I want my customisation to only run if C-c C-c has nothing "more interesting" to do. Possibilities include: 1. Advising org-ctrl-c-ctrl-c. However it seems difficult to tell whether this function has "succeeded" from its return value, ie there doesn't seem to be any standard value returned when the command has succeeded. OTOH if it fails, it throws a simple error, which I could catch -- but then I would not know if the error I was handling was actually caused by something else going wrong in the depths of the function. This could be solved by altering org-ctrl-c-ctrl-c so it uses a specific, identifiable error symbol instead of 'error'. 2. Creating another variable called org-ctrl-c-ctrl-c-post-hook which runs after all other possibilities have failed, but just before org-ctrl-c-ctrl-c fails. Both options would be easy to implement. Option 1 just involves adding the following code: (put 'org-ctrl-c-ctrl-c-error 'error-message "C-c C-c can do nothing useful at this location") (put 'org-ctrl-c-ctrl-c-error 'error-conditions '(error org-ctrl-c-ctrl-c-error)) And changing the '(error ...' line at the end of org-ctrl-c-ctrl-c to: (signal 'org-ctrl-c-ctrl-c-error nil) This error is still a subtype of 'error' so it behaves the same, unless someone is specifically trying to catch it. Any thoughts, objections, or better ideas?