From: Tim Cross <theophilusx@gmail.com>
To: emacs-devel@gnu.org
Subject: defadvice bug or something else?
Date: Thu, 29 Apr 2021 11:17:09 +1000 [thread overview]
Message-ID: <87fsz9swcf.fsf@gmail.com> (raw)
Hi All,
I've been tracking down a bug in an application which makes extensive
use of defadvice and found something which seems inconsistent. I'm not
sure if this is a bug or some misunderstanding on my part.
The problem is, I'm getting different values for window-end calls when
they occur as part of an after advice compared to when they are called
ouside of any defadvice. the value returned when called within defadvice
is incorrect and does not represent the position at the end of the
window.
I used the following defadvice and defun to verify this behaviour
(require 'cl-lib)
(require 'advice)
(cl-loop
for f in
'(scroll-up scroll-down
scroll-up-command scroll-down-command)
do
(eval
`(defadvice ,f (after emacspeak pre act comp)
(message "scroll advice: start = %d end = %d diff = %d"
(window-start)
(window-end)
(- (window-end) (window-start))))))
(defun tx-window ()
(interactive)
(message "tx-window: start = %d end = %d diff = %d"
(window-start)
(window-end)
(- (window-end) (window-start))))
Using a test file of data which is multiple screenfuls in size, I open
the file, move point to the start of the buffer, scroll down with either
C-v or pgdown, run M-x tx-window. I did this twice and then did the
opposite, scrolling back two windows to be back at the beginning of the
buffer, executing tx-window after each scroll. The output I get is
scroll advice: start = 1259 end = 1536 diff = 277
tx-window: start = 1259 end = 2863 diff = 1604
scroll advice: start = 2662 end = 2863 diff = 201
tx-window: start = 2662 end = 4069 diff = 1407
scroll advice: start = 1259 end = 4069 diff = 2810
tx-window: start = 1259 end = 2863 diff = 1604
scroll advice: start = 1 end = 2863 diff = 2862
tx-window: start = 1 end = 1536 diff = 1535
I would expect the output from 'scroll advice' and 'tx-window' to be the
same. Note the end value (from window-end call). The value returned from
within 'scroll advice' is incorrect. It is either way too small after
C-v/pgdown or way too large after M-v/pgup. The value from tx-window is
correct.
This is with Emacs 27.2 built from git repo yesterday on Ubuntu 20.10,
but I think the same issue exists in current master. I started with
emacs -Q and loaded the above test code.
Does this look like a bug or is there something I've overlooked or
misunderstood?
thanks,
Tim
--
Tim Cross
next reply other threads:[~2021-04-29 1:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-29 1:17 Tim Cross [this message]
2021-04-29 2:07 ` defadvice bug or something else? Stefan Monnier
2021-04-29 3:15 ` T.V Raman
2021-04-29 4:22 ` Tim Cross
2021-04-29 4:11 ` dick.r.chiang
2021-04-29 4:55 ` Tim Cross
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=87fsz9swcf.fsf@gmail.com \
--to=theophilusx@gmail.com \
--cc=emacs-devel@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).