From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.devel Subject: Re: master 5a8a5e3d: Input fontification for M-x shell Date: Sat, 10 Sep 2022 17:53:51 +0200 Message-ID: <87r10j2pkg.fsf@miha-pc> References: <83mtb8bbdl.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18757"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Sep 10 17:41:31 2022 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 1oX2bq-0004kl-NF for ged-emacs-devel@m.gmane-mx.org; Sat, 10 Sep 2022 17:41:31 +0200 Original-Received: from localhost ([::1]:39386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oX2bp-0008I8-Ni for ged-emacs-devel@m.gmane-mx.org; Sat, 10 Sep 2022 11:41:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oX2b1-0006xf-Ui for emacs-devel@gnu.org; Sat, 10 Sep 2022 11:40:39 -0400 Original-Received: from kamnitnik.top ([2001:19f0:5001:bf2:5400:2ff:fee0:2626]:42978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oX2az-0008ML-Hm; Sat, 10 Sep 2022 11:40:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1662824430; bh=7T32uM+UU7lvBayKWFY2AVQj1abqgWEZeCerfGzbDb8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ata0Elw/x4qAIBzf7YOPuUR9+3XV9Y+bAqLkS4BuWTrLswXZET50FT/TJk6sl9qPk tTFYXKbcoXUr9HM50XqK8FPouA9FirV2Xk8l/cWrdZweeHWGjZV8IM9GdHxp386lka 5A1pWE8x2jPL7IaHHWMGxYDn//HHM+gikUD6quo6yiMUA3guwPIe4TgiojlsDTa/VK ++w+clNZdBDwFa/hRQOSlskjHkNTZ/s4Ot+yVZSb8KFlC0s9W6jTzykF3SIwH537ZA aMLiidTzhuoTudGCOwniPaO9HoLiOZNRsuoZTNJxf2tJtwH3xFlzK+wFw3+Pg85uqr tt6v5GtScc1bA== In-Reply-To: <83mtb8bbdl.fsf@gnu.org> Received-SPF: pass client-ip=2001:19f0:5001:bf2:5400:2ff:fee0:2626; envelope-from=miha@kamnitnik.top; helo=kamnitnik.top X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 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, FROM_SUSPICIOUS_NTLD=0.499, PDS_OTHER_BAD_TLD=2, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" Xref: news.gmane.io gmane.emacs.devel:295134 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> +(defcustom shell-indirect-setup-hook nil >> + "Hook run after setting up an indirect shell fontification buffer." > > Thank you for working on these features. I have a general comment > about this and other of your changes that were installed recently: > > It is not useful to have customizable user options whose doc string > doesn't explain their purpose. It makes discovery and use of such > options much harder. Imagine a user who upgrades to Emacs 29 and runs > "M-x customize-changed" to learn about new options in the new version: > what will such user understand by reading the doc string of this > option? There's no explanation what are indirect shell fontification > buffers, nor how and for what purpose they are used. Without that, it > is impossible to understand when and how this hook could be useful. > > Could you please augment the doc string with the above in mind? > > The same goes for several other hooks in your changes installed today. Thanks. Will something like this be good? I also tried to address your other e-mail. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Improve-doc-strings-of-comint-input-fontification-me.patch Content-Transfer-Encoding: quoted-printable From=2031b0c60a8ae1e0fe10a3f3d7dd865e2b20086d6e Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Sat, 10 Sep 2022 17:47:12 +0200 Subject: [PATCH] Improve doc strings of comint input fontification mechanism =2D-- lisp/comint.el | 14 +++++++++----- lisp/ielm.el | 12 +++++++++--- lisp/shell.el | 27 +++++++++++++++++++-------- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/lisp/comint.el b/lisp/comint.el index 751e561d3e..f9094a932c 100644 =2D-- a/lisp/comint.el +++ b/lisp/comint.el @@ -4030,9 +4030,13 @@ comint-indirect-setup-function `after-change-major-mode-hook' are bound to nil.") =20 (defcustom comint-indirect-setup-hook nil =2D "Hook run after setting up an indirect comint fontification buffer. =2DIt is run after the indirect buffer is set up for fontification =2Dof input regions." + "Hook run in an indirect buffer for input fontification. +If input fontification or indentation is enabled, create an +indirect buffer and set up its major mode and syntax +highlighting. As the final step of its initialization, run this +hook with the indirect buffer as the current buffer. +Fontification and indentation of input is then performed in the +indirect buffer." :group 'comint :type 'hook :version "29.1") @@ -4117,8 +4121,8 @@ comint--fl-ppss-flush-indirect =20 (defun comint--fl-fontify-region (fun beg end verbose) "Fontify process output and user input in the current comint buffer. =2DFirst, highlight the region between BEG and END using FUN. Then =2Dhighlight only the input text in the region with the help of an +First, fontify the region between BEG and END using FUN. Then +fontify only the input text in the region with the help of an indirect buffer. VERBOSE is passed to the fontify-region functions. Skip fontification of input regions with non-nil `comint--fl-inhibit-fontification' text property." diff --git a/lisp/ielm.el b/lisp/ielm.el index 211804210c..3af91113ef 100644 =2D-- a/lisp/ielm.el +++ b/lisp/ielm.el @@ -475,16 +475,22 @@ ielm-set-pm ;;; Input fontification =20 (defcustom ielm-comint-fl-enable t =2D "Enable highlighting of input in ielm buffers. + "Enable fontification of input in ielm buffers. This variable only has effect when creating an ielm buffer. Use =2Dthe command `comint-fl-mode' to toggle highlighting of input in +the command `comint-fl-mode' to toggle fontification of input in an already existing ielm buffer." :type 'boolean :safe 'booleanp :version "29.1") =20 (defcustom ielm-indirect-setup-hook nil =2D "Hook run after setting up an indirect ielm fontification buffer." + "Hook run in an indirect buffer for input fontification. +If input fontification is enabled for an IELM buffer, create an +indirect buffer and set up its major mode and syntax +highlighting. In addition to `comint-indirect-setup-hook', run +this hook with the indirect buffer as the current buffer, to +perform the final step of its initialization. Fontification and +indentation of input is then performed in the indirect buffer." :type 'boolean :safe 'booleanp :version "29.1") diff --git a/lisp/shell.el b/lisp/shell.el index eccac66376..a45746be50 100644 =2D-- a/lisp/shell.el +++ b/lisp/shell.el @@ -309,16 +309,23 @@ shell-input-autoexpand :group 'shell) =20 (defcustom shell-comint-fl-enable t =2D "Enable highlighting of input in shell buffers. + "Enable fontification of input in shell buffers. This variable only has effect when the shell is started. Use the =2Dcommand `comint-fl-mode' to toggle highlighting of input." +command `comint-fl-mode' to toggle fontification of input." :type 'boolean :group 'shell :safe 'booleanp :version "29.1") =20 (defcustom shell-indirect-setup-hook nil =2D "Hook run after setting up an indirect shell fontification buffer." + "Hook run in an indirect buffer for input fontification. +If input fontification or indentation is enabled for a +`shell-mode' buffer, create an indirect buffer and set up its +major mode and syntax highlighting. In addition to +`comint-indirect-setup-hook', run this hook with the indirect +buffer as the current buffer, to perform the final step of its +initialization. Fontification and indentation of input is then +performed in the indirect buffer." :type 'boolean :group 'shell :safe 'booleanp @@ -1680,7 +1687,7 @@ shell-highlight-undef-matcher t)) =20 (defvar-local shell--highlight-undef-indirect nil =2D "t if shell commands are fontified in `comint-indirect-buffer'.") + "Non-nil if shell commands are fontified in `comint-indirect-buffer'.") =20 (declare-function sh-feature "sh-script" (alist &optional function)) (defvar sh-leading-keywords) @@ -1700,7 +1707,7 @@ shell-highlight-undef-mode (font-lock-remove-keywords nil shell-highlight-undef-keywords)= ))) (font-lock-remove-keywords nil shell-highlight-undef-keywords)) (remove-hook 'comint-fl-mode-hook =2D #'shell-highlight-undef-reset-mode t) + #'shell-highlight-undef-mode-restart t) =20 (when shell-highlight-undef-mode (when comint-use-prompt-regexp @@ -1742,12 +1749,16 @@ shell-highlight-undef-mode (t (funcall setup)))) =20 (add-hook 'comint-fl-mode-hook =2D #'shell-highlight-undef-reset-mode nil t)) + #'shell-highlight-undef-mode-restart nil t)) =20 (font-lock-flush)) =20 =2D(defun shell-highlight-undef-reset-mode () =2D "If `shell-highlight-undef-mode' is on, turn it off and on." +(defun shell-highlight-undef-mode-restart () + "If `shell-highlight-undef-mode' is on, restart it. +`shell-highlight-undef-mode' performs its set-up differently +depending on `comint-fl-mode'. It's useful to call this function +when switching `comint-fl-mode' in order to make +`shell-highlight-undef-mode' redo its setup." (when shell-highlight-undef-mode (shell-highlight-undef-mode 1))) =20 =2D-=20 2.37.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmMcsw8THG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZPwGVD/9djjwO+V/fXHWkyTSCBPQ/hYqoz1Gh XgNXvKmSJhvsnr1Cq5gWJSm+0cGElhSr7Sa8H7JOfKkj9Fmze41kq2igvVxzsqhB 4w9ld1ukc5uj4xc9KX7NQw9FKI2b3Nl7tA2bESdSrEOJhMmDvL6MOLJt3Jtr0C8s EWayjjM4FmedFsfFW9hRdWDPoBMK0YIgCAlEu5zo5zAhBJsmJKaUQfQyEqK2AZ3u /t5XVzeViOw4gv76Yfn7olxGRlLKSj/8hHo+DODeyfkKtQLSdU8A/RQBmXSRkJpU Yi+wUcaDu64lVMSLDW7FVErPeQ0h2Wm5L3I9++ke5u1l2YBy+paMDMoUFlOz3kJ3 e3APbzUgQgAOg31VYkFHNRLuSbYlh5R6/62QPS+5TSbgiOIaPHMFTansfUZqmi8G o5KFIpJSnmojeQXodXeaVM4BA6hZNIxUMDsNckHqm848/yAIR7lQpmBq2rSqunre OpJJNvm13TD7sds4pAYsc5xdmfY8qkylB0inuJEVJYdv7Py/Py1eGr4uTO9LRgF9 mj5kQE6NYeE7LgiCpIRqzddnAwJe13axnaIZ8HRUxx2kQ7ZDxaRgBQTW93oU9Zkg qgi+PfuTRgrLkN/OD+j7FN3wXjntq2iOliz3iOKWXxhtcv0Zi5aE4nnDrXceEQzH bUxiH2DmvLAZJw== =qyet -----END PGP SIGNATURE----- --==-=-=--