From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.help Subject: Re: Set-window-vscroll sometimes doesn't work Date: Sun, 18 Oct 2020 13:24:25 -0400 Message-ID: <853C8CD1-B58B-4F22-A889-4AB2AEE3DD80@gmail.com> References: <72B62847-3F35-412A-9F74-88442A936B19@gmail.com> <83eelvsivm.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28127"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 18 19:25:03 2020 Return-path: Envelope-to: geh-help-gnu-emacs@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 1kUCQZ-0007Ds-1G for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 18 Oct 2020 19:25:03 +0200 Original-Received: from localhost ([::1]:57458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUCQY-0007vb-3y for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 18 Oct 2020 13:25:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUCQ4-0007vK-GA for help-gnu-emacs@gnu.org; Sun, 18 Oct 2020 13:24:32 -0400 Original-Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]:34350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUCQ2-0005Rp-8x; Sun, 18 Oct 2020 13:24:32 -0400 Original-Received: by mail-io1-xd30.google.com with SMTP id z5so1696019iob.1; Sun, 18 Oct 2020 10:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=1CMRBVhcYVv2Te8BdC5uc+buFBAlBkgEYGpLlOD6Xlk=; b=V0PKw1UhoWNN/ux48RtZ4yzAm+/m+sCj4nb14rgMHeX+LTf0LVnSpP94Ky/AICVbGQ fgrX6ywoZRBuTCzN+BM+51AnLmvx+J8wlQWj5etnccw0G/N4pFGvRlg1dkA9FjGrWisd dkz15W/eGXvvXIQ/mEY7h03pGodyIFKNb03FRLW43v3Ct9IQ+lT1C9owlmUACMFj4qYp binsZFuA3OtzT9K+ojAutBKzY3CbAZmD1nRJYbJYGpuhxPNeZtnly8OAkSA/c+n2Tv3a +ud/zVQoCuWyuyIaQyd18v/F9xrS+m2IwkJ1gsPxyJZ9JLp12W5sXWW6IkUVOEqdqbiT jSxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=1CMRBVhcYVv2Te8BdC5uc+buFBAlBkgEYGpLlOD6Xlk=; b=nrVFXYT0S/r98KkogrteTSQ+OVxhl9jIRpTJyuvGph0P0L31Bo6P2EIB4RIgzMcRUg +0H3PGCOGpdj/JR0ntTasecmnTEKXmBTovd0yX4tknDrINizGSASI7T6akkFpKNoIFdn 98wgzXKA30rFfGb7zq6+Y49YQV9InOF8cSWgfONHBskx7QJhAlSz25O83eW1UiERADmB FxYnF9fPgmRXJw9JOyK6kKicmGnmm2g1kMLCa+52flqJHLcNVmUJnpsrdFg47Q7ql0EI BNZXBfbYclOrcaKLqlCXn6tjxWlwfh4m6s2tOuTCFtx61efEHcmQZfSOBw0CerK0uTp+ 4rQw== X-Gm-Message-State: AOAM530W4pvUXUm+gl4H2JRyINJesM7erlSP0cF2NDvzU/oeVPwaYkSe K0P6kghFSe8k+NUw/SsJVT1pF6WW64STqJBn X-Google-Smtp-Source: ABdhPJymvxrW2VrbPlw/tBRquVsSQdgLHRGJXKJO8aaGOfknCloDeJ2FcIFomxPEu+qGW/9tPhvWng== X-Received: by 2002:a05:6602:442:: with SMTP id e2mr8275567iov.71.1603041866685; Sun, 18 Oct 2020 10:24:26 -0700 (PDT) Original-Received: from ?IPv6:2601:98a:4200:9210:d02a:1c66:2033:eacb? ([2601:98a:4200:9210:d02a:1c66:2033:eacb]) by smtp.gmail.com with ESMTPSA id r2sm7749121ile.1.2020.10.18.10.24.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2020 10:24:26 -0700 (PDT) In-Reply-To: <83eelvsivm.fsf@gnu.org> X-Mailer: Apple Mail (2.3608.120.23.2.4) Received-SPF: pass client-ip=2607:f8b0:4864:20::d30; envelope-from=casouri@gmail.com; helo=mail-io1-xd30.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, HTML_MESSAGE=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-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124544 Archived-At: > On Oct 18, 2020, at 10:34 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Sat, 17 Oct 2020 20:35:00 -0400 >>=20 >> Normally if you scroll back onto an image, the image appears = completely. I want to instead only show part of the image, like what = pixel scrolling would do. If everything works as expected I should only = see the bottom of the image, instead I see the whole image. >>=20 >> It seems to be because (set-window-vscroll nil (- img-height = (frame-char-height)) t) didn=E2=80=99t take effect, if you call that = again with M-: or wrap it in (run-with-timer), then it works as = expected. >>=20 >> Is this caused by some redisplay optimization or something? >=20 > No. The problem is in your code. First, you use set-window-start and > scroll-down, both of which tramp window-vscroll (as you probably > realize if you think about what those do). =20 Why is so? Is there any material that I can read about these? > And after all that, you > need one "normal" redisplay cycle before you can set the vscroll, so, > for example, a single change below should make the code work as you > expect. >=20 > (progn > (switch-to-buffer (get-buffer-create "test")) > (erase-buffer) > (insert "\n\n") > (insert-image (create-image "abby road.jpeg" nil nil :scale 0.1) > "x") > (insert "\n") > (let ((after-img (point))) > (set-window-start nil (point)) > (scroll-down 1) > (sit-for 0) ;; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > (let* ((img (plist-get (text-properties-at (window-start)) = 'display)) > (img-height (cdr (image-size img t)))) > (set-window-vscroll nil (- img-height (frame-char-height)) t)))) This works, but brings flickers: the image first shows completely then = the vscroll takes effect, which is reasonable but not preferred. I found = that using (set-window-start nil (point) t) with the third argument = non-nil gives me the desired effect. My guess is that, as the doctoring = said, setting that to non-nil prevents redisplay to try to make point = completely visible, so redisplay doesn=E2=80=99t modify vscroll, so my = vscroll value survived. Is that right? Thanks, Yuan=