1
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!
1
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!
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)
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
andkill-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 thekill-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 usingkill-new
orkill-region
). – lawlist – 2015-04-12T23:24:30.817So we can add a advice to those functions.Thank you! – godblessfq – 2015-04-13T15:29:30.697
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 optionkill-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 thekill-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 – 2015-04-15T18:12:35.320