Fix handling of manpage references divided by hyphenation
* lisp/man.el (Man-reference-regexp): Accept a newline as part of a manpage name only if it's preceded by a hyphen. (Bug#34286) (Man-translate-references): Adapt to change in 'Man-reference-regexp'. (Man-default-man-entry): Support references divided between two lines by an ASCII hyphen. This is a left-over from fixing bug#6289.
This commit is contained in:
parent
7ad0cd6f1e
commit
57ece2a052
1 changed files with 16 additions and 5 deletions
21
lisp/man.el
21
lisp/man.el
|
@ -318,7 +318,7 @@ This regular expression should start with a `^' character.")
|
||||||
|
|
||||||
(defvar Man-reference-regexp
|
(defvar Man-reference-regexp
|
||||||
(concat "\\(" Man-name-regexp
|
(concat "\\(" Man-name-regexp
|
||||||
"\\(‐?\n[ \t]+" Man-name-regexp "\\)*\\)[ \t]*(\\("
|
"\\(\\([-‐]\n\\)?[ \t]+" Man-name-regexp "\\)*\\)[ \t]*(\\("
|
||||||
Man-section-regexp "\\))")
|
Man-section-regexp "\\))")
|
||||||
"Regular expression describing a reference to another manpage.")
|
"Regular expression describing a reference to another manpage.")
|
||||||
|
|
||||||
|
@ -664,7 +664,7 @@ and the `Man-section-translations-alist' variables)."
|
||||||
;; "chmod(2V)" case ?
|
;; "chmod(2V)" case ?
|
||||||
((string-match (concat "^" Man-reference-regexp "$") ref)
|
((string-match (concat "^" Man-reference-regexp "$") ref)
|
||||||
(setq name (replace-regexp-in-string "[\n\t ]" "" (match-string 1 ref))
|
(setq name (replace-regexp-in-string "[\n\t ]" "" (match-string 1 ref))
|
||||||
section (match-string 3 ref)))
|
section (match-string 4 ref)))
|
||||||
;; "2v chmod" case ?
|
;; "2v chmod" case ?
|
||||||
((string-match (concat "^\\(" Man-section-regexp
|
((string-match (concat "^\\(" Man-section-regexp
|
||||||
"\\) +\\(" Man-name-regexp "\\)$") ref)
|
"\\) +\\(" Man-name-regexp "\\)$") ref)
|
||||||
|
@ -783,11 +783,22 @@ POS defaults to `point'."
|
||||||
;; see this-
|
;; see this-
|
||||||
;; command-here(1)
|
;; command-here(1)
|
||||||
;; Note: This code gets executed iff our entry is after POS.
|
;; 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
|
||||||
(setq word (concat word (match-string-no-properties 1)))
|
(concat
|
||||||
|
"‐?[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)(" Man-section-regexp ")"))
|
||||||
|
(let ((1st-part word))
|
||||||
|
(setq word (concat word (match-string-no-properties 1)))
|
||||||
|
;; If they use -Tascii, we cannot know whether a hyphen at
|
||||||
|
;; EOL is or isn't part of the referenced manpage name.
|
||||||
|
;; Heuristics: if the part of the manpage before the hyphen
|
||||||
|
;; doesn't include a hyphen, we consider the hyphen to be
|
||||||
|
;; added by troff, and remove it.
|
||||||
|
(or (not (eq (string-to-char (substring 1st-part -1)) ?-))
|
||||||
|
(string-match-p "-" (substring 1st-part 0 -1))
|
||||||
|
(setq word (replace-regexp-in-string "-" "" word))))
|
||||||
;; Make sure the section number gets included by the code below.
|
;; Make sure the section number gets included by the code below.
|
||||||
(goto-char (match-end 1)))
|
(goto-char (match-end 1)))
|
||||||
(when (string-match "[-._]+$" word)
|
(when (string-match "[-._‐]+$" word)
|
||||||
(setq word (substring word 0 (match-beginning 0))))
|
(setq word (substring word 0 (match-beginning 0))))
|
||||||
;; The following was commented out since the preceding code
|
;; The following was commented out since the preceding code
|
||||||
;; should not produce a leading "*" in the first place.
|
;; should not produce a leading "*" in the first place.
|
||||||
|
|
Loading…
Add table
Reference in a new issue