unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Maurer <maurer.michael@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: custom function getting initialized randomly
Date: Mon, 27 Mar 2023 10:29:31 +0200	[thread overview]
Message-ID: <CAH-0+bDs3ytzGL-RXqpKxA4iksu-RTDwai5QHu_mkPzsPK6WxA@mail.gmail.com> (raw)

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)



             reply	other threads:[~2023-03-27  8:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27  8:29 Michael Maurer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-03-27  8:22 custom function getting initialized randomly Michael Maurer
2023-03-27 13:56 ` Richard Copley
2023-03-27 14:56   ` Michael Maurer
2023-03-27 15:06     ` Richard Copley
2023-03-27 15:20   ` tomas
2023-03-27 15:30     ` Michael Maurer
2023-03-27 15:52       ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH-0+bDs3ytzGL-RXqpKxA4iksu-RTDwai5QHu_mkPzsPK6WxA@mail.gmail.com \
    --to=maurer.michael@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).