From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: feature/android a5b74e2ff62: Initialize text conversion hooks for each C Mode buffer Date: Sat, 28 Oct 2023 08:16:41 +0800 Message-ID: <87fs1vy51y.fsf@yahoo.com> References: <168629733551.31969.16984560043233541806@vcs2.savannah.gnu.org> <20230609075536.0E919C1924D@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23379"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org, bug-cc-mode@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Oct 28 02:17:57 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qwX1Y-0005q3-PL for ged-emacs-devel@m.gmane-mx.org; Sat, 28 Oct 2023 02:17:56 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwX0j-0001Q6-2B; Fri, 27 Oct 2023 20:17:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwX0c-0001Ph-PT for emacs-devel@gnu.org; Fri, 27 Oct 2023 20:16:59 -0400 Original-Received: from sonic304-22.consmr.mail.ne1.yahoo.com ([66.163.191.148]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwX0b-0002UU-5Y for emacs-devel@gnu.org; Fri, 27 Oct 2023 20:16:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1698452212; bh=dOXtprhHyv6p3LYXGb98fm1R0Gd06MLy/tq9SiN+cXk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=idA/yQT5GvSgLFki6gTf8jZgj9rnir+EzK5gwOhsX4aPDAb6wp1ht5DkUum8RFCmKK/b7DWoLte/Lfj2HasCi0exAYS2WDL8dPN/JF7ocp/peFNZ84j4fc6w+TEprrS8R2/gWmtQLQPWeUE5vqyLDi2JhvzKcugS5LAdAlyW9o0IwuRwdUwh9FtSUKaL/hvw1nHtf5qmUeg13fBlz/0T8A2HEV9O0no8rsTD/F9YbzGyBQBNtOJUV3SiKgNKTZ4cb1qRO1er9wHed6aZbKQBBp6e7Cr8E6UPk8WhcacojmtxseOP62P0mtvrlKig0wXciwGa7vTg2Z25l/6ixDtJfQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1698452212; bh=Ty4AHGrCLLAUaFJHCOT3FFuQYd3sri9nWjvtJ0rFF6y=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=dgGV5rUESEDG/EgPSqpmEa+04z8+Ue4nfc228czsj6XJkF4yC3jbwDIK72c5GwV7J5vgL02Mk2o09MYO4Nsrqf1VpyZZbpYvndaTTtXSK4xL0BumdG/zIf+HB0RnwqTFqVg5L+vUBeRwPiMgVZ7sqA+E84fmtRvw4Tpsp9BpNAQYCoRjnRULeLQScfebcFfslsDdxt5IG5jmqkGwcYXZZlIBsIOzjzhxBtiq7/sJwx9X0bsEgEGQTqR/aibplk0EOortGpMal895qmVgz0J5Yzmal9cDEtF8+o3z55RpDCybhzqjAzGVwvVIiNyDIW0CzRo0tingOg+FC0gbP73Fbw== X-YMail-OSG: GiA8.C8VM1lc3dKAhm2JfJUiMs57MbZGfMTGvhJzo1qCpKy6tbbNdnxmK7DmxBX 1Bt__wxzCrqXoX1iV2pShwK41W_LhaUkMoK0Gi8Atc98QWo23GOsgEUIJnGeU2_4WaPwcGtgxywd QSraAFaCOawl_tZ5XWZysx.2MWOxeSACxQ756O2xU6iER_E15hTh3S8f6v6Un4v06jLSBdKg0uaT 9_g9JbZFR_bUIajhP.4H4.670UJSO1PgIUY7vKRKRecylfrzNoKDd54eBgWrFT.46FblKV5.VZOn nnffu_1.wlYjPzrXaIv1Z3g0ieKIv2e_pq.LCV5uv_ews0lHunrqmS4sGmdqjxWgrxtscMaWCz8v 99roSwMg7kDv6e1z0pzqh8JPaG0HlB067gPL7XqdiaUMzXOeLQCL7QTy9lB8ovvGtsXIHsvlXA.f U4nQebaOr2ytCSgOKzeUuoAKZvb51NbkXU6oC5QbqdMOA2l_DtIh_S2WDSYANrVPw8kZF.hCZKzp DEjuDsbyysE3i.TFP1Bw6B7Csd0.qzmagMLXpThSfyku9cegLLyLKSqW7WISp4nHpmRJU3CYMfK_ SEClU0VwnoBXoY90uAcDgCfv1lNJVfX_A.dwHAXw2FLOcqoV9sN1qxOlW9vUepbPPaFau6uvWBT2 d3kxU.Gm8kmZXoeufkgDatNF9I_BJOgzjPyyHta9YYLiv7q7S8fe2Wr6gkkIQvrNJItXr8oCxT2X W.D1ACqEWHtrag8E4tjNysnvS82By7dhP8HdSBm2RQlIKYBJ.a2IH86TVKX2P.3HKw3Z2Xgvn0OY PnAY1BvGgzHml3wUKZ8w726jE57diQgGCIBap_Dyrj X-Sonic-MF: X-Sonic-ID: 0e943c14-59bf-4087-89b1-fc95db7e72dd Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Sat, 28 Oct 2023 00:16:52 +0000 Original-Received: by hermes--production-sg3-8696d769c6-tpgxt (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c90ead047151cb55c7e388d5e612fb6a; Sat, 28 Oct 2023 00:16:45 +0000 (UTC) In-Reply-To: (Stefan Monnier's message of "Fri, 27 Oct 2023 16:05:18 -0400") X-Mailer: WebService/1.1.21890 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.191.148; envelope-from=luangruo@yahoo.com; helo=sonic304-22.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:311944 Archived-At: Stefan Monnier 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.