(read-char-from-minibuffer): Allow use of `quoted-insert` (bug#65805)
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 12 Sep 2023 16:55:54 +0000 (12:55 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 12 Sep 2023 16:55:54 +0000 (12:55 -0400)
* lisp/subr.el (read-char-from-minibuffer-map): No need to remap
`self-insert-command` any more.
(read-char-from-minibuffer): Use `post-command-hook` to exit as soon as
a char is provided.

lisp/subr.el

index 6cedaffa80637d2b135a5e3eb7c63d3017b2abbb..3fad9d36b3ee6c02614a0a2a9b26ee0dff2d44c3 100644 (file)
@@ -993,11 +993,11 @@ SEQ must be a list, vector, or string.  The comparison is done with `equal'.
 Contrary to `delete', this does not use side-effects, and the argument
 SEQ is not modified."
   (declare (side-effect-free t))
-  (if (nlistp seq)
-      ;; If SEQ isn't a list, there's no need to copy SEQ because
-      ;; `delete' will return a new object.
-      (delete elt seq)
-    (delete elt (copy-sequence seq))))
+  (delete elt (if (nlistp seq)
+                  ;; If SEQ isn't a list, there's no need to copy SEQ because
+                  ;; `delete' will return a new object.
+                  seq
+                (copy-sequence seq))))
 
 (defun remq (elt list)
   "Return LIST with all occurrences of ELT removed.
@@ -3499,7 +3499,7 @@ If there is a natural number at point, use it as default."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
 
-    (define-key map [remap self-insert-command] #'read-char-from-minibuffer-insert-char)
+    ;; (define-key map [remap self-insert-command] #'read-char-from-minibuffer-insert-char)
     (define-key map [remap exit-minibuffer] #'read-char-from-minibuffer-insert-other)
 
     (define-key map [remap recenter-top-bottom] #'minibuffer-recenter-top-bottom)
@@ -3530,7 +3530,7 @@ allowed to type into the minibuffer.  When the user types any
 such key, this command discard all minibuffer input and displays
 an error message."
   (interactive)
-  (when (minibufferp)
+  (when (minibufferp) ;;FIXME: Why?
     (delete-minibuffer-contents)
     (ding)
     (discard-input)
@@ -3578,6 +3578,10 @@ There is no need to explicitly add `help-char' to CHARS;
                                         (interactive)
                                         (let ((help-form msg)) ; lexically bound msg
                                           (help-form-show)))))
+                        ;; FIXME: We use `read-char-from-minibuffer-insert-char'
+                        ;; here only as a kind of alias of `self-insert-command'
+                        ;; to prevent those keys from being remapped to
+                        ;; `read-char-from-minibuffer-insert-other'.
                         (dolist (char chars)
                           (define-key map (vector char)
                                       #'read-char-from-minibuffer-insert-char))
@@ -3589,7 +3593,15 @@ There is no need to explicitly add `help-char' to CHARS;
                 read-char-from-minibuffer-map))
          ;; Protect this-command when called from pre-command-hook (bug#45029)
          (this-command this-command)
-         (result (progn
+         (result (minibuffer-with-setup-hook
+                    (lambda ()
+                      (add-hook 'post-command-hook
+                                (lambda ()
+                                  ;; FIXME: Should we use `<='?
+                                  (if (= (1+ (minibuffer-prompt-end))
+                                         (point-max))
+                                       (exit-minibuffer)))
+                                nil 'local))
                    ;; Disable text conversion if it is enabled.
                    ;; (bug#65370)
                    (when (fboundp 'set-text-conversion-style)
@@ -5754,8 +5766,8 @@ Return nil if there isn't one."
         (load-elt (and loads (car loads))))
     (save-match-data
       (while (and loads
-                 (or (null (car load-elt))
-                     (not (string-match file-regexp (car load-elt)))))
+                 (not (and (car load-elt)
+                            (string-match file-regexp (car load-elt)))))
        (setq loads (cdr loads)
              load-elt (and loads (car loads)))))
     load-elt))
@@ -6328,7 +6340,7 @@ command is called from a keyboard macro?"
              ;; Skip special forms (from non-compiled code).
              (and frame (null (car frame)))
              ;; Skip also `interactive-p' (because we don't want to know if
-             ;; interactive-p was called interactively but if it's caller was).
+             ;; interactive-p was called interactively but if its caller was).
              (eq (nth 1 frame) 'interactive-p)
              ;; Skip package-specific stack-frames.
              (let ((skip (run-hook-with-args-until-success
@@ -6573,7 +6585,6 @@ effectively rounded up."
   (unless min-time
     (setq min-time 0.2))
   (let ((reporter
-        ;; Force a call to `message' now
         (cons (or min-value 0)
               (vector (if (>= min-time 0.02)
                           (float-time) nil)
@@ -6584,6 +6595,7 @@ effectively rounded up."
                        min-time
                        ;; SUFFIX
                        nil))))
+    ;; Force a call to `message' now.
     (progress-reporter-update reporter (or current-value min-value))
     reporter))