Is there a way to tell emacs ignore kill that are less than 4 characters long? It is quite annoying to have a lot of single character kills in evil mode. Thank you!
Asked
Active
Viewed 83 times
1
-
2I suspect that you will need to track down the relevant functions you are using to add data to the kill-ring -- e.g., `kill-new` and `kill-region` -- and modify those functions. There is no simple length variable I am aware of that permits a user to specify a certain minimum length before data is added to the `kill-ring`. Other alternatives include modifying specific functions that are in turn calling other functions responsible for saving information to the kill-ring (which in turn may be using `kill-new` or `kill-region`). – lawlist Apr 12 '15 at 23:24
-
So we can add a advice to those functions.Thank you! – godblessfq Apr 13 '15 at 15:29
-
1Dunno why someone downvoted you. I think this kind of question is helpful. My suggestion would be to send an enhancement request (`M-x report-emacs-bug`) asking for a hook of filter functions, to be able to control what gets added as a kill. In Emacs 23 they added option `kill-do-not-save-duplicates`, for example, which is good. But it would be good for users to be able to further discriminate wrt what gets added to the `kill-ring`. Instead of adding an option for each such possibility (e.g., for your case, `kill-ring-entry-length`), we should be able to add a filter function to a hook. – Drew Apr 15 '15 at 18:12
1 Answers
1
The filter mechanism is already in 24.4. Thanks to glucas. https://emacs.stackexchange.com/questions/8097/how-do-i-filter-kill-ring-contents
(defvar kill-ring-entry-length 3)
(defun my/replace-blank-kill (args)
(let ((string (car args))
(replace (cdr args))
(last (car-safe kill-ring)))
(when (or (and last (string-blank-p last))
(< (length last) kill-ring-entry-length))
(setq replace t))
(list string replace)))
(advice-add 'kill-new :filter-args #'my/replace-blank-kill)
godblessfq
- 371
- 1
- 12