emacs-devel
[Top][All Lists]
Advanced

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

Re: feature/android a5b74e2ff62: Initialize text conversion hooks for ea


From: Po Lu
Subject: Re: feature/android a5b74e2ff62: Initialize text conversion hooks for each C Mode buffer
Date: Sat, 28 Oct 2023 08:16:41 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

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.


reply via email to

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