[Top][All Lists]

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

[elpa] externals/mct a5c4ba3 7/8: Do not affect completions-format globa

From: ELPA Syncer
Subject: [elpa] externals/mct a5c4ba3 7/8: Do not affect completions-format global state
Date: Tue, 30 Nov 2021 13:57:26 -0500 (EST)

branch: externals/mct
commit a5c4ba36da4c146b4a2feece902fc8170961e94e
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Do not affect completions-format global state
    Thanks to Daniel Mendler for the contributions that make this possible,
    including the following patches:
    c77fb3f 2021-11-30 Move mct--clean-completions to mct--setup-completion-list
    d0ac8aa 2021-11-30 Avoid setting variables globally, restrict state to the 
    6b19465 2021-11-30 Unify completion list setup into a single function
    1cee8df 2021-11-30 Rename mct--setup-completions to 
    799041d 2021-11-30 Introduce mct--active variable, use advice for 
minibuffer setup
    The upside of this change is that mct-completions-format can now be set
    with 'setq' without the exception it had before of requiring a restart
    of mct-mode.
 README.org |  3 ---
 mct.el     | 21 +++++++++------------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/README.org b/README.org
index 55a8a1d..e99fec9 100644
--- a/README.org
+++ b/README.org
@@ -408,9 +408,6 @@ And with more options:
 (setq mct-apply-completion-stripes t)
 (setq mct-minimum-input 3)
 (setq mct-live-update-delay 0.6)
-;; NOTE: setting this variable with `setq', requires `mct-mode' to be
-;; reloaded.
 (setq mct-completions-format 'one-column)
 ;; NOTE: `mct-completion-blocklist' can be used for commands with lots
diff --git a/mct.el b/mct.el
index a809366..72623bb 100644
--- a/mct.el
+++ b/mct.el
@@ -169,14 +169,7 @@ and/or the documentation string of `display-buffer'."
 (defcustom mct-completions-format 'one-column
   "The appearance and sorting used by `mct-mode'.
-See `completions-format' for possible values.
-NOTE that setting this option with `setq' requires a restart of
-  :set (lambda (var val)
-         (when (bound-and-true-p mct-mode)
-           (setq completions-format val))
-         (set var val))
+See `completions-format' for possible values."
   :type '(choice (const horizontal) (const vertical) (const one-column))
   :group 'mct)
@@ -308,6 +301,10 @@ Meant to be added to `after-change-functions'."
               (buf (window-buffer win)))
       (buffer-local-value 'mct--active buf)))
+(defun mct--display-completion-list-advice (&rest app)
+  (let ((completions-format mct-completions-format))
+    (apply app)))
 (defun mct--completing-read-advice (&rest app)
       (lambda ()
@@ -384,8 +381,7 @@ Meant to be added to `after-change-functions'."
 ;; We need this to make things work on Emacs 27.
 (defun mct--one-column-p ()
   "Test if we have a one-column view available."
-  (and (eq completions-format 'one-column)
-       (eq mct-completions-format 'one-column)
+  (and (eq mct-completions-format 'one-column)
        (>= emacs-major-version 28)))
 ;;;;; Focus minibuffer and/or show completions
@@ -1029,8 +1025,7 @@ region.")
 (defun mct--setup-completion-list ()
   (when (mct--active-p)
-    (setq-local completion-show-help nil
-                completions-format mct-completions-format)
+    (setq-local completion-show-help nil)
@@ -1060,6 +1055,7 @@ region.")
         (advice-add #'completing-read-default :around 
         (advice-add #'completing-read-multiple :around 
         (advice-add #'completing-read-multiple :filter-args 
+        (advice-add #'display-completion-list :around 
         (advice-add #'minibuffer-message :around #'mct--honor-inhibit-message)
         (advice-add #'minibuf-eldef-setup-minibuffer :around 
     (remove-hook 'completion-list-mode-hook #'mct--setup-completion-list)
@@ -1072,6 +1068,7 @@ region.")
     (advice-remove #'completing-read-default #'mct--completing-read-advice)
     (advice-remove #'completing-read-multiple #'mct--completing-read-advice)
     (advice-remove #'completing-read-multiple #'mct--crm-indicator)
+    (advice-remove #'display-completion-list 
     (advice-remove #'minibuffer-message #'mct--honor-inhibit-message)
     (advice-remove #'minibuf-eldef-setup-minibuffer #'mct--stealthily)))

reply via email to

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