emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/mct 935a190 3/4: Remove completion-in-region field func


From: ELPA Syncer
Subject: [elpa] externals/mct 935a190 3/4: Remove completion-in-region field functions
Date: Mon, 29 Nov 2021 02:57:28 -0500 (EST)

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

    Remove completion-in-region field functions
    
    Currently mct targets minibuffer completion (completing-read), therefore I
    propose to remove the completion-in-region related functions.
    
    You may want to add completion-in-region support to mct at some point later,
    such that you complete in region similar to in the minibuffer. Other
    completion-in-region packages should be disabled then, e.g., Corfu and
    consult-completion-in-region.
    
    Alternatively a separate mct-like completion-in-region package could be a 
good
    idea, let's say "prc" (Prot's region completion). From my experience with 
Corfu,
    it seems good to separate minibuffer and region completion, since they have
    different requirements and you may want to tune them separately. In 
particular
    users may want to combine different minibuffer and region completion 
packages,
    e.g., Mct/Vertico/Icomplete + Corfu/consult-completion-in-region. On the 
other
    hand the default completion system conflates the two.
---
 mct.el | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/mct.el b/mct.el
index 15881a6..a40e9ba 100644
--- a/mct.el
+++ b/mct.el
@@ -182,27 +182,17 @@ NOTE that setting this option with `setq' requires a 
restart of
 
 ;;;; Completion metadata
 
-(defun mct--minibuffer-field-beg ()
-  "Determine beginning of completion in the minibuffer."
-  (if-let ((window (active-minibuffer-window)))
-      (with-current-buffer (window-buffer window)
-        (minibuffer-prompt-end))
-    (nth 0 completion-in-region--data)))
-
-(defun mct--minibuffer-field-end ()
-  "Determine end of completion in the minibuffer."
-  (if-let ((window (active-minibuffer-window)))
-      (with-current-buffer (window-buffer window)
-        (point-max))
-    (nth 1 completion-in-region--data)))
-
 (defun mct--completion-category ()
   "Return completion category."
   (when-let ((window (active-minibuffer-window)))
     (with-current-buffer (window-buffer window)
-      (let* ((beg (mct--minibuffer-field-beg))
-             (md (completion--field-metadata beg)))
-        (alist-get 'category (cdr md))))))
+      (completion-metadata-get
+       (completion-metadata (buffer-substring-no-properties
+                             (minibuffer-prompt-end)
+                             (max (minibuffer-prompt-end) (point)))
+                            minibuffer-completion-table
+                            minibuffer-completion-predicate)
+       'category))))
 
 ;;;; Basics of intersection between minibuffer and Completions' buffer
 
@@ -454,7 +444,7 @@ by `mct-completion-windows-regexp'."
    ((and (eq (char-before) ?/)
          (eq (mct--completion-category) 'file))
     (when (string-equal (minibuffer-contents) "~/")
-      (delete-region (mct--minibuffer-field-beg) (mct--minibuffer-field-end))
+      (delete-minibuffer-contents)
       (insert (expand-file-name "~/"))
       (goto-char (line-end-position)))
     (save-excursion
@@ -899,7 +889,7 @@ ARGS."
            (eq (mct--completion-category) 'file)
            rfn-eshadow-overlay (overlay-buffer rfn-eshadow-overlay)
            (eq this-command 'self-insert-command)
-           (= saved-point (mct--minibuffer-field-end))
+           (= saved-point (point-max))
            (or (>= (- (point) (overlay-end rfn-eshadow-overlay)) 2)
                (eq ?/ (char-before (- (point) 2)))))
       (delete-region (overlay-start rfn-eshadow-overlay)



reply via email to

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