From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sven Joachim Newsgroups: gmane.emacs.help Subject: Re: What variable says that the buffer is in narrowed state? Date: Mon, 15 Oct 2007 19:51:46 +0200 Message-ID: <87ve98w9jh.fsf@gmx.de> References: <87tzov5drs.fsf@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1192477505 26249 80.91.229.12 (15 Oct 2007 19:45:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 15 Oct 2007 19:45:05 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 15 21:44:56 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IhUru-0001k3-6K for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Oct 2007 20:40:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IhUrn-0005Dx-8F for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Oct 2007 14:40:39 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed1.swip.net!swipnet!newsfeed1.funet.fi!newsfeeds.funet.fi!uio.no!quimby.gnus.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 23 Original-NNTP-Posting-Host: p54864bba.dip.t-dialin.net Original-X-Trace: quimby.gnus.org 1192470631 11373 84.134.75.186 (15 Oct 2007 17:50:31 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Mon, 15 Oct 2007 17:50:31 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:T/DPE6oXJ0OkL3mci+sV9RnN5to= Original-Xref: shelby.stanford.edu gnu.emacs.help:152954 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:48459 Archived-At: Stefan Monnier 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