[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
custom function getting initialized randomly
From: |
Michael Maurer |
Subject: |
custom function getting initialized randomly |
Date: |
Mon, 27 Mar 2023 10:22:45 +0200 |
Hello,
I wrote the following function to copy the kill-ring to the scratch
buffer, but it only gets initialized sometimes at the start of emacs,
sometimes not. Why?
(defun copy-to-scratch-on-kill
()
"Copy every kill (delete or yank) to *scratch* buffer."
(let
((cur-kill-string
(current-kill 0 t)))
(when
(and
(not
(equal cur-kill-string ""))
(not
(equal cur-kill-string prev-kill-string))
(get-buffer "*scratch*"))
(with-current-buffer "*scratch*"
(goto-char
(point-max))
(insert cur-kill-string "\n")
(goto-char
(point-max))))
(setq prev-kill-string cur-kill-string)))
(add-hook 'post-command-hook #'copy-to-scratch-on-kill)