[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
DWIM interface (was: Re: Select/highlight and *copy* matches of some reg
From: |
Emanuel Berg |
Subject: |
DWIM interface (was: Re: Select/highlight and *copy* matches of some regex) |
Date: |
Tue, 28 Jun 2022 01:11:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
> 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
Re: Select/highlight and *copy* matches of some regex, tomas, 2022/06/28