diff lisp/info.el @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents de805c49cfc1
children da8ed4261e83
line wrap: on
line diff
--- a/lisp/info.el	Mon Aug 13 11:19:22 2007 +0200
+++ b/lisp/info.el	Mon Aug 13 11:20:41 2007 +0200
@@ -22,7 +22,7 @@
 ;; General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with XEmacs; see the file COPYING.  If not, write to the
+;; along with XEmacs; see the file COPYING.  If not, write to the 
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
@@ -308,7 +308,7 @@
 ;; contain none or when it has become older than info files in the same
 ;; directory.
 
-;; Modified 1998-09-23 by Didier Verna <didier@xemacs.org>
+;; Modified 1998-09-23 by Didier Verna <verna@inf.enst.fr>
 ;;
 ;; Use the new macro `with-search-caps-disable-folding'
 
@@ -402,10 +402,10 @@
 `always' auto-generate a directory listing ignoring existing
   `dir' and `localdir' files
 `if-missing', the default, auto-generates a directory listing
-  if no `dir' or `localdir' file is present.  Otherwise the
+  if no `dir' or `localdir' file is present.  Otherwise the 
   contents of any of these files is used instead.
 `if-outdated' auto-generates a directory listing if the `dir'
-  and `localdir' are either inexistent or outdated (touched
+  and `localdir' are either inexistent or outdated (touched 
   less recently than an info file in the same directory)."
   :type '(choice (const :tag "never" never)
 		 (const :tag "always" always)
@@ -413,15 +413,15 @@
 		 (const :tag "if-outdated" if-outdated))
   :group 'info)
 
-(defcustom Info-save-auto-generated-dir 'never
+(defcustom Info-save-auto-generated-dir nil
   "*Whether an auto-generated info directory listing should be saved.
 Possible values are:
-nil or `never', the default, auto-generated info directory
+nil or `never', the default, auto-generated info directory 
   information will never be saved.
 `always', auto-generated info directory information will be saved to
   a `dir' file in the same directory overwriting it if it exists
 `conservative', auto-generated info directory information will be saved
-  to a `dir' file in the same directory but the user is asked before
+  to a `dir' file in the same directory but the user is asked before 
   overwriting any existing file."
   :type '(choice (const :tag "never" never)
 		 (const :tag "always" always)
@@ -437,15 +437,9 @@
   "List of directories to search for Info documentation files.
 
 The first directory in this list, the \"dir\" file there will become
-the (dir)Top node of the Info documentation tree.
-
-Note: DO NOT use the `customize' interface to change the value of this
-variable.  Its value is created dynamically on each startup, depending
-on XEmacs packages installed on the system.  If you want to change the
-search path, make the needed modifications on the variable's value
-from .emacs.  For instance:
-
-    (setq Info-directory-list (cons \"~/info\" Info-directory-list))")
+the (dir)Top node of the Info documentation tree.  If you wish to
+modify the info search path, use `M-x customize-variable,
+Info-directory-list' to do so.")
 
 (defcustom Info-localdir-heading-regexp
     "^Locally installed XEmacs Packages:?"
@@ -463,9 +457,8 @@
   :group 'info-faces)
 
 ;; Is this right for NT?  .zip, with -c for to stdout, right?
-(defvar Info-suffix-list '( ("" . nil)
+(defvar Info-suffix-list '( ("" . nil) 
 			    (".info" . nil)
-			    (".info.bz2" . "bzip2 -dc %s")
 			    (".info.gz" . "gzip -dc %s")
 			    (".info-z" . "gzip -dc %s")
 			    (".info.Z" . "uncompress -c %s")
@@ -508,12 +501,9 @@
   "List of possible matches for last Info-index command.")
 (defvar Info-index-first-alternative nil)
 
-(defcustom Info-annotations-path
-  (list
-   (paths-construct-path (list user-init-directory "info.notes"))
-   (paths-construct-path '("~" ".infonotes"))
-   (paths-construct-path '("usr" "lib" "info.notes")
-			 (char-to-string directory-sep-char)))
+(defcustom Info-annotations-path '("~/.xemacs/info.notes"
+                                   "~/.infonotes"
+				   "/usr/lib/info.notes")
   "*Names of files that contain annotations for different Info nodes.
 By convention, the first one should reside in your personal directory.
 The last should be a world-writable \"public\" annotations file."
@@ -537,7 +527,7 @@
 looking at that node, which is (dir)Top.
 
 File: dir	Node: Top	This is the top of the INFO tree
-  This (the Directory node) gives a menu of major topics.
+  This (the Directory node) gives a menu of major topics. 
 
 * Menu: The list of major topics begins on the next line.
 
@@ -592,7 +582,6 @@
 	  (bury-buffer (find-file-noselect (car f))))
       (setq f (cdr f)))))
 
-;;;###autoload
 (defun Info-find-node (filename &optional nodename no-going-back tryfile line)
   "Go to an info node specified as separate FILENAME and NODENAME.
 Look for a plausible filename, or if not found then look for URL's and
@@ -608,7 +597,7 @@
     (Info-find-file-node nil nodename no-going-back tryfile line))
    ;; Convert filename to lower case if not found as specified.
    ;; Expand it, look harder...
-   ((let (temp temp-downcase found
+   ((let (temp temp-downcase found 
 	       (fname (substitute-in-file-name filename)))
       (let ((dirs (cond
 		   ((string-match "^\\./" fname) ; If specified name starts with `./'
@@ -629,7 +618,7 @@
 	  ;; Try downcasing, appending a suffix, or both.
 	  (setq found (Info-suffixed-file temp temp-downcase))
 	  (setq dirs (cdr dirs)))
-	(if found
+	(if found 
 	    (progn (setq filename (expand-file-name found))
 		   t))))
     (Info-find-file-node filename nodename no-going-back tryfile line))
@@ -871,7 +860,7 @@
 				       (if (string-match "localdir" file)
 					   "localdir"
 					 "info dir"))))
-		      (if (not buf)
+		      (if (not buf) 
 			  (insert-file-contents file))
 		      (if (string-match "localdir" (buffer-name))
 			  (setq lbuffers (cons (current-buffer) lbuffers))
@@ -882,13 +871,13 @@
 				      Info-dir-file-attributes)))))))
 	  (or (cdr dirs) (setq Info-dir-contents-directory (car dirs)))
 	  (setq dirs (cdr dirs))))
-
+      
       ;; ensure that the localdir files are inserted last, and reverse
       ;; the list of them so that when they get pushed in, they appear
       ;; in the same order they got specified in the path, from top to
       ;; bottom.
       (nconc buffers (reverse lbuffers))
-
+      
       (or buffers
 	  (error "Can't find the Info directory node"))
       ;; Distinguish the dir file that comes with Emacs from all the
@@ -957,7 +946,7 @@
 		  (setq end (point))
 		  (setq nodes (cons (list nodename other beg end) nodes))))))
 	  (setq others (cdr others))))
-
+      
       ;; Add to the main menu a menu item for each other node.
       (re-search-forward "^\\* Menu:" nil t)
       (forward-line 1)
@@ -1017,7 +1006,7 @@
     (if (not (find-buffer-visiting file))
 	(if (not (file-exists-p file))
 	    (if (or (eq Info-auto-generate-directory 'always)
-		    (eq Info-auto-generate-directory 'if-missing))
+		    (eq Info-auto-generate-directory 'if-missing))	      
 		(Info-build-dir-anew (file-name-directory file)))
 	  (if (or (eq Info-auto-generate-directory 'always)
 		  (and (eq Info-auto-generate-directory 'if-outdated)
@@ -1035,7 +1024,7 @@
 	f-mod-time
 	newer)
     (setq Info-dir-newer-info-files nil)
-    (mapcar
+    (mapcar 
      #'(lambda (f)
 	 (prog2
 	     (setq f-mod-time (nth 5 (file-attributes f)))
@@ -1044,7 +1033,7 @@
 				  (> (car (cdr f-mod-time)) (car (cdr dir-mod-time))))))
 	   (if (and (file-readable-p f)
 		    newer)
-	       (setq Info-dir-newer-info-files
+	       (setq Info-dir-newer-info-files 
 		     (cons f Info-dir-newer-info-files)))))
      (directory-files (file-name-directory file)
 		      'fullname
@@ -1083,12 +1072,12 @@
 			    (match-string 1)
 			    (downcase (or (match-string 3)
 					  (match-string 1)))))
-	  (setq entry
-		(cons (nreverse
-		       (cdr
-			(nreverse
-			 (split-string
-			  (buffer-substring
+	  (setq entry 
+		(cons (nreverse 
+		       (cdr 
+			(nreverse 
+			 (split-string 
+			  (buffer-substring 
 			   (re-search-forward "[ \t]*" nil t)
 			   (or (and (re-search-forward "^[^ \t]" nil t)
 				    (goto-char (match-beginning 0)))
@@ -1109,7 +1098,7 @@
 		(if (> len description-col)
 		    (setq description-col len)))
 	    entries)
-    (setq description-col (+ 5 description-col))
+    (setq description-col (+ 5 description-col)) 
     (mapcar #'(lambda (e)
 		(setq e (cdr e))	; Drop filename
 		(insert "* " (car e) ":" (car (cdr e)))
@@ -1124,7 +1113,7 @@
 
 (defun Info-build-dir-anew (directory)
   "Build info directory information for DIRECTORY.
-The generated directory listing may be saved to a `dir' according
+The generated directory listing may be saved to a `dir' according 
 to the value of `Info-save-auto-generated-dir'"
   (save-excursion
     (let* ((dirfile (expand-file-name "dir" directory))
@@ -1132,7 +1121,7 @@
 			(eq Info-save-auto-generated-dir 'never)
 			(and (not (file-writable-p dirfile))
 			     (message "File not writable %s. Using temporary." dirfile))))
-	   (info-files
+	   (info-files 
 	    (directory-files directory
 			     'fullname
 			     ".*\\.info\\(.gz\\|.Z\\|-z\\|.zip\\)?$"
@@ -1146,13 +1135,13 @@
       (erase-buffer)
       (insert Info-dir-prologue
 	      "Info files in " directory ":\n\n")
-      (Info-dump-dir-entries
-       (mapcar
+      (Info-dump-dir-entries 
+       (mapcar 
 	#'(lambda (f)
 	    (or (Info-extract-dir-entry-from f)
 		(list 'dummy
-		      (progn
-			(string-match "\\(.*\\)\\.info\\(.gz\\|.Z\\|-z\\|.zip\\)?$"
+		      (progn 
+			(string-match "\\(.*\\)\\.info\\(.gz\\|.Z\\|-z\\|.zip\\)?$" 
 				      (file-name-nondirectory f))
 			(capitalize (match-string 1 (file-name-nondirectory f))))
 		      ":"
@@ -1168,10 +1157,10 @@
 
 (defun Info-rebuild-dir (file)
   "Build info directory information in the directory of dir FILE.
-Description of info files are merged from the info files in the
+Description of info files are merged from the info files in the 
 directory and the contents of FILE with the description in info files
-taking precedence over descriptions in FILE.
-The generated directory listing may be saved to a `dir' according to
+taking precedence over descriptions in FILE.  
+The generated directory listing may be saved to a `dir' according to 
 the value of `Info-save-auto-generated-dir' "
   (save-excursion
     (save-restriction
@@ -1180,7 +1169,7 @@
 	    file-dir-entry
 	    mark next-section
 	    not-first-section
-	    (to-temp
+	    (to-temp 
 	     (or (null Info-save-auto-generated-dir)
 		 (eq Info-save-auto-generated-dir 'never)
 		 (and (eq Info-save-auto-generated-dir 'always)
@@ -1189,8 +1178,8 @@
 		 (and (eq Info-save-auto-generated-dir 'conservative)
 		      (or (and (not (file-writable-p file))
 			       (message "File not writable %s. Using temporary." file))
-			  (not (y-or-n-p
-				(message "%s is outdated. Overwrite ? "
+			  (not (y-or-n-p 
+				(message "%s is outdated. Overwrite ? " 
 					 file))))))))
 	(set-buffer (find-file-noselect file t))
 	(setq buffer-read-only nil)
@@ -1233,12 +1222,12 @@
 		     (if file-dir-entry
 			 (setq dir-section-contents (cons file-dir-entry
 							  dir-section-contents))
-		       (setq dir-section-contents
+		       (setq dir-section-contents 
 			     (cons (list 'dummy
 					 (capitalize (file-name-sans-extension
 						      (file-name-nondirectory file)))
 					 ":"
-					 (list Info-no-description-string))
+					 (list Info-no-description-string)) 
 				   dir-section-contents))))))
 	     Info-dir-newer-info-files)
 	    (delete-region (point-min) (point-max))
@@ -1260,7 +1249,7 @@
 	  (save-buffer)
 	  (message "Rebuilding %s...done" file))))))
 
-;;;###autoload
+;;;###autoload      
 (defun Info-batch-rebuild-dir ()
   "(Re)build info `dir' files in the directories remaining on the command line.
 Use this from the command line, with `-batch';
@@ -1280,7 +1269,7 @@
 		   (car command-line-args-left))
 	(setq dir (expand-file-name "dir" (car command-line-args-left)))
 	(setq localdir (expand-file-name "localdir" (car command-line-args-left)))
-	(cond
+	(cond 
 	 ((file-exists-p dir)
 	  (Info-rebuild-dir dir))
 	 ((file-exists-p localdir)
@@ -1496,10 +1485,12 @@
     (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag)))))
 
 ;;;###autoload
-(defun Info-visit-file (file)
+(defun Info-visit-file ()
   "Directly visit an info file."
-  (interactive "fVisit Info file: ")
-  (Info-find-node (expand-file-name file) "Top"))
+  (interactive)
+  (let* ((insert-default-directory nil)
+	 (file (read-file-name "Goto Info file: " "" "")))
+    (or (equal file "") (Info-find-node (expand-file-name file) "Top"))))
 
 (defun Info-restore-point (&optional always)
   "Restore point to same location it had last time we were in this node."
@@ -1518,33 +1509,13 @@
        (set-window-start (get-buffer-window (current-buffer))
 			 (+ (nth 2 entry) (point-min)))))
 
-(defvar Info-read-node-completion-table)
-
-;; This function is used as the "completion table" while reading a node name.
-;; It does completion using the alist in Info-read-node-completion-table
-;; unless STRING starts with an open-paren.
-(defun Info-read-node-name-1 (string predicate code)
-  (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\())))
-    (cond ((eq code nil)
-	   (if no-completion
-	       string
-	     (try-completion string Info-read-node-completion-table predicate)))
-	  ((eq code t)
-	   (if no-completion
-	       nil
-	     (all-completions string Info-read-node-completion-table predicate)))
-	  ((eq code 'lambda)
-	   (if no-completion
-	       t
-	     (assoc string Info-read-node-completion-table))))))
-
 (defun Info-read-node-name (prompt &optional default)
   (Info-setup-initial)
   (let* ((completion-ignore-case t)
-	 (Info-read-node-completion-table (Info-build-node-completions))
-	 (nodename (completing-read prompt 'Info-read-node-name-1
-				    nil t nil 'Info-minibuffer-history
-				    default)))
+	 (nodename (completing-read prompt
+				    (Info-build-node-completions)
+				    nil nil nil
+				    'Info-minibuffer-history)))
     (if (equal nodename "")
 	(or default
 	    (Info-read-node-name prompt))
@@ -1588,7 +1559,7 @@
 		  (forward-line 1)
 		  (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
 					  beg t)
-		      (setq compl
+		      (setq compl 
 			    (cons (list (buffer-substring (match-beginning 1)
 							  (match-end 1)))
 				  compl))))))))
@@ -1601,14 +1572,10 @@
 ;;;###autoload
 (defun Info-search (regexp)
   "Search for REGEXP, starting from point, and select node it's found in."
-  (interactive (list
-		(read-from-minibuffer
-		 (if Info-last-search
-		     (format "Search (regexp, default %s): "
-			     Info-last-search)
-		   "Search (regexp): ")
-		 nil nil nil nil nil Info-last-search)))
-  (setq Info-last-search regexp)
+  (interactive "sSearch (regexp): ")
+  (if (equal regexp "")
+      (setq regexp Info-last-search)
+    (setq Info-last-search regexp))
   (with-search-caps-disable-folding regexp t
     (let ((found ())
           (onode Info-current-node)
@@ -1668,7 +1635,7 @@
           (Info-history-add ofile onode opoint)))))
 
 ;; Extract the value of the node-pointer named NAME.
-;; If there is none, use ERRORNAME in the error message;
+;; If there is none, use ERRORNAME in the error message; 
 ;; if ERRORNAME is nil, just return nil.
 (defun Info-extract-pointer (name &optional errorname)
   (save-excursion
@@ -1685,7 +1652,7 @@
 
 ;; Return the node name in the buffer following point.
 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
-;; saying which chars may appear in the node name.
+;; saying which chas may appear in the node name.
 (defun Info-following-node-name (&optional allowedchars)
   (skip-chars-forward " \t")
   (buffer-substring
@@ -1695,7 +1662,7 @@
        (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
        (if (looking-at "(")
 	   (skip-chars-forward "^)")))
-     (skip-chars-backward " .")
+     (skip-chars-backward " ")
      (point))))
 
 (defun Info-next (&optional n)
@@ -1790,8 +1757,7 @@
 						  default ") ")
 					"Follow reference named: ")
 				      completions nil t nil
-				      'Info-minibuffer-history
-				      default)))
+				      'Info-minibuffer-history)))
 	   (if (and (string= item "") default)
 	       (list default)
 	     (list item)))
@@ -1875,19 +1841,7 @@
 	  (if (looking-at ":")
 	      (buffer-substring beg (1- (point)))
 	    (skip-chars-forward " \t\n")
-	    ;; Kludge.
-	    ;; Allow dots in node name not followed by whitespace.
-	    (re-search-forward
-	     (concat "\\(([^)]+)[^."
-		     (if multi-line "" "\n")
-		     "]*\\|\\([^.,\t"
-		     (if multi-line "" "\n")
-		     ;; We consider dots followed by newline as
-		     ;; end of nodename even if multil-line.
-		     ;; Also stops at .).  It is generated by @pxref.
-		     ;; Skips sequential dots.
-		     "]\\|\\.+[^ \t\n)]\\)+\\)"))
-	    (match-string 1)))
+	    (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n"))))
     (while (setq i (string-match "\n" str i))
       (aset str i ?\ ))
     str))
@@ -1930,8 +1884,7 @@
 						   default)
 					   "Menu item: ")
 				       completions nil t nil
-				       'Info-minibuffer-history
-				       default)))
+				       'Info-minibuffer-history)))
 	 ;; we rely on the fact that completing-read accepts an input
 	 ;; of "" even when the require-match argument is true and ""
 	 ;; is not a valid possibility
@@ -1944,7 +1897,7 @@
   ;; there is a problem here in that if several menu items have the same
   ;; name you can only go to the node of the first with this command.
   (Info-goto-node (Info-extract-menu-item menu-item) nil t))
-
+  
 (defun Info-extract-menu-item (menu-item &optional noerror)
   (save-excursion
     (goto-char (point-min))
@@ -2107,9 +2060,11 @@
 	  (progn
 	    (Info-global-prev)
 	    (message "Node: %s" Info-current-node)
-	    (goto-char (point-max))
-	    (recenter -1)
-	    (move-to-window-line 0))
+	    (sit-for 0)
+	    ;;(scroll-up 1)   ; work around bug in pos-visible-in-window-p
+	    ;;(scroll-down 1)
+	    (while (not (pos-visible-in-window-p (point-max)))
+	      (scroll-up)))
 	(scroll-down)))))
 
 (defun Info-scroll-prev (arg)
@@ -2119,9 +2074,9 @@
 	       (not (eq Info-auto-advance t))
 	       (not (eq last-command this-command)))
 	  (message "Hit %s again to go to previous node"
-		   (if (mouse-event-p last-command-event)
+		   (if (= last-command-char 0)
 		       "mouse button"
-		     (key-description (event-key last-command-event))))
+		     (key-description (char-to-string last-command-char))))
 	(Info-page-prev)
 	(setq this-command 'Info))
     (scroll-down arg)))
@@ -2138,7 +2093,7 @@
   (interactive "sIndex topic: ")
   (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s"
 			 (regexp-quote topic)
-			 "\\(.*\\)\\.[ t]*\\([0-9]*\\)$"))
+			 "\\([^.\n]*\\)\\.[ t]*\\([0-9]*\\)"))
 	node)
     (message "Searching index for `%s'..." topic)
     (Info-goto-node "Top")
@@ -2293,7 +2248,7 @@
   "Look up an Emacs Lisp function in the Elisp manual in the Info system.
 This command is designed to be used whether you are already in Info or not."
   (interactive (let ((fn (function-at-point))
-		     (enable-recursive-minibuffers t)
+		     (enable-recursive-minibuffers t)	     
 		     val)
 		 (setq val (completing-read
 			    (format "Look up Emacs Lisp function%s: "
@@ -3000,7 +2955,7 @@
 Used to construct the menubar submenu and popup menu."
   (or event (setq event (point)))
   (let ((case-fold-search t)
-	(xref-regexp (concat "\\*"
+	(xref-regexp (concat "\\*" 
 			     (regexp-quote Info-footnote-tag)
 			     "[ \n\t]*\\([^:]*\\):"))
 	up-p prev-p next-p menu xrefs subnodes in)