From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Backward completions (was: Vertical completions) Date: Wed, 18 Nov 2009 11:47:12 +0200 Organization: JURTA Message-ID: <87tywsz9lb.fsf_-_@mail.jurta.org> References: <61C01A08-8FB6-4908-B9F1-B9F1CE3E3D92@gmail.com> <20091111212658.GD12012@headley> <87fx8kjosa.fsf_-_@mail.jurta.org> <7b501d5c0911120209x7c8f493fm68fadef6f1311206@mail.gmail.com> <87bpj16pkh.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1258539506 18792 80.91.229.12 (18 Nov 2009 10:18:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 18 Nov 2009 10:18:26 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 18 11:18:19 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NAhcB-0004SA-9P for ged-emacs-devel@m.gmane.org; Wed, 18 Nov 2009 11:18:19 +0100 Original-Received: from localhost ([127.0.0.1]:51379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAhcA-0005Jb-83 for ged-emacs-devel@m.gmane.org; Wed, 18 Nov 2009 05:18:18 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NAhbx-0005Fz-O7 for emacs-devel@gnu.org; Wed, 18 Nov 2009 05:18:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NAhbs-0005Cx-AC for emacs-devel@gnu.org; Wed, 18 Nov 2009 05:18:04 -0500 Original-Received: from [199.232.76.173] (port=37375 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAhbr-0005Cd-TM for emacs-devel@gnu.org; Wed, 18 Nov 2009 05:18:00 -0500 Original-Received: from smtp-out3.starman.ee ([85.253.0.5]:58011 helo=mx1.starman.ee) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NAhbq-00013P-TI for emacs-devel@gnu.org; Wed, 18 Nov 2009 05:17:59 -0500 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.31.20.cable.starman.ee [82.131.31.20]) by mx1.starman.ee (Postfix) with ESMTP id 9C7453F4117 for ; Wed, 18 Nov 2009 12:17:52 +0200 (EET) In-Reply-To: <87bpj16pkh.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 17 Nov 2009 19:45:54 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:117163 Archived-At: >>> 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 key is convenient to find a desirable item in a long list. However, typing the 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 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/