[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Asymmetry in next/previous-property-change
From: |
Juri Linkov |
Subject: |
Asymmetry in next/previous-property-change |
Date: |
Sun, 03 Jul 2022 19:50:29 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) |
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))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Asymmetry in next/previous-property-change,
Juri Linkov <=