From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/hyperbole c501027 2/2: Fix set-buffer byte-compiler warnings; remove outdated references Date: Mon, 10 May 2021 09:59:57 -0400 Message-ID: References: <20210510035708.29543.25002@vcs0.savannah.gnu.org> <20210510035709.E742920DFD@vcs0.savannah.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="11957"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Bob Weiner To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon May 10 16:01:16 2021 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 1lg6TD-0002y1-Kp for ged-emacs-devel@m.gmane-mx.org; Mon, 10 May 2021 16:01:15 +0200 Original-Received: from localhost ([::1]:44092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lg6TC-0005r3-Mv for ged-emacs-devel@m.gmane-mx.org; Mon, 10 May 2021 10:01:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lg6S7-0004hM-IR for emacs-devel@gnu.org; Mon, 10 May 2021 10:00:07 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:53665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lg6S2-0001DJ-09; Mon, 10 May 2021 10:00:06 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 0B4F2100216; Mon, 10 May 2021 10:00:00 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 7132E10019F; Mon, 10 May 2021 09:59:58 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1620655198; bh=R04FyJkP6NTfupZEfmsRUWbCWGpe45sk4tKRwPtZ9As=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=H66MlityMbA/mKRAFsAUpd0kevUNPBMCRGNGeImh+GC5H0UmiegheVX2HGsKEmb+2 bjFvvWSUiyiNW9oAWqdfvGEuwWxkFoXvFVsyUfRkSMP0Fre02lg9kUZZ3KNKOacrj7 4U0Njq8VwPXU69biRX0oJE3pYlHr2rIdsODA1wdlpxCuJ02LQEyrwDQJm8p8pieEyJ SBdga3JM2OIx9fERd8o/bClnGcBbdXlrEwOeiBG/M9o2Uu+IGlVYjbhw5jPJio7Hzn INiHgCDp4eL7xzO0IWxWOJF1LBOwaMFNmTXlXDshXOpbTa/8sEJO6DWl5T8/eMOQmC whCloK0+MJ15A== Original-Received: from alfajor (76-10-140-76.dsl.teksavvy.com [76.10.140.76]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 493C9120388; Mon, 10 May 2021 09:59:58 -0400 (EDT) In-Reply-To: <20210510035709.E742920DFD@vcs0.savannah.gnu.org> (ELPA Syncer's message of "Sun, 9 May 2021 23:57:09 -0400 (EDT)") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:269116 Archived-At: > (save-excursion > - (set-buffer (if (bufferp loc) loc (find-file-noselect loc))) > - (when (ibut:to (ibut:key but-sym)) > - (let (buffer-read-only) > - (if (< (point) start) > - ;; Find beginning of button named label delimiter and delete > - ;; from there. > - (progn (goto-char (- (point) (length ibut:label-start))) > - (delete-region (point) end)) > - ;; No label, just delete delimited ibutton text. > - (delete-region start end)) > - (when (looking-at "[ \t]*\r?\n") > - (delete-region (point) (match-end 0))) > - (run-hooks 'ibut-delete-hook)))) > + (with-current-buffer (if (bufferp loc) loc (find-file-noselect loc)) > + (when (ibut:to (ibut:key but-sym)) > + (let (buffer-read-only) > + (if (< (point) start) > + ;; Find beginning of button named label delimiter and delete > + ;; from there. > + (progn (goto-char (- (point) (length ibut:label-start))) > + (delete-region (point) end)) > + ;; No label, just delete delimited ibutton text. > + (delete-region start end)) > + (when (looking-at "[ \t]*\r?\n") > + (delete-region (point) (match-end 0))) > + (run-hooks 'ibut-delete-hook))))) > but-sym)))) > > (defun ibut:get (&optional lbl-key buffer key-src) > diff --git a/hui-window.el b/hui-window.el > index 654c035..796770e 100644 > --- a/hui-window.el > +++ b/hui-window.el > @@ -311,12 +311,12 @@ part of InfoDock and not a part of Hyperbole)." > "Return t iff there is a non-empty active region in buffer of the last Smart Mouse Key release." > (when (setq hkey-value (if assist-flag assist-key-depress-prev-point action-key-depress-prev-point)) > (save-excursion > - (set-buffer (marker-buffer hkey-value)) > - ;; Store and goto any prior value of point from the region > - ;; prior to the Smart Key depress, so we can return to it later. > - (and (goto-char hkey-value) > - (hmouse-save-region) > - t)))) > + (with-current-buffer (marker-buffer hkey-value) > + ;; Store and goto any prior value of point from the region > + ;; prior to the Smart Key depress, so we can return to it later. > + (and (goto-char hkey-value) > + (hmouse-save-region) > + t))))) These two don't make much sense: `save-excursion` only saves the position of point in the current buffer, so (save-excursion (with-current-buffer FOO ...)) is useless in one of two ways: - FOO is already the current buffer, so `with-current-buffer` (previously `set-buffer`) does nothing. - FOO is a different buffer, so the buffer-position saved&restored by `save-excursion` is in a buffer that's not affected by `...`. If you want to combine the two, then you should use (with-current-buffer FOO (save-excursion ...)) Tho if we presume that the `set-buffer` in the previous code did do something useful (i.e. selected a different buffer), then there's a good chance that the `save-excursion` has never done its intended job and can be removed. Stefan