]> code.delx.au - gnu-emacs/blobdiff - lisp/help-fns.el
* cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
[gnu-emacs] / lisp / help-fns.el
index 2974e65bf888022c629db9344734b80e3c7e8c5f..78c156fa410695774b5890f9a8eef9345f72cfe1 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
 
@@ -251,7 +223,6 @@ KIND should be `var' for a variable or `subr' for a subroutine."
            (concat "src/" file)
          file)))))
 
-;;;###autoload
 (defface help-argument-name '((((supports :slant italic)) :inherit italic))
   "Face to highlight argument names in *Help* buffers."
   :group 'help)
@@ -269,22 +240,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 +282,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 +348,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.
@@ -451,7 +435,9 @@ face (according to `face-differs-from-default-p')."
                          (format "\nMacro: %s" (format-kbd-macro def)))
                         (t "[Missing arglist.  Please make a bug report.]")))
                  (high (help-highlight-arguments use doc)))
-            (insert (car high) "\n")
+            (let ((fill-begin (point)))
+             (insert (car high) "\n")
+             (fill-region fill-begin (point)))
             (setq doc (cdr high))))
         (let ((obsolete (and
                          ;; function might be a lambda construct.
@@ -511,7 +497,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 +523,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 +703,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))))))))