bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#19359: Buttons in man pages


From: Álvar Ibeas
Subject: bug#19359: Buttons in man pages
Date: Sun, 14 Dec 2014 01:40:39 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

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.

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)
 

reply via email to

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