Subject: bug#49842: re-builder restriction to region (lisp/emacs-lisp/re-builder)

From: Karthik Chikmagalur <[email-masked]>
Date: Wed, 04 Aug 2021 13:59:26 -0700

I'm working on a few improvements to re-builder including the above, and need to store some state information (bounds of region, etc) that persists until the re-builder session is closed. I see two ways to do this:

1. With a buffer-local variable in reb-target-buffer, with the assumption that only one re-builder session can be run per buffer.

2. With a lexical closure in the re-builder update code.

I'm not very familiar with elisp best practices, is there a reason to prefer one over the other beyond the direct effect on the re-builder code logic/complexity?

Karthik

Lars Ingebrigtsen <[email-masked]> writes:

> Karthik Chikmagalur <[email-masked]> writes:
>
>> IIRC, the right way to restrict this to the region would be to define
>> a variable to hold the bounds of the region as specified by the user
>> before starting re-builder and re-search-forward inside those
>> bounds. Perhaps a closure that's tied to the specific re-builder
>> session can be used to avoid issues with the value of this variable
>> when running multiple simultaneous re-builder sessions.
>
> I'm not very familiar with re-builder.el myself, but I think that sounds
> like a promising approach.
>
> -- 
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no