emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

defadvice bug or something else?


From: Tim Cross
Subject: defadvice bug or something else?
Date: Thu, 29 Apr 2021 11:17:09 +1000
User-agent: mu4e 1.5.12; emacs 28.0.50

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]