[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: buffer-narrowed-p
From: |
Lennart Borgman |
Subject: |
Re: buffer-narrowed-p |
Date: |
Sat, 14 Aug 2010 14:39:55 +0200 |
On Sat, Aug 14, 2010 at 2:33 PM, Andreas Röhler
<andreas.roehler@easy-emacs.de> wrote:
>
>
> 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 :-)
I have this (which I think I stole from a comment by Stefan) in
ourcomments-util.el in nXhtml:
;;;###autoload
(defun buffer-narrowed-p ()
"Return non-nil if the current buffer is narrowed."
(/= (buffer-size)
(- (point-max)
(point-min))))
- buffer-narrowed-p, Andreas Röhler, 2010/08/14
- Re: buffer-narrowed-p,
Lennart Borgman <=