emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kill-ring visualization


From: Juri Linkov
Subject: Re: kill-ring visualization
Date: Fri, 26 Mar 2010 09:09:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

>>> If you use a `substring' style completion, you're already closer (tho
>>> it's not a regexp-search).
>> Is the below what you mean?
>
> Yes.  Here's my "not for installation" code, FWIW,
>
> [...]
> +(defun yank-browse ()
> +  "Browse the `kill-ring' to choose which entry to yank."
> +  (interactive)
> +  (minibuffer-with-setup-hook
> +      (lambda ()
> +        (set (make-local-variable 'completion-styles) '(substring))
> +        ;; FIXME: use more separation between entries in *Completions*,
> +        ;; somehow cleanup the \n in there as well.  Maybe indent the
> +        ;; entries a little bit.

This requires implementing a new option in `completions-format'
and let-binding it in `yank-browse'.  It does more separation
with ^L or with a line of dashes, and cleans up the \n with
`query-replace-descr':

=== modified file 'lisp/minibuffer.el'
--- lisp/minibuffer.el  2010-03-23 00:59:49 +0000
+++ lisp/minibuffer.el  2010-03-26 07:09:08 +0000
@@ -818,11 +818,22 @@ (defcustom completions-format nil
 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))
+horizontally in alphabetical order, rather than down the screen.
+If the value is `line', display completions in one column where
+every completion is displayed on one line with newlines and
+control characters converted to readable format and lines separated
+with a string defined by the variable `completions-format-separator'."
+  :type '(choice (const nil)
+                (const horizontal)
+                (const vertical)
+                (const line))
   :group 'minibuffer
   :version "23.2")
 
+(defvar completions-format-separator "\f"   ; "--------"
+  "String inserted between completions in the *Completions* buffer.
+Used only when `completions-format' is `line'.")
+
 (defun completion--insert-strings (strings)
   "Insert a list of STRINGS into the current buffer.
 Uses columns to keep the listing readable but compact.
@@ -858,6 +869,9 @@ (defun completion--insert-strings (strin
                                (string-width (cadr str)))
                           (string-width str))))
             (cond
+            ((eq completions-format 'line)
+             ;; One-line format
+             (setq str (query-replace-descr str)))
             ((eq completions-format 'vertical)
              ;; Vertical format
              (when (> row rows)
@@ -898,6 +912,9 @@ (defun completion--insert-strings (strin
                                    '(mouse-face nil
                                                face completions-annotations)))
            (cond
+            ((eq completions-format 'line)
+             ;; One-line format
+             (insert "\n" (or completions-format-separator "") "\n"))
             ((eq completions-format 'vertical)
              ;; Vertical format
              (if (> column 0)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]