]> code.delx.au - gnu-emacs/blobdiff - lisp/help-fns.el
(Minor Mode Conventions): Use custom-set-minor-mode.
[gnu-emacs] / lisp / help-fns.el
index 2974e65bf888022c629db9344734b80e3c7e8c5f..6e1bd62d04bca1f0f3897aba4265330681324462 100644 (file)
@@ -100,34 +100,6 @@ With ARG, you are asked to choose which language."
       (setq buffer-undo-list nil)
       (set-buffer-modified-p nil))))
 
-;;;###autoload
-(defun locate-library (library &optional nosuffix path interactive-call)
-  "Show the precise file name of Emacs library LIBRARY.
-This command searches the directories in `load-path' like `\\[load-library]'
-to find the file that `\\[load-library] RET LIBRARY RET' would load.
-Optional second arg NOSUFFIX non-nil means don't add suffixes `load-suffixes'
-to the specified name LIBRARY.
-
-If the optional third arg PATH is specified, that list of directories
-is used instead of `load-path'.
-
-When called from a program, the file name is normaly returned as a
-string.  When run interactively, the argument INTERACTIVE-CALL is t,
-and the file name is displayed in the echo area."
-  (interactive (list (completing-read "Locate library: "
-                                     'locate-file-completion
-                                     (cons load-path load-suffixes))
-                    nil nil
-                    t))
-  (let ((file (locate-file library
-                          (or path load-path)
-                          (append (unless nosuffix load-suffixes) '("")))))
-    (if interactive-call
-       (if file
-           (message "Library is file %s" (abbreviate-file-name file))
-         (message "No library %s in search path" library)))
-    file))
-
 \f
 ;; Functions
 
@@ -269,22 +241,20 @@ face (according to `face-differs-from-default-p')."
 (defun help-do-arg-highlight (doc args)
   (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table)
     (modify-syntax-entry ?\- "w")
-    (while args
-      (let ((arg (prog1 (car args) (setq args (cdr args)))))
-        (setq doc (replace-regexp-in-string
-                   ;; This is heuristic, but covers all common cases
-                   ;; except ARG1-ARG2
-                   (concat "\\<"                   ; beginning of word
-                           "\\(?:[a-z-]*-\\)?"     ; for xxx-ARG
-                           "\\("
-                           (regexp-quote arg)
-                           "\\)"
-                           "\\(?:es\\|s\\|th\\)?"  ; for ARGth, ARGs
-                           "\\(?:-[a-z-]+\\)?"     ; for ARG-xxx
-                           "\\>")                  ; end of word
-                   (help-default-arg-highlight arg)
-                   doc t t 1))))
-    doc))
+    (dolist (arg args doc)
+      (setq doc (replace-regexp-in-string
+                 ;; This is heuristic, but covers all common cases
+                 ;; except ARG1-ARG2
+                 (concat "\\<"                   ; beginning of word
+                         "\\(?:[a-z-]*-\\)?"     ; for xxx-ARG
+                         "\\("
+                         (regexp-quote arg)
+                         "\\)"
+                         "\\(?:es\\|s\\|th\\)?"  ; for ARGth, ARGs
+                         "\\(?:-[a-z0-9-]+\\)?"  ; for ARG-xxx, ARG-n
+                         "\\>")                  ; end of word
+                 (help-default-arg-highlight arg)
+                 doc t t 1)))))
 
 (defun help-highlight-arguments (usage doc &rest args)
   (when usage
@@ -313,6 +283,20 @@ face (according to `face-differs-from-default-p')."
   ;; Return value is like the one from help-split-fundoc, but highlighted
   (cons usage doc))
 
+;;;###autoload
+(defun describe-simplify-lib-file-name (file)
+  "Simplify a library name FILE to a relative name, and make it a source file."
+  (if file
+      ;; Try converting the absolute file name to a library name.
+      (let ((libname (file-name-nondirectory file)))
+       ;; Now convert that back to a file name and see if we get
+       ;; the original one.  If so, they are equivalent.
+       (if (equal file (locate-file libname load-path '("")))
+           (if (string-match "[.]elc\\'" libname)
+               (substring libname 0 -1)
+             libname)
+         file))))
+
 ;;;###autoload
 (defun describe-function-1 (function)
   (let* ((def (if (symbolp function)
@@ -365,6 +349,7 @@ face (according to `face-differs-from-default-p')."
              (help-xref-button 1 'help-function def)))))
     (or file-name
        (setq file-name (symbol-file function 'defun)))
+    (setq file-name (describe-simplify-lib-file-name file-name))
     (when (equal file-name "loaddefs.el")
       ;; Find the real def site of the preloaded function.
       ;; This is necessary only for defaliases.
@@ -511,7 +496,11 @@ it is displayed along with the global value."
                                    (format
                                     "Describe variable (default %s): " v)
                                  "Describe variable: ")
-                               obarray 'boundp t nil nil
+                               obarray
+                               '(lambda (vv)
+                                  (or (boundp vv)
+                                      (get vv 'variable-documentation)))
+                               t nil nil
                                (if (symbolp v) (symbol-name v))))
      (list (if (equal val "")
               v (intern val)))))
@@ -533,6 +522,7 @@ it is displayed along with the global value."
            ;; change the format of the buffer's initial line in case
            ;; anything expects the current format.)
            (let ((file-name (symbol-file variable 'defvar)))
+             (setq file-name (describe-simplify-lib-file-name file-name))
              (when (equal file-name "loaddefs.el")
                ;; Find the real def site of the preloaded variable.
                (let ((location
@@ -712,7 +702,7 @@ BUFFER should be a buffer or a buffer name."
            (dotimes (i 95)
              (let ((elt (aref docs i)))
                (when elt
-                 (insert (+ i ?\ ) ": " elt "\n"))))
+                 (insert (+ i ?\s) ": " elt "\n"))))
            (while (setq table (char-table-parent table))
              (insert "\nThe parent category table is:")
              (describe-vector table 'help-describe-category-set))))))))