diff options
| author | Eli Zaretskii | 2019-02-16 11:51:25 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-02-16 11:51:25 +0200 |
| commit | 57ece2a0521e3167254f3b97fbfa7dc51aa9fea5 (patch) | |
| tree | 22772deecbf95a7e04955851d1ccdd3d046e6d88 | |
| parent | 7ad0cd6f1ebb90261bea99fd591b7cdb00f8aa8e (diff) | |
| download | emacs-57ece2a0521e3167254f3b97fbfa7dc51aa9fea5.tar.gz emacs-57ece2a0521e3167254f3b97fbfa7dc51aa9fea5.zip | |
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.
| -rw-r--r-- | lisp/man.el | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lisp/man.el b/lisp/man.el index e38d2854fc3..409fadb66b8 100644 --- a/lisp/man.el +++ b/lisp/man.el | |||
| @@ -318,7 +318,7 @@ This regular expression should start with a `^' character.") | |||
| 318 | 318 | ||
| 319 | (defvar Man-reference-regexp | 319 | (defvar Man-reference-regexp |
| 320 | (concat "\\(" Man-name-regexp | 320 | (concat "\\(" Man-name-regexp |
| 321 | "\\(‐?\n[ \t]+" Man-name-regexp "\\)*\\)[ \t]*(\\(" | 321 | "\\(\\([-‐]\n\\)?[ \t]+" Man-name-regexp "\\)*\\)[ \t]*(\\(" |
| 322 | Man-section-regexp "\\))") | 322 | Man-section-regexp "\\))") |
| 323 | "Regular expression describing a reference to another manpage.") | 323 | "Regular expression describing a reference to another manpage.") |
| 324 | 324 | ||
| @@ -664,7 +664,7 @@ and the `Man-section-translations-alist' variables)." | |||
| 664 | ;; "chmod(2V)" case ? | 664 | ;; "chmod(2V)" case ? |
| 665 | ((string-match (concat "^" Man-reference-regexp "$") ref) | 665 | ((string-match (concat "^" Man-reference-regexp "$") ref) |
| 666 | (setq name (replace-regexp-in-string "[\n\t ]" "" (match-string 1 ref)) | 666 | (setq name (replace-regexp-in-string "[\n\t ]" "" (match-string 1 ref)) |
| 667 | section (match-string 3 ref))) | 667 | section (match-string 4 ref))) |
| 668 | ;; "2v chmod" case ? | 668 | ;; "2v chmod" case ? |
| 669 | ((string-match (concat "^\\(" Man-section-regexp | 669 | ((string-match (concat "^\\(" Man-section-regexp |
| 670 | "\\) +\\(" Man-name-regexp "\\)$") ref) | 670 | "\\) +\\(" Man-name-regexp "\\)$") ref) |
| @@ -783,11 +783,22 @@ POS defaults to `point'." | |||
| 783 | ;; see this- | 783 | ;; see this- |
| 784 | ;; command-here(1) | 784 | ;; command-here(1) |
| 785 | ;; Note: This code gets executed iff our entry is after POS. | 785 | ;; Note: This code gets executed iff our entry is after POS. |
| 786 | (when (looking-at "‐?[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)([0-9])") | 786 | (when (looking-at |
| 787 | (setq word (concat word (match-string-no-properties 1))) | 787 | (concat |
| 788 | "‐?[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)(" Man-section-regexp ")")) | ||
| 789 | (let ((1st-part word)) | ||
| 790 | (setq word (concat word (match-string-no-properties 1))) | ||
| 791 | ;; If they use -Tascii, we cannot know whether a hyphen at | ||
| 792 | ;; EOL is or isn't part of the referenced manpage name. | ||
| 793 | ;; Heuristics: if the part of the manpage before the hyphen | ||
| 794 | ;; doesn't include a hyphen, we consider the hyphen to be | ||
| 795 | ;; added by troff, and remove it. | ||
| 796 | (or (not (eq (string-to-char (substring 1st-part -1)) ?-)) | ||
| 797 | (string-match-p "-" (substring 1st-part 0 -1)) | ||
| 798 | (setq word (replace-regexp-in-string "-" "" word)))) | ||
| 788 | ;; Make sure the section number gets included by the code below. | 799 | ;; Make sure the section number gets included by the code below. |
| 789 | (goto-char (match-end 1))) | 800 | (goto-char (match-end 1))) |
| 790 | (when (string-match "[-._]+$" word) | 801 | (when (string-match "[-._‐]+$" word) |
| 791 | (setq word (substring word 0 (match-beginning 0)))) | 802 | (setq word (substring word 0 (match-beginning 0)))) |
| 792 | ;; The following was commented out since the preceding code | 803 | ;; The following was commented out since the preceding code |
| 793 | ;; should not produce a leading "*" in the first place. | 804 | ;; should not produce a leading "*" in the first place. |