aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2006-02-17 21:29:13 +0000
committerJuri Linkov2006-02-17 21:29:13 +0000
commitbec275ed0a888ffdd01fdf3367ad0a3f6cac7853 (patch)
tree98a71a1f458cdc45df92f8317a3f95caf8eafea7
parent2f457246e77d5532ee929be7142b265d4b0cc8f1 (diff)
downloademacs-bec275ed0a888ffdd01fdf3367ad0a3f6cac7853.tar.gz
emacs-bec275ed0a888ffdd01fdf3367ad0a3f6cac7853.zip
(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.
-rw-r--r--lisp/ChangeLog34
-rw-r--r--lisp/info.el168
2 files changed, 120 insertions, 82 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 39ddc63fb78..3aa80e6446b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,37 @@
12006-02-17 Juri Linkov <juri@jurta.org>
2
3 * info.el (Info-find-file): Check for symbols `apropos', `history',
4 `toc' in the input filename, and return these symbols as is.
5 (Info-find-node-2): Set Info-current-file to symbols `apropos',
6 `history', `toc' instead of strings.
7 (Info-set-mode-line): For non-string Info-current-file use the
8 symbol's name inside **.
9 (Info-isearch-push-state): Add quote before Info-current-file and
10 Info-current-node.
11 (Info-isearch-pop-state): Use `equal' instead of `string='.
12 (Info-extract-pointer, Info-following-node-name): Use
13 `match-string-no-properties' instead of `match-string'.
14 (Info-up): Check `old-file' for `stringp'.
15 (Info-history): Use `equal' instead of `string-equal'.
16 Check `file' for `stringp'.
17 (Info-history): Use symbol `history' instead of string as first arg
18 of `Info-find-node'.
19 (Info-toc): Check `Info-current-file' for `stringp'. Use symbol
20 `toc' instead of string.
21 (Info-extract-menu-node-name): Use `buffer-substring-no-properties'
22 instead of `buffer-substring', and `match-string-no-properties'
23 instead of `match-string'.
24 (Info-index-nodes): Check for symbols `apropos', `history', `toc'
25 instead of strings.
26 (info-apropos): Use `Info-find-node' instead of `Info-goto-node'.
27 Use symbol `apropos' instead of string.
28 (Info-copy-current-node-name): Check `Info-current-file' for
29 `stringp' and construct a command with `Info-find-node' from it.
30 (Info-fontify-node): Use `match-string-no-properties' instead of
31 `match-string' and check file names for `stringp'.
32 (Info-desktop-buffer-misc-data): Check for symbols `apropos',
33 `history', `toc' instead of strings.
34
12006-02-17 Chong Yidong <cyd@stupidchicken.com> 352006-02-17 Chong Yidong <cyd@stupidchicken.com>
2 36
3 * files.el: Rearrange functions and variables in the file local 37 * files.el: Rearrange functions and variables in the file local
diff --git a/lisp/info.el b/lisp/info.el
index e3514fb9729..e2baa3aa583 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -622,12 +622,6 @@ just return nil (no error)."
622 (cond 622 (cond
623 ((string= (downcase filename) "dir") 623 ((string= (downcase filename) "dir")
624 (setq found t)) 624 (setq found t))
625 ((string= filename "apropos")
626 (setq found 'apropos))
627 ((string= filename "history")
628 (setq found 'history))
629 ((string= filename "toc")
630 (setq found 'toc))
631 (t 625 (t
632 (let ((dirs (if (string-match "^\\./" filename) 626 (let ((dirs (if (string-match "^\\./" filename)
633 ;; If specified name starts with `./' 627 ;; If specified name starts with `./'
@@ -673,7 +667,8 @@ just return nil (no error)."
673 (if noerror 667 (if noerror
674 (setq filename nil) 668 (setq filename nil)
675 (error "Info file %s does not exist" filename))) 669 (error "Info file %s does not exist" filename)))
676 filename))) 670 filename)
671 (and (member filename '(apropos history toc)) filename)))
677 672
678(defun Info-find-node (filename nodename &optional no-going-back) 673(defun Info-find-node (filename nodename &optional no-going-back)
679 "Go to an Info node specified as separate FILENAME and NODENAME. 674 "Go to an Info node specified as separate FILENAME and NODENAME.
@@ -891,9 +886,6 @@ a case-insensitive match is tried."
891 (setq Info-current-file 886 (setq Info-current-file
892 (cond 887 (cond
893 ((eq filename t) "dir") 888 ((eq filename t) "dir")
894 ((eq filename 'apropos) "apropos")
895 ((eq filename 'history) "history")
896 ((eq filename 'toc) "toc")
897 (t filename))) 889 (t filename)))
898 )) 890 ))
899 ;; Use string-equal, not equal, to ignore text props. 891 ;; Use string-equal, not equal, to ignore text props.
@@ -1409,7 +1401,7 @@ any double quotes or backslashes must be escaped (\\\",\\\\)."
1409 (if (stringp Info-current-file) 1401 (if (stringp Info-current-file)
1410 (replace-regexp-in-string 1402 (replace-regexp-in-string
1411 "%" "%%" (file-name-nondirectory Info-current-file)) 1403 "%" "%%" (file-name-nondirectory Info-current-file))
1412 "") 1404 (format "*%S*" Info-current-file))
1413 ") " 1405 ") "
1414 (if Info-current-node 1406 (if Info-current-node
1415 (propertize (replace-regexp-in-string 1407 (propertize (replace-regexp-in-string
@@ -1831,11 +1823,11 @@ If DIRECTION is `backward', search in the reverse direction."
1831 1823
1832(defun Info-isearch-push-state () 1824(defun Info-isearch-push-state ()
1833 `(lambda (cmd) 1825 `(lambda (cmd)
1834 (Info-isearch-pop-state cmd ,Info-current-file ,Info-current-node))) 1826 (Info-isearch-pop-state cmd ',Info-current-file ',Info-current-node)))
1835 1827
1836(defun Info-isearch-pop-state (cmd file node) 1828(defun Info-isearch-pop-state (cmd file node)
1837 (or (and (string= Info-current-file file) 1829 (or (and (equal Info-current-file file)
1838 (string= Info-current-node node)) 1830 (equal Info-current-node node))
1839 (progn (Info-find-node file node) (sit-for 0)))) 1831 (progn (Info-find-node file node) (sit-for 0))))
1840 1832
1841(defun Info-isearch-start () 1833(defun Info-isearch-start ()
@@ -1853,7 +1845,7 @@ if ERRORNAME is nil, just return nil."
1853 (forward-line 1) 1845 (forward-line 1)
1854 (cond ((re-search-backward 1846 (cond ((re-search-backward
1855 (concat name ":" (Info-following-node-name-re)) bound t) 1847 (concat name ":" (Info-following-node-name-re)) bound t)
1856 (match-string 1)) 1848 (match-string-no-properties 1))
1857 ((not (eq errorname t)) 1849 ((not (eq errorname t))
1858 (error "Node has no %s" 1850 (error "Node has no %s"
1859 (capitalize (or errorname name))))))))) 1851 (capitalize (or errorname name)))))))))
@@ -1875,7 +1867,7 @@ End of submatch 0, 1, and 3 are the same, so you can safely concat."
1875;;; For compatibility; other files have used this name. 1867;;; For compatibility; other files have used this name.
1876(defun Info-following-node-name () 1868(defun Info-following-node-name ()
1877 (and (looking-at (Info-following-node-name-re)) 1869 (and (looking-at (Info-following-node-name-re))
1878 (match-string 1))) 1870 (match-string-no-properties 1)))
1879 1871
1880(defun Info-next () 1872(defun Info-next ()
1881 "Go to the next node of this node." 1873 "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 (Info-goto-node node) 1901 (Info-goto-node node)
1910 (setq p (point)) 1902 (setq p (point))
1911 (goto-char (point-min)) 1903 (goto-char (point-min))
1912 (if (and (search-forward "\n* Menu:" nil t) 1904 (if (and (stringp old-file)
1905 (search-forward "\n* Menu:" nil t)
1913 (re-search-forward 1906 (re-search-forward
1914 (if (string-equal old-node "Top") 1907 (if (string-equal old-node "Top")
1915 (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file) ")") 1908 (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 (while hl 1970 (while hl
1978 (let ((file (nth 0 (car hl))) 1971 (let ((file (nth 0 (car hl)))
1979 (node (nth 1 (car hl)))) 1972 (node (nth 1 (car hl))))
1980 (if (and (string-equal file curr-file) 1973 (if (and (equal file curr-file)
1981 (string-equal node curr-node)) 1974 (equal node curr-node))
1982 (setq p (point))) 1975 (setq p (point)))
1983 (insert "* " node ": (" 1976 (if (stringp file)
1984 (propertize (or (file-name-directory file) "") 'invisible t) 1977 (insert "* " node ": ("
1985 (file-name-nondirectory file) 1978 (propertize (or (file-name-directory file) "") 'invisible t)
1986 ")" node ".\n")) 1979 (file-name-nondirectory file)
1980 ")" node ".\n")))
1987 (setq hl (cdr hl)))))) 1981 (setq hl (cdr hl))))))
1988 (Info-find-node "history" "Top") 1982 (Info-find-node 'history "Top")
1989 (goto-char (or p (point-min))))) 1983 (goto-char (or p (point-min)))))
1990 1984
1991(defun Info-toc () 1985(defun Info-toc ()
1992 "Go to a node with table of contents of the current Info file. 1986 "Go to a node with table of contents of the current Info file.
1993Table of contents is created from the tree structure of menus." 1987Table of contents is created from the tree structure of menus."
1994 (interactive) 1988 (interactive)
1995 (let ((curr-file (substring-no-properties Info-current-file)) 1989 (if (stringp Info-current-file)
1996 (curr-node (substring-no-properties Info-current-node)) 1990 (let ((curr-file (substring-no-properties Info-current-file))
1997 p) 1991 (curr-node (substring-no-properties Info-current-node))
1998 (with-current-buffer (get-buffer-create " *info-toc*") 1992 p)
1999 (let ((inhibit-read-only t) 1993 (with-current-buffer (get-buffer-create " *info-toc*")
2000 (node-list (Info-build-toc curr-file))) 1994 (let ((inhibit-read-only t)
2001 (erase-buffer) 1995 (node-list (Info-build-toc curr-file)))
2002 (goto-char (point-min)) 1996 (erase-buffer)
2003 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n") 1997 (goto-char (point-min))
2004 (insert "Table of Contents\n*****************\n\n") 1998 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
2005 (insert "*Note Top: (" curr-file ")Top.\n") 1999 (insert "Table of Contents\n*****************\n\n")
2006 (Info-insert-toc 2000 (insert "*Note Top: (" curr-file ")Top.\n")
2007 (nth 2 (assoc "Top" node-list)) ; get Top nodes 2001 (Info-insert-toc
2008 node-list 0 curr-file)) 2002 (nth 2 (assoc "Top" node-list)) ; get Top nodes
2009 (if (not (bobp)) 2003 node-list 0 curr-file))
2010 (let ((Info-hide-note-references 'hide) 2004 (if (not (bobp))
2011 (Info-fontify-visited-nodes nil)) 2005 (let ((Info-hide-note-references 'hide)
2012 (Info-mode) 2006 (Info-fontify-visited-nodes nil))
2013 (setq Info-current-file "toc" Info-current-node "Top") 2007 (Info-mode)
2014 (goto-char (point-min)) 2008 (setq Info-current-file 'toc Info-current-node "Top")
2015 (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t) 2009 (goto-char (point-min))
2016 (point-min)) 2010 (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t)
2017 (point-max)) 2011 (point-min))
2018 (Info-fontify-node) 2012 (point-max))
2019 (widen))) 2013 (Info-fontify-node)
2020 (goto-char (point-min)) 2014 (widen)))
2021 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t)) 2015 (goto-char (point-min))
2022 (setq p (- p (length curr-node) 2)))) 2016 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t))
2023 (Info-find-node "toc" "Top") 2017 (setq p (- p (length curr-node) 2))))
2024 (goto-char (or p (point-min))))) 2018 (Info-find-node 'toc "Top")
2019 (goto-char (or p (point-min))))))
2025 2020
2026(defun Info-insert-toc (nodes node-list level curr-file) 2021(defun Info-insert-toc (nodes node-list level curr-file)
2027 "Insert table of contents with references to nodes." 2022 "Insert table of contents with references to nodes."
@@ -2221,16 +2216,18 @@ Because of ambiguities, this should be concatenated with something like
2221 (setq Info-point-loc 2216 (setq Info-point-loc
2222 (if (match-beginning 5) 2217 (if (match-beginning 5)
2223 (string-to-number (match-string 5)) 2218 (string-to-number (match-string 5))
2224 (buffer-substring (match-beginning 0) (1- (match-beginning 1))))) 2219 (buffer-substring-no-properties
2220 (match-beginning 0) (1- (match-beginning 1)))))
2225;;; Uncomment next line to use names of cross-references in non-index nodes: 2221;;; Uncomment next line to use names of cross-references in non-index nodes:
2226;;; (setq Info-point-loc 2222;;; (setq Info-point-loc
2227;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1)))) 2223;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
2228 ) 2224 )
2229 (replace-regexp-in-string 2225 (replace-regexp-in-string
2230 "[ \n]+" " " 2226 "[ \n]+" " "
2231 (or (match-string 2) 2227 (or (match-string-no-properties 2)
2232 ;; If the node name is the menu entry name (using `entry::'). 2228 ;; If the node name is the menu entry name (using `entry::').
2233 (buffer-substring (match-beginning 0) (1- (match-beginning 1))))))) 2229 (buffer-substring-no-properties
2230 (match-beginning 0) (1- (match-beginning 1)))))))
2234 2231
2235;; No one calls this. 2232;; No one calls this.
2236;;(defun Info-menu-item-sequence (list) 2233;;(defun Info-menu-item-sequence (list)
@@ -2684,7 +2681,7 @@ following nodes whose names also contain the word \"Index\"."
2684 (or file (setq file Info-current-file)) 2681 (or file (setq file Info-current-file))
2685 (or (assoc file Info-index-nodes) 2682 (or (assoc file Info-index-nodes)
2686 ;; Skip virtual Info files 2683 ;; Skip virtual Info files
2687 (and (member file '("dir" "history" "toc" "apropos")) 2684 (and (member file '("dir" apropos history toc))
2688 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) 2685 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes)))
2689 (not (stringp file)) 2686 (not (stringp file))
2690 (if Info-file-supports-index-cookies 2687 (if Info-file-supports-index-cookies
@@ -2926,7 +2923,7 @@ Build a menu of the possible matches."
2926 (message "%s" (if (eq (car-safe err) 'error) 2923 (message "%s" (if (eq (car-safe err) 'error)
2927 (nth 1 err) err)) 2924 (nth 1 err) err))
2928 (sit-for 1 t))))) 2925 (sit-for 1 t)))))
2929 (Info-goto-node (concat "(" current-file ")" current-node)) 2926 (Info-find-node current-file current-node)
2930 (setq Info-history ohist 2927 (setq Info-history ohist
2931 Info-history-list ohist-list) 2928 Info-history-list ohist-list)
2932 (message "Searching indices...done") 2929 (message "Searching indices...done")
@@ -2945,7 +2942,7 @@ Build a menu of the possible matches."
2945 (if (nth 3 entry) 2942 (if (nth 3 entry)
2946 (concat " (line " (nth 3 entry) ")") 2943 (concat " (line " (nth 3 entry) ")")
2947 ""))))) 2944 "")))))
2948 (Info-find-node "apropos" "Index") 2945 (Info-find-node 'apropos "Index")
2949 (setq Info-complete-cache nil))))) 2946 (setq Info-complete-cache nil)))))
2950 2947
2951(defun Info-undefined () 2948(defun Info-undefined ()
@@ -3287,10 +3284,14 @@ With a zero prefix arg, put the name inside a function call to `info'."
3287 (interactive "P") 3284 (interactive "P")
3288 (unless Info-current-node 3285 (unless Info-current-node
3289 (error "No current Info node")) 3286 (error "No current Info node"))
3290 (let ((node (concat "(" (file-name-nondirectory Info-current-file) ")" 3287 (let ((node (if (stringp Info-current-file)
3291 Info-current-node))) 3288 (concat "(" (file-name-nondirectory Info-current-file) ")"
3289 Info-current-node))))
3292 (if (zerop (prefix-numeric-value arg)) 3290 (if (zerop (prefix-numeric-value arg))
3293 (setq node (concat "(info \"" node "\")"))) 3291 (setq node (concat "(info \"" node "\")")))
3292 (unless (stringp Info-current-file)
3293 (setq node (format "(Info-find-node '%S '%S)"
3294 Info-current-file Info-current-node)))
3294 (kill-new node) 3295 (kill-new node)
3295 (message "%s" node))) 3296 (message "%s" node)))
3296 3297
@@ -3817,29 +3818,30 @@ the variable `Info-file-list-for-emacs'."
3817 "^[ \t]+" "" 3818 "^[ \t]+" ""
3818 (replace-regexp-in-string 3819 (replace-regexp-in-string
3819 "[ \t\n]+" " " 3820 "[ \t\n]+" " "
3820 (or (match-string 5) 3821 (or (match-string-no-properties 5)
3821 (and (not (equal (match-string 4) "")) 3822 (and (not (equal (match-string 4) ""))
3822 (match-string 4)) 3823 (match-string-no-properties 4))
3823 (match-string 2))))) 3824 (match-string-no-properties 2)))))
3824 (external-link-p 3825 (external-link-p
3825 (string-match "(\\([^)]+\\))\\([^)]*\\)" node)) 3826 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
3826 (file (if external-link-p 3827 (file (if external-link-p
3827 (file-name-nondirectory 3828 (file-name-nondirectory
3828 (match-string 1 node)) 3829 (match-string-no-properties 1 node))
3829 Info-current-file)) 3830 Info-current-file))
3830 (hl Info-history-list) 3831 (hl Info-history-list)
3831 res) 3832 res)
3832 (if external-link-p 3833 (if external-link-p
3833 (setq node (if (equal (match-string 2 node) "") 3834 (setq node (if (equal (match-string 2 node) "")
3834 "Top" 3835 "Top"
3835 (match-string 2 node)))) 3836 (match-string-no-properties 2 node))))
3836 (while hl 3837 (while hl
3837 (if (and (string-equal node (nth 1 (car hl))) 3838 (if (and (string-equal node (nth 1 (car hl)))
3838 (string-equal 3839 (equal file
3839 file (if external-link-p 3840 (if (and external-link-p
3840 (file-name-nondirectory 3841 (stringp (caar hl)))
3841 (caar hl)) 3842 (file-name-nondirectory
3842 (caar hl)))) 3843 (caar hl))
3844 (caar hl))))
3843 (setq res (car hl) hl nil) 3845 (setq res (car hl) hl nil)
3844 (setq hl (cdr hl)))) 3846 (setq hl (cdr hl))))
3845 res))) 'info-xref-visited 'info-xref)) 3847 res))) 'info-xref-visited 'info-xref))
@@ -3932,26 +3934,28 @@ the variable `Info-file-list-for-emacs'."
3932 (if (and Info-fontify-visited-nodes 3934 (if (and Info-fontify-visited-nodes
3933 (save-match-data 3935 (save-match-data
3934 (let* ((node (if (equal (match-string 3) "") 3936 (let* ((node (if (equal (match-string 3) "")
3935 (match-string 1) 3937 (match-string-no-properties 1)
3936 (match-string 3))) 3938 (match-string-no-properties 3)))
3937 (external-link-p 3939 (external-link-p
3938 (string-match "(\\([^)]+\\))\\([^)]*\\)" node)) 3940 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
3939 (file (if external-link-p 3941 (file (if external-link-p
3940 (file-name-nondirectory 3942 (file-name-nondirectory
3941 (match-string 1 node)) 3943 (match-string-no-properties 1 node))
3942 Info-current-file)) 3944 Info-current-file))
3943 (hl Info-history-list) 3945 (hl Info-history-list)
3944 res) 3946 res)
3945 (if external-link-p 3947 (if external-link-p
3946 (setq node (if (equal (match-string 2 node) "") 3948 (setq node (if (equal (match-string 2 node) "")
3947 "Top" 3949 "Top"
3948 (match-string 2 node)))) 3950 (match-string-no-properties 2 node))))
3949 (while hl 3951 (while hl
3950 (if (and (string-equal node (nth 1 (car hl))) 3952 (if (and (string-equal node (nth 1 (car hl)))
3951 (string-equal 3953 (equal file
3952 file (if external-link-p 3954 (if (and external-link-p
3953 (file-name-nondirectory (caar hl)) 3955 (stringp (caar hl)))
3954 (caar hl)))) 3956 (file-name-nondirectory
3957 (caar hl))
3958 (caar hl))))
3955 (setq res (car hl) hl nil) 3959 (setq res (car hl) hl nil)
3956 (setq hl (cdr hl)))) 3960 (setq hl (cdr hl))))
3957 res))) 'info-xref-visited 'info-xref))) 3961 res))) 'info-xref-visited 'info-xref)))
@@ -4210,8 +4214,8 @@ BUFFER is the buffer speedbar is requesting buttons for."
4210 4214
4211(defun Info-desktop-buffer-misc-data (desktop-dirname) 4215(defun Info-desktop-buffer-misc-data (desktop-dirname)
4212 "Auxiliary information to be saved in desktop file." 4216 "Auxiliary information to be saved in desktop file."
4213 (if (not (member Info-current-file '("apropos" "history" "toc"))) 4217 (unless (member Info-current-file '(apropos history toc nil))
4214 (list Info-current-file Info-current-node))) 4218 (list Info-current-file Info-current-node)))
4215 4219
4216(defun Info-restore-desktop-buffer (desktop-buffer-file-name 4220(defun Info-restore-desktop-buffer (desktop-buffer-file-name
4217 desktop-buffer-name 4221 desktop-buffer-name