help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: [External] : interactive to do `use-region-p'


From: Drew Adams
Subject: RE: [External] : interactive to do `use-region-p'
Date: Sun, 6 Nov 2022 15:41:08 +0000

> 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 via email to

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