all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Deniz Dogan <deniz.a.m.dogan@gmail.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: Vertical completions
Date: Tue, 17 Nov 2009 19:45:54 +0200	[thread overview]
Message-ID: <87bpj16pkh.fsf@mail.jurta.org> (raw)
In-Reply-To: <7b501d5c0911120209x7c8f493fm68fadef6f1311206@mail.gmail.com> (Deniz Dogan's message of "Thu, 12 Nov 2009 11:09:33 +0100")

>>>> And speaking about *Completions*, would it be possible to fill the
>>>> completions column-first, not row-first as it is now?  I find it quite
>>>> unreasonable, as the display is column-wise, but not so filling, making
>>>> it harder to quickly skim through the list.
>>
>> It's easier to skim through a list when completions are sorted
>> vertically in columns down the screen.
>>
>> That's what `ls' does by default for the list of files unless
>> `-x' (`--format=horizontal') is specified.  As well as readline
>> completions in bash unless `print-completions-horizontally' is `On'.
>
> 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.

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	17 Nov 2009 17:44:46 -0000
***************
*** 778,783 ****
--- 778,793 ----
  (defface completions-annotations '((t :inherit italic))
    "Face to use for annotations in the *Completions* buffer.")
  
+ (defcustom completions-format nil
+   "Define the appearance and sorting of completions.
+ If the value is `vertical', display completions sorted vertically
+ in columns in the *Completions* buffer.
+ If the value is `horizontal' or nil, display completions sorted
+ horizontally in alphabetical order, rather than down the screen."
+   :type '(choice (const nil) (const horizontal) (const vertical))
+   :group 'minibuffer
+   :version "23.2")
+ 
  (defun completion--insert-strings (strings)
    "Insert a list of STRINGS into the current buffer.
  Uses columns to keep the listing readable but compact.
***************
*** 800,805 ****
--- 810,817 ----
  		     (max 1 (/ (length strings) 2))))
  	   (colwidth (/ wwidth columns))
             (column 0)
+ 	   (rows (/ (length strings) columns))
+ 	   (row 0)
  	   (laststring nil))
        ;; The insertion should be "sensible" no matter what choices were made
        ;; for the parameters above.
***************
*** 810,815 ****
--- 822,840 ----
                              (+ (string-width (car str))
                                 (string-width (cadr str)))
                            (string-width str))))
+             (cond
+ 	     ((eq completions-format 'vertical)
+ 	      ;; Vertical format
+ 	      (when (> row rows)
+ 		(forward-line (- -1 rows))
+ 		(setq row 0 column (setq column (+ column colwidth))))
+ 	      (when (> column 0)
+ 		(end-of-line)
+ 		(insert " \t")
+ 		(set-text-properties (- (point) 1) (point)
+ 				     `(display (space :align-to ,column)))))
+ 	     (t
+ 	      ;; Horizontal format
  	      (unless (bolp)
  		(if (< wwidth (+ (max colwidth length) column))
  		    ;; No space for `str' at point, move to next line.
***************
*** 823,829 ****
                                       ;; completion-setup-function will kill all
                                       ;; local variables :-(
                                       `(display (space :align-to ,column)))
!                 nil))
              (if (not (consp str))
                  (put-text-property (point) (progn (insert str) (point))
                                     'mouse-face 'highlight)
--- 848,854 ----
  				       ;; completion-setup-function will kill all
  				       ;; local variables :-(
  				       `(display (space :align-to ,column)))
! 		  nil))))
              (if (not (consp str))
                  (put-text-property (point) (progn (insert str) (point))
                                     'mouse-face 'highlight)
***************
*** 832,841 ****
                (add-text-properties (point) (progn (insert (cadr str)) (point))
                                     '(mouse-face nil
                                       face completions-annotations)))
              ;; Next column to align to.
              (setq column (+ column
                              ;; Round up to a whole number of columns.
!                             (* colwidth (ceiling length colwidth))))))))))
  
  (defvar completion-common-substring nil)
  (make-obsolete-variable 'completion-common-substring nil "23.1")
--- 857,875 ----
                (add-text-properties (point) (progn (insert (cadr str)) (point))
                                     '(mouse-face nil
  						face completions-annotations)))
+ 	    (cond
+ 	     ((eq completions-format 'vertical)
+ 	      ;; Vertical format
+ 	      (if (> column 0)
+ 		  (forward-line)
+ 		(insert "\n"))
+ 	      (setq row (1+ row)))
+ 	     (t
+ 	      ;; Horizontal format
  	      ;; Next column to align to.
  	      (setq column (+ column
  			      ;; Round up to a whole number of columns.
! 			      (* colwidth (ceiling length colwidth))))))))))))
  
  (defvar completion-common-substring nil)
  (make-obsolete-variable 'completion-common-substring nil "23.1")

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




  reply	other threads:[~2009-11-17 17:45 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           ` Juri Linkov [this message]
2009-11-18  8:11             ` Vertical completions martin rudalics
2009-11-18  9:59               ` Juri Linkov
2009-11-18  9:47             ` Backward completions (was: Vertical completions) Juri Linkov
2009-11-18 15:06               ` 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=87bpj16pkh.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=deniz.a.m.dogan@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.