all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: DWIM interface (was: Re: Select/highlight and *copy* matches of some regex)
Date: Tue, 28 Jun 2022 01:11:04 +0200	[thread overview]
Message-ID: <87r139g0s7.fsf_-_@dataswamp.org> (raw)
In-Reply-To: 87bkudhgq2.fsf@dataswamp.org

> Either use the region or consider that an interactive
> feature only and set 'beg' and 'end' to the default
> `point-min' and `point-max'?

Or `point' (not `point-min'), that's another thing to think
about ... but that maybe depends on the particular function,
or more so at least, what to do from Lisp with no supplied
boundaries _but_ a region, if you have a good answer to that
I think it would hold for all such functions ...

Here, compare ... ?

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/dwim.el

(defun test-dwim (&optional beg end)
  (interactive (when (use-region-p)
                 (list (region-beginning) (region-end)) ))
  (or beg (setq beg (point-min))) ; or (point)
  (or end (setq end (point-max)))
  ;; insert code here
  ;; now let's just make a list to do something
  (list beg end) )

(defun test-dwim-2 (&optional beg end)
  (interactive (when (use-region-p)
                 (list (region-beginning) (region-end)) ))
  (or beg (setq beg (if (use-region-p) (region-beginning) (point-min))))
  (or end (setq end (if (use-region-p) (region-end)       (point-max))))
  (list beg end) )

-- 
underground experts united
https://dataswamp.org/~incal




  reply	other threads:[~2022-06-27 23:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27 15:52 Select/highlight and *copy* matches of some regex Joost
2022-06-27 16:12 ` tomas
2022-06-27 17:16   ` Joost
2022-06-27 17:44     ` tomas
2022-06-28  4:40     ` Visuwesh
2022-06-28 19:52       ` Emanuel Berg
2022-06-29 21:40       ` Joost Kremers
2022-06-30  6:05         ` Emanuel Berg
2022-06-28  9:29     ` Daniel Martín
2022-06-28 10:33       ` tomas
2022-06-27 20:56 ` Stephen Berman
2022-06-27 21:09   ` Joost Kremers
2022-06-27 22:26     ` Emanuel Berg
2022-06-27 22:29     ` Emanuel Berg
2022-06-27 22:41       ` Emanuel Berg
2022-06-27 23:11         ` Emanuel Berg [this message]
2022-06-27 22:44       ` Emanuel Berg
2022-06-28  4:43         ` tomas
2022-06-28  5:37           ` Emanuel Berg
2022-06-28  4:42   ` tomas

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=87r139g0s7.fsf_-_@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=help-gnu-emacs@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.