[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/lisp minibuffer.el
From: |
Juri Linkov |
Subject: |
[Emacs-diffs] emacs/lisp minibuffer.el |
Date: |
Thu, 19 Nov 2009 17:38:37 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Juri Linkov <jurta> 09/11/19 17:38:37
Modified files:
lisp : minibuffer.el
Log message:
(completions-format): New defcustom.
(completion--insert-strings): Implement vertical format.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/minibuffer.el?cvsroot=emacs&r1=1.97&r2=1.98
Patches:
Index: minibuffer.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/minibuffer.el,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -b -r1.97 -r1.98
--- minibuffer.el 19 Nov 2009 03:12:52 -0000 1.97
+++ minibuffer.el 19 Nov 2009 17:38:37 -0000 1.98
@@ -778,6 +778,16 @@
(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,6 +810,8 @@
(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,6 +822,24 @@
(+ (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 (+ column colwidth)))
+ (when (> column 0)
+ (end-of-line)
+ (while (> (current-column) column)
+ (if (eobp)
+ (insert "\n")
+ (forward-line 1)
+ (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,7 +853,7 @@
;; completion-setup-function will kill all
;; local variables :-(
`(display (space :align-to ,column)))
- nil))
+ nil))))
(if (not (consp str))
(put-text-property (point) (progn (insert str) (point))
'mouse-face 'highlight)
@@ -832,10 +862,19 @@
(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))))))))))
+ (* colwidth (ceiling length colwidth))))))))))))
(defvar completion-common-substring nil)
(make-obsolete-variable 'completion-common-substring nil "23.1")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs/lisp minibuffer.el,
Juri Linkov <=