1

how can one teach emacs to do something useful here?

for example if the current line contains the word "FOO" anywhere, change it to whatever the string returned by special-lisp-function-001

enter image description here

8

You can attach something to org-ctrl-c-ctrl-c-final-hook:

Hook for functions attaching themselves to ‘C-c C-c’.

This can be used to add additional functionality to the C-c C-c key which executes context-dependent commands. This hook is run after any other test, while ‘org-ctrl-c-ctrl-c-hook’ is run before the first test.

To add something to a hook, we use add-hook:

(add-hook 'org-ctrl-c-ctrl-c-final-hook
          (lambda () (message "yeah, you got \"%s\"" (word-at-point))
            t))

Now, when you press C-c C-c, and org has no other action for the place that point is at, it'll send a message in the minibuffer. Obviously you can change this as necessary.

Note that we explicitly return a non-nil value so that org-ctrl-c-ctrl-c knows to stop running other functions in org-ctrl-c-ctrl-c-final-hook once we hit this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.