[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] bug? 'org-ctrl-c-ctrl-c-final-hook not run
From: |
Marco Wahl |
Subject: |
Re: [O] bug? 'org-ctrl-c-ctrl-c-final-hook not run |
Date: |
Sun, 17 Mar 2019 20:42:37 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
address@hidden (Thomas Plass) writes:
> This is a question for Org API users regarding
> 'org-ctrl-c-ctrl-c-final-hook and how it is to be understood.
>
> As per the docstring
>
> 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, ...
>
> should the 'message in the hook function below be executed?
>
> (add-hook 'org-ctrl-c-ctrl-c-final-hook
> (function (lambda ()
> (message "org-ctrl-c-ctrl-c-final-hook called from %s"
> (org-element-type (org-element-context)))
> t)))
>
> In fact, the hook isn't run at all, although it makes no assumptions
> whatsoever about its context.
Your hook runs if no other C-c C-c functionality jumped in. You could
apply C-c C-c at several locations in an Org buffer to see your hook in
action.
> Is this the way things are intended or is this behaviour a bug?
I guess this is intended. You can add functionality for C-c C-c for
locations which don't have C-c C-c functionality yet.
> What I'm trying to achieve is to post-process a standard Org element.
> However, my target element is already taken care of by one of the
> patterns in 'ctrl-c-ctrl-c, so the hook-caller is never reached.
Exactly.
> As a workaround, I take advantage of the rest of the above docstring
>
> ... while ‘org-ctrl-c-ctrl-c-hook’ is run before the first test.
>
> and add to this hook a function that recursively calls
> 'org-ctrl-c-ctrl-c before it does its own work - which seems
> incredibly kludgy.
Possibly it's a good idea to realize the implementation of your idea
independent of C-c C-c. And postpone the binding with C-c C-c.
HTH, ciao,
--
Marco