aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2024-08-02 09:24:55 +0300
committerEli Zaretskii2024-08-02 09:24:55 +0300
commit4fa540f86587d4458cf33da352176f57e20723d4 (patch)
treeba1bc9dca6cc731ec192d45f49dceace712b35ee
parent1134734e19617a0875b77f8c7df64cfb265ec118 (diff)
downloademacs-4fa540f86587d4458cf33da352176f57e20723d4.tar.gz
emacs-4fa540f86587d4458cf33da352176f57e20723d4.zip
Fix finding anchor references after 'Info-on-current-buffer'
* lisp/info.el (Info--record-tag-table): New function, extracted from 'Info-find-node-2'. (Info-find-node-2, Info-on-current-buffer): Use 'Info--record-tag-table'. (Bug#72391)
-rw-r--r--lisp/info.el74
1 files changed, 44 insertions, 30 deletions
diff --git a/lisp/info.el b/lisp/info.el
index d151c6365b8..e18772436e9 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1032,6 +1032,48 @@ If NOERROR, inhibit error messages when we can't find the node."
1032 Info-history)) 1032 Info-history))
1033 (Info-find-node-2 filename nodename no-going-back strict-case)) 1033 (Info-find-node-2 filename nodename no-going-back strict-case))
1034 1034
1035(defun Info--record-tag-table (nodename)
1036 "If the current Info file has a tag table, record its location for NODENAME.
1037
1038This creates a tag-table buffer, sets `Info-tag-table-buffer' to
1039name that buffer, and records the buffer and the tag table in
1040the marker `Info-tag-table-buffer'. If the Info file has no
1041tag table, or if NODENAME is \"*\", the function sets the marker
1042to nil to indicate the tag table is not available/relevant.
1043
1044The function assumes that the Info buffer is widened, and does
1045not preserve point."
1046 (goto-char (point-max))
1047 (forward-line -8)
1048 ;; Use string-equal, not equal, to ignore text props.
1049 (if (not (or (string-equal nodename "*")
1050 (not
1051 (search-forward "\^_\nEnd tag table\n" nil t))))
1052 (let (pos)
1053 ;; We have a tag table. Find its beginning.
1054 ;; Is this an indirect file?
1055 (search-backward "\nTag table:\n")
1056 (setq pos (point))
1057 (if (save-excursion
1058 (forward-line 2)
1059 (looking-at "(Indirect)\n"))
1060 ;; It is indirect. Copy it to another buffer
1061 ;; and record that the tag table is in that buffer.
1062 (let ((buf (current-buffer))
1063 (tagbuf
1064 (or Info-tag-table-buffer
1065 (generate-new-buffer " *info tag table*"))))
1066 (setq Info-tag-table-buffer tagbuf)
1067 (with-current-buffer tagbuf
1068 (buffer-disable-undo (current-buffer))
1069 (setq case-fold-search t)
1070 (erase-buffer)
1071 (insert-buffer-substring buf))
1072 (set-marker Info-tag-table-marker
1073 (match-end 0) tagbuf))
1074 (set-marker Info-tag-table-marker pos)))
1075 (set-marker Info-tag-table-marker nil)))
1076
1035;;;###autoload 1077;;;###autoload
1036(defun Info-on-current-buffer (&optional nodename) 1078(defun Info-on-current-buffer (&optional nodename)
1037 "Use Info mode to browse the current Info buffer. 1079 "Use Info mode to browse the current Info buffer.
@@ -1048,6 +1090,7 @@ otherwise, that defaults to `Top'."
1048 (or buffer-file-name 1090 (or buffer-file-name
1049 ;; If called on a non-file buffer, make a fake file name. 1091 ;; If called on a non-file buffer, make a fake file name.
1050 (concat default-directory (buffer-name)))) 1092 (concat default-directory (buffer-name))))
1093 (Info--record-tag-table nodename)
1051 (Info-find-node-2 nil nodename)) 1094 (Info-find-node-2 nil nodename))
1052 1095
1053(defun Info-revert-find-node (filename nodename) 1096(defun Info-revert-find-node (filename nodename)
@@ -1210,36 +1253,7 @@ is non-nil)."
1210 (Info-file-supports-index-cookies filename)) 1253 (Info-file-supports-index-cookies filename))
1211 1254
1212 ;; See whether file has a tag table. Record the location if yes. 1255 ;; See whether file has a tag table. Record the location if yes.
1213 (goto-char (point-max)) 1256 (Info--record-tag-table nodename)
1214 (forward-line -8)
1215 ;; Use string-equal, not equal, to ignore text props.
1216 (if (not (or (string-equal nodename "*")
1217 (not
1218 (search-forward "\^_\nEnd tag table\n" nil t))))
1219 (let (pos)
1220 ;; We have a tag table. Find its beginning.
1221 ;; Is this an indirect file?
1222 (search-backward "\nTag table:\n")
1223 (setq pos (point))
1224 (if (save-excursion
1225 (forward-line 2)
1226 (looking-at "(Indirect)\n"))
1227 ;; It is indirect. Copy it to another buffer
1228 ;; and record that the tag table is in that buffer.
1229 (let ((buf (current-buffer))
1230 (tagbuf
1231 (or Info-tag-table-buffer
1232 (generate-new-buffer " *info tag table*"))))
1233 (setq Info-tag-table-buffer tagbuf)
1234 (with-current-buffer tagbuf
1235 (buffer-disable-undo (current-buffer))
1236 (setq case-fold-search t)
1237 (erase-buffer)
1238 (insert-buffer-substring buf))
1239 (set-marker Info-tag-table-marker
1240 (match-end 0) tagbuf))
1241 (set-marker Info-tag-table-marker pos)))
1242 (set-marker Info-tag-table-marker nil))
1243 (setq Info-current-file filename) 1257 (setq Info-current-file filename)
1244 ))) 1258 )))
1245 1259