summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el64
1 files changed, 51 insertions, 13 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 03d3324f3d8..d49c9cb155e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1654,7 +1654,13 @@ nil or (STRING . POSITION)'.
`posn-timestamp': The time the event occurred, in milliseconds.
For more information, see Info node `(elisp)Click Events'."
- (or (and (consp event) (nth 1 event))
+ (or (and (consp event)
+ ;; Ignore touchscreen events. They store the posn in a
+ ;; different format, and can have multiple posns.
+ (not (memq (car event) '(touchscreen-begin
+ touchscreen-update
+ touchscreen-end)))
+ (nth 1 event))
(event--posn-at-point)))
(defun event-end (event)
@@ -1662,7 +1668,11 @@ For more information, see Info node `(elisp)Click Events'."
EVENT should be a click, drag, or key press event.
See `event-start' for a description of the value returned."
- (or (and (consp event) (nth (if (consp (nth 2 event)) 2 1) event))
+ (or (and (consp event)
+ (not (memq (car event) '(touchscreen-begin
+ touchscreen-update
+ touchscreen-end)))
+ (nth (if (consp (nth 2 event)) 2 1) event))
(event--posn-at-point)))
(defsubst event-click-count (event)
@@ -3445,6 +3455,9 @@ an error message."
(minibuffer-message "Wrong answer")
(sit-for 2)))
+;; Defined in textconv.c.
+(defvar overriding-text-conversion-style)
+
(defun read-char-from-minibuffer (prompt &optional chars history)
"Read a character from the minibuffer, prompting for it with PROMPT.
Like `read-char', but uses the minibuffer to read and return a character.
@@ -3459,7 +3472,15 @@ while calling this function, then pressing `help-char'
causes it to evaluate `help-form' and display the result.
There is no need to explicitly add `help-char' to CHARS;
`help-char' is bound automatically to `help-form-show'."
- (let* ((map (if (consp chars)
+
+ ;; If text conversion is enabled in this buffer, then it will only
+ ;; be disabled the next time `force-mode-line-update' happens.
+ (when (and (bound-and-true-p overriding-text-conversion-style)
+ (bound-and-true-p text-conversion-style))
+ (force-mode-line-update))
+
+ (let* ((overriding-text-conversion-style nil)
+ (map (if (consp chars)
(or (gethash (list help-form (cons help-char chars))
read-char-from-minibuffer-map-hash)
(let ((map (make-sparse-keymap))
@@ -3471,15 +3492,15 @@ There is no need to explicitly add `help-char' to CHARS;
;; being a command char.
(when help-form
(define-key map (vector help-char)
- (lambda ()
- (interactive)
- (let ((help-form msg)) ; lexically bound msg
- (help-form-show)))))
+ (lambda ()
+ (interactive)
+ (let ((help-form msg)) ; lexically bound msg
+ (help-form-show)))))
(dolist (char chars)
(define-key map (vector char)
- #'read-char-from-minibuffer-insert-char))
+ #'read-char-from-minibuffer-insert-char))
(define-key map [remap self-insert-command]
- #'read-char-from-minibuffer-insert-other)
+ #'read-char-from-minibuffer-insert-other)
(puthash (list help-form (cons help-char chars))
map read-char-from-minibuffer-map-hash)
map))
@@ -3581,10 +3602,15 @@ confusing to some users.")
(defun use-dialog-box-p ()
"Return non-nil if the current command should prompt the user via a dialog box."
(and last-input-event ; not during startup
- (or (consp last-nonmenu-event) ; invoked by a mouse event
+ (or (featurep 'android) ; prefer dialog boxes on Android
+ (consp last-nonmenu-event) ; invoked by a mouse event
from--tty-menu-p) ; invoked via TTY menu
use-dialog-box))
+;; Actually in textconv.c.
+(defvar overriding-text-conversion-style)
+(declare-function set-text-conversion-style "textconv.c")
+
(defun y-or-n-p (prompt)
"Ask user a \"y or n\" question.
Return t if answer is \"y\" and nil if it is \"n\".
@@ -3662,6 +3688,9 @@ like) while `y-or-n-p' is running)."
(while
(let* ((scroll-actions '(recenter scroll-up scroll-down
scroll-other-window scroll-other-window-down))
+ ;; Disable text conversion so that real key events
+ ;; are sent.
+ (overriding-text-conversion-style nil)
(key
(let ((cursor-in-echo-area t))
(when minibuffer-auto-raise
@@ -3693,6 +3722,9 @@ like) while `y-or-n-p' is running)."
(setq prompt (funcall padded prompt))
(let* ((enable-recursive-minibuffers t)
(msg help-form)
+ ;; Disable text conversion so that real Y or N events are
+ ;; sent.
+ (overriding-text-conversion-style nil)
(keymap (let ((map (make-composed-keymap
y-or-n-p-map query-replace-map)))
(when help-form
@@ -3706,9 +3738,15 @@ like) while `y-or-n-p' is running)."
map))
;; Protect this-command when called from pre-command-hook (bug#45029)
(this-command this-command)
- (str (read-from-minibuffer
- prompt nil keymap nil
- (or y-or-n-p-history-variable t))))
+ (str (progn
+ (when (active-minibuffer-window)
+ ;; If the minibuffer is already active, the
+ ;; selected window might not change. Disable
+ ;; text conversion by hand.
+ (set-text-conversion-style text-conversion-style))
+ (read-from-minibuffer
+ prompt nil keymap nil
+ (or y-or-n-p-history-variable t)))))
(setq answer (if (member str '("y" "Y")) 'act 'skip)))))
(let ((ret (eq answer 'act)))
(unless noninteractive