From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Whitton Newsgroups: gmane.emacs.devel Subject: Re: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Date: Fri, 06 May 2022 12:26:46 -0700 Message-ID: <871qx6ea2x.fsf@athena.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> <83r1571an1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4144"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Notmuch/0.36 Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: monnier@iro.umontreal.ca, rpluim@gmail.com, emacs-devel@gnu.org, 55257-submitter@debbugs.gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 06 21:27:40 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nn3c1-0000rg-3K for ged-emacs-devel@m.gmane-mx.org; Fri, 06 May 2022 21:27:39 +0200 Original-Received: from localhost ([::1]:32900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nn3bz-0003Vr-JR for ged-emacs-devel@m.gmane-mx.org; Fri, 06 May 2022 15:27:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nn3bG-0002r2-Cw for emacs-devel@gnu.org; Fri, 06 May 2022 15:26:50 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:39457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nn3bE-000104-Qc; Fri, 06 May 2022 15:26:50 -0400 Original-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) Original-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: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 6 May 2022 15:26:47 -0400 (EDT) Original-Received: by athena.silentflame.com (Postfix, from userid 1000) id CBCBF1C0503; Fri, 6 May 2022 19:26:46 +0000 (UTC) In-Reply-To: <83r1571an1.fsf@gnu.org> Received-SPF: pass client-ip=66.111.4.28; envelope-from=spwhitton@spwhitton.name; helo=out4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289338 Archived-At: 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