* Asymmetry in next/previous-property-change
@ 2022-07-03 16:50 Juri Linkov
0 siblings, 0 replies; only message in thread
From: Juri Linkov @ 2022-07-03 16:50 UTC (permalink / raw)
To: emacs-devel
In a new buffer eval:
M-: (progn (insert "abc") (add-text-properties 2 3 '(prop t)))
Then while searching in different directions, the result of get-text-property
is different between forward/backward search:
(get-text-property (next-single-property-change (point-min) 'prop) 'prop)
=> t
(get-text-property (previous-single-property-change (point-max) 'prop) 'prop)
=> nil
This is because get-text-property returns the property value of the character
AFTER the given position. But while searching backwards, what is needed is
BEFORE the given position.
Has anybody given any thought to address this inconsistency?
Maybe a new function get-text-property-before could help
while searching backwards simply by using:
(get-text-property-before (point) 'prop)
instead of currently required such ugly code:
(unless (bobp) (get-text-property (1- (point)) 'prop))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-03 16:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-03 16:50 Asymmetry in next/previous-property-change Juri Linkov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).