]> code.delx.au - gnu-emacs/blobdiff - lisp/help.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / help.el
index 1826cb7219a2f9be9d93279bdefb74f892eb2798..baccf5988b8882bda14c658b0bbaf881b0def5e6 100644 (file)
@@ -1,6 +1,6 @@
 ;;; help.el --- help commands for Emacs
 
-;; Copyright (C) 1985-1986, 1993-1994, 1998-2015 Free Software
+;; Copyright (C) 1985-1986, 1993-1994, 1998-2016 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: emacs-devel@gnu.org
@@ -355,7 +355,7 @@ With argument, display info only for the selected version."
                   (while (re-search-forward
                           (if (member file '("NEWS.18" "NEWS.1-17"))
                               "Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
-                            "^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t)
+                            "^\\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t)
                     (setq res (cons (match-string-no-properties 1) res)))))
               (cons "NEWS"
                     (directory-files data-directory nil
@@ -392,7 +392,7 @@ With argument, display info only for the selected version."
       (when (re-search-forward
             (concat (if (< vn 19)
                         "Changes in Emacs[ \t]*"
-                      "^\* [^0-9\n]*") version "$")
+                      "^\\* [^0-9\n]*") version "$")
             nil t)
        (beginning-of-line)
        (narrow-to-region
@@ -402,7 +402,7 @@ With argument, display info only for the selected version."
                             (re-search-forward
                              (if (< vn 19)
                                  "Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
-                               "^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t))
+                               "^\\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t))
                       (equal (match-string-no-properties 1) version)))
           (or res (goto-char (point-max)))
           (beginning-of-line)
@@ -613,7 +613,15 @@ temporarily enables it to allow getting help on disabled items and buttons."
           (when (null (cdr yank-menu))
             (setq saved-yank-menu (copy-sequence yank-menu))
             (menu-bar-update-yank-menu "(any string)" nil))
-          (setq key (read-key-sequence "Describe key (or click or menu item): "))
+           (while
+               (progn
+                 (setq key (read-key-sequence "Describe the following key, mouse click, or menu item: "))
+                 (and (vectorp key)
+                      (consp (aref key 0))
+                      (symbolp (car (aref key 0)))
+                      (string-match "\\(mouse\\|down\\|click\\|drag\\)"
+                                    (symbol-name (car (aref key 0))))
+                      (not (sit-for (/ double-click-time 1000.0) t)))))
           ;; Clear the echo area message (Bug#7014).
           (message nil)
           ;; If KEY is a down-event, read and discard the
@@ -750,7 +758,15 @@ temporarily enables it to allow getting help on disabled items and buttons."
           (when (null (cdr yank-menu))
             (setq saved-yank-menu (copy-sequence yank-menu))
             (menu-bar-update-yank-menu "(any string)" nil))
-          (setq key (read-key-sequence "Describe key (or click or menu item): "))
+           (while
+               (progn
+                 (setq key (read-key-sequence "Describe the following key, mouse click, or menu item: "))
+                 (and (vectorp key)
+                      (consp (aref key 0))
+                      (symbolp (car (aref key 0)))
+                      (string-match "\\(mouse\\|down\\|click\\|drag\\)"
+                                    (symbol-name (car (aref key 0))))
+                      (not (sit-for (/ double-click-time 1000.0) t)))))
           (list
            key
            (prefix-numeric-value current-prefix-arg)
@@ -964,13 +980,12 @@ documentation for the major and minor modes of that buffer."
        (let* ((mode major-mode)
               (file-name (find-lisp-object-file-name mode nil)))
          (when file-name
-           (princ (concat (substitute-command-keys " defined in ‘")
-                           (file-name-nondirectory file-name)
-                           (substitute-command-keys "’")))
+           (princ (format-message " defined in `%s'"
+                                   (file-name-nondirectory file-name)))
            ;; Make a hyperlink to the library.
            (with-current-buffer standard-output
              (save-excursion
-               (re-search-backward (substitute-command-keys "‘\\([^‘’]+\\)’")
+               (re-search-backward (substitute-command-keys "`\\([^`']+\\)'")
                                     nil t)
                (help-xref-button 1 'help-function-def mode file-name)))))
        (princ ":\n")
@@ -1070,7 +1085,7 @@ is currently activated with completion."
 ;;; Automatic resizing of temporary buffers.
 (defcustom temp-buffer-max-height
   (lambda (buffer)
-    (if (eq (selected-window) (frame-root-window))
+    (if (and (display-graphic-p) (eq (selected-window) (frame-root-window)))
        (/ (x-display-pixel-height) (frame-char-height) 2)
       (/ (- (frame-height) 2) 2)))
   "Maximum height of a window displaying a temporary buffer.
@@ -1087,7 +1102,7 @@ function is called, the window to be resized is selected."
 
 (defcustom temp-buffer-max-width
   (lambda (buffer)
-    (if (eq (selected-window) (frame-root-window))
+    (if (and (display-graphic-p) (eq (selected-window) (frame-root-window)))
        (/ (x-display-pixel-width) (frame-char-width) 2)
       (/ (- (frame-width) 2) 2)))
   "Maximum width of a window displaying a temporary buffer.
@@ -1163,8 +1178,8 @@ size of WINDOW."
                       (and (window-combined-p window t)
                            fit-window-to-buffer-horizontally)))
              (and (eq quit-cadr 'frame)
-                    fit-frame-to-buffer
-                    (eq window (frame-root-window window))))
+                   fit-frame-to-buffer
+                   (eq window (frame-root-window window))))
        (fit-window-to-buffer window height nil width nil t))))
 
 ;;; Help windows.
@@ -1353,8 +1368,8 @@ the help window if the current value of the user option
 \f
 (defun help--docstring-quote (string)
   "Return a doc string that represents STRING.
-The result, when formatted by ‘substitute-command-keys’, should equal STRING."
-  (replace-regexp-in-string "['\\`]" "\\\\=\\&" string))
+The result, when formatted by `substitute-command-keys', should equal STRING."
+  (replace-regexp-in-string "['\\`‘’]" "\\\\=\\&" string))
 
 ;; The following functions used to be in help-fns.el, which is not preloaded.
 ;; But for various reasons, they are more widely needed, so they were
@@ -1395,9 +1410,10 @@ ARGLIST can also be t or a string of the form \"(FUN ARG1 ARG2 ...)\"."
            (if (string-match "\n?\n\\'" docstring)
                (if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "")
              "\n\n")
-           (if (and (stringp arglist)
-                    (string-match "\\`([^ ]+\\(.*\\))\\'" arglist))
-               (concat "(fn" (match-string 1 arglist) ")")
+           (if (stringp arglist)
+                (if (string-match "\\`[^ ]+\\(.*\\))\\'" arglist)
+                    (concat "(fn" (match-string 1 arglist) ")")
+                  (error "Unrecognized usage format"))
              (help--make-usage-docstring 'fn arglist)))))
 
 (defun help-function-arglist (def &optional preserve-names)