From: Sam Steingold <sds@gnu.org>
To: emacs-devel@gnu.org
Subject: (interactive "r") and (use-region-p)
Date: Thu, 16 Mar 2017 13:20:30 -0400 [thread overview]
Message-ID: <lzh92t16ld.fsf@gnu.org> (raw)
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.
next reply other threads:[~2017-03-16 17:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-16 17:20 Sam Steingold [this message]
2017-03-16 18:31 ` (interactive "r") and (use-region-p) 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lzh92t16ld.fsf@gnu.org \
--to=sds@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).