Closed zaeph closed 4 years ago
Interesting. What's the advantage of cloning the buffer?
Interesting. What's the advantage of cloning the buffer?
lispy-goto-symbol
always finds the definition of the symbol in a real buffer. If you've narrowed the buffer and want to visit a symbol that is in the same file, but outside of the current restriction, the restriction will not be removed. This is especially bad when you're trying to find out which nested function is causing a problem, since you constantly have to go back and forth between the different levels of nesting.
I've found cloning-and-narrowing to be a good solution to that problem.
Could we instead have lispy-goto-symbol
respect the current narrowing?
Could we instead have
lispy-goto-symbol
respect the current narrowing? [emphasis added]
What do you mean by this? I see two ways to understand it:
def
(or potentially to anything else), then narrow to def
after lispy-goto-symbol
, narrow.Now, we could widen after lispy-goto-symbol
, which I think would fit with the intention of users when running the command. Howeber, that does not address the workflow I've described above, since we'd still be in the main file-visiting buffer rather than an indirect clone.
OK. So you want to be able to use lispy-goto-symbol
, but you don't want to be able to go back to your current narrowing.
Then we could do this:
lispy-goto-symbol
) removes the narrowinglispy-back
) can restore the point position and the narrowing after lispy-goto-symbol
This way, all users gain the potential benefit, without adding a new command. Would this work for you?
Would this work for you?
It would be absolutely wonderful. Hadn't thought of using a history, thanks!
I have some experience with making a history of narrowing, and reverting to those. Generally, a local-variable to which you push
and pop
is enough.
Would you like me to take care of it?
Would you like me to take care of it?
Would be great. Thanks in advance.
I'll schedule this for next week, then.
PR is ready.
g
(lispy-goto-symbol
) removes the narrowing
b
(lispy-back
) can restore the point position and the narrowing afterlispy-goto-symbol
[emphasis added]
I've implemented both behaviours. I was iffy on the bold part because my first implementation wasn't robust, but reworking it convinced me that it was useful.
I've made the behaviour toggleable with lispy-back-restore-restriction
(default to t
).
Thanks, the code looks good. Some comments:
lispy-goto
and lispy-goto-local
should work on the whole buffer, even if it's narrowed.pcase-let*
. Maybe use cl-destructuring-bind
or a simple let*
instead?Sure, I'm going to address your comments now.
- I'm not sure about which Emacs version supports
pcase-let*
. Maybe usecl-destructuring-bind
or a simplelet*
instead?
Addressed in 1fbc1b6b2f745d9bea95cd82ed78309ea3a967c4.
- I think
lispy-goto
andlispy-goto-local
should work on the whole buffer, even if it's narrowed.
I'm not sure if I understand. I've only touched lispy-goto-symbol
which I access with the M-.
. Does that mean you'd want me to patch lispy-goto
and lispy-goto-local
similarly to what I've done with lispy-goto-symbol
?
Thanks, I see now. I think it's fine to merge then. lispy-goto
working on a narrowed buffer can be a separate issue.
I'll try to play around with lispy-goto
on my end to see if there's a need for it, and I'll open a PR if I feel it's a good idea. Thanks for the merge!
Hi there,
When I'm investigating a function, I like to narrow the buffer to it to make it easier to focus on it. However, when I'm in an
edebug
session, I find it easier to clone the buffer, and narrow to that function in that cloned buffer. It makes it easier to visit other functions in the file.lispy-isolate
is a proof-of-concept that does just that. The name's not great, but before going forward, I'd prefer to make sure that you haven't already implemented something similar. If not, I'd be willing to write something a little more fleshed out.