[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/icomplete-vertical-mode-improvements f7b22c0 08/10: Simplify ico
From: |
João Távora |
Subject: |
scratch/icomplete-vertical-mode-improvements f7b22c0 08/10: Simplify icomplete-vertical-mode scrolling implementation |
Date: |
Fri, 28 May 2021 06:10:06 -0400 (EDT) |
branch: scratch/icomplete-vertical-mode-improvements
commit f7b22c08f81b768a552ae4b3a82a35fb0a777c15
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Simplify icomplete-vertical-mode scrolling implementation
* lisp/icomplete.el:
(icomplete--last-selected, icomplete--comp-predecessors): Remove.
(icomplete--scrolled-past, icomplete--scrolled-completions): New variables.
(icomplete-forward-completions)
(icomplete-backward-completions)
(icomplete-minibuffer-setup): Simplify.
(icomplete-exhibit): Use new variable name.
(icomplete--render-vertical): Simplify.
---
lisp/icomplete.el | 44 +++++++++++++++++++++-----------------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 61129eb..b8ebb74 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -224,11 +224,13 @@ the default otherwise."
(minibuffer-force-complete nil nil 'dont-cycle))
;; 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
- "Last completion explicitly selected.")
+;; non-nil. We implement within classic rotating, non-scrolling
+;; icomplete by rotationg two lists (classic icomplete rotates only
+;; one list)
+(defvar icomplete--scrolled-past nil
+ "Completions manually scrolled past.")
+(defvar icomplete--scrolled-completions nil
+ "Completions manually scrolled to.")
(defun icomplete-forward-completions ()
"Step forward completions by one entry.
@@ -241,9 +243,8 @@ Second entry becomes the first and can be selected with
(last (last comps)))
(when (consp (cdr comps))
(cond (icomplete-scroll
- (push (pop comps) icomplete--comp-predecessors)
- (setq icomplete--last-selected
- (cons (car comps) (buffer-modified-tick))))
+ (push (pop comps) icomplete--scrolled-past)
+ (setq icomplete--scrolled-completions comps))
(t
(setcdr (last comps) (cons (pop comps) (cdr last)))))
(completion--cache-all-sorted-completions beg end comps))))
@@ -257,10 +258,9 @@ 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-scroll icomplete--comp-predecessors)
- (push (pop icomplete--comp-predecessors) comps)
- (setq icomplete--last-selected
- (cons (car comps) (buffer-modified-tick))))
+ (cond ((and icomplete-scroll icomplete--scrolled-past)
+ (push (pop icomplete--scrolled-past) comps)
+ (setq icomplete--scrolled-completions comps))
((and (not icomplete-scroll)
(consp (cdr (setq last-but-one (last comps 2)))))
;; At least two elements in comps
@@ -475,7 +475,7 @@ Usually run by inclusion in `minibuffer-setup-hook'."
(when (and icomplete-mode (icomplete-simple-completing-p))
(setq-local icomplete--initial-input (icomplete--field-string))
(setq-local completion-show-inline-help nil)
- (setq icomplete--last-selected nil)
+ (setq icomplete--scrolled-completions nil)
(use-local-map (make-composed-keymap icomplete-minibuffer-map
(current-local-map)))
(add-hook 'pre-command-hook #'icomplete-pre-command-hook nil t)
@@ -642,7 +642,7 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
(when (and icomplete-mode
(icomplete-simple-completing-p)) ;Shouldn't be necessary.
(unless completion-all-sorted-completions
- (setq icomplete--comp-predecessors nil))
+ (setq icomplete--scrolled-past nil))
(let ((saved-point (point)))
(save-excursion
(goto-char (point-max))
@@ -703,21 +703,19 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
;; First, attempt to keep selection stable. Do this only if
;; `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
- ;; for our manually selected one. That's because if we were to
+ ;; Most importantly, also only if the new completions list doesn't
+ ;; match out manually scrolled list. That's because if we were to
;; 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-scroll
- icomplete--last-selected
- (not (eq (cdr icomplete--last-selected) (buffer-modified-tick))))
+ (not (eq icomplete--scrolled-completions comps)))
(cl-loop
with preds
for (comp . rest) on comps
- when (equal comp (car icomplete--last-selected))
+ when (equal comp (car icomplete--scrolled-completions))
do
- (setq icomplete--comp-predecessors preds
+ (setq icomplete--scrolled-past preds
comps (cons comp rest))
(completion--cache-all-sorted-completions
(icomplete--field-beg)
@@ -725,12 +723,12 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
comps)
and return nil
do (push comp preds)
- finally (setq icomplete--last-selected nil)))
+ finally (setq icomplete--scrolled-completions nil)))
;; The ugliest loop, collect the completions before and after the
;; selected one, considering scrolling positions.
;;
(cl-loop
- with preds = icomplete--comp-predecessors
+ with preds = icomplete--scrolled-past
with succs = (cdr comps)
with max-lines = (1- (min icomplete-prospects-height
(max-mini-window-height)))
- branch scratch/icomplete-vertical-mode-improvements created (now 0337e73), João Távora, 2021/05/28
- scratch/icomplete-vertical-mode-improvements d3b85d0 04/10: * lisp/icomplete.el (icomplete--render-vertical): Simplify slightly., João Távora, 2021/05/28
- scratch/icomplete-vertical-mode-improvements 136f71b 02/10: Distinguish fido-mode from icomplete-mode verticality, João Távora, 2021/05/28
- scratch/icomplete-vertical-mode-improvements 82f8a3d 03/10: Fix an edge case bug in icomplete.el where base-size wasn't restored, João Távora, 2021/05/28
- scratch/icomplete-vertical-mode-improvements 776633a 01/10: Improve icomplete-vertical-mode, João Távora, 2021/05/28
- scratch/icomplete-vertical-mode-improvements f751980 05/10: Don't break icomplete-vertical-mode scrolling when moving non-destructively, João Távora, 2021/05/28
- scratch/icomplete-vertical-mode-improvements 24ddc91 07/10: Rename icomplete-rotate to icomplete-scroll, for clarity, João Távora, 2021/05/28
- scratch/icomplete-vertical-mode-improvements 94368e2 06/10: Adjust scrolling behaviour of icomplete-vertical-mode, João Távora, 2021/05/28
- scratch/icomplete-vertical-mode-improvements f7b22c0 08/10: Simplify icomplete-vertical-mode scrolling implementation,
João Távora <=
- scratch/icomplete-vertical-mode-improvements 0337e73 10/10: Add annotation capability to icomplete-vertical-mode, João Távora, 2021/05/28
- scratch/icomplete-vertical-mode-improvements 37f0362 09/10: Update NEWS, João Távora, 2021/05/28