unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: feature/android a5b74e2ff62: Initialize text conversion hooks for each C Mode buffer
       [not found] ` <20230609075536.0E919C1924D@vcs2.savannah.gnu.org>
@ 2023-10-27 20:05   ` Stefan Monnier
  2023-10-28  0:16     ` Po Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2023-10-27 20:05 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel, bug-cc-mode

Hi Po Lu (and Alan),

Regarding this patch of yours from a few months back:

> diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
> index 1364117bdc8..88e0aebb9a2 100644
> --- a/lisp/progmodes/cc-mode.el
> +++ b/lisp/progmodes/cc-mode.el
> @@ -251,13 +251,14 @@ control).  See \"cc-mode.el\" for more info."
>              (when (fboundp 'electric-indent-local-mode)
>  	      (add-hook 'electric-indent-mode-hook 'c-electric-indent-mode-hook)
>                (add-hook 'electric-indent-local-mode-hook
> -                        'c-electric-indent-local-mode-hook))
> -	    ;; Set up text conversion, for Emacs >= 30.0
> -	    (when (boundp 'post-text-conversion-hook)
> -	      (add-hook 'post-text-conversion-hook #'c-post-text-conversion)))
> +                        'c-electric-indent-local-mode-hook)))
>  	;; Will try initialization hooks again if they failed.
>  	(put 'c-initialize-cc-mode initprop c-initialization-ok))))
>  
> +  ;; Set up text conversion, for Emacs >= 30.0
> +  (when (boundp 'post-text-conversion-hook)
> +    (add-hook 'post-text-conversion-hook #'c-post-text-conversion))
> +
>    (unless new-style-init
>      (c-init-language-vars-for 'c-mode)))

Why is this specific to CC-mode?
Is it because other modes handle electricity via the
`post-self-insert-hook` instead?

And why is the hook function added globally?
Wouldn't it be better to add it buffer-locally instead?


        Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: feature/android a5b74e2ff62: Initialize text conversion hooks for each C Mode buffer
  2023-10-27 20:05   ` feature/android a5b74e2ff62: Initialize text conversion hooks for each C Mode buffer Stefan Monnier
@ 2023-10-28  0:16     ` Po Lu
  2023-10-28  1:18       ` Stefan Monnier via CC-Mode-help
  0 siblings, 1 reply; 4+ messages in thread
From: Po Lu @ 2023-10-28  0:16 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, bug-cc-mode

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Hi Po Lu (and Alan),
>
> Regarding this patch of yours from a few months back:
>
>> diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
>> index 1364117bdc8..88e0aebb9a2 100644
>> --- a/lisp/progmodes/cc-mode.el
>> +++ b/lisp/progmodes/cc-mode.el
>> @@ -251,13 +251,14 @@ control).  See \"cc-mode.el\" for more info."
>>              (when (fboundp 'electric-indent-local-mode)
>>  	      (add-hook 'electric-indent-mode-hook 'c-electric-indent-mode-hook)
>>                (add-hook 'electric-indent-local-mode-hook
>> -                        'c-electric-indent-local-mode-hook))
>> -	    ;; Set up text conversion, for Emacs >= 30.0
>> -	    (when (boundp 'post-text-conversion-hook)
>> -	      (add-hook 'post-text-conversion-hook #'c-post-text-conversion)))
>> +                        'c-electric-indent-local-mode-hook)))
>>  	;; Will try initialization hooks again if they failed.
>>  	(put 'c-initialize-cc-mode initprop c-initialization-ok))))
>>  
>> +  ;; Set up text conversion, for Emacs >= 30.0
>> +  (when (boundp 'post-text-conversion-hook)
>> +    (add-hook 'post-text-conversion-hook #'c-post-text-conversion))
>> +
>>    (unless new-style-init
>>      (c-init-language-vars-for 'c-mode)))
>
> Why is this specific to CC-mode?
> Is it because other modes handle electricity via the
> `post-self-insert-hook` instead?

Correct.

> And why is the hook function added globally?
> Wouldn't it be better to add it buffer-locally instead?

It's installed buffer-locally, since the hook variable itself is
buffer-local.

Thanks.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: feature/android a5b74e2ff62: Initialize text conversion hooks for each C Mode buffer
  2023-10-28  0:16     ` Po Lu
@ 2023-10-28  1:18       ` Stefan Monnier via CC-Mode-help
  2023-10-28  2:19         ` Po Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier via CC-Mode-help @ 2023-10-28  1:18 UTC (permalink / raw)
  To: Po Lu; +Cc: bug-cc-mode, emacs-devel

>> Why is this specific to CC-mode?
>> Is it because other modes handle electricity via the
>> `post-self-insert-hook` instead?
> Correct.

Thanks for confirming.

>> And why is the hook function added globally?
>> Wouldn't it be better to add it buffer-locally instead?
> It's installed buffer-locally, since the hook variable itself is
> buffer-local.

Ah, I missed that.  I just changed the code to make it explicit.


        Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: feature/android a5b74e2ff62: Initialize text conversion hooks for each C Mode buffer
  2023-10-28  1:18       ` Stefan Monnier via CC-Mode-help
@ 2023-10-28  2:19         ` Po Lu
  0 siblings, 0 replies; 4+ messages in thread
From: Po Lu @ 2023-10-28  2:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, bug-cc-mode

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> Why is this specific to CC-mode?
>>> Is it because other modes handle electricity via the
>>> `post-self-insert-hook` instead?
>> Correct.
>
> Thanks for confirming.
>
>>> And why is the hook function added globally?
>>> Wouldn't it be better to add it buffer-locally instead?
>> It's installed buffer-locally, since the hook variable itself is
>> buffer-local.
>
> Ah, I missed that.  I just changed the code to make it explicit.

OK, thanks.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-28  2:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <168629733551.31969.16984560043233541806@vcs2.savannah.gnu.org>
     [not found] ` <20230609075536.0E919C1924D@vcs2.savannah.gnu.org>
2023-10-27 20:05   ` feature/android a5b74e2ff62: Initialize text conversion hooks for each C Mode buffer Stefan Monnier
2023-10-28  0:16     ` Po Lu
2023-10-28  1:18       ` Stefan Monnier via CC-Mode-help
2023-10-28  2:19         ` Po Lu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).