jed-users mailing list

[2006 Date Index] [2006 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: is format_paragraph_hook useful?


On  1.02.06, Jörg Sommer wrote:
> Hi,
> 
> the format_paragraph_hook is called at the beginning of
> text_format_paragraph() in text.c, if it exists. It is the only function
> that is run, if it is called. So for what is it? Why not redefine the key
> \eQ to run a new implemented function?

2 Reasons:

1. Because rebinding \eQ does not help if an emulation binds
   format_paragraph to some other key.
   
   You can use rebind() from jedmodes.sf.net/mode/bufutils/
   
     SYNOPSIS
      Rebind all keys bound to `old_fun' to `new_fun'.
    
     USAGE
      rebind(old_fun, new_fun, keymap=what_keymap(), prefix="")
      
   So, e.g. email.sl does
   
     rebind("format_paragraph", "email_reformat", mode);
     
   but could also use
   
     set_buffer_hook("format_paragraph_hook", "email_reformat");
   or
     set_buffer_hook("format_paragraph_hook", &email_reformat);

   (the latter form allows email_reformat to be static or even private).

   
2. While the keymap is mode-local, the format_paragraph_hook is
   buffer-local.
   
   From hooks.txt:

      The following buffer-local hooks are supported:
      ...
       "format_paragraph_hook"
      ...
      
   This way, a hook could change the formatting based on some conditions
   without introducing a new keymap, if e.g. a certain config file should
   use sh-mode but have a different formatting. 
   
   I do not know whether such a scenario is really usefull and I would
   not introduce the format_paragraph_hook just to be prepared for it.
   However as it now exists and is documented, I'd leave it as is.
   
   
Günter


-- 
Milde ife.et.tu-dresden.de

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2006 date index] [2006 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]