From: JD Smith <jdtsmith@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Temporarily select-window, without updating mode-line face and cursor fill?
Date: Sat, 1 May 2021 16:32:22 -0400 [thread overview]
Message-ID: <6168853E-E5B1-4247-A0D7-4D4191DCED0A@gmail.com> (raw)
In-Reply-To: <83pmya8d49.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1968 bytes --]
> On May 1, 2021, at 3:31 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: JD Smith <jdtsmith@gmail.com>
>> Date: Sat, 1 May 2021 14:46:31 -0400
>>
>> I’m working on a small “in mode-line” scroll bar, and have implemented mouse events for it, which are working well. When I interact using the mouse with the mode line of a non-selected window, I need to have that window temporarily selected, so I can calculate its line offsets and move within it. But (just as for regular scrollbars), I’d like to retain the originally active window afterwards.
>
> Please explain in more detail why do you think you need to select the
> window. What are those "line offsets", and why "move within it"
> requires to select the window?
Sure, thanks. I compute line positions at a number of points (window-start, window-end, and point-max) inside a mode line :eval form. To compute line numbers at these positions, for speed in very long files, I’m actually using:
(defun mlscroll-fast-line-number-at-pos (pos)
(save-excursion
(goto-char pos)
(string-to-number (format-mode-line "%l"))))
The operative bits of the “move within” look like:
(when (/= targ start)
(forward-line (- targ start))
(recenter))
During normal automatic mode-line update, the selected window is automatically bound correctly while the mode line string is computed (without updating the mode line face, I might add!). But during the mouse event callback, I must use the starting window of the mouse event (a press) as the window to target, since the user could click on any of them.
I believe I can re-task all of the “computing lines” code to take a window argument, i.e. to avoid actually selecting the window itself. But less clear is how to move forward and back a given number of lines (forward-line) and recenter in an unselected window, without selecting it temporarily and causing the mode line face flashing.
[-- Attachment #2: Type: text/html, Size: 3232 bytes --]
next prev parent reply other threads:[~2021-05-01 20:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-01 18:46 Temporarily select-window, without updating mode-line face and cursor fill? JD Smith
2021-05-01 19:31 ` Eli Zaretskii
2021-05-01 20:32 ` JD Smith [this message]
2021-05-02 6:49 ` Eli Zaretskii
2021-05-03 2:15 ` JD Smith
2021-05-03 7:50 ` martin rudalics
2021-05-03 16:16 ` JD Smith
2021-05-03 17:32 ` martin rudalics
2021-05-02 7:40 ` martin rudalics
2021-05-03 2:23 ` JD Smith
2021-05-01 22:17 ` JD Smith
2021-05-02 6:55 ` Eli Zaretskii
2021-05-03 2:08 ` JD Smith
2021-05-03 2:25 ` Stefan Monnier
2021-05-03 2:49 ` JD Smith
2021-05-04 19:28 ` JD Smith
2021-05-04 19:40 ` Stefan Monnier
2021-05-05 0:49 ` Stefan Kangas
2021-05-05 11:54 ` Eli Zaretskii
2021-05-05 19:32 ` Stefan Kangas
2021-05-05 19:47 ` Stefan Monnier
2021-05-06 0:16 ` JD Smith
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6168853E-E5B1-4247-A0D7-4D4191DCED0A@gmail.com \
--to=jdtsmith@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.