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: Edebug corrupting point in buffers; we need buffer-point and set-buffer-point, perhaps. Date: Mon, 31 Oct 2022 19:55:40 +0200 Message-ID: <83mt9bev37.fsf@gnu.org> References: <83v8o0dtg3.fsf@gnu.org> <83pme8dp2r.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21688"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 31 18:56:47 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 1opZ1i-0005VE-U7 for ged-emacs-devel@m.gmane-mx.org; Mon, 31 Oct 2022 18:56:47 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opZ13-0008PA-B2; Mon, 31 Oct 2022 13:56:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opZ0x-0008I8-Dt for emacs-devel@gnu.org; Mon, 31 Oct 2022 13:55:59 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opZ0w-00052y-0i; Mon, 31 Oct 2022 13:55: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=21PskmTCjfllTffJZEqQ2WMIJP6cf0Cnbh6sd36XOCY=; b=ZxhAIuO00qi3 vCYlvNYp22c+pLxYw9dVAOnFuz3LxY0y7XnZ3908Hog9IcD/hDZ+vL9RbBV3DKq+wHNjpKeaLSfnc yPEzpa3ww9lv566mqOJ49kqqrjhPGwQoLR5wRJHoJR5O3siaV+CFsYQ+7Yr9f3bwWCN/jz1a3sxs+ jHBMB9T4vQeYy+1GOIYV7yEzm5PHCOzsSoEC/7m0jXRVPLsoVRtJYtLgbpUyKOhuowjwTzI/wOSiT n3B/a+CYOxgFNBuQ4oAaQ11My3IhMT5B3pQIrpObGj2JdtV74c/4q1iKdV45oTmhlcydZtzu4Ouyd jUdj4EqeVVNC4TzCBYhVmg==; Original-Received: from [87.69.77.57] (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 1opZ0t-0006lj-Il; Mon, 31 Oct 2022 13:55:57 -0400 In-Reply-To: (message from Alan Mackenzie on Mon, 31 Oct 2022 15:46:07 +0000) 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: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298881 Archived-At: > Date: Mon, 31 Oct 2022 15:46:07 +0000 > Cc: emacs-devel@gnu.org > From: Alan Mackenzie > > > I'm not sure performance in a debugger is a reason good enough to add > > 2 more primitives. The fact that we didn't need them until now should > > tell us something, no? > > Well, I timed it. With 207 buffers, creating an alist of (buffer . > buffere-point) with my new function was 17 times as fast as using > with-current-buffer and point. 17 times faster doesn't yet tell how important is the speedup, because you give no absolute numbers, and they are what's important here. > But on the other hand, these two functions feel like they ought to exist. > They could save a lot of clumsy programming with swapping the buffer, > just to get or set point. There's nothing clumsy with what we did, and the fact that we did manage without them speaks volumes. > > > +DEFUN ("buffer-point", Fbuffer_point, Sbuffer_point, 1, 1, 0, > > > + doc: /* Return the buffer point of BUFFER-OR-NAME. > > > +The argument may be a buffer or the name of an existing buffer. */) > > > + (Lisp_Object buffer_or_name) > > > Why not an optional argument to 'point'? And why in buffer.c and not > > in editfns.c? > > I'm not sure what you mean by an optional argument, here. I mean (point &optional buffer), of course, what else could I mean? > > > + return (make_fixnum (b->pt)); > > > Please never-ever use b->pt etc. directly. We have BUF_PT and other > > macros for that, and for a good reason. > > BUF_PT and friends work specifically on current_buffer. No, they don't: /* Position of point in buffer. */ INLINE ptrdiff_t BUF_PT (struct buffer *buf) { return (buf == current_buffer ? PT : NILP (BVAR (buf, pt_marker)) ? buf->pt : marker_position (BVAR (buf, pt_marker))); } > The whole idea of the new functions is to avoid having to switch > buffers. We do this from C in a gazillion of places.