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: Stefan Monnier
Subject: Re: What variable says that the buffer is in narrowed state?
Date: Sun, 14 Oct 2007 15:57:02 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

>> I expected to find some `buffer-narrowed-p' variable.  Is there
>> something like this?  The mode-line is able to display this bit 
>> of information, so I guess it might somehow be accessible.

> If there were such a thing, it should probably be a function rather
> than a variable.  Doesn't seem there is one, so I wrote it for you:

> (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.  Even in the above case, for example, you can simply check:

   (defun buffer-narrowed-p ()
     (> (buffer-size) (- (point-max) (point-min))))


-- Stefan


reply via email to

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