Path: utzoo!utgpu!water!watmath!clyde!cbosgd!mandrill!hal!ncoast!axcess!allbery From: allbery@axcess.UUCP (Brandon S. Allbery) Newsgroups: comp.emacs Subject: Is there a cleaner way to check for a narrowed buffer? Keywords: GNU Emacs narrow-to-region Message-ID: <138@axcess.UUCP> Date: 16 Jan 88 02:19:36 GMT Organization: aXcess Company, Mentor, Ohio Lines: 29 I have a function which wants to narrow the current buffer to a region only if it is not already narrowed. (The narrowing separates parts of a buffer which are edited with different major modes.) If the buffer is already narrowed, I want the function to signal an error. The only way I have figured out so far to do this is the following piece of ugliness: (let ((old-min (point-min)) (old-max (point-max))) (unwind-protect (progn (widen) (if (not (and (= old-min (point-min)) (= old-max (point-max)))) (error "You already have a C section in this file."))) (narrow-to-region old-min old-max))) I personally consider stuff like "unwind-protect" to be for use in special situations -- and checking for narrowing isn't one of them, or shouldn't be. I guess it's done in the C code rather than Lisp (since the format %n is used in the modeline rather than checking for a variable's value), but why isn't some special function provided ( (narrowp) or something ) to do this? -- ___ ________________, Brandon S. Allbery cbosgd \ ' \/ __ __, __, aXcess Company mandrill| __ | /__> <__ <__ 6615 Center St. #A1-105 !ncoast! / ` | \__. .__> .__> Mentor, OH 44060-4101 necntc | axcess!allbery \___/\________________. Moderator, comp.sources.misc hoptoad/