[spacemacs-bootstrap] Remove whitespace from kill ring. (#15634)
When `dotspacemacs-enable-paste-transient-state` is on, there exists a minor annoyance that deleted whitespaces appear in the kill ring. This requires an extra C-j/C-k to bypass the noise. This commit uses a advice function to `kill-new` to prevent text with only whitespaces from entering kill ring. Credit: https://stackoverflow.com/questions/12102554/emacs-skip-whitespace-kills Co-authored-by: Lucius Hu <1222865+lebensterben@users.noreply.github.com> Co-authored-by: Lucius Hu <lebensterben@users.noreply.github.com>
This commit is contained in:
parent
8041d8a349
commit
91af298090
|
@ -100,6 +100,8 @@ the [[file:CHANGELOG.org][CHANGELOG.org]] file.
|
|||
- The property =:powerline-scale= of variable =dotspacemacs-default-font= has
|
||||
been removed and replaced by the property =:separator-scale= used in the new
|
||||
dotfile variable =dotspacemacs-mode-line-theme=.
|
||||
- If =dotspacemacs-enable-paste-transient-state= is enabled, whitespace is
|
||||
removed from the kill ring for better ergonomics. (thanks to BenedictHW)
|
||||
**** Layers
|
||||
***** Spacemacs distribution layers
|
||||
- Key bindings:
|
||||
|
|
|
@ -324,7 +324,7 @@ It should only modify the values of Spacemacs settings."
|
|||
|
||||
;; If non-nil, the paste transient-state is enabled. While enabled, after you
|
||||
;; paste something, pressing `C-j' and `C-k' several times cycles through the
|
||||
;; elements in the `kill-ring'. (default nil)
|
||||
;; non-whitespace elements in the `kill-ring'. (default nil)
|
||||
dotspacemacs-enable-paste-transient-state nil
|
||||
|
||||
;; Which-key delay in seconds. The which-key buffer is the popup listing
|
||||
|
|
|
@ -242,7 +242,17 @@
|
|||
(define-key evil-normal-state-map
|
||||
"p" 'spacemacs/paste-transient-state/evil-paste-after)
|
||||
(define-key evil-normal-state-map
|
||||
"P" 'spacemacs/paste-transient-state/evil-paste-before))
|
||||
"P" 'spacemacs/paste-transient-state/evil-paste-before)
|
||||
;; Based on https://stackoverflow.com/questions/12102554/emacs-skip-whitespace-kills
|
||||
(define-advice kill-new (:around (orig-fn string &optional rest) ignore-whitespaces)
|
||||
"Don't put whitespaces into kill ring."
|
||||
(let* ((string-raw (substring-no-properties string))
|
||||
(space-p (not (string-match-p "[^ \t\n\r]" string-raw))))
|
||||
(if (not space-p)
|
||||
(apply orig-fn string rest)
|
||||
(message "skipped whitespace kill")
|
||||
nil))))
|
||||
|
||||
;; fold transient state
|
||||
(when (eq 'evil dotspacemacs-folding-method)
|
||||
(spacemacs|define-transient-state fold
|
||||
|
|
Loading…
Reference in New Issue