* How to add a temporary blank line at the end of buffer safely
@ 2018-01-11 8:45 tumashu
2018-01-11 16:03 ` Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: tumashu @ 2018-01-11 8:45 UTC (permalink / raw)
To: emacs-devel@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]
-----------------------------------------------------------------------
> Date: Mon, 11 Dec 2017 16:29:16 +0800 (CST)
> From: tumashu <address@hidden>
> Cc: "address@hidden" <address@hidden>
>
> by the way, does emacs has a function, which can get the point's left-bottom
> pixel position, if not,
> is it possible to add it to emacs?
Doesn't vertical-motion fit the bill? If not, why not?
------------------------------------------------------------------------
@Eli Zaretskii Thanks for your suggestion, it works very well, the only problem is that
it can not work when point at the end line of buffer, I use the below code to handle this problem,
(add a temp "\n" then remove) but it seem to hacky. any good way to solve this problem:
(if (= (line-end-position) (point-max))
(let (posn)
(goto-char (point-max))
(insert "\n")
(setq posn (posn-at-point (point) window))
(delete-char -1)
posn)
(vertical-motion 1)
(posn-at-point (point) window))
[-- Attachment #2: Type: text/html, Size: 1577 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to add a temporary blank line at the end of buffer safely
2018-01-11 8:45 How to add a temporary blank line at the end of buffer safely tumashu
@ 2018-01-11 16:03 ` Eli Zaretskii
2018-01-12 1:38 ` tumashu
0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2018-01-11 16:03 UTC (permalink / raw)
To: tumashu; +Cc: emacs-devel
> Date: Thu, 11 Jan 2018 16:45:43 +0800 (CST)
> From: tumashu <tumashu@163.com>
>
> Doesn't vertical-motion fit the bill? If not, why not?
> ------------------------------------------------------------------------
> @Eli Zaretskii Thanks for your suggestion, it works very well, the only problem is that
> it can not work when point at the end line of buffer, I use the below code to handle this problem,
> (add a temp "\n" then remove) but it seem to hacky. any good way to solve this problem:
Something like the below, perhaps?
(aref (font-info (font-at POS)) 3)
This will give you the height of the font used at position POS. Then
you could add that to the y-coordinate of the line at EOB, to get the
bottom y-coordinate of that line. (Caveat: font-at doesn't like to be
called at EOB, so make sure you are one buffer position before that.)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re:Re: How to add a temporary blank line at the end of buffer safely
2018-01-11 16:03 ` Eli Zaretskii
@ 2018-01-12 1:38 ` tumashu
0 siblings, 0 replies; 3+ messages in thread
From: tumashu @ 2018-01-12 1:38 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel@gnu.org
[-- Attachment #1: Type: text/plain, Size: 966 bytes --]
It works, thanks very much.
At 2018-01-12 00:03:51, "Eli Zaretskii" <eliz@gnu.org> wrote:
>> Date: Thu, 11 Jan 2018 16:45:43 +0800 (CST)
>> From: tumashu <tumashu@163.com>
>>
>> Doesn't vertical-motion fit the bill? If not, why not?
>> ------------------------------------------------------------------------
>> @Eli Zaretskii Thanks for your suggestion, it works very well, the only problem is that
>> it can not work when point at the end line of buffer, I use the below code to handle this problem,
>> (add a temp "\n" then remove) but it seem to hacky. any good way to solve this problem:
>
>Something like the below, perhaps?
>
> (aref (font-info (font-at POS)) 3)
>
>This will give you the height of the font used at position POS. Then
>you could add that to the y-coordinate of the line at EOB, to get the
>bottom y-coordinate of that line. (Caveat: font-at doesn't like to be
>called at EOB, so make sure you are one buffer position before that.)
[-- Attachment #2: Type: text/html, Size: 1230 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-12 1:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-11 8:45 How to add a temporary blank line at the end of buffer safely tumashu
2018-01-11 16:03 ` Eli Zaretskii
2018-01-12 1:38 ` tumashu
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.