unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* creating a function that works for active region or whole buffer
@ 2013-01-22 11:20 Luca Ferrari
  2013-01-22 14:37 ` Mark Skilbeck
  2013-01-22 16:01 ` Le Wang
  0 siblings, 2 replies; 10+ messages in thread
From: Luca Ferrari @ 2013-01-22 11:20 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,
I'd like to write a function that can be invoked when a region is
active, and therefore is limited to the region itself, or on the whole
buffer if not any region is active. Therefore in my function I placed
the following conditional to set the start-block and end-block lines
to the whole buffer or the whole region:


(if (not (null (region-beginning) ) )
          (progn

            (setq current-block-start-line (line-number-at-pos
(region-beginning) ) )
            (setq current-block-end-line   (line-number-at-pos
(region-end) ) ) )

                                        ; else mark the whole buffer
        (progn
          (setq current-block-start-line (line-number-at-pos (point-min) ) )
          (setq current-block-end-line   (line-number-at-pos (point-max) ) ) ) )

It seems to work, but when I mark a region, that remove the region
(i.e., unmark) and call the function again it seems that the function
has still the region-beginning and region-end marks (i.e., it does not
work on the whole buffer). Is there a smarter way to see if a region
is currently active?

Thanks,
Luca



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

end of thread, other threads:[~2013-02-01 13:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-22 11:20 creating a function that works for active region or whole buffer Luca Ferrari
2013-01-22 14:37 ` Mark Skilbeck
2013-01-22 16:01 ` Le Wang
2013-01-22 17:18   ` Ludwig, Mark
     [not found]   ` <mailman.18089.1358876370.855.help-gnu-emacs@gnu.org>
2013-01-22 19:57     ` Barry Margolin
2013-01-23  7:41       ` Luca Ferrari
2013-01-23  7:43         ` Luca Ferrari
2013-01-28 14:02           ` Stefan Monnier
2013-02-01 10:36             ` Luca Ferrari
2013-02-01 13:55               ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).