Closed oantolin closed 3 months ago
I don't remember exactly, but I think this used to work, and then we changed the way stripping tofus worked and didn't notice that affected consult-global-mark
export.
consult--global-mark-candidates
should probably use the consult--location-candidate
for uniformity with other -candidates
functions that produce candidates with category consult-location
.
Thanks for the quick fix. I was about to propose a different fix using consult--location-candidate
, but as usual you beat me to the punch. :)
I don't think we can use consult--location-candidate since it is too limited.
I meant concatenating it with the prefix as follows:
diff --git a/consult.el b/consult.el
index 1e69e5c..f3f470b 100644
--- a/consult.el
+++ b/consult.el
@@ -3236,12 +3236,15 @@ The symbol at point is added to the future history."
(when (consult--in-range-p pos)
(goto-char pos)
;; `line-number-at-pos' is slow, see comment in `consult--mark-candidates'.
- (let* ((line (line-number-at-pos pos consult-line-numbers-widen))
- (prefix (consult--format-file-line-match (buffer-name buf) line ""))
- (cand (concat prefix (consult--line-with-mark marker) (consult--tofu-encode marker))))
- (put-text-property 0 (length prefix) 'consult-strip t cand)
- (put-text-property 0 (length cand) 'consult-location (cons marker line) cand)
- (push cand candidates))))))))
+ (let ((line (line-number-at-pos pos consult-line-numbers-widen)))
+ (push (concat
+ (propertize
+ (consult--format-file-line-match (buffer-name buf) line "")
+ 'consult-location (cons marker line)
+ 'consult-strip t)
+ (consult--location-candidate
+ (consult--line-with-mark marker) marker line marker))
+ candidates))))))))
(unless candidates
(user-error "No global marks"))
(nreverse (delete-dups candidates))))
But I don't really think that's very different from what you did.
Omar Antolín Camarena @.***> writes:
I meant concatenating it with the prefix as follows:
Alright. This would work, but would be slightly less efficient. Not that it matters for consult-global-mark.
I just noticed that
embark-export
doesn't work withconsult-global-mark
, while it does work withconsult-mark
. I think the difference is thatconsult--mark-candidates
andconsult--global-mark-candidates
store theconsult-location
property in different places:consult--mark-candidates
puts it on the first character of the line, andconsult--global-mark-candidates
puts it in the file and line number prefix, which is also markedconsult-strip t
. Sinceembark-export
uses the transformed candidates, the consult-locations are stripped by the timeembark-consult-occur-export
sees them.Do you think you could put the
consult-location
property on the first character of the line instead?