help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What variable says that the buffer is in narrowed state?


From: Sven Joachim
Subject: Re: What variable says that the buffer is in narrowed state?
Date: Mon, 15 Oct 2007 19:51:46 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> (defun buffer-narrowed-p ()
>>   "Return t if buffer is narrowed, nil otherwise."
>>   (or (> (point-min) 1)
>>       (< (point-max) (buffer-size))))
>
> Sometimes you can't avoid assuming that buffer positions start at 1, but
> that's rare.

What's worse is that I incorrectly assumed that buffer positions end
at (buffer-size), while they actually end at (1+ (buffer-size)). :-/

>  Even in the above case, for example, you can simply check:
>
>    (defun buffer-narrowed-p ()
>      (> (buffer-size) (- (point-max) (point-min))))

Thanks.  I'm still learning, maybe in a few years I'll be able to post
a snippet here that actually works. :-(

Slightly embarrassed,
Sven


reply via email to

[Prev in Thread] Current Thread [Next in Thread]