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

* Re: Customising C-c C-c behaviour
  2011-07-15  0:07 Customising C-c C-c behaviour Paul Sexton
@ 2011-07-24 14:11 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2011-07-24 14:11 UTC (permalink / raw)
  To: Paul Sexton; +Cc: emacs-orgmode

Hi Paul,

Paul Sexton <psexton@xnet.co.nz> writes:

> 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. 

I've taken this road, and pushed this change in git.  

Except that I called the hook `org-ctrl-c-ctrl-c-post-hook' to 
match other hooks names like `org-shiftup-final-hook'.

Let me know if it works for you!

Thanks for this idea,

-- 
 Bastien

^ 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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).