]> code.delx.au - gnu-emacs/blobdiff - lisp/subr.el
; Merge from origin/emacs-25
[gnu-emacs] / lisp / subr.el
index db1baf09c43ca9594826d6abb728c01052df6e24..6eea54f2a32cfb2892d7fc1c20c6f0d68080b226 100644 (file)
@@ -2255,7 +2255,7 @@ Usage example:
   (let* ((altered-names nil)
          (full-prompt
           (format
-           "%s (%s, ?): "
+           "%s (%s): "
            prompt
            (mapconcat
             (lambda (elem)
@@ -2268,7 +2268,8 @@ Usage example:
                         (format "[%c] %s" (car elem) name))
                        ;; The prompt character is in the name, so highlight
                        ;; it on graphical terminals...
-                       ((display-graphic-p)
+                       ((display-supports-face-attributes-p
+                         '(:underline t) (window-frame))
                         (setq name (copy-sequence name))
                         (put-text-property pos (1+ pos)
                                            'face 'read-multiple-choice-face
@@ -2285,19 +2286,41 @@ Usage example:
                 (push (cons (car elem) altered-name)
                       altered-names)
                 altered-name))
-            choices ", ")))
-         tchar buf)
+            (append choices '((?? "?")))
+            ", ")))
+         tchar buf wrong-char)
     (save-window-excursion
       (save-excursion
        (while (not tchar)
-         (message "%s" full-prompt)
-         (setq tchar (condition-case nil
-                          (read-char)
-                        (error nil)))
+         (message "%s%s"
+                   (if wrong-char
+                       "Invalid choice.  "
+                     "")
+                   full-prompt)
+          (setq tchar
+                (if (and (display-popup-menus-p)
+                         last-input-event ; not during startup
+                         (listp last-nonmenu-event)
+                         use-dialog-box)
+                    (x-popup-dialog
+                     t
+                     (cons prompt
+                           (mapcar
+                            (lambda (elem)
+                              (cons (capitalize (cadr elem))
+                                    (car elem)))
+                            choices)))
+                  (condition-case nil
+                      (let ((cursor-in-echo-area t))
+                        (read-char))
+                    (error nil))))
           ;; The user has entered an invalid choice, so display the
           ;; help messages.
          (when (not (assq tchar choices))
-           (setq tchar nil)
+           (setq wrong-char (not (memq tchar '(?? ?\C-h)))
+                  tchar nil)
+            (when wrong-char
+              (ding))
             (with-help-window (setq buf (get-buffer-create
                                          "*Multiple Choice Help*"))
               (with-current-buffer buf
@@ -2317,9 +2340,10 @@ Usage example:
                         ;; Add padding.
                         (while (not (eobp))
                           (end-of-line)
-                          (insert (make-string (- (* (mod times columns)
-                                                     (+ fill-column 4))
-                                                  (current-column))
+                          (insert (make-string (max (- (* (mod times columns)
+                                                          (+ fill-column 4))
+                                                       (current-column))
+                                                    0)
                                                ?\s))
                           (forward-line 1))))
                     (setq times (1+ times))
@@ -2331,10 +2355,11 @@ Usage example:
                                       (cdr (assq (car elem) altered-names))))
                              (fill-region (point-min) (point-max))
                              (when (nth 2 elem)
-                               (insert (nth 2 elem))
-                               (unless (bolp)
-                                 (insert "\n"))
-                               (fill-region start (point-max)))
+                               (let ((start (point)))
+                                 (insert (nth 2 elem))
+                                 (unless (bolp)
+                                   (insert "\n"))
+                                 (fill-region start (point-max))))
                              (buffer-string))))
                       (goto-char start)
                       (dolist (line (split-string text "\n"))
@@ -2740,29 +2765,7 @@ See also `locate-user-emacs-file'.")
   "Determine the boundaries of the default tag, based on text at point.
 Return a cons cell with the beginning and end of the found tag.
 If there is no plausible default, return nil."
-  (let (from to bound)
-    (when (or (progn
-               ;; Look at text around `point'.
-               (save-excursion
-                 (skip-syntax-backward "w_") (setq from (point)))
-               (save-excursion
-                 (skip-syntax-forward "w_") (setq to (point)))
-               (> to from))
-             ;; Look between `line-beginning-position' and `point'.
-             (save-excursion
-               (and (setq bound (line-beginning-position))
-                    (skip-syntax-backward "^w_" bound)
-                    (> (setq to (point)) bound)
-                    (skip-syntax-backward "w_")
-                    (setq from (point))))
-             ;; Look between `point' and `line-end-position'.
-             (save-excursion
-               (and (setq bound (line-end-position))
-                    (skip-syntax-forward "^w_" bound)
-                    (< (setq from (point)) bound)
-                    (skip-syntax-forward "w_")
-                    (setq to (point)))))
-      (cons from to))))
+  (bounds-of-thing-at-point 'symbol))
 
 (defun find-tag-default ()
   "Determine default tag to search for, based on text at point.