Coder Social home page Coder Social logo

browse-kill-ring's Introduction

Synopsis

Are you tired of using the endless keystrokes of C-y M-y M-y M-y ... to get at that bit of text you killed thirty-seven kills ago? Ever wish you could just look through everything you've killed recently to find out if you killed that piece of text that you think you killed, but you're not quite sure? If so, then browse-kill-ring is the Emacs extension for you.

Installation

Manual

Just drop browse-kill-ring.el somewhere in your load-path. The folder ~/.emacs.d/vendor is a popular choice:

(add-to-list 'load-path "~/emacs.d/vendor")
(require 'browse-kill-ring)

MELPA

If you're an Emacs 24 user or you have a recent version of package.el you can install browse-kill-ring from the MELPA repository.

el-get

If you prefer el-get, you can install browse-kill-ring with M-x el-get-install.

Emacs Prelude

browse-kill-ring is naturally part of the Emacs Prelude. If you're a Prelude user - browse-kill-ring is already properly configured and ready for action.

Usage

Just do M-x browse-kill-ring.

Optionally, you can map M-y to browse-kill-ring by adding the form (browse-kill-ring-default-keybindings) to your ~/.emacs. Alternatively you can map browse-kill-ring to another key combination, for example (global-set-key "\C-cy" 'browse-kill-ring).

Additional Configuration

The browse-kill-ring package can be customized through the usual emacs customization interface using M-x customize-group <RET> browse-kill-ring <RET>. The following list contains some of the interesting configuration variables:

  • Setting browse-kill-ring-highlight-current-entry to t will cause the item in the *Kill Ring* that will be inserted, to be highlighted.

  • Setting browse-kill-ring-highlight-inserted-item to non-nil will cause the item that has just been inserted to be highlighted. Possible values to which this variable can be set are nil, pulse, solid, or t. The value nil turns highlighting off, the value pulse uses the pulse library from cedet (which is a part of recent emacs versions) to highlight the inserted item then fade the highlighting out over a short period of time. The value solid highlights the inserted item in a fixed face for a short period of time. The value t will use the default style for highlighting the inserted item, this is currently pulse.

  • The variable browse-kill-ring-separator is the string that is placed between items in the *Kill Ring* buffer between entries.

  • The variable browse-kill-ring-separator-face contains the face used for the separator in the *Kill Ring* buffer.

  • Setting browse-kill-ring-show-preview to t will cause a preview of the item under point in the *Kill Ring* buffer to be displayed in the original buffer where the item would be inserted.

Known issues

Check out the project's issue list a list of unresolved issues. By the way - feel free to fix any of them and send a pull request. :-)

History

Originally written by Colin Walters (Debian Developer, Emacs hacker, SELinux hacker, and general Free Software Guru Extrordinaire). After that maintained by Nick Hurley. Unfortunately he had to abandon Emacs and this organisation account was created at Github. Feel free to issue pull requests.

Contributors

Here's a list of all the people who have contributed to the development of browse-kill-ring.

Bugs & Improvements

Bug reports and suggestions for improvements are always welcome. GitHub pull requests are even better! :-)

browse-kill-ring's People

Contributors

ajschumacher avatar baohaojun avatar edwardbetts avatar glasserc avatar irigone avatar monsanto avatar nwgh avatar samaaron avatar skyer9 avatar t-j-teru avatar to1ne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

browse-kill-ring's Issues

Use semantic versioning

Versing numbering like 1.5a is quite uncommon today, so I'd suggest adopting the much more popular semver.

Using it 1.5a would be 1.5.1. Actually elisp's version-to-list interprets 1.5a as 1.5.1 anyways.

change shortcut for browse-kill-ring-insert-move-and-quit

in many case, last yanked text also yanked again
(in any case yanked by brows-kill-ring or C-y)

so i suggest shortcut for browse-kill-ring-insert-move-and-quit must be RET.

it will make user yank text as expected by typing C-y
(after selected kill by browse-kill-ring)

ps. many user do NOT read source code. ;-(

Preview

When browsing the kill ring, it should be possible to preview the 'to be yanked' text as it would look in the target buffer if you were to yank it - similar to the default behaviour of the kill ring, only controlled by navigating the kill ring buffer.

Currently, when focus shifts to the kill-ring browser, the cursor in the target buffer is no longer visible, so you have to remember where the code will be inserted. browse-kill-ring should show you where it will be inserted by live-updating the target buffer with the current candidate and having an option of highlighting the candidate with a unique face.

Put point at the end of the yanked text

If you compare the behavior:

  • (yank) puts point at the end of the yanked text
  • `(browse-kill-ring-insert) puts point at the beginning of the yanked text

I don't like that.

only display items whose stripped length than minimum

I need delete lots of lines in javascript code, which I have not intention to reuse from kill-ring.

like " } ", say minimum length is 2, the stripped version of original string in kill-ring is "}" (stripping tab/space/line-feed characters), its length is 1. So it should not be displayed.

Unable to run browse-kill-ring

In Emacs 24.5.1 (running with minimal configuration), after installing the package, the command is not working. The error message is:

font-lock-set-defaults: Wrong type argument: symbolp, (font-lock-fontify-region-function . browse-kill-ring-fontify-region)

Integrate with form-feed-mode

Emacs has form-feed-mode which displays form feed characters on lines by themselves to be displayed as horizontal lines. Based on that, I’ve tried doing:

(setq browse-kill-ring-separator "\x0C")  ; form feed
(add-hook 'browse-kill-ring-hook 'form-feed-mode)

and while form feed character is inserted as separator and form-feed-mode is enabled in the *Kill Ring* buffer, the form feed characters aren’t displayed as lines.

I suspect this is because browse-kill-ring sets face on the separator which interferes with form-feed-mode.

kill-ring-yank-pointer should be used

kill-ring-yank-pointer points to the element last yanked from the kill-ring. This variable should be used to set the cursor to the correct position in the *Kill Ring* buffer.
Also when an element is yanked, it should be set to that element in the kill-ring.

Warnings from Emacs 29.1 upon loading browse-kill-ring

FYI, here's what's appearing in the Messages buffer after loading the current version (20220410.1509) of browse-kill-ring :

.emacs.d/load-path-subdirs/td-esdf/td-startup-lisp/Elpa/browse-kill-ring-20220410.1509/browse-kill-ring.el: Warning: Case 'insert will match `quote'.  If that's intended, write (insert quote) instead.  Otherwise, don't quote `insert'.
.emacs.d/load-path-subdirs/td-esdf/td-startup-lisp/Elpa/browse-kill-ring-20220410.1509/browse-kill-ring.el: Warning: Case 'append will match `quote'.  If that's intended, write (append quote) instead.  Otherwise, don't quote `append'.
.emacs.d/load-path-subdirs/td-esdf/td-startup-lisp/Elpa/browse-kill-ring-20220410.1509/browse-kill-ring.el: Warning: Case 'prepend will match `quote'.  If that's intended, write (prepend quote) instead.  Otherwise, don't quote `prepend'.
.emacs.d/load-path-subdirs/td-esdf/td-startup-lisp/Elpa/browse-kill-ring-20220410.1509/browse-kill-ring.el: Warning: Case 'move will match `quote'.  If that's intended, write (move quote) instead.  Otherwise, don't quote `move'.
.emacs.d/load-path-subdirs/td-esdf/td-startup-lisp/Elpa/browse-kill-ring-20220410.1509/browse-kill-ring.el: Warning: Case 'delete will match `quote'.  If that's intended, write (delete quote) instead.  Otherwise, don't quote `delete'.
.emacs.d/load-path-subdirs/td-esdf/td-startup-lisp/Elpa/browse-kill-ring-20220410.1509/browse-kill-ring.el: Warning: Case 'solid will match `quote'.  If that's intended, write (solid quote) instead.  Otherwise, don't quote `solid'.

Pressing g in browse-kill-ring buffer causes errors

Subj.

emacs 24.2.1

Here is the log
''browse-kill-ring-update: Wrong number of arguments: (lambda (kill-buf orig-buf window &optional regexp window-config) (setq browse-kill-ring-this-buffer-replace-yanked-text (and browse-kill-ring-replace-yank (eq last-command (quote yank)))) (let* ((will-replace (or browse-kill-ring-this-buffer-replace-yanked-text (region-active-p))) (start (if will-replace (min (point) (mark)) (point))) (end (if will-replace (max (point) (mark)) (point)))) (when browse-kill-ring-show-preview (setq browse-kill-ring-preview-overlay (make-overlay start end (current-buffer))))) (overlay-put browse-kill-ring-preview-overlay (quote invisible) t) (with-current-buffer kill-buf (unwind-protect (progn (browse-kill-ring-mode) (setq buffer-read-only nil) (when (eq browse-kill-ring-display-style (quote one-line)) (setq truncate-lines t)) (let ((inhibit-read-only t)) (erase-buffer)) (setq browse-kill-ring-original-buffer orig-buf 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 (function browse-kill-ring-depropertize-string) (function copy-sequence)) kill-ring))) (when (not browse-kill-ring-display-duplicates) (require (quote cl)) (setq items (delete-duplicates items :test (function equal)))) (when (stringp regexp) (setq items (delq nil (mapcar (function ...) 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) (browse-kill-ring-preview-update (point-min)) (add-hook (quote post-command-hook) (quote browse-kill-ring-preview-update) nil t) (message (let ((entry (if ... "entry" "entries"))) (concat (if (and ... browse-kill-ring-display-duplicates) (format "%s %s in the kill ring." ... entry) (format "%s (of %s) %s in the kill ring shown." ... ... entry)) (substitute-command-keys (concat " Type \\[browse-kill-ring-quit] to quit. " "\\[describe-mode] for help."))))) (set-buffer-modified-p nil) (goto-char (point-min)) ...)) (progn (setq buffer-read-only t))))), 2Error during redisplay: (error "Lisp nesting exceedsmax-lisp-eval-depth'")''

Update kill-ring-yank-pointer when deleting kill-ring elements.

In browse-kill-ring-delete, after (setq kill-ring (delete target kill-ring)), add:

 (catch 'done
  (mapc
    (lambda (x)
      (when (equal target (substring-no-properties x))
        (setq kill-ring-yank-pointer (delete target kill-ring-yank-pointer))
        (throw 'done nil)))
    kill-ring-yank-pointer))

C-g does not quit browse-kill-ring

While browse-kill-ring correctly emits a Quit message in the minibuffer after pressing C-g, its window stays open and control remains with browse-kill-ring.

Expected behavior

C-g closes browse-kill-ring and point returns to the window it was called from without inserting an entry from the kill-ring, analogous to pressing q.

Closing browse-kill-ring closes my windows

When I open a window with C-x 2 and then do M-x browse-kill-ring, and select one and press q to close the window, it closes my window so my frame only has one window open.

Maybe you can just make it do quit-window to make the window go back to whatever it was before? I don't know elisp so take that suggestion with a grain of salt. But regardless, the current behavior isn't correct and should change.

Thoughts implementing this package for mark-ring

Hi

I'm using this package since some time and really like it. Thanks!

I had an idea that I liked to implement and wanted to ask for some advice, hints and tips.

I want to use the same concept but instead of the kill-ring, it should be for the mark-ring.

How much tweaking would be needed to use this for the mark-ring?

May it be optimal to abstract it in a way to work with any "ring"-datastructure?

cl is deprecated

In Emacs 27, the cl package is deprecated. Loading this library throws a warning, which is annoying. The cl features should be replaced by their cl-lib counterparts moving forward. I would do this work myself, but I don't know enough about the functions exported by cl.

Increase major version

Considering all the recent changes done (some of which are not backward compatible) I suggest we increase the major version number, so we'll get v2.0.0.

Information about the versioning scheme can be found at http://semver.org/.

C-g should cancel

I just installed this, so perhaps I'm missing something, but when I ran the command to test it out, it was a bit annoying to cancel.

First I tried C-g, which didn't work, so I just closed the buffer, but then I was stuck with the selected item from the kill ring. The text couldn't be deleted, so I had to close the buffer entirely to get stuff back in order.

Feature request: Numerical yanking

I'd love to M-y 3 to get the 3rd item in the kill ring instead of M-y n n n Return to yank it. I would happily contribute this myself, but my elisp is weak :(

Wrong type argument: overlayp, nil

After calling browse-kill-ring, select a item and press RET, it just says "Wrong type argument: overlayp, nil". In the end, the browse-kill-ring buffer still existed without the item inserted.

Error when the kill-ring is empty

If you try invoking browse-kill-ring immediately after starting Emacs (for instance) you'll get:

browse-kill-ring: Wrong type argument: stringp, nil

Cannot insert item when global linum mode is on

When I invoke browse-kill-ring with global linum mode is on, I cannot insert the candidates except the first one. I got the follow error:

Debugger entered--Lisp error: (wrong-type-argument overlayp nil)
  overlay-start(nil)
  (setq current-overlay-start-point (overlay-start (car (overlays-at (point)))))
  (while (not stop-search) (setq current-overlay-start-point (overlay-start (car (overlays-at (point))))) (if (eq overlay-start-point current-overlay-start-point) (setq stop-search t)) (if (not stop-search) (progn (browse-kill-ring-forward 1) (setq current-index (1+ current-index)))))
  (save-excursion (goto-char (point-min)) (while (not stop-search) (setq current-overlay-start-point (overlay-start (car (overlays-at (point))))) (if (eq overlay-start-point current-overlay-start-point) (setq stop-search t)) (if (not stop-search) (progn (browse-kill-ring-forward 1) (setq current-index (1+ current-index))))))
  (let ((overlay-start-point (overlay-start (car (overlays-at pt)))) (current-index 0) (stop-search nil) current-overlay-start-point) (save-excursion (goto-char (point-min)) (while (not stop-search) (setq current-overlay-start-point (overlay-start (car (overlays-at (point))))) (if (eq overlay-start-point current-overlay-start-point) (setq stop-search t)) (if (not stop-search) (progn (browse-kill-ring-forward 1) (setq current-index (1+ current-index)))))) current-index)
  browse-kill-ring-current-index(#<buffer *Kill Ring*> 16)
  (nthcdr (browse-kill-ring-current-index buf pt) kill-ring)
  (setq result-yank-pointer (nthcdr (browse-kill-ring-current-index buf pt) kill-ring))
  (if browse-kill-ring-display-duplicates (setq result-yank-pointer (nthcdr (browse-kill-ring-current-index buf pt) kill-ring)) (if browse-kill-ring-display-leftmost-duplicate (while (< i (length kill-ring)) (if (and (not found) (equal (substring-no-properties current-string) (substring-no-properties (elt kill-ring i)))) (progn (setq result-yank-pointer (nthcdr i kill-ring)) (setq found t))) (setq i (1+ i))) (setq i (1- (length kill-ring))) (while (<= 0 i) (if (and (not found) (equal (substring-no-properties current-string) (substring-no-properties (elt kill-ring i)))) (progn (setq result-yank-pointer (nthcdr i kill-ring)) (setq found t))) (setq i (1- i)))))
  (let ((result-yank-pointer kill-ring) (current-string (browse-kill-ring-current-string buf pt)) (found nil) (i 0)) (if browse-kill-ring-display-duplicates (setq result-yank-pointer (nthcdr (browse-kill-ring-current-index buf pt) kill-ring)) (if browse-kill-ring-display-leftmost-duplicate (while (< i (length kill-ring)) (if (and (not found) (equal (substring-no-properties current-string) (substring-no-properties ...))) (progn (setq result-yank-pointer (nthcdr i kill-ring)) (setq found t))) (setq i (1+ i))) (setq i (1- (length kill-ring))) (while (<= 0 i) (if (and (not found) (equal (substring-no-properties current-string) (substring-no-properties ...))) (progn (setq result-yank-pointer (nthcdr i kill-ring)) (setq found t))) (setq i (1- i))))) result-yank-pointer)
  browse-kill-ring-current-kill-ring-yank-pointer(#<buffer *Kill Ring*> 16)
  (setq kill-ring-yank-pointer (browse-kill-ring-current-kill-ring-yank-pointer buf pt))
  (let ((str (browse-kill-ring-current-string buf pt))) (setq kill-ring-yank-pointer (browse-kill-ring-current-kill-ring-yank-pointer buf pt)) (progn (if quit (browse-kill-ring-quit) (browse-kill-ring-clear-preview)) (let ((save-selected-window--state (internal--before-with-selected-window browse-kill-ring-original-window))) (save-current-buffer (unwind-protect (progn (select-window (car save-selected-window--state) (quote norecord)) (save-current-buffer (set-buffer browse-kill-ring-original-buffer) (progn ... ... ...) (if quit nil ...))) (internal--after-with-selected-window save-selected-window--state))))))
  browse-kill-ring-do-insert(#<buffer *Kill Ring*> 16 nil)
  browse-kill-ring-insert(nil)
  call-interactively(browse-kill-ring-insert nil nil)

On the other hand, append is OK.

Reproducable on Emacs 24.3.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.