emacs-diffs
[Top][All Lists]
Advanced

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

scratch/icomplete-vertical-mode-improvements 24ddc91 07/10: Rename icomp


From: João Távora
Subject: scratch/icomplete-vertical-mode-improvements 24ddc91 07/10: Rename icomplete-rotate to icomplete-scroll, for clarity
Date: Fri, 28 May 2021 06:10:06 -0400 (EDT)

branch: scratch/icomplete-vertical-mode-improvements
commit 24ddc9185af4e4b268fdc434a8b407115bb9443c
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Rename icomplete-rotate to icomplete-scroll, for clarity
    
    * lisp/icomplete.el (icomplete-rotate): Remove.
    (icomplete-scroll): New.
    (icomplete-forward-completions)
    (icomplete-backward-completions)
    (icomplete--render-vertical):  Use icomplete-scroll.
    (icomplete--fido-mode-setup): Set icomplete-scroll
    (icomplete-completions): Use icomplete-scroll.
---
 lisp/icomplete.el | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 8357d8f..61129eb 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -146,8 +146,8 @@ icompletion is occurring."
   :type 'hook
   :group 'icomplete)
 
-(defvar icomplete-rotate t
-  "If non-nil, cycle around from last completion to first.")
+(defvar icomplete-scroll nil
+  "If non-nil, scroll candidates list instead of rotating it.")
 
 ;;;_* Initialization
 
@@ -223,8 +223,8 @@ the default otherwise."
   ;; We're not at all interested in cycling here (bug#34077).
   (minibuffer-force-complete nil nil 'dont-cycle))
 
-;; Both these variables are only meaningful if `icomplete-rotate' is
-;; nil.
+;; Both these variables are only meaningful if `icomplete-scroll' is
+;; non-nil.
 (defvar icomplete--comp-predecessors nil
   "Completions to list before the selected one.")
 (defvar icomplete--last-selected nil
@@ -240,12 +240,12 @@ Second entry becomes the first and can be selected with
          (comps (completion-all-sorted-completions beg end))
          (last (last comps)))
     (when (consp (cdr comps))
-      (cond (icomplete-rotate
-             (setcdr (last comps) (cons (pop comps) (cdr last))))
-            (t
+      (cond (icomplete-scroll
              (push (pop comps) icomplete--comp-predecessors)
              (setq icomplete--last-selected
-                   (cons (car comps) (buffer-modified-tick)))))
+                   (cons (car comps) (buffer-modified-tick))))
+            (t
+             (setcdr (last comps) (cons (pop comps) (cdr last)))))
       (completion--cache-all-sorted-completions beg end comps))))
 
 (defun icomplete-backward-completions ()
@@ -257,15 +257,15 @@ Last entry becomes the first and can be selected with
          (end (icomplete--field-end))
          (comps (completion-all-sorted-completions beg end))
         last-but-one)
-    (cond ((and icomplete-rotate
+    (cond ((and icomplete-scroll icomplete--comp-predecessors)
+           (push (pop icomplete--comp-predecessors) comps)
+           (setq icomplete--last-selected
+                 (cons (car comps) (buffer-modified-tick))))
+          ((and (not icomplete-scroll)
                 (consp (cdr (setq last-but-one (last comps 2)))))
            ;; At least two elements in comps
            (push (car (cdr last-but-one)) comps)
-           (setcdr last-but-one (cdr (cdr last-but-one))))
-          (icomplete--comp-predecessors
-           (push (pop icomplete--comp-predecessors) comps)
-           (setq icomplete--last-selected
-                 (cons (car comps) (buffer-modified-tick)))))
+           (setcdr last-but-one (cdr (cdr last-but-one)))))
     (completion--cache-all-sorted-completions beg end comps)))
 
 ;;; Helpers for `fido-mode' (or `ido-mode' emulation)
@@ -376,7 +376,7 @@ if that doesn't produce a completion match."
     (setq-local icomplete-tidy-shadowed-file-names t
                 icomplete-show-matches-on-no-input t
                 icomplete-hide-common-prefix nil
-                icomplete-rotate (null icomplete-vertical-mode)
+                icomplete-scroll (not (null icomplete-vertical-mode))
                 completion-styles '(flex)
                 completion-flex-nospace nil
                 completion-category-defaults nil
@@ -701,7 +701,7 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
   ;; This is loopapalooza
   ;;
   ;; First, attempt to keep selection stable.  Do this only if
-  ;; rotation is off and there is a selection.
+  ;; `icomplete-scroll' is t and there is a selection.
   ;;
   ;; Most importantly, also only do this if the buffer changed,
   ;; meaning there are new candidates within which we want to search
@@ -709,9 +709,9 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
   ;; needlessly search for our selection in unchanged candidates, we'd
   ;; obviously always find it in the first position, lose the illusion
   ;; of a dropdown scroll.
-  (when (and icomplete--last-selected
-             (not (eq (cdr icomplete--last-selected) (buffer-modified-tick)))
-             (null icomplete-rotate))
+  (when (and icomplete-scroll
+             icomplete--last-selected
+             (not (eq (cdr icomplete--last-selected) (buffer-modified-tick))))
     (cl-loop
      with preds
      for (comp . rest) on comps
@@ -730,7 +730,7 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
   ;; selected one, considering scrolling positions.
   ;;
   (cl-loop
-   with preds = (and (null icomplete-rotate) icomplete--comp-predecessors)
+   with preds = icomplete--comp-predecessors
    with succs = (cdr comps)
    with max-lines = (1- (min icomplete-prospects-height
                              (max-mini-window-height)))
@@ -869,7 +869,7 @@ matches exist."
                     (length prefix))) ;;)
               prospects comp limit)
          (prog1
-             (if (or (eq most-try t) (and icomplete-rotate
+             (if (or (eq most-try t) (and (not icomplete-scroll)
                                           (not (consp (cdr comps)))))
                  (concat determ " [Matched]")
                (when (member name comps)



reply via email to

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