From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: 29.0.50; New command `scratch-buffer' inconsistent with startup Resent-From: David Ponce Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 May 2022 08:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 55257@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16516531277614 (code B ref -1); Wed, 04 May 2022 08:33:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 May 2022 08:32:07 +0000 Received: from localhost ([127.0.0.1]:41729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmAQZ-0001yj-2R for submit@debbugs.gnu.org; Wed, 04 May 2022 04:32:07 -0400 Received: from lists.gnu.org ([209.51.188.17]:33126) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmAQX-0001yc-BV for submit@debbugs.gnu.org; Wed, 04 May 2022 04:32:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmAQT-0006Bh-AT for bug-gnu-emacs@gnu.org; Wed, 04 May 2022 04:32:04 -0400 Received: from smtp09.smtpout.orange.fr ([80.12.242.131]:55117 helo=smtp.smtpout.orange.fr) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nmAQQ-00018k-R8 for bug-gnu-emacs@gnu.org; Wed, 04 May 2022 04:32:01 -0400 Received: from [192.168.1.15] ([2.7.228.182]) by smtp.orange.fr with ESMTPA id mAQKnI2WmqoKwmAQLn7LFH; Wed, 04 May 2022 10:31:53 +0200 X-ME-Helo: [192.168.1.15] X-ME-Auth: OWU0YmVhODllOThlNTBiMTcxZWVkMmNjZmQ4ZWZlMmRlNQ== X-ME-Date: Wed, 04 May 2022 10:31:53 +0200 X-ME-IP: 2.7.228.182 From: David Ponce Message-ID: Date: Wed, 4 May 2022 10:31:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Language: fr Content-Transfer-Encoding: 7bit Received-SPF: none client-ip=80.12.242.131; envelope-from=da_vid@orange.fr; helo=smtp.smtpout.orange.fr X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello, The new command `scratch-buffer' does not re-create the *scratch* buffer like in startup.el. The below patch fix this: --- a/./installs/emacs/lisp/simple.el +++ b/./emacs.d/simple.el @@ -10221,7 +10221,8 @@ If the buffer doesn't exist, create it first." (pop-to-buffer-same-window "*scratch*") (pop-to-buffer-same-window (get-buffer-create "*scratch*")) (when initial-scratch-message - (insert initial-scratch-message)) + (insert (substitute-command-keys initial-scratch-message)) + (set-buffer-modified-p nil)) (funcall initial-major-mode))) Thanks! In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.17.4) of 2022-05-04 Repository revision: 268713e227e8b665b1874c96ea96d1e7fccaab11 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: Fedora Linux 35 (KDE Plasma) Configured using: 'configure --with-cairo --without-sqlite3 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LC_TIME: fr_FR.utf8 value of $LANG: fr_FR.UTF-8 locale-coding-system: utf-8-unix From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: 29.0.50; New command `scratch-buffer' inconsistent with startup Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 May 2022 14:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: David Ponce Cc: 55257@debbugs.gnu.org Received: via spool by 55257-submit@debbugs.gnu.org id=B55257.165167633424507 (code B ref 55257); Wed, 04 May 2022 14:59:02 +0000 Received: (at 55257) by debbugs.gnu.org; 4 May 2022 14:58:54 +0000 Received: from localhost ([127.0.0.1]:43665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmGSr-0006ND-TG for submit@debbugs.gnu.org; Wed, 04 May 2022 10:58:54 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:35577) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmGSp-0006My-Gc for 55257@debbugs.gnu.org; Wed, 04 May 2022 10:58:52 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 61EB95C01CF; Wed, 4 May 2022 10:58:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 04 May 2022 10:58:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1651676325; x=1651762725; bh=jM hpkiSNEM9GC8BXureoFdjfqPOWnFQqxj3W5N4FQ9I=; b=ksAftupT7ZQ2QXt454 XsMcg7ihhzGrX29UhCFI7uWV+MkvZv7WwYlpS7RDFvXyPhK1TW2ZDFb1LzsIFclN qjWDpAcJxyPQRtdjGiK4fdTsWvdr8D/Ig0ieBnGjnP1gGJFOYsd046DApxXIAlhB ChoA6FOoDFB+pCUg+DN0SDUyni44EHcpxPjZVeVje4kcEzRkXH63dacnKTIou/7X JgL4SasNBEOpPej4DqXDFElxnd0GN4rqE/X3NxlB7MsRrsa+Sy3dDpHCGSRQHajj k4WBpywkbd6cZd12hzNLj6qt/YqwM1GL01bMdKy5kXh2QOW5Ht7EsX+6CkzVkxbG eBYg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651676325; x= 1651762725; bh=jMhpkiSNEM9GC8BXureoFdjfqPOWnFQqxj3W5N4FQ9I=; b=m r/qq5qGIUxVQ40P6r2/zRl9e+4WlpDWXLW2MkdqDrTynnLceNn0yheAOokn0ztBK VuoV6biBpwspOvO2n/7VuusFAeHhqqnN7Hxk9EWs0bceYD/e8PcZY/bG2/gj7SIv m5IIVG+qdEOdcTLIUqPtk/chMnlL9lc9KtUuF60+A0aDfem7sRx2gz3wA35zShZo PeCG857WK+1UCnLima26xf+75uL4hTk2DjZEeDJdJsWSkTcM0e4NkXzpmG/OqcMM CST8Sfr/E5MYh1CaFF9Q8F5sMPT6Y9qceXFnQSVp+TuJKZZMIwokMWD42Q0ULmWs RNdki79O6OZj5BQ/AjGTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdelgdekvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefujghffgffkfggtgesthdttd dttdertdenucfhrhhomhepufgvrghnucghhhhithhtohhnuceoshhpfihhihhtthhonhes shhpfihhihhtthhonhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpedvjeettdeiteejge ejkefggfehtdekledtfedtteekgfeukeeftdduhfetleejkeenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsphifhhhithhtohhnsehsphifhh hithhtohhnrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 4 May 2022 10:58:44 -0400 (EDT) Received: by athena.silentflame.com (Postfix, from userid 1000) id 3A4301BB9A5; Wed, 4 May 2022 14:58:44 +0000 (UTC) From: Sean Whitton In-Reply-To: References: User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Wed, 04 May 2022 07:58:44 -0700 Message-ID: <87r159e44b.fsf@athena.silentflame.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, On Wed 04 May 2022 at 10:31am +02, David Ponce wrote: > Hello, > > The new command `scratch-buffer' does not re-create the *scratch* buffer > like in startup.el. > > The below patch fix this: > --- a/./installs/emacs/lisp/simple.el > +++ b/./emacs.d/simple.el > @@ -10221,7 +10221,8 @@ If the buffer doesn't exist, create it first." > (pop-to-buffer-same-window "*scratch*") > (pop-to-buffer-same-window (get-buffer-create "*scratch*")) > (when initial-scratch-message > - (insert initial-scratch-message)) > + (insert (substitute-command-keys initial-scratch-message)) > + (set-buffer-modified-p nil)) > (funcall initial-major-mode))) Thanks. Let me try to fix this as part of factoring out the *scratch* initialisation code, as discussed in an emacs-devel thread. -- Sean Whitton From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Thu, 05 May 2022 22:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Robert Pluim , 55257-submitter@debbugs.gnu.org, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.16517884715751 (code U ref 55257); Thu, 05 May 2022 22:08:01 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 5 May 2022 22:07:51 +0000 Received: from localhost ([127.0.0.1]:46698 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmjdX-0001Ug-8E for submit@debbugs.gnu.org; Thu, 05 May 2022 18:07:51 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:40055) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmjdV-0001UU-6a for 55257-submitter@debbugs.gnu.org; Thu, 05 May 2022 18:07:49 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 24C8C5C00EB; Thu, 5 May 2022 18:07:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 05 May 2022 18:07:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1651788464; x=1651874864; bh=nO 3YJF+ssfkfdb+kqBIu+8Ciz8qcPyqaZswMgM3HAlg=; b=PspMmdy+DFg+CRM5GG P1ddHGyGmkGmlOaan8lIjKysEIzlGrEjRnuoqW4lSribY+oAQyf89Nsr3uAlID+A fM56kCa1oA3RK+8IME7bLy3C4y8+5dDaEyoMUoi+pzsHtA/NkB7qy0P/fl7WL2ji iNoBIf9dSCHjxZl+Hox6YxKYWPEK66KI+tU5m8MSEsl8MoE/nQ8XAh2lMOd4yVhA 74f5DmGwrroRvEWhuPhPWsE5B0YNsTPRzsoVqkSPm0cW3Xe82XUl9pjZZroJJAHe zGRjyYVcY5ADt5aA8jtgr/dt/BCBtJEzA8RnVhRp+Y2LpAUCzQVBdMrPLhUXo5up I+Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651788464; x= 1651874864; bh=nO3YJF+ssfkfdb+kqBIu+8Ciz8qcPyqaZswMgM3HAlg=; b=d UeTlOXNAyJEOEn1ut4jD0pctiCscxBcYnI1tGgZo+wAnxW/gYlPV9bkzoobzmytr p50gRJLRyXSvNGRcnvjTjnkzOOgMtE/Hi+oG8l1w82mub0vmNYUMphMX6+2b4Rp+ rYmB0aieW+gUa29tEYLSzguZlRbZNYEaamljGKpLEr52kUXA0JDrUQaGmiDeAzjy 7T5csmjfHlSUEMUIcWX4keh9vdb2HAr7v9OlIzHJ5bPU1LkVZKJxCmWy67xeaJgJ hvEiQKID+B1NsXL3/1AZ1CinS0ufjI58uzddzEw4N+9GA/plXcGp58PkbywRgc9Y xkneh1OXWqFZWyyNf2N5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvgddthecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufgjfhgffffkgggtsehmtddtredtredtnecuhfhrohhmpefuvggrnhcu hghhihhtthhonhcuoehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqne cuggftrfgrthhtvghrnhepfeffhfegudeuueehkeejjefhgeelffdvveefheekvedukeeu keeuhedvueejvdfhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 May 2022 18:07:43 -0400 (EDT) Received: by melete.silentflame.com (Postfix, from userid 1000) id 06CDC7E5A84; Thu, 5 May 2022 15:07:42 -0700 (MST) From: Sean Whitton In-Reply-To: References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Thu, 05 May 2022 15:07:41 -0700 Message-ID: <871qx74or6.fsf@melete.silentflame.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Hello, On Wed 04 May 2022 at 12:26PM -04, Stefan Monnier wrote: >> It looks like Fother_window is called only from Fcall_interactively and >> Fkill_buffer, so there probably isn't a bootstrapping issue if I make >> those Ffuncall my new `get-initial-buffer-create'. It looks like >> bootstrapping C code just makes an empty *scratch* and leaves it to >> startup.el to initialise it. > > Even better, Here's my fix. Haven't quite finished testing each and every call site but seemed worth posting it for comments. -- Sean Whitton --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Factor-out-scratch-initialization.patch >From ac1c813ccd4cc266dd722704a36a9d178dab1e4c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 5 May 2022 13:03:06 -0700 Subject: [PATCH] Factor out *scratch* initialization * lisp/simple.el: Require subr-x when compiling. (get-initial-buffer-create): New function, factored out of scratch-buffer, and additionally clearing the modification flag and calling substitute-command-keys (bug#55257). (scratch-buffer): lisp/server.el (server-execute): lisp/startup.el (normal-no-mouse-startup-screen): (command-line-1): lisp/window.el (last-buffer): src/buffer.c (Fother_buffer, other_buffer_safely): Use it. lisp/startup.el (startup--get-buffer-create-scratch): Delete now-unused function. --- lisp/server.el | 2 +- lisp/simple.el | 22 +++++++++++++++------- lisp/startup.el | 12 +++--------- lisp/window.el | 5 +---- src/buffer.c | 21 ++------------------- 5 files changed, 22 insertions(+), 40 deletions(-) diff --git a/lisp/server.el b/lisp/server.el index 763cf27f7a..042962b8e9 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1367,7 +1367,7 @@ server-execute ((functionp initial-buffer-choice) (funcall initial-buffer-choice))))) (switch-to-buffer - (if (buffer-live-p buf) buf (get-buffer-create "*scratch*")) + (if (buffer-live-p buf) buf (get-initial-buffer-create)) 'norecord))) ;; Delete the client if necessary. diff --git a/lisp/simple.el b/lisp/simple.el index 861d9eefde..5a37e246f7 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -28,7 +28,9 @@ ;;; Code: -(eval-when-compile (require 'cl-lib)) +(eval-when-compile + (require 'cl-lib) + (require 'subr-x)) (declare-function widget-convert "wid-edit" (type &rest args)) (declare-function shell-mode "shell" ()) @@ -10213,16 +10215,22 @@ capitalize-dwim the number of seconds east of Greenwich.") ) +(defun get-initial-buffer-create () + "Return the \*scratch\* buffer, creating a new one if needed." + (if-let ((scratch (get-buffer "*scratch*"))) + scratch + (prog1 (setq scratch (get-buffer-create "*scratch*")) + (with-current-buffer scratch + (when initial-scratch-message + (insert (substitute-command-keys initial-scratch-message)) + (set-buffer-modified-p nil)) + (funcall initial-major-mode))))) + (defun scratch-buffer () "Switch to the \*scratch\* buffer. If the buffer doesn't exist, create it first." (interactive) - (if (get-buffer "*scratch*") - (pop-to-buffer-same-window "*scratch*") - (pop-to-buffer-same-window (get-buffer-create "*scratch*")) - (when initial-scratch-message - (insert initial-scratch-message)) - (funcall initial-major-mode))) + (pop-to-buffer-same-window (get-initial-buffer-create))) diff --git a/lisp/startup.el b/lisp/startup.el index c7cf86a01e..3fa25ddee9 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2355,7 +2355,7 @@ normal-no-mouse-startup-screen (insert "\t\t") (insert-button "Open *scratch* buffer" 'action (lambda (_button) (switch-to-buffer - (startup--get-buffer-create-scratch))) + (get-initial-buffer-create))) 'follow-link t) (insert "\n") (save-restriction @@ -2487,12 +2487,6 @@ display-about-screen (defalias 'about-emacs 'display-about-screen) (defalias 'display-splash-screen 'display-startup-screen) -(defun startup--get-buffer-create-scratch () - (or (get-buffer "*scratch*") - (with-current-buffer (get-buffer-create "*scratch*") - (set-buffer-major-mode (current-buffer)) - (current-buffer)))) - ;; This avoids byte-compiler warning in the unexec build. (declare-function pdumper-stats "pdumper.c" ()) @@ -2784,7 +2778,7 @@ command-line-1 (when (eq initial-buffer-choice t) ;; When `initial-buffer-choice' equals t make sure that *scratch* ;; exists. - (startup--get-buffer-create-scratch)) + (get-initial-buffer-create)) ;; If *scratch* exists and is empty, insert initial-scratch-message. ;; Do this before switching to *scratch* below to handle bug#9605. @@ -2808,7 +2802,7 @@ command-line-1 ((functionp initial-buffer-choice) (funcall initial-buffer-choice)) ((eq initial-buffer-choice t) - (startup--get-buffer-create-scratch)) + (get-initial-buffer-create)) (t (error "`initial-buffer-choice' must be a string, a function, or t"))))) (unless (buffer-live-p buf) diff --git a/lisp/window.el b/lisp/window.el index 9f78784612..4ec329e0cf 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4886,10 +4886,7 @@ last-buffer (setq frame (or frame (selected-frame))) (or (get-next-valid-buffer (nreverse (buffer-list frame)) buffer visible-ok frame) - (get-buffer "*scratch*") - (let ((scratch (get-buffer-create "*scratch*"))) - (set-buffer-major-mode scratch) - scratch))) + (get-initial-buffer-create))) (defcustom frame-auto-hide-function #'iconify-frame "Function called to automatically hide frames. diff --git a/src/buffer.c b/src/buffer.c index f8a7a4f510..702b21f9fc 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1634,16 +1634,7 @@ DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0, if (!NILP (notsogood)) return notsogood; else - { - AUTO_STRING (scratch, "*scratch*"); - buf = Fget_buffer (scratch); - if (NILP (buf)) - { - buf = Fget_buffer_create (scratch, Qnil); - Fset_buffer_major_mode (buf); - } - return buf; - } + return call0 (intern ("get-initial-buffer-create")); } /* The following function is a safe variant of Fother_buffer: It doesn't @@ -1659,15 +1650,7 @@ other_buffer_safely (Lisp_Object buffer) if (candidate_buffer (buf, buffer)) return buf; - AUTO_STRING (scratch, "*scratch*"); - buf = Fget_buffer (scratch); - if (NILP (buf)) - { - buf = Fget_buffer_create (scratch, Qnil); - Fset_buffer_major_mode (buf); - } - - return buf; + return call0 (intern ("get-initial-buffer-create")); } DEFUN ("buffer-enable-undo", Fbuffer_enable_undo, Sbuffer_enable_undo, -- 2.30.2 --=-=-=-- From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Thu, 05 May 2022 22:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Robert Pluim , 55257-submitter@debbugs.gnu.org, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.16517888136285 (code U ref 55257); Thu, 05 May 2022 22:14:01 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 5 May 2022 22:13:33 +0000 Received: from localhost ([127.0.0.1]:46711 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmjj2-0001dJ-LT for submit@debbugs.gnu.org; Thu, 05 May 2022 18:13:33 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:60009) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmjj0-0001d6-RR for 55257-submitter@debbugs.gnu.org; Thu, 05 May 2022 18:13:31 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id C9CED5C00EF; Thu, 5 May 2022 18:13:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 05 May 2022 18:13:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1651788805; x=1651875205; bh=Y1 jSN5cVbBmsWaKMTO5+MrLagmP2ZE8qXRD2QXtGtOQ=; b=prZgPS6MY4i9FCaTGU nIR32My1XmTM6LsSbiPBlFmewzr9MmaAcPfcpx8swnSzW/dFK2zgPK52f5qHzhJb ryS+NWYUT23SFIPA3ox+IsHaB983Ufhahpn+6qw8QDVZTijdnnKFZmH7enwENgrz eaeOX6E1erzcZq7PHV7+xJBeey08B9r87U83sbdBN/deqYT6En0WKgKd29jD/fig XUNVWA7OxM+amCRcCytudeVmYRP4bxFaLfYt+6/+LSEbOqli8tb+gNcvPWbJSbok kdFraEjFCyoZDwfMzGU9oNggRMQpKDrBgBpgT4BmQuk/FC3y/1rw5Dh2Y72+Rugn 4C0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651788805; x= 1651875205; bh=Y1jSN5cVbBmsWaKMTO5+MrLagmP2ZE8qXRD2QXtGtOQ=; b=J FhnhnG3o2Jl6l/w0wMAhylsj03jChOi8GIlKs5zgvLA8U3Hc9i+h/9dSwXuQdhiC w6OHYOmDCOjFTrShI+S16KLvfXH7oq9sIWIYjw17RIeP6iRqI6RKNl1JS+KaFUI3 3aU/kaf/zuUHS/fxHscjg5Mm+w5cBmtdmZuvlPLWHhXo05dBSHadHLRpHVcLUfFA /Px1GOG02MQp7l9LiNr5D1+kGfy3NnKVTm1teegpQmKBHaV5LNKHBYhvpcBzIqJ+ zHHJMEMll2y+sfOn2vQAwwxYaTV1R9cTGZ4i8dK/0LhKKH6h7b9ATYcoT+PulBQy D9ZmFyxeHM2eKy6nIsseA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvgddtkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufgjfhgffffkgggtsehmtddtredtredtnecuhfhrohhmpefuvggrnhcu hghhihhtthhonhcuoehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqne cuggftrfgrthhtvghrnhepfeffhfegudeuueehkeejjefhgeelffdvveefheekvedukeeu keeuhedvueejvdfhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 May 2022 18:13:25 -0400 (EDT) Received: by melete.silentflame.com (Postfix, from userid 1000) id AA1267E5F71; Thu, 5 May 2022 15:13:24 -0700 (MST) From: Sean Whitton In-Reply-To: <871qx74or6.fsf@melete.silentflame.com> References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Thu, 05 May 2022 15:13:24 -0700 Message-ID: <87y1zf39x7.fsf@melete.silentflame.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Hello, On Thu 05 May 2022 at 03:07PM -07, Sean Whitton wrote: > Hello, > > On Wed 04 May 2022 at 12:26PM -04, Stefan Monnier wrote: > >>> It looks like Fother_window is called only from Fcall_interactively and >>> Fkill_buffer, so there probably isn't a bootstrapping issue if I make >>> those Ffuncall my new `get-initial-buffer-create'. It looks like >>> bootstrapping C code just makes an empty *scratch* and leaves it to >>> startup.el to initialise it. >> >> Even better, > > Here's my fix. Haven't quite finished testing each and every call site > but seemed worth posting it for comments. Hopefully fixed the commit message in the attached. -- Sean Whitton --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Factor-out-scratch-initialization.patch >From 9731fa66ff5b6e2ed3287ef033b71c584abadd12 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 5 May 2022 13:03:06 -0700 Subject: [PATCH] Factor out *scratch* initialization * lisp/simple.el: Require subr-x when compiling. (get-initial-buffer-create): New function, factored out of scratch-buffer, and additionally clearing the modification flag and calling substitute-command-keys (bug#55257). (scratch-buffer): * lisp/server.el (server-execute): * lisp/startup.el (normal-no-mouse-startup-screen, command-line-1): * lisp/window.el (last-buffer): * src/buffer.c (Fother_buffer, other_buffer_safely): Use it. * lisp/startup.el (startup--get-buffer-create-scratch): Delete now-unused function. --- lisp/server.el | 2 +- lisp/simple.el | 22 +++++++++++++++------- lisp/startup.el | 12 +++--------- lisp/window.el | 5 +---- src/buffer.c | 21 ++------------------- 5 files changed, 22 insertions(+), 40 deletions(-) diff --git a/lisp/server.el b/lisp/server.el index 763cf27f7a..042962b8e9 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1367,7 +1367,7 @@ server-execute ((functionp initial-buffer-choice) (funcall initial-buffer-choice))))) (switch-to-buffer - (if (buffer-live-p buf) buf (get-buffer-create "*scratch*")) + (if (buffer-live-p buf) buf (get-initial-buffer-create)) 'norecord))) ;; Delete the client if necessary. diff --git a/lisp/simple.el b/lisp/simple.el index 861d9eefde..5a37e246f7 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -28,7 +28,9 @@ ;;; Code: -(eval-when-compile (require 'cl-lib)) +(eval-when-compile + (require 'cl-lib) + (require 'subr-x)) (declare-function widget-convert "wid-edit" (type &rest args)) (declare-function shell-mode "shell" ()) @@ -10213,16 +10215,22 @@ capitalize-dwim the number of seconds east of Greenwich.") ) +(defun get-initial-buffer-create () + "Return the \*scratch\* buffer, creating a new one if needed." + (if-let ((scratch (get-buffer "*scratch*"))) + scratch + (prog1 (setq scratch (get-buffer-create "*scratch*")) + (with-current-buffer scratch + (when initial-scratch-message + (insert (substitute-command-keys initial-scratch-message)) + (set-buffer-modified-p nil)) + (funcall initial-major-mode))))) + (defun scratch-buffer () "Switch to the \*scratch\* buffer. If the buffer doesn't exist, create it first." (interactive) - (if (get-buffer "*scratch*") - (pop-to-buffer-same-window "*scratch*") - (pop-to-buffer-same-window (get-buffer-create "*scratch*")) - (when initial-scratch-message - (insert initial-scratch-message)) - (funcall initial-major-mode))) + (pop-to-buffer-same-window (get-initial-buffer-create))) diff --git a/lisp/startup.el b/lisp/startup.el index c7cf86a01e..3fa25ddee9 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2355,7 +2355,7 @@ normal-no-mouse-startup-screen (insert "\t\t") (insert-button "Open *scratch* buffer" 'action (lambda (_button) (switch-to-buffer - (startup--get-buffer-create-scratch))) + (get-initial-buffer-create))) 'follow-link t) (insert "\n") (save-restriction @@ -2487,12 +2487,6 @@ display-about-screen (defalias 'about-emacs 'display-about-screen) (defalias 'display-splash-screen 'display-startup-screen) -(defun startup--get-buffer-create-scratch () - (or (get-buffer "*scratch*") - (with-current-buffer (get-buffer-create "*scratch*") - (set-buffer-major-mode (current-buffer)) - (current-buffer)))) - ;; This avoids byte-compiler warning in the unexec build. (declare-function pdumper-stats "pdumper.c" ()) @@ -2784,7 +2778,7 @@ command-line-1 (when (eq initial-buffer-choice t) ;; When `initial-buffer-choice' equals t make sure that *scratch* ;; exists. - (startup--get-buffer-create-scratch)) + (get-initial-buffer-create)) ;; If *scratch* exists and is empty, insert initial-scratch-message. ;; Do this before switching to *scratch* below to handle bug#9605. @@ -2808,7 +2802,7 @@ command-line-1 ((functionp initial-buffer-choice) (funcall initial-buffer-choice)) ((eq initial-buffer-choice t) - (startup--get-buffer-create-scratch)) + (get-initial-buffer-create)) (t (error "`initial-buffer-choice' must be a string, a function, or t"))))) (unless (buffer-live-p buf) diff --git a/lisp/window.el b/lisp/window.el index 9f78784612..4ec329e0cf 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4886,10 +4886,7 @@ last-buffer (setq frame (or frame (selected-frame))) (or (get-next-valid-buffer (nreverse (buffer-list frame)) buffer visible-ok frame) - (get-buffer "*scratch*") - (let ((scratch (get-buffer-create "*scratch*"))) - (set-buffer-major-mode scratch) - scratch))) + (get-initial-buffer-create))) (defcustom frame-auto-hide-function #'iconify-frame "Function called to automatically hide frames. diff --git a/src/buffer.c b/src/buffer.c index f8a7a4f510..702b21f9fc 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1634,16 +1634,7 @@ DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0, if (!NILP (notsogood)) return notsogood; else - { - AUTO_STRING (scratch, "*scratch*"); - buf = Fget_buffer (scratch); - if (NILP (buf)) - { - buf = Fget_buffer_create (scratch, Qnil); - Fset_buffer_major_mode (buf); - } - return buf; - } + return call0 (intern ("get-initial-buffer-create")); } /* The following function is a safe variant of Fother_buffer: It doesn't @@ -1659,15 +1650,7 @@ other_buffer_safely (Lisp_Object buffer) if (candidate_buffer (buf, buffer)) return buf; - AUTO_STRING (scratch, "*scratch*"); - buf = Fget_buffer (scratch); - if (NILP (buf)) - { - buf = Fget_buffer_create (scratch, Qnil); - Fset_buffer_major_mode (buf); - } - - return buf; + return call0 (intern ("get-initial-buffer-create")); } DEFUN ("buffer-enable-undo", Fbuffer_enable_undo, Sbuffer_enable_undo, -- 2.30.2 --=-=-=-- From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Eli Zaretskii , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Eli Zaretskii , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Fri, 06 May 2022 05:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: rpluim@gmail.com, 55257-submitter@debbugs.gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.165181567417561 (code U ref 55257); Fri, 06 May 2022 05:42:01 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 6 May 2022 05:41:14 +0000 Received: from localhost ([127.0.0.1]:46877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmqiH-0004ZB-LL for submit@debbugs.gnu.org; Fri, 06 May 2022 01:41:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmqiG-0004Yz-6H for 55257-submitter@debbugs.gnu.org; Fri, 06 May 2022 01:41:13 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39130) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmqiA-0002iC-1t; Fri, 06 May 2022 01:41:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Jrv0LZWzCkY2VtaKS15cBomAI6DU0GUn0eMi4t/bYyY=; b=lNJXC8nfcptG of4Eo8m9caq+GSJi0gQ8OuwEyLesDAWFt+3hmwAE1HjmpvMnNPx2QTGiYM9FS2k6w9tHEEH6RtjEl kcSluclak6Fd5PPCA5JLo18QCavTPtVOGxhiYPeO25paoRNtwIju9mX9HB/Ypu7dJNQqqZbIdl9yW ikwnAgkRPwOa82WglQc1wnvF31DLzWSI1ccNs88cbvW8TdsDDv0cyE8/cOYk7okYKhk/K/KRDKyzm t8i75qdgNtr2xBgi+8YYsIulTsyluv+tLd0f0GNrz+sjyqtQ5NfklwFwUP+4uYZfNyUK/Gdcvj56p ErFcQieF/IOEBqbuQ+N6IA==; Received: from [87.69.77.57] (port=1102 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmqi9-0005a7-A7; Fri, 06 May 2022 01:41:05 -0400 Date: Fri, 06 May 2022 08:40:50 +0300 Message-Id: <83r1571an1.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <871qx74or6.fsf@melete.silentflame.com> (message from Sean Whitton on Thu, 05 May 2022 15:07:41 -0700) References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Sean Whitton > Cc: Robert Pluim , emacs-devel@gnu.org, > 55257-submitter@debbugs.gnu.org > Date: Thu, 05 May 2022 15:07:41 -0700 > > -(eval-when-compile (require 'cl-lib)) > +(eval-when-compile > + (require 'cl-lib) > + (require 'subr-x)) Why did you need subr-x here? AFAIR, doing this breaks bootstrap, which is why if-let is now in subr.el. > +(defun get-initial-buffer-create () > + "Return the \*scratch\* buffer, creating a new one if needed." > + (if-let ((scratch (get-buffer "*scratch*"))) > + scratch > + (prog1 (setq scratch (get-buffer-create "*scratch*")) > + (with-current-buffer scratch > + (when initial-scratch-message > + (insert (substitute-command-keys initial-scratch-message)) > + (set-buffer-modified-p nil)) > + (funcall initial-major-mode))))) It's somewhat inelegant to explicitly test for the buffer's existence before you call get-buffer-create. Is that only to avoid changing its contents? If so, can't you test for that in some other way? > + return call0 (intern ("get-initial-buffer-create")); Instead of calling intern each time this function is called from C, it is better to define a symbol for it, usually named Qget_initial_buffer_create, and then call0 it directly. > /* The following function is a safe variant of Fother_buffer: It doesn't > @@ -1659,15 +1650,7 @@ other_buffer_safely (Lisp_Object buffer) > if (candidate_buffer (buf, buffer)) > return buf; > > - AUTO_STRING (scratch, "*scratch*"); > - buf = Fget_buffer (scratch); > - if (NILP (buf)) > - { > - buf = Fget_buffer_create (scratch, Qnil); > - Fset_buffer_major_mode (buf); > - } > - > - return buf; > + return call0 (intern ("get-initial-buffer-create")); get-initial-buffer-create shows the initial-scratch-message, something the C code you are replacing didn't do. This is a change in behavior that should at least be documented, if not fixed. I also wonder whether we should use safe_call in these places. Thanks. From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Juri Linkov , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Juri Linkov , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Fri, 06 May 2022 08:00:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: Robert Pluim , 55257-submitter@debbugs.gnu.org, Stefan Monnier , emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.16518239497120 (code U ref 55257); Fri, 06 May 2022 08:00:04 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 6 May 2022 07:59:09 +0000 Received: from localhost ([127.0.0.1]:46995 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmsrl-0001qm-8Y for submit@debbugs.gnu.org; Fri, 06 May 2022 03:59:09 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:45763) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmsrj-0001q8-0q for 55257-submitter@debbugs.gnu.org; Fri, 06 May 2022 03:59:07 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 53A28E0010; Fri, 6 May 2022 07:58:56 +0000 (UTC) From: Juri Linkov Organization: LINKOV.NET References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> Date: Fri, 06 May 2022 10:41:06 +0300 In-Reply-To: <871qx74or6.fsf@melete.silentflame.com> (Sean Whitton's message of "Thu, 05 May 2022 15:07:41 -0700") Message-ID: <86h763ds6l.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Here's my fix. Haven't quite finished testing each and every call site > but seemed worth posting it for comments. As found in https://debbugs.gnu.org/9054#295 there is another place that needs get-initial-buffer-create in switch-to-buffer: if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0) function = find_symbol_value (intern ("initial-major-mode")); From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Stefan Monnier , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Stefan Monnier , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Fri, 06 May 2022 11:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: Robert Pluim , 55257-submitter@debbugs.gnu.org, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.16518368916292 (code U ref 55257); Fri, 06 May 2022 11:35:02 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 6 May 2022 11:34:51 +0000 Received: from localhost ([127.0.0.1]:47283 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmwEV-0001dP-Cw for submit@debbugs.gnu.org; Fri, 06 May 2022 07:34:51 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:47985) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmwET-0001dB-08 for 55257-submitter@debbugs.gnu.org; Fri, 06 May 2022 07:34:49 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3D9A9440F2E; Fri, 6 May 2022 07:34:43 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id EA7574407CA; Fri, 6 May 2022 07:34:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1651836881; bh=mKNt7dnHw9iiil19W1B8pIw4ZLjBCX8zJ1WfBd6raTo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Fy2+F2/vXVWdzfU7p5FFg+7LxHREerkKRgTw3pkYrkKiJn8+GRit7wsyDFeF+NX7Q q0Xc231RtSksWRoqjBUKGW/yTCgLMJjg2JLSgI/OcSgP4oTo/oYQvCz74BClAB2T/P Lmatp3xcUB6vsPxhwznEpBh1wW79DdngHKVrgtqxi1T+adx/SZofeVUDHOhSPwpeYn RXVfOsKCIJMY1xgt6riKlmNrZK8IklYlveT4gT84D86bTZ6qw1hCqsDYrowFKFva5g PMO1IPyZbFXdTNH51/HeiPDzlG02GQPV7SrwSW6105grxG45nMI4oAX2FEx9+xiJJL 6ROLuzU2A3ZUg== Received: from pastel (unknown [45.72.221.51]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6A68012023B; Fri, 6 May 2022 07:34:41 -0400 (EDT) From: Stefan Monnier Message-ID: References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <87y1zf39x7.fsf@melete.silentflame.com> Date: Fri, 06 May 2022 07:34:40 -0400 In-Reply-To: <87y1zf39x7.fsf@melete.silentflame.com> (Sean Whitton's message of "Thu, 05 May 2022 15:13:24 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.052 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > + (if-let ((scratch (get-buffer "*scratch*"))) > + scratch A.k.a (or (get-buffer "*scratch*") > (defun scratch-buffer () > "Switch to the \*scratch\* buffer. > If the buffer doesn't exist, create it first." > (interactive) > - (if (get-buffer "*scratch*") > - (pop-to-buffer-same-window "*scratch*") > - (pop-to-buffer-same-window (get-buffer-create "*scratch*")) > - (when initial-scratch-message > - (insert initial-scratch-message)) > - (funcall initial-major-mode))) > + (pop-to-buffer-same-window (get-initial-buffer-create))) I think the new function can be considered "internal", and I think it would be better for its name to use "scratch-buffer" as a prefix, so maybe `scratch-buffer--create`? Other than that, it looks good to me, thank you very much. Stefan From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Fri, 06 May 2022 19:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Robert Pluim , 55257-submitter@debbugs.gnu.org, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.16518648206254 (code U ref 55257); Fri, 06 May 2022 19:21:01 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 6 May 2022 19:20:20 +0000 Received: from localhost ([127.0.0.1]:49857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nn3Uy-0001co-Gi for submit@debbugs.gnu.org; Fri, 06 May 2022 15:20:20 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:55709) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nn3Ux-0001cX-5E for 55257-submitter@debbugs.gnu.org; Fri, 06 May 2022 15:20:19 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1D1525C0075; Fri, 6 May 2022 15:20:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 06 May 2022 15:20:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1651864814; x=1651951214; bh=m6 qq2HypqBmtVSxFHKZ+ujG3owY991/l+wKaXg+ttvw=; b=hA76BwdFOaERNlgZ06 CB6Qb8kilvLw8nSOPhyPvEiGyIeRzsnLEjZ6AqIQ2YqTeURN+1PA1exyMliUWceT nS+VgbUaxgouzsmla0wVVwGOcbusJVybHEjY2R1ejPnzX6yslxRatV6y7mOnwDbj rsTP5sBZcnW6tJ50BfNqpY3iwtiuDjXFREVpc+O6NZB0aSSVm96srsTf12aSCeH5 zHHRDj2DumFJMhhqVlj2ZlW5VjnE85Y54IZSOKkQDK+UsOee7bQq5J+rnetatywX 3V5HlIF+dPObB7ubXX8Wv6bcaGJHkwkfkHoAgLVWy0wwlOfdz8+KDczuNPRpSznT SUkA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651864814; x= 1651951214; bh=m6qq2HypqBmtVSxFHKZ+ujG3owY991/l+wKaXg+ttvw=; b=p xcYI1wAMK8ucUlIDD71ceMBKr+h6iAZRAjkkR9kmaYWDRGRfVxVxcwX9cP2lN+gi OwFOqG0JBS17UnIV/J1TkaAEBkEmeeKdq6Iovf53pWrB5sdnJS5rlaJxt+FP7Yy/ y8VUeJ2ZvM476KgkpnYh09P90lCA7o49tTX+JynrJyH770UDCmiYo59kaVdB36l+ xZNpYcIjgAS0aW/Mr/AP0btDRUNc+uSmF7Gsr2uYjCElJu2Y8oosR0n9hTpyy1gd iFP2WYo+QVGIinKeyey0ipBAvV+G9gope5i5baOfbF832VgAfW48/+0UNkgZCyk0 AurzrIpTKsEEqE5M1rl9g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgddufeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffgffkfggtgesthdttddttdertdenucfhrhhomhepufgvrghn ucghhhhithhtohhnuceoshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpedvjeettdeiteejgeejkefggfehtdekledtfedtteekgfeu keeftdduhfetleejkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 6 May 2022 15:20:13 -0400 (EDT) Received: by athena.silentflame.com (Postfix, from userid 1000) id B6BFC1C0503; Fri, 6 May 2022 19:20:11 +0000 (UTC) From: Sean Whitton In-Reply-To: References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <87y1zf39x7.fsf@melete.silentflame.com> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Fri, 06 May 2022 12:20:11 -0700 Message-ID: <874k22eadw.fsf@athena.silentflame.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello Stefan, On Fri 06 May 2022 at 07:34am -04, Stefan Monnier wrote: >> + (if-let ((scratch (get-buffer "*scratch*"))) >> + scratch > > A.k.a > > (or (get-buffer "*scratch*") Ah yes. >> (defun scratch-buffer () >> "Switch to the \*scratch\* buffer. >> If the buffer doesn't exist, create it first." >> (interactive) >> - (if (get-buffer "*scratch*") >> - (pop-to-buffer-same-window "*scratch*") >> - (pop-to-buffer-same-window (get-buffer-create "*scratch*")) >> - (when initial-scratch-message >> - (insert initial-scratch-message)) >> - (funcall initial-major-mode))) >> + (pop-to-buffer-same-window (get-initial-buffer-create))) > > I think the new function can be considered "internal", and I think it > would be better for its name to use "scratch-buffer" as a prefix, so > maybe `scratch-buffer--create`? It gets called in places like server.el, though. And I can imagine wanting to use it in third party code as a better version of (get-buffer-create "*scratch"*). So it seems to me not to be internal. -- Sean Whitton From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Lars Ingebrigtsen , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Lars Ingebrigtsen , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Fri, 06 May 2022 19:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: Robert Pluim , 55257-submitter@debbugs.gnu.org, Stefan Monnier , emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.16518650576640 (code U ref 55257); Fri, 06 May 2022 19:25:01 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 6 May 2022 19:24:17 +0000 Received: from localhost ([127.0.0.1]:49862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nn3Yn-0001j1-0m for submit@debbugs.gnu.org; Fri, 06 May 2022 15:24:17 -0400 Received: from quimby.gnus.org ([95.216.78.240]:40484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nn3Yk-0001io-Pp for 55257-submitter@debbugs.gnu.org; Fri, 06 May 2022 15:24:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=V7dOA9nWx6Qdk0Paioms3b7CukIBB3MnjY808jTryLc=; b=lgsd3aIizVASDDHfG1Y0rGgz3P yRs8+r55A6ISXZAIknAYZ1O3gUyrD2hq5+7zaFDT5hxEu2sk112frrwyKfM1KkhOMX9l19G4+1CaJ YWlR2/f+J0mzoVDL4DWHOQHCAzZuMjJVhWuDO0t3HLL7a7O0Ft2Es0eFhto6JHbAW/iM=; Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nn3YZ-00024B-Kd; Fri, 06 May 2022 21:24:06 +0200 From: Lars Ingebrigtsen References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <87y1zf39x7.fsf@melete.silentflame.com> <874k22eadw.fsf@athena.silentflame.com> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEXaOQLkViP2spH/ //9y+Ee7AAAAAWJLR0QDEQxM8gAAAAd0SU1FB+YFBhMWOMu4kvMAAAEsSURBVCjPrZK/boMwEMbP UWBOJSzRPUPapzBVG6kbSDFS2RoVRPwUyUgmWsVD2ToEhXvK+r94gHws9+POx/k7AJQiyFfAwIhw LusGMYcSg5gDgRPPTVnEXWC1MkcZENwPp+nUYSt7IOt9l11+uvRpULXr5vzajl36+N0r+OyK98M5 3UgN9XCspaRJ6WYAUhQ8AaDcaadfaoL7KJrFxDRdWqDzL1QSeLgmZyC0EVZLnfGwmXdrQ6jcED6m qnbyJTdlFDrI8kX2NrrEhVbZ8Gf7k3GLDKWdllyriqGZjSiPp+xlMvDAYsRdbAE0/IpR2o0s9MK8 Y9EBx5u/Nvlohj7Alj+zAH0u1N7cbFcQRweJetCXqeEsELsdYjO8VL/O1wIZCSYqiLg7AzEyyv8B CJdkPxkQ068AAAAldEVYdGRhdGU6Y3JlYXRlADIwMjItMDUtMDZUMTk6MjI6NTUrMDA6MDATDOiN AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIyLTA1LTA2VDE5OjIyOjU1KzAwOjAwYlFQMQAAAABJRU5E rkJggg== X-Now-Playing: The Smiths's _Complete (8): Louder Than Bombs_: "Half a Person" Date: Fri, 06 May 2022 21:24:02 +0200 In-Reply-To: <874k22eadw.fsf@athena.silentflame.com> (Sean Whitton's message of "Fri, 06 May 2022 12:20:11 -0700") Message-ID: <87o80aforx.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Sean Whitton writes: > It gets called in places like server.el, though. And I can imagine > wanting to use it in third party code as a better version of > (get-buffer-create "*scratch"*). So it seems to me not to be inter [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Sean Whitton writes: > It gets called in places like server.el, though. And I can imagine > wanting to use it in third party code as a better version of > (get-buffer-create "*scratch"*). So it seems to me not to be internal. scratch-buffer isn't meant as an internal function, but a command users can use to recreate the *scratch* buffer. (It's a question that comes up from users once in a while.) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Fri, 06 May 2022 19:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: rpluim@gmail.com, 55257-submitter@debbugs.gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.16518652166881 (code U ref 55257); Fri, 06 May 2022 19:27:02 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 6 May 2022 19:26:56 +0000 Received: from localhost ([127.0.0.1]:49868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nn3bL-0001mv-ES for submit@debbugs.gnu.org; Fri, 06 May 2022 15:26:55 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:56919) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nn3bJ-0001mh-2b for 55257-submitter@debbugs.gnu.org; Fri, 06 May 2022 15:26:53 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id F3E8F5C00AB; Fri, 6 May 2022 15:26:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 06 May 2022 15:26:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1651865207; x=1651951607; bh=S/ 1wLwP6+L5oZX447jeP9LGQROUBp8n/c6IkpBFlE9c=; b=jPqEBdAq97I73M1wrT 4zOORCCL4k5ZR4tgnmw81hfoYHnBOASw4rc1rCgjPR6KpA0wd7uD4xsd4NSj2vMO bokKu1LgQufbstjpq0tio8Yt/+2SQ9J1dCgO1iwrdT7FUH+iCOehl/kkFWvqdxmc t3scsMNvjFYK6WZlN93128/B47Udhpi282+iG8PZGvS+rYYOecyLqDOUE4phQx5W SWCg9lpb/trL+l3B110cNgqMEVMvRg4+p446GzlpQcYu4I2NrZA7q/p0maKohUaj h1O/FN0mX3iIDmWHSO9OLEIJ82ZdQvxDuvbbshJv4S6yOqGGo91QBrdVbXrwN3sB MEKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651865207; x= 1651951607; bh=S/1wLwP6+L5oZX447jeP9LGQROUBp8n/c6IkpBFlE9c=; b=Q +jM7vJrtMlSCNSfLD80Oh3M104J7C0v0DMWrNVbSYvufNVVR/SjUb+FhMHjMQE/t Lv9ruo09KRn31mSbeRQ1z9zb+SI59cGvdWD4M1SJt7nZLmsvMjAU0/uxTq3kLmbP C1H5FfQUZf7cfbe9gvUq6wENXLqgIWC3+hCvtFscVE6lzHzudhKS0erMqpMMzuwO T/PC8y0nkX3mTKfv6UhRdWptDXy8+91BpkR531jdGy5+POHLei3FdcUpNhDed6Ux aS64TPKOBBNtml+RyevhF8fdjHuVw6VmmNotbYe0c+uHyk9VnZIh699v/5Hd57Mf odLKrnFBPJBNDkcugwn6A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgddufeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffgffkfggtgesthdttddttdertdenucfhrhhomhepufgvrghn ucghhhhithhtohhnuceoshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpedvjeettdeiteejgeejkefggfehtdekledtfedtteekgfeu keeftdduhfetleejkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 6 May 2022 15:26:47 -0400 (EDT) Received: by athena.silentflame.com (Postfix, from userid 1000) id CBCBF1C0503; Fri, 6 May 2022 19:26:46 +0000 (UTC) From: Sean Whitton In-Reply-To: <83r1571an1.fsf@gnu.org> References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <83r1571an1.fsf@gnu.org> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Fri, 06 May 2022 12:26:46 -0700 Message-ID: <871qx6ea2x.fsf@athena.silentflame.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, On Fri 06 May 2022 at 08:40am +03, Eli Zaretskii wrote: >> From: Sean Whitton >> Cc: Robert Pluim , emacs-devel@gnu.org, >> 55257-submitter@debbugs.gnu.org >> Date: Thu, 05 May 2022 15:07:41 -0700 >> >> -(eval-when-compile (require 'cl-lib)) >> +(eval-when-compile >> + (require 'cl-lib) >> + (require 'subr-x)) > > Why did you need subr-x here? AFAIR, doing this breaks bootstrap, > which is why if-let is now in subr.el. Ah, my mistake, I didn't know it had moved (though I'm going to get rid of the if-let I think). >> +(defun get-initial-buffer-create () >> + "Return the \*scratch\* buffer, creating a new one if needed." >> + (if-let ((scratch (get-buffer "*scratch*"))) >> + scratch >> + (prog1 (setq scratch (get-buffer-create "*scratch*")) >> + (with-current-buffer scratch >> + (when initial-scratch-message >> + (insert (substitute-command-keys initial-scratch-message)) >> + (set-buffer-modified-p nil)) >> + (funcall initial-major-mode))))) > > It's somewhat inelegant to explicitly test for the buffer's existence > before you call get-buffer-create. Is that only to avoid changing its > contents? If so, can't you test for that in some other way? I had the same intuition at first, but I don't think there is another way -- the code wants to touch the buffer at all only if it wasn't already there. And the code path where it already exists will be by far the most commonly called, so it seems best to avoid calling with-current-buffer if we don't have to. >> + return call0 (intern ("get-initial-buffer-create")); > > Instead of calling intern each time this function is called from C, it > is better to define a symbol for it, usually named > Qget_initial_buffer_create, and then call0 it directly. Will do. >> /* The following function is a safe variant of Fother_buffer: It doesn't >> @@ -1659,15 +1650,7 @@ other_buffer_safely (Lisp_Object buffer) >> if (candidate_buffer (buf, buffer)) >> return buf; >> >> - AUTO_STRING (scratch, "*scratch*"); >> - buf = Fget_buffer (scratch); >> - if (NILP (buf)) >> - { >> - buf = Fget_buffer_create (scratch, Qnil); >> - Fset_buffer_major_mode (buf); >> - } >> - >> - return buf; >> + return call0 (intern ("get-initial-buffer-create")); > > get-initial-buffer-create shows the initial-scratch-message, something > the C code you are replacing didn't do. This is a change in behavior > that should at least be documented, if not fixed. This is deliberate -- to my mind I'm fixing the same bug as the one in server.el. other-buffer recreates *scratch* for the same sort of reasons that 'emacsclient -nc' does. Where were you thinking it should be documented? The Emacs Lisp changes section of NEWS? > I also wonder whether we should use safe_call in these places. Could you say more? -- Sean Whitton From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Fri, 06 May 2022 19:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: Robert Pluim , 55257-submitter@debbugs.gnu.org, Stefan Monnier , emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.16518653147053 (code U ref 55257); Fri, 06 May 2022 19:29:01 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 6 May 2022 19:28:34 +0000 Received: from localhost ([127.0.0.1]:49874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nn3cw-0001pg-09 for submit@debbugs.gnu.org; Fri, 06 May 2022 15:28:34 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:45463) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nn3cv-0001pQ-19 for 55257-submitter@debbugs.gnu.org; Fri, 06 May 2022 15:28:33 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id EBB065C0100; Fri, 6 May 2022 15:28:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 06 May 2022 15:28:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1651865307; x=1651951707; bh=KY g8BYDDfY8UOC+jeUMvBEdIWAO7RL8yShboUjYmUb4=; b=SRBwZ/pHD3jcuEqLTL UtoXKNBOL5raB1zMosyEQr2XbxfRVhCm0KEdvqQsO36YfB29ffd7dVGts19J9nxJ qjkgN/EBj3tG7cfuB5RT/LxrELusxJZav14RMZ5dlGNYf2fhcGPcSz2DI00ByO0H Rza1F3o651ejNx1G2kx5yYNYa4Vgj2oKHq1pGvt/9vYCr1S4sZ0HBkXMGDZnTKsP TnAAhvVF8CG1ehtXPxzcQYaX1FoAvpL02jJ2cV1NXp67Wo8FrKjZDx0XVMyONCj/ DOfEN/L1Z49EeGFv1jCqQZ/jU8fpOzQh568G+K+LCI9wu02Y0Z5CQx0JFQz/4eCR PyeA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651865307; x= 1651951707; bh=KYg8BYDDfY8UOC+jeUMvBEdIWAO7RL8yShboUjYmUb4=; b=I k9hDaBbpaDvPCpYokWZ7j/GIsc9+jv3H90qDluCX+9Mui0YTH7D1oFtiV3+/4E5f jdEcTtljB1u7o35LFMxowkSfIKZcgYFsGd3f7II8AMYm2tdu657TPdfBTdu+ysHH 8Y7PKsK1Bz2QhaP21fkHJejRtPBWuC56FnRuUA8s+gJkaVVsyT8RciOO83Ir7Os0 mxU3XA2zr+m9uTbJVNSz7JPTbn6ZS19qfRATD5cGQWmofvgippOoUF06GJpZNpS9 HNRy8zVsx/eSL7WtV2j/jxVLTwpWeJ3fqYZ3SePu6hIhBZkw0HzVYdHcFd9aKQO5 4no0HBYLfJDgmlHx0Hx8w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgddufeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffgffkfggtgesthdttddttdertdenucfhrhhomhepufgvrghn ucghhhhithhtohhnuceoshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpeevuedujeeuveeuveevfedvtdduueekjeevgfeuveeihfek ffehjeegtdehleeivdenucffohhmrghinhepghhnuhdrohhrghenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsphifhhhithhtohhnsehsphif hhhithhtohhnrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 6 May 2022 15:28:27 -0400 (EDT) Received: by athena.silentflame.com (Postfix, from userid 1000) id 820F51C0503; Fri, 6 May 2022 19:28:25 +0000 (UTC) From: Sean Whitton In-Reply-To: <86h763ds6l.fsf@mail.linkov.net> References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <86h763ds6l.fsf@mail.linkov.net> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Fri, 06 May 2022 12:28:25 -0700 Message-ID: <87y1zecvfq.fsf@athena.silentflame.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, On Fri 06 May 2022 at 10:41am +03, Juri Linkov wrote: >> Here's my fix. Haven't quite finished testing each and every call site >> but seemed worth posting it for comments. > > As found in https://debbugs.gnu.org/9054#295 > there is another place that needs get-initial-buffer-create > in switch-to-buffer: > > if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0) > function = find_symbol_value (intern ("initial-major-mode")); Yes I think you're right. I'll add that to my patch, thanks. -- Sean Whitton From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Eli Zaretskii , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Eli Zaretskii , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Sat, 07 May 2022 05:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: rpluim@gmail.com, 55257-submitter@debbugs.gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.165190142629571 (code U ref 55257); Sat, 07 May 2022 05:31:02 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 7 May 2022 05:30:26 +0000 Received: from localhost ([127.0.0.1]:50235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnD1O-0007gt-E0 for submit@debbugs.gnu.org; Sat, 07 May 2022 01:30:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnD1M-0007gd-B5 for 55257-submitter@debbugs.gnu.org; Sat, 07 May 2022 01:30:24 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:33452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnD1F-0000XP-Vu; Sat, 07 May 2022 01:30:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Ezd5cwbbZv6RgO4trctvKfiL2GtxFUesmadHv/9ykCc=; b=G5nlKToX65g/ xsVvtbIio1IouDZWkodXbUvLfvrm33TL5uPyNOpncc40a1LG2KzXd4zZKxfC/tWvo1iqLl/5XUBsG KSjN9qbjsOTP68eXqkvQA9Da8u3xEw7aDGgXHmlnS95R7WMpjTD+5R0ecSqTk2fChUycoGrzwIwOY 7wtgI5C3etk3gNzZdcpW1qev88u+uODDE3hKBaTtD3q/B4Pu6lEeDDwAXrQiGAkmxYOtup1Lt76N1 c/tMmY0bV6UJTFjYnSGjosulozKQ4BNX/xe7tu9jcUb9pdaIFQc1m6s5E9STUIt+yaqE8p0Exb9Xv KSKhNsZo5xHTti9KvMHbrw==; Received: from [87.69.77.57] (port=1780 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnD1F-00075B-Eu; Sat, 07 May 2022 01:30:17 -0400 Date: Sat, 07 May 2022 08:30:06 +0300 Message-Id: <83tua1zz8h.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <871qx6ea2x.fsf@athena.silentflame.com> (message from Sean Whitton on Fri, 06 May 2022 12:26:46 -0700) References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <83r1571an1.fsf@gnu.org> <871qx6ea2x.fsf@athena.silentflame.com> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Sean Whitton > Cc: monnier@iro.umontreal.ca, rpluim@gmail.com, emacs-devel@gnu.org, > 55257-submitter@debbugs.gnu.org > Date: Fri, 06 May 2022 12:26:46 -0700 > > >> +(defun get-initial-buffer-create () > >> + "Return the \*scratch\* buffer, creating a new one if needed." > >> + (if-let ((scratch (get-buffer "*scratch*"))) > >> + scratch > >> + (prog1 (setq scratch (get-buffer-create "*scratch*")) > >> + (with-current-buffer scratch > >> + (when initial-scratch-message > >> + (insert (substitute-command-keys initial-scratch-message)) > >> + (set-buffer-modified-p nil)) > >> + (funcall initial-major-mode))))) > > > > It's somewhat inelegant to explicitly test for the buffer's existence > > before you call get-buffer-create. Is that only to avoid changing its > > contents? If so, can't you test for that in some other way? > > I had the same intuition at first, but I don't think there is another > way -- the code wants to touch the buffer at all only if it wasn't > already there. What do you mean by "touch"? Doesn't get-buffer already "touch" the buffer if it exists? And determining whether the buffer has any stuff in it (if this is the concern here) is just one function call away, and is very fast. > And the code path where it already exists will be by far > the most commonly called, so it seems best to avoid calling > with-current-buffer if we don't have to. But get-buffer-create already does all that internally, and it exists for this very purpose. I don't really understand the objections, to tell the truth. Unless some more fundamental problem is involved, which is why I asked about the reasons. > >> + return call0 (intern ("get-initial-buffer-create")); > > > > get-initial-buffer-create shows the initial-scratch-message, something > > the C code you are replacing didn't do. This is a change in behavior > > that should at least be documented, if not fixed. > > This is deliberate -- to my mind I'm fixing the same bug as the one in > server.el. other-buffer recreates *scratch* for the same sort of > reasons that 'emacsclient -nc' does. > > Where were you thinking it should be documented? The Emacs Lisp changes > section of NEWS? This is not about Emacs Lisp, this is an incompatible behavior change, and we have a section for that in NEWS. > > I also wonder whether we should use safe_call in these places. > > Could you say more? My bother is that the function you call could signal an error at some point, and that could cause trouble to some of the callers, perhaps. Calling Lisp from C should always assume this could happen, because basically the Lisp function you call is out of your control, and you cannot reliably assume anything about what it does or will do at some future time. Does this answer your question? From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Stefan Monnier , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Stefan Monnier , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Sat, 07 May 2022 13:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: rpluim@gmail.com, emacs-devel@gnu.org, 55257-submitter@debbugs.gnu.org, Sean Whitton Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.165193152524148 (code U ref 55257); Sat, 07 May 2022 13:53:02 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 7 May 2022 13:52:05 +0000 Received: from localhost ([127.0.0.1]:50807 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnKqr-0006HP-JM for submit@debbugs.gnu.org; Sat, 07 May 2022 09:52:05 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:33286) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnKqq-0006Gv-6I for 55257-submitter@debbugs.gnu.org; Sat, 07 May 2022 09:52:04 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 58F03440C44; Sat, 7 May 2022 09:51:58 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C8175440ABD; Sat, 7 May 2022 09:51:56 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1651931516; bh=FHmSdTLH8rXojfrzyZW2XtHHG4IDfm7kqAg65AODB+0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=b3YjXSvj6OajgVn0eU6F2IKuY3hp3lUQBpNz2DBvEk2hEvXiGhSN1rFo5RX9x9EwJ NwP5oN7kNicO5gHIvcvKf4V74EK1QVwFUpVITzqXSSpJVh8CXSFcA6/qq55+6cuGNe DJJ9TByg7ED+mE8/+zVjiFaNCdm5dH6vxUzbMbfP+WVbbmvKeCYtdflm7DPcw8ATS3 sUHQaLoTuKD89BmTEp7GNPvKuJY9dex0+kwM/ORY6O+uQDd3LpmghFJpCgzbR5nnbn P9Zm2OlZBkwPrfmMYOFDVbCFVlGPS8SBMCbIJq+HmlO5vNcIjh0JzzcNR5D84KArlx xugTq7WyTERgA== Received: from alfajor (modemcable034.207-20-96.mc.videotron.ca [96.20.207.34]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 75127120278; Sat, 7 May 2022 09:51:56 -0400 (EDT) From: Stefan Monnier Message-ID: References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <83r1571an1.fsf@gnu.org> <871qx6ea2x.fsf@athena.silentflame.com> <83tua1zz8h.fsf@gnu.org> Date: Sat, 07 May 2022 09:51:54 -0400 In-Reply-To: <83tua1zz8h.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 07 May 2022 08:30:06 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.155 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> I had the same intuition at first, but I don't think there is another >> way -- the code wants to touch the buffer at all only if it wasn't >> already there. > What do you mean by "touch"? Modify the buffer in any way (change its content or some of its buffer-local variables (e.g. the major mode)). His code just reproduces the existing code's behavior, AFAICT. > Doesn't get-buffer already "touch" the buffer if it exists? > And determining whether the buffer has any stuff in it (if this is the > concern here) is just one function call away, and is very fast. Not sure what it is we'd be gaining. The code is just trying to avoid modifying the buffer in any way (since that would likely lose information or undo something the user did, without its explicit request). > But get-buffer-create already does all that internally, and it exists > for this very purpose. I don't really understand the objections, to > tell the truth. Unless some more fundamental problem is involved, > which is why I asked about the reasons. Indeed `get-buffer-create` begins by calling `get-buffer` so there's redundancy at run-time. But we don't export any `create-buffer` function which presumes that there is no buffer by that name, so when we want to create a buffer named *scratch* and we know there is no such buffer yet, we still have to call `get-buffer-create` :-( Since we want to preserve the invariant that there can't be two buffers with the same name, we don't have much choice in this matter (we couldn't offer a `create-buffer` and just trust users to only call it when it's safe, tho we could do that in the C code that's not exported to ELisp). > My bother is that the function you call could signal an error at some > point, and that could cause trouble to some of the callers, perhaps. > Calling Lisp from C should always assume this could happen, because > basically the Lisp function you call is out of your control, and you > cannot reliably assume anything about what it does or will do at some > future time. I think this is not needed here, or at least we haven't needed it so far: the old C code called `Fset_buffer_major_mode` which itself calls `call0 (function);` where `function` is the `initial-major-mode`. Stefan From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Eli Zaretskii , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Eli Zaretskii , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Sat, 07 May 2022 14:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: rpluim@gmail.com, emacs-devel@gnu.org, 55257-submitter@debbugs.gnu.org, spwhitton@spwhitton.name Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.165193278328007 (code U ref 55257); Sat, 07 May 2022 14:14:01 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 7 May 2022 14:13:03 +0000 Received: from localhost ([127.0.0.1]:52644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnLB9-0007Hf-1I for submit@debbugs.gnu.org; Sat, 07 May 2022 10:13:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58228) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnLB7-0007H6-8r for 55257-submitter@debbugs.gnu.org; Sat, 07 May 2022 10:13:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnLB1-0003ZW-Fh; Sat, 07 May 2022 10:12:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Ozo/MbugOepo3a2Pr1JgF+339mfVASXatD2syQiP38M=; b=oOhK+zSqYieZ FVkLi33sZM4uEesKpzGY5fDd2mea0e3hWk60565mVblMZWL9RihNbOCcUTgX5Dxz8emA2gES7DU2M S6qqCkus47IsvIyqdOu+2FLT6f/4kKxYBWozp8FIZuKkMMPiEI4yZUoRuVzMJclyjkbCV0Hlb/+nZ 5Shp/5hn1PSt8wduWy8d6Jp6qXTL77SBIHI66Ujuwl0cGvZSPiFCO4quoO0pxarvzSvJquexcJbgb NhrDqbfCH2mYS2DaajwTcVa+S/jDOavbk6rIa8j/jG68qZLUs7gCr/Ok3kVywljwLc2VvcciT+D8C QCbtevltzYiwYB8d5eSBrg==; Received: from [87.69.77.57] (port=2767 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnLB0-00071e-V6; Sat, 07 May 2022 10:12:55 -0400 Date: Sat, 07 May 2022 17:12:45 +0300 Message-Id: <83r155xwgy.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Stefan Monnier on Sat, 07 May 2022 09:51:54 -0400) References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <83r1571an1.fsf@gnu.org> <871qx6ea2x.fsf@athena.silentflame.com> <83tua1zz8h.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: Sean Whitton , rpluim@gmail.com, > emacs-devel@gnu.org, 55257-submitter@debbugs.gnu.org > Date: Sat, 07 May 2022 09:51:54 -0400 > > > Doesn't get-buffer already "touch" the buffer if it exists? > > And determining whether the buffer has any stuff in it (if this is the > > concern here) is just one function call away, and is very fast. > > Not sure what it is we'd be gaining. We will gain that I won't raise my brow and won't want to change that code each time my eyes fall on it. > > My bother is that the function you call could signal an error at some > > point, and that could cause trouble to some of the callers, perhaps. > > Calling Lisp from C should always assume this could happen, because > > basically the Lisp function you call is out of your control, and you > > cannot reliably assume anything about what it does or will do at some > > future time. > > I think this is not needed here, or at least we haven't needed it so > far: the old C code called `Fset_buffer_major_mode` which itself > calls `call0 (function);` where `function` is the `initial-major-mode`. We have recently learned that these calls are not safe enough, so I think using safe_call's family here will be more future-proof, as more and more code is moved to Lisp and more and more hooks are bing added. So I'm still unconvinced, and would like this code to be safer. From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Sat, 07 May 2022 16:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: rpluim@gmail.com, 55257-submitter@debbugs.gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.165194100026407 (code U ref 55257); Sat, 07 May 2022 16:30:02 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 7 May 2022 16:30:00 +0000 Received: from localhost ([127.0.0.1]:52854 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnNJg-0006rr-4v for submit@debbugs.gnu.org; Sat, 07 May 2022 12:30:00 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:56151) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnNJf-0006rb-4o for 55257-submitter@debbugs.gnu.org; Sat, 07 May 2022 12:29:59 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id CB0D032000D7; Sat, 7 May 2022 12:29:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 07 May 2022 12:29:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1651940992; x=1652027392; bh=hC iER9OVnIrtr9z+NcWKnoVzZOndiSeCDvmgYOsuWvM=; b=djPkheo5Y3AxVO3xRV lqRqHoGVePQzXSq7RulW/5IjBkPy9zk7mWAy5A0XKMnGFXAVnz3QSgeOKXY6ibDQ bD+spXk/6nEG9wwY0KNJIdfEWNUx7vCRQFnhr13HFSBU53Uy3+6a5LNd646JqVP6 cD3CyZitQ35qv97P3DR7FKq4Jd8xTzw/iLqBYnu4oQaJp0iURq8C6fVe3bA0vfxT 0+JsuxZlslAuOO5HmFD8HavrIMvgRrmiqr1O1yTgF7JUmr45FYuOFfcwk0yCFhDv 7cbEFxZRGCCctXpR0f8UAUfbjdeLLiE6uVb4/3QgNqf3Jx1OvHvJImBKwEGqRiVs mtkg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651940992; x= 1652027392; bh=hCiER9OVnIrtr9z+NcWKnoVzZOndiSeCDvmgYOsuWvM=; b=l PuyVSaKjuwPz3KDP+ytQC0LugBJlhoGFaUHtm9lWJxdBjsYeJiZC1E+zi0dmHAc6 idvXM+2oZP6as3xHLI30YOVC2EKJ+ZFJ71wiACLNK70iUAXEGKAAFgOSVkM2VKgw jbTnGcXbuI1x2mIgTLg2JMdaGmf7whOZdpPo1Kgkv3xkjZgQBNHm9ovjJDYR4Exx w0ntk/hpVJMsOEADbghOE04BZU2rLgPI9KKuTTnUxGoiEhxHNQmOrkN+pkXuLi2D ZaTS2KUj01CCiD8DRaW2WmGparBatpNKnr4QPfuXw96RRGdXflv53gdwNp4gPOWu l1Wwf+V8FfpFkcZ/OMtig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeehgddutddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffgffkfggtgesthdttddttdertdenucfhrhhomhepufgvrghn ucghhhhithhtohhnuceoshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpedvjeettdeiteejgeejkefggfehtdekledtfedtteekgfeu keeftdduhfetleejkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 May 2022 12:29:52 -0400 (EDT) Received: by athena.silentflame.com (Postfix, from userid 1000) id CE7101C0248; Sat, 7 May 2022 16:29:50 +0000 (UTC) From: Sean Whitton In-Reply-To: <83tua1zz8h.fsf@gnu.org> References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <83r1571an1.fsf@gnu.org> <871qx6ea2x.fsf@athena.silentflame.com> <83tua1zz8h.fsf@gnu.org> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Sat, 07 May 2022 09:29:50 -0700 Message-ID: <871qx5uwzl.fsf@athena.silentflame.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, On Sat 07 May 2022 at 08:30am +03, Eli Zaretskii wrote: > What do you mean by "touch"? Doesn't get-buffer already "touch" the > buffer if it exists? And determining whether the buffer has any stuff > in it (if this is the concern here) is just one function call away, > and is very fast. As Stefan said, if the user has deleted the initial scratch message, we do not want to go reinserting it. And similarly if they have changed the mode away from whatever initial-major-mode specifies, we do not want to change it back. The only time we want to do anything is when the buffer does not exist. > This is not about Emacs Lisp, this is an incompatible behavior change, > and we have a section for that in NEWS. Okay. > My bother is that the function you call could signal an error at some > point, and that could cause trouble to some of the callers, perhaps. > Calling Lisp from C should always assume this could happen, because > basically the Lisp function you call is out of your control, and you > cannot reliably assume anything about what it does or will do at some > future time. > > Does this answer your question? I'm still not clear on what safe_call protects us from here. It's in xdisp.c and the comment next to it talks about preventing redisplay, but I don't see how redisplay is relevant to what this function does. Does safe_call also catch all signals and convert them to nil, or something? -- Sean Whitton From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Eli Zaretskii , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Eli Zaretskii , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Sat, 07 May 2022 16:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: rpluim@gmail.com, 55257-submitter@debbugs.gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.16519417413699 (code U ref 55257); Sat, 07 May 2022 16:43:01 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 7 May 2022 16:42:21 +0000 Received: from localhost ([127.0.0.1]:52878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnNVO-0000xJ-Bl for submit@debbugs.gnu.org; Sat, 07 May 2022 12:42:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47964) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnNVM-0000wq-TZ for 55257-submitter@debbugs.gnu.org; Sat, 07 May 2022 12:42:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnNVH-0007IK-L8; Sat, 07 May 2022 12:41:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Hygc2wLOh9q6PuAKALjMfUxfw0AN64mp8BMGB3suNmM=; b=IPJcLLs9Wscw 2WVRtyRQkxXqEVGurDw1Ns8+9Y07MrWEG9/y+tH6L4PIT1ulyifchHe62OgS8KKjuXzRZBtCFeVBH 1FR6PKFfBX7CuefSh5w5EFP8yx8jrujByXUVCPq3sr5CZrkNBYhpBoiFki8DFDIej7+aanbrPQVpm wzSHcO/SFzQ68L4w654cnkq4bGZzibmRemkE9IPdPule1IDtgTbgg18EuBXX0XZzSi/CN73bduOlk L1/y2t3QfN0xlPArB43J6gmyJzy2LHW+r0wd2aqXuqqKgU8q48EybFLBTut29TmZtIZVynKs+V6tO msCgPJOpfYBiqAMvBu4uZg==; Received: from [87.69.77.57] (port=4323 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnNVG-0006Xz-Uz; Sat, 07 May 2022 12:41:59 -0400 Date: Sat, 07 May 2022 19:41:50 +0300 Message-Id: <83bkw9xpkh.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <871qx5uwzl.fsf@athena.silentflame.com> (message from Sean Whitton on Sat, 07 May 2022 09:29:50 -0700) References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <83r1571an1.fsf@gnu.org> <871qx6ea2x.fsf@athena.silentflame.com> <83tua1zz8h.fsf@gnu.org> <871qx5uwzl.fsf@athena.silentflame.com> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > From: Sean Whitton > Cc: monnier@iro.umontreal.ca, rpluim@gmail.com, emacs-devel@gnu.org, > 55257-submitter@debbugs.gnu.org > Date: Sat, 07 May 2022 09:29:50 -0700 > > I'm still not clear on what safe_call protects us from here. It catches any errors and doesn't let the control flow escape to top-level. From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Reply-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Mail-Followup-To: Sean Whitton , 55257-quiet@debbugs.gnu.org Original-Sender: "Debbugs-submit" Resent-To: David Ponce Resent-Date: Sat, 07 May 2022 17:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: rpluim@gmail.com, 55257-submitter@debbugs.gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org Received: via spool by 55257-submitter@debbugs.gnu.org id=U55257.165194297914213 (code U ref 55257); Sat, 07 May 2022 17:03:01 +0000 Received: (at 55257-submitter) by debbugs.gnu.org; 7 May 2022 17:02:59 +0000 Received: from localhost ([127.0.0.1]:52898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnNpa-0003hB-Ri for submit@debbugs.gnu.org; Sat, 07 May 2022 13:02:59 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:50743) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnNpZ-0003gx-14 for 55257-submitter@debbugs.gnu.org; Sat, 07 May 2022 13:02:57 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id E6FFB3200657; Sat, 7 May 2022 13:02:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 07 May 2022 13:02:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1651942970; x=1652029370; bh=wW BmERMi0OI88jk7gZlYPhVHebWQtEdVET70LzX+4Xg=; b=WTBAG03eyvLjijFCq0 KTLtEkeDevSIlpkipJ1WIDWZlHvREbZ6pwasr2ZjY1D0/jn7TSrHXNHUtv9X4vdw BiJ/4rquKMlXxpDBWkPrcrtfSvdmXhB9njpyp8Q+E6k+3fVwNwLGOBknprmvhWAM a6xltDMPnwdbufFsA3sRuphZtuih9HwILqQrRa4pK+WMuWseGEVGoXxFrvyFc6E+ xe6fzeKa40ZVghdBgtQB5VUmUPuQAGbEVR3Dhs65cryQxJmUBgE7JPU+HNRGt2iR L4BIJZdAYvHRyih68XmESWU1abYPBPaMbAXYa7dXY5xq0As44AsyNdxNaTcg/D3v EE/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651942970; x= 1652029370; bh=wWBmERMi0OI88jk7gZlYPhVHebWQtEdVET70LzX+4Xg=; b=M kkJO6WVA9ixCuGbIJ2HVrAlunNvI+tpKkOptRmNYEXbCkmTlQOObFw/eBAtSpf3U 2OzrOIh+2WkCH42O2zG/8ZYPG6Yr5+hfyoMDbkKlsJclKt7a3frMpQvUfoKfjfdC aKrjtLDKscn+LE1UW7I/o+dNY9V75yQCXmu330x39u/QUlrXxA2AYo6p+XMpYPzV odLYDEhVus5yBK7xpkVckNDwMwXckjzJ0auhdmTCkb6VEgoCyJ1Mq7G5+6V7pgcR SP/57Qr0QKk3ORokoHy+mz0CnLKONS75jTJIo5NEWMX/0bcVmDaInZXHxJkzj1qP jDg/SKBUphS2qBVLu8xzA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeehgddutdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffgffkfggtgesthdttddttdertdenucfhrhhomhepufgvrghn ucghhhhithhtohhnuceoshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpedvjeettdeiteejgeejkefggfehtdekledtfedtteekgfeu keeftdduhfetleejkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 May 2022 13:02:50 -0400 (EDT) Received: by athena.silentflame.com (Postfix, from userid 1000) id 983541C0248; Sat, 7 May 2022 17:02:48 +0000 (UTC) From: Sean Whitton In-Reply-To: <83bkw9xpkh.fsf@gnu.org> References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <83r1571an1.fsf@gnu.org> <871qx6ea2x.fsf@athena.silentflame.com> <83tua1zz8h.fsf@gnu.org> <871qx5uwzl.fsf@athena.silentflame.com> <83bkw9xpkh.fsf@gnu.org> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Sat, 07 May 2022 10:02:48 -0700 Message-ID: <87y1zdtgw7.fsf@athena.silentflame.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, On Sat 07 May 2022 at 07:41pm +03, Eli Zaretskii wrote: >> From: Sean Whitton >> Cc: monnier@iro.umontreal.ca, rpluim@gmail.com, emacs-devel@gnu.org, >> 55257-submitter@debbugs.gnu.org >> Date: Sat, 07 May 2022 09:29:50 -0700 >> >> I'm still not clear on what safe_call protects us from here. > > It catches any errors and doesn't let the control flow escape to > top-level. Okay, thanks. -- Sean Whitton From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 May 2022 00:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: emacs-devel@gnu.org, 55257@debbugs.gnu.org Cc: Robert Pluim , Eli Zaretskii , Stefan Monnier Received: via spool by 55257-submit@debbugs.gnu.org id=B55257.16519696737979 (code B ref 55257); Sun, 08 May 2022 00:28:02 +0000 Received: (at 55257) by debbugs.gnu.org; 8 May 2022 00:27:53 +0000 Received: from localhost ([127.0.0.1]:53138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnUm8-00024c-Tn for submit@debbugs.gnu.org; Sat, 07 May 2022 20:27:53 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:58963) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnUm2-00024K-TV for 55257@debbugs.gnu.org; Sat, 07 May 2022 20:27:51 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id C3ED7320051E; Sat, 7 May 2022 20:27:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sat, 07 May 2022 20:27:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1651969660; x=1652056060; bh=mM KQF7g1HvumOPA/p5dIrvU9MnaKokCtyUL4JG3AnkU=; b=cl68Wxc1l2GN6wnuMj ZAruAf/qWlVnvDUXUxiKERzDP+amuIAhNOuS8huP3fGQVRTR+Vl+qTgcu8uKIHjH 5n+QH6BUwH7jMdOs9mhuVLiTP52Dv8PLLkcaWHZ2Z8NmMs92Dpn81xcdu7ROf+wK PX5PPSx1eS+7u58B2xBewU+5zPpBTOAtzzRsl0bfQr+pwVvUmmId3dksWcHt7jX6 DvK730ELeiQX1gOLeY52FJFYQ9DhuMuWQkkATfJvV5pPv8ScKkGlfZgQC4R3It0v cXFalkJU4x94LrNUJG2MopLTliIAcxNvnm9n/xfBjV+taWbbj9uFQG5mVpjGjgQk g6qQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651969660; x= 1652056060; bh=mMKQF7g1HvumOPA/p5dIrvU9MnaKokCtyUL4JG3AnkU=; b=C v9BWKuTUf9Y19TCn85UNVmTsAFEA9vsPg5Ls/s8lEu/JPTeBjLsmLBcMZsB8Tc3K R6NXxalFqXasZzxO4Ecc1cqZo4yIAWHo5ki8uS+lZsbOcrsvYK9hCF3stzLfBMR7 AzSG9WhGEZGQAHYVN5tE5TT7ZOWmDNcrrOv1mWe2WIJfBB67rDVuYsQ19T4j1fKI 5F3KnIK/1Om2AQG8Y4QBvcxP3yAJRQ+Rc5UDh8m8mz6gWiprZ9mwPXhiIud6ZL9c K34DW/QqTAWmluc2zXZxcZWKE8sveNE+vbOg5ytB4hb+yEvnVQZGT7ndpFlzHmcj 4HvR1SQLKhExvVvuNNv7Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeigdeffecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufgjfhgffffkgggtsehmtddtredtredtnecuhfhrohhmpefuvggrnhcu hghhihhtthhonhcuoehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqne cuggftrfgrthhtvghrnhepfeffhfegudeuueehkeejjefhgeelffdvveefheekvedukeeu keeuhedvueejvdfhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 May 2022 20:27:39 -0400 (EDT) Received: by melete.silentflame.com (Postfix, from userid 1000) id 032767E4942; Sat, 7 May 2022 17:27:38 -0700 (MST) From: Sean Whitton In-Reply-To: <871qx74or6.fsf@melete.silentflame.com> References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Sat, 07 May 2022 17:27:38 -0700 Message-ID: <871qx4lvgl.fsf@melete.silentflame.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Hello, On Thu 05 May 2022 at 03:07PM -07, Sean Whitton wrote: > Hello, > > On Wed 04 May 2022 at 12:26PM -04, Stefan Monnier wrote: > >>> It looks like Fother_window is called only from Fcall_interactively and >>> Fkill_buffer, so there probably isn't a bootstrapping issue if I make >>> those Ffuncall my new `get-initial-buffer-create'. It looks like >>> bootstrapping C code just makes an empty *scratch* and leaves it to >>> startup.el to initialise it. >> >> Even better, > > Here's my fix. Haven't quite finished testing each and every call site > but seemed worth posting it for comments. Here's an updated patch. -- Sean Whitton --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v2-0001-Factor-out-scratch-initialization.patch >From 4b80914abeb67065b22eb0a491cf684a5b1eff71 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 5 May 2022 13:03:06 -0700 Subject: [PATCH v2] Factor out *scratch* initialization * lisp/simple.el (get-initial-buffer-create): New function, factored out of scratch-buffer, and additionally clearing the modification flag and calling substitute-command-keys (bug#55257). (scratch-buffer): * lisp/server.el (server-execute): * lisp/startup.el (normal-no-mouse-startup-screen, command-line-1): * lisp/window.el (last-buffer, window-normalize-buffer-to-switch-to): * src/buffer.c (Fother_buffer, other_buffer_safely): Use it. (syms_of_buffer): Add Qget_initial_buffer_create. * lisp/startup.el (startup--get-buffer-create-scratch): Delete now-unused function. * doc/lispref/os.texi (Summary: Sequence of Actions at Startup): * NEWS (Incompatible changes in Emacs 29.1): Document the change. --- doc/lispref/os.texi | 8 ++++---- etc/NEWS | 8 ++++++++ lisp/server.el | 2 +- lisp/simple.el | 20 ++++++++++++++------ lisp/startup.el | 12 +++--------- lisp/window.el | 18 ++++++++---------- src/buffer.c | 22 +++------------------- 7 files changed, 41 insertions(+), 49 deletions(-) diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 9df708532d..f4dd2e7072 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -329,10 +329,10 @@ Startup Summary @end defopt @defopt initial-scratch-message -This variable, if non-@code{nil}, should be a string, which is -treated as documentation to be -inserted into the @file{*scratch*} buffer when Emacs starts up. If it -is @code{nil}, the @file{*scratch*} buffer is empty. +This variable, if non-@code{nil}, should be a string, which is treated +as documentation to be inserted into the @file{*scratch*} buffer when +Emacs starts up or when that buffer is recreated. If it is +@code{nil}, the @file{*scratch*} buffer is empty. @end defopt @noindent diff --git a/etc/NEWS b/etc/NEWS index 6637eda00c..20ef8f7b52 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -238,6 +238,14 @@ encouraged to test timestamp-related code with this variable set to nil, as it will default to nil in a future Emacs version and will be removed some time after that. ++++ +** Functions which recreate the *scratch* buffer now also initialize it. +When functions like 'other-buffer' and 'server-execute' recreate +*scratch*, they now also insert 'initial-scratch-message' and change +the major mode according to 'initial-major-mode', like at Emacs +startup. Previously, these functions ignored +'initial-scratch-message' and left *scratch* in 'fundamental-mode'. + * Changes in Emacs 29.1 diff --git a/lisp/server.el b/lisp/server.el index 763cf27f7a..042962b8e9 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1367,7 +1367,7 @@ server-execute ((functionp initial-buffer-choice) (funcall initial-buffer-choice))))) (switch-to-buffer - (if (buffer-live-p buf) buf (get-buffer-create "*scratch*")) + (if (buffer-live-p buf) buf (get-initial-buffer-create)) 'norecord))) ;; Delete the client if necessary. diff --git a/lisp/simple.el b/lisp/simple.el index 861d9eefde..1ed82b0a48 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -10213,16 +10213,24 @@ capitalize-dwim the number of seconds east of Greenwich.") ) +(defun get-initial-buffer-create () + "Return the \*scratch\* buffer, creating a new one if needed." + (or (get-buffer "*scratch*") + (let ((scratch (get-buffer-create "*scratch*"))) + ;; Don't touch the buffer contents or mode unless we know that + ;; we just created it. + (with-current-buffer scratch + (when initial-scratch-message + (insert (substitute-command-keys initial-scratch-message)) + (set-buffer-modified-p nil)) + (funcall initial-major-mode)) + scratch))) + (defun scratch-buffer () "Switch to the \*scratch\* buffer. If the buffer doesn't exist, create it first." (interactive) - (if (get-buffer "*scratch*") - (pop-to-buffer-same-window "*scratch*") - (pop-to-buffer-same-window (get-buffer-create "*scratch*")) - (when initial-scratch-message - (insert initial-scratch-message)) - (funcall initial-major-mode))) + (pop-to-buffer-same-window (get-initial-buffer-create))) diff --git a/lisp/startup.el b/lisp/startup.el index c7cf86a01e..3fa25ddee9 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2355,7 +2355,7 @@ normal-no-mouse-startup-screen (insert "\t\t") (insert-button "Open *scratch* buffer" 'action (lambda (_button) (switch-to-buffer - (startup--get-buffer-create-scratch))) + (get-initial-buffer-create))) 'follow-link t) (insert "\n") (save-restriction @@ -2487,12 +2487,6 @@ display-about-screen (defalias 'about-emacs 'display-about-screen) (defalias 'display-splash-screen 'display-startup-screen) -(defun startup--get-buffer-create-scratch () - (or (get-buffer "*scratch*") - (with-current-buffer (get-buffer-create "*scratch*") - (set-buffer-major-mode (current-buffer)) - (current-buffer)))) - ;; This avoids byte-compiler warning in the unexec build. (declare-function pdumper-stats "pdumper.c" ()) @@ -2784,7 +2778,7 @@ command-line-1 (when (eq initial-buffer-choice t) ;; When `initial-buffer-choice' equals t make sure that *scratch* ;; exists. - (startup--get-buffer-create-scratch)) + (get-initial-buffer-create)) ;; If *scratch* exists and is empty, insert initial-scratch-message. ;; Do this before switching to *scratch* below to handle bug#9605. @@ -2808,7 +2802,7 @@ command-line-1 ((functionp initial-buffer-choice) (funcall initial-buffer-choice)) ((eq initial-buffer-choice t) - (startup--get-buffer-create-scratch)) + (get-initial-buffer-create)) (t (error "`initial-buffer-choice' must be a string, a function, or t"))))) (unless (buffer-live-p buf) diff --git a/lisp/window.el b/lisp/window.el index 9f78784612..615c5c078a 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4886,10 +4886,7 @@ last-buffer (setq frame (or frame (selected-frame))) (or (get-next-valid-buffer (nreverse (buffer-list frame)) buffer visible-ok frame) - (get-buffer "*scratch*") - (let ((scratch (get-buffer-create "*scratch*"))) - (set-buffer-major-mode scratch) - scratch))) + (get-initial-buffer-create))) (defcustom frame-auto-hide-function #'iconify-frame "Function called to automatically hide frames. @@ -8621,12 +8618,13 @@ window-normalize-buffer-to-switch-to `other-buffer'. Else, if a buffer specified by BUFFER-OR-NAME exists, return that buffer. If no such buffer exists, create a buffer with the name BUFFER-OR-NAME and return that buffer." - (if buffer-or-name - (or (get-buffer buffer-or-name) - (let ((buffer (get-buffer-create buffer-or-name))) - (set-buffer-major-mode buffer) - buffer)) - (other-buffer))) + (pcase buffer-or-name + ('nil (other-buffer)) + ("*scratch*" (get-initial-buffer-create)) + (_ (or (get-buffer buffer-or-name) + (let ((buffer (get-buffer-create buffer-or-name))) + (set-buffer-major-mode buffer) + buffer))))) (defcustom switch-to-buffer-preserve-window-point t "If non-nil, `switch-to-buffer' tries to preserve `window-point'. diff --git a/src/buffer.c b/src/buffer.c index f8a7a4f510..a153ffe78c 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1634,16 +1634,7 @@ DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0, if (!NILP (notsogood)) return notsogood; else - { - AUTO_STRING (scratch, "*scratch*"); - buf = Fget_buffer (scratch); - if (NILP (buf)) - { - buf = Fget_buffer_create (scratch, Qnil); - Fset_buffer_major_mode (buf); - } - return buf; - } + return safe_call (1, Qget_initial_buffer_create); } /* The following function is a safe variant of Fother_buffer: It doesn't @@ -1659,15 +1650,7 @@ other_buffer_safely (Lisp_Object buffer) if (candidate_buffer (buf, buffer)) return buf; - AUTO_STRING (scratch, "*scratch*"); - buf = Fget_buffer (scratch); - if (NILP (buf)) - { - buf = Fget_buffer_create (scratch, Qnil); - Fset_buffer_major_mode (buf); - } - - return buf; + return safe_call (1, Qget_initial_buffer_create); } DEFUN ("buffer-enable-undo", Fbuffer_enable_undo, Sbuffer_enable_undo, @@ -5552,6 +5535,7 @@ syms_of_buffer (void) DEFSYM (Qbefore_change_functions, "before-change-functions"); DEFSYM (Qafter_change_functions, "after-change-functions"); DEFSYM (Qkill_buffer_query_functions, "kill-buffer-query-functions"); + DEFSYM (Qget_initial_buffer_create, "get-initial-buffer-create"); DEFSYM (Qvertical_scroll_bar, "vertical-scroll-bar"); Fput (Qvertical_scroll_bar, Qchoice, list4 (Qnil, Qt, Qleft, Qright)); -- 2.30.2 --=-=-=-- From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 May 2022 18:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: Robert Pluim , 55257@debbugs.gnu.org, Eli Zaretskii , emacs-devel@gnu.org Received: via spool by 55257-submit@debbugs.gnu.org id=B55257.165211988630225 (code B ref 55257); Mon, 09 May 2022 18:12:02 +0000 Received: (at 55257) by debbugs.gnu.org; 9 May 2022 18:11:26 +0000 Received: from localhost ([127.0.0.1]:59386 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1no7qv-0007rP-FM for submit@debbugs.gnu.org; Mon, 09 May 2022 14:11:25 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:55895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1no7qt-0007qv-EG for 55257@debbugs.gnu.org; Mon, 09 May 2022 14:11:23 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1CF451001CB; Mon, 9 May 2022 14:11:18 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 2473F100118; Mon, 9 May 2022 14:11:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1652119876; bh=DmxyQLuuL+Gr/wenyPD9eT6C+NVwFndZMHMaCpxyG+0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=AKy2Ld1HN0W6r780s+vieWDyFczErJOjxjaCJh6wujhGqqvZJOxW1RvzVzOEK1/O4 nEt6aSPjJIRCyB1K94RCY1GcRL/emllfEwUIInD5VNHlVObOycwrZOmtF9+/7BTTs4 5HUsi1NRpKip2XDZyxgLTvHWC296Dr7ki8qP77JxGB1P2iStphceLuGpeNUpDTTgGi z/rdWiu0HhulLRq9/L8H3eyJSGoge1Xbve5WB2HSJjFn+gZCpt4kDbrzUQbG4CFd6s kpQbd52VyMgL33K9j6QR4osVZFdY2HV2b5JGx3kGJIOQfLFj+Mvtv0D8rrolvaDzz+ g8FtgQg8xvM4w== Received: from alfajor (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id F2682120B95; Mon, 9 May 2022 14:11:15 -0400 (EDT) From: Stefan Monnier Message-ID: References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <871qx4lvgl.fsf@melete.silentflame.com> Date: Mon, 09 May 2022 14:11:14 -0400 In-Reply-To: <871qx4lvgl.fsf@melete.silentflame.com> (Sean Whitton's message of "Sat, 07 May 2022 17:27:38 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.184 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Here's an updated patch. LGTM, thank you (feel free to push, as far as I'm concerned). See further comments below. Stefan > +** Functions which recreate the *scratch* buffer now also initialize it. > +When functions like 'other-buffer' and 'server-execute' recreate > +*scratch*, they now also insert 'initial-scratch-message' and change > +the major mode according to 'initial-major-mode', like at Emacs > +startup. Previously, these functions ignored > +'initial-scratch-message' and left *scratch* in 'fundamental-mode'. I'd say "set the major mode" rather than "change the major mode". > +(defun get-initial-buffer-create () I know you didn't like my `scratch-buffer--create` suggestion because of the double dash, but I think at least "scratch" would be very welcome in it. > + "Return the \*scratch\* buffer, creating a new one if needed." > + (or (get-buffer "*scratch*") > + (let ((scratch (get-buffer-create "*scratch*"))) > + ;; Don't touch the buffer contents or mode unless we know that > + ;; we just created it. > + (with-current-buffer scratch > + (when initial-scratch-message > + (insert (substitute-command-keys initial-scratch-message)) > + (set-buffer-modified-p nil)) > + (funcall initial-major-mode)) > + scratch))) > + > (defun scratch-buffer () > "Switch to the \*scratch\* buffer. > If the buffer doesn't exist, create it first." > (interactive) > - (if (get-buffer "*scratch*") > - (pop-to-buffer-same-window "*scratch*") > - (pop-to-buffer-same-window (get-buffer-create "*scratch*")) > - (when initial-scratch-message > - (insert initial-scratch-message)) > - (funcall initial-major-mode))) > + (pop-to-buffer-same-window (get-initial-buffer-create))) Now that I look at it again, it occurs to me that maybe we should do something like: (defun scratch-buffer (&optional display) "Create the \*scratch\* buffer. If the buffer doesn't exist, create it first. If DISPLAY (or when used interactively), switch to it." (interactive (list t)) (let ((buf (get-buffer "*scratch*"))) (unless buf ;; Don't touch the buffer contents or mode unless we know that ;; we just created it. (with-current-buffer (setq buf (get-buffer-create "*scratch*")) (when initial-scratch-message (insert (substitute-command-keys initial-scratch-message)) (set-buffer-modified-p nil)) (funcall initial-major-mode))) (when display (pop-to-buffer-same-window buf)) buf)) i.e. combine the new function with the existing command, so we don't need to come up with a new name. From unknown Fri Sep 19 21:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 May 2022 01:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: Robert Pluim , 55257@debbugs.gnu.org, Eli Zaretskii , emacs-devel@gnu.org Received: via spool by 55257-submit@debbugs.gnu.org id=B55257.165214736328172 (code B ref 55257); Tue, 10 May 2022 01:50:02 +0000 Received: (at 55257) by debbugs.gnu.org; 10 May 2022 01:49:23 +0000 Received: from localhost ([127.0.0.1]:59802 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1noF06-0007KK-RB for submit@debbugs.gnu.org; Mon, 09 May 2022 21:49:23 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:59447) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1noEzt-0007Jo-Nk for 55257@debbugs.gnu.org; Mon, 09 May 2022 21:49:22 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 970535C0198; Mon, 9 May 2022 21:49:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 09 May 2022 21:49:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1652147344; x=1652233744; bh=CM f1evKqb0Lu72DGHV+HaFR6tfF8LN3Oo31g4fAhxx8=; b=PuCl0t7o05+LuZEuIy QTkWttznj+RIQzuJSW0fkTpMkzroadeJtIdWBYigjvhs+2D0cUL8we6Fpbi77/3a a3A8ZoLfuAeUID5XLmIQN0UyDl1mqbo3ZoqGS8RcHseNV0OfqwBAItZxr2mSaTA3 wXyxvtOishK498XQTQN8F3CIX4hwaqXJC6L6in4XZrS2VHuNClxLLe/sMwefsbk5 U9EvR8U2cVg0mdRaW6u0m3MIYGgT5weRJ8tPlGh8dHI7MNxeb5rjPsnM/ZTDNEuR jABzsPbhsHtD/iqYgRc1l99UVBnbcHpfOnfEBvO6AaqXDXlZtLlNejHLRmy8YkjB VVDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1652147344; x= 1652233744; bh=CMf1evKqb0Lu72DGHV+HaFR6tfF8LN3Oo31g4fAhxx8=; b=w 9ZrLifugVPHlMKFd9JlWkNGlHbB4rh+nGuv9IhypUNYJ6GTlfgtpQyRUyN1n6p+j haqUb6D80K8DqVC0Xbt/+XAWLN+NdaFQlrhxC/5mT73EfPfibC1s3SRVHzOXu7WD I1E9jkVAFWpqE9al5HrdHkJUFL9L2d15ZoVRinyYcoGs47cU34xWX8aaGSWTR/Bn qgCBCkPglHfh4EmG2zYoMnip2bYdtdPdTDZBSgJmmItbhhtW2F3fqolYwIFmxvrx nawmq9hYMKfXdYUdateEsm0ED0n14PWTrGXxaQQ9UyuCgVTPTQ4Npyv6cravAJOM HIHB5Ke0UCUoyOyR5JrbQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrgedtgdehtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufgjfhgffffkgggtsehttddttddtredtnecuhfhrohhmpefuvggrnhcu hghhihhtthhonhcuoehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqne cuggftrfgrthhtvghrnhepvdejtedtieetjeegjeekgffghedtkeeltdeftdetkefgueek fedtudfhteeljeeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 May 2022 21:49:04 -0400 (EDT) Received: by athena.silentflame.com (Postfix, from userid 1000) id CDD451BA78C; Tue, 10 May 2022 01:49:02 +0000 (UTC) From: Sean Whitton In-Reply-To: References: <165162665935.26821.8964921720746152690@vcs2.savannah.gnu.org> <20220504011059.9F667C009A8@vcs2.savannah.gnu.org> <87levhdfeh.fsf@athena.silentflame.com> <87y1zhe5qz.fsf@athena.silentflame.com> <87levhe24h.fsf@athena.silentflame.com> <871qx74or6.fsf@melete.silentflame.com> <871qx4lvgl.fsf@melete.silentflame.com> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Mon, 09 May 2022 18:49:02 -0700 Message-ID: <87ilqerwc1.fsf@athena.silentflame.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, On Mon 09 May 2022 at 02:11pm -04, Stefan Monnier wrote: > I know you didn't like my `scratch-buffer--create` suggestion because of > the double dash, but I think at least "scratch" would be very welcome in it. I've done s/initial/scratch/ which is better because this function always uses *scratch* rather than, say, looking at initial-buffer-choice. > Now that I look at it again, it occurs to me that maybe we should do > something like: > > (defun scratch-buffer (&optional display) > "Create the \*scratch\* buffer. > If the buffer doesn't exist, create it first. > If DISPLAY (or when used interactively), switch to it." > (interactive (list t)) > (let ((buf (get-buffer "*scratch*"))) > (unless buf > ;; Don't touch the buffer contents or mode unless we know that > ;; we just created it. > (with-current-buffer (setq buf (get-buffer-create "*scratch*")) > (when initial-scratch-message > (insert (substitute-command-keys initial-scratch-message)) > (set-buffer-modified-p nil)) > (funcall initial-major-mode))) > (when display (pop-to-buffer-same-window buf)) > buf)) > > i.e. combine the new function with the existing command, so we don't > need to come up with a new name. Nice idea, but I'd argue for keeping them separate. I find it more natural to distinguish functions called for their return values and commands. -- Sean Whitton From unknown Fri Sep 19 21:59:28 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: David Ponce Subject: bug#55257: closed (Re: bug#55257: 29.0.50; New command `scratch-buffer' inconsistent with startup) Message-ID: References: <87fslirw9u.fsf@athena.silentflame.com> X-Gnu-PR-Message: they-closed 55257 X-Gnu-PR-Package: emacs Reply-To: 55257@debbugs.gnu.org Date: Tue, 10 May 2022 01:51:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1652147461-28331-1" This is a multi-part message in MIME format... ------------=_1652147461-28331-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #55257: 29.0.50; New command `scratch-buffer' inconsistent with startup which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 55257@debbugs.gnu.org. --=20 55257: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D55257 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1652147461-28331-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 55257-done) by debbugs.gnu.org; 10 May 2022 01:50:29 +0000 Received: from localhost ([127.0.0.1]:59808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1noF1B-0007MF-9J for submit@debbugs.gnu.org; Mon, 09 May 2022 21:50:29 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:54403) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1noF19-0007M1-El for 55257-done@debbugs.gnu.org; Mon, 09 May 2022 21:50:27 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5298B5C01A1 for <55257-done@debbugs.gnu.org>; Mon, 9 May 2022 21:50:22 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 09 May 2022 21:50:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1652147422; x=1652233822; bh=TmfHI1akpw sr7r/gw31YeSoC7lrDDwFHIh1Nt2ElfVo=; b=Dg8Oy40mDPepxvGk2Ku4U+Ktls Fvo9P5L0A9WOc67IxHL1nzxc7ZgxiFRNvBqefrwj6fQT2XOMcRQQRFFcqMBB0Ycv ckeTK34s5/p9+lCq740FEyZwG/6QEU71i3oY4YoMv/wicJp/4etjdGUbC/rgzovz cyXkg9nK+ntXYcR2n8MI7Av0TEOn01HoD111ECy5lCp519jdtPUHWML03WM1J6kl 8paQT79ta6noHZIYhRDgu7hOFKqNYF03TaV29WTBcHrwUx2rPcz6bpHn+yZaWNg3 E2BTZobbLqznezFPfYzB47o6imfPKUxF70KrnuRLA6Iwoq7nY81P/htcbjnA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1652147422; x= 1652233822; bh=TmfHI1akpwsr7r/gw31YeSoC7lrDDwFHIh1Nt2ElfVo=; b=m J99MhodVBp57Es2hvUautez7ims06jB2gJgbT3hziUzbzxoyUaco2zCMK2Vm9dph cHBz7Yf+qopXd4HGKVZrEI6GSJyKThtJ6JoE5e7J1NTT2F1YNcmZSnd816HnR25W wicuhvUdOKCg3XLH9y5/sdOLxT66RCYjNvwTtepgitg5tv7jANsuQWhz4jVYxNjd ZB7yF5bx0Rhqm//XVKCXCkwdUfPL9ahXaAlPqgxO5ST1upDGu/mPODbwRwWNw4OI 7rGJRUimT+zECC3wXJVOOU3p45pcf1fFPb2JLTke8kH7Jhthn7VvpPQw7+rdeHfA Nlw9ySekD7zTtELCQjwXg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrgedtgdehudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufgjfhgffffkgggtsehttddttd dtredtnecuhfhrohhmpefuvggrnhcuhghhihhtthhonhcuoehsphifhhhithhtohhnsehs phifhhhithhtohhnrdhnrghmvgeqnecuggftrfgrthhtvghrnhepleeggefgvdeijedvhf dugfegtefgkeekueeileejjeehudeggeefteeghfeuffeknecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhpfihhihhtthhonhesshhpfihhih htthhonhdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for <55257-done@debbugs.gnu.org>; Mon, 9 May 2022 21:50:22 -0400 (EDT) Received: by athena.silentflame.com (Postfix, from userid 1000) id 374711BA78C; Tue, 10 May 2022 01:50:21 +0000 (UTC) From: Sean Whitton To: 55257-done@debbugs.gnu.org Subject: Re: bug#55257: 29.0.50; New command `scratch-buffer' inconsistent with startup In-Reply-To: <87r159e44b.fsf@athena.silentflame.com> References: <87r159e44b.fsf@athena.silentflame.com> User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Date: Mon, 09 May 2022 18:50:21 -0700 Message-ID: <87fslirw9u.fsf@athena.silentflame.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 55257-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, On Wed 04 May 2022 at 07:58am -07, Sean Whitton wrote: > Hello, > > On Wed 04 May 2022 at 10:31am +02, David Ponce wrote: > >> Hello, >> >> The new command `scratch-buffer' does not re-create the *scratch* buffer >> like in startup.el. >> >> The below patch fix this: >> --- a/./installs/emacs/lisp/simple.el >> +++ b/./emacs.d/simple.el >> @@ -10221,7 +10221,8 @@ If the buffer doesn't exist, create it first." >> (pop-to-buffer-same-window "*scratch*") >> (pop-to-buffer-same-window (get-buffer-create "*scratch*")) >> (when initial-scratch-message >> - (insert initial-scratch-message)) >> + (insert (substitute-command-keys initial-scratch-message)) >> + (set-buffer-modified-p nil)) >> (funcall initial-major-mode))) > > Thanks. Let me try to fix this as part of factoring out the *scratch* > initialisation code, as discussed in an emacs-devel thread. This is now on master. -- Sean Whitton ------------=_1652147461-28331-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 4 May 2022 08:32:07 +0000 Received: from localhost ([127.0.0.1]:41729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmAQZ-0001yj-2R for submit@debbugs.gnu.org; Wed, 04 May 2022 04:32:07 -0400 Received: from lists.gnu.org ([209.51.188.17]:33126) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nmAQX-0001yc-BV for submit@debbugs.gnu.org; Wed, 04 May 2022 04:32:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmAQT-0006Bh-AT for bug-gnu-emacs@gnu.org; Wed, 04 May 2022 04:32:04 -0400 Received: from smtp09.smtpout.orange.fr ([80.12.242.131]:55117 helo=smtp.smtpout.orange.fr) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nmAQQ-00018k-R8 for bug-gnu-emacs@gnu.org; Wed, 04 May 2022 04:32:01 -0400 Received: from [192.168.1.15] ([2.7.228.182]) by smtp.orange.fr with ESMTPA id mAQKnI2WmqoKwmAQLn7LFH; Wed, 04 May 2022 10:31:53 +0200 X-ME-Helo: [192.168.1.15] X-ME-Auth: OWU0YmVhODllOThlNTBiMTcxZWVkMmNjZmQ4ZWZlMmRlNQ== X-ME-Date: Wed, 04 May 2022 10:31:53 +0200 X-ME-IP: 2.7.228.182 To: bug-gnu-emacs@gnu.org From: David Ponce Subject: 29.0.50; New command `scratch-buffer' inconsistent with startup Message-ID: Date: Wed, 4 May 2022 10:31:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Language: fr Content-Transfer-Encoding: 7bit Received-SPF: none client-ip=80.12.242.131; envelope-from=da_vid@orange.fr; helo=smtp.smtpout.orange.fr X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello, The new command `scratch-buffer' does not re-create the *scratch* buffer like in startup.el. The below patch fix this: --- a/./installs/emacs/lisp/simple.el +++ b/./emacs.d/simple.el @@ -10221,7 +10221,8 @@ If the buffer doesn't exist, create it first." (pop-to-buffer-same-window "*scratch*") (pop-to-buffer-same-window (get-buffer-create "*scratch*")) (when initial-scratch-message - (insert initial-scratch-message)) + (insert (substitute-command-keys initial-scratch-message)) + (set-buffer-modified-p nil)) (funcall initial-major-mode))) Thanks! In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.17.4) of 2022-05-04 Repository revision: 268713e227e8b665b1874c96ea96d1e7fccaab11 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: Fedora Linux 35 (KDE Plasma) Configured using: 'configure --with-cairo --without-sqlite3 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LC_TIME: fr_FR.utf8 value of $LANG: fr_FR.UTF-8 locale-coding-system: utf-8-unix ------------=_1652147461-28331-1--