diff options
| author | Glenn Morris | 2013-07-02 20:09:38 -0700 |
|---|---|---|
| committer | Glenn Morris | 2013-07-02 20:09:38 -0700 |
| commit | 9b057d613a30b83adcb26600118075dc81777510 (patch) | |
| tree | b42154e03df1db733a72c02232072f3ea427e636 /lisp | |
| parent | e01aa29cd90dc51ecb9b8c4ec6164fb748a6b892 (diff) | |
| download | emacs-9b057d613a30b83adcb26600118075dc81777510.tar.gz emacs-9b057d613a30b83adcb26600118075dc81777510.zip | |
Make info-xref checks case-sensitive by default
* lisp/info.el (Info-find-node, Info-find-in-tag-table)
(Info-find-node-in-buffer, Info-find-node-2, Info-goto-node):
Add option for exact case matching of nodes.
* lisp/info-xref.el (info-xref): New custom group.
(info-xref-case-fold): New option.
(info-xref-goto-node-p): Pass info-xref-case-fold to Info-goto-node.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/info-xref.el | 23 | ||||
| -rw-r--r-- | lisp/info.el | 43 |
3 files changed, 58 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f717fdcc4e4..8327fb03b4e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-07-03 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | Make info-xref checks case-sensitive by default | ||
| 4 | * info.el (Info-find-node, Info-find-in-tag-table) | ||
| 5 | (Info-find-node-in-buffer, Info-find-node-2, Info-goto-node): | ||
| 6 | Add option for exact case matching of nodes. | ||
| 7 | * info-xref.el (info-xref): New custom group. | ||
| 8 | (info-xref-case-fold): New option. | ||
| 9 | (info-xref-goto-node-p): Pass info-xref-case-fold to Info-goto-node. | ||
| 10 | |||
| 1 | 2013-07-03 Leo Liu <sdl.web@gmail.com> | 11 | 2013-07-03 Leo Liu <sdl.web@gmail.com> |
| 2 | 12 | ||
| 3 | * ido.el (ido-delete-file-at-head): Respect delete-by-moving-to-trash. | 13 | * ido.el (ido-delete-file-at-head): Respect delete-by-moving-to-trash. |
diff --git a/lisp/info-xref.el b/lisp/info-xref.el index c38e23bab8a..21fb592ff19 100644 --- a/lisp/info-xref.el +++ b/lisp/info-xref.el | |||
| @@ -45,7 +45,25 @@ | |||
| 45 | ;;; Code: | 45 | ;;; Code: |
| 46 | 46 | ||
| 47 | (require 'info) | 47 | (require 'info) |
| 48 | (eval-when-compile (require 'cl-lib)) ;; for `incf' | 48 | (eval-when-compile (require 'cl-lib)) ; for `cl-incf' |
| 49 | |||
| 50 | (defgroup info-xref nil | ||
| 51 | "Check external cross-references in Info documents." | ||
| 52 | :group 'docs) ; FIXME right parent? | ||
| 53 | |||
| 54 | ;; Should this even be an option? | ||
| 55 | (defcustom info-xref-case-fold nil | ||
| 56 | "Non-nil means node checks should ignore case. | ||
| 57 | When following cross-references, the Emacs Info reader first tries a | ||
| 58 | case-sensitive match, then if that fails a case-insensitive one. | ||
| 59 | The standalone Info reader does not do this, nor does this work | ||
| 60 | for links in the html versions of Texinfo manuals. Therefore | ||
| 61 | to ensure your cross-references work on the widest range of platforms, | ||
| 62 | you should set this variable to nil." | ||
| 63 | :group 'info-xref | ||
| 64 | :type 'boolean | ||
| 65 | :version "24.4") | ||
| 66 | |||
| 49 | 67 | ||
| 50 | ;;----------------------------------------------------------------------------- | 68 | ;;----------------------------------------------------------------------------- |
| 51 | ;; vaguely generic | 69 | ;; vaguely generic |
| @@ -204,7 +222,8 @@ buffer's line and column of point." | |||
| 204 | (Info-goto-node node | 222 | (Info-goto-node node |
| 205 | (when (get-buffer "*info*") | 223 | (when (get-buffer "*info*") |
| 206 | (set-buffer "*info*") | 224 | (set-buffer "*info*") |
| 207 | "xref - temporary")) | 225 | "xref - temporary") |
| 226 | (not info-xref-case-fold)) | ||
| 208 | t) | 227 | t) |
| 209 | (error nil)) | 228 | (error nil)) |
| 210 | (unless (equal (current-buffer) oldbuf) | 229 | (unless (equal (current-buffer) oldbuf) |
diff --git a/lisp/info.el b/lisp/info.el index f9851a0c1e8..0e0a11753ba 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -920,10 +920,14 @@ just return nil (no error)." | |||
| 920 | (error "Info file %s does not exist" filename))) | 920 | (error "Info file %s does not exist" filename))) |
| 921 | filename)))) | 921 | filename)))) |
| 922 | 922 | ||
| 923 | (defun Info-find-node (filename nodename &optional no-going-back) | 923 | (defun Info-find-node (filename nodename &optional no-going-back strict-case) |
| 924 | "Go to an Info node specified as separate FILENAME and NODENAME. | 924 | "Go to an Info node specified as separate FILENAME and NODENAME. |
| 925 | NO-GOING-BACK is non-nil if recovering from an error in this function; | 925 | NO-GOING-BACK is non-nil if recovering from an error in this function; |
| 926 | it says do not attempt further (recursive) error recovery." | 926 | it says do not attempt further (recursive) error recovery. |
| 927 | |||
| 928 | This function first looks for a case-sensitive match for NODENAME; | ||
| 929 | if none is found it then tries a case-insensitive match (unless | ||
| 930 | STRICT-CASE is non-nil)." | ||
| 927 | (info-initialize) | 931 | (info-initialize) |
| 928 | (setq filename (Info-find-file filename)) | 932 | (setq filename (Info-find-file filename)) |
| 929 | ;; Go into Info buffer. | 933 | ;; Go into Info buffer. |
| @@ -933,7 +937,7 @@ it says do not attempt further (recursive) error recovery." | |||
| 933 | Info-current-file | 937 | Info-current-file |
| 934 | (push (list Info-current-file Info-current-node (point)) | 938 | (push (list Info-current-file Info-current-node (point)) |
| 935 | Info-history)) | 939 | Info-history)) |
| 936 | (Info-find-node-2 filename nodename no-going-back)) | 940 | (Info-find-node-2 filename nodename no-going-back strict-case)) |
| 937 | 941 | ||
| 938 | ;;;###autoload | 942 | ;;;###autoload |
| 939 | (defun Info-on-current-buffer (&optional nodename) | 943 | (defun Info-on-current-buffer (&optional nodename) |
| @@ -1010,7 +1014,7 @@ which the match was found." | |||
| 1010 | (+ (point-min) (read (current-buffer))) | 1014 | (+ (point-min) (read (current-buffer))) |
| 1011 | major-mode))))) | 1015 | major-mode))))) |
| 1012 | 1016 | ||
| 1013 | (defun Info-find-in-tag-table (marker regexp) | 1017 | (defun Info-find-in-tag-table (marker regexp &optional strict-case) |
| 1014 | "Find a node in a tag table. | 1018 | "Find a node in a tag table. |
| 1015 | MARKER specifies the buffer and position to start searching at. | 1019 | MARKER specifies the buffer and position to start searching at. |
| 1016 | REGEXP is a regular expression matching nodes or references. Its first | 1020 | REGEXP is a regular expression matching nodes or references. Its first |
| @@ -1020,10 +1024,11 @@ FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position | |||
| 1020 | where the match was found, and MODE is `major-mode' of the buffer in | 1024 | where the match was found, and MODE is `major-mode' of the buffer in |
| 1021 | which the match was found. | 1025 | which the match was found. |
| 1022 | This function tries to find a case-sensitive match first, then a | 1026 | This function tries to find a case-sensitive match first, then a |
| 1023 | case-insensitive match is tried." | 1027 | case-insensitive match is tried (unless optional argument STRICT-CASE |
| 1028 | is non-nil)." | ||
| 1024 | (let ((result (Info-find-in-tag-table-1 marker regexp nil))) | 1029 | (let ((result (Info-find-in-tag-table-1 marker regexp nil))) |
| 1025 | (when (null (car result)) | 1030 | (or strict-case (car result) |
| 1026 | (setq result (Info-find-in-tag-table-1 marker regexp t))) | 1031 | (setq result (Info-find-in-tag-table-1 marker regexp t))) |
| 1027 | result)) | 1032 | result)) |
| 1028 | 1033 | ||
| 1029 | (defun Info-find-node-in-buffer-1 (regexp case-fold) | 1034 | (defun Info-find-node-in-buffer-1 (regexp case-fold) |
| @@ -1046,17 +1051,19 @@ Value is the position at which a match was found, or nil if not found." | |||
| 1046 | (setq found (line-beginning-position))))))) | 1051 | (setq found (line-beginning-position))))))) |
| 1047 | found)) | 1052 | found)) |
| 1048 | 1053 | ||
| 1049 | (defun Info-find-node-in-buffer (regexp) | 1054 | (defun Info-find-node-in-buffer (regexp &optional strict-case) |
| 1050 | "Find a node or anchor in the current buffer. | 1055 | "Find a node or anchor in the current buffer. |
| 1051 | REGEXP is a regular expression matching nodes or references. Its first | 1056 | REGEXP is a regular expression matching nodes or references. Its first |
| 1052 | group should match `Node:' or `Ref:'. | 1057 | group should match `Node:' or `Ref:'. |
| 1053 | Value is the position at which a match was found, or nil if not found. | 1058 | Value is the position at which a match was found, or nil if not found. |
| 1054 | This function looks for a case-sensitive match first. If none is found, | 1059 | This function looks for a case-sensitive match first. If none is found, |
| 1055 | a case-insensitive match is tried." | 1060 | a case-insensitive match is tried (unless optional argument STRICT-CASE |
| 1061 | is non-nil)." | ||
| 1056 | (or (Info-find-node-in-buffer-1 regexp nil) | 1062 | (or (Info-find-node-in-buffer-1 regexp nil) |
| 1057 | (Info-find-node-in-buffer-1 regexp t))) | 1063 | (and (not strict-case) |
| 1064 | (Info-find-node-in-buffer-1 regexp t)))) | ||
| 1058 | 1065 | ||
| 1059 | (defun Info-find-node-2 (filename nodename &optional no-going-back) | 1066 | (defun Info-find-node-2 (filename nodename &optional no-going-back strict-case) |
| 1060 | (buffer-disable-undo (current-buffer)) | 1067 | (buffer-disable-undo (current-buffer)) |
| 1061 | (or (eq major-mode 'Info-mode) | 1068 | (or (eq major-mode 'Info-mode) |
| 1062 | (Info-mode)) | 1069 | (Info-mode)) |
| @@ -1167,7 +1174,7 @@ a case-insensitive match is tried." | |||
| 1167 | ;; First, search a tag table, if any | 1174 | ;; First, search a tag table, if any |
| 1168 | (when (marker-position Info-tag-table-marker) | 1175 | (when (marker-position Info-tag-table-marker) |
| 1169 | (let* ((m Info-tag-table-marker) | 1176 | (let* ((m Info-tag-table-marker) |
| 1170 | (found (Info-find-in-tag-table m regexp))) | 1177 | (found (Info-find-in-tag-table m regexp strict-case))) |
| 1171 | 1178 | ||
| 1172 | (when found | 1179 | (when found |
| 1173 | ;; FOUND is (ANCHOR POS MODE). | 1180 | ;; FOUND is (ANCHOR POS MODE). |
| @@ -1194,7 +1201,7 @@ a case-insensitive match is tried." | |||
| 1194 | ;; buffer) to find the actual node. First, check | 1201 | ;; buffer) to find the actual node. First, check |
| 1195 | ;; whether the node is right where we are, in case the | 1202 | ;; whether the node is right where we are, in case the |
| 1196 | ;; buffer begins with a node. | 1203 | ;; buffer begins with a node. |
| 1197 | (let ((pos (Info-find-node-in-buffer regexp))) | 1204 | (let ((pos (Info-find-node-in-buffer regexp strict-case))) |
| 1198 | (when pos | 1205 | (when pos |
| 1199 | (goto-char pos) | 1206 | (goto-char pos) |
| 1200 | (throw 'foo t))) | 1207 | (throw 'foo t))) |
| @@ -1701,7 +1708,7 @@ escaped (\\\",\\\\)." | |||
| 1701 | ;; Don't autoload this function: the correct entry point for other packages | 1708 | ;; Don't autoload this function: the correct entry point for other packages |
| 1702 | ;; to use is `info'. --Stef | 1709 | ;; to use is `info'. --Stef |
| 1703 | ;; ;;;###autoload | 1710 | ;; ;;;###autoload |
| 1704 | (defun Info-goto-node (nodename &optional fork) | 1711 | (defun Info-goto-node (nodename &optional fork strict-case) |
| 1705 | "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME. | 1712 | "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME. |
| 1706 | If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file | 1713 | If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file |
| 1707 | FILENAME; otherwise, NODENAME should be in the current Info file (or one of | 1714 | FILENAME; otherwise, NODENAME should be in the current Info file (or one of |
| @@ -1711,7 +1718,11 @@ in the Info file FILENAME after the closing parenthesis in (FILENAME). | |||
| 1711 | Empty NODENAME in (FILENAME) defaults to the Top node. | 1718 | Empty NODENAME in (FILENAME) defaults to the Top node. |
| 1712 | If FORK is non-nil (interactively with a prefix arg), show the node in | 1719 | If FORK is non-nil (interactively with a prefix arg), show the node in |
| 1713 | a new Info buffer. | 1720 | a new Info buffer. |
| 1714 | If FORK is a string, it is the name to use for the new buffer." | 1721 | If FORK is a string, it is the name to use for the new buffer. |
| 1722 | |||
| 1723 | This function first looks for a case-sensitive match for the node part | ||
| 1724 | of NODENAME; if none is found it then tries a case-insensitive match | ||
| 1725 | \(unless STRICT-CASE is non-nil)." | ||
| 1715 | (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg)) | 1726 | (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg)) |
| 1716 | (info-initialize) | 1727 | (info-initialize) |
| 1717 | (if fork | 1728 | (if fork |
| @@ -1730,7 +1741,7 @@ If FORK is a string, it is the name to use for the new buffer." | |||
| 1730 | (if trim (setq nodename (substring nodename 0 trim)))) | 1741 | (if trim (setq nodename (substring nodename 0 trim)))) |
| 1731 | (if transient-mark-mode (deactivate-mark)) | 1742 | (if transient-mark-mode (deactivate-mark)) |
| 1732 | (Info-find-node (if (equal filename "") nil filename) | 1743 | (Info-find-node (if (equal filename "") nil filename) |
| 1733 | (if (equal nodename "") "Top" nodename)))) | 1744 | (if (equal nodename "") "Top" nodename) nil strict-case))) |
| 1734 | 1745 | ||
| 1735 | (defvar Info-read-node-completion-table) | 1746 | (defvar Info-read-node-completion-table) |
| 1736 | 1747 | ||