Re: feature/android a5b74e2ff62: Initialize text conversion hooks for each C Mode buffer

Stefan Monnier via CC-Mode-help <[email protected]> Fri, 27 Oct 2023 16:05:18 -0400
Newsgroups gmane.emacs.cc-mode.general
Message-ID <jwvbkcjsumk.fsf-monnier+emacs__42285.6232080207$1698438800$gmane$org@gnu.org>
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