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

Can't pass command line arguments with spaces to editor #491

Closed
tleish opened this issue Jul 25, 2017 · 11 comments
Closed

Can't pass command line arguments with spaces to editor #491

tleish opened this issue Jul 25, 2017 · 11 comments
Labels
bug Something isn't working 📌 This can't go stale

Comments

@tleish
Copy link

tleish commented Jul 25, 2017

The following command starts macvim, opens the journal file with a pre-vimrc that sets the syntax to Markdown

$ macvim -f -c 'setf markdown' ~/Dropbox/Journal/2017.md'

However, when I used this same command in the .jrnl_config I get an error:

.jrnl_config

{
  "editor": "macvim -f -c 'setf markdown'",
}

Error

$ jrnl -1 --edit
Error detected while processing pre-vimrc command line:
E20: Mark not set
Press ENTER or type command to continue

Any suggestions on how to fix this?

@wadegbow
Copy link

wadegbow commented Nov 6, 2017

Pretty sure it's happening because the command just get's split by any whitespace, including the stuff in single quotes.

https://github.com/maebert/jrnl/blob/master/jrnl/util.py#L133

Not sure of an elegant way to fix this by changing your editor value. Might try making a branch using shlex split, because it keeps the stuff in single quotes intact.

For anyone wondering, the reason this would be cool is so that you can journal with vim and have vim-pencil and goyo start automatically.

@cecep2
Copy link

cecep2 commented Nov 27, 2017

I solved this by adding a simple function to my .vimrc which sets the desired defaults for the jrnl app:

function! JrnlSettings()
    set ft=pandoc
    Goyo
endfunction
command! JrnlSettings call JrnlSettings()

In my case it turns on vim-pandoc for Markdown editing and Goyo for distraction-free writing. Then in your .jrnl_config you use this:

{
  "editor": "macvim -f -c JrnlSettings",
}

@dankozlowski
Copy link

@cecep2 We should totally get this in to the docs!

@stale
Copy link

stale bot commented Jul 7, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 7, 2019
@BenKettlewell
Copy link

I'm trying to solve a similar issue. I renamed the journals from .txt to .md and updated the .jrnl_config to point to the new path. I can edit them directly with vim /path/to/journal.md and my vim highlighting plugin works fine. The problem is if I use jrnl @tag --edit it still assumes it's text.
A temporary workaround is to set the file type manually in vim with :set ft=markdown but having to do this every time I open it is a drag.

@gregorybodnar
Copy link
Contributor

I think the problem that the OP was seeing is vim interpreting the single quote as a jump-to-mark. The error is correctly indicating that there is no mark for s. But I'm baffled as to why it would happen when called from jrnl but not when called on the command line.

@BenKettlewell You should be able to automatically call :set ft=markdown on a matched path. Check the file pattern that is used when jrnl creates the temp file. I'm getting something like /tmp/jrnlXXXXXXXX.txt. So you might get by with autocmd BufRead /tmp/jrnl*.txt set ft=markdown in your .vimrc.

@BenKettlewell
Copy link

autocmd BufRead /tmp/jrnl*.txt set ft=markdown

@gregorybodnar , you sir have my sincerest thanks 💯 That worked a dream.

@gregorybodnar
Copy link
Contributor

Happy to help. I'm tempted to work out some syntax highlighting for time and tags as well.

@wren wren added bug Something isn't working and removed stale labels Jul 20, 2019
@wren
Copy link
Member

wren commented Jul 20, 2019

@gregorybodnar Syntax highlighting would be fantastic!

I think we need to rework how the editor command is executed, so that arguments are passed properly to all editors.

PRs welcome!

@stale
Copy link

stale bot commented Sep 18, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Inactive issue: will be closed soon if no activity label Sep 18, 2019
@wren wren added the 📌 This can't go stale label Sep 21, 2019
@stale stale bot removed the stale Inactive issue: will be closed soon if no activity label Sep 21, 2019
@wren wren changed the title pre-vimrc commands Can't pass command line arguments with spaces to editor Sep 21, 2019
@wren wren added this to the v2.2 - Users? In my config? milestone Sep 21, 2019
@dbxnr dbxnr mentioned this issue Jan 24, 2020
@micahellison
Copy link
Member

This is duplicated by #581 but there's more conversation and a potential fix there so I'm closing this one.

@micahellison micahellison removed this from the v2.2 milestone May 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📌 This can't go stale
Projects
None yet
Development

No branches or pull requests

8 participants