[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#36927: 26.2.90; include stdarg.h is without hyperlinking on vfprintf

From: VanL
Subject: bug#36927: 26.2.90; include stdarg.h is without hyperlinking on vfprintf's manpage
Date: Sat, 10 Aug 2019 15:05:16 +1000

> On 9 Aug 2019, at 23:58, Eli Zaretskii <address@hidden> wrote:
>> Date: Mon, 05 Aug 2019 19:10:28 +0300
>> From: Eli Zaretskii <address@hidden>
>> Cc: address@hidden
>>> From: VanL <van@scratch.space>
>>> Date: Mon, 5 Aug 2019 11:51:56 +1000
>>> See manpage for vfprintf().
>>> Unlike the first instance of the #include preprocessing directive
>>>  #include <stdio.h>
>>> at approximately line 12 of printf(3), which is underlined and
>>> hyperlinked, the second instance at approximately line 32, is not
>>> underlined and not hyperlinked.
>>> 1. M-x man RET vfprintf
>>> 2. on line 32 see #include <stdarg.h> which is without hyperlinking
>> For some reason, we don't put a button on the second #include.
> The logic in Man-highlight-references0 was flawed: it assumed that a
> section ("SYNOPSIS", "FILES", "SEE ALSO", etc.) is always received
> entirely in a single chunk of text that is read from the subprocess,
> which is, of course, not guaranteed, and depends on factors such as
> the size of each section, buffering, how busy is the system, etc.
> (Those reasons also made this a bitch to debug, because a bug comes
> and goes unpredictably, and never shows when one steps with Edebug.)


That sounds really convoluted and this is what I can see

diff --git a/lisp/man.el b/lisp/man.el
index d52ca2156d..8858451b38 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1288,8 +1288,23 @@ Man-highlight-references
 (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
                     (forward-line 1)

> I think I made it much better on master, although I still see a rare
> case where one or the other "include" is not buttonized.  But I've run
> out of time, so someone else will have to find and fix what I missed.
> I'm leaving this bug open because I don't think it's 100% fixed.

A possible way is to wait for all the subprocess sections to be done and to 
post-process on the fully collected buffer having lines like

line 11: .In stdio.h
line 24: .In stdarg.h

with buttonization transformation in theory like [1]

        8.4 Computing with Lists

reply via email to

[Prev in Thread] Current Thread [Next in Thread]