Berndl, Klaus writes:
 > >>         ;; to a buffer belonging to another.
 > >>         (make-local-hook 'post-command-hook)
 > 
 > >Hmm, I don't think I need the above form because the add-hook form below
 > >makes the variable local anyway.
 > 
 > Indeed.

I have removed the redundant form in the JDEE sources.

 > 
 > > >         (add-hook 'post-command-hook
 > > >                   'jde-detect-java-buffer-activation nil t)
 > > > 
 > > >  
 > > > This is the code from `jde-mode' (JDEE 2.3.4beta3).
 > >This should work even if the "from" buffer is not a jde-mode buffer. Are
 > >you saying that it doesn't?
 > 
 > Yes, i'm saying this 

Well, it does work on my system.

 > - and it can not work in other modes:
 > This add-hook is called when `jde-mode' is called which is only called when a 
 > buffer X is opened which is "linked" to jde-mode. And because you add the function 
 > LOCALLY to post-command-hook only the local value (local in buffer X) contains this 
 > function - the global value of post-command-hook doesn't. Therefore this works only 
 > in jde-buffers - which is suboptimal IMHO ;-)
 > 


It is not intended to work in other modes. It's intended to support JDEE project
switching.


 > >Then the hook function would run in buffers that are not jde-mode
 > >buffers? This seemed a waste
 > >of processing cycles to me when I wrote the code.
 > 
 > No.
 > 1. It should run in other mode buffers

Why?

 > 2. You are right, that then the check if the current-buffer is running 
 >    jde-mode would be processed after each command in each buffer but this 
 >    is really not a problem - A powerful Emacs-setup contains some functions 
 >    in post-command-hook and this is not a problem if these funtions are 
 >    well designed, i.e. do their task only if needed and check this with a 
 >    efficient condition - and (equal major-mode 'jde-mode) is very efficient 
 >    ;-)
 > 
 > Thoughts?

I don't understand what you want. The purpose of the post-command-hook
function we are discussing is to detect when the user has switched from a buffer
of any type to a jde-mode buffer. It performs this task correctly, at least
on my system as I verified when I originally wrote the code and as I reverified
this evening. If it does not work correctly on your system, please post your
system configuration and the details of how you switched buffers when trying
to verify the code. It's possible that there are ways to switch buffers that
do not trigger execution of the post-command-hook function. (When I verified
it, I switched buffers by clicking the mouse in the frames displaying the
buffers.)

Paul

 > 
 > >I will try to make the doc clearer on these issues.
 > 
 > Would be better to fix the things above ;-)
 > 
 > >jde-entering-java-buffer-hook functions are supposed to run whenever the
 > >user activates a jde-mode buffer,
 > >regardless of the mode of the previously active buffer. As far as I
 > >know, it works correctly and that
 > >is easily verifiable. Are you saying that the hook functions are not
 > >being run when a jde-mode buffer
 > >is entered from a buffer that is operating in a different mode?
 > 
 > Yes, indeed! See above...
 > 
 > Klaus

Reply via email to