From 7fc38f2a66f5545c276836d62a7e3a8669c3eb10 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Thu, 15 Apr 2021 22:27:08 +0000 Subject: [PATCH] Make it possible to disable icomplete-mode in recursive minibuffers * lisp/icomplete.el (minibuffer-disable-icomplete-mode): New internal variable. (icomplete-minibuffer-setup): Disable icomplete-mode when minibuffer-disable-icomplete-mode is non-nil * lisp/subr.el (read-number, read-char-from-minibuffer, y-or-n-p): Use it. * lisp/simple.el (read--expression): Use it. --- lisp/icomplete.el | 5 +++++ lisp/simple.el | 3 +++ lisp/subr.el | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index d5b6f76d7b..551b8bdc4a 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -442,10 +442,15 @@ icomplete-simple-completing-p (eq icomplete-with-completion-tables t) (member table icomplete-with-completion-tables)))))) +(defvar minibuffer-disable-icomplete-mode nil) + ;;;_ > icomplete-minibuffer-setup () (defun icomplete-minibuffer-setup () "Run in minibuffer on activation to establish incremental completion. Usually run by inclusion in `minibuffer-setup-hook'." + (when minibuffer-disable-icomplete-mode + (setq-local icomplete-mode nil) + (setq minibuffer-disable-icomplete-mode nil)) (when (and icomplete-mode (icomplete-simple-completing-p)) (setq-local icomplete--initial-input (icomplete--field-string)) (setq-local completion-show-inline-help nil) diff --git a/lisp/simple.el b/lisp/simple.el index 999755a642..9626b3605f 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1739,6 +1739,8 @@ eval-expression-print-format (defvar eval-expression-minibuffer-setup-hook nil "Hook run by `eval-expression' when entering the minibuffer.") +(defvar minibuffer-disable-icomplete-mode) + (defun read--expression (prompt &optional initial-contents) "Read an Emacs Lisp expression from the minibuffer. @@ -1755,6 +1757,7 @@ read--expression (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil t) (run-hooks 'eval-expression-minibuffer-setup-hook)) + (setq minibuffer-disable-icomplete-mode t) (read-from-minibuffer prompt initial-contents read-expression-map t 'read-expression-history)))) diff --git a/lisp/subr.el b/lisp/subr.el index c2be26a15f..bc25fe234f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2794,6 +2794,8 @@ read-passwd (defvar read-number-history nil "The default history for the `read-number' function.") +(defvar minibuffer-disable-icomplete-mode) + (defun read-number (prompt &optional default hist) "Read a numeric value in the minibuffer, prompting with PROMPT. DEFAULT specifies a default value to return if the user just types RET. @@ -2812,6 +2814,7 @@ read-number prompt t t)))) (while (progn + (setq minibuffer-disable-icomplete-mode t) (let ((str (read-from-minibuffer prompt nil nil nil (or hist 'read-number-history) (when default @@ -3052,8 +3055,10 @@ read-char-from-minibuffer ;; Protect this-command when called from pre-command-hook (bug#45029) (this-command this-command) (result - (read-from-minibuffer prompt nil map nil - (or history 'empty-history))) + (progn + (setq minibuffer-disable-icomplete-mode t) + (read-from-minibuffer prompt nil map nil + (or history 'empty-history)))) (char (if (> (length result) 0) ;; We have a string (with one character), so return the first one. @@ -3247,9 +3252,11 @@ y-or-n-p 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 'empty-history)))) + (str (progn + (setq minibuffer-disable-icomplete-mode t) + (read-from-minibuffer + prompt nil keymap nil + (or y-or-n-p-history-variable 'empty-history))))) (setq answer (if (member str '("y" "Y")) 'act 'skip))))) (let ((ret (eq answer 'act))) (unless noninteractive -- 2.30.2