From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tim Cross Newsgroups: gmane.emacs.devel Subject: defadvice bug or something else? Date: Thu, 29 Apr 2021 11:17:09 +1000 Message-ID: <87fsz9swcf.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23704"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.5.12; emacs 28.0.50 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 29 03:39:54 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 1lbvek-00064l-4Q for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Apr 2021 03:39:54 +0200 Original-Received: from localhost ([::1]:56044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbvei-0002uj-NM for ged-emacs-devel@m.gmane-mx.org; Wed, 28 Apr 2021 21:39:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbveB-0002Sv-6v for emacs-devel@gnu.org; Wed, 28 Apr 2021 21:39:19 -0400 Original-Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:41501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbve9-0001Om-Hz for emacs-devel@gnu.org; Wed, 28 Apr 2021 21:39:18 -0400 Original-Received: by mail-pg1-x52b.google.com with SMTP id m37so3456920pgb.8 for ; Wed, 28 Apr 2021 18:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:date:message-id:mime-version; bh=M71mDS8a0UTTPqX+/4cxUH4D4hZ4a7gzD28uNh7y3JI=; b=V9kxBIxblFHxbBMdQLKE0vMK811e4RFSO4HH36H+Eg9qs5CwKeWwCAsresRt8UDuEa rq2SXUf//Wa39A6qMh8edh5d4woR+EjSxu4tZqVbXIHZKVMTkdZJBo1Id7SGE/HiVHC0 ZuSL7wsG7eLchNTjkarVPEC2eSaHMLU72wqKKozx7c6eNL0yb1BJIKWZG4Dkf+v6H8PM rEpIk/WZiLLYYbb0OHcSUr+3MhT8xrGEtoF5R5EqOyOGIUs1H0QLUbxk0NZBmhevKR+O waEejjDkBZKxBPjLCdC+aRJfIVEUWlgrj5f9E/V+CJk+YHUdrImZMrBz79ds5ClHM1oP Ytlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=M71mDS8a0UTTPqX+/4cxUH4D4hZ4a7gzD28uNh7y3JI=; b=LlDMPap+DhcplmHr2jkqH7BpYYhCsgTjfMTb25eO5fn3NaylIkj6On9tlSRFKdlBWG mVt3sqS3VhpZwjUHyHJrDWMLaf3WknlZ3QXj7A2It4WD3o4wPcEAlxQyP0KV2u6MC2tM CS734hm+lX1H1nk3glgH2RGQKUtPVUOvu0+HvxMJoNwqVT3RPhcOxPXRi1C0pWsIlcOn Sdi/ip3yWuvyB3cDnvJD3jNLw3lGFKCbT+AOcAfz7SpAi7mDNPCaCzRWLb2xXfsjIFci FtFKRZsKkG3ccPAh4p4hxj7XewjTHqqzdHixfpv3K/Uxc29brIZmR2/al2Q/02yYFQOa y6uQ== X-Gm-Message-State: AOAM533KRtAhg9xer3cCXfJp2J0VXXZemvSyAcvdyvU5hTzliyDxr3ce rw66yec74DZl08+q4/Yln0ZExkN6MI4= X-Google-Smtp-Source: ABdhPJwaxb4HimiuShmR1J4N0Me/OT36/Ixudq9CFnruMsX8xvOf7FPuNrjFGf/c55nLb5SPEOjjrg== X-Received: by 2002:a63:5466:: with SMTP id e38mr29759140pgm.172.1619660355615; Wed, 28 Apr 2021 18:39:15 -0700 (PDT) Original-Received: from tim-desktop (106-69-100-114.dyn.iinet.net.au. [106.69.100.114]) by smtp.gmail.com with ESMTPSA id r127sm769403pfr.163.2021.04.28.18.39.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 18:39:15 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=theophilusx@gmail.com; helo=mail-pg1-x52b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:268593 Archived-At: 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