* kill-ring visualization
@ 2010-03-18 6:18 joakim
2010-03-18 14:06 ` Stefan Monnier
2010-03-18 15:16 ` Drew Adams
0 siblings, 2 replies; 40+ messages in thread
From: joakim @ 2010-03-18 6:18 UTC (permalink / raw)
To: Emacs development discussions
[-- Attachment #1: Type: text/plain, Size: 413 bytes --]
I find browse-kill-ring very convenient.
It cleverly advices m-y so if its run before any preceding yank, it
shows the contents of the kill-ring and the user can select one entry to
be yanked.
Could something like this be included in Emacs-24? I feel it would be
useful to newcomers (and old-timers with bad short-term memory like me)
The defadvices would have to be removed.
I attach the lisp for inspection.
[-- Attachment #2: browse-kill-ring.el --]
[-- Type: text/plain, Size: 40728 bytes --]
;;; browse-kill-ring.el --- interactively insert items from kill-ring -*- coding: utf-8 -*-
;; Copyright (C) 2001, 2002 Colin Walters <walters@verbum.org>
;; Author: Colin Walters <walters@verbum.org>
;; Maintainer: Nick Hurley <hurley@cis.ohio-state.edu>
;; Created: 7 Apr 2001
;; Version: 1.3a (CVS)
;; X-RCS: $Id: browse-kill-ring.el,v 1.2 2008/10/29 00:23:00 hurley Exp $
;; URL: http://freedom.cis.ohio-state.edu/~hurley/
;; URL-ja: http://www.fan.gr.jp/~ring/doc/browse-kill-ring.html
;; Keywords: convenience
;; This file is not currently part of GNU Emacs.
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program ; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Ever feel that 'C-y M-y M-y M-y ...' is not a great way of trying
;; to find that piece of text you know you killed a while back? Then
;; browse-kill-ring.el is for you.
;; This package is simple to install; add (require 'browse-kill-ring)
;; to your ~/.emacs file, after placing this file somewhere in your
;; `load-path'. If you want to use 'M-y' to invoke
;; `browse-kill-ring', also add (browse-kill-ring-default-keybindings)
;; to your ~/.emacs file. Alternatively, you can bind it to another
;; key such as "C-c k", with:
;; (global-set-key (kbd "C-c k") 'browse-kill-ring)
;; Note that the command keeps track of the last window displayed to
;; handle insertion of chosen text; this might have unexpected
;; consequences if you do 'M-x browse-kill-ring', then switch your
;; window configuration, and try to use the same *Kill Ring* buffer
;; again.
;;; Change Log:
;; Changes from 1.3 to 1.3a:
;; * Sneak update by Benjamin Andresen <bandresen@gmail.com>
;; * Added the read-only bugfix (http://bugs.debian.org/225082) from
;; the emacs-goodies-el package
;; Changes from 1.2 to 1.3:
;; * New maintainer, Nick Hurley <hurley@cis.ohio-state.edu>
;; * New functions `browse-kill-ring-prepend-insert', and
;; `browse-kill-ring-append-insert', bound to 'b' and 'a' by
;; default. There are also the unbound functions
;; `browse-kill-ring-prepend-insert-and-quit',
;; `browse-kill-ring-prepend-insert-and-move',
;; `browse-kill-ring-prepend-insert-move-and-quit',
;; `browse-kill-ring-append-insert-and-quit',
;; `browse-kill-ring-append-insert-and-move',
;; `browse-kill-ring-append-insert-move-and-quit'.
;; Changes from 1.1 to 1.2:
;; * New variable `browse-kill-ring-resize-window', which controls
;; whether or not the browse-kill-ring window will try to resize
;; itself to fit the buffer. Implementation from Juanma Barranquero
;; <lektu@terra.es>.
;; * New variable `browse-kill-ring-highlight-inserted-item'.
;; Implementation from Yasutaka SHINDOH <ring-pub@fan.gr.jp>.
;; * `browse-kill-ring-mouse-insert' (normally bound to mouse-2) now
;; calls `browse-kill-ring-quit'.
;; * Some non-user-visible code cleanup.
;; * New variable `browse-kill-ring-recenter', implementation from
;; René Kyllingstad <kyllingstad@users.sourceforge.net>.
;; * Patch from Michal Maršuka <mmc@maruska.dyndns.org> which handles
;; read-only text better.
;; * New ability to move unkilled entries back to the beginning of the
;; ring; patch from Yasutaka SHINDOH <ring-pub@fan.gr.jp>.
;; * Do nothing if the user invokes `browse-kill-ring' when we're
;; already in a *Kill Ring* buffer (initial patch from Juanma
;; Barranquero <lektu@terra.es>).
;; Changes from 1.0 to 1.1:
;; * Important keybinding change! The default bindings of RET and 'i'
;; have switched; this means typing RET now by default inserts the
;; text and calls `browse-kill-ring-quit'; 'i' just inserts.
;; * The variable `browse-kill-ring-use-fontification' is gone;
;; browse-kill-ring.el has been rewritten to use font-lock. XEmacs
;; users who want fontification will have to do:
;; (add-hook 'browse-kill-ring-hook 'font-lock-mode)
;; * Integrated code from Michael Slass <mikesl@wrq.com> into
;; `browse-kill-ring-default-keybindings'.
;; * New Japanese homepage for browse-kill-ring.el, thanks to
;; Yasutaka SHINDOH <ring-pub@fan.gr.jp>.
;; * Correctly restore window configuration after editing an entry.
;; * New command `browse-kill-ring-insert-and-delete'.
;; * Bug reports and patches from Michael Slass <mikesl@wrq.com> and
;; Juanma Barranquero <lektu@terra.es>.
;; Changes from 0.9b to 1.0:
;; * Add autoload cookie to `browse-kill-ring'; suggestion from
;; D. Goel <deego@glue.umd.edu> and Dave Pearson <davep@davep.org>.
;; * Add keybinding tip from Michael Slass <mikesl@wrq.com>.
;; Changes from 0.9a to 0.9b:
;; * Remove extra parenthesis. Duh.
;; Changes from 0.9 to 0.9a:
;; * Fix bug making `browse-kill-ring-quit-action' uncustomizable.
;; Patch from Henrik Enberg <henrik@enberg.org>.
;; * Add `url-link' and `group' attributes to main Customization
;; group.
;; Changes from 0.8 to 0.9:
;; * Add new function `browse-kill-ring-insert-and-quit', bound to 'i'
;; by default (idea from Yasutaka Shindoh).
;; * Make default `browse-kill-ring-quit-action' be
;; `bury-and-delete-window', which handles the case of a single window
;; more nicely.
;; * Note change of home page and author address.
;; Changes from 0.7 to 0.8:
;; * Fix silly bug in `browse-kill-ring-edit' which made it impossible
;; to edit entries.
;; * New variable `browse-kill-ring-quit-action'.
;; * `browse-kill-ring-restore' renamed to `browse-kill-ring-quit'.
;; * Describe the keymaps in mode documentation. Patch from
;; Marko Slyz <mslyz@eecs.umich.edu>.
;; * Fix advice documentation for `browse-kill-ring-no-duplicates'.
;; Changes from 0.6 to 0.7:
;; * New functions `browse-kill-ring-search-forward' and
;; `browse-kill-ring-search-backward', bound to "s" and "r" by
;; default, respectively.
;; * New function `browse-kill-ring-edit' bound to "e" by default, and
;; a associated new major mode.
;; * New function `browse-kill-ring-occur', bound to "l" by default.
;; Changes from 0.5 to 0.6:
;; * Fix bug in `browse-kill-ring-forward' which sometimes would cause
;; a message "Wrong type argument: overlayp, nil" to appear.
;; * New function `browse-kill-ring-update'.
;; * New variable `browse-kill-ring-highlight-current-entry'.
;; * New variable `browse-kill-ring-display-duplicates'.
;; * New optional advice `browse-kill-ring-no-kill-new-duplicates',
;; and associated variable `browse-kill-ring-no-duplicates'. Code
;; from Klaus Berndl <Klaus.Berndl@sdm.de>.
;; * Bind "?" to `describe-mode'. Patch from Dave Pearson
;; <dave@davep.org>.
;; * Fix typo in `browse-kill-ring-display-style' defcustom form.
;; Thanks "Kahlil (Kal) HODGSON" <kahlil@discus.anu.edu.au>.
;; Changes from 0.4 to 0.5:
;; * New function `browse-kill-ring-delete', bound to "d" by default.
;; * New function `browse-kill-ring-undo', bound to "U" by default.
;; * New variable `browse-kill-ring-maximum-display-length'.
;; * New variable `browse-kill-ring-use-fontification'.
;; * New variable `browse-kill-ring-hook', called after the
;; "*Kill Ring*" buffer is created.
;; Changes from 0.3 to 0.4:
;; * New functions `browse-kill-ring-forward' and
;; `browse-kill-ring-previous', bound to "n" and "p" by default,
;; respectively.
;; * Change the default `browse-kill-ring-display-style' to
;; `separated'.
;; * Removed `browse-kill-ring-original-window-config'; Now
;; `browse-kill-ring-restore' just buries the "*Kill Ring*" buffer
;; and deletes its window, which is simpler and more intuitive.
;; * New variable `browse-kill-ring-separator-face'.
;;; Bugs:
;; * Sometimes, in Emacs 21, the cursor will jump to the end of an
;; entry when moving backwards using `browse-kill-ring-previous'.
;; This doesn't seem to occur in Emacs 20 or XEmacs.
;;; Code:
(eval-when-compile
(require 'cl)
(require 'derived))
(when (featurep 'xemacs)
(require 'overlay))
(defun browse-kill-ring-depropertize-string (str)
"Return a copy of STR with text properties removed."
(let ((str (copy-sequence str)))
(set-text-properties 0 (length str) nil str)
str))
(cond ((fboundp 'propertize)
(defalias 'browse-kill-ring-propertize 'propertize))
;; Maybe save some memory :)
((fboundp 'ibuffer-propertize)
(defalias 'browse-kill-ring-propertize 'ibuffer-propertize))
(t
(defun browse-kill-ring-propertize (string &rest properties)
"Return a copy of STRING with text properties added.
[Note: this docstring has been copied from the Emacs 21 version]
First argument is the string to copy.
Remaining arguments form a sequence of PROPERTY VALUE pairs for text
properties to add to the result."
(let ((str (copy-sequence string)))
(add-text-properties 0 (length str)
properties
str)
str))))
(defgroup browse-kill-ring nil
"A package for browsing and inserting the items in `kill-ring'."
:link '(url-link "http://freedom.cis.ohio-state.edu/~hurley/")
:group 'convenience)
(defvar browse-kill-ring-display-styles
'((separated . browse-kill-ring-insert-as-separated)
(one-line . browse-kill-ring-insert-as-one-line)))
(defcustom browse-kill-ring-display-style 'separated
"How to display the kill ring items.
If `one-line', then replace newlines with \"\\n\" for display.
If `separated', then display `browse-kill-ring-separator' between
entries."
:type '(choice (const :tag "One line" one-line)
(const :tag "Separated" separated))
:group 'browse-kill-ring)
(defcustom browse-kill-ring-quit-action 'bury-and-delete-window
"What action to take when `browse-kill-ring-quit' is called.
If `bury-buffer', then simply bury the *Kill Ring* buffer, but keep
the window.
If `bury-and-delete-window', then bury the buffer, and (if there is
more than one window) delete the window. This is the default.
If `save-and-restore', then save the window configuration when
`browse-kill-ring' is called, and restore it at quit.
If `kill-and-delete-window', then kill the *Kill Ring* buffer, and
delete the window on close.
Otherwise, it should be a function to call."
:type '(choice (const :tag "Bury buffer" :value bury-buffer)
(const :tag "Delete window" :value delete-window)
(const :tag "Save and restore" :value save-and-restore)
(const :tag "Bury buffer and delete window" :value bury-and-delete-window)
(const :tag "Kill buffer and delete window" :value kill-and-delete-window)
function)
:group 'browse-kill-ring)
(defcustom browse-kill-ring-resize-window nil
"Whether to resize the `browse-kill-ring' window to fit its contents.
Value is either t, meaning yes, or a cons pair of integers,
(MAXIMUM . MINIMUM) for the size of the window. MAXIMUM defaults to
the window size chosen by `pop-to-buffer'; MINIMUM defaults to
`window-min-height'."
:type '(choice (const :tag "No" nil)
(const :tag "Yes" t)
(cons (integer :tag "Maximum") (integer :tag "Minimum")))
:group 'browse-kill-ring)
(defcustom browse-kill-ring-separator "-------"
"The string separating entries in the `separated' style.
See `browse-kill-ring-display-style'."
:type 'string
:group 'browse-kill-ring)
(defcustom browse-kill-ring-recenter nil
"If non-nil, then always keep the current entry at the top of the window."
:type 'boolean
:group 'browse-kill-ring)
(defcustom browse-kill-ring-highlight-current-entry nil
"If non-nil, highlight the currently selected `kill-ring' entry."
:type 'boolean
:group 'browse-kill-ring)
(defcustom browse-kill-ring-highlight-inserted-item browse-kill-ring-highlight-current-entry
"If non-nil, temporarily highlight the inserted `kill-ring' entry."
:type 'boolean
:group 'browse-kill-ring)
(defcustom browse-kill-ring-separator-face 'bold
"The face in which to highlight the `browse-kill-ring-separator'."
:type 'face
:group 'browse-kill-ring)
(defcustom browse-kill-ring-maximum-display-length nil
"Whether or not to limit the length of displayed items.
If this variable is an integer, the display of `kill-ring' will be
limited to that many characters.
Setting this variable to nil means no limit."
:type '(choice (const :tag "None" nil)
integer)
:group 'browse-kill-ring)
(defcustom browse-kill-ring-display-duplicates t
"If non-nil, then display duplicate items in `kill-ring'."
:type 'boolean
:group 'browse-kill-ring)
(defadvice kill-new (around browse-kill-ring-no-kill-new-duplicates)
"An advice for not adding duplicate elements to `kill-ring'.
Even after being \"activated\", this advice will only modify the
behavior of `kill-new' when `browse-kill-ring-no-duplicates'
is non-nil."
(if browse-kill-ring-no-duplicates
(setq kill-ring (delete (ad-get-arg 0) kill-ring)))
ad-do-it)
(defcustom browse-kill-ring-no-duplicates nil
"If non-nil, then the `b-k-r-no-kill-new-duplicates' advice will operate.
This means that duplicate entries won't be added to the `kill-ring'
when you call `kill-new'.
If you set this variable via customize, the advice will be activated
or deactivated automatically. Otherwise, to enable the advice, add
(ad-enable-advice 'kill-new 'around 'browse-kill-ring-no-kill-new-duplicates)
(ad-activate 'kill-new)
to your init file."
:type 'boolean
:set (lambda (symbol value)
(set symbol value)
(if value
(ad-enable-advice 'kill-new 'around
'browse-kill-ring-no-kill-new-duplicates)
(ad-disable-advice 'kill-new 'around
'browse-kill-ring-no-kill-new-duplicates))
(ad-activate 'kill-new))
:group 'browse-kill-ring)
(defcustom browse-kill-ring-depropertize nil
"If non-nil, remove text properties from `kill-ring' items.
This only changes the items for display and insertion from
`browse-kill-ring'; if you call `yank' directly, the items will be
inserted with properties."
:type 'boolean
:group 'browse-kill-ring)
(defcustom browse-kill-ring-hook nil
"A list of functions to call after `browse-kill-ring'."
:type 'hook
:group 'browse-kill-ring)
(defvar browse-kill-ring-original-window-config nil
"The window configuration to restore for `browse-kill-ring-quit'.")
(make-variable-buffer-local 'browse-kill-ring-original-window-config)
(defvar browse-kill-ring-original-window nil
"The window in which chosen kill ring data will be inserted.
It is probably not a good idea to set this variable directly; simply
call `browse-kill-ring' again.")
(defun browse-kill-ring-mouse-insert (e)
"Insert the chosen text, and close the *Kill Ring* buffer afterwards."
(interactive "e")
(let* ((data (save-excursion
(mouse-set-point e)
(cons (current-buffer) (point))))
(buf (car data))
(pt (cdr data)))
(browse-kill-ring-do-insert buf pt))
(browse-kill-ring-quit))
(if (fboundp 'fit-window-to-buffer)
(defalias 'browse-kill-ring-fit-window 'fit-window-to-buffer)
(defun browse-kill-ring-fit-window (window max-height min-height)
(setq min-height (or min-height window-min-height))
(setq max-height (or max-height (- (frame-height) (window-height) 1)))
(let* ((window-min-height min-height)
(windows (count-windows))
(config (current-window-configuration)))
(enlarge-window (- max-height (window-height)))
(when (> windows (count-windows))
(set-window-configuration config))
(if (/= (point-min) (point-max))
(shrink-window-if-larger-than-buffer window)
(shrink-window (- (window-height) window-min-height))))))
(defun browse-kill-ring-resize-window ()
(when browse-kill-ring-resize-window
(apply #'browse-kill-ring-fit-window (selected-window)
(if (consp browse-kill-ring-resize-window)
(list (car browse-kill-ring-resize-window)
(or (cdr browse-kill-ring-resize-window)
window-min-height))
(list nil window-min-height)))))
(defun browse-kill-ring-undo-other-window ()
"Undo the most recent change in the other window's buffer.
You most likely want to use this command for undoing an insertion of
yanked text from the *Kill Ring* buffer."
(interactive)
(with-current-buffer (window-buffer browse-kill-ring-original-window)
(undo)))
(defun browse-kill-ring-insert (&optional quit)
"Insert the kill ring item at point into the last selected buffer.
If optional argument QUIT is non-nil, close the *Kill Ring* buffer as
well."
(interactive "P")
(browse-kill-ring-do-insert (current-buffer)
(point))
(when quit
(browse-kill-ring-quit)))
(defun browse-kill-ring-insert-and-delete (&optional quit)
"Insert the kill ring item at point, and remove it from the kill ring.
If optional argument QUIT is non-nil, close the *Kill Ring* buffer as
well."
(interactive "P")
(browse-kill-ring-do-insert (current-buffer)
(point))
(browse-kill-ring-delete)
(when quit
(browse-kill-ring-quit)))
(defun browse-kill-ring-insert-and-quit ()
"Like `browse-kill-ring-insert', but close the *Kill Ring* buffer afterwards."
(interactive)
(browse-kill-ring-insert t))
(defun browse-kill-ring-insert-and-move (&optional quit)
"Like `browse-kill-ring-insert', but move the entry to the front."
(interactive "P")
(let ((buf (current-buffer))
(pt (point)))
(browse-kill-ring-do-insert buf pt)
(let ((str (browse-kill-ring-current-string buf pt)))
(browse-kill-ring-delete)
(kill-new str)))
(if quit
(browse-kill-ring-quit)
(browse-kill-ring-update)))
(defun browse-kill-ring-insert-move-and-quit ()
"Like `browse-kill-ring-insert-and-move', but close the *Kill Ring* buffer."
(interactive)
(browse-kill-ring-insert-and-move t))
(defun browse-kill-ring-prepend-insert (&optional quit)
"Like `browse-kill-ring-insert', but it places the entry at the beginning
of the buffer as opposed to point."
(interactive "P")
(browse-kill-ring-do-prepend-insert (current-buffer)
(point))
(when quit
(browse-kill-ring-quit)))
(defun browse-kill-ring-prepend-insert-and-quit ()
"Like `browse-kill-ring-prepend-insert', but close the *Kill Ring* buffer."
(interactive)
(browse-kill-ring-prepend-insert t))
(defun browse-kill-ring-prepend-insert-and-move (&optional quit)
"Like `browse-kill-ring-prepend-insert', but move the entry to the front
of the *Kill Ring*."
(interactive "P")
(let ((buf (current-buffer))
(pt (point)))
(browse-kill-ring-do-prepend-insert buf pt)
(let ((str (browse-kill-ring-current-string buf pt)))
(browse-kill-ring-delete)
(kill-new str)))
(if quit
(browse-kill-ring-quit)
(browse-kill-ring-update)))
(defun browse-kill-ring-prepend-insert-move-and-quit ()
"Like `browse-kill-ring-prepend-insert-and-move', but close the
*Kill Ring* buffer."
(interactive)
(browse-kill-ring-prepend-insert-and-move t))
(defun browse-kill-ring-do-prepend-insert (buf pt)
(let ((str (browse-kill-ring-current-string buf pt)))
(let ((orig (current-buffer)))
(unwind-protect
(progn
(unless (window-live-p browse-kill-ring-original-window)
(error "Window %s has been deleted; Try calling `browse-kill-ring' again"
browse-kill-ring-original-window))
(set-buffer (window-buffer browse-kill-ring-original-window))
(save-excursion
(let ((pt (point)))
(goto-char (point-min))
(insert (if browse-kill-ring-depropertize
(browse-kill-ring-depropertize-string str)
str))
(when browse-kill-ring-highlight-inserted-item
(let ((o (make-overlay (point-min) (point))))
(overlay-put o 'face 'highlight)
(sit-for 0.5)
(delete-overlay o)))
(goto-char pt))))
(set-buffer orig)))))
(defun browse-kill-ring-append-insert (&optional quit)
"Like `browse-kill-ring-insert', but places the entry at the end of the
buffer as opposed to point."
(interactive "P")
(browse-kill-ring-do-append-insert (current-buffer)
(point))
(when quit
(browse-kill-ring-quit)))
(defun browse-kill-ring-append-insert-and-quit ()
"Like `browse-kill-ring-append-insert', but close the *Kill Ring* buffer."
(interactive)
(browse-kill-ring-append-insert t))
(defun browse-kill-ring-append-insert-and-move (&optional quit)
"Like `browse-kill-ring-append-insert', but move the entry to the front
of the *Kill Ring*."
(interactive "P")
(let ((buf (current-buffer))
(pt (point)))
(browse-kill-ring-do-append-insert buf pt)
(let ((str (browse-kill-ring-current-string buf pt)))
(browse-kill-ring-delete)
(kill-new str)))
(if quit
(browse-kill-ring-quit)
(browse-kill-ring-update)))
(defun browse-kill-ring-append-insert-move-and-quit ()
"Like `browse-kill-ring-append-insert-and-move', but close the
*Kill Ring* buffer."
(interactive)
(browse-kill-ring-append-insert-and-move t))
(defun browse-kill-ring-do-append-insert (buf pt)
(let ((str (browse-kill-ring-current-string buf pt)))
(let ((orig (current-buffer)))
(unwind-protect
(progn
(unless (window-live-p browse-kill-ring-original-window)
(error "Window %s has been deleted; Try calling `browse-kill-ring' again"
browse-kill-ring-original-window))
(set-buffer (window-buffer browse-kill-ring-original-window))
(save-excursion
(let ((pt (point))
(begin-pt (point-max)))
(goto-char begin-pt)
(insert (if browse-kill-ring-depropertize
(browse-kill-ring-depropertize-string str)
str))
(when browse-kill-ring-highlight-inserted-item
(let ((o (make-overlay begin-pt (point-max))))
(overlay-put o 'face 'highlight)
(sit-for 0.5)
(delete-overlay o)))
(goto-char pt))))
(set-buffer orig)))))
(defun browse-kill-ring-delete ()
"Remove the item at point from the `kill-ring'."
(interactive)
(let ((over (car (overlays-at (point)))))
(unless (overlayp over)
(error "No kill ring item here"))
(unwind-protect
(progn
(setq buffer-read-only nil)
(let ((target (overlay-get over 'browse-kill-ring-target)))
(delete-region (overlay-start over)
(1+ (overlay-end over)))
(setq kill-ring (delete target kill-ring)))
(when (get-text-property (point) 'browse-kill-ring-extra)
(let ((prev (previous-single-property-change (point)
'browse-kill-ring-extra))
(next (next-single-property-change (point)
'browse-kill-ring-extra)))
;; This is some voodoo.
(when prev
(incf prev))
(when next
(incf next))
(delete-region (or prev (point-min))
(or next (point-max))))))
(setq buffer-read-only t)))
(browse-kill-ring-resize-window)
(browse-kill-ring-forward 0))
(defun browse-kill-ring-current-string (buf pt)
(with-current-buffer buf
(let ((overs (overlays-at pt)))
(or (and overs
(overlay-get (car overs) 'browse-kill-ring-target))
(error "No kill ring item here")))))
(defun browse-kill-ring-do-insert (buf pt)
(let ((str (browse-kill-ring-current-string buf pt)))
(let ((orig (current-buffer)))
(unwind-protect
(progn
(unless (window-live-p browse-kill-ring-original-window)
(error "Window %s has been deleted; Try calling `browse-kill-ring' again"
browse-kill-ring-original-window))
(set-buffer (window-buffer browse-kill-ring-original-window))
(save-excursion
(let ((pt (point)))
(insert (if browse-kill-ring-depropertize
(browse-kill-ring-depropertize-string str)
str))
(when browse-kill-ring-highlight-inserted-item
(let ((o (make-overlay pt (point))))
(overlay-put o 'face 'highlight)
(sit-for 0.5)
(delete-overlay o))))))
(set-buffer orig)))))
(defun browse-kill-ring-forward (&optional arg)
"Move forward by ARG `kill-ring' entries."
(interactive "p")
(beginning-of-line)
(while (not (zerop arg))
(if (< arg 0)
(progn
(incf arg)
(if (overlays-at (point))
(progn
(goto-char (overlay-start (car (overlays-at (point)))))
(goto-char (previous-overlay-change (point)))
(goto-char (previous-overlay-change (point))))
(progn
(goto-char (1- (previous-overlay-change (point))))
(unless (bobp)
(goto-char (overlay-start (car (overlays-at (point)))))))))
(progn
(decf arg)
(if (overlays-at (point))
(progn
(goto-char (overlay-end (car (overlays-at (point)))))
(goto-char (next-overlay-change (point))))
(goto-char (next-overlay-change (point)))
(unless (eobp)
(goto-char (overlay-start (car (overlays-at (point))))))))))
;; This could probably be implemented in a more intelligent manner.
;; Perhaps keep track over the overlay we started from? That would
;; break when the user moved manually, though.
(when (and browse-kill-ring-highlight-current-entry
(overlays-at (point)))
(let ((overs (overlay-lists))
(current-overlay (car (overlays-at (point)))))
(mapcar #'(lambda (o)
(overlay-put o 'face nil))
(nconc (car overs) (cdr overs)))
(overlay-put current-overlay 'face 'highlight)))
(when browse-kill-ring-recenter
(recenter 1)))
(defun browse-kill-ring-previous (&optional arg)
"Move backward by ARG `kill-ring' entries."
(interactive "p")
(browse-kill-ring-forward (- arg)))
(defun browse-kill-ring-read-regexp (msg)
(let* ((default (car regexp-history))
(input
(read-from-minibuffer
(if default
(format "%s for regexp (default `%s'): "
msg
default)
(format "%s (regexp): " msg))
nil
nil
nil
'regexp-history)))
(if (equal input "")
default
input)))
(defun browse-kill-ring-search-forward (regexp &optional backwards)
"Move to the next `kill-ring' entry matching REGEXP from point.
If optional arg BACKWARDS is non-nil, move to the previous matching
entry."
(interactive
(list (browse-kill-ring-read-regexp "Search forward")
current-prefix-arg))
(let ((orig (point)))
(browse-kill-ring-forward (if backwards -1 1))
(let ((overs (overlays-at (point))))
(while (and overs
(not (if backwards (bobp) (eobp)))
(not (string-match regexp
(overlay-get (car overs)
'browse-kill-ring-target))))
(browse-kill-ring-forward (if backwards -1 1))
(setq overs (overlays-at (point))))
(unless (and overs
(string-match regexp
(overlay-get (car overs)
'browse-kill-ring-target)))
(progn
(goto-char orig)
(message "No more `kill-ring' entries matching %s" regexp))))))
(defun browse-kill-ring-search-backward (regexp)
"Move to the previous `kill-ring' entry matching REGEXP from point."
(interactive
(list (browse-kill-ring-read-regexp "Search backward")))
(browse-kill-ring-search-forward regexp t))
(defun browse-kill-ring-quit ()
"Take the action specified by `browse-kill-ring-quit-action'."
(interactive)
(case browse-kill-ring-quit-action
(save-and-restore
(let (buf (current-buffer))
(set-window-configuration browse-kill-ring-original-window-config)
(kill-buffer buf)))
(kill-and-delete-window
(kill-buffer (current-buffer))
(unless (= (count-windows) 1)
(delete-window)))
(bury-and-delete-window
(bury-buffer)
(unless (= (count-windows) 1)
(delete-window)))
(t
(funcall browse-kill-ring-quit-action))))
(put 'browse-kill-ring-mode 'mode-class 'special)
(define-derived-mode browse-kill-ring-mode fundamental-mode
"Kill Ring"
"A major mode for browsing the `kill-ring'.
You most likely do not want to call `browse-kill-ring-mode' directly; use
`browse-kill-ring' instead.
\\{browse-kill-ring-mode-map}"
(set (make-local-variable 'font-lock-defaults)
'(nil t nil nil nil
(font-lock-fontify-region-function . browse-kill-ring-fontify-region)))
(define-key browse-kill-ring-mode-map (kbd "q") 'browse-kill-ring-quit)
(define-key browse-kill-ring-mode-map (kbd "U") 'browse-kill-ring-undo-other-window)
(define-key browse-kill-ring-mode-map (kbd "d") 'browse-kill-ring-delete)
(define-key browse-kill-ring-mode-map (kbd "s") 'browse-kill-ring-search-forward)
(define-key browse-kill-ring-mode-map (kbd "r") 'browse-kill-ring-search-backward)
(define-key browse-kill-ring-mode-map (kbd "g") 'browse-kill-ring-update)
(define-key browse-kill-ring-mode-map (kbd "l") 'browse-kill-ring-occur)
(define-key browse-kill-ring-mode-map (kbd "e") 'browse-kill-ring-edit)
(define-key browse-kill-ring-mode-map (kbd "n") 'browse-kill-ring-forward)
(define-key browse-kill-ring-mode-map (kbd "p") 'browse-kill-ring-previous)
(define-key browse-kill-ring-mode-map [(mouse-2)] 'browse-kill-ring-mouse-insert)
(define-key browse-kill-ring-mode-map (kbd "?") 'describe-mode)
(define-key browse-kill-ring-mode-map (kbd "h") 'describe-mode)
(define-key browse-kill-ring-mode-map (kbd "y") 'browse-kill-ring-insert)
(define-key browse-kill-ring-mode-map (kbd "u") 'browse-kill-ring-insert-move-and-quit)
(define-key browse-kill-ring-mode-map (kbd "i") 'browse-kill-ring-insert)
(define-key browse-kill-ring-mode-map (kbd "o") 'browse-kill-ring-insert-and-move)
(define-key browse-kill-ring-mode-map (kbd "x") 'browse-kill-ring-insert-and-delete)
(define-key browse-kill-ring-mode-map (kbd "RET") 'browse-kill-ring-insert-and-quit)
(define-key browse-kill-ring-mode-map (kbd "b") 'browse-kill-ring-prepend-insert)
(define-key browse-kill-ring-mode-map (kbd "a") 'browse-kill-ring-append-insert))
;;;###autoload
(defun browse-kill-ring-default-keybindings ()
"Set up M-y (`yank-pop') so that it can invoke `browse-kill-ring'.
Normally, if M-y was not preceeded by C-y, then it has no useful
behavior. This function sets things up so that M-y will invoke
`browse-kill-ring'."
(interactive)
(defadvice yank-pop (around kill-ring-browse-maybe (arg))
"If last action was not a yank, run `browse-kill-ring' instead."
;; yank-pop has an (interactive "*p") form which does not allow
;; it to run in a read-only buffer. We want browse-kill-ring to
;; be allowed to run in a read only buffer, so we change the
;; interactive form here. In that case, we need to
;; barf-if-buffer-read-only if we're going to call yank-pop with
;; ad-do-it
(interactive "p")
(if (not (eq last-command 'yank))
(browse-kill-ring)
(barf-if-buffer-read-only)
ad-do-it))
(ad-activate 'yank-pop))
(define-derived-mode browse-kill-ring-edit-mode fundamental-mode
"Kill Ring Edit"
"A major mode for editing a `kill-ring' entry.
You most likely do not want to call `browse-kill-ring-edit-mode'
directly; use `browse-kill-ring' instead.
\\{browse-kill-ring-edit-mode-map}"
(define-key browse-kill-ring-edit-mode-map (kbd "C-c C-c")
'browse-kill-ring-edit-finish))
(defvar browse-kill-ring-edit-target nil)
(make-variable-buffer-local 'browse-kill-ring-edit-target)
(defun browse-kill-ring-edit ()
"Edit the `kill-ring' entry at point."
(interactive)
(let ((overs (overlays-at (point))))
(unless overs
(error "No kill ring entry here"))
(let* ((target (overlay-get (car overs)
'browse-kill-ring-target))
(target-cell (member target kill-ring)))
(unless target-cell
(error "Item deleted from the kill-ring"))
(switch-to-buffer (get-buffer-create "*Kill Ring Edit*"))
(setq buffer-read-only nil)
(erase-buffer)
(insert target)
(goto-char (point-min))
(browse-kill-ring-resize-window)
(browse-kill-ring-edit-mode)
(message "%s"
(substitute-command-keys
"Use \\[browse-kill-ring-edit-finish] to finish editing."))
(setq browse-kill-ring-edit-target target-cell))))
(defun browse-kill-ring-edit-finish ()
"Commit the changes to the `kill-ring'."
(interactive)
(if browse-kill-ring-edit-target
(setcar browse-kill-ring-edit-target (buffer-string))
(when (y-or-n-p "The item has been deleted; add to front? ")
(push (buffer-string) kill-ring)))
(bury-buffer)
;; The user might have rearranged the windows
(when (eq major-mode 'browse-kill-ring-mode)
(browse-kill-ring-setup (current-buffer)
browse-kill-ring-original-window
nil
browse-kill-ring-original-window-config)
(browse-kill-ring-resize-window)))
(defmacro browse-kill-ring-add-overlays-for (item &rest body)
(let ((beg (gensym "browse-kill-ring-add-overlays-"))
(end (gensym "browse-kill-ring-add-overlays-")))
`(let ((,beg (point))
(,end
(progn
,@body
(point))))
(let ((o (make-overlay ,beg ,end)))
(overlay-put o 'browse-kill-ring-target ,item)
(overlay-put o 'mouse-face 'highlight)))))
;; (put 'browse-kill-ring-add-overlays-for 'lisp-indent-function 1)
(defun browse-kill-ring-elide (str)
(if (and browse-kill-ring-maximum-display-length
(> (length str)
browse-kill-ring-maximum-display-length))
(concat (substring str 0 (- browse-kill-ring-maximum-display-length 3))
(browse-kill-ring-propertize "..." 'browse-kill-ring-extra t))
str))
(defun browse-kill-ring-insert-as-one-line (items)
(dolist (item items)
(browse-kill-ring-add-overlays-for item
(let* ((item (browse-kill-ring-elide item))
(len (length item))
(start 0)
(newl (browse-kill-ring-propertize "\\n" 'browse-kill-ring-extra t)))
(while (and (< start len)
(string-match "\n" item start))
(insert (substring item start (match-beginning 0))
newl)
(setq start (match-end 0)))
(insert (substring item start len))))
(insert "\n")))
(defun browse-kill-ring-insert-as-separated (items)
(while (cdr items)
(browse-kill-ring-insert-as-separated-1 (car items) t)
(setq items (cdr items)))
(when items
(browse-kill-ring-insert-as-separated-1 (car items) nil)))
(defun browse-kill-ring-insert-as-separated-1 (origitem separatep)
(let* ((item (browse-kill-ring-elide origitem))
(len (length item)))
(browse-kill-ring-add-overlays-for origitem
(insert item))
;; When the kill-ring has items with read-only text property at
;; **the end of** string, browse-kill-ring-setup fails with error
;; `Text is read-only'. So inhibit-read-only here.
;; See http://bugs.debian.org/225082
;; - INOUE Hiroyuki <dombly@kc4.so-net.ne.jp>
(let ((inhibit-read-only t))
(insert "\n")
(when separatep
(insert (browse-kill-ring-propertize browse-kill-ring-separator
'browse-kill-ring-extra t
'browse-kill-ring-separator t))
(insert "\n")))))
(defun browse-kill-ring-occur (regexp)
"Display all `kill-ring' entries matching REGEXP."
(interactive
(list
(browse-kill-ring-read-regexp "Display kill ring entries matching")))
(assert (eq major-mode 'browse-kill-ring-mode))
(browse-kill-ring-setup (current-buffer)
browse-kill-ring-original-window
regexp)
(browse-kill-ring-resize-window))
(defun browse-kill-ring-fontify-on-property (prop face beg end)
(save-excursion
(goto-char beg)
(let ((prop-end nil))
(while
(setq prop-end
(let ((prop-beg (or (and (get-text-property (point) prop) (point))
(next-single-property-change (point) prop nil end))))
(when (and prop-beg (not (= prop-beg end)))
(let ((prop-end (next-single-property-change prop-beg prop nil end)))
(when (and prop-end (not (= prop-end end)))
(put-text-property prop-beg prop-end 'face face)
prop-end)))))
(goto-char prop-end)))))
(defun browse-kill-ring-fontify-region (beg end &optional verbose)
(when verbose (message "Fontifying..."))
(let ((buffer-read-only nil))
(browse-kill-ring-fontify-on-property 'browse-kill-ring-extra 'bold beg end)
(browse-kill-ring-fontify-on-property 'browse-kill-ring-separator
browse-kill-ring-separator-face beg end))
(when verbose (message "Fontifying...done")))
(defun browse-kill-ring-update ()
"Update the buffer to reflect outside changes to `kill-ring'."
(interactive)
(assert (eq major-mode 'browse-kill-ring-mode))
(browse-kill-ring-setup (current-buffer)
browse-kill-ring-original-window)
(browse-kill-ring-resize-window))
(defun browse-kill-ring-setup (buf window &optional regexp window-config)
(with-current-buffer buf
(unwind-protect
(progn
(browse-kill-ring-mode)
(setq buffer-read-only nil)
(when (eq browse-kill-ring-display-style
'one-line)
(setq truncate-lines t))
(let ((inhibit-read-only t))
(erase-buffer))
(setq browse-kill-ring-original-window window
browse-kill-ring-original-window-config
(or window-config
(current-window-configuration)))
(let ((browse-kill-ring-maximum-display-length
(if (and browse-kill-ring-maximum-display-length
(<= browse-kill-ring-maximum-display-length 3))
4
browse-kill-ring-maximum-display-length))
(items (mapcar
(if browse-kill-ring-depropertize
#'browse-kill-ring-depropertize-string
#'copy-sequence)
kill-ring)))
(when (not browse-kill-ring-display-duplicates)
;; I'm not going to rewrite `delete-duplicates'. If
;; someone really wants to rewrite it here, send me a
;; patch.
(require 'cl)
(setq items (delete-duplicates items :test #'equal)))
(when (stringp regexp)
(setq items (delq nil
(mapcar
#'(lambda (item)
(when (string-match regexp item)
item))
items))))
(funcall (or (cdr (assq browse-kill-ring-display-style
browse-kill-ring-display-styles))
(error "Invalid `browse-kill-ring-display-style': %s"
browse-kill-ring-display-style))
items)
;; Code from Michael Slass <mikesl@wrq.com>
(message
(let ((entry (if (= 1 (length kill-ring)) "entry" "entries")))
(concat
(if (and (not regexp)
browse-kill-ring-display-duplicates)
(format "%s %s in the kill ring."
(length kill-ring) entry)
(format "%s (of %s) %s in the kill ring shown."
(length items) (length kill-ring) entry))
(substitute-command-keys
(concat " Type \\[browse-kill-ring-quit] to quit. "
"\\[describe-mode] for help.")))))
;; End code from Michael Slass <mikesl@wrq.com>
(set-buffer-modified-p nil)
(goto-char (point-min))
(browse-kill-ring-forward 0)
(when regexp
(setq mode-name (concat "Kill Ring [" regexp "]")))
(run-hooks 'browse-kill-ring-hook)
;; I will be very glad when I can get rid of this gross
;; hack, which solely exists for XEmacs users.
(when (and (featurep 'xemacs)
font-lock-mode)
(browse-kill-ring-fontify-region (point-min) (point-max)))))
(progn
(setq buffer-read-only t)))))
;;;###autoload
(defun browse-kill-ring ()
"Display items in the `kill-ring' in another buffer."
(interactive)
(if (eq major-mode 'browse-kill-ring-mode)
(message "Already viewing the kill ring")
(let ((orig-buf (current-buffer))
(buf (get-buffer-create "*Kill Ring*")))
(browse-kill-ring-setup buf (selected-window))
(pop-to-buffer buf)
(browse-kill-ring-resize-window)
nil)))
(provide 'browse-kill-ring)
;;; browse-kill-ring.el ends here
[-- Attachment #3: Type: text/plain, Size: 19 bytes --]
--
Joakim Verona
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-18 6:18 kill-ring visualization joakim
@ 2010-03-18 14:06 ` Stefan Monnier
2010-03-18 18:39 ` Leo
2010-03-24 9:34 ` Juri Linkov
2010-03-18 15:16 ` Drew Adams
1 sibling, 2 replies; 40+ messages in thread
From: Stefan Monnier @ 2010-03-18 14:06 UTC (permalink / raw)
To: joakim; +Cc: Emacs development discussions
> I find browse-kill-ring very convenient.
> It cleverly advices m-y so if its run before any preceding yank, it
> shows the contents of the kill-ring and the user can select one entry to
> be yanked.
> Could something like this be included in Emacs-24? I feel it would be
> useful to newcomers (and old-timers with bad short-term memory like me)
I think it's indeed a very nice feature. I end up not using it much,
but at least it seems like a natural use for M-y.
OTOH the few times I've used it I wished it use a form of completion.
Basically, I'd like it to use an interface similar to completing-read,
except maybe that it'd bring up the *Completions* buffer right away (and
that the completion would use a substring search).
So I think if we want to enable such a feature by default, it'd need to
be better integrated with the completion code.
Stefan
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: kill-ring visualization
2010-03-18 6:18 kill-ring visualization joakim
2010-03-18 14:06 ` Stefan Monnier
@ 2010-03-18 15:16 ` Drew Adams
1 sibling, 0 replies; 40+ messages in thread
From: Drew Adams @ 2010-03-18 15:16 UTC (permalink / raw)
To: joakim, 'Emacs development discussions'
> I find browse-kill-ring very convenient.
>
> It cleverly advices m-y so if its run before any preceding yank,
> it shows the contents of the kill-ring and the user can select
> one entry to be yanked.
>
> Could something like this be included in Emacs-24? I feel it would
> be useful to newcomers (and old-timers with bad short-term
> memory like me)
>
> The defadvices would have to be removed.
> I attach the lisp for inspection.
If you do consider that code, then perhaps consider this addition to it as well:
http://www.emacswiki.org/emacs/browse-kill-ring%2b.el
See also http://www.emacswiki.org/emacs/BrowseKillRing.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-18 14:06 ` Stefan Monnier
@ 2010-03-18 18:39 ` Leo
2010-03-18 19:37 ` joakim
2010-03-24 9:34 ` Juri Linkov
1 sibling, 1 reply; 40+ messages in thread
From: Leo @ 2010-03-18 18:39 UTC (permalink / raw)
To: Stefan Monnier; +Cc: joakim, Emacs development discussions
On 2010-03-18 14:06 +0000, Stefan Monnier wrote:
>> I find browse-kill-ring very convenient.
>> It cleverly advices m-y so if its run before any preceding yank, it
>> shows the contents of the kill-ring and the user can select one entry to
>> be yanked.
>> Could something like this be included in Emacs-24? I feel it would be
>> useful to newcomers (and old-timers with bad short-term memory like me)
>
> I think it's indeed a very nice feature. I end up not using it much,
> but at least it seems like a natural use for M-y.
>
> OTOH the few times I've used it I wished it use a form of completion.
> Basically, I'd like it to use an interface similar to completing-read,
> except maybe that it'd bring up the *Completions* buffer right away (and
> that the completion would use a substring search).
>
> So I think if we want to enable such a feature by default, it'd need to
> be better integrated with the completion code.
I think at least it should be built on top of ewoc. It seems like a
natural choice.
I have been using b-k-r for around 2 years, at least keeping it around.
But unfortunately when I need it, it refuses to insert the text from
time to time, which is really annoying. So I wrote something really
simple for myself and I tried to make it work with the existing kill
yank facility in Emacs. I think new features can be easily added.
I posted the code here: http://paste.lisp.org/display/96565
> Stefan
Cheers,
Leo
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-18 18:39 ` Leo
@ 2010-03-18 19:37 ` joakim
0 siblings, 0 replies; 40+ messages in thread
From: joakim @ 2010-03-18 19:37 UTC (permalink / raw)
To: Leo; +Cc: Stefan Monnier, Emacs development discussions
Leo <sdl.web@gmail.com> writes:
> On 2010-03-18 14:06 +0000, Stefan Monnier wrote:
>>> I find browse-kill-ring very convenient.
>>> It cleverly advices m-y so if its run before any preceding yank, it
>>> shows the contents of the kill-ring and the user can select one entry to
>>> be yanked.
>>> Could something like this be included in Emacs-24? I feel it would be
>>> useful to newcomers (and old-timers with bad short-term memory like me)
>>
>> I think it's indeed a very nice feature. I end up not using it much,
>> but at least it seems like a natural use for M-y.
>>
>> OTOH the few times I've used it I wished it use a form of completion.
>> Basically, I'd like it to use an interface similar to completing-read,
>> except maybe that it'd bring up the *Completions* buffer right away (and
>> that the completion would use a substring search).
>>
>> So I think if we want to enable such a feature by default, it'd need to
>> be better integrated with the completion code.
>
> I think at least it should be built on top of ewoc. It seems like a
> natural choice.
>
> I have been using b-k-r for around 2 years, at least keeping it around.
> But unfortunately when I need it, it refuses to insert the text from
> time to time, which is really annoying. So I wrote something really
I think this happens because b-k-r doesnt wash away overlays. For
instance, when killing a text containing a button, that button is still
active in the b-k-r buffer. That ought to be fixable.
That said, I dont have any particular preference on the implementation
used in the end.
> simple for myself and I tried to make it work with the existing kill
> yank facility in Emacs. I think new features can be easily added.
>
> I posted the code here: http://paste.lisp.org/display/96565
Looks nice!
>
>> Stefan
>
> Cheers,
> Leo
--
Joakim Verona
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-18 14:06 ` Stefan Monnier
2010-03-18 18:39 ` Leo
@ 2010-03-24 9:34 ` Juri Linkov
2010-03-24 13:54 ` Stefan Monnier
2010-03-25 16:49 ` Drew Adams
1 sibling, 2 replies; 40+ messages in thread
From: Juri Linkov @ 2010-03-24 9:34 UTC (permalink / raw)
To: Stefan Monnier; +Cc: joakim, Emacs development discussions
> OTOH the few times I've used it I wished it use a form of completion.
> Basically, I'd like it to use an interface similar to completing-read,
> except maybe that it'd bring up the *Completions* buffer right away (and
> that the completion would use a substring search).
>
> So I think if we want to enable such a feature by default, it'd need to
> be better integrated with the completion code.
And please also add an ability to search for a regexp in completions
of the kill-ring.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-24 9:34 ` Juri Linkov
@ 2010-03-24 13:54 ` Stefan Monnier
2010-03-25 7:04 ` Juri Linkov
2010-03-25 17:29 ` kill-ring visualization Juri Linkov
2010-03-25 16:49 ` Drew Adams
1 sibling, 2 replies; 40+ messages in thread
From: Stefan Monnier @ 2010-03-24 13:54 UTC (permalink / raw)
To: Juri Linkov; +Cc: joakim, Emacs development discussions
>> OTOH the few times I've used it I wished it use a form of completion.
>> Basically, I'd like it to use an interface similar to completing-read,
>> except maybe that it'd bring up the *Completions* buffer right away (and
>> that the completion would use a substring search).
>>
>> So I think if we want to enable such a feature by default, it'd need to
>> be better integrated with the completion code.
> And please also add an ability to search for a regexp in completions
> of the kill-ring.
If you use a `substring' style completion, you're already closer (tho
it's not a regexp-search).
Stefan
PS: I do not know how to do regexp-style completion, to tell you the
truth. I.e. I know how to implement the all-completions part of it,
obviously, but I don't know how to then merge the matches into something
suitable for try-complétion. I guess you could just apply
try-completion to the list of matches, but that would only lead to
something useful if the matches share some prefix.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-24 13:54 ` Stefan Monnier
@ 2010-03-25 7:04 ` Juri Linkov
2010-03-25 9:47 ` Thierry Volpiatto
2010-03-26 2:00 ` regexp completion (was: kill-ring visualization) Stefan Monnier
2010-03-25 17:29 ` kill-ring visualization Juri Linkov
1 sibling, 2 replies; 40+ messages in thread
From: Juri Linkov @ 2010-03-25 7:04 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs development discussions
> PS: I do not know how to do regexp-style completion, to tell you the
> truth. I.e. I know how to implement the all-completions part of it,
> obviously, but I don't know how to then merge the matches into something
> suitable for try-completion. I guess you could just apply
> try-completion to the list of matches, but that would only lead to
> something useful if the matches share some prefix.
Currently a `*' in the completion string acts as the simplest regexp
(wildcard), and it does its job pretty well. Couldn't this be extended
to the true regular expressions?
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-25 7:04 ` Juri Linkov
@ 2010-03-25 9:47 ` Thierry Volpiatto
2010-03-25 10:13 ` joakim
2010-03-26 2:00 ` regexp completion (was: kill-ring visualization) Stefan Monnier
1 sibling, 1 reply; 40+ messages in thread
From: Thierry Volpiatto @ 2010-03-25 9:47 UTC (permalink / raw)
To: emacs-devel
Juri Linkov <juri@jurta.org> writes:
>> PS: I do not know how to do regexp-style completion, to tell you the
>> truth. I.e. I know how to implement the all-completions part of it,
>> obviously, but I don't know how to then merge the matches into something
>> suitable for try-completion. I guess you could just apply
>> try-completion to the list of matches, but that would only lead to
>> something useful if the matches share some prefix.
>
> Currently a `*' in the completion string acts as the simplest regexp
> (wildcard), and it does its job pretty well. Couldn't this be extended
> to the true regular expressions?
Actually, anything have a source to browse killring.
I use it always, it's very nice.
However, you could reuse the code of bookmark-bmenu-search (see
bookmark.el) as interface for kill ring to mimic what anything does.
You will narrow down killring list when typing.
See also ioccur.el:
http://mercurial.intuxication.org/hg/ioccur
That use same technique.
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-25 9:47 ` Thierry Volpiatto
@ 2010-03-25 10:13 ` joakim
2010-03-25 10:20 ` Thierry Volpiatto
0 siblings, 1 reply; 40+ messages in thread
From: joakim @ 2010-03-25 10:13 UTC (permalink / raw)
To: Thierry Volpiatto; +Cc: emacs-devel
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
> Juri Linkov <juri@jurta.org> writes:
>
>>> PS: I do not know how to do regexp-style completion, to tell you the
>>> truth. I.e. I know how to implement the all-completions part of it,
>>> obviously, but I don't know how to then merge the matches into something
>>> suitable for try-completion. I guess you could just apply
>>> try-completion to the list of matches, but that would only lead to
>>> something useful if the matches share some prefix.
>>
>> Currently a `*' in the completion string acts as the simplest regexp
>> (wildcard), and it does its job pretty well. Couldn't this be extended
>> to the true regular expressions?
>
> Actually, anything have a source to browse killring.
> I use it always, it's very nice.
> However, you could reuse the code of bookmark-bmenu-search (see
> bookmark.el) as interface for kill ring to mimic what anything does.
> You will narrow down killring list when typing.
>
Nice I didnt know that. I use Anything all the time as well. Could
Anything be included in Emacs?
> See also ioccur.el:
> http://mercurial.intuxication.org/hg/ioccurThat use same technique.
--
Joakim Verona
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-25 10:13 ` joakim
@ 2010-03-25 10:20 ` Thierry Volpiatto
2010-03-25 13:56 ` anything.el inclusion (was: kill-ring visualization) Ted Zlatanov
0 siblings, 1 reply; 40+ messages in thread
From: Thierry Volpiatto @ 2010-03-25 10:20 UTC (permalink / raw)
To: joakim; +Cc: emacs-devel
joakim@verona.se writes:
> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>> Juri Linkov <juri@jurta.org> writes:
>>
>>>> PS: I do not know how to do regexp-style completion, to tell you the
>>>> truth. I.e. I know how to implement the all-completions part of it,
>>>> obviously, but I don't know how to then merge the matches into something
>>>> suitable for try-completion. I guess you could just apply
>>>> try-completion to the list of matches, but that would only lead to
>>>> something useful if the matches share some prefix.
>>>
>>> Currently a `*' in the completion string acts as the simplest regexp
>>> (wildcard), and it does its job pretty well. Couldn't this be extended
>>> to the true regular expressions?
>>
>> Actually, anything have a source to browse killring.
>> I use it always, it's very nice.
>> However, you could reuse the code of bookmark-bmenu-search (see
>> bookmark.el) as interface for kill ring to mimic what anything does.
>> You will narrow down killring list when typing.
>>
>
> Nice I didnt know that. I use Anything all the time as well.
You will find other useful things in anything-config.el.
http://repo.or.cz/w/anything-config.git
> Could Anything be included in Emacs?
Would be great!
>> See also ioccur.el:
>> http://mercurial.intuxication.org/hg/ioccurThat use same technique.
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
^ permalink raw reply [flat|nested] 40+ messages in thread
* anything.el inclusion (was: kill-ring visualization)
2010-03-25 10:20 ` Thierry Volpiatto
@ 2010-03-25 13:56 ` Ted Zlatanov
2010-03-25 17:28 ` anything.el inclusion Juri Linkov
0 siblings, 1 reply; 40+ messages in thread
From: Ted Zlatanov @ 2010-03-25 13:56 UTC (permalink / raw)
To: emacs-devel
On Thu, 25 Mar 2010 11:20:50 +0100 Thierry Volpiatto <thierry.volpiatto@gmail.com> wrote:
TV> joakim@verona.se writes:
>> Could Anything be included in Emacs?
TV> Would be great!
I'd be in favor of including anything.el as well. I use it all the time.
Ted
^ permalink raw reply [flat|nested] 40+ messages in thread
* RE: kill-ring visualization
2010-03-24 9:34 ` Juri Linkov
2010-03-24 13:54 ` Stefan Monnier
@ 2010-03-25 16:49 ` Drew Adams
1 sibling, 0 replies; 40+ messages in thread
From: Drew Adams @ 2010-03-25 16:49 UTC (permalink / raw)
To: 'Juri Linkov', 'Stefan Monnier'
Cc: joakim, 'Emacs development discussions'
> >> shows the contents of the kill-ring and
> >> the user can select one entry to be yanked.
> >
> > I'd like it to use an interface similar to completing-read
>
> And please also add an ability to search for a regexp in completions
> of the kill-ring.
FWIW, this has been available in Icicles since 2006. With a negative prefix arg,
`C-y' lets you complete against the kill-ring.
This includes regexp matching, combining multiple match patterns, and completing
to the matches complement.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-25 13:56 ` anything.el inclusion (was: kill-ring visualization) Ted Zlatanov
@ 2010-03-25 17:28 ` Juri Linkov
2010-03-26 6:37 ` Thierry Volpiatto
2010-03-26 17:09 ` Ted Zlatanov
0 siblings, 2 replies; 40+ messages in thread
From: Juri Linkov @ 2010-03-25 17:28 UTC (permalink / raw)
To: Ted Zlatanov; +Cc: emacs-devel
> Could Anything be included in Emacs?
I think its "configs" would be good to have in Emacs
to use in completions.
However, its UI is non-standard and inconvenient.
You have to add the `anything-' prefix to every command,
i.e. to use `anything-write-file' instead of `write-file',
`anything-insert-file' instead of `insert-file', etc.
It would be better to display its "completions" buffer
from the minibuffer of existing commands.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-24 13:54 ` Stefan Monnier
2010-03-25 7:04 ` Juri Linkov
@ 2010-03-25 17:29 ` Juri Linkov
2010-03-26 2:53 ` Stefan Monnier
1 sibling, 1 reply; 40+ messages in thread
From: Juri Linkov @ 2010-03-25 17:29 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs development discussions
> If you use a `substring' style completion, you're already closer (tho
> it's not a regexp-search).
Is the below what you mean?
I remember there were requests to reuse M-y to complete on the kill-ring
instead of signalling an error that the previous command was not a yank.
=== modified file 'lisp/simple.el'
--- lisp/simple.el 2010-03-23 23:25:12 +0000
+++ lisp/simple.el 2010-03-25 17:29:27 +0000
@@ -3216,9 +3216,21 @@ (defun yank-pop (&optional arg)
When this command inserts killed text into the buffer, it honors
`yank-excluded-properties' and `yank-handler' as described in the
doc string for `insert-for-yank-1', which see."
- (interactive "*p")
+ (interactive
+ (list
+ (if (not (eq last-command 'yank))
+ (let ((completion-styles '(substring)))
+ (completing-read "Yank from kill-ring: " kill-ring))
+ (barf-if-buffer-read-only)
+ current-prefix-arg)))
+
(if (not (eq last-command 'yank))
- (error "Previous command was not a yank"))
+ (yank (mod (abs (- (length (member arg kill-ring))
+ (length kill-ring-yank-pointer)
+ 1))
+ (length kill-ring)))
+
+ ;; Otherwise, if last-command eq 'yank.
(setq this-command 'yank)
(unless arg (setq arg 1))
(let ((inhibit-read-only t)
@@ -3238,7 +3250,8 @@ (defun yank-pop (&optional arg)
;; loop would deactivate the mark because we inserted text.
(goto-char (prog1 (mark t)
(set-marker (mark-marker) (point) (current-buffer))))))
- nil)
+ nil))
+
(defun yank (&optional arg)
"Reinsert (\"paste\") the last stretch of killed text.
PS: This patch is for the demonstration, not for installation.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 40+ messages in thread
* regexp completion (was: kill-ring visualization)
2010-03-25 7:04 ` Juri Linkov
2010-03-25 9:47 ` Thierry Volpiatto
@ 2010-03-26 2:00 ` Stefan Monnier
1 sibling, 0 replies; 40+ messages in thread
From: Stefan Monnier @ 2010-03-26 2:00 UTC (permalink / raw)
To: Juri Linkov; +Cc: Emacs development discussions
>> PS: I do not know how to do regexp-style completion, to tell you the
>> truth. I.e. I know how to implement the all-completions part of it,
>> obviously, but I don't know how to then merge the matches into something
>> suitable for try-completion. I guess you could just apply
>> try-completion to the list of matches, but that would only lead to
>> something useful if the matches share some prefix.
> Currently a `*' in the completion string acts as the simplest regexp
> (wildcard), and it does its job pretty well. Couldn't this be extended
> to the true regular expressions?
It probably could, but I don't know *how*. But maybe it's because I'd
want it to do something more than what it can. I.e. maybe the "trivial"
answer is pretty much the only answer.
Stefan
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-25 17:29 ` kill-ring visualization Juri Linkov
@ 2010-03-26 2:53 ` Stefan Monnier
2010-03-26 7:09 ` Juri Linkov
0 siblings, 1 reply; 40+ messages in thread
From: Stefan Monnier @ 2010-03-26 2:53 UTC (permalink / raw)
To: Juri Linkov; +Cc: Emacs development discussions
>> 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,
Stefan
--- lisp/simple.el 2010-02-16 14:40:45 +0000
+++ lisp/simple.el 2010-03-24 14:52:19 +0000
@@ -3115,7 +3197,7 @@
doc string for `insert-for-yank-1', which see."
(interactive "*p")
(if (not (eq last-command 'yank))
- (error "Previous command was not a yank"))
+ (call-interactively 'yank-browse)
(setq this-command 'yank)
(unless arg (setq arg 1))
(let ((inhibit-read-only t)
@@ -3135,7 +3217,7 @@
;; loop would deactivate the mark because we inserted text.
(goto-char (prog1 (mark t)
(set-marker (mark-marker) (point) (current-buffer))))))
- nil)
+ nil))
(defun yank (&optional arg)
"Reinsert (\"paste\") the last stretch of killed text.
@@ -3171,6 +3257,23 @@
(setq this-command 'yank))
nil)
+(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.
+ (minibuffer-completion-help))
+ (let* ((kills (delete-dups (append kill-ring-yank-pointer kill-ring)))
+ (entry (completing-read "Yank: " kills nil t))
+ )
+ (setq this-command 'yank)
+ (insert-for-yank entry))))
+
+
(defun rotate-yank-pointer (arg)
"Rotate the yanking point in the kill ring.
With ARG, rotate that many kills forward (or backward, if negative)."
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-25 17:28 ` anything.el inclusion Juri Linkov
@ 2010-03-26 6:37 ` Thierry Volpiatto
2010-03-26 7:01 ` Juri Linkov
2010-03-26 17:09 ` Ted Zlatanov
1 sibling, 1 reply; 40+ messages in thread
From: Thierry Volpiatto @ 2010-03-26 6:37 UTC (permalink / raw)
To: emacs-devel
Juri Linkov <juri@jurta.org> writes:
>> Could Anything be included in Emacs?
>
> I think its "configs" would be good to have in Emacs
> to use in completions.
What do you mean by "configs"?
> However, its UI is non-standard and inconvenient.
What is inconvenient in anything commands?
> You have to add the `anything-' prefix to every command,
> i.e. to use `anything-write-file' instead of `write-file',
> `anything-insert-file' instead of `insert-file', etc.
It seem you are speaking of file completion of anything-config, as it is
part of anything, it must have `anything-' prefix no?, or may be i don't
understand what you mean.
> It would be better to display its "completions" buffer
> from the minibuffer of existing commands.
The goal of anything completion (for files) is to stay in the anything
loop without going out, a regular use of minibuffer will complete on one
search and then exit.
Actually with anything-find-files you can navigate in all you system
file with completion without quitting anything and without opening any dired
buffers.
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-26 6:37 ` Thierry Volpiatto
@ 2010-03-26 7:01 ` Juri Linkov
2010-03-26 7:22 ` Thierry Volpiatto
0 siblings, 1 reply; 40+ messages in thread
From: Juri Linkov @ 2010-03-26 7:01 UTC (permalink / raw)
To: Thierry Volpiatto; +Cc: emacs-devel
>> I think its "configs" would be good to have in Emacs
>> to use in completions.
> What do you mean by "configs"?
Predefined configurations for `anything.el'.
>> You have to add the `anything-' prefix to every command,
>> i.e. to use `anything-write-file' instead of `write-file',
>> `anything-insert-file' instead of `insert-file', etc.
> It seem you are speaking of file completion of anything-config, as it is
> part of anything, it must have `anything-' prefix no?, or may be i don't
> understand what you mean.
I mean these completions would be useful for standard existing
commands as well.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-26 2:53 ` Stefan Monnier
@ 2010-03-26 7:09 ` Juri Linkov
2010-03-26 20:17 ` Stefan Monnier
0 siblings, 1 reply; 40+ messages in thread
From: Juri Linkov @ 2010-03-26 7:09 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs development discussions
>>> 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/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-26 7:01 ` Juri Linkov
@ 2010-03-26 7:22 ` Thierry Volpiatto
2010-03-26 20:19 ` Stefan Monnier
0 siblings, 1 reply; 40+ messages in thread
From: Thierry Volpiatto @ 2010-03-26 7:22 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
Juri Linkov <juri@jurta.org> writes:
>>> I think its "configs" would be good to have in Emacs
>>> to use in completions.
>> What do you mean by "configs"?
>
> Predefined configurations for `anything.el'.
Ok.
Configurations for anything.el are (mostly) in anything-config.el.
>>> You have to add the `anything-' prefix to every command,
>>> i.e. to use `anything-write-file' instead of `write-file',
>>> `anything-insert-file' instead of `insert-file', etc.
>> It seem you are speaking of file completion of anything-config, as it is
>> part of anything, it must have `anything-' prefix no?, or may be i don't
>> understand what you mean.
>
> I mean these completions would be useful for standard existing
> commands as well.
Yes, i agree, but they need anything system to be dynamic, standard
emacs commands use static completion (one shot completion, no timer).
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-25 17:28 ` anything.el inclusion Juri Linkov
2010-03-26 6:37 ` Thierry Volpiatto
@ 2010-03-26 17:09 ` Ted Zlatanov
2010-03-27 19:38 ` Juri Linkov
1 sibling, 1 reply; 40+ messages in thread
From: Ted Zlatanov @ 2010-03-26 17:09 UTC (permalink / raw)
To: emacs-devel
On Thu, 25 Mar 2010 19:28:10 +0200 Juri Linkov <juri@jurta.org> wrote:
>> Could Anything be included in Emacs?
JL> I think its "configs" would be good to have in Emacs to use in
JL> completions.
...or at least something like them. There are many anything-* configs
that don't belong in Emacs, but the basic engine is useful.
JL> However, its UI is non-standard and inconvenient. You have to add
JL> the `anything-' prefix to every command, i.e. to use
JL> `anything-write-file' instead of `write-file',
JL> `anything-insert-file' instead of `insert-file', etc.
JL> It would be better to display its "completions" buffer from the
JL> minibuffer of existing commands.
What needs to happen for inclusion of anything.el by itself, in your
opinion? Stefan or Yidong, do you have any requirements?
Ted
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-26 7:09 ` Juri Linkov
@ 2010-03-26 20:17 ` Stefan Monnier
2010-03-27 19:42 ` Juri Linkov
0 siblings, 1 reply; 40+ messages in thread
From: Stefan Monnier @ 2010-03-26 20:17 UTC (permalink / raw)
To: Juri Linkov; +Cc: Emacs development discussions
> This requires implementing a new option in `completions-format'
> and let-binding it in `yank-browse'.
let-binding is not a good option, because if you use recursive
minibuffers, this let-binding can end up affecting unrelated completions.
Also, to tell you the truth, I'd want this format to be specified by the
completion table rather than by the code calling the completing-read.
> + ((eq completions-format 'line)
> + ;; One-line format
> + (setq str (query-replace-descr str)))
But this will not just change the string displayed, but also the string
inserted by the yank. We need to distinguish the two.
Stefan
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-26 7:22 ` Thierry Volpiatto
@ 2010-03-26 20:19 ` Stefan Monnier
2010-03-29 18:32 ` Ted Zlatanov
0 siblings, 1 reply; 40+ messages in thread
From: Stefan Monnier @ 2010-03-26 20:19 UTC (permalink / raw)
To: Thierry Volpiatto; +Cc: Juri Linkov, emacs-devel
>> I mean these completions would be useful for standard existing
>> commands as well.
> Yes, i agree, but they need anything system to be dynamic, standard
> emacs commands use static completion (one shot completion, no timer).
I don't really know what you guys are talking about. Can someone give
an example of what behavior is under discussion here?
Stefan
PS: No objection to including anything.el from me.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-26 17:09 ` Ted Zlatanov
@ 2010-03-27 19:38 ` Juri Linkov
2010-03-27 21:35 ` Johan Busk Eriksson
` (2 more replies)
0 siblings, 3 replies; 40+ messages in thread
From: Juri Linkov @ 2010-03-27 19:38 UTC (permalink / raw)
To: Ted Zlatanov; +Cc: emacs-devel
> What needs to happen for inclusion of anything.el by itself,
> in your opinion?
What do you think about the following idea for package.el?
To every package handled by package.el add a new parameter that tracks
the package's "popularity". This could mean either the number of
downloads from the server that hosts these packages, or to add UI
where users would be able to vote for a package.
Then we could sort all available packages by popularity in package.el UI,
so the top packages are objective candidates for inclusion in Emacs.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-26 20:17 ` Stefan Monnier
@ 2010-03-27 19:42 ` Juri Linkov
2010-03-27 20:37 ` Stefan Monnier
0 siblings, 1 reply; 40+ messages in thread
From: Juri Linkov @ 2010-03-27 19:42 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs development discussions
>> This requires implementing a new option in `completions-format'
>> and let-binding it in `yank-browse'.
>
> let-binding is not a good option, because if you use recursive
> minibuffers, this let-binding can end up affecting unrelated completions.
Thanks, I see now that it should be (mini)buffer-local.
> Also, to tell you the truth, I'd want this format to be specified by the
> completion table rather than by the code calling the completing-read.
If this means dropping `completion--insert-strings',
then I don't see benefits of doing that.
>> + ((eq completions-format 'line)
>> + ;; One-line format
>> + (setq str (query-replace-descr str)))
>
> But this will not just change the string displayed, but also the string
> inserted by the yank. We need to distinguish the two.
Maybe to put the `display' property with the value "^J" on newlines?
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-27 19:42 ` Juri Linkov
@ 2010-03-27 20:37 ` Stefan Monnier
2010-03-30 16:07 ` Juri Linkov
0 siblings, 1 reply; 40+ messages in thread
From: Stefan Monnier @ 2010-03-27 20:37 UTC (permalink / raw)
To: Juri Linkov; +Cc: Emacs development discussions
>> Also, to tell you the truth, I'd want this format to be specified by the
>> completion table rather than by the code calling the completing-read.
> If this means dropping `completion--insert-strings',
> then I don't see benefits of doing that.
I don't see why you'd think there should be such a connection.
>>> + ((eq completions-format 'line)
>>> + ;; One-line format
>>> + (setq str (query-replace-descr str)))
>> But this will not just change the string displayed, but also the string
>> inserted by the yank. We need to distinguish the two.
> Maybe to put the `display' property with the value "^J" on newlines?
That would only work if this property is removed when the string in
subsequently inserted.
Stefan
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-27 19:38 ` Juri Linkov
@ 2010-03-27 21:35 ` Johan Busk Eriksson
2010-03-28 7:58 ` Yoni Rabkin
2010-03-29 18:25 ` Ted Zlatanov
2 siblings, 0 replies; 40+ messages in thread
From: Johan Busk Eriksson @ 2010-03-27 21:35 UTC (permalink / raw)
To: Juri Linkov; +Cc: Ted Zlatanov, emacs-devel
At Sat, 27 Mar 2010 21:38:52 +0200,
Juri Linkov wrote:
>
> > What needs to happen for inclusion of anything.el by itself,
> > in your opinion?
>
> What do you think about the following idea for package.el?
>
> To every package handled by package.el add a new parameter that tracks
> the package's "popularity". This could mean either the number of
> downloads from the server that hosts these packages, or to add UI
> where users would be able to vote for a package.
>
> Then we could sort all available packages by popularity in package.el UI,
> so the top packages are objective candidates for inclusion in Emacs.
>
> --
> Juri Linkov
> http://www.jurta.org/emacs/
>
>
A popularity contest? Please let me opt-out of that.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-27 19:38 ` Juri Linkov
2010-03-27 21:35 ` Johan Busk Eriksson
@ 2010-03-28 7:58 ` Yoni Rabkin
2010-03-28 17:39 ` joakim
2010-03-29 18:25 ` Ted Zlatanov
2 siblings, 1 reply; 40+ messages in thread
From: Yoni Rabkin @ 2010-03-28 7:58 UTC (permalink / raw)
To: emacs-devel
Juri Linkov <juri@jurta.org> writes:
>> What needs to happen for inclusion of anything.el by itself,
>> in your opinion?
>
> What do you think about the following idea for package.el?
>
> To every package handled by package.el add a new parameter that tracks
> the package's "popularity". This could mean either the number of
> downloads from the server that hosts these packages, or to add UI
> where users would be able to vote for a package.
>
> Then we could sort all available packages by popularity in package.el UI,
> so the top packages are objective candidates for inclusion in Emacs.
This is the exact kind of of thinking that makes me want to avoid any
centralized system such as package.el. Centralized systems like these
makes people start thinking of all kinds of "benefits" the centralized
system can bestow on users without the users ever asking for them (or
knowing they exist).
--
"Cut your own wood and it will warm you twice"
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-28 7:58 ` Yoni Rabkin
@ 2010-03-28 17:39 ` joakim
0 siblings, 0 replies; 40+ messages in thread
From: joakim @ 2010-03-28 17:39 UTC (permalink / raw)
To: Yoni Rabkin; +Cc: emacs-devel
Yoni Rabkin <yoni@rabkins.net> writes:
> Juri Linkov <juri@jurta.org> writes:
>
>>> What needs to happen for inclusion of anything.el by itself,
>>> in your opinion?
>>
>> What do you think about the following idea for package.el?
>>
>> To every package handled by package.el add a new parameter that tracks
>> the package's "popularity". This could mean either the number of
>> downloads from the server that hosts these packages, or to add UI
>> where users would be able to vote for a package.
>>
>> Then we could sort all available packages by popularity in package.el UI,
>> so the top packages are objective candidates for inclusion in Emacs.
>
> This is the exact kind of of thinking that makes me want to avoid any
> centralized system such as package.el. Centralized systems like these
> makes people start thinking of all kinds of "benefits" the centralized
> system can bestow on users without the users ever asking for them (or
> knowing they exist).
I havent seen any such tendency with the distribution specific
repositories I have used (Fedora, Debian, Suse)
--
Joakim Verona
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-27 19:38 ` Juri Linkov
2010-03-27 21:35 ` Johan Busk Eriksson
2010-03-28 7:58 ` Yoni Rabkin
@ 2010-03-29 18:25 ` Ted Zlatanov
2 siblings, 0 replies; 40+ messages in thread
From: Ted Zlatanov @ 2010-03-29 18:25 UTC (permalink / raw)
To: emacs-devel
On Sat, 27 Mar 2010 21:38:52 +0200 Juri Linkov <juri@jurta.org> wrote:
JL> What do you think about the following idea for package.el?
JL> To every package handled by package.el add a new parameter that tracks
JL> the package's "popularity". This could mean either the number of
JL> downloads from the server that hosts these packages, or to add UI
JL> where users would be able to vote for a package.
JL> Then we could sort all available packages by popularity in package.el UI,
JL> so the top packages are objective candidates for inclusion in Emacs.
A package "score" could be useful. But it should not be based on
popularity, it's better to simply listen to what people want in mailing
lists, on the Emacs Wiki, etc. So I'm not opposed to scores but they
should be optional and curated by each repository's maintainer.
If the maintainer chooses to use popularity as the only score component,
that's their choice.
On Sun, 28 Mar 2010 10:58:14 +0300 Yoni Rabkin <yoni@rabkins.net> wrote:
YR> This is the exact kind of of thinking that makes me want to avoid any
YR> centralized system such as package.el. Centralized systems like these
YR> makes people start thinking of all kinds of "benefits" the centralized
YR> system can bestow on users without the users ever asking for them (or
YR> knowing they exist).
package.el will not be centralized in the form that goes into Emacs.
On Sat, 27 Mar 2010 22:35:46 +0100 Johan Busk Eriksson <busk@lysator.liu.se> wrote:
JBE> A popularity contest? Please let me opt-out of that.
I don't think package.el should be the agent to generate popularity
scores. If the repository maintainer wants them, he can analyze the
server logs.
Ted
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-26 20:19 ` Stefan Monnier
@ 2010-03-29 18:32 ` Ted Zlatanov
2010-03-29 19:34 ` Thierry Volpiatto
2010-04-03 13:53 ` Stefan Monnier
0 siblings, 2 replies; 40+ messages in thread
From: Ted Zlatanov @ 2010-03-29 18:32 UTC (permalink / raw)
To: emacs-devel; +Cc: thierry.volpiatto
On Fri, 26 Mar 2010 16:19:37 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:
>>> I mean these completions would be useful for standard existing
>>> commands as well.
>> Yes, i agree, but they need anything system to be dynamic, standard
>> emacs commands use static completion (one shot completion, no timer).
SM> I don't really know what you guys are talking about. Can someone give
SM> an example of what behavior is under discussion here?
Ditto, I don't know the anything.el internals well enough. As a user I
find it very valuable but I haven't even written a anything-* source,
only configured existing ones.
SM> PS: No objection to including anything.el from me.
It lives at http://www.emacswiki.org/emacs/Anything
According to that page, Tassilo Horn, Jason McBrayer, rubikitch and
Thierry Volpiatto maintain the anything-config repository. They would
probably be the best group to put together a version of anything.el
suitable for inclusion and to propose a list of anything-config sources
that the Emacs maintainers can pick from.
rubikitch or Thierry, are you interested in doing this?
Ted
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-29 18:32 ` Ted Zlatanov
@ 2010-03-29 19:34 ` Thierry Volpiatto
2010-04-03 5:44 ` Thierry Volpiatto
2010-04-03 13:53 ` Stefan Monnier
1 sibling, 1 reply; 40+ messages in thread
From: Thierry Volpiatto @ 2010-03-29 19:34 UTC (permalink / raw)
To: emacs-devel
Ted Zlatanov <tzz@lifelogs.com> writes:
> On Fri, 26 Mar 2010 16:19:37 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:
>
>>>> I mean these completions would be useful for standard existing
>>>> commands as well.
>>> Yes, i agree, but they need anything system to be dynamic, standard
>>> emacs commands use static completion (one shot completion, no timer).
>
> SM> I don't really know what you guys are talking about. Can someone give
> SM> an example of what behavior is under discussion here?
>
> Ditto, I don't know the anything.el internals well enough. As a user I
> find it very valuable but I haven't even written a anything-* source,
> only configured existing ones.
>
> SM> PS: No objection to including anything.el from me.
>
> It lives at http://www.emacswiki.org/emacs/Anything
>
> According to that page, Tassilo Horn, Jason McBrayer, rubikitch and
> Thierry Volpiatto maintain the anything-config repository. They would
> probably be the best group to put together a version of anything.el
> suitable for inclusion and to propose a list of anything-config sources
> that the Emacs maintainers can pick from.
>
> rubikitch or Thierry, are you interested in doing this?
No problems for me.
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-27 20:37 ` Stefan Monnier
@ 2010-03-30 16:07 ` Juri Linkov
2010-03-30 20:35 ` Stefan Monnier
0 siblings, 1 reply; 40+ messages in thread
From: Juri Linkov @ 2010-03-30 16:07 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs development discussions
>>>> + ((eq completions-format 'line)
>>>> + ;; One-line format
>>>> + (setq str (query-replace-descr str)))
>>> But this will not just change the string displayed, but also the string
>>> inserted by the yank. We need to distinguish the two.
>> Maybe to put the `display' property with the value "^J" on newlines?
>
> That would only work if this property is removed when the string in
> subsequently inserted.
In the patch I sent earlier, yank-pop doesn't insert the string selected
from the *Completions* buffer. It searches for selected completion string
in the kill-ring (using `member' that ignores the `display' property),
gets its position in the kill-ring, and calls `yank' with this position
as a numeric index.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-30 16:07 ` Juri Linkov
@ 2010-03-30 20:35 ` Stefan Monnier
2010-03-31 15:04 ` Juri Linkov
0 siblings, 1 reply; 40+ messages in thread
From: Stefan Monnier @ 2010-03-30 20:35 UTC (permalink / raw)
To: Juri Linkov; +Cc: Emacs development discussions
>>>>> + ((eq completions-format 'line)
>>>>> + ;; One-line format
>>>>> + (setq str (query-replace-descr str)))
>>>> But this will not just change the string displayed, but also the string
>>>> inserted by the yank. We need to distinguish the two.
>>> Maybe to put the `display' property with the value "^J" on newlines?
>> That would only work if this property is removed when the string in
>> subsequently inserted.
> In the patch I sent earlier, yank-pop doesn't insert the string selected
> from the *Completions* buffer. It searches for selected completion string
> in the kill-ring (using `member' that ignores the `display' property),
> gets its position in the kill-ring, and calls `yank' with this position
> as a numeric index.
Yes, I noticed it, and the problem is that my yank happens to be advised
and that breaks it (because the advice occasionally adds elements to
the kill-ring).
So, while I also started with such an approach, I ended up going the
more straightforward route of inserting the actual selected text, since
it's more reliable.
Stefan
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: kill-ring visualization
2010-03-30 20:35 ` Stefan Monnier
@ 2010-03-31 15:04 ` Juri Linkov
0 siblings, 0 replies; 40+ messages in thread
From: Juri Linkov @ 2010-03-31 15:04 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs development discussions
>> In the patch I sent earlier, yank-pop doesn't insert the string selected
>> from the *Completions* buffer. It searches for selected completion string
>> in the kill-ring (using `member' that ignores the `display' property),
>> gets its position in the kill-ring, and calls `yank' with this position
>> as a numeric index.
>
> Yes, I noticed it, and the problem is that my yank happens to be advised
> and that breaks it (because the advice occasionally adds elements to
> the kill-ring).
>
> So, while I also started with such an approach, I ended up going the
> more straightforward route of inserting the actual selected text, since
> it's more reliable.
`yank' and `yank-pop' use `current-kill' to rotate the yanking pointer
in the kill ring.
But maybe `yank-browse' should have its own yanking pointer?
For instance, with the kill ring having the value:
'("string1" "foo" "string2" "bar" "string3")
this scenario would be useful:
M-y str RET ;; the user types a substring "str" in the minibuffer
;; and RET inserts "string1" to the current buffer
M-y ;; reinserts "string2" to the current buffer
M-y ;; reinserts "string3" to the current buffer
M-y ;; reinserts "string1" to the current buffer
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-29 19:34 ` Thierry Volpiatto
@ 2010-04-03 5:44 ` Thierry Volpiatto
0 siblings, 0 replies; 40+ messages in thread
From: Thierry Volpiatto @ 2010-04-03 5:44 UTC (permalink / raw)
To: emacs-devel
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
> Ted Zlatanov <tzz@lifelogs.com> writes:
>
>> On Fri, 26 Mar 2010 16:19:37 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:
>>
>>>>> I mean these completions would be useful for standard existing
>>>>> commands as well.
>>>> Yes, i agree, but they need anything system to be dynamic, standard
>>>> emacs commands use static completion (one shot completion, no timer).
>>
>> SM> I don't really know what you guys are talking about. Can someone give
>> SM> an example of what behavior is under discussion here?
>>
>> Ditto, I don't know the anything.el internals well enough. As a user I
>> find it very valuable but I haven't even written a anything-* source,
>> only configured existing ones.
>>
>> SM> PS: No objection to including anything.el from me.
>>
>> It lives at http://www.emacswiki.org/emacs/Anything
>>
>> According to that page, Tassilo Horn, Jason McBrayer, rubikitch and
>> Thierry Volpiatto maintain the anything-config repository. They would
>> probably be the best group to put together a version of anything.el
>> suitable for inclusion and to propose a list of anything-config sources
>> that the Emacs maintainers can pick from.
>>
>> rubikitch or Thierry, are you interested in doing this?
> No problems for me.
Rubikitch have started merging files in anything-config repository, when
files selection in this repo will be finish, you could merge
anything-config repo with Emacs.
What do you need more for anything inclusion ?
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-03-29 18:32 ` Ted Zlatanov
2010-03-29 19:34 ` Thierry Volpiatto
@ 2010-04-03 13:53 ` Stefan Monnier
2010-04-03 14:17 ` Thierry Volpiatto
1 sibling, 1 reply; 40+ messages in thread
From: Stefan Monnier @ 2010-04-03 13:53 UTC (permalink / raw)
To: Ted Zlatanov; +Cc: thierry.volpiatto, emacs-devel
>>>> I mean these completions would be useful for standard existing
>>>> commands as well.
>>> Yes, i agree, but they need anything system to be dynamic, standard
>>> emacs commands use static completion (one shot completion, no timer).
SM> I don't really know what you guys are talking about. Can someone give
SM> an example of what behavior is under discussion here?
> Ditto, I don't know the anything.el internals well enough. As a user I
I'm even more lost: my question was not about internals but about behavior.
Stefan
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-04-03 13:53 ` Stefan Monnier
@ 2010-04-03 14:17 ` Thierry Volpiatto
2010-04-03 19:08 ` Stefan Monnier
0 siblings, 1 reply; 40+ messages in thread
From: Thierry Volpiatto @ 2010-04-03 14:17 UTC (permalink / raw)
To: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>>>> I mean these completions would be useful for standard existing
>>>>> commands as well.
>>>> Yes, i agree, but they need anything system to be dynamic, standard
>>>> emacs commands use static completion (one shot completion, no timer).
> SM> I don't really know what you guys are talking about. Can someone give
> SM> an example of what behavior is under discussion here?
>> Ditto, I don't know the anything.el internals well enough. As a user I
>
> I'm even more lost: my question was not about internals but about behavior.
I think Juri was asking for using the anything filename completion stuff
outside of anything, but it have been build to work with anything, not
with Emacs standard completion system.(See anything-find-files in
anything-config.el)
The real point is the inclusion of the anything framework in Emacs
(anything.el), then, when that is done, emacs developpers will be able to
use it as they want, picking up sources in anything-config.el or using
the actual anything-config.el.(with modification maybe to be more Emacs
compliant)
I suggest integrating in Emacs:
anything.el
anything-config.el
anything-match-plugin.el
these work really well together and provide a lot of features.
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: anything.el inclusion
2010-04-03 14:17 ` Thierry Volpiatto
@ 2010-04-03 19:08 ` Stefan Monnier
0 siblings, 0 replies; 40+ messages in thread
From: Stefan Monnier @ 2010-04-03 19:08 UTC (permalink / raw)
To: Thierry Volpiatto; +Cc: emacs-devel
>> I'm even more lost: my question was not about internals but about behavior.
> I think Juri was asking for using the anything filename completion stuff
> outside of anything, but it have been build to work with anything, not
> with Emacs standard completion system.(See anything-find-files in
> anything-config.el)
There are two sides to this: "use the anything code elsewhere", and
"provide the anything behavior elsewhere". I'd like to hear the second.
Is that more clear?
Stefan
^ permalink raw reply [flat|nested] 40+ messages in thread
end of thread, other threads:[~2010-04-03 19:08 UTC | newest]
Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-18 6:18 kill-ring visualization joakim
2010-03-18 14:06 ` Stefan Monnier
2010-03-18 18:39 ` Leo
2010-03-18 19:37 ` joakim
2010-03-24 9:34 ` Juri Linkov
2010-03-24 13:54 ` Stefan Monnier
2010-03-25 7:04 ` Juri Linkov
2010-03-25 9:47 ` Thierry Volpiatto
2010-03-25 10:13 ` joakim
2010-03-25 10:20 ` Thierry Volpiatto
2010-03-25 13:56 ` anything.el inclusion (was: kill-ring visualization) Ted Zlatanov
2010-03-25 17:28 ` anything.el inclusion Juri Linkov
2010-03-26 6:37 ` Thierry Volpiatto
2010-03-26 7:01 ` Juri Linkov
2010-03-26 7:22 ` Thierry Volpiatto
2010-03-26 20:19 ` Stefan Monnier
2010-03-29 18:32 ` Ted Zlatanov
2010-03-29 19:34 ` Thierry Volpiatto
2010-04-03 5:44 ` Thierry Volpiatto
2010-04-03 13:53 ` Stefan Monnier
2010-04-03 14:17 ` Thierry Volpiatto
2010-04-03 19:08 ` Stefan Monnier
2010-03-26 17:09 ` Ted Zlatanov
2010-03-27 19:38 ` Juri Linkov
2010-03-27 21:35 ` Johan Busk Eriksson
2010-03-28 7:58 ` Yoni Rabkin
2010-03-28 17:39 ` joakim
2010-03-29 18:25 ` Ted Zlatanov
2010-03-26 2:00 ` regexp completion (was: kill-ring visualization) Stefan Monnier
2010-03-25 17:29 ` kill-ring visualization Juri Linkov
2010-03-26 2:53 ` Stefan Monnier
2010-03-26 7:09 ` Juri Linkov
2010-03-26 20:17 ` Stefan Monnier
2010-03-27 19:42 ` Juri Linkov
2010-03-27 20:37 ` Stefan Monnier
2010-03-30 16:07 ` Juri Linkov
2010-03-30 20:35 ` Stefan Monnier
2010-03-31 15:04 ` Juri Linkov
2010-03-25 16:49 ` Drew Adams
2010-03-18 15:16 ` Drew Adams
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).