unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#58169: 29.0.50; comint-fl-mode fontifies the output
@ 2022-09-29 16:24 Augusto Stoffel
  2022-09-30  1:55 ` Visuwesh
  0 siblings, 1 reply; 10+ messages in thread
From: Augusto Stoffel @ 2022-09-29 16:24 UTC (permalink / raw)
  To: 58169; +Cc: Miha Rihtaršič

On emacs -Q, calling M-x shell and typing, say

  echo '#123'

prints some text with font-lock-comment-face.  Similarly

  echo '`123`'

prints text with the `sh-quoted-exec` face.  I wouldn't expect these
faces to be there, since the output is just output, not a comment or a
quoted exec.  If I turn off comint-fl-mode, then the output is not
fontified.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#58169: 29.0.50; comint-fl-mode fontifies the output
  2022-09-29 16:24 bug#58169: 29.0.50; comint-fl-mode fontifies the output Augusto Stoffel
@ 2022-09-30  1:55 ` Visuwesh
  2022-09-30  5:58   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Visuwesh @ 2022-09-30  1:55 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 58169, Miha Rihtaršič

Quickly hijacking this bug report to say: can we please announce
comint-fl-mode in NEWS, and say how to turn it off?  I was confused when
M-x shell randomly started to fontify the input line despite me
disabling every font-lock related thing in *shell* buffers.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#58169: 29.0.50; comint-fl-mode fontifies the output
  2022-09-30  1:55 ` Visuwesh
@ 2022-09-30  5:58   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-30 13:38     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 10+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-09-30  5:58 UTC (permalink / raw)
  To: Visuwesh, Augusto Stoffel; +Cc: 58169

Visuwesh <visuweshm@gmail.com> writes:

> Quickly hijacking this bug report to say: can we please announce
> comint-fl-mode in NEWS, and say how to turn it off?  I was confused when
> M-x shell randomly started to fontify the input line despite me
> disabling every font-lock related thing in *shell* buffers.

Thanks for reporting, I'll have time to work one these issues in the
afternoon.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#58169: 29.0.50; comint-fl-mode fontifies the output
  2022-09-30  5:58   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-09-30 13:38     ` Lars Ingebrigtsen
  2022-09-30 18:38       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-30 13:38 UTC (permalink / raw)
  To: miha; +Cc: 58169, Augusto Stoffel, Visuwesh

<miha@kamnitnik.top> writes:

>> Quickly hijacking this bug report to say: can we please announce
>> comint-fl-mode in NEWS, and say how to turn it off?  I was confused when
>> M-x shell randomly started to fontify the input line despite me
>> disabling every font-lock related thing in *shell* buffers.
>
> Thanks for reporting, I'll have time to work one these issues in the
> afternoon.

And I think we should probably rename it to `comint-font-lock-mode',
because the current name is obscure.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#58169: 29.0.50; comint-fl-mode fontifies the output
  2022-09-30 18:38       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-09-30 18:26         ` Lars Ingebrigtsen
  2022-09-30 19:22           ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-30 18:26 UTC (permalink / raw)
  To: miha; +Cc: 58169, Augusto Stoffel, Visuwesh

<miha@kamnitnik.top> writes:

> +(defalias 'comint-fontify-input-mode #'comint-fl-mode)

Thanks, but why aliases instead of just renaming the functions and
variables?





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#58169: 29.0.50; comint-fl-mode fontifies the output
  2022-09-30 13:38     ` Lars Ingebrigtsen
@ 2022-09-30 18:38       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-30 18:26         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 10+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-09-30 18:38 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 58169, Augusto Stoffel, Visuwesh


[-- Attachment #1.1: Type: text/plain, Size: 667 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> <miha@kamnitnik.top> writes:
>
>>> Quickly hijacking this bug report to say: can we please announce
>>> comint-fl-mode in NEWS, and say how to turn it off?  I was confused when
>>> M-x shell randomly started to fontify the input line despite me
>>> disabling every font-lock related thing in *shell* buffers.
>>
>> Thanks for reporting, I'll have time to work one these issues in the
>> afternoon.
>
> And I think we should probably rename it to `comint-font-lock-mode',
> because the current name is obscure.

I went with 'comint-fontify-input-mode'. I also made two more
descriptive variable aliases. Patches attached


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-comint-fl-Prevent-fontification-of-output-as-input.patch --]
[-- Type: text/x-patch, Size: 2334 bytes --]

From ddbad11131d0bfcdef33666c028f3d7070cefc31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
Date: Fri, 30 Sep 2022 20:07:03 +0200
Subject: [PATCH 1/2] comint-fl: Prevent fontification of output as input

* lisp/comint.el (comint-output-filter): Inhibit jit-lock
fontification of inserted process output before marking it with the
'output' filed property (bug#58169).
---
 lisp/comint.el | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index e7d2136c84..15c9388ea4 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2150,24 +2150,26 @@ comint-output-filter
 	    ;; insert-before-markers is a bad thing. XXX
 	    ;; Luckily we don't have to use it any more, we use
 	    ;; window-point-insertion-type instead.
-	    (insert string)
+	    (make-local-variable 'jit-lock-mode)
+	    (let ((jit-lock-mode nil))
+	      (insert string)
 
-	    ;; Advance process-mark
-	    (set-marker (process-mark process) (point))
+	      ;; Advance process-mark
+	      (set-marker (process-mark process) (point))
 
-	    (unless comint-inhibit-carriage-motion
+	      (unless comint-inhibit-carriage-motion
 	      ;; Interpret any carriage motion characters (newline, backspace)
 	      (comint-carriage-motion comint-last-output-start (point)))
 
-	    ;; Run these hooks with point where the user had it.
-	    (goto-char saved-point)
-	    (run-hook-with-args 'comint-output-filter-functions string)
-	    (set-marker saved-point (point))
+	      ;; Run these hooks with point where the user had it.
+	      (goto-char saved-point)
+	      (run-hook-with-args 'comint-output-filter-functions string)
+	      (set-marker saved-point (point))
 
-	    (goto-char (process-mark process)) ; In case a filter moved it.
+	      (goto-char (process-mark process)) ; In case a filter moved it.
 
-	    (unless comint-use-prompt-regexp
-              (comint--mark-as-output comint-last-output-start (point)))
+	      (unless comint-use-prompt-regexp
+                (comint--mark-as-output comint-last-output-start (point))))
 
 	    ;; Highlight the prompt, where we define `prompt' to mean
 	    ;; the most recent output that doesn't end with a newline.
-- 
2.37.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-comint-fl-New-descriptive-aliases-and-NEWS.patch --]
[-- Type: text/x-patch, Size: 3270 bytes --]

From f6d07520aaa2156957962397c59093d6b1c4acd7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
Date: Fri, 30 Sep 2022 20:28:15 +0200
Subject: [PATCH 2/2] comint-fl: New descriptive aliases and NEWS

* lisp/comint.el (comint-fontify-input-mode): New alias for
'comint-fl-mode' (bug#58169).
* lisp/ielm.el (ielm-fontify-input-enable): New alias for
'ielm-comint-fl-enable'.
* lisp/shell.el (shell-fontify-input-enable): New alias for
'shell-comint-fl-enable'.
* etc/NEWS: Mention the new modes and how to turn them disable or
enable them.
---
 etc/NEWS       | 14 ++++++++++++++
 lisp/comint.el |  2 ++
 lisp/ielm.el   |  2 ++
 lisp/shell.el  |  2 ++
 4 files changed, 20 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index aad1a17ae7..bce6a72481 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1214,6 +1214,14 @@ When nil, this prevents comint from deleting the current input when
 inserting previous input using '<mouse-2>'.  The default is t, to
 preserve past behavior.
 
+---
+*** New minor mode 'comint-fontify-input-mode'.
+This minor mode is enabled by default in "*shell*" and "*ielm*"
+buffers.  It fontifies input text according to 'shell-mode' or
+'emacs-lisp-mode' font-lock rules.  Customize the user options
+'shell-fontify-input-enable' and 'ielm-fontify-input-enable' to nil if
+you don't want to enable input fontification by default.
+
 ** Mwheel
 
 ---
@@ -2513,6 +2521,12 @@ behavior, customize the new 'eshell-lisp-form-nil-is-failure' option.
 Enabling this will automatically kill a "*shell*" buffer as soon as
 the shell session terminates.
 
+---
+*** New minor mode 'shell-highlight-undef-mode'
+Customize 'shell-highlight-undef-enable' to t if you want to enable
+this minor mode in "*shell*" buffers.  It will highlight undefined
+commands with a warning face as you type.
+
 ** Calc
 
 +++
diff --git a/lisp/comint.el b/lisp/comint.el
index 15c9388ea4..3d7218b868 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -3978,6 +3978,8 @@ comint--indirect-buffer
 
 (defvar-local comint--fl-saved-jit-lock-contextually nil)
 
+(defalias 'comint-fontify-input-mode #'comint-fl-mode)
+
 (define-minor-mode comint-fl-mode
   "Enable input fontification in the current comint buffer.
 This minor mode is useful if the current major mode derives from
diff --git a/lisp/ielm.el b/lisp/ielm.el
index ad41cb1f6b..33a5fc8440 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -483,6 +483,8 @@ ielm-comint-fl-enable
   :safe 'booleanp
   :version "29.1")
 
+(defvaralias 'ielm-fontify-input-enable 'ilem-comint-fl-enable)
+
 (defcustom ielm-indirect-setup-hook nil
   "Hook run in an indirect buffer for input fontification.
 Input fontification and indentation of an IELM buffer, if
diff --git a/lisp/shell.el b/lisp/shell.el
index 18bb372242..33dcb248ab 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -308,6 +308,8 @@ shell-input-autoexpand
 		 (const :tag "on" t))
   :group 'shell)
 
+(defvaralias 'shell-fontify-input-enable 'shell-comint-fl-enable)
+
 (defcustom shell-comint-fl-enable t
   "Enable fontification of input in shell buffers.
 This variable only has effect when the shell is started.  Use the
-- 
2.37.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#58169: 29.0.50; comint-fl-mode fontifies the output
  2022-09-30 19:22           ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-09-30 19:14             ` Lars Ingebrigtsen
  2022-10-01 14:43             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-30 19:14 UTC (permalink / raw)
  To: miha; +Cc: 58169, Augusto Stoffel, Visuwesh

<miha@kamnitnik.top> writes:

> I originally thought that the function names could become too long. But
> now I tried it and it's not so bad, so here are the revised patches
> attached.

Thanks; pushed to Emacs 29.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#58169: 29.0.50; comint-fl-mode fontifies the output
  2022-09-30 18:26         ` Lars Ingebrigtsen
@ 2022-09-30 19:22           ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-30 19:14             ` Lars Ingebrigtsen
  2022-10-01 14:43             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 10+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-09-30 19:22 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 58169, Augusto Stoffel, Visuwesh


[-- Attachment #1.1: Type: text/plain, Size: 371 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> <miha@kamnitnik.top> writes:
>
>> +(defalias 'comint-fontify-input-mode #'comint-fl-mode)
>
> Thanks, but why aliases instead of just renaming the functions and
> variables?

I originally thought that the function names could become too long. But
now I tried it and it's not so bad, so here are the revised patches
attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-comint-fl-Prevent-fontification-of-output-as-input.patch --]
[-- Type: text/x-patch, Size: 2334 bytes --]

From ddbad11131d0bfcdef33666c028f3d7070cefc31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
Date: Fri, 30 Sep 2022 20:07:03 +0200
Subject: [PATCH 1/2] comint-fl: Prevent fontification of output as input

* lisp/comint.el (comint-output-filter): Inhibit jit-lock
fontification of inserted process output before marking it with the
'output' filed property (bug#58169).
---
 lisp/comint.el | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index e7d2136c84..15c9388ea4 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2150,24 +2150,26 @@ comint-output-filter
 	    ;; insert-before-markers is a bad thing. XXX
 	    ;; Luckily we don't have to use it any more, we use
 	    ;; window-point-insertion-type instead.
-	    (insert string)
+	    (make-local-variable 'jit-lock-mode)
+	    (let ((jit-lock-mode nil))
+	      (insert string)
 
-	    ;; Advance process-mark
-	    (set-marker (process-mark process) (point))
+	      ;; Advance process-mark
+	      (set-marker (process-mark process) (point))
 
-	    (unless comint-inhibit-carriage-motion
+	      (unless comint-inhibit-carriage-motion
 	      ;; Interpret any carriage motion characters (newline, backspace)
 	      (comint-carriage-motion comint-last-output-start (point)))
 
-	    ;; Run these hooks with point where the user had it.
-	    (goto-char saved-point)
-	    (run-hook-with-args 'comint-output-filter-functions string)
-	    (set-marker saved-point (point))
+	      ;; Run these hooks with point where the user had it.
+	      (goto-char saved-point)
+	      (run-hook-with-args 'comint-output-filter-functions string)
+	      (set-marker saved-point (point))
 
-	    (goto-char (process-mark process)) ; In case a filter moved it.
+	      (goto-char (process-mark process)) ; In case a filter moved it.
 
-	    (unless comint-use-prompt-regexp
-              (comint--mark-as-output comint-last-output-start (point)))
+	      (unless comint-use-prompt-regexp
+                (comint--mark-as-output comint-last-output-start (point))))
 
 	    ;; Highlight the prompt, where we define `prompt' to mean
 	    ;; the most recent output that doesn't end with a newline.
-- 
2.37.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-Rename-comint-fl-to-comint-fontify-input-and-mention.patch --]
[-- Type: text/x-patch, Size: 13237 bytes --]

From 734d2b840618e323f8676f74e152b6c85a68a020 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
Date: Fri, 30 Sep 2022 20:28:15 +0200
Subject: [PATCH 2/2] Rename comint-fl-* to comint-fontify-input-* and mention
 it in NEWS

* lisp/comint.el
(comint-fontify-input-mode):
(comint--fontify-input-saved-jit-lock-contextually):
(comint--fontify-input-on):
(comint--fontify-input-off):
(comint--fontify-input-ppss-flush-indirect):
(comint--fontify-input-fontify-region): Replace comint-fl-* with
comint-fontify-input-*.

* lisp/ielm.el (ielm-fontify-input-enable):
(ielm-fontify-input-enable):
(ielm-indirect-setup-hook):
(inferior-emacs-lisp-mode): Replace comint-fl-* with
comint-fontify-input-*.

* lisp/shell.el (shell-comint-fl-enable):
(shell-mode): Replace comint-fl-* with comint-fontify-input-*.

* etc/NEWS: Mention the new modes and how to disable or enable
them (bug#58169).
---
 etc/NEWS       | 14 ++++++++++++++
 lisp/comint.el | 46 +++++++++++++++++++++++-----------------------
 lisp/ielm.el   | 10 +++++-----
 lisp/shell.el  | 33 +++++++++++++++++----------------
 4 files changed, 59 insertions(+), 44 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index aad1a17ae7..bce6a72481 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1214,6 +1214,14 @@ When nil, this prevents comint from deleting the current input when
 inserting previous input using '<mouse-2>'.  The default is t, to
 preserve past behavior.
 
+---
+*** New minor mode 'comint-fontify-input-mode'.
+This minor mode is enabled by default in "*shell*" and "*ielm*"
+buffers.  It fontifies input text according to 'shell-mode' or
+'emacs-lisp-mode' font-lock rules.  Customize the user options
+'shell-fontify-input-enable' and 'ielm-fontify-input-enable' to nil if
+you don't want to enable input fontification by default.
+
 ** Mwheel
 
 ---
@@ -2513,6 +2521,12 @@ behavior, customize the new 'eshell-lisp-form-nil-is-failure' option.
 Enabling this will automatically kill a "*shell*" buffer as soon as
 the shell session terminates.
 
+---
+*** New minor mode 'shell-highlight-undef-mode'
+Customize 'shell-highlight-undef-enable' to t if you want to enable
+this minor mode in "*shell*" buffers.  It will highlight undefined
+commands with a warning face as you type.
+
 ** Calc
 
 +++
diff --git a/lisp/comint.el b/lisp/comint.el
index 15c9388ea4..a70a75c648 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1945,7 +1945,7 @@ comint-send-input
               (when comint-highlight-input
                 (add-text-properties beg end
                                      '( font-lock-face comint-highlight-input
-                                        comint--fl-inhibit-fontification t
+                                        comint--fontify-input-inhibit-fontification t
                                         front-sticky t )))
               (unless comint-use-prompt-regexp
                 ;; Give old user input a field property of `input', to
@@ -3976,9 +3976,9 @@ comint-indirect-setup-hook
 (defvar-local comint--indirect-buffer nil
   "Indirect buffer used for input fontification.")
 
-(defvar-local comint--fl-saved-jit-lock-contextually nil)
+(defvar-local comint--fontify-input-saved-jit-lock-contextually nil)
 
-(define-minor-mode comint-fl-mode
+(define-minor-mode comint-fontify-input-mode
   "Enable input fontification in the current comint buffer.
 This minor mode is useful if the current major mode derives from
 `comint-mode' and if `comint-indirect-setup-function' is set.
@@ -3993,71 +3993,71 @@ comint-fl-mode
 non-nil.  Input fontification isn't compatible with this
 setting."
   :lighter nil
-  (if comint-fl-mode
+  (if comint-fontify-input-mode
       (let ((success nil))
         (unwind-protect
             (progn
-              (comint--fl-on)
+              (comint--fontify-input-on)
               (setq success t))
           (unless success
-            (setq comint-fl-mode nil)
-            (comint--fl-off))))
-    (comint--fl-off)))
+            (setq comint-fontify-input-mode nil)
+            (comint--fontify-input-off))))
+    (comint--fontify-input-off)))
 
-(defun comint--fl-on ()
+(defun comint--fontify-input-on ()
   "Enable input fontification in the current comint buffer."
-  (comint--fl-off)
+  (comint--fontify-input-off)
 
   (when comint-use-prompt-regexp
     (error
      "Input fontification is incompatible with `comint-use-prompt-regexp'"))
 
   (add-function :around (local 'font-lock-fontify-region-function)
-                #'comint--fl-fontify-region)
+                #'comint--fontify-input-fontify-region)
   ;; `before-change-functions' are only run in the current buffer and
   ;; not in its indirect buffers, which means that we must manually
   ;; flush ppss cache
   (add-hook 'before-change-functions
-            #'comint--fl-ppss-flush-indirect 99 t)
+            #'comint--fontify-input-ppss-flush-indirect 99 t)
 
   ;; Set up contextual fontification
   (unless (booleanp jit-lock-contextually)
-    (setq comint--fl-saved-jit-lock-contextually
+    (setq comint--fontify-input-saved-jit-lock-contextually
           jit-lock-contextually)
     (setq-local jit-lock-contextually t)
     (when jit-lock-mode
       (jit-lock-mode t))))
 
-(defun comint--fl-off ()
+(defun comint--fontify-input-off ()
   "Disable input fontification in the current comint buffer."
   (remove-function (local 'font-lock-fontify-region-function)
-                   #'comint--fl-fontify-region)
+                   #'comint--fontify-input-fontify-region)
   (remove-hook 'before-change-functions
-               #'comint--fl-ppss-flush-indirect t)
+               #'comint--fontify-input-ppss-flush-indirect t)
 
   ;; Reset contextual fontification
-  (when comint--fl-saved-jit-lock-contextually
+  (when comint--fontify-input-saved-jit-lock-contextually
     (setq-local jit-lock-contextually
-                comint--fl-saved-jit-lock-contextually)
-    (setq comint--fl-saved-jit-lock-contextually nil)
+                comint--fontify-input-saved-jit-lock-contextually)
+    (setq comint--fontify-input-saved-jit-lock-contextually nil)
     (when jit-lock-mode
       (jit-lock-mode t)))
 
   (font-lock-flush))
 
-(defun comint--fl-ppss-flush-indirect (beg &rest rest)
+(defun comint--fontify-input-ppss-flush-indirect (beg &rest rest)
   (when-let ((buf (comint-indirect-buffer t)))
     (with-current-buffer buf
       (when (memq #'syntax-ppss-flush-cache before-change-functions)
         (apply #'syntax-ppss-flush-cache beg rest)))))
 
-(defun comint--fl-fontify-region (fun beg end verbose)
+(defun comint--fontify-input-fontify-region (fun beg end verbose)
   "Fontify process output and user input in the current comint buffer.
 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."
+`comint--fontify-input-inhibit-fontification' text property."
   (pcase (funcall fun beg end verbose)
     (`(jit-lock-bounds ,beg1 . ,end1)
      (setq beg beg1 end end1)))
@@ -4069,7 +4069,7 @@ comint--fl-fontify-region
           (comint--intersect-regions
            nil (lambda (beg end)
                  (unless (get-text-property
-                          beg 'comint--fl-inhibit-fontification)
+                          beg 'comint--fontify-input-inhibit-fontification)
                    (font-lock-fontify-region beg end verbose)))
            beg end)))
     (`((jit-lock-bounds ,beg1 . ,_) . (jit-lock-bounds ,_ . ,end1))
diff --git a/lisp/ielm.el b/lisp/ielm.el
index ad41cb1f6b..fd41afa243 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -474,11 +474,11 @@ ielm-set-pm
 
 ;;; Input fontification
 
-(defcustom ielm-comint-fl-enable t
+(defcustom ielm-fontify-input-enable t
   "Enable fontification of input in ielm buffers.
 This variable only has effect when creating an ielm buffer.  Use
-the command `comint-fl-mode' to toggle fontification of input in
-an already existing ielm buffer."
+the command `comint-fontify-input-mode' to toggle fontification
+of input in an already existing ielm buffer."
   :type 'boolean
   :safe 'booleanp
   :version "29.1")
@@ -556,8 +556,8 @@ inferior-emacs-lisp-mode
   :syntax-table emacs-lisp-mode-syntax-table
   :after-hook
   (and (null comint-use-prompt-regexp)
-       ielm-comint-fl-enable
-       (comint-fl-mode))
+       ielm-fontify-input-enable
+       (comint-fontify-input-mode))
 
   (setq comint-prompt-regexp (concat "^" (regexp-quote ielm-prompt)))
   (setq-local paragraph-separate "\\'")
diff --git a/lisp/shell.el b/lisp/shell.el
index 18bb372242..641f274045 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -308,10 +308,11 @@ shell-input-autoexpand
 		 (const :tag "on" t))
   :group 'shell)
 
-(defcustom shell-comint-fl-enable t
+(defcustom shell-fontify-input-enable t
   "Enable fontification of input in shell buffers.
 This variable only has effect when the shell is started.  Use the
-command `comint-fl-mode' to toggle fontification of input."
+command `comint-fontify-input-mode' to toggle fontification of
+input."
   :type 'boolean
   :group 'shell
   :safe 'booleanp
@@ -623,8 +624,8 @@ shell-mode
   :interactive nil
   :after-hook
   (unless comint-use-prompt-regexp
-    (if shell-comint-fl-enable
-        (comint-fl-mode))
+    (if shell-fontify-input-enable
+        (comint-fontify-input-mode))
     (if shell-highlight-undef-enable
         (shell-highlight-undef-mode)))
 
@@ -1664,8 +1665,8 @@ shell-highlight-undef-matcher
                       (if buf (buffer-local-value 'default-directory buf)
                         default-directory)))
                 (cond
-                 ;; Don't highlight command output.  Mostly useful if
-                 ;; `comint-fl-mode' is disabled.
+                 ;; Don't fontify command output.  Mostly useful if
+                 ;; `comint-fontify-input-mode' is disabled.
                  ((text-property-any beg (point) 'field 'output)
                   nil)
                  ((member cmd shell-highlight-undef-aliases)
@@ -1696,7 +1697,7 @@ sh-other-keywords
 (define-minor-mode shell-highlight-undef-mode
   "Highlight undefined shell commands and aliases.
 This minor mode is mostly useful in `shell-mode' buffers and
-works better if `comint-fl-mode' is enabled."
+works better if `comint-fontify-input-mode' is enabled."
   :init-value nil
   (if shell--highlight-undef-indirect
       (progn
@@ -1706,7 +1707,7 @@ shell-highlight-undef-mode
           (with-current-buffer buf
             (font-lock-remove-keywords nil shell-highlight-undef-keywords))))
     (font-lock-remove-keywords nil shell-highlight-undef-keywords))
-  (remove-hook 'comint-fl-mode-hook
+  (remove-hook 'comint-fontify-input-mode-hook
                #'shell-highlight-undef-mode-restart t)
 
   (when shell-highlight-undef-mode
@@ -1722,9 +1723,9 @@ shell-highlight-undef-mode
             (concat
              "\\("
              "[;(){}`|&]"
-             (if comint-fl-mode
-                 ;; `comint-fl-mode' already puts point-min on end of
-                 ;; prompt
+             (if comint-fontify-input-mode
+                 ;; `comint-fontify-input-mode' already puts
+                 ;; point-min on end of prompt
                  ""
                (concat "\\|" comint-prompt-regexp))
              "\\|^"
@@ -1740,7 +1741,7 @@ shell-highlight-undef-mode
             (lambda ()
               (setq shell-highlight-undef-regexp regexp)
               (font-lock-add-keywords nil shell-highlight-undef-keywords t))))
-      (cond (comint-fl-mode
+      (cond (comint-fontify-input-mode
              (setq shell--highlight-undef-indirect setup)
              (if-let ((buf (comint-indirect-buffer t)))
                  (with-current-buffer buf
@@ -1748,7 +1749,7 @@ shell-highlight-undef-mode
                (add-hook 'comint-indirect-setup-hook setup nil t)))
             (t (funcall setup))))
 
-    (add-hook 'comint-fl-mode-hook
+    (add-hook 'comint-fontify-input-mode-hook
               #'shell-highlight-undef-mode-restart nil t))
 
   (font-lock-flush))
@@ -1756,9 +1757,9 @@ shell-highlight-undef-mode
 (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."
+depending on `comint-fontify-input-mode'.  It's useful to call
+this function when switching `comint-fontify-input-mode' in order
+to make `shell-highlight-undef-mode' redo its setup."
   (when shell-highlight-undef-mode
     (shell-highlight-undef-mode 1)))
 
-- 
2.37.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#58169: 29.0.50; comint-fl-mode fontifies the output
  2022-09-30 19:22           ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-30 19:14             ` Lars Ingebrigtsen
@ 2022-10-01 14:43             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-10-06 18:37               ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-10-01 14:43 UTC (permalink / raw)
  To: miha; +Cc: 58169, Lars Ingebrigtsen, Augusto Stoffel, Visuwesh

> @@ -2150,24 +2150,26 @@ comint-output-filter
>  	    ;; insert-before-markers is a bad thing. XXX
>  	    ;; Luckily we don't have to use it any more, we use
>  	    ;; window-point-insertion-type instead.
> -	    (insert string)
> +	    (make-local-variable 'jit-lock-mode)
> +	    (let ((jit-lock-mode nil))
> +	      (insert string)

Yuck!
Oh, and this will fail to do what it intends if the user has set
`font-lock-support-mode` t nil: don't confuse font-lock and jit-lock.

Also, I suspect that the above is not sufficient if you edit earlier
parts of the buffer (presumably previous inputs) which may cause later
parts to be *re*fontified.

A better way might be to change the font-lock rules to skip any text
that is marked as being output (e.g. by testing if the `field` property
is set to `output`).


        Stefan






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#58169: 29.0.50; comint-fl-mode fontifies the output
  2022-10-01 14:43             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-10-06 18:37               ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 10+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-10-06 18:37 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 58169, Lars Ingebrigtsen, Augusto Stoffel, Visuwesh

[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> writes:

>> @@ -2150,24 +2150,26 @@ comint-output-filter
>>  	    ;; insert-before-markers is a bad thing. XXX
>>  	    ;; Luckily we don't have to use it any more, we use
>>  	    ;; window-point-insertion-type instead.
>> -	    (insert string)
>> +	    (make-local-variable 'jit-lock-mode)
>> +	    (let ((jit-lock-mode nil))
>> +	      (insert string)
>
> Yuck!
> Oh, and this will fail to do what it intends if the user has set
> `font-lock-support-mode` t nil: don't confuse font-lock and jit-lock.
>
> Also, I suspect that the above is not sufficient if you edit earlier
> parts of the buffer (presumably previous inputs) which may cause later
> parts to be *re*fontified.
>
> A better way might be to change the font-lock rules to skip any text
> that is marked as being output (e.g. by testing if the `field` property
> is set to `output`).
>
>
>         Stefan

Thanks for feedback, discussion continued at
https://lists.gnu.org/r/emacs-devel/2022-10/msg00005.html.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-10-06 18:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-29 16:24 bug#58169: 29.0.50; comint-fl-mode fontifies the output Augusto Stoffel
2022-09-30  1:55 ` Visuwesh
2022-09-30  5:58   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-30 13:38     ` Lars Ingebrigtsen
2022-09-30 18:38       ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-30 18:26         ` Lars Ingebrigtsen
2022-09-30 19:22           ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-30 19:14             ` Lars Ingebrigtsen
2022-10-01 14:43             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-06 18:37               ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).