all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* buffer-narrowed-p
@ 2009-10-11 20:41 Lennart Borgman
  2009-10-11 20:48 ` buffer-narrowed-p Deniz Dogan
  0 siblings, 1 reply; 6+ messages in thread
From: Lennart Borgman @ 2009-10-11 20:41 UTC (permalink / raw)
  To: Emacs-Devel devel

Could this perhaps be included in Emacs?

';;;###autoload
(defun buffer-narrowed-p ()
  "Return non-nil if the current buffer is narrowed."
  (/= (buffer-size)
      (- (point-max)
         (point-min))))




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: buffer-narrowed-p
  2009-10-11 20:41 buffer-narrowed-p Lennart Borgman
@ 2009-10-11 20:48 ` Deniz Dogan
  2009-10-11 21:25   ` buffer-narrowed-p Lennart Borgman
  0 siblings, 1 reply; 6+ messages in thread
From: Deniz Dogan @ 2009-10-11 20:48 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Emacs-Devel devel

2009/10/11 Lennart Borgman <lennart.borgman@gmail.com>:
> Could this perhaps be included in Emacs?
>
> ';;;###autoload
> (defun buffer-narrowed-p ()
>  "Return non-nil if the current buffer is narrowed."
>  (/= (buffer-size)
>      (- (point-max)
>         (point-min))))
>
>
>

I was almost certain a function like this existed already. Am I mistaken?

-- 
Deniz Dogan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: buffer-narrowed-p
  2009-10-11 20:48 ` buffer-narrowed-p Deniz Dogan
@ 2009-10-11 21:25   ` Lennart Borgman
  0 siblings, 0 replies; 6+ messages in thread
From: Lennart Borgman @ 2009-10-11 21:25 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

On Sun, Oct 11, 2009 at 10:48 PM, Deniz Dogan <deniz.a.m.dogan@gmail.com> wrote:
> 2009/10/11 Lennart Borgman <lennart.borgman@gmail.com>:
>> Could this perhaps be included in Emacs?
>>
>> ';;;###autoload
>> (defun buffer-narrowed-p ()
>>  "Return non-nil if the current buffer is narrowed."
>>  (/= (buffer-size)
>>      (- (point-max)
>>         (point-min))))
>>
>>
>>
>
> I was almost certain a function like this existed already. Am I mistaken?


I thought so too, but it is actually part of nXhtml ... ;-)




^ permalink raw reply	[flat|nested] 6+ messages in thread

* buffer-narrowed-p
@ 2010-08-14 12:33 Andreas Röhler
  2010-08-14 12:39 ` buffer-narrowed-p Lennart Borgman
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Röhler @ 2010-08-14 12:33 UTC (permalink / raw)
  To: help-gnu-emacs



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/



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: buffer-narrowed-p
  2010-08-14 12:33 buffer-narrowed-p Andreas Röhler
@ 2010-08-14 12:39 ` Lennart Borgman
  2010-08-14 13:09   ` buffer-narrowed-p Andreas Röhler
  0 siblings, 1 reply; 6+ messages in thread
From: Lennart Borgman @ 2010-08-14 12:39 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

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))))



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: buffer-narrowed-p
  2010-08-14 12:39 ` buffer-narrowed-p Lennart Borgman
@ 2010-08-14 13:09   ` Andreas Röhler
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Röhler @ 2010-08-14 13:09 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: help-gnu-emacs

Am 14.08.2010 14:39, schrieb Lennart Borgman:
> 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))))
>

Should be faster, thanks!




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-08-14 13:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-14 12:33 buffer-narrowed-p Andreas Röhler
2010-08-14 12:39 ` buffer-narrowed-p Lennart Borgman
2010-08-14 13:09   ` buffer-narrowed-p Andreas Röhler
  -- strict thread matches above, loose matches on Subject: below --
2009-10-11 20:41 buffer-narrowed-p Lennart Borgman
2009-10-11 20:48 ` buffer-narrowed-p Deniz Dogan
2009-10-11 21:25   ` buffer-narrowed-p Lennart Borgman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.