On 17.03.2017 14:05, Noam Postavsky wrote: > On Fri, Mar 17, 2017 at 4:16 AM, Andreas Röhler > 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.