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: Sun, 11 Sep 2022 13:06:43 +0200 Message-ID: <87h71e2mrg.fsf@miha-pc> References: <83mtb8bbdl.fsf@gnu.org> <87r10j2pkg.fsf@miha-pc> <83mtb79qqi.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="22845"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 11 12:57:08 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 1oXKeB-0005ha-IJ for ged-emacs-devel@m.gmane-mx.org; Sun, 11 Sep 2022 12:57:08 +0200 Original-Received: from localhost ([::1]:45826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXKeA-0008A8-FG for ged-emacs-devel@m.gmane-mx.org; Sun, 11 Sep 2022 06:57:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXKag-0006wA-Vf for emacs-devel@gnu.org; Sun, 11 Sep 2022 06:53:31 -0400 Original-Received: from kamnitnik.top ([209.250.245.214]:45890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXKac-0004Wz-0Y; Sun, 11 Sep 2022 06:53:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1662893601; bh=ZKJ32nPyRuYk3rOYiO6V4QiP6zLhsgGJj40bZLFI9cM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=kjqfWNjID3DFcsRf6/cL0RL1s5i+ql8+kJldgcviVNzJDH1QGetMzznuK+zmc7rLu qf9Omoaut+1Bx1+RLEL6THE44PA2ufZ3ROu1vrb6HrQnSBjrra23+4/1G+8gNTUsKC 8ZRXxWGoQ2HlBGvYcRAoXQJeU2iEbZSVfMV1S/VkUoaIyLCiNBNnO0mgTjN+E41te5 qVZeSlqYkYHdUuj9fLLQRxdT9ksIMco1se/mjlSGWIfqdSDkfC8LVRsO/QjQ5jU7cM W/Jpw43+bkMuWErpFmnFsgu6QWwJ8Tolxn/WJNc0S5vMh+fSr0g2fRGyIBRRCKFO29 RssVQM0YUCP6A== In-Reply-To: <83mtb79qqi.fsf@gnu.org> Received-SPF: pass client-ip=209.250.245.214; 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:295170 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Eli Zaretskii writes: > [...] > You say "create an indirect buffer and set up...", but isn't that done > by some of the other code you submitted? If so, instead of > "create...and set up...", which implies that the user of this variable > must do so, the doc string should say something like > > If input fontification or indentation is enabled, function > `so-and-so' creates an indirect buffer and sets up its major mode > and syntax highlighting. This hook is useful for running in that > indirect buffer when its major mode is turned on. Okay, thanks for feedback, please find a refined patch attached. --=-=-= 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=20dc79db872ac0a90b759f7999afadc75a60b2ade2 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 | 13 ++++++++++--- lisp/shell.el | 27 +++++++++++++++++++-------- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/lisp/comint.el b/lisp/comint.el index 751e561d3e..696dac3d12 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. +Input fontification and indentation, if enabled, is performed in +an indirect buffer, whose major mode and syntax highlighting are +set up according to `comint-indirect-setup-function'. After this +setup is done, run this hook with the indirect buffer as the +current buffer. This can be used to further customize +fontification and other behaviour of 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..4a10c00297 100644 =2D-- a/lisp/ielm.el +++ b/lisp/ielm.el @@ -475,16 +475,23 @@ 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. +Input fontification and indentation of an IELM buffer, if +enabled, is performed in an indirect buffer, whose indentation +and syntax highlighting are set up with `emacs-lisp-mode'. In +addition to `comint-indirect-setup-hook', run this hook with the +indirect buffer as the current buffer after its setup is done. +This can be used to further customize fontification and other +behaviour of the indirect buffer." :type 'boolean :safe 'booleanp :version "29.1") diff --git a/lisp/shell.el b/lisp/shell.el index eccac66376..834ca6b627 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. +Input fontification and indentation of a `shell-mode' buffer, if +enabled, is performed in an indirect buffer, whose indentation +and syntax highlighting is set up with `sh-mode'. In addition to +`comint-indirect-setup-hook', run this hook with the indirect +buffer as the current buffer after its setup is done. This can +be used to further customize fontification and other behaviour of +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 setup 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----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmMdwUMTHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP0uSD/0c2oljILYndVEBG3cTKZ4avD2J6uIF yBT9nIPWk8alNa+u4bvExDQMPIzLag02CPmZ2M/Tskb7ElIv6yQRCouys/CjC771 qio77c0XvTd+bk0i4lwVbYDEMOAHNfYWI0k9Nj71wCSE06nb+KQZq9UjHmSPx86X pydEm4Q6OgZBfCBL5Q7gscSVcBIbeo14/iU0rKZoWtvzy8WTfKrBlkGDd7t/FQW2 LqbYLK8ileiV0pvT4t7txXiadxpYMLcj/g56TwkauwvNH89LsSa7gaQau1RLh3SD Wgu0GZw14YVWM8+req4uExfzrX8uU2FvbApVT3Lgp5ySRZYvbXxhAHhNH15kIt8J BU3f742XJW82zqTsBat5rCbAO94Rejaj5IJPLhJWPKASvOMR3prQ7dHwGiGSszb4 /mmdo3MqUe2UweAbwjVwJcy7fwrJTZ9ABeoXN9tkp8XVNInNIK6krcODQ5ULgRIP QgaZlb4IfmBypr+mXtFjVmMUTIEyzUOxK7y7YIrmC1aeV9wj0lKKLQcsveEycFjt UEPdoA98m1uplyFtRv9cWIl1eGrwkkcKqKS9tsKD3TfjScvmW6Pj6Uq7+oNzHQSm lf5oMSiHT7YqlTr2MC9ksyn78nnsbT40ity/1PQdEUXq2sk1Su9wHb7FZq7fnwxY iHTSuWd0KyffkQ== =pgR1 -----END PGP SIGNATURE----- --==-=-=--