From unknown Sun Jun 15 13:00:42 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#19359 <19359@debbugs.gnu.org> To: bug#19359 <19359@debbugs.gnu.org> Subject: Status: [PATCHES] Buttons in man pages Reply-To: bug#19359 <19359@debbugs.gnu.org> Date: Sun, 15 Jun 2025 20:00:42 +0000 retitle 19359 [PATCHES] Buttons in man pages reassign 19359 emacs submitter 19359 ibeas@gmx.com (=C3=81lvar Ibeas) severity 19359 minor tag 19359 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 12 11:46:15 2014 Received: (at submit) by debbugs.gnu.org; 12 Dec 2014 16:46:15 +0000 Received: from localhost ([127.0.0.1]:44132 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XzTM6-0006kE-9z for submit@debbugs.gnu.org; Fri, 12 Dec 2014 11:46:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53752) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XzQbQ-0002JL-FA for submit@debbugs.gnu.org; Fri, 12 Dec 2014 08:49:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzQbD-0006qf-ON for submit@debbugs.gnu.org; Fri, 12 Dec 2014 08:49:47 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60673) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzQbD-0006qa-Kr for submit@debbugs.gnu.org; Fri, 12 Dec 2014 08:49:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzQb7-0005Jp-5Y for bug-gnu-emacs@gnu.org; Fri, 12 Dec 2014 08:49:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzQaz-0006of-GB for bug-gnu-emacs@gnu.org; Fri, 12 Dec 2014 08:49:33 -0500 Received: from mout.gmx.net ([212.227.17.22]:58130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzQaz-0006oR-62 for bug-gnu-emacs@gnu.org; Fri, 12 Dec 2014 08:49:25 -0500 Received: from yermo ([84.127.142.133]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0M2cDB-1Xj0H13R1p-00sLch; Fri, 12 Dec 2014 14:49:23 +0100 From: ibeas@gmx.com (=?utf-8?Q?=C3=81lvar?= Ibeas) To: bug-gnu-emacs@gnu.org Subject: [PATCHES] Buttons in man pages Date: Fri, 12 Dec 2014 14:49:21 +0100 Message-ID: <87a92tf066.fsf@gmx.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K0:2LQBN9uyPj/bk0XtIottUz958roZi6IpRWHwsADG7M+BNT6RDji QJf1WBGV30dsABzmfPLQamQxOj+VFMqQKMmrc2tTL6iRg94G3Zgu1YTPFC3CAqlqkZum47o qe0nugOjN67f92p3g4m8A9iZbFYe37YS/ycISwJRq+Xaim9XmlyPBkBSlpvsDj7AByuQxEq GsNSzsQeCGyk4HsHn5mdQ== X-UI-Out-Filterresults: notjunk:1; X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 12 Dec 2014 11:46:12 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) --=-=-= Content-Type: text/plain 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)) --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=patch_a Content-Description: patch_a 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) --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=patch_b Content-Description: patch_b 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). --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=patch_c Content-Description: patch_c 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) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 12 15:23:33 2014 Received: (at 19359) by debbugs.gnu.org; 12 Dec 2014 20:23:33 +0000 Received: from localhost ([127.0.0.1]:44216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XzWkP-0003pZ-6T for submit@debbugs.gnu.org; Fri, 12 Dec 2014 15:23:33 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:44100) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XzWkM-0003pQ-SY for 19359@debbugs.gnu.org; Fri, 12 Dec 2014 15:23:31 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3jzk353JL6z3hjcM; Fri, 12 Dec 2014 21:23:29 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3jzk351SF6zvh2R; Fri, 12 Dec 2014 21:23:29 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id VUKSmqL4t42o; Fri, 12 Dec 2014 21:23:28 +0100 (CET) X-Auth-Info: D72ubLKBL40SFxgtBTyOKK4hkQVhaOZ2pLhl45Fsu8EibR2KPPkWei3ZRySFELfd Received: from igel.home (host-188-174-214-129.customer.m-online.net [188.174.214.129]) by mail.mnet-online.de (Postfix) with ESMTPA; Fri, 12 Dec 2014 21:23:28 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id 29C572C1C40; Fri, 12 Dec 2014 21:23:28 +0100 (CET) From: Andreas Schwab To: ibeas@gmx.com (=?utf-8?Q?=C3=81lvar?= Ibeas) Subject: Re: bug#19359: [PATCHES] Buttons in man pages References: <87a92tf066.fsf@gmx.com> X-Yow: - if it GLISTENS, gobble it!! Date: Fri, 12 Dec 2014 21:23:28 +0100 In-Reply-To: <87a92tf066.fsf@gmx.com> (=?utf-8?Q?=22=C3=81lvar?= Ibeas"'s message of "Fri, 12 Dec 2014 14:49:21 +0100") Message-ID: <87bnn8vcqn.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19359 Cc: 19359@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) ibeas@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@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 13 19:40:50 2014 Received: (at 19359) by debbugs.gnu.org; 14 Dec 2014 00:40:50 +0000 Received: from localhost ([127.0.0.1]:45114 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XzxEv-0001d4-JE for submit@debbugs.gnu.org; Sat, 13 Dec 2014 19:40:50 -0500 Received: from mout.gmx.net ([212.227.17.21]:49263) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XzxEt-0001cm-DP for 19359@debbugs.gnu.org; Sat, 13 Dec 2014 19:40:48 -0500 Received: from yermo ([84.127.142.133]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0LjdS8-1XOPUe3Uk4-00bcMw; Sun, 14 Dec 2014 01:40:41 +0100 From: ibeas@gmx.com (=?utf-8?Q?=C3=81lvar?= Ibeas) To: 19359@debbugs.gnu.org Subject: Buttons in man pages Date: Sun, 14 Dec 2014 01:40:39 +0100 Message-ID: <87k31vhxmg.fsf@gmx.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K0:FGeq3Mgujy49wnhE6oha+x0COj+S57VdrzQJorQmsm0BffOYfqC /zfjA6WP3iKJDzychpT9ySWGaEFXDezUVqLISFmwy4dT41b/dhgzUfTd9JnS7Vim4mM/SaW f2v6ZCTe8gXmgOfz1D4tgIQObYYRQ0JUe+uHj+7mddaOBF+uZTfs3aC1Hjdp1UZ1SU8mQB+ MsQOa+Yu7VvgwamjBDUHA== X-UI-Out-Filterresults: notjunk:1; X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19359 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline; filename=patch_a2 Content-Transfer-Encoding: quoted-printable Content-Description: patch_a2 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. =20 - + ;;; Code: =20 (require 'ansi-color) @@ -275,7 +275,7 @@ Used in `bookmark-set' to get the default bookmark name= ." :type 'hook :group 'man) =20 -(defvar Man-name-regexp "[-a-zA-Z0-9_=C2=AD+][-a-zA-Z0-9_.:=C2=AD+]*" +(defvar Man-name-regexp "[-a-zA-Z0-9_+][-a-zA-Z0-9_.:+]*" "Regular expression describing the name of a manpage (without section).") =20 (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.") =20 (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_.:=C2=AD+]*\\)?\\_>\\)[ \t]*(\\(" Man-section-regexp "\\))") "Regular expression describing a reference to another manpage.") =20 @@ -373,7 +373,7 @@ Otherwise, the value is whatever the function :type 'string :group 'man) =20 - + ;; 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") =20 - + ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ;; utilities =20 @@ -707,7 +707,7 @@ a \"/\" as a local filename. The function returns eith= er `man-db' 'man)))) Man-support-local-filenames)) =20 - + ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ;; default man entry: get word near point =20 @@ -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))))))) + + ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ;; Top level command and background process sentinel =20 @@ -1455,7 +1457,7 @@ manpage command." (split-string args " "))) " ")) =20 - + ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ;; set up manual mode in buffer and build alists =20 @@ -1652,7 +1654,7 @@ The following key bindings are currently in effect in= the buffer: (forward-line 1))) )))) =20 - + ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ;; Man mode commands =20 @@ -1889,7 +1891,7 @@ Uses `Man-name-local-regexp'." (bookmark-default-handler `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark))))) =20 - + ;; Init the man package variables, if not already done. (Man-init-defvars) =20 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 17 17:16:04 2014 Received: (at 19359) by debbugs.gnu.org; 17 Dec 2014 22:16:04 +0000 Received: from localhost ([127.0.0.1]:49329 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1Mt1-0007qf-4c for submit@debbugs.gnu.org; Wed, 17 Dec 2014 17:16:04 -0500 Received: from mout.gmx.net ([212.227.17.22]:53982) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1Msy-0007qD-BN for 19359@debbugs.gnu.org; Wed, 17 Dec 2014 17:16:01 -0500 Received: from yermo ([84.127.142.133]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0LpbfG-1XOTtJ1PHS-00fSjw; Wed, 17 Dec 2014 23:15:59 +0100 From: ibeas@gmx.com (=?utf-8?Q?=C3=81lvar?= Ibeas) To: 19359@debbugs.gnu.org Subject: Buttons in man pages Date: Wed, 17 Dec 2014 23:15:56 +0100 Message-ID: <87bnn1ylb7.fsf@gmx.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K0:zs0JKSXzDUeOWE+uRhyeEoK4l1tRbM/KEh77++5C7SJ6lKLYwXq ggH45nzOeyaOyxCf3yPT/7AEA0L+kWo7XD2QbojcfiikMci2sCSHo2mTkb8sU/ZnIqiKXWt ZdC54DZN4NRq9HigbHJ3QBjLFOUDpm6szLSR3VE5lawo5v0UwcwJ5ANKUzsyC9KIHAix/40 w3NRMqD1JQFXROzHvODWA== X-UI-Out-Filterresults: notjunk:1; X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19359 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=patch_a3 Content-Transfer-Encoding: quoted-printable Content-Description: patch_a3 diff --git a/lisp/man.el b/lisp/man.el index a61524b..51e5b1b 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -275,7 +275,22 @@ Used in `bookmark-set' to get the default bookmark nam= e." :type 'hook :group 'man) =20 -(defvar Man-name-regexp "[-a-zA-Z0-9_=C2=AD+][-a-zA-Z0-9_.:=C2=AD+]*" +(defvar Man-name-leading-character "[-a-zA-Z0-9_+]" + "Regular expression describing the first character of the name of a manp= age.") + +(defvar Man-name-character "[-a-zA-Z0-9_.:+]" + "Regular expression describing a generic character in the name of a manp= age.") + +(defvar Man-hyphenation-added-character "[\u2010\u00AD]" + "Regular expression describing a character added to break a name.") + +(defvar Man-hyphenation-character + (concat "\\(?:-\\|" Man-hyphenation-added-character "\\)") + "Regular expression describing a character used for hyphenation.") + +(defvar Man-name-regexp + (concat "\\(\\_<" Man-name-leading-character "\\(" Man-name-character "*= ?" + Man-hyphenation-character "\n[ \t]*\\)*" Man-name-character "*\\_>\\)") "Regular expression describing the name of a manpage (without section).") =20 (defvar Man-section-regexp "[0-9][a-zA-Z0-9+]*\\|[LNln]" @@ -304,9 +319,7 @@ This regexp should not start with a `^' character.") This regular expression should start with a `^' character.") =20 (defvar Man-reference-regexp - (concat "\\(" Man-name-regexp - "\\(\n[ \t]+" Man-name-regexp "\\)*\\)[ \t]*(\\(" - Man-section-regexp "\\))") + (concat Man-name-regexp "[ \t]*(\\(" Man-section-regexp "\\))") "Regular expression describing a reference to another manpage.") =20 (defvar Man-apropos-regexp @@ -707,7 +720,33 @@ a \"/\" as a local filename. The function returns eit= her `man-db' 'man)))) Man-support-local-filenames)) =20 - + +(defun Man-skip-name-backward () + "Move point backward until the beginning of what seems to be a +name. Return the name length." + (let (travel) + (setq travel (skip-chars-backward "-a-zA-Z0-9_.:+")) + (while (looking-back (concat Man-hyphenation-character "\n[ \t]*")) + (end-of-line 0) + (backward-char) + (setq travel (+ travel + (skip-chars-backward "-a-zA-Z0-9_.:+")))) + travel)) + +(defun Man-skip-name-forward () + "Move point forward until the end of what seems to be a name. +Return the name length." + (let (travel) + (setq travel (skip-chars-forward "-a-zA-Z0-9_.:+")) + (while (or (and (looking-back "-") + (looking-at "$")) + (looking-at (concat Man-hyphenation-character "$"))) + (beginning-of-line 2) + (skip-chars-forward "[ \t]*") + (setq travel (+ travel + (skip-chars-forward "-a-zA-Z0-9_.:+")))) + travel)) + ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ;; default man entry: get word near point =20 @@ -729,7 +768,7 @@ POS defaults to `point'." ;; We skipped a valid section number backwards, look at ;; preceding text. (or (and (skip-chars-backward ",; \t") - (not (zerop (skip-chars-backward "-a-zA-Z0-9._+:")))) + (not (zerop (Man-skip-name-backward)))) ;; Not a valid entry, move POS after closing paren. (not (setq pos (match-end 0))))) ;; We have a candidate, make `start' record its starting @@ -737,7 +776,7 @@ POS defaults to `point'." (setq start (point)) ;; Otherwise look at char before POS. (goto-char pos) - (if (not (zerop (skip-chars-backward "-a-zA-Z0-9._+:"))) + (if (not (zerop (Man-skip-name-backward))) ;; Our candidate is just before or around POS. (setq start (point)) ;; Otherwise record the current column and look backwards. @@ -750,7 +789,7 @@ POS defaults to `point'." ;; Skip section number backwards. (goto-char (match-beginning 0)) (skip-chars-backward " \t")) - (if (not (zerop (skip-chars-backward "-a-zA-Z0-9._+:"))) + (if (not (zerop (Man-skip-name-backward))) (progn ;; We have a candidate before POS ... (setq start (point)) @@ -768,17 +807,12 @@ 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._+:") + (Man-skip-name-forward) (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])") - (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))) + (setq word (replace-regexp-in-string + (concat "\\([ \t\n]\\|" + Man-hyphenation-added-character "\\)") + "" word)) (when (string-match "[-._]+$" word) (setq word (substring word 0 (match-beginning 0)))) ;; The following was commented out since the preceding code @@ -786,14 +820,14 @@ 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))))))) + (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))))))) =20 ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @@ -1535,7 +1569,7 @@ The following key bindings are currently in effect in= the buffer: (end (progn (Man-next-section 1) (point))) - hyphenated + ;; hyphenated (runningpoint -1)) (save-restriction (narrow-to-region start end) @@ -1543,18 +1577,22 @@ The following key bindings are currently in effect = in the buffer: (back-to-indentation) (while (and (not (eobp)) (/=3D (point) runningpoint)) (setq runningpoint (point)) - (if (re-search-forward Man-hyphenated-reference-regexp end t) - (let* ((word (match-string 0)) - (len (1- (length word)))) - (if hyphenated - (setq word (concat hyphenated word) - hyphenated nil - ;; Update len, in case a reference spans - ;; more than two lines (paranoia). - len (1- (length word)))) - (if (memq (aref word len) '(?- ?=C2=AD)) - (setq hyphenated (substring word 0 len))) - (and (string-match Man-reference-regexp word) + (if (re-search-forward Man-reference-regexp end t) + (let* ((word (match-string 0))) + ;; (len (1- (length word))) + ;; (if hyphenated + ;; (setq word (concat hyphenated word) + ;; hyphenated nil + ;; ;; Update len, in case a reference spans + ;; ;; more than two lines (paranoia). + ;; len (1- (length word)))) + ;; (if (memq (aref word len) '(?- ?=C2=AD)) + ;; (setq hyphenated (substring word 0 len))) + (setq word (replace-regexp-in-string + (concat "\\([ \t\n]\\|" + Man-hyphenation-added-character "\\)") + "" word)) + (and ;(string-match Man-reference-regexp word) (not (member word Man--refpages)) (push word Man--refpages)))) (skip-chars-forward " \t\n,")))))) @@ -1720,25 +1758,25 @@ Actually the section moved to is described by `Man-= see-also-regexp'." (error "%s" (concat "No " Man-see-also-regexp " section found in the current manpage")))) =20 -(defun Man-possibly-hyphenated-word () - "Return a possibly hyphenated word at point. -If the word starts at the first non-whitespace column, and the -previous line ends with a hyphen, return the last word on the previous -line instead. Thus, if a reference to \"tcgetpgrp(3V)\" is hyphenated -as \"tcgetp-grp(3V)\", and point is at \"grp(3V)\", we return -\"tcgetp-\" instead of \"grp\"." - (save-excursion - (skip-syntax-backward "w()") - (skip-chars-forward " \t") - (let ((beg (point)) - (word (current-word))) - (when (eq beg (save-excursion - (back-to-indentation) - (point))) - (end-of-line 0) - (if (eq (char-before) ?-) - (setq word (current-word)))) - word))) +;; (defun Man-possibly-hyphenated-word () +;; "Return a possibly hyphenated word at point. +;; If the word starts at the first non-whitespace column, and the +;; previous line ends with a hyphen, return the last word on the previous +;; line instead. Thus, if a reference to \"tcgetpgrp(3V)\" is hyphenated +;; as \"tcgetp-grp(3V)\", and point is at \"grp(3V)\", we return +;; \"tcgetp-\" instead of \"grp\"." +;; (save-excursion +;; (skip-syntax-backward "w()") +;; (skip-chars-forward " \t") +;; (let ((beg (point)) +;; (word (current-word))) +;; (when (eq beg (save-excursion +;; (back-to-indentation) +;; (point))) +;; (end-of-line 0) +;; (if (eq (char-before) ?-) +;; (setq word (current-word)))) +;; word))) =20 (defvar Man--last-refpage nil) =20 @@ -1752,14 +1790,14 @@ Specify which REFERENCE to use; default is based on= word at point." (let* ((default (or (car (all-completions (let ((word - (or (Man-possibly-hyphenated-word) - ""))) + (or (Man-default-man-entry) + ""))) ;; strip a trailing '-': - (if (string-match "-$" word) - (substring word 0 - (match-beginning 0)) - word)) - Man--refpages)) + ;; (if (string-match "-$" word) + ;; (substring word 0 + ;; (match-beginning 0)) + ;; word)) + Man--refpages))) (if (member Man--last-refpage Man--refpages) Man--last-refpage (car Man--refpages)))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 25 17:03:31 2019 Received: (at 19359) by debbugs.gnu.org; 25 Jun 2019 21:03:31 +0000 Received: from localhost ([127.0.0.1]:33656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfsbD-0005El-HD for submit@debbugs.gnu.org; Tue, 25 Jun 2019 17:03:31 -0400 Received: from quimby.gnus.org ([80.91.231.51]:56574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfsbC-0005Ee-7g for 19359@debbugs.gnu.org; Tue, 25 Jun 2019 17:03:30 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hfsb8-0004Lh-1T; Tue, 25 Jun 2019 23:03:28 +0200 From: Lars Ingebrigtsen To: ibeas@gmx.com (=?utf-8?Q?=C3=81lvar?= Ibeas) Subject: Re: bug#19359: [PATCHES] Buttons in man pages References: <87a92tf066.fsf@gmx.com> Date: Tue, 25 Jun 2019 23:03:25 +0200 In-Reply-To: <87a92tf066.fsf@gmx.com> (=?utf-8?Q?=22=C3=81lvar?= Ibeas"'s message of "Fri, 12 Dec 2014 14:49:21 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: ibeas@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: > > Int [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19359 Cc: 19359@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) ibeas@gmx.com (=C3=81lvar 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. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 25 17:03:37 2019 Received: (at control) by debbugs.gnu.org; 25 Jun 2019 21:03:37 +0000 Received: from localhost ([127.0.0.1]:33659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfsbI-0005F7-Sk for submit@debbugs.gnu.org; Tue, 25 Jun 2019 17:03:37 -0400 Received: from quimby.gnus.org ([80.91.231.51]:56588) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfsbH-0005Ex-GN for control@debbugs.gnu.org; Tue, 25 Jun 2019 17:03:35 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hfsbF-0004Lo-0Z for control@debbugs.gnu.org; Tue, 25 Jun 2019 23:03:34 +0200 Date: Tue, 25 Jun 2019 23:03:32 +0200 Message-Id: To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #19359 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 19359 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 19359 quit From unknown Sun Jun 15 13:00:42 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 24 Jul 2019 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator