unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* defadvice bug or something else?
@ 2021-04-29  1:17 Tim Cross
  2021-04-29  2:07 ` Stefan Monnier
  2021-04-29  4:11 ` dick.r.chiang
  0 siblings, 2 replies; 6+ messages in thread
From: Tim Cross @ 2021-04-29  1:17 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-29  4:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-29  1:17 defadvice bug or something else? Tim Cross
2021-04-29  2:07 ` 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

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).