Skip to content

Instantly share code, notes, and snippets.

@jamescherti
Created April 16, 2024 18:33
Show Gist options
  • Save jamescherti/0505d990af3f782b9d3717b6b1a29f76 to your computer and use it in GitHub Desktop.
Save jamescherti/0505d990af3f782b9d3717b6b1a29f76 to your computer and use it in GitHub Desktop.
;; Description:
;; Prevent 'evil-paste-after' and 'evil-paste-before' from failing when the
;; paste ring (akin to the clipboard) is empty.
;;
;; Gits URL:
;; License: MIT
;; Author: James Cherti
(defun ignore-empty-ring-errors (orig-func &rest args)
"Ignore errors related to the empty ring when calling ORIG-FUNC with ARGS."
(condition-case nil
(apply orig-func args)
(error (message "Nothing to paste!") nil)))
(advice-add 'evil-paste-after :around #'ignore-empty-ring-errors)
(advice-add 'evil-paste-before :around #'ignore-empty-ring-errors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment