Path: utzoo!utgpu!water!watmath!clyde!ima!bbn!rochester!quiroz From: quiroz@cs.rochester.edu (Cesar Quiroz) Newsgroups: comp.emacs Subject: Re: Is there a cleaner way to check for a narrowed buffer? Summary: Not enough to check (point-min) Message-ID: <5959@sol.ARPA> Date: 18 Jan 88 04:38:50 GMT References: <138@axcess.UUCP> <2336@bloom-beacon.MIT.EDU> Reply-To: quiroz@cs.rochester.edu (Cesar Quiroz) Organization: U of Rochester, CS Dept, Rochester, NY 14627 Lines: 31 Expires: Sender: Followup-To: Brandon Allbery wants a function defined to check if the current buffer is under narrowing. I take he was thinking of a C primitive or such, to complement the other narrowing functions. Wolfgang Rupprecht suggests this function: :(defun narowp () :"Return t if buffer is narrowed." : (/= 1 (point-min))) This doesn't work, as a little reflection shows. The narrowing might permit (= 1 (point-min))! Think of narrowing to the first page, for instance. The original idea (to check if either point-min or point-max changed) is better. A possible implementation, although I suspect Brandon doesn't need this code: (defun narrowp () "True if the current buffer is narrowed. The value actually returned is a list of the end points of the restriction." (let ((min (point-min)) (max (point-max))) (if (and (= min 1) (= max (1+ (buffer-size)))) nil (list min max)))) This still fails if the restriction coincides with the whole buffer... -- Cesar Augusto Quiroz Gonzalez Department of Computer Science ...allegra!rochester!quiroz University of Rochester or Rochester, NY 14627 quiroz@cs.rochester.edu