From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Bob Weiner <rsw@gnu.org>
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 [thread overview]
Message-ID: <jwv4kfavgqn.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20210510035709.E742920DFD@vcs0.savannah.gnu.org> (ELPA Syncer's message of "Sun, 9 May 2021 23:57:09 -0400 (EDT)")
> (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
next parent reply other threads:[~2021-05-10 13:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210510035708.29543.25002@vcs0.savannah.gnu.org>
[not found] ` <20210510035709.E742920DFD@vcs0.savannah.gnu.org>
2021-05-10 13:59 ` Stefan Monnier [this message]
2021-05-11 0:18 ` [elpa] externals/hyperbole c501027 2/2: Fix set-buffer byte-compiler warnings; remove outdated references Robert Weiner
2021-05-11 1:25 ` Stefan Monnier
2021-05-11 15:15 ` Jean Louis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv4kfavgqn.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=rsw@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).