]> code.delx.au - gnu-emacs/blobdiff - lisp/help.el
(inferior-octave-complete): Use comint-line-beginning-position.
[gnu-emacs] / lisp / help.el
index c683071ef5b0676c7d83663f0b325337a1fb2743..2950ffd59299bbbdd81bf588b53fa92b6683fe67 100644 (file)
@@ -357,7 +357,8 @@ For minor modes, see following pages.\n\n"))
          ;; Document a minor mode if it is listed in minor-mode-alist,
          ;; bound locally in this buffer, non-nil, and has a function
          ;; definition.
-         (if (and (symbol-value minor-mode)
+         (if (and (boundp minor-mode)
+                  (symbol-value minor-mode)
                   (fboundp minor-mode))
              (let ((pretty-minor-mode minor-mode))
                (if (string-match "-mode$" (symbol-name minor-mode))
@@ -724,17 +725,28 @@ It can also be nil, if the definition is not associated with any file."
                       ;; Builtins get the calling sequence at the end of
                       ;; the doc string.  Move it to the same place as
                       ;; for other functions.
-                      (if (looking-at (format "(%S[ )]" function))
-                          (let ((start (point-marker)))
-                            (goto-char (point-min))
-                            (forward-paragraph)
-                            (insert-buffer-substring (current-buffer) start)
-                            (insert ?\n)
-                            (delete-region (1- start) (point-max)))
-                        (goto-char (point-min))
-                        (forward-paragraph)
-                        (insert
-                         "[Missing arglist.  Please make a bug report.]\n"))
+
+                      ;; In cases where `function' has been fset to a
+                      ;; subr we can't search for function's name in
+                      ;; the doc string.  Kluge round that using the
+                      ;; printed representation.  The arg list then
+                      ;; shows the wrong function name, but that
+                      ;; might be a useful hint.
+                      (let* ((rep (prin1-to-string def))
+                             (name (progn
+                                     (string-match " \\([^ ]+\\)>$" rep)
+                                     (match-string 1 rep))))
+                        (if (looking-at (format "(%s[ )]" name))
+                            (let ((start (point-marker)))
+                              (goto-char (point-min))
+                              (forward-paragraph)
+                              (insert-buffer-substring (current-buffer) start)
+                              (insert ?\n)
+                              (delete-region (1- start) (point-max)))
+                          (goto-char (point-min))
+                          (forward-paragraph)
+                          (insert
+                           "[Missing arglist.  Please make a bug report.]\n")))
                       (goto-char (point-max))))
                 (help-setup-xref (list #'describe-function function)
                                  interactive-p))
@@ -836,13 +848,16 @@ Returns the documentation as a string, also."
            (set-buffer standard-output)
            (if (> (count-lines (point-min) (point-max)) 10)
                (progn
+                 ;; Note that setting the syntax table like below
+                 ;; makes forward-sexp move over a `'s' at the end
+                 ;; of a symbol.
                  (set-syntax-table emacs-lisp-mode-syntax-table)
                  (goto-char (point-min))
                  (if valvoid
                      (forward-line 1)
                    (forward-sexp 1)
                    (delete-region (point) (progn (end-of-line) (point)))
-                   (insert "'s value is shown below.\n\n")
+                   (insert " value is shown below.\n\n")
                    (save-excursion
                      (insert "\n\nValue:"))))))
          (princ "Documentation:")