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 16:50:52 +0200 Message-ID: <83pme8dp2r.fsf@gnu.org> References: <83v8o0dtg3.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28904"; 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 15:51:57 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 1opW8r-0007K9-Ao for ged-emacs-devel@m.gmane-mx.org; Mon, 31 Oct 2022 15:51:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opW8G-0001of-NO; Mon, 31 Oct 2022 10:51:20 -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 1opW87-0001nz-H4 for emacs-devel@gnu.org; Mon, 31 Oct 2022 10:51:12 -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 1opW85-0004GZ-IG; Mon, 31 Oct 2022 10:51:10 -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=e9/RW/1GwgYbcbhOdy2RpPyRK9Ab5ccp2VoRj1GOCaY=; b=ShpoLq2SvdOb oihhgWps8R8yeZx8MPKorQx2RKNZsDMjJp5f1qTTTfCb785uHUHxSH0s3MV8oPA3dQjtcKMk2GorU MQ0PzvwbiDFM5Sl7RordLlMGif0AfitMlViyQAoys+Vkr6E4PjNr+a0ie+PfEPwevU22yXHulbJ7p nuF13fT9wy3VUyQFuxCceZM0yMkDzi1AH8XkGB6BPZ9789iQ9qvIsWZb2ZOqX+n4KeQkaJc+QcqRk UXc0dRPiN3zjYad+SPSKOFgTcoGNwVs2Fgr7jebeTA+/MEB3T7tT96DgtLbUImJ4CrPwmhb4dQZj7 f0eaLKc0aExjMYoNF0Pv4w==; 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 1opW84-0007vh-6M; Mon, 31 Oct 2022 10:51:09 -0400 In-Reply-To: (message from Alan Mackenzie on Mon, 31 Oct 2022 14:32:12 +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:298859 Archived-At: > Date: Mon, 31 Oct 2022 14:32:12 +0000 > Cc: emacs-devel@gnu.org > From: Alan Mackenzie > > Anyhow, I proposed buffer-point and set-buffer-point. They would be a > lot faster than set-buffer followed by point and goto-char. Here is my > first version of these. What do you think? 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? Stefan, Lars, WDYT? Anyway, a couple of minor comments: > +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? > + 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. > + CHECK_FIXNUM_COERCE_MARKER (pos); > + p = XFIXNUM (pos); This is sub-optimal: a marker holds both character and byte position, and you lose it here. Ignoring the byte position is only justified if the marker belongs to the wrong buffer. > + if (p < b->begv) p = b->begv; > + if (p > b->zv) p = b->zv; We have clip_to_bounds. And again, always use BUF_BEGV and BUF_ZV, not literal references to members of struct buffer. > + SET_PT (p); We have SET_BUF_PT_BOTH.