restclient.el icon indicating copy to clipboard operation
restclient.el copied to clipboard

Add imenu support

Open colonelpanic8 opened this issue 8 years ago • 14 comments

This is sort of WIP. I think that everything works properly, but the code feels a little messy to me.

colonelpanic8 avatar Jul 14 '15 11:07 colonelpanic8

Closes #65

colonelpanic8 avatar Jul 14 '15 11:07 colonelpanic8

Thanks! I'm not dead, just a bit busy at the moment :) I'll review and merge this as soon as I get to proper computer.

pashky avatar Jul 29 '15 14:07 pashky

@pashky good to heal you are still kicking... thanks

colonelpanic8 avatar Jul 29 '15 17:07 colonelpanic8

Ok, so how does one use it? I've never used imenu myself unfortunately, so not familiar with it. I tried calling M-x imenu and got user-error: This buffer cannot use `imenu-default-create-index-function'

What's the purpose of restclient-goto-current-min and splitting restclient-http-parse-current-and-do into two?

pashky avatar Aug 17 '15 10:08 pashky

you tried calling imenu?

Ok, so how does one use it? I've never used imenu myself unfortunately, so not familiar with it. I tried calling M-x imenu and got user-error: This buffer cannot use `imenu-default-create-index-function'

Yeah, you aren't using the imenu functions from this pull request. I think I forgot the line:

(set (make-local-variable 'imenu-create-index-function) #'restclient-create-imenu-index)

which i have in my local copy. Sorry about that. As I mentioned this was sort of WIP. Its in a good working state now though, so ill fix it an update.

What's the purpose of restclient-goto-current-min

I thought it might be useful. Can remove if you don't want it.

splitting restclient-http-parse-current-and-do into two?

Single responsibility principle thing. Originally I was using restclient-http-parse-current to get imenu titles, but then it became clear that that would be far too slow. Still generally think its a good refactor that could be useful to others that want to extend restclient.

colonelpanic8 avatar Aug 18 '15 19:08 colonelpanic8

Ping?

colonelpanic8 avatar Nov 18 '15 08:11 colonelpanic8

I've reviewed your change.

  1. I get compile time warnings

    In restclient-create-imenu-index:
    restclient.el:397:8:Warning: `beginning-of-buffer' is for interactive use
    only; use `(goto-char (point-min))' instead.
    restclient.el:410:38:Warning: assignment to free variable `marker'
    restclient.el:410:27:Warning: reference to free variable `marker'
    
  2. There is debug (message ...) left in code.

  3. Change to (restclient-jump-prev) is unnecessary as it makes it jump to beginning of current request if cursor is before that point. This shouldn't happen, it should just stay where it is if there's nowhere to jump.

  4. Unused (restclient-goto-current-min) is still there.

  5. And it's still not working for me. I'm getting.

restclient-create-imenu-index: Not enough arguments for format string

if I do M-x imenu on sample httpbin file.

pashky avatar Nov 18 '15 23:11 pashky

I get compile time warnings

Fixed

There is debug (message ...) left in code.

Fixed

Change to (restclient-jump-prev) is unnecessary as it makes it jump to beginning of current request if cursor is before that point. This shouldn't happen, it should just stay where it is if there's nowhere to jump.

This was deliberate -- without this change there isn't consistency about where you jump to when navigating between requests. Seems like its better to always go to the uri line when you do a jump forward or backwards. I changed it back for you, but I don't understand why this behavior is preferred

Unused (restclient-goto-current-min) is still there. And it's still not working for me. I'm getting. restclient-create-imenu-index: Not enough arguments for format string if I do M-x imenu on sample httpbin file.

an httpbin file? this is imenu for restclient. I'm assuming you have restclient mode enabled?

Can you M-x toggle-debug-on-errror and give me a stack trace for this

colonelpanic8 avatar Nov 20 '15 02:11 colonelpanic8

ping

colonelpanic8 avatar Jan 05 '16 19:01 colonelpanic8

This would be awesome to have. I absolutely love imenu (particularly helm-imenu, you should try it!).

blaenk avatar Jul 20 '16 22:07 blaenk

I'm happy to deal with merge conflicts if @pashky will agree to merge this.

I really think that imenu is a better option than direct helm support

colonelpanic8 avatar Jul 20 '16 23:07 colonelpanic8

@IvanMalison Do you have some code in your .init I can copy to make this work? Or a fork of restclient I can use?

I was about to write this myself, but realized it was more work than I have time for right now and a google led me here ;)

expez avatar Dec 15 '17 10:12 expez

@expez Just use this pull request? I believe its in my fork... https://github.com/IvanMalison/restclient.el

colonelpanic8 avatar Dec 15 '17 13:12 colonelpanic8

@pashky @IvanMalison not sure what is status of this PR, but this simple line can also provide imenu support:

(require 'imenu)
(setq imenu-generic-expression '((nil "^[A-Z]+\s+.+" 0)))

Nothing fancy, just will display things like GET.http://www.httpbin.org and contains request + url to be jumped to.

sanel avatar Feb 11 '19 14:02 sanel