diff options
author | Miha Rihtaršič <miha@kamnitnik.top> | 2021-11-11 06:16:52 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-11-11 06:16:52 +0100 |
commit | 0a93fb499b8885ffd87338f1ccc9cb5093f567c1 (patch) | |
tree | 338d2c4e903c5f9fe74af3dc0938ede8ac27d178 /lisp/emacs-lisp | |
parent | 396355f46b964d6a63ced9fe48fb6c7fb43d8f06 (diff) | |
download | emacs-0a93fb499b8885ffd87338f1ccc9cb5093f567c1.tar.gz emacs-0a93fb499b8885ffd87338f1ccc9cb5093f567c1.tar.bz2 emacs-0a93fb499b8885ffd87338f1ccc9cb5093f567c1.zip |
Set `minibuffer-completion-*` variables locally in more places
* lisp/calc/calc-store.el (calc-read-var-name):
* lisp/emacs-lisp/crm.el (completing-read-multiple):
* lisp/progmodes/cc-styles.el (c-read-offset):
* lisp/window.el (read-buffer-to-switch):
Set `minibuffer-completion-*` variables buffer-locally instead of
using a global let-binding (bug#48925).
Follow-up to commit
2021-05-01 "* lisp/minibuffer.el (completing-read-default): Fix bug#45474"
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/crm.el | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el index d24ea355a51..59cbc0e50d5 100644 --- a/lisp/emacs-lisp/crm.el +++ b/lisp/emacs-lisp/crm.el @@ -244,30 +244,29 @@ contents of the minibuffer are \"alice,bob,eve\" and point is between This function returns a list of the strings that were read, with empty strings removed." - (unwind-protect - (progn - (add-hook 'choose-completion-string-functions - 'crm--choose-completion-string) - (let* ((minibuffer-completion-table #'crm--collection-fn) - (minibuffer-completion-predicate predicate) - ;; see completing_read in src/minibuf.c - (minibuffer-completion-confirm - (unless (eq require-match t) require-match)) - (crm-completion-table table) - (map (if require-match - crm-local-must-match-map - crm-local-completion-map)) - ;; If the user enters empty input, `read-from-minibuffer' - ;; returns the empty string, not DEF. - (input (read-from-minibuffer - prompt initial-input map - nil hist def inherit-input-method))) - (when (and def (string-equal input "")) - (setq input (if (consp def) (car def) def))) - ;; Remove empty strings in the list of read strings. - (split-string input crm-separator t))) - (remove-hook 'choose-completion-string-functions - 'crm--choose-completion-string))) + (let* ((map (if require-match + crm-local-must-match-map + crm-local-completion-map)) + input) + (minibuffer-with-setup-hook + (lambda () + (add-hook 'choose-completion-string-functions + 'crm--choose-completion-string nil 'local) + (setq-local minibuffer-completion-table #'crm--collection-fn) + (setq-local minibuffer-completion-predicate predicate) + ;; see completing_read in src/minibuf.c + (setq-local minibuffer-completion-confirm + (unless (eq require-match t) require-match)) + (setq-local crm-completion-table table)) + (setq input (read-from-minibuffer + prompt initial-input map + nil hist def inherit-input-method))) + ;; If the user enters empty input, `read-from-minibuffer' + ;; returns the empty string, not DEF. + (when (and def (string-equal input "")) + (setq input (if (consp def) (car def) def))) + ;; Remove empty strings in the list of read strings. + (split-string input crm-separator t))) ;; testing and debugging ;; (defun crm-init-test-environ () |