unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: <miha@kamnitnik.top>
To: Eli Zaretskii <eliz@gnu.org>, Lars Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: master 90744ff0be 1/2: comint-fl: Prevent fontification of output as input
Date: Thu, 06 Oct 2022 20:31:18 +0200	[thread overview]
Message-ID: <874jwgu7m1.fsf@miha-pc> (raw)
In-Reply-To: <831qrscabj.fsf@gnu.org>


[-- 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 --]

  reply	other threads:[~2022-10-06 18:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-10-07 11:44   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jwgu7m1.fsf@miha-pc \
    --to=miha@kamnitnik.top \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).