GNU bug report logs - #19359
[PATCHES] Buttons in man pages

Previous Next

Package: emacs;

Reported by: ibeas <at> gmx.com (Álvar Ibeas)

Date: Fri, 12 Dec 2014 16:47:02 UTC

Severity: minor

Tags: patch

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19359 in the body.
You can then email your comments to 19359 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#19359; Package emacs. (Fri, 12 Dec 2014 16:47:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to ibeas <at> gmx.com (Álvar Ibeas):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 12 Dec 2014 16:47:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: ibeas <at> gmx.com (Álvar Ibeas)
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCHES] Buttons in man pages
Date: Fri, 12 Dec 2014 14:49:21 +0100
[Message part 1 (text/plain, inline)]
Hello,

I find some broken links and highlight problems after invoking:

M-x man groff

1. If a reference to another man page starts a line and the previous
   line has some text, its last word is included in the button. Also,
   the link follows the whole string. For instance:

          Introduction, history and further readings:
              roff(7).

   Here, the button tries to fetch the man page `readings:roff(7)'.

   The proposed (and lazy) patch_a doesn't allow references spanning
   several lines.

2. As the output of the background process is filtered by chunks, if
   the `SEE ALSO' section is split into several (and I guess this is
   likely if the section is as big as the one in groff(1)), only the
   first of them gets highlighted. This doesn't happen in 24.4.

   It would be necessary to format the buffer only at the end of the
   process (I don't know how to do it).

   Additionally (or instead), it might be desirable to extend the
   highlighted buttons to (what appear to be) references in the whole
   page, as is done with patch_b. This solves also the issue with man
   pages in languages other than English, where the `SEE ALSO' section
   is not recognized by the current `Man-see-also-regexp' and
   references are not highlighted.

3. There are three highlighted files in the subsection `groff Font
   Directory'. The last two are only partially highlighted. With
   patch_c, they are discarded as buttons. As for the first file, the
   link is broken. When a file ends with a dot, I guess it's more likely
   it be punctuation rather than part of the file, so patch_c also
   removes those dots.

In GNU Emacs 25.0.50.1 (i686-pc-linux-gnu, GTK+ Version 3.4.2)
 of 2014-12-11 on yermo
Windowing system distributor `The X.Org Foundation', version 11.0.11204000
System Description:	Debian GNU/Linux 7.7 (wheezy)

Configured features:
XPM JPEG TIFF GIF PNG SOUND GSETTINGS NOTIFY FREETYPE XFT ZLIB

Important settings:
  value of $LANG: es_ES.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Man

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Invoking man groff in the background
groff man page formatted
Mark set
Invoking man 1 formatters:groff in the background
Can't find the 1 formatters:groff manpage
Man-next-manpage: This is the only manpage in the buffer
Cannot find a file: /usr/share/groff/1.21/tmac.
Making completion list...
Quit

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils tabify imenu man easymenu
cl-loaddefs cl-lib ansi-color time-date tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 8 88263 5052)
 (symbols 24 18365 0)
 (miscs 20 108 241)
 (strings 16 12637 3932)
 (string-bytes 1 364509)
 (vectors 8 10694)
 (vector-slots 4 411857 4524)
 (floats 8 75 74)
 (intervals 28 4874 16)
 (buffers 520 13)
 (heap 1024 43027 358))

[patch_a (text/plain, inline)]
    Disallow line breaks in reference names

    * lisp/man.el (Man-reference-regexp)
---
 lisp/man.el |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lisp/man.el b/lisp/man.el
index a61524b..c6954a0 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -304,8 +304,7 @@ This regexp should not start with a `^' character.")
 This regular expression should start with a `^' character.")
 
 (defvar Man-reference-regexp
-  (concat "\\(" Man-name-regexp
-	  "\\(\n[ \t]+" Man-name-regexp "\\)*\\)[ \t]*(\\("
+  (concat "\\(" Man-name-regexp "\\)[ \t]*(\\("
 	  Man-section-regexp "\\))")
   "Regular expression describing a reference to another manpage.")
 
@@ -657,7 +656,7 @@ and the `Man-section-translations-alist' variables)."
      ;; "chmod(2V)" case ?
      ((string-match (concat "^" Man-reference-regexp "$") ref)
       (setq name (replace-regexp-in-string "[\n\t ]" "" (match-string 1 ref))
-	    section (match-string 3 ref)))
+	    section (match-string 2 ref)))
      ;; "2v chmod" case ?
      ((string-match (concat "^\\(" Man-section-regexp
 			    "\\) +\\(" Man-name-regexp "\\)$") ref)


[patch_b (text/plain, inline)]
    Highlight cross-references all across man pages, except the title

    * lisp/man.el (Man-highlight-references, Man-highlight-references0)
---
 lisp/man.el |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/man.el b/lisp/man.el
index a61524b..1c482ba 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1263,7 +1263,7 @@ default type, `Man-xref-man-page' is used for the buttons."
 	(Man-highlight-references0 nil Man-apropos-regexp 1
 				   'Man-default-man-entry
 				   (or xref-man-type 'Man-xref-man-page)))
-    (Man-highlight-references0 Man-see-also-regexp Man-reference-regexp 1
+    (Man-highlight-references0 nil Man-reference-regexp 1
 			       'Man-default-man-entry
 			       (or xref-man-type 'Man-xref-man-page))
     (Man-highlight-references0 Man-synopsis-regexp Man-header-regexp 0 2
@@ -1284,6 +1284,8 @@ default type, `Man-xref-man-page' is used for the buttons."
 		       (point)))
 		 (goto-char (point-min))
 		 nil)))
+      (if (eq (point) 1)
+	  (Man-next-section 1))
       (while (re-search-forward regexp end t)
 	;; An overlay button is preferable because the underlying text
 	;; may have text property highlights (Bug#7881).

[patch_c (text/plain, inline)]
    Change file links in man pages

    * lisp/man.el (Man-file-name-regexp): Remove single trailing dot
    and force beginning at the beggining of a symbol.
---
 lisp/man.el |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/man.el b/lisp/man.el
index a61524b..5f278ac 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -339,7 +339,8 @@ This regexp should not start with a `^' character.")
   "Regular expression describing references to header files.")
 
 (defvar Man-normal-file-regexp
-  (concat Man-normal-file-prefix-regexp Man-file-name-regexp)
+  (concat "\\(\\_<" Man-normal-file-prefix-regexp
+	  "[^<>\", \t\n]+?\\)\\.?\\_>")
   "Regular expression describing references to normal files.")
 
 ;; This includes the section as an optional part to catch hyphenated
@@ -1268,7 +1269,7 @@ default type, `Man-xref-man-page' is used for the buttons."
 			       (or xref-man-type 'Man-xref-man-page))
     (Man-highlight-references0 Man-synopsis-regexp Man-header-regexp 0 2
 			       'Man-xref-header-file)
-    (Man-highlight-references0 Man-files-regexp Man-normal-file-regexp 0 0
+    (Man-highlight-references0 Man-files-regexp Man-normal-file-regexp 1 1
 			       'Man-xref-normal-file)))
 
 (defun Man-highlight-references0 (start-section regexp button-pos target type)



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19359; Package emacs. (Fri, 12 Dec 2014 20:24:02 GMT) Full text and rfc822 format available.

Message #8 received at 19359 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: ibeas <at> gmx.com (Álvar Ibeas)
Cc: 19359 <at> debbugs.gnu.org
Subject: Re: bug#19359: [PATCHES] Buttons in man pages
Date: Fri, 12 Dec 2014 21:23:28 +0100
ibeas <at> gmx.com (Álvar Ibeas) writes:

> 1. If a reference to another man page starts a line and the previous
>    line has some text, its last word is included in the button. Also,
>    the link follows the whole string. For instance:
>
>           Introduction, history and further readings:
>               roff(7).
>
>    Here, the button tries to fetch the man page `readings:roff(7)'.
>
>    The proposed (and lazy) patch_a doesn't allow references spanning
>    several lines.

This will break word-wrapped references, see bug#6289.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19359; Package emacs. (Sun, 14 Dec 2014 00:41:02 GMT) Full text and rfc822 format available.

Message #11 received at 19359 <at> debbugs.gnu.org (full text, mbox):

From: ibeas <at> gmx.com (Álvar Ibeas)
To: 19359 <at> debbugs.gnu.org
Subject: Buttons in man pages
Date: Sun, 14 Dec 2014 01:40:39 +0100
[Message part 1 (text/plain, inline)]
This patch only forms wrapped references when there is a hyphenation
character, solving the first issue. It doesn't highlight however
references extended over more than two lines, in the same way as the
current `Man-default-man-entry', which is the function used to fetch the
link target.

As long as this, it might be worth to address the fact that the blank
space between the parts of a wrapped reference is fontified.

[patch_a2 (text/plain, inline)]
diff --git a/lisp/man.el b/lisp/man.el
index a61524b..7a75e46 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -84,7 +84,7 @@
 ;; - Allow a user option to mean that all the manpages should go in
 ;;   the same buffer, where they can be browsed with M-n and M-p.
 
-
+
 ;;; Code:
 
 (require 'ansi-color)
@@ -275,7 +275,7 @@ Used in `bookmark-set' to get the default bookmark name."
   :type 'hook
   :group 'man)
 
-(defvar Man-name-regexp "[-a-zA-Z0-9_­+][-a-zA-Z0-9_.:­+]*"
+(defvar Man-name-regexp "[-a-zA-Z0-9_+][-a-zA-Z0-9_.:+]*"
   "Regular expression describing the name of a manpage (without section).")
 
 (defvar Man-section-regexp "[0-9][a-zA-Z0-9+]*\\|[LNln]"
@@ -304,8 +304,8 @@ This regexp should not start with a `^' character.")
 This regular expression should start with a `^' character.")
 
 (defvar Man-reference-regexp
-  (concat "\\(" Man-name-regexp
-	  "\\(\n[ \t]+" Man-name-regexp "\\)*\\)[ \t]*(\\("
+  (concat "\\(\\_<" Man-name-regexp "?\\([-\u2010\u00AD]\n[ \t]*"
+	  "[-a-zA-Z0-9_.:­+]*\\)?\\_>\\)[ \t]*(\\("
 	  Man-section-regexp "\\))")
   "Regular expression describing a reference to another manpage.")
 
@@ -373,7 +373,7 @@ Otherwise, the value is whatever the function
   :type 'string
   :group 'man)
 
-
+
 ;; other variables and keymap initializations
 (defvar Man-original-frame)
 (make-variable-buffer-local 'Man-original-frame)
@@ -519,7 +519,7 @@ Otherwise, the value is whatever the function
   'follow-link t
   'help-echo "mouse-2: display this file")
 
-
+
 ;; ======================================================================
 ;; utilities
 
@@ -707,7 +707,7 @@ a \"/\" as a local filename.  The function returns either `man-db'
                      'man))))
     Man-support-local-filenames))
 
-
+
 ;; ======================================================================
 ;; default man entry: get word near point
 
@@ -768,14 +768,15 @@ POS defaults to `point'."
 	    (setq start (point)))))
       ;; We have found a suitable starting point, try to skip at least
       ;; one character.
-      (skip-chars-forward "-a-zA-Z0-9._+:")
+      (skip-chars-forward "-a-zA-Z0-9._+:\u2010\u00AD")
       (setq word (buffer-substring-no-properties start (point)))
       ;; If there is a continuation at the end of line, check the
       ;; following line too, eg:
       ;;     see this-
       ;;     command-here(1)
       ;; Note: This code gets executed iff our entry is after POS.
-      (when (looking-at "[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)([0-9])")
+      (when (looking-at (concat "[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)("
+				Man-section-regexp ")"))
 	(setq word (concat word (match-string-no-properties 1)))
 	;; Make sure the section number gets included by the code below.
 	(goto-char (match-end 1)))
@@ -786,16 +787,17 @@ POS defaults to `point'."
 ;;;       ;; If looking at something like *strcat(... , remove the '*'
 ;;;       (when (string-match "^*" word)
 ;;; 	(setq word (substring word 1)))
-	(concat
-	 word
-	 (and (not (string-equal word ""))
-	      ;; If looking at something like ioctl(2) or brc(1M),
-	      ;; include the section number in the returned value.
-	      (looking-at
-	       (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)"))
-	      (format "(%s)" (match-string-no-properties 1)))))))
-
-
+      (setq word (replace-regexp-in-string "[\u2010\u00AD]" "" word))
+      (concat
+       word
+       (and (not (string-equal word ""))
+	    ;; If looking at something like ioctl(2) or brc(1M),
+	    ;; include the section number in the returned value.
+	    (looking-at
+	     (concat "[ \t]*([ \t]*\\(" Man-section-regexp "\\)[ \t]*)"))
+	    (format "(%s)" (match-string-no-properties 1)))))))
+
+
 ;; ======================================================================
 ;; Top level command and background process sentinel
 
@@ -1455,7 +1457,7 @@ manpage command."
 	    (split-string args " ")))
    " "))
 
-
+
 ;; ======================================================================
 ;; set up manual mode in buffer and build alists
 
@@ -1652,7 +1654,7 @@ The following key bindings are currently in effect in the buffer:
 	      (forward-line 1)))
 	))))
 
-
+
 ;; ======================================================================
 ;; Man mode commands
 
@@ -1889,7 +1891,7 @@ Uses `Man-name-local-regexp'."
     (bookmark-default-handler
      `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark)))))
 
-
+
 ;; Init the man package variables, if not already done.
 (Man-init-defvars)
 

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19359; Package emacs. (Wed, 17 Dec 2014 22:17:01 GMT) Full text and rfc822 format available.

Message #14 received at 19359 <at> debbugs.gnu.org (full text, mbox):

From: ibeas <at> gmx.com (Álvar Ibeas)
To: 19359 <at> debbugs.gnu.org
Subject: Buttons in man pages
Date: Wed, 17 Dec 2014 23:15:56 +0100
[Message part 1 (text/plain, inline)]
Here is another suggestion that could serve as an approach to avoid
cross-references being interpreted as word-wrapped links, when the
previous line doesn't end with a hyphen. This one allows references to
span more than two lines.

The variable `Man-name-regexp' is changed to include line
breaks. Hopefully, this doesn't mess up (many) other things.

As an advantage, with this approach, a cross-reference outside the `SEE
ALSO' section that is split across two (or more) lines can be followed
by typing RET not only with point on the first of them.

[patch_a3 (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19359; Package emacs. (Tue, 25 Jun 2019 21:04:02 GMT) Full text and rfc822 format available.

Message #17 received at 19359 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: ibeas <at> gmx.com (Álvar Ibeas)
Cc: 19359 <at> debbugs.gnu.org
Subject: Re: bug#19359: [PATCHES] Buttons in man pages
Date: Tue, 25 Jun 2019 23:03:25 +0200
ibeas <at> gmx.com (Álvar Ibeas) writes:

>
> 1. If a reference to another man page starts a line and the previous
>    line has some text, its last word is included in the button. Also,
>    the link follows the whole string. For instance:
>
>           Introduction, history and further readings:
>               roff(7).
>
>    Here, the button tries to fetch the man page `readings:roff(7)'.

I'm unable to reproduce this on the Emacs trunk, so I would guess this
has been fixed by now, and I'm closing this bug report.  If it's still
present, please reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 19359 <at> debbugs.gnu.org and ibeas <at> gmx.com (Álvar Ibeas) Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 25 Jun 2019 21:04:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 24 Jul 2019 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 276 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.