all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: emacs-devel@gnu.org
Subject: Backward completions (was: Vertical completions)
Date: Wed, 18 Nov 2009 11:47:12 +0200	[thread overview]
Message-ID: <87tywsz9lb.fsf_-_@mail.jurta.org> (raw)
In-Reply-To: <87bpj16pkh.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 17 Nov 2009 19:45:54 +0200")

>>> It's easier to skim through a list when completions are sorted
>>> vertically in columns down the screen.
>>
>> If it's not too problematic to implement, I'm all for the change (or
>> rather an option to have it).
>
> Not problematic at all.  Below is a small patch that implements
> a new option for vertical completions with the default to
> traditional horizontal completions, of course.

Scrolling the *Completions* buffer a full screen with the <TAB> key
is convenient to find a desirable item in a long list.

However, typing the <backtab> key doesn't reverse the scrolling
direction like this key does in other places in Emacs.  So to return to
the previous screen requires scrolling to the end of the *Completions*
buffer, wrapping to the beginning and scrolling forward from the
beginning, looking carefully to not miss the previous screen again.

The following patch binds <backtab> to `minibuffer-complete-backward'
that is an alias of `minibuffer-complete'.  But maybe code in
`minibuffer-complete' is so small, so it could be copied to a new
function `minibuffer-complete-backward' (with small modifications)
instead of creating an alias?

Index: lisp/minibuffer.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/minibuffer.el,v
retrieving revision 1.96
diff -c -w -b -r1.96 minibuffer.el
*** lisp/minibuffer.el	12 Nov 2009 23:10:06 -0000	1.96
--- lisp/minibuffer.el	18 Nov 2009 09:45:59 -0000
***************
*** 516,524 ****
  If you repeat this command after it displayed such a list,
  scroll the window of possible completions."
    (interactive)
!   ;; If the previous command was not this,
    ;; mark the completion buffer obsolete.
!   (unless (eq this-command last-command)
      (setq minibuffer-scroll-window nil))
  
    (let ((window minibuffer-scroll-window))
--- 516,528 ----
  If you repeat this command after it displayed such a list,
  scroll the window of possible completions."
    (interactive)
!   ;; If the previous command (or its alias) was not this,
    ;; mark the completion buffer obsolete.
!   (unless (or (eq this-command last-command)
! 	      (and (memq this-command '(minibuffer-complete
! 					minibuffer-complete-backward))
! 		   (memq last-command '(minibuffer-complete
! 					minibuffer-complete-backward))))
      (setq minibuffer-scroll-window nil))
  
    (let ((window minibuffer-scroll-window))
***************
*** 526,536 ****
      ;; and this command is repeated, scroll that window.
      (if (window-live-p window)
          (with-current-buffer (window-buffer window)
            (if (pos-visible-in-window-p (point-max) window)
  	      ;; If end is in view, scroll up to the beginning.
  	      (set-window-start window (point-min) nil)
  	    ;; Else scroll down one screen.
! 	    (scroll-other-window))
  	  nil)
  
        (case (completion--do-completion)
--- 530,550 ----
      ;; and this command is repeated, scroll that window.
      (if (window-live-p window)
          (with-current-buffer (window-buffer window)
+           (if (eq this-command 'minibuffer-complete-backward)
+ 	      ;; Scroll completions backward.
+ 	      (if (pos-visible-in-window-p (point-min) window)
+ 		  ;; If beginning is in view, scroll down to the end.
+ 		  (with-selected-window window
+ 		    (goto-char (point-max))
+ 		    (recenter -1))
+ 		;; Else scroll up one screen.
+ 		(scroll-other-window-down nil))
+ 	    ;; Scroll completions forward.
  	    (if (pos-visible-in-window-p (point-max) window)
  		;; If end is in view, scroll up to the beginning.
  		(set-window-start window (point-min) nil)
  	      ;; Else scroll down one screen.
! 	      (scroll-other-window)))
  	  nil)
  
        (case (completion--do-completion)
***************
*** 541,546 ****
--- 555,568 ----
                 t)
          (t     t)))))
  
+ (defalias 'minibuffer-complete-backward 'minibuffer-complete
+   "Like `minibuffer-complete', but scroll completions backward.
+ If you repeat this command after `minibuffer-complete' or
+ `minibuffer-complete-backward' displayed a list of possible
+ completions, it scrolls the window of possible completions a full
+ screen in the direction opposite to the scrolling direction of
+ `minibuffer-complete'.")
+ 
  (defvar completion-all-sorted-completions nil)
  (make-variable-buffer-local 'completion-all-sorted-completions)

-- 
Juri Linkov
http://www.jurta.org/emacs/




  parent reply	other threads:[~2009-11-18  9:47 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-11 19:45 completions - remove window after use? David Reitter
2009-11-11 20:28 ` Stefan Monnier
2009-11-11 21:26   ` Štěpán Němec
2009-11-11 23:21     ` Stefan Monnier
2009-11-12  9:57       ` Vertical completions (was: completions - remove window after use?) Juri Linkov
2009-11-12 10:09         ` Deniz Dogan
2009-11-17 17:45           ` Vertical completions Juri Linkov
2009-11-18  8:11             ` martin rudalics
2009-11-18  9:59               ` Juri Linkov
2009-11-18  9:47             ` Juri Linkov [this message]
2009-11-18 15:06               ` Backward completions (was: Vertical completions) Drew Adams
2009-11-18 15:47                 ` Lennart Borgman
2009-11-18 19:02                   ` Backward completions Juri Linkov
2009-11-18 19:36                     ` Lennart Borgman
2009-11-19 17:36                       ` Juri Linkov
2009-11-19 17:58                         ` Lennart Borgman
2009-11-19 18:24                         ` Drew Adams
2009-11-20  9:27                           ` Juri Linkov
2009-11-20 17:29                           ` Juri Linkov
2009-11-20 17:49                             ` Lennart Borgman
2009-11-20 21:26                             ` Drew Adams
2009-11-18 15:45               ` Stefan Monnier
2009-11-18 19:01                 ` Juri Linkov
2009-11-18 19:50               ` Backward completions (was: Vertical completions) Dan Nicolaescu
2009-11-19 17:32                 ` Backward completions Juri Linkov
2009-11-19 18:29                   ` Dan Nicolaescu
2009-11-19 18:36                     ` Drew Adams
2009-11-19 19:26                       ` Dan Nicolaescu
2009-11-19 19:30                         ` Drew Adams
2009-11-18  9:52             ` switch-to-completions (was: Vertical completions) Juri Linkov
2009-11-18 15:48               ` switch-to-completions Stefan Monnier
2009-11-18 19:04                 ` switch-to-completions Juri Linkov
2009-11-19  1:12                   ` switch-to-completions Stefan Monnier
2009-11-12 10:29         ` Vertical completions (was: completions - remove window after use?) Štěpán Němec
2009-11-12 19:26         ` Eli Zaretskii
2009-11-12 22:00           ` Lennart Borgman
2009-11-12 13:30       ` completions - remove window after use? Lluís
2009-11-12 14:40         ` David Reitter
2009-11-12 15:15         ` Stefan Monnier
2009-11-14  0:30           ` Richard Stallman
2009-11-12  3:00 ` Xavier Maillard
2009-11-12  8:19 ` martin rudalics
2009-11-12 13:31   ` bug#4914: " David Reitter
2009-11-12 17:40     ` martin rudalics
2009-11-12 17:56       ` David Reitter
2009-11-12 19:26         ` martin rudalics
2009-11-17 23:00           ` Stefan Monnier
2009-11-18  8:11             ` martin rudalics
2009-11-23 13:58             ` David Reitter
2009-11-12 20:22         ` Stefan Monnier
2010-01-17 23:41     ` Chong Yidong
     [not found]       ` <5C420BAC-187B-4B19-BF13-CC1A71745D59@gmail.com>
2010-01-18 17:58         ` David Reitter
2010-01-18 15:09     ` bug#4914: marked as done (completions - remove window after use?) Emacs bug Tracking System
2009-11-12 22:36   ` completions - remove window after use? Xavier Maillard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tywsz9lb.fsf_-_@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.