From: Keith David Bershatsky <esq@lawlist.com>
To: Eli Zaretskii <eliz@gnu.org>, Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 17678@debbugs.gnu.org
Subject: bug#17678: 24.4.50; Feature Request -- calculate new `window-start` & `window-end` before visual redisplay
Date: Fri, 13 Jun 2014 13:21:02 -0700 [thread overview]
Message-ID: <982E0AD5-5D0B-43F0-BF17-CDAB88C239BA@lawlist.com> (raw)
In-Reply-To: <jwvvbs4ac20.fsf-monnier+emacsbugs@gnu.org>
Here is a first draft, which appears to correctly handle common movement through the buffer using `beginning-of-buffer`, `end-of-buffer`, and custom paragraph forward / backward function.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar old-window-start nil
"This local variable is set within the `post-command-hook`; and,
is also used by the `window-scroll-functions` hook.")
(make-variable-buffer-local 'old-window-start)
(defvar old-window-end nil
"This local variable is set within the `post-command-hook`; and,
is also used by the `window-scroll-functions` hook.")
(make-variable-buffer-local 'old-window-end)
(defvar old-window-end-forced nil
"This local variable is set within the `post-command-hook`; and,
is also used by the `window-scroll-functions` hook.")
(make-variable-buffer-local 'old-window-end-forced)
(defun test-post-command-hook ()
(when
(and
(not (minibufferp))
(window-live-p (get-buffer-window (current-buffer))))
(setq old-window-start (window-start))
(setq old-window-end (window-end))
(setq old-window-end-forced (window-end nil t))
(when
(and
(not (< (point) old-window-start))
(not (> (point) old-window-end))
(not (> (point) old-window-end-forced)))
(message (concat
"P.C.H. -- `point`: %s | "
"`old-window-start`: %s | "
"`old-window-end`: %s | "
"`old-window-end-forced`: %s")
(point)
old-window-start
old-window-end
old-window-end-forced))))
(defun test-window-scroll-functions (win _start)
"Good for things like: `beginning-of-buffer`; `end-of-buffer`; `yank`; etc"
(when
(and
(not (minibufferp))
(window-live-p (get-buffer-window (current-buffer))))
(when
(or
(< (point) old-window-start)
(> (point) old-window-end)
(> (point) old-window-end-forced))
(message (concat
"W.S.F. -- `point`: %s | "
"*new* window-start: %s | "
"*new* window-end: %s")
(point)
_start
(window-end win t)))))
(define-minor-mode test-mode
"A minor-mode for testing `window-start` and `window-end`."
:init-value nil
:lighter " 𝓣𝓔𝓢𝓣"
:keymap nil
:global nil
(cond
(test-mode
(condition-case error
(progn
(setq scroll-conservatively 101)
(setq scroll-margin 0)
(add-hook 'post-command-hook 'test-post-command-hook nil t)
(add-hook 'window-scroll-functions 'test-window-scroll-functions nil t)
(message "Turned ON `test-mode`."))
(error
(test-mode 0)
(signal (car error) (cdr error)))))
((not test-mode)
(remove-hook 'post-command-hook 'test-post-command-hook t)
(remove-hook 'window-scroll-functions 'test-window-scroll-functions t)
(message "Turned OFF `test-mode`.") )))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
next prev parent reply other threads:[~2014-06-13 20:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-03 17:48 bug#17678: 24.4.50; Feature Request -- calculate new `window-start` & `window-end` before visual redisplay Keith David Bershatsky
2014-06-11 18:00 ` Stefan Monnier
2014-06-11 18:45 ` Eli Zaretskii
2014-06-11 21:58 ` Stefan Monnier
2014-06-12 17:54 ` Eli Zaretskii
2014-06-13 2:11 ` Stefan Monnier
2014-06-13 6:22 ` Eli Zaretskii
2014-06-13 12:34 ` Stefan Monnier
2014-06-13 13:27 ` Eli Zaretskii
2014-06-13 14:14 ` Stefan Monnier
2014-06-13 14:47 ` Eli Zaretskii
2014-06-13 18:47 ` Stefan Monnier
2014-06-13 20:21 ` Keith David Bershatsky [this message]
2014-06-13 20:59 ` Eli Zaretskii
2014-06-14 9:45 ` Eli Zaretskii
2014-06-14 17:10 ` Keith David Bershatsky
2014-06-15 2:24 ` Stefan Monnier
2014-06-13 16:22 ` Keith David Bershatsky
2014-06-13 17:55 ` Eli Zaretskii
2014-06-13 18:24 ` Keith David Bershatsky
2014-06-13 20:54 ` Eli Zaretskii
2014-06-13 21:19 ` Keith David Bershatsky
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=982E0AD5-5D0B-43F0-BF17-CDAB88C239BA@lawlist.com \
--to=esq@lawlist.com \
--cc=17678@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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).