all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Emanuel Berg <incal@dataswamp.org>,
	"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : interactive to do `use-region-p'
Date: Sun, 6 Nov 2022 15:41:08 +0000	[thread overview]
Message-ID: <SJ0PR10MB548864CAB669766DFEA9A7BBF33D9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87o7tkci2t.fsf@dataswamp.org>

> This is a common situation (the first three lines of the code
> below) and possible area of integration, because there is
> already a lowercase "r" you can send to `interactive', however
> that doesn't do `use-region-p', maybe we could have an
> uppercase "R" that sent (nil nil) unless use-region-p, and
> otherwise behaved like "r", i.e. sent the region to beg
> and end?

`M-x report-emacs-bug' is also for enhancement requests.
___

But instead of (nil nil) you might prefer
`(,(point-min) ,(point-max)).  This use case:

(interactive
  (let* ((regp (use-region-p))
         (st   (if regp (region-beginning) (point-min)))
         (en   (if regp (region-end) (point-max))))
    (list st en)))

And then there are the cases where you want to
ignore the value of `use-empty-active-region'
(i.e., use `region-active-p' instead of
`use-region-p').

`interactive' with string arg is OK, but often
isn't TRT.  It can sometimes be clearer to just
define a function that does what you want, and
use that with (interactive `(,@(DTRT))).



  reply	other threads:[~2022-11-06 15:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06 13:45 interactive to do `use-region-p' Emanuel Berg
2022-11-06 15:41 ` Drew Adams [this message]
2022-11-06 18:53   ` [External] : " Emanuel Berg
2022-11-07  1:41   ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-11-07  2:29     ` Drew Adams
2022-11-07 12:28       ` Emanuel Berg
2022-11-07 15:51         ` Drew Adams
2022-11-07 17:25           ` Emanuel Berg

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=SJ0PR10MB548864CAB669766DFEA9A7BBF33D9@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=incal@dataswamp.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.