all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

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.