help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

buffer-narrowed-p


From: Andreas Röhler
Subject: buffer-narrowed-p
Date: Sat, 14 Aug 2010 14:33:24 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6



Hi,

a couple of functions should behave different if buffer
is narrowed, i.e. taking narrowing already as
users decision to work on it, dismissing check for region
then.

As its used repeatedly, here an essay to solve it one
for all:

(defun buffer-narrowed-p ()
  (interactive)
  "Returns t, if buffer is narrowed. "
  (save-restriction
    (lexical-let ((beg (point-min))
                  (end (point-max))
                  erg)
      (widen)
      (setq erg (not (and (eq beg (point-min)) (eq end (point-max)))))
      (when (interactive-p)
        (if erg (message "Buffer is narrowed to: %d %d" beg end)
          (message "Buffer not narrowed: %s" "nil")))
      erg)))

Comments welcome :-)

Andreas

--
https://code.launchpad.net/~a-roehler/python-mode
https://code.launchpad.net/s-x-emacs-werkstatt/



reply via email to

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