[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(interactive "r") and (use-region-p)

From: Sam Steingold
Subject: (interactive "r") and (use-region-p)
Date: Thu, 16 Mar 2017 13:20:30 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (darwin)


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


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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]