[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] Customising C-c C-c behaviour
From: |
Paul Sexton |
Subject: |
[O] Customising C-c C-c behaviour |
Date: |
Fri, 15 Jul 2011 00:07:42 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.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?
- [O] Customising C-c C-c behaviour,
Paul Sexton <=