emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Paul Sexton <psexton@xnet.co.nz>
To: emacs-orgmode@gnu.org
Subject: Customising C-c C-c behaviour
Date: Fri, 15 Jul 2011 00:07:42 +0000 (UTC)	[thread overview]
Message-ID: <loom.20110715T015517-301@post.gmane.org> (raw)

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?

             reply	other threads:[~2011-07-15  0:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-15  0:07 Paul Sexton [this message]
2011-07-24 14:11 ` Customising C-c C-c behaviour Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20110715T015517-301@post.gmane.org \
    --to=psexton@xnet.co.nz \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).