all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: What variable says that the buffer is in narrowed state?
Date: Sun, 14 Oct 2007 15:57:02 -0400	[thread overview]
Message-ID: <jwvhckth3p3.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: 87tzov5drs.fsf@gmx.de

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

  parent reply	other threads:[~2007-10-14 19:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2016.1192278715.18990.help-gnu-emacs@gnu.org>
2007-10-13 13:45 ` What variable says that the buffer is in narrowed state? Sven Joachim
2007-10-13 15:57   ` Bastien
2007-10-14 19:57   ` Stefan Monnier [this message]
2007-10-15 17:51     ` Sven Joachim
2007-10-13 13:30 Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvhckth3p3.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.