(defun icomplete-forward-completions ()
"Step forward completions by one entry.
Second entry becomes the first and can be selected with
-`icomplete-force-complete-and-exit'."
+`icomplete-force-complete-and-exit'.
+Return non-nil iff something was stepped."
(interactive)
(let* ((beg (icomplete--field-beg))
(end (icomplete--field-end))
(defun icomplete-backward-completions ()
"Step backward completions by one entry.
Last entry becomes the first and can be selected with
-`icomplete-force-complete-and-exit'."
+`icomplete-force-complete-and-exit'.
+Return non-nil iff something was stepped."
(interactive)
(let* ((beg (icomplete--field-beg))
(end (icomplete--field-end))
(comps (completion-all-sorted-completions beg end))
- last-but-one)
- (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
- (push (car (cdr last-but-one)) comps)
- (setcdr last-but-one (cdr (cdr last-but-one)))))
- (completion--cache-all-sorted-completions beg end comps)))
+ last-but-one)
+ (prog1
+ (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
+ (push (car (cdr last-but-one)) comps)
+ (setcdr last-but-one (cdr (cdr last-but-one)))))
+ (completion--cache-all-sorted-completions beg end comps))))
+
+(defun icomplete-vertical-goto-first ()
+ "Go to first completions entry when `icomplete-scroll' is non-nil."
+ (interactive)
+ (unless icomplete-scroll (error "Only works with `icomplete-scroll'"))
+ (while (icomplete-backward-completions)))
+
+(defun icomplete-vertical-goto-last ()
+ "Go to last completions entry when `icomplete-scroll' is non-nil."
+ (interactive)
+ (unless icomplete-scroll (error "Only works with `icomplete-scroll'"))
+ (while (icomplete-forward-completions)))
;;;_* Helpers for `fido-mode' (or `ido-mode' emulation)
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-n") 'icomplete-forward-completions)
(define-key map (kbd "C-p") 'icomplete-backward-completions)
+ (define-key map (kbd "M-<") 'icomplete-vertical-goto-first)
+ (define-key map (kbd "M->") 'icomplete-vertical-goto-last)
map)
"Keymap used by `icomplete-vertical-mode' in the minibuffer.")