]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix highlighting in man pages displayed by "M-x man"
authorEli Zaretskii <eliz@gnu.org>
Fri, 9 Aug 2019 13:51:14 +0000 (16:51 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 9 Aug 2019 13:51:14 +0000 (16:51 +0300)
* lisp/man.el (Man-highlight-references0): Handle the case
when a section is divided between 2 or more chunks of text
received from the 'man' program.  (Bug#36927)

lisp/man.el

index d52ca2156d2273c14c5e9978e14a5162485b55ab..8858451b38479571d05c6286e940667560b88cfa 100644 (file)
@@ -1288,8 +1288,23 @@ default type, `Man-xref-man-page' is used for the buttons."
 
 (defun Man-highlight-references0 (start-section regexp button-pos target type)
   ;; Based on `Man-build-references-alist'
-  (when (or (null start-section)
-           (Man-find-section start-section))
+  (when (or (null start-section)        ;; Search regardless of sections.
+            ;; Section header is in this chunk.
+           (Man-find-section start-section)
+            ;; Section header was in one of the previous chunks.
+            (save-excursion
+              (save-restriction
+                (let ((orig-pos (point)))
+                  (widen)
+                  (if (Man-find-section start-section)
+                      ;; We are in the right section of the next
+                      ;; section is either not yet in the buffer, or
+                      ;; it starts after the position where we should
+                      ;; start highlighting.
+                      (progn
+                        (forward-line 1)
+                        (or (null (re-search-forward Man-heading-regexp nil t))
+                            (> (point) orig-pos))))))))
     (let ((end (if start-section
                   (progn
                     (forward-line 1)