unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master 90744ff0be 1/2: comint-fl: Prevent fontification of output as input
@ 2022-10-01  6:44 Eli Zaretskii
  2022-10-06 18:31 ` miha
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2022-10-01  6:44 UTC (permalink / raw)
  To: Miha Rihtaršič, Lars Ingebrigtsen; +Cc: emacs-devel

> branch: master
> commit 90744ff0be581b69cedea1194b7e78265bdb67a4
> Author: Miha Rihtaršič <miha@kamnitnik.top>
> Commit: Lars Ingebrigtsen <larsi@gnus.org>
> 
>     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 @@ Make backspaces delete the previous character."
>  	    ;; 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)

Isn't that hammer too large/blunt for this job?  It will disable every
single function registered with jit-lock, not just the fontification
functions.  Some of the functions registered with jit-lock have
nothing to do with fontifications.



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

* Re: master 90744ff0be 1/2: comint-fl: Prevent fontification of output as input
  2022-10-01  6:44 master 90744ff0be 1/2: comint-fl: Prevent fontification of output as input Eli Zaretskii
@ 2022-10-06 18:31 ` miha
  2022-10-07 11:44   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: miha @ 2022-10-06 18:31 UTC (permalink / raw)
  To: Eli Zaretskii, Lars Ingebrigtsen; +Cc: emacs-devel, Stefan Monnier


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

Eli Zaretskii <eliz@gnu.org> writes:

>> branch: master
>> commit 90744ff0be581b69cedea1194b7e78265bdb67a4
>> Author: Miha Rihtaršič <miha@kamnitnik.top>
>> Commit: Lars Ingebrigtsen <larsi@gnus.org>
>> 
>>     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 @@ Make backspaces delete the previous character."
>>  	    ;; 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)
>
> Isn't that hammer too large/blunt for this job?  It will disable every
> single function registered with jit-lock, not just the fontification
> functions.  Some of the functions registered with jit-lock have
> nothing to do with fontifications.

Sorry for late reply. I agree. Please consider applying the attached
patches.

See also reply https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58169#31


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

From f3edbf1484cfbab781d76c6d39f6157b8506224d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
Date: Thu, 6 Oct 2022 19:06:37 +0200
Subject: [PATCH 1/2] Revert "comint-fl: Prevent fontification of output as
 input"

This reverts commit 90744ff0be581b69cedea1194b7e78265bdb67a4.
---
 lisp/comint.el | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index b1f3ad8259..e3eee8411c 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2150,26 +2150,24 @@ 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.
-	    (make-local-variable 'jit-lock-mode)
-	    (let ((jit-lock-mode nil))
-	      (insert string)
+	    (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-fontify-input-Don-t-fontify-output-as-input-d.patch --]
[-- Type: text/x-patch, Size: 1321 bytes --]

From 2264b29ed709babf3f22668ea25ebde431845be7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
Date: Thu, 6 Oct 2022 20:22:39 +0200
Subject: [PATCH 2/2] comint-fontify-input: Don't fontify output as input,
 different approach

* lisp/comint.el (comint-output-filter): Propertize process output
with field=output before inserting it into buffer to prevent
comint-fontify-input from fontifying it (bug#58169).
---
 lisp/comint.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/comint.el b/lisp/comint.el
index e3eee8411c..07ced8d321 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2147,6 +2147,12 @@ comint-output-filter
 	    (goto-char (process-mark process))
 	    (set-marker comint-last-output-start (point))
 
+            ;; Before we call `comint--mark-as-output' later,
+            ;; redisplay can be called.  We mark the inserted text as
+            ;; output early, to prevent redisplay from fontifying it
+            ;; as input in case of `comint-fontify-input-mode'.
+            (put-text-property 0 (length string) 'field 'output string)
+
 	    ;; 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.
-- 
2.37.2


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

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

* Re: master 90744ff0be 1/2: comint-fl: Prevent fontification of output as input
  2022-10-06 18:31 ` miha
@ 2022-10-07 11:44   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-10-07 11:44 UTC (permalink / raw)
  To: miha; +Cc: Eli Zaretskii, emacs-devel, Stefan Monnier

<miha@kamnitnik.top> writes:

> Sorry for late reply. I agree. Please consider applying the attached
> patches.

Thanks; pushed to Emacs 29.



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

end of thread, other threads:[~2022-10-07 11:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-01  6:44 master 90744ff0be 1/2: comint-fl: Prevent fontification of output as input Eli Zaretskii
2022-10-06 18:31 ` miha
2022-10-07 11:44   ` Lars Ingebrigtsen

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).