* How to get the number of displayed line the point is in?
@ 2018-06-03 3:58 Marcin Borkowski
2018-06-03 7:41 ` tomas
2018-06-03 15:04 ` Eli Zaretskii
0 siblings, 2 replies; 7+ messages in thread
From: Marcin Borkowski @ 2018-06-03 3:58 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi all,
as in the subject. I want to know how far the point is from the top of
the screen. (What I actually need to do is to inert something in the
current buffer in such a position so that it appears precisely on the
last visible line.)
TIA,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to get the number of displayed line the point is in?
2018-06-03 3:58 Marcin Borkowski
@ 2018-06-03 7:41 ` tomas
2018-06-07 17:11 ` Marcin Borkowski
2018-06-03 15:04 ` Eli Zaretskii
1 sibling, 1 reply; 7+ messages in thread
From: tomas @ 2018-06-03 7:41 UTC (permalink / raw)
To: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sun, Jun 03, 2018 at 05:58:07AM +0200, Marcin Borkowski wrote:
> Hi all,
>
> as in the subject. I want to know how far the point is from the top of
> the screen. (What I actually need to do is to inert something in the
> current buffer in such a position so that it appears precisely on the
> last visible line.)
Is it some combination of `line-number-at-pos' and `window-start' what
you are looking for?
Besides the section on "Window Start and End Positions" in the elisp
manual could be a source of inspiration.
Cheers
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlsTm8cACgkQBcgs9XrR2ka/zACfb58gySBpVVcZyp/HifiVuUYN
R9sAmwYEDswq9Ws2UkNTFU+9BY6b2a+P
=6wv0
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to get the number of displayed line the point is in?
[not found] <mailman.1029.1527998388.1292.help-gnu-emacs@gnu.org>
@ 2018-06-03 10:52 ` Ben Bacarisse
2018-06-07 17:12 ` Marcin Borkowski
0 siblings, 1 reply; 7+ messages in thread
From: Ben Bacarisse @ 2018-06-03 10:52 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> as in the subject. I want to know how far the point is from the top of
> the screen. (What I actually need to do is to inert something in the
> current buffer in such a position so that it appears precisely on the
> last visible line.)
I'd start with:
(progn
(goto-char (window-end))
(forward-line -1))
and work round problems like partial lines, the last line not having a
newline after it and whether the display changes as a result of the
positioning as you encounter them!
Caveat: I'm no expert. For all I know there's a
"put-point-at-start-of-last-whole-visible-line-in-window-without-scrolling"
function.
--
Ben.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to get the number of displayed line the point is in?
2018-06-03 3:58 Marcin Borkowski
2018-06-03 7:41 ` tomas
@ 2018-06-03 15:04 ` Eli Zaretskii
2018-06-07 17:10 ` Marcin Borkowski
1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2018-06-03 15:04 UTC (permalink / raw)
To: help-gnu-emacs
> From: Marcin Borkowski <mbork@mbork.pl>
> Date: Sun, 03 Jun 2018 05:58:07 +0200
>
> as in the subject. I want to know how far the point is from the top of
> the screen.
Does posn-at-point fit the bill?
> (What I actually need to do is to inert something in the
> current buffer in such a position so that it appears precisely on the
> last visible line.)
Then perhaps pos-visible-in-window-p is your friend?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to get the number of displayed line the point is in?
2018-06-03 15:04 ` Eli Zaretskii
@ 2018-06-07 17:10 ` Marcin Borkowski
0 siblings, 0 replies; 7+ messages in thread
From: Marcin Borkowski @ 2018-06-07 17:10 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
On 2018-06-03, at 17:04, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Marcin Borkowski <mbork@mbork.pl>
>> Date: Sun, 03 Jun 2018 05:58:07 +0200
>>
>> as in the subject. I want to know how far the point is from the top of
>> the screen.
>
> Does posn-at-point fit the bill?
>
>> (What I actually need to do is to inert something in the
>> current buffer in such a position so that it appears precisely on the
>> last visible line.)
>
> Then perhaps pos-visible-in-window-p is your friend?
Thanks a lot, I'll check it out in some Free Time™.
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to get the number of displayed line the point is in?
2018-06-03 7:41 ` tomas
@ 2018-06-07 17:11 ` Marcin Borkowski
0 siblings, 0 replies; 7+ messages in thread
From: Marcin Borkowski @ 2018-06-07 17:11 UTC (permalink / raw)
To: tomas; +Cc: help-gnu-emacs
On 2018-06-03, at 09:41, tomas@tuxteam.de wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Sun, Jun 03, 2018 at 05:58:07AM +0200, Marcin Borkowski wrote:
>> Hi all,
>>
>> as in the subject. I want to know how far the point is from the top of
>> the screen. (What I actually need to do is to inert something in the
>> current buffer in such a position so that it appears precisely on the
>> last visible line.)
>
> Is it some combination of `line-number-at-pos' and `window-start' what
> you are looking for?
>
> Besides the section on "Window Start and End Positions" in the elisp
> manual could be a source of inspiration.
Thanks, I'll check these, too (only not within the next 48 hours,
I guess...)
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to get the number of displayed line the point is in?
2018-06-03 10:52 ` How to get the number of displayed line the point is in? Ben Bacarisse
@ 2018-06-07 17:12 ` Marcin Borkowski
0 siblings, 0 replies; 7+ messages in thread
From: Marcin Borkowski @ 2018-06-07 17:12 UTC (permalink / raw)
To: Ben Bacarisse; +Cc: help-gnu-emacs
On 2018-06-03, at 12:52, Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> as in the subject. I want to know how far the point is from the top of
>> the screen. (What I actually need to do is to inert something in the
>> current buffer in such a position so that it appears precisely on the
>> last visible line.)
>
> I'd start with:
>
> (progn
> (goto-char (window-end))
> (forward-line -1))
>
> and work round problems like partial lines, the last line not having a
> newline after it and whether the display changes as a result of the
> positioning as you encounter them!
>
> Caveat: I'm no expert. For all I know there's a
> "put-point-at-start-of-last-whole-visible-line-in-window-without-scrolling"
> function.
Thanks, and this might be the best solution (I have fairly good control
over everything in the buffer - e.g., I have truncate-line-mode on.)
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-06-07 17:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.1029.1527998388.1292.help-gnu-emacs@gnu.org>
2018-06-03 10:52 ` How to get the number of displayed line the point is in? Ben Bacarisse
2018-06-07 17:12 ` Marcin Borkowski
2018-06-03 3:58 Marcin Borkowski
2018-06-03 7:41 ` tomas
2018-06-07 17:11 ` Marcin Borkowski
2018-06-03 15:04 ` Eli Zaretskii
2018-06-07 17:10 ` Marcin Borkowski
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).