[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/mct d0ac8aa 4/8: Avoid setting variables globally, rest

From: ELPA Syncer
Subject: [elpa] externals/mct d0ac8aa 4/8: Avoid setting variables globally, restrict state to the buffers
Date: Tue, 30 Nov 2021 13:57:25 -0500 (EST)

branch: externals/mct
commit d0ac8aa9db6e0de00b8020ef0ff0ef352c61ebcb
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Avoid setting variables globally, restrict state to the buffers
    We restrict the tweaks to the buffers where Mct is active.
    In particular we avoid the introduction of multiple variables
    to retain the original state.
 mct.el | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/mct.el b/mct.el
index a265a59..b5ce826 100644
--- a/mct.el
+++ b/mct.el
@@ -312,6 +312,8 @@ Meant to be added to `after-change-functions'."
 (defun mct--completing-read-advice (&rest app)
       (lambda ()
+        (setq-local resize-mini-windows t
+                    completion-auto-help t)
         (setq mct--active t)
@@ -1028,6 +1030,8 @@ region.")
 (defun mct--setup-completion-list ()
   (when (mct--active-p)
+    (setq-local completion-show-help nil
+                completions-format mct-completions-format)
     ;; TODO use a uniform naming scheme here?
     ;; mct--setup-completions-* or mct--setup-*
     (mct--setup-completions-styles) ;; TODO this name is confusing, because of 
@@ -1041,11 +1045,6 @@ region.")
 (declare-function minibuf-eldef-setup-minibuffer "minibuf-eldef")
-(defvar mct--resize-mini-windows nil)
-(defvar mct--completion-show-help nil)
-(defvar mct--completion-auto-help nil)
-(defvar mct--completions-format nil)
 (define-minor-mode mct-mode
   "Set up opinionated default completion UI."
@@ -1053,14 +1052,6 @@ region.")
   :group 'mct
   (if mct-mode
-        (setq mct--resize-mini-windows resize-mini-windows
-              mct--completion-show-help completion-show-help
-              mct--completion-auto-help completion-auto-help
-              mct--completions-format completions-format)
-        (setq resize-mini-windows t
-              completion-show-help nil
-              completion-auto-help t
-              completions-format mct-completions-format)
         (add-hook 'completion-list-mode-hook #'mct--setup-completion-list)
         (add-hook 'completion-setup-hook #'mct--clean-completions)
         (dolist (fn '(exit-minibuffer
@@ -1074,10 +1065,6 @@ region.")
         (advice-add #'completing-read-multiple :filter-args 
         (advice-add #'minibuffer-message :around #'mct--honor-inhibit-message)
         (advice-add #'minibuf-eldef-setup-minibuffer :around 
-    (setq resize-mini-windows mct--resize-mini-windows
-          completion-show-help mct--completion-show-help
-          completion-auto-help mct--completion-auto-help
-          completions-format mct--completions-format)
     (remove-hook 'completion-list-mode-hook #'mct--setup-completion-list)
     (remove-hook 'completion-setup-hook #'mct--clean-completions)
     (dolist (fn '(exit-minibuffer

reply via email to

[Prev in Thread] Current Thread [Next in Thread]