help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: post-command-hook to slow?


From: Thorsten Jolitz
Subject: Re: post-command-hook to slow?
Date: Thu, 05 Jun 2014 23:09:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

"Pascal J. Bourguignon" <address@hidden> writes:

> Thorsten Jolitz <address@hidden> writes:
>> […]
>>
>>  ,-----------------------
>>  | call-interactively cmd
>>  `-----------------------
>>
>> should quickly run cmd and post-command-hook before 
>>
>>  ,----------------------------------
>>  | copy-content-and-exit-temp-buffer
>>  `----------------------------------
>>
>> is executed - but apparently not. 
>
>
> I'm still not sure to understand exactly what you're trying, but if what
> you want is to have some function in post-command-hook to be called
> after you call-interactively cmd, perhaps you could just do that
> explicitely, since indeed, post-command-hooks won't be run while
> processing post-command-hooks.

Its a bit hard to explain, in fact I don't want to run a
post-command-hook, I just want to call an Org function in a temporary
buffer - but that function runs a post-command hook, and I have to deal
with that (it is somehow run too late, when the temp buffer is already
closed).

An MWE is difficult unless you are an Org user, but anyway:

Evaluate this in an emacs-lisp-mode buffer (without the
surrounding #+begin_ and #+end_ delimiters):

#+begin_src emacs-lisp
(setq org-todo-keywords
      (quote
       ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!/!)")
        (sequence
         "WAITING(w@/!)" "HOLD(h@/!)" "|"
         "CANCELLED(c@/!)" "PHONE"))))

(with-temp-buffer
  (org-mode)
  (insert "* Level 1\nSome Text\n")
  (org-todo)
  (message "%s" (buffer-substring-no-properties
     (point-min) (point-max))))
#+end_src

you should be prompted for a state, choose TODO first (t) and it should
 work.

Then evaluate 'with-temp-buffer again, this time chosing a state with an
 @ in its definition:

 "WAITING" or "HOLD" or "CANCELLED

because thats triggers taking a log note (and calling a
post-command-hook function).

You should get the error:

,-----------------------------------------------
| Error in post-command-hook (org-add-log-note):
| (error "Marker does not point anywhere")
`-----------------------------------------------

When you insert a message statement at the very beginning of
`org-add-log-note' that print current-buffer an major-mode, you will see
that its called in the emacs-lisp buffer and not in the temp buffer. 

-- 
cheers,
Thorsten




reply via email to

[Prev in Thread] Current Thread [Next in Thread]