emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Customising C-c C-c behaviour
@ 2011-07-15  0:07 Paul Sexton
  2011-07-24 14:11 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Sexton @ 2011-07-15  0:07 UTC (permalink / raw)
  To: emacs-orgmode

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?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-07-24 19:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-15  0:07 Customising C-c C-c behaviour Paul Sexton
2011-07-24 14:11 ` Bastien

Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).