all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@online.de>
To: Noam Postavsky <npostavs@users.sourceforge.net>
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: Sat, 18 Mar 2017 18:40:29 +0100	[thread overview]
Message-ID: <f8839b52-413b-2048-cbbc-c9e58c0d2c2a@online.de> (raw)
In-Reply-To: <CAM-tV--on7i_crDbdFm3pZ7eWQrYVyE06ZrGpLYXqU---cjJ8g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]



On 17.03.2017 14:05, Noam Postavsky wrote:
> 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)))

Okay, thanks. So that's no occasion to question the use-region-p, 
region-active-p design.
For the case given, think the error is reasonable, as a command 
explicitly working on region might expect an existing one.




[-- Attachment #2: Type: text/html, Size: 1926 bytes --]

  reply	other threads:[~2017-03-18 17:40 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
2017-03-18 17:40       ` Andreas Röhler [this message]
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=f8839b52-413b-2048-cbbc-c9e58c0d2c2a@online.de \
    --to=andreas.roehler@online.de \
    --cc=emacs-devel@gnu.org \
    --cc=i.lohmar@gmail.com \
    --cc=npostavs@users.sourceforge.net \
    --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.