all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: "Andreas Röhler" <andreas.roehler@online.de>
Cc: Ingo Lohmar <i.lohmar@gmail.com>, Sam Steingold <sds@gnu.org>,
	Emacs developers <emacs-devel@gnu.org>
Subject: Re: (interactive "r") and (use-region-p)
Date: Fri, 17 Mar 2017 09:05:36 -0400	[thread overview]
Message-ID: <CAM-tV--on7i_crDbdFm3pZ7eWQrYVyE06ZrGpLYXqU---cjJ8g@mail.gmail.com> (raw)
In-Reply-To: <75ca08aa-f9b1-4407-c150-c96f738e268c@online.de>

On Fri, Mar 17, 2017 at 4:16 AM, Andreas Röhler
<andreas.roehler@online.de> wrote:
>>> --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---
>> AFAIK, you cannot use the (interactive "r") form for this "dwim-ish"
>> kind of behavior.
>
> Why that? If a region is set, why should (use-region-p) fail?

(use-region-p) doesn't fail, the "r" in interactive fails, when there
is no mark (i.e., when a region is not and has never been set). It's
basically equivalent to this:

(defun my-command (beg end)
  (interactive (sort (list (point) (mark)) #'<))
  (if (use-region-p)
      (my-command-region beg end)
    (my-command-non-region)))



  reply	other threads:[~2017-03-17 13:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM-tV--on7i_crDbdFm3pZ7eWQrYVyE06ZrGpLYXqU---cjJ8g@mail.gmail.com \
    --to=npostavs@users.sourceforge.net \
    --cc=andreas.roehler@online.de \
    --cc=emacs-devel@gnu.org \
    --cc=i.lohmar@gmail.com \
    --cc=sds@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 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.