Commit bec275ed authored by Juri Linkov's avatar Juri Linkov
Browse files

(Info-find-file): Check for symbols `apropos', `history',

`toc' in the input filename, and return these symbols as is.
(Info-find-node-2): Set Info-current-file to symbols `apropos',
`history', `toc' instead of strings.
(Info-set-mode-line): For non-string Info-current-file use the
symbol's name inside **.
(Info-isearch-push-state): Add quote before Info-current-file and
Info-current-node.
(Info-isearch-pop-state): Use `equal' instead of `string='.
(Info-extract-pointer, Info-following-node-name): Use
`match-string-no-properties' instead of `match-string'.
(Info-up): Check `old-file' for `stringp'.
(Info-history): Use `equal' instead of `string-equal'.
Check `file' for `stringp'.
(Info-history): Use symbol `history' instead of string as first arg
of `Info-find-node'.
(Info-toc): Check `Info-current-file' for `stringp'.  Use symbol
`toc' instead of string.
(Info-extract-menu-node-name): Use `buffer-substring-no-properties'
instead of `buffer-substring', and `match-string-no-properties'
instead of `match-string'.
(Info-index-nodes): Check for symbols `apropos', `history', `toc'
instead of strings.
(info-apropos): Use `Info-find-node' instead of `Info-goto-node'.
Use symbol `apropos' instead of string.
(Info-copy-current-node-name): Check `Info-current-file' for
`stringp' and construct a command with `Info-find-node' from it.
(Info-fontify-node): Use `match-string-no-properties' instead of
`match-string' and check file names for `stringp'.
(Info-desktop-buffer-misc-data): Check for symbols `apropos',
`history', `toc' instead of strings.
parent 2f457246
2006-02-17 Juri Linkov <juri@jurta.org>
* info.el (Info-find-file): Check for symbols `apropos', `history',
`toc' in the input filename, and return these symbols as is.
(Info-find-node-2): Set Info-current-file to symbols `apropos',
`history', `toc' instead of strings.
(Info-set-mode-line): For non-string Info-current-file use the
symbol's name inside **.
(Info-isearch-push-state): Add quote before Info-current-file and
Info-current-node.
(Info-isearch-pop-state): Use `equal' instead of `string='.
(Info-extract-pointer, Info-following-node-name): Use
`match-string-no-properties' instead of `match-string'.
(Info-up): Check `old-file' for `stringp'.
(Info-history): Use `equal' instead of `string-equal'.
Check `file' for `stringp'.
(Info-history): Use symbol `history' instead of string as first arg
of `Info-find-node'.
(Info-toc): Check `Info-current-file' for `stringp'. Use symbol
`toc' instead of string.
(Info-extract-menu-node-name): Use `buffer-substring-no-properties'
instead of `buffer-substring', and `match-string-no-properties'
instead of `match-string'.
(Info-index-nodes): Check for symbols `apropos', `history', `toc'
instead of strings.
(info-apropos): Use `Info-find-node' instead of `Info-goto-node'.
Use symbol `apropos' instead of string.
(Info-copy-current-node-name): Check `Info-current-file' for
`stringp' and construct a command with `Info-find-node' from it.
(Info-fontify-node): Use `match-string-no-properties' instead of
`match-string' and check file names for `stringp'.
(Info-desktop-buffer-misc-data): Check for symbols `apropos',
`history', `toc' instead of strings.
2006-02-17 Chong Yidong <cyd@stupidchicken.com> 2006-02-17 Chong Yidong <cyd@stupidchicken.com>
* files.el: Rearrange functions and variables in the file local * files.el: Rearrange functions and variables in the file local
......
...@@ -622,12 +622,6 @@ just return nil (no error)." ...@@ -622,12 +622,6 @@ just return nil (no error)."
(cond (cond
((string= (downcase filename) "dir") ((string= (downcase filename) "dir")
(setq found t)) (setq found t))
((string= filename "apropos")
(setq found 'apropos))
((string= filename "history")
(setq found 'history))
((string= filename "toc")
(setq found 'toc))
(t (t
(let ((dirs (if (string-match "^\\./" filename) (let ((dirs (if (string-match "^\\./" filename)
;; If specified name starts with `./' ;; If specified name starts with `./'
...@@ -673,7 +667,8 @@ just return nil (no error)." ...@@ -673,7 +667,8 @@ just return nil (no error)."
(if noerror (if noerror
(setq filename nil) (setq filename nil)
(error "Info file %s does not exist" filename))) (error "Info file %s does not exist" filename)))
filename))) filename)
(and (member filename '(apropos history toc)) filename)))
(defun Info-find-node (filename nodename &optional no-going-back) (defun Info-find-node (filename nodename &optional no-going-back)
"Go to an Info node specified as separate FILENAME and NODENAME. "Go to an Info node specified as separate FILENAME and NODENAME.
...@@ -891,9 +886,6 @@ a case-insensitive match is tried." ...@@ -891,9 +886,6 @@ a case-insensitive match is tried."
(setq Info-current-file (setq Info-current-file
(cond (cond
((eq filename t) "dir") ((eq filename t) "dir")
((eq filename 'apropos) "apropos")
((eq filename 'history) "history")
((eq filename 'toc) "toc")
(t filename))) (t filename)))
)) ))
;; Use string-equal, not equal, to ignore text props. ;; Use string-equal, not equal, to ignore text props.
...@@ -1409,7 +1401,7 @@ any double quotes or backslashes must be escaped (\\\",\\\\)." ...@@ -1409,7 +1401,7 @@ any double quotes or backslashes must be escaped (\\\",\\\\)."
(if (stringp Info-current-file) (if (stringp Info-current-file)
(replace-regexp-in-string (replace-regexp-in-string
"%" "%%" (file-name-nondirectory Info-current-file)) "%" "%%" (file-name-nondirectory Info-current-file))
"") (format "*%S*" Info-current-file))
") " ") "
(if Info-current-node (if Info-current-node
(propertize (replace-regexp-in-string (propertize (replace-regexp-in-string
...@@ -1831,11 +1823,11 @@ If DIRECTION is `backward', search in the reverse direction." ...@@ -1831,11 +1823,11 @@ If DIRECTION is `backward', search in the reverse direction."
(defun Info-isearch-push-state () (defun Info-isearch-push-state ()
`(lambda (cmd) `(lambda (cmd)
(Info-isearch-pop-state cmd ,Info-current-file ,Info-current-node))) (Info-isearch-pop-state cmd ',Info-current-file ',Info-current-node)))
(defun Info-isearch-pop-state (cmd file node) (defun Info-isearch-pop-state (cmd file node)
(or (and (string= Info-current-file file) (or (and (equal Info-current-file file)
(string= Info-current-node node)) (equal Info-current-node node))
(progn (Info-find-node file node) (sit-for 0)))) (progn (Info-find-node file node) (sit-for 0))))
(defun Info-isearch-start () (defun Info-isearch-start ()
...@@ -1853,7 +1845,7 @@ if ERRORNAME is nil, just return nil." ...@@ -1853,7 +1845,7 @@ if ERRORNAME is nil, just return nil."
(forward-line 1) (forward-line 1)
(cond ((re-search-backward (cond ((re-search-backward
(concat name ":" (Info-following-node-name-re)) bound t) (concat name ":" (Info-following-node-name-re)) bound t)
(match-string 1)) (match-string-no-properties 1))
((not (eq errorname t)) ((not (eq errorname t))
(error "Node has no %s" (error "Node has no %s"
(capitalize (or errorname name))))))))) (capitalize (or errorname name)))))))))
...@@ -1875,7 +1867,7 @@ End of submatch 0, 1, and 3 are the same, so you can safely concat." ...@@ -1875,7 +1867,7 @@ End of submatch 0, 1, and 3 are the same, so you can safely concat."
;;; For compatibility; other files have used this name. ;;; For compatibility; other files have used this name.
(defun Info-following-node-name () (defun Info-following-node-name ()
(and (looking-at (Info-following-node-name-re)) (and (looking-at (Info-following-node-name-re))
(match-string 1))) (match-string-no-properties 1)))
(defun Info-next () (defun Info-next ()
"Go to the next node of this node." "Go to the next node of this node."
...@@ -1909,7 +1901,8 @@ If SAME-FILE is non-nil, do not move to a different Info file." ...@@ -1909,7 +1901,8 @@ If SAME-FILE is non-nil, do not move to a different Info file."
(Info-goto-node node) (Info-goto-node node)
(setq p (point)) (setq p (point))
(goto-char (point-min)) (goto-char (point-min))
(if (and (search-forward "\n* Menu:" nil t) (if (and (stringp old-file)
(search-forward "\n* Menu:" nil t)
(re-search-forward (re-search-forward
(if (string-equal old-node "Top") (if (string-equal old-node "Top")
(concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file) ")") (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file) ")")
...@@ -1977,51 +1970,53 @@ If SAME-FILE is non-nil, do not move to a different Info file." ...@@ -1977,51 +1970,53 @@ If SAME-FILE is non-nil, do not move to a different Info file."
(while hl (while hl
(let ((file (nth 0 (car hl))) (let ((file (nth 0 (car hl)))
(node (nth 1 (car hl)))) (node (nth 1 (car hl))))
(if (and (string-equal file curr-file) (if (and (equal file curr-file)
(string-equal node curr-node)) (equal node curr-node))
(setq p (point))) (setq p (point)))
(insert "* " node ": (" (if (stringp file)
(propertize (or (file-name-directory file) "") 'invisible t) (insert "* " node ": ("
(file-name-nondirectory file) (propertize (or (file-name-directory file) "") 'invisible t)
")" node ".\n")) (file-name-nondirectory file)
")" node ".\n")))
(setq hl (cdr hl)))))) (setq hl (cdr hl))))))
(Info-find-node "history" "Top") (Info-find-node 'history "Top")
(goto-char (or p (point-min))))) (goto-char (or p (point-min)))))
(defun Info-toc () (defun Info-toc ()
"Go to a node with table of contents of the current Info file. "Go to a node with table of contents of the current Info file.
Table of contents is created from the tree structure of menus." Table of contents is created from the tree structure of menus."
(interactive) (interactive)
(let ((curr-file (substring-no-properties Info-current-file)) (if (stringp Info-current-file)
(curr-node (substring-no-properties Info-current-node)) (let ((curr-file (substring-no-properties Info-current-file))
p) (curr-node (substring-no-properties Info-current-node))
(with-current-buffer (get-buffer-create " *info-toc*") p)
(let ((inhibit-read-only t) (with-current-buffer (get-buffer-create " *info-toc*")
(node-list (Info-build-toc curr-file))) (let ((inhibit-read-only t)
(erase-buffer) (node-list (Info-build-toc curr-file)))
(goto-char (point-min)) (erase-buffer)
(insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n") (goto-char (point-min))
(insert "Table of Contents\n*****************\n\n") (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
(insert "*Note Top: (" curr-file ")Top.\n") (insert "Table of Contents\n*****************\n\n")
(Info-insert-toc (insert "*Note Top: (" curr-file ")Top.\n")
(nth 2 (assoc "Top" node-list)) ; get Top nodes (Info-insert-toc
node-list 0 curr-file)) (nth 2 (assoc "Top" node-list)) ; get Top nodes
(if (not (bobp)) node-list 0 curr-file))
(let ((Info-hide-note-references 'hide) (if (not (bobp))
(Info-fontify-visited-nodes nil)) (let ((Info-hide-note-references 'hide)
(Info-mode) (Info-fontify-visited-nodes nil))
(setq Info-current-file "toc" Info-current-node "Top") (Info-mode)
(goto-char (point-min)) (setq Info-current-file 'toc Info-current-node "Top")
(narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t) (goto-char (point-min))
(point-min)) (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t)
(point-max)) (point-min))
(Info-fontify-node) (point-max))
(widen))) (Info-fontify-node)
(goto-char (point-min)) (widen)))
(if (setq p (search-forward (concat "*Note " curr-node ":") nil t)) (goto-char (point-min))
(setq p (- p (length curr-node) 2)))) (if (setq p (search-forward (concat "*Note " curr-node ":") nil t))
(Info-find-node "toc" "Top") (setq p (- p (length curr-node) 2))))
(goto-char (or p (point-min))))) (Info-find-node 'toc "Top")
(goto-char (or p (point-min))))))
(defun Info-insert-toc (nodes node-list level curr-file) (defun Info-insert-toc (nodes node-list level curr-file)
"Insert table of contents with references to nodes." "Insert table of contents with references to nodes."
...@@ -2221,16 +2216,18 @@ Because of ambiguities, this should be concatenated with something like ...@@ -2221,16 +2216,18 @@ Because of ambiguities, this should be concatenated with something like
(setq Info-point-loc (setq Info-point-loc
(if (match-beginning 5) (if (match-beginning 5)
(string-to-number (match-string 5)) (string-to-number (match-string 5))
(buffer-substring (match-beginning 0) (1- (match-beginning 1))))) (buffer-substring-no-properties
(match-beginning 0) (1- (match-beginning 1)))))
;;; Uncomment next line to use names of cross-references in non-index nodes: ;;; Uncomment next line to use names of cross-references in non-index nodes:
;;; (setq Info-point-loc ;;; (setq Info-point-loc
;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1)))) ;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
) )
(replace-regexp-in-string (replace-regexp-in-string
"[ \n]+" " " "[ \n]+" " "
(or (match-string 2) (or (match-string-no-properties 2)
;; If the node name is the menu entry name (using `entry::'). ;; If the node name is the menu entry name (using `entry::').
(buffer-substring (match-beginning 0) (1- (match-beginning 1))))))) (buffer-substring-no-properties
(match-beginning 0) (1- (match-beginning 1)))))))
;; No one calls this. ;; No one calls this.
;;(defun Info-menu-item-sequence (list) ;;(defun Info-menu-item-sequence (list)
...@@ -2684,7 +2681,7 @@ following nodes whose names also contain the word \"Index\"." ...@@ -2684,7 +2681,7 @@ following nodes whose names also contain the word \"Index\"."
(or file (setq file Info-current-file)) (or file (setq file Info-current-file))
(or (assoc file Info-index-nodes) (or (assoc file Info-index-nodes)
;; Skip virtual Info files ;; Skip virtual Info files
(and (member file '("dir" "history" "toc" "apropos")) (and (member file '("dir" apropos history toc))
(setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) (setq Info-index-nodes (cons (cons file nil) Info-index-nodes)))
(not (stringp file)) (not (stringp file))
(if Info-file-supports-index-cookies (if Info-file-supports-index-cookies
...@@ -2926,7 +2923,7 @@ Build a menu of the possible matches." ...@@ -2926,7 +2923,7 @@ Build a menu of the possible matches."
(message "%s" (if (eq (car-safe err) 'error) (message "%s" (if (eq (car-safe err) 'error)
(nth 1 err) err)) (nth 1 err) err))
(sit-for 1 t))))) (sit-for 1 t)))))
(Info-goto-node (concat "(" current-file ")" current-node)) (Info-find-node current-file current-node)
(setq Info-history ohist (setq Info-history ohist
Info-history-list ohist-list) Info-history-list ohist-list)
(message "Searching indices...done") (message "Searching indices...done")
...@@ -2945,7 +2942,7 @@ Build a menu of the possible matches." ...@@ -2945,7 +2942,7 @@ Build a menu of the possible matches."
(if (nth 3 entry) (if (nth 3 entry)
(concat " (line " (nth 3 entry) ")") (concat " (line " (nth 3 entry) ")")
""))))) "")))))
(Info-find-node "apropos" "Index") (Info-find-node 'apropos "Index")
(setq Info-complete-cache nil))))) (setq Info-complete-cache nil)))))
(defun Info-undefined () (defun Info-undefined ()
...@@ -3287,10 +3284,14 @@ With a zero prefix arg, put the name inside a function call to `info'." ...@@ -3287,10 +3284,14 @@ With a zero prefix arg, put the name inside a function call to `info'."
(interactive "P") (interactive "P")
(unless Info-current-node (unless Info-current-node
(error "No current Info node")) (error "No current Info node"))
(let ((node (concat "(" (file-name-nondirectory Info-current-file) ")" (let ((node (if (stringp Info-current-file)
Info-current-node))) (concat "(" (file-name-nondirectory Info-current-file) ")"
Info-current-node))))
(if (zerop (prefix-numeric-value arg)) (if (zerop (prefix-numeric-value arg))
(setq node (concat "(info \"" node "\")"))) (setq node (concat "(info \"" node "\")")))
(unless (stringp Info-current-file)
(setq node (format "(Info-find-node '%S '%S)"
Info-current-file Info-current-node)))
(kill-new node) (kill-new node)
(message "%s" node))) (message "%s" node)))
...@@ -3817,29 +3818,30 @@ the variable `Info-file-list-for-emacs'." ...@@ -3817,29 +3818,30 @@ the variable `Info-file-list-for-emacs'."
"^[ \t]+" "" "^[ \t]+" ""
(replace-regexp-in-string (replace-regexp-in-string
"[ \t\n]+" " " "[ \t\n]+" " "
(or (match-string 5) (or (match-string-no-properties 5)
(and (not (equal (match-string 4) "")) (and (not (equal (match-string 4) ""))
(match-string 4)) (match-string-no-properties 4))
(match-string 2))))) (match-string-no-properties 2)))))
(external-link-p (external-link-p
(string-match "(\\([^)]+\\))\\([^)]*\\)" node)) (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
(file (if external-link-p (file (if external-link-p
(file-name-nondirectory (file-name-nondirectory
(match-string 1 node)) (match-string-no-properties 1 node))
Info-current-file)) Info-current-file))
(hl Info-history-list) (hl Info-history-list)
res) res)
(if external-link-p (if external-link-p
(setq node (if (equal (match-string 2 node) "") (setq node (if (equal (match-string 2 node) "")
"Top" "Top"
(match-string 2 node)))) (match-string-no-properties 2 node))))
(while hl (while hl
(if (and (string-equal node (nth 1 (car hl))) (if (and (string-equal node (nth 1 (car hl)))
(string-equal (equal file
file (if external-link-p (if (and external-link-p
(file-name-nondirectory (stringp (caar hl)))
(caar hl)) (file-name-nondirectory
(caar hl)))) (caar hl))
(caar hl))))
(setq res (car hl) hl nil) (setq res (car hl) hl nil)
(setq hl (cdr hl)))) (setq hl (cdr hl))))
res))) 'info-xref-visited 'info-xref)) res))) 'info-xref-visited 'info-xref))
...@@ -3932,26 +3934,28 @@ the variable `Info-file-list-for-emacs'." ...@@ -3932,26 +3934,28 @@ the variable `Info-file-list-for-emacs'."
(if (and Info-fontify-visited-nodes (if (and Info-fontify-visited-nodes
(save-match-data (save-match-data
(let* ((node (if (equal (match-string 3) "") (let* ((node (if (equal (match-string 3) "")
(match-string 1) (match-string-no-properties 1)
(match-string 3))) (match-string-no-properties 3)))
(external-link-p (external-link-p
(string-match "(\\([^)]+\\))\\([^)]*\\)" node)) (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
(file (if external-link-p (file (if external-link-p
(file-name-nondirectory (file-name-nondirectory
(match-string 1 node)) (match-string-no-properties 1 node))
Info-current-file)) Info-current-file))
(hl Info-history-list) (hl Info-history-list)
res) res)
(if external-link-p (if external-link-p
(setq node (if (equal (match-string 2 node) "") (setq node (if (equal (match-string 2 node) "")
"Top" "Top"
(match-string 2 node)))) (match-string-no-properties 2 node))))
(while hl (while hl
(if (and (string-equal node (nth 1 (car hl))) (if (and (string-equal node (nth 1 (car hl)))
(string-equal (equal file
file (if external-link-p (if (and external-link-p
(file-name-nondirectory (caar hl)) (stringp (caar hl)))
(caar hl)))) (file-name-nondirectory
(caar hl))
(caar hl))))
(setq res (car hl) hl nil) (setq res (car hl) hl nil)
(setq hl (cdr hl)))) (setq hl (cdr hl))))
res))) 'info-xref-visited 'info-xref))) res))) 'info-xref-visited 'info-xref)))
...@@ -4210,8 +4214,8 @@ BUFFER is the buffer speedbar is requesting buttons for." ...@@ -4210,8 +4214,8 @@ BUFFER is the buffer speedbar is requesting buttons for."
(defun Info-desktop-buffer-misc-data (desktop-dirname) (defun Info-desktop-buffer-misc-data (desktop-dirname)
"Auxiliary information to be saved in desktop file." "Auxiliary information to be saved in desktop file."
(if (not (member Info-current-file '("apropos" "history" "toc"))) (unless (member Info-current-file '(apropos history toc nil))
(list Info-current-file Info-current-node))) (list Info-current-file Info-current-node)))
(defun Info-restore-desktop-buffer (desktop-buffer-file-name (defun Info-restore-desktop-buffer (desktop-buffer-file-name
desktop-buffer-name desktop-buffer-name
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment