[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DWIM region (was: Re: count regexp hits)
From: |
Marcin Borkowski |
Subject: |
Re: DWIM region (was: Re: count regexp hits) |
Date: |
Sun, 07 Jan 2018 06:32:07 +0100 |
User-agent: |
mu4e 0.9.19; emacs 27.0.50 |
On 2018-01-04, at 22:32, Emanuel Berg <moasen@zoho.com> wrote:
> BTW this method on acting on the region (if
> any) I have found very useful and it has
> recurred many times in my code:
>
> (defun count-regexp-hits (regexp)
> (interactive "sregexp: ")
> (let*((region (if mark-active
> `(,(region-beginning) ,(region-end))
> `(,(point-min) ,(point-max)) ))
> (start (car region))
> (end (cadr region)) )
> (count-matches regexp start end t) ))
>
> Is it the canonical way of doing it as well?
Why not use (use-region-p) instead of mark-active?
Also, spacing is kind of strange.
Hth,
--
Marcin Borkowski
- Re: DWIM region, (continued)
- Re: DWIM region, Emanuel Berg, 2018/01/06
- Re: DWIM region, Stefan Monnier, 2018/01/08
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/08
- Re: DWIM region, Stefan Monnier, 2018/01/08
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/08
- Re: DWIM region, Stefan Monnier, 2018/01/09
- Re: DWIM region, Stefan Monnier, 2018/01/08
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/08
- Re: DWIM region, Stefan Monnier, 2018/01/08
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/04
- Re: DWIM region (was: Re: count regexp hits),
Marcin Borkowski <=
- Message not available
- Re: DWIM region (was: Re: count regexp hits), Emanuel Berg, 2018/01/07
- Re: DWIM region (was: Re: count regexp hits), Marcin Borkowski, 2018/01/07
- Message not available
- Re: DWIM region (was: Re: count regexp hits), Emanuel Berg, 2018/01/07
- Re: DWIM region (was: Re: count regexp hits), Marcin Borkowski, 2018/01/09
- Re: DWIM region, Stefan Monnier, 2018/01/09
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/09
- Message not available
- Re: DWIM region (was: Re: count regexp hits), Emanuel Berg, 2018/01/09