unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Why does `(window-line-height)' return nil?
@ 2013-08-03  8:26 Xue Fuqiao
  2013-08-03  9:01 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Xue Fuqiao @ 2013-08-03  8:26 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

In my *scratch* buffer, all of the following expressions return nil with
`eval-print-last-sexp' (also tried `eval-last-sexp'):

--8<---------------cut here---------------start------------->8---
(window-line-height 'header-line)
(window-line-height 'mode-line)
(window-line-height)
(window-line-height 0)
(window-line-height -1)
--8<---------------cut here---------------end--------------->8---

Why do they return nil?  After reading the doc string, I only found one
sentence that may be relavant: "Return nil if window display is not
up-to-date."  So, does that mean window display is not up-to-date when
evaluating the expression?  I've searched the archives/web, but found
little information about this function.

-- 
Best regards, Xue Fuqiao.
http://www.gnu.org/software/emacs/



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why does `(window-line-height)' return nil?
  2013-08-03  8:26 Why does `(window-line-height)' return nil? Xue Fuqiao
@ 2013-08-03  9:01 ` Eli Zaretskii
  2013-08-04  3:52   ` Xue Fuqiao
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2013-08-03  9:01 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 3 Aug 2013 16:26:50 +0800
> From: Xue Fuqiao <xfq.free@gmail.com>
> 
> In my *scratch* buffer, all of the following expressions return nil with
> `eval-print-last-sexp' (also tried `eval-last-sexp'):
> 
> --8<---------------cut here---------------start------------->8---
> (window-line-height 'header-line)
> (window-line-height 'mode-line)
> (window-line-height)
> (window-line-height 0)
> (window-line-height -1)
> --8<---------------cut here---------------end--------------->8---
> 
> Why do they return nil?  After reading the doc string, I only found one
> sentence that may be relavant: "Return nil if window display is not
> up-to-date."  So, does that mean window display is not up-to-date when
> evaluating the expression?

Yes, that's what it means.  This function will almost always return
nil if you evaluate an expression that calls it in the *scratch*
buffer, because that evaluation forces a new redisplay cycle (to
display the result).  It does return non-nil values when called from
Lisp code that does not trigger redisplay, though.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why does `(window-line-height)' return nil?
  2013-08-03  9:01 ` Eli Zaretskii
@ 2013-08-04  3:52   ` Xue Fuqiao
  0 siblings, 0 replies; 3+ messages in thread
From: Xue Fuqiao @ 2013-08-04  3:52 UTC (permalink / raw)
  To: help-gnu-emacs

On Sat, Aug 3, 2013 at 5:01 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sat, 3 Aug 2013 16:26:50 +0800
>> From: Xue Fuqiao <xfq.free@gmail.com>
>>
>> In my *scratch* buffer, all of the following expressions return nil with
>> `eval-print-last-sexp' (also tried `eval-last-sexp'):
>>
>> --8<---------------cut here---------------start------------->8---
>> (window-line-height 'header-line)
>> (window-line-height 'mode-line)
>> (window-line-height)
>> (window-line-height 0)
>> (window-line-height -1)
>> --8<---------------cut here---------------end--------------->8---
>>
>> Why do they return nil?  After reading the doc string, I only found one
>> sentence that may be relavant: "Return nil if window display is not
>> up-to-date."  So, does that mean window display is not up-to-date when
>> evaluating the expression?
>
> Yes, that's what it means.  This function will almost always return
> nil if you evaluate an expression that calls it in the *scratch*
> buffer, because that evaluation forces a new redisplay cycle (to
> display the result).  It does return non-nil values when called from
> Lisp code that does not trigger redisplay, though.

Ah, I see.  Thank you.

-- 
Best regards, Xue Fuqiao.
http://www.gnu.org/software/emacs/



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-04  3:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-03  8:26 Why does `(window-line-height)' return nil? Xue Fuqiao
2013-08-03  9:01 ` Eli Zaretskii
2013-08-04  3:52   ` Xue Fuqiao

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).