Skip to content
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

bind v to open file in $EDITOR #211

Closed
mundry opened this issue Jun 10, 2024 · 4 comments
Closed

bind v to open file in $EDITOR #211

mundry opened this issue Jun 10, 2024 · 4 comments

Comments

@mundry
Copy link

mundry commented Jun 10, 2024

Hi there,

first of all: Great job! I've really been enjoying moar so far.

Something that's ingrained in my muscle memory from less is pressing v to open the current file in $EDITOR.

It would be great to have that same functionality in moar, too.

What do you think?

@walles
Copy link
Owner

walles commented Jun 12, 2024

I want this. It would sort of solve #135 as well.

For reference I tried less's behavior (less 581.2, comes with macOS) and:

  • With $EDITOR set:
    • When showing an actual file, less does /usr/local/bin/fish -c code -w +34 services and waits for that command to finish. Parts are:
      • /usr/local/bin/fish is my shell
      • -c tells the shell to execute a command line
      • code -w is my $EDITOR variable
      • +34 is unknown and messes up the editor. It's not the current line number at least since I'm on the first line in less.
      • services is the file I opened.
    • When piping from stdin, less just says "Cannot edit standard input"
  • With $VISUAL set (and not $EDITOR) less does the same thing, but uses the value of $VISUAL instead.
  • If the editor doesn't exist, nothing happens on v, but error messages are shown after exiting less.

Except for the number I think this makes for a reasonable starting point.

@walles
Copy link
Owner

walles commented Jun 12, 2024

less primarily picks $VISUAL, then falls back to $EDITOR, then to vi (from defines.ds):

https://github.com/gwsw/less/blob/db13e771320d4bfc9d403ee951b623a8c3d5e425/main.c#L331-L342

@walles walles closed this as completed in d911e54 Jun 22, 2024
@walles
Copy link
Owner

walles commented Jun 23, 2024

@mundry please try this out in moar 1.24.0!

walles added a commit that referenced this issue Jun 28, 2024
By writing it to a file and opening the editor on that file.

Related to #211.
@walles
Copy link
Owner

walles commented Jun 28, 2024

FYI, with v1.24.4 this now works when piping input to moar as well.

I know I have wanted that, maybe you do as well :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants