-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add narrowing to consult-outline #277
Conversation
The local require style is a no-go. We can either require it globally, code the needed functions ourselves or create a separate consult-outline.el in case on wants to preserve lazy loading. Which code is simplified exactly if you require outline? As far as I understand both
Yes, it should be done when generating the candidate list for performance. You can use |
@@ -1935,10 +1935,14 @@ See `multi-occur' for the meaning of the arguments BUFS, REGEXP and NLINES." | |||
(consult--forbid-minibuffer) | |||
(let* ((line (line-number-at-pos (point-min) consult-line-numbers-widen)) | |||
(heading-regexp (concat "^\\(?:" | |||
(if (boundp 'outline-regexp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If outline-regexp
is bound and nil (which shouldn't happen), there will be an error in the ensuing re-search-forward
. So I changed to (or
(bound-and-true-p ...`
consult.el
Outdated
@@ -1950,6 +1954,7 @@ See `multi-occur' for the meaning of the arguments BUFS, REGEXP and NLINES." | |||
'fontify) | |||
(point-marker) line) | |||
candidates) | |||
(put-text-property 0 1 'consult-level (funcall level-function) (car candidates)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for the record, this is a tricky line, because it depends on the match data from the previous re-search-forward
.
Oops, I misread this. If you think it's a one off thing, we can keep as in the current version of the PR, otherwise I'll do as you suggest and add a |
@astoff Yes, I meant add a rest argument to |
Should be good now ;-) |
Thanks! |
Here's a sketch for the narrowing by outline level in
consult-outline
.Some comments:
consult--ouline-level
function too much. It would be easy enough to compute the level when building the candidate list, but then I would have to changeconsult--location-candidate
to allow including this extra datum in each candidate.outline
in the body ofconsult--ouline-level
. If we reimplemented code fromoutline
to avoid requiring it, it wouldn't add that many lines of code. Still, I don't quite see why not(require 'outline)
in the body ofconsult-outline
itself. Thenconsult--outline-candidates
could also be slightly simplified.Level ≤ 1
narrows to the smallest level, but otherwise leave any holes as they are. This also means it's impossible to reach the level of(defun
in consult.el, because those haveoutline-level=16
a.k.a.Level ≤ 13
.