* PATCH: Don't mark entire man sections bold
@ 2020-10-17 6:26 Jim Blandy
2020-10-18 7:50 ` Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2020-10-17 6:26 UTC (permalink / raw
To: Emacs Devel
[-- Attachment #1: Type: text/plain, Size: 3067 bytes --]
If Man-bgproc-filter, receiving async output from `man`, happens to get a
chunk from the subprocess that ends in a bold (or whatever) section, but
not in the middle of an escape sequence, the entire section up to the end
of that output chunk gets marked bold.
This is because Man-fontify-manpage wants to process whole sections at once
(not sure why, but it's what the comment there says), so Man-bgproc-filter
doesn't tell it the true starting position of the newly inserted text it
just received, instead always backing up to the last section start. Since
successive calls to Man-fontify-manpage are passed regions that overlap,
these are passed along to ansi-color-apply-on-region.
ansi-color-apply-on-region is prepared to resume work at a position
*earlier* than requested, to handle chunks that ended in the middle of an
escape sequence. But it assumes that otherwise, if it left off work with
some sort of highlighting active, then when it's called again, it should
resume that highlighting at the `begin` position it's passed.
If that `begin` position has been backed up to the last man section start,
it ends up bolding the whole section up until the end of some random bold
bit.
Maybe `Man-fontify-manpage` should be passed more arguments. But it seemed
easier just to make ansi-color-apply-on-region more robust, and have it
remember the proper starting position whenever there's some highlighting to
be resumed.
commit 2b65205572277260d4a317f82bd7d1dd7493287f (HEAD ->
ansi-color-man-restart-fix)
Author: Jim Blandy <jimb@red-bean.com>
Date: Fri Oct 16 22:35:16 2020 -0700
Man highlighting: Don't occasionally bold entire sections.
* lisp/ansi-color.el (ansi-color-apply-on-region): Always save a
restart position in ansi-color-context-region if the region ends with
highlighting active.
diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index 141ad2353e..c3b2d98c14 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -414,11 +414,17 @@ ansi-color-apply-on-region
;; if the rest of the region should have a face, put it there
(funcall ansi-color-apply-face-function
start-marker end-marker (ansi-color--find-face codes))
- (setq ansi-color-context-region (if codes (list codes)))))
+ ;; Save a restart position when there are codes active. It's
+ ;; convenient for man.el's process filter to pass `begin'
+ ;; positions that overlap regions previously colored; these
+ ;; `codes' should not be applied to that overlap, so we need
+ ;; to know where they should really start.
+ (setq ansi-color-context-region (if codes (list codes
end-marker)))))
;; Clean up our temporary markers.
(unless (eq start-marker (cadr ansi-color-context-region))
(set-marker start-marker nil))
- (set-marker end-marker nil)))
+ (unless (eq end-marker (cadr ansi-color-context-region))
+ (set-marker end-marker nil))))
(defun ansi-color-apply-overlay-face (beg end face)
"Make an overlay from BEG to END, and apply face FACE.
[-- Attachment #2: Type: text/html, Size: 3420 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: PATCH: Don't mark entire man sections bold
2020-10-17 6:26 PATCH: Don't mark entire man sections bold Jim Blandy
@ 2020-10-18 7:50 ` Lars Ingebrigtsen
2020-10-20 2:56 ` Jim Blandy
0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-18 7:50 UTC (permalink / raw
To: Jim Blandy; +Cc: Emacs Devel
Jim Blandy <jimb@red-bean.com> writes:
> Maybe `Man-fontify-manpage` should be passed more arguments. But it
> seemed easier just to make ansi-color-apply-on-region more robust, and
> have it remember the proper starting position whenever there's some
> highlighting to be resumed.
Sounds like a good idea.
The patch was malformed, though (probably mangled by Gmail), so could
you resend it as an attachment?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: Don't mark entire man sections bold
2020-10-18 7:50 ` Lars Ingebrigtsen
@ 2020-10-20 2:56 ` Jim Blandy
2020-10-20 11:09 ` Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2020-10-20 2:56 UTC (permalink / raw
To: Lars Ingebrigtsen; +Cc: Emacs Devel
[-- Attachment #1.1: Type: text/plain, Size: 633 bytes --]
D'oh. Sorry.
On Sun, Oct 18, 2020 at 12:50 AM Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Jim Blandy <jimb@red-bean.com> writes:
>
> > Maybe `Man-fontify-manpage` should be passed more arguments. But it
> > seemed easier just to make ansi-color-apply-on-region more robust, and
> > have it remember the proper starting position whenever there's some
> > highlighting to be resumed.
>
> Sounds like a good idea.
>
> The patch was malformed, though (probably mangled by Gmail), so could
> you resend it as an attachment?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
>
[-- Attachment #1.2: Type: text/html, Size: 1117 bytes --]
[-- Attachment #2: 0001-Man-highlighting-Don-t-occasionally-bold-entire-sect.patch --]
[-- Type: text/x-patch, Size: 1685 bytes --]
From 2b65205572277260d4a317f82bd7d1dd7493287f Mon Sep 17 00:00:00 2001
From: Jim Blandy <jimb@red-bean.com>
Date: Fri, 16 Oct 2020 22:35:16 -0700
Subject: [PATCH] Man highlighting: Don't occasionally bold entire sections.
* lisp/ansi-color.el (ansi-color-apply-on-region): Always save a
restart position in ansi-color-context-region if the region ends with
highlighting active.
---
lisp/ansi-color.el | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index 141ad2353e..c3b2d98c14 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -414,11 +414,17 @@ ansi-color-apply-on-region
;; if the rest of the region should have a face, put it there
(funcall ansi-color-apply-face-function
start-marker end-marker (ansi-color--find-face codes))
- (setq ansi-color-context-region (if codes (list codes)))))
+ ;; Save a restart position when there are codes active. It's
+ ;; convenient for man.el's process filter to pass `begin'
+ ;; positions that overlap regions previously colored; these
+ ;; `codes' should not be applied to that overlap, so we need
+ ;; to know where they should really start.
+ (setq ansi-color-context-region (if codes (list codes end-marker)))))
;; Clean up our temporary markers.
(unless (eq start-marker (cadr ansi-color-context-region))
(set-marker start-marker nil))
- (set-marker end-marker nil)))
+ (unless (eq end-marker (cadr ansi-color-context-region))
+ (set-marker end-marker nil))))
(defun ansi-color-apply-overlay-face (beg end face)
"Make an overlay from BEG to END, and apply face FACE.
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: PATCH: Don't mark entire man sections bold
2020-10-20 2:56 ` Jim Blandy
@ 2020-10-20 11:09 ` Lars Ingebrigtsen
2020-10-20 16:17 ` Jim Blandy
0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-20 11:09 UTC (permalink / raw
To: Jim Blandy; +Cc: Emacs Devel
Jim Blandy <jimb@red-bean.com> writes:
> * lisp/ansi-color.el (ansi-color-apply-on-region): Always save a
> restart position in ansi-color-context-region if the region ends with
> highlighting active.
Thanks; applied to Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: Don't mark entire man sections bold
2020-10-20 11:09 ` Lars Ingebrigtsen
@ 2020-10-20 16:17 ` Jim Blandy
0 siblings, 0 replies; 5+ messages in thread
From: Jim Blandy @ 2020-10-20 16:17 UTC (permalink / raw
To: Lars Ingebrigtsen; +Cc: Emacs Devel
[-- Attachment #1: Type: text/plain, Size: 449 bytes --]
You're the best!
On Tue, Oct 20, 2020 at 4:09 AM Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Jim Blandy <jimb@red-bean.com> writes:
>
> > * lisp/ansi-color.el (ansi-color-apply-on-region): Always save a
> > restart position in ansi-color-context-region if the region ends with
> > highlighting active.
>
> Thanks; applied to Emacs 28.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
>
[-- Attachment #2: Type: text/html, Size: 913 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-10-20 16:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-17 6:26 PATCH: Don't mark entire man sections bold Jim Blandy
2020-10-18 7:50 ` Lars Ingebrigtsen
2020-10-20 2:56 ` Jim Blandy
2020-10-20 11:09 ` Lars Ingebrigtsen
2020-10-20 16:17 ` Jim Blandy
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.