From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Maurer Newsgroups: gmane.emacs.help Subject: custom function getting initialized randomly Date: Mon, 27 Mar 2023 10:22:45 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12945"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 27 11:21:07 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgj2I-000374-3k for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 27 Mar 2023 11:21:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgj1l-000582-Hq; Mon, 27 Mar 2023 05:20:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgi80-0008AV-T6 for help-gnu-emacs@gnu.org; Mon, 27 Mar 2023 04:22:57 -0400 Original-Received: from mail-ua1-x931.google.com ([2607:f8b0:4864:20::931]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pgi7y-0006va-Ue for help-gnu-emacs@gnu.org; Mon, 27 Mar 2023 04:22:56 -0400 Original-Received: by mail-ua1-x931.google.com with SMTP id e12so5708981uaa.3 for ; Mon, 27 Mar 2023 01:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679905373; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=//SNEVU0bjf+ZLcnOyaoKYstgab2svsDa9nBqq2zRT8=; b=VSwRjFs+QFT8jZSbLzaZvzgwKOQUFSSquozFrelnfINl4KJRoSfyaIemSkfHMzxcuX tlMu+ZJZJz4MWPEWPEsVI6Bc50MfgkcQ8ck6IK/wTZKiWHhmuGB0JYPZ8D7rC7t9gS/G cpCtu8xREw2P26G4L65ep35ugD82p5swgDFOKeon7GYDFvsuwVCpEItxu5+3lGU+H5ve TaAH+y/OyewYCD3gonyDvu7Z+sPWrjt01XCPHfXykvuWwyOHZDiUGwfzVgZwNWx9GZEx LP+pJTVt2N8yUBQqaWELwSRxMxKSsFHHnsCG2H0BRQaEuXHeqXCBEriuvW4LFSaMkfd0 B1cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679905373; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=//SNEVU0bjf+ZLcnOyaoKYstgab2svsDa9nBqq2zRT8=; b=eFwHrAf4QG2f8+G0Kg1ujIvu52qiShFTwYyIfu9+rmZO0PmTloSFzLFOITip+CnrE2 auYf0CiMXLMdR2ffLgJ3KEtsZkFMm4/ySRIWWHdrY0ycfnoI7f/yGpKgZokwqidKodD+ bchwqSZUuQ+RJgEr2zl7rVcRfKgZDGuIvCh+gBYbfPr4yYyJW6jcKa3ijLlmfUamhjzR XdqQvmk1+xyH1229fCdtHKz2yKEXzhKthMfmLK2evfgeHnF7pz1MLjP6h8q4RMRvr0EM ghGJGyndgiVgNdZsmjqrWGAEFmk4tHkZfgZUhLAQsMqJ7aC+Y0VFa4Ut4w8JgyR2HGRn KI7g== X-Gm-Message-State: AAQBX9dU/Mwpe9gIdmyfRAtE7fZ+tTe/tsUz+Wfll121yZmBjEe9+rOQ rdR43iNRqwYEb6WZepqs5Sd6M2MSxrmsCIf+tej6bXUfixM= X-Google-Smtp-Source: AKy350a5neLpw9maPDnNrF8MbFbc/SGUitabUdEToGSP/krw6EXr0IISdMpE8QaB4ToWXj4EpB73i/IRTvOeGl18BoQ= X-Received: by 2002:a05:6130:3a9:b0:68d:6360:77b with SMTP id az41-20020a05613003a900b0068d6360077bmr8006798uab.1.1679905373377; Mon, 27 Mar 2023 01:22:53 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::931; envelope-from=maurer.michael@gmail.com; helo=mail-ua1-x931.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 27 Mar 2023 05:20:30 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143123 Archived-At: 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)