[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35536: 27.0.50; Expose buffer's marker list to Elisp
From: |
Stefan Monnier |
Subject: |
bug#35536: 27.0.50; Expose buffer's marker list to Elisp |
Date: |
Thu, 02 May 2019 15:59:38 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> I attach a patch implementing this based on BUF_MARKERS, as per Martin's
> suggestion. Any reasons not to expose such a function?
AFAIK the main reason for such a function is so that you can implement
"replace" functions which preserves markers better than "insert+delete"
does, right? Arguably `replace-buffer-contents` reduced this need, but
this is just one way to "guess" how to preserve the markers and for
specific replacements there are surely other approaches which would
work better, hence the desire to get access to the marker-list to write
ad-hoc solutions.
Random thoughts:
- I wouldn't expose a `(marker-list)` function but rather `(markers-in
BEG END)` so you're not bothered by unrelated markers outside of
the region of interest.
- The main problem I see is that some of the markers in BUF_MARKERS are
"proper" markers, while others are just the markers that we happen to
use in the current internal representation of overlays.
If you can get your hands on those markers, you might end up breaking
some invariants on which the C code relies (e.g. place the
overlay-start after the overlay-end, or in a different buffer).
- I think the serious risks (e.g. crashes) are solvable. E.g. there's
room for an additional boolean field `lisp_marker` which could be used
to distinguish those markers which can be safely returned (because
they're normal Lisp-level markers already accessible from Lisp anyway)
from the internal ones (such as those from overlays).
- Then we'd probably want to discussion whether markers used within
`save-excursion` and friends should be marked as `lisp_marker` or not.
This said, as you say later:
> I have yet to see a use-case for marker-list which can't be engineered
> in a different way
So, whether it's worth the trouble: I don't know.
Stefan
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, (continued)
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, Drew Adams, 2019/05/03
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, Basil L. Contovounesios, 2019/05/03
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, Drew Adams, 2019/05/03
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, Stefan Monnier, 2019/05/03
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, Drew Adams, 2019/05/03
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, Stefan Monnier, 2019/05/03
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, Drew Adams, 2019/05/03
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, Richard Stallman, 2019/05/04
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, Mauro Aranda, 2019/05/03
- bug#35536: 27.0.50; Expose buffer's marker list to Elisp, martin rudalics, 2019/05/04
bug#35536: 27.0.50; Expose buffer's marker list to Elisp,
Stefan Monnier <=