From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer Date: Fri, 06 May 2022 08:40:50 +0300 Message-ID: <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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15603"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, rpluim@gmail.com, emacs-devel@gnu.org, 55257-submitter@debbugs.gnu.org To: Sean Whitton Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 06 07:44:12 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 1nmql9-0003tj-Oa for ged-emacs-devel@m.gmane-mx.org; Fri, 06 May 2022 07:44:11 +0200 Original-Received: from localhost ([::1]:56906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmql6-0002J1-9U for ged-emacs-devel@m.gmane-mx.org; Fri, 06 May 2022 01:44:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmqiB-0001Ln-5k for emacs-devel@gnu.org; Fri, 06 May 2022 01:41:07 -0400 Original-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==; Original-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 In-Reply-To: <871qx74or6.fsf@melete.silentflame.com> (message from Sean Whitton on Thu, 05 May 2022 15:07:41 -0700) 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:289296 Archived-At: > 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.