all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* (interactive "r") and (use-region-p)
@ 2017-03-16 17:20 Sam Steingold
  2017-03-16 18:31 ` Ingo Lohmar
  2017-03-16 19:07 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Sam Steingold @ 2017-03-16 17:20 UTC (permalink / raw)
  To: emacs-devel

Hi

Is this a valid coding pattern:

--8<---------------cut here---------------start------------->8---
(defun my-command (beg end)
  (interactive "r")
  (if (use-region-p)
      (my-command-region beg end)
    (my-command-non-region)))
--8<---------------cut here---------------end--------------->8---

Alas, it fails with

(error "The mark is not set now, so there is no region")

when the mark is not set, instead of calling `my-command-non-region'.

What is the correct metaphor/pattern?

Maybe we should add "R" interactive code which would pass nil/nil if
`use-region-p' returns nil?

Thanks.

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504
http://steingoldpsychology.com http://www.childpsy.net http://iris.org.il
https://ffii.org http://honestreporting.com http://islamexposedonline.com
If you cannot improve on silence, keep it.




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

end of thread, other threads:[~2017-03-18 17:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-16 17:20 (interactive "r") and (use-region-p) Sam Steingold
2017-03-16 18:31 ` Ingo Lohmar
2017-03-17  8:16   ` Andreas Röhler
2017-03-17 13:05     ` Noam Postavsky
2017-03-18 17:40       ` Andreas Röhler
2017-03-16 19:07 ` 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.