* bug#59626: 29.0.50; [PATCH] comint-fontify-input: Fix field boundary issue
@ 2022-11-27 9:23 miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27 9:39 ` Eli Zaretskii
2022-12-07 15:43 ` Eli Zaretskii
0 siblings, 2 replies; 5+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-27 9:23 UTC (permalink / raw)
To: 59626
[-- Attachment #1.1: Type: text/plain, Size: 386 bytes --]
Please find attached a patch which fixes a minor issue with narrowing to
fields during comint input fontification. The issue didn't cause any
visible bugs that I know of, I only noticed it during experimentation
with tree-sitter integration.
Not that my copyright paperwork renewal is currently in progress, but I
hope that the number of lines in this patch fall below the threshold.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-comint-fontify-input-Fix-field-boundary-issue.patch --]
[-- Type: text/x-patch, Size: 1406 bytes --]
From 5e2effcaf8d4b1f1cc835fae910e8d85abb7be3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
Date: Sat, 26 Nov 2022 23:01:24 +0100
Subject: [PATCH] comint-fontify-input: Fix field boundary issue
* lisp/comint.el (comint--intersect-regions): Don't call field-end if
we are on a field boundary already.
---
lisp/comint.el | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lisp/comint.el b/lisp/comint.el
index ddb3464891..f47e6089f2 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -4122,9 +4122,15 @@ comint--intersect-regions
(save-restriction
(let ((beg2 beg1)
(end2 end1))
- (when (= beg2 beg)
+ (when (and (= beg2 beg)
+ (> beg2 (point-min))
+ (eq is-output
+ (eq (get-text-property (1- beg2) 'field) 'output)))
(setq beg2 (field-beginning beg2)))
- (when (= end2 end)
+ (when (and (= end2 end)
+ (< end2 (point-max))
+ (eq is-output
+ (eq (get-text-property (1+ end2) 'field) 'output)))
(setq end2 (field-end end2)))
;; Narrow to the whole field surrounding the region
(narrow-to-region beg2 end2))
--
2.38.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#59626: 29.0.50; [PATCH] comint-fontify-input: Fix field boundary issue
2022-11-27 9:23 bug#59626: 29.0.50; [PATCH] comint-fontify-input: Fix field boundary issue miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-27 9:39 ` Eli Zaretskii
2022-11-27 12:22 ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-07 15:43 ` Eli Zaretskii
1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-11-27 9:39 UTC (permalink / raw)
To: miha; +Cc: 59626
> Date: Sun, 27 Nov 2022 10:23:57 +0100
> From: miha--- via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> Please find attached a patch which fixes a minor issue with narrowing to
> fields during comint input fontification. The issue didn't cause any
> visible bugs that I know of, I only noticed it during experimentation
> with tree-sitter integration.
Thanks. Do you have a recipe for demonstrating the problem which you are
trying to fix?
> Not that my copyright paperwork renewal is currently in progress, but I
> hope that the number of lines in this patch fall below the threshold.
Since when your previous assignment became outdated? I need to know that to
make sure the cumulative amount of changes we already received from you
doesn't exceed the limit.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#59626: 29.0.50; [PATCH] comint-fontify-input: Fix field boundary issue
2022-11-27 9:39 ` Eli Zaretskii
@ 2022-11-27 12:22 ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27 12:27 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-27 12:22 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 59626
[-- Attachment #1: Type: text/plain, Size: 2554 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Sun, 27 Nov 2022 10:23:57 +0100
>> From: miha--- via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>
>> Please find attached a patch which fixes a minor issue with narrowing to
>> fields during comint input fontification. The issue didn't cause any
>> visible bugs that I know of, I only noticed it during experimentation
>> with tree-sitter integration.
>
> Thanks. Do you have a recipe for demonstrating the problem which you are
> trying to fix?
Instrument comint input fontification with this diff:
diff --git a/lisp/comint.el b/lisp/comint.el
index f47e6089f2..c83da95ad2 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -4083,7 +4083,10 @@ comint--fontify-input-fontify-region
nil (lambda (beg end)
(unless (get-text-property
beg 'comint--fontify-input-inhibit-fontification)
- (font-lock-fontify-region beg end verbose)))
+ (font-lock-fontify-region beg end verbose)
+ ;; Output contents of the visible portion of the
+ ;; buffer to *Messages*.
+ (message "%S" (buffer-substring-no-properties (point-min) (point-max)))))
beg end)))
(`((jit-lock-bounds ,beg1 . ,_) . (jit-lock-bounds ,_ . ,end1))
(setq beg (min beg beg1))
Now open up an M-x shell and type "date RET" into the buffer to make
your shell output the current date and an new prompt. Press "C-p C-p
C-e" to move point to "date" and change it into "datee".
Open up *Messages* and find the following strings:
"date"
"date
"
"datee
Sun Nov 27 01:05:27 PM CET 2022
~$ "
These strings represent the context in which shell fontification was
performed on the input. The last one includes "Sun Nov 27 01:05:27 PM
CET 2022\n~$ ", which is a mistake that this patch attempts to fix.
However, in pretty much all cases, this didn't result in any user
visible inaccuracies, since shell fontification of a command rarely
depends on the contents of the lines that follow it.
>> Not that my copyright paperwork renewal is currently in progress, but I
>> hope that the number of lines in this patch fall below the threshold.
>
> Since when your previous assignment became outdated? I need to know that to
> make sure the cumulative amount of changes we already received from you
> doesn't exceed the limit.
24. of October this year.
Thanks, best regards.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#59626: 29.0.50; [PATCH] comint-fontify-input: Fix field boundary issue
2022-11-27 12:22 ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-27 12:27 ` Eli Zaretskii
0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2022-11-27 12:27 UTC (permalink / raw)
To: miha; +Cc: 59626
> From: <miha@kamnitnik.top>
> Cc: 59626@debbugs.gnu.org
> Date: Sun, 27 Nov 2022 13:22:50 +0100
>
> > Thanks. Do you have a recipe for demonstrating the problem which you are
> > trying to fix?
>
> Instrument comint input fontification with this diff:
>
> diff --git a/lisp/comint.el b/lisp/comint.el
> index f47e6089f2..c83da95ad2 100644
> --- a/lisp/comint.el
> +++ b/lisp/comint.el
> @@ -4083,7 +4083,10 @@ comint--fontify-input-fontify-region
> nil (lambda (beg end)
> (unless (get-text-property
> beg 'comint--fontify-input-inhibit-fontification)
> - (font-lock-fontify-region beg end verbose)))
> + (font-lock-fontify-region beg end verbose)
> + ;; Output contents of the visible portion of the
> + ;; buffer to *Messages*.
> + (message "%S" (buffer-substring-no-properties (point-min) (point-max)))))
> beg end)))
> (`((jit-lock-bounds ,beg1 . ,_) . (jit-lock-bounds ,_ . ,end1))
> (setq beg (min beg beg1))
>
> Now open up an M-x shell and type "date RET" into the buffer to make
> your shell output the current date and an new prompt. Press "C-p C-p
> C-e" to move point to "date" and change it into "datee".
>
> Open up *Messages* and find the following strings:
>
> "date"
>
> "date
> "
>
> "datee
> Sun Nov 27 01:05:27 PM CET 2022
> ~$ "
>
> These strings represent the context in which shell fontification was
> performed on the input. The last one includes "Sun Nov 27 01:05:27 PM
> CET 2022\n~$ ", which is a mistake that this patch attempts to fix.
> However, in pretty much all cases, this didn't result in any user
> visible inaccuracies, since shell fontification of a command rarely
> depends on the contents of the lines that follow it.
Thanks, I will study this.
> >> Not that my copyright paperwork renewal is currently in progress, but I
> >> hope that the number of lines in this patch fall below the threshold.
> >
> > Since when your previous assignment became outdated? I need to know that to
> > make sure the cumulative amount of changes we already received from you
> > doesn't exceed the limit.
>
> 24. of October this year.
Then it's okay to install this without an assignment (when we decide to
install it).
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#59626: 29.0.50; [PATCH] comint-fontify-input: Fix field boundary issue
2022-11-27 9:23 bug#59626: 29.0.50; [PATCH] comint-fontify-input: Fix field boundary issue miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27 9:39 ` Eli Zaretskii
@ 2022-12-07 15:43 ` Eli Zaretskii
1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2022-12-07 15:43 UTC (permalink / raw)
To: miha; +Cc: 59626-done
> Date: Sun, 27 Nov 2022 10:23:57 +0100
> From: miha--- via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> Please find attached a patch which fixes a minor issue with narrowing to
> fields during comint input fontification. The issue didn't cause any
> visible bugs that I know of, I only noticed it during experimentation
> with tree-sitter integration.
>
> Not that my copyright paperwork renewal is currently in progress, but I
> hope that the number of lines in this patch fall below the threshold.
Thanks, installed on the master branch, and closing the bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-12-07 15:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-27 9:23 bug#59626: 29.0.50; [PATCH] comint-fontify-input: Fix field boundary issue miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27 9:39 ` Eli Zaretskii
2022-11-27 12:22 ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27 12:27 ` Eli Zaretskii
2022-12-07 15:43 ` Eli Zaretskii
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).