[Top][All Lists]

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

[elpa] externals/mct 6db7f29 36/70: Rewrite mct-edit-completion for grea

From: ELPA Syncer
Subject: [elpa] externals/mct 6db7f29 36/70: Rewrite mct-edit-completion for greater accuracy
Date: Thu, 11 Nov 2021 03:57:47 -0500 (EST)

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

    Rewrite mct-edit-completion for greater accuracy
 mct.el | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/mct.el b/mct.el
index 64994bd..0ff6c30 100644
--- a/mct.el
+++ b/mct.el
@@ -664,23 +664,39 @@ Otherwise behave like `mct-choose-completion-exit'."
         (let ((inhibit-message t))
+(defun mct--completion-string (point)
+  "Get completion string at POINT."
+  (get-text-property point 'completion--string))
 (defun mct-edit-completion ()
-  "Edit the candidate from the Completions in the minibuffer."
+  "Edit the current completion candidate inside the minibuffer.
+The current candidate is the one at point while inside the
+Completions' buffer.
+When point is in the minibuffer, the current candidate is
+determined as follows:
++ The one at the last known position in the Completions'
+  window (if the window is deleted and produced again, this value
+  is reset).
++ The first candidate in the Completions' buffer.
+A candidate is recognised for as long as point is not past its
+last character."
   (interactive nil mct-mode)
   (let (string)
-    ;; BUG 2021-07-26: When we use `mct-list-completions-toggle'
-    ;; the first line is active even without switching to the
-    ;; Completions' buffer, so the user would expect that this command
-    ;; would capture the candidate at that point.  It does not.
-    ;;
-    ;; If we focus the Completions' buffer at least once, then
-    ;; everything works as expected.
     (when (or (and (minibufferp)
               (and (derived-mode-p 'completion-list-mode)
-      (with-current-buffer (window-buffer (mct--get-completion-window))
-        (setq string (get-text-property (point) 'completion--string)))
+      (let ((window (mct--get-completion-window)))
+        (with-current-buffer (window-buffer window)
+          (when-let ((old-point (window-old-point window)))
+            (if (= old-point (point-min))
+                (setq string (mct--completion-string 
+              (setq string (mct--completion-string old-point))))))
       (if string
             (select-window (active-minibuffer-window) nil)

reply via email to

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