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

allow JULIA_EDITOR to specify how to pass file and line to an editor #2594

Closed
wlbksy opened this issue Mar 18, 2013 · 10 comments
Closed

allow JULIA_EDITOR to specify how to pass file and line to an editor #2594

wlbksy opened this issue Mar 18, 2013 · 10 comments
Labels
REPL Julia's REPL (Read Eval Print Loop) system:windows Affects only Windows

Comments

@wlbksy
Copy link
Contributor

wlbksy commented Mar 18, 2013

  • file2 in function edit(file::String, line::Integer) need modification

should be file2 = "$JULIA_HOME/../share/julia/base/$file"

However, files in base/linalg/ and base/pkg/ cannot be tracked even under this modification.

Should figure out a new way to track all the "*.jl" files.

  • On Windows, if user set JULIA_EDITOR something different from start or notepad, this function would never deal with it.
    Should add some branch to enable some editors with specific command line syntax , i.e. "notepad++" : "<bla~bla~bla~>/notepad++ $file -n$line"
@quinnj
Copy link
Member

quinnj commented Jun 3, 2014

@wlbksy, what else needs to be done here? Once #7108 gets merged, edit works as expected, as far as I can tell (i.e. can open base/pkg files, other base files, package directory files, etc.). You can also change ENV["JULIA_EDITOR"] and it should still work as expected (as long as you set a valid editor).

@wlbksy
Copy link
Contributor Author

wlbksy commented Jun 4, 2014

@quinnj This is somehow a little different from the command start. I was telling that we need think out a way to convey "editor", "filename", "parameter", "line number" in any order that a specific editor needed to open at that line with this editor

@quinnj
Copy link
Member

quinnj commented Jun 4, 2014

Hmmmm......I'm still not quite sure what you're after. Can you give a more concrete example (i.e. the actual command) that you'd like to run? It seems like this may be a good candidate that a few of us could help you write and then whoever wants can stick it in their .juliarc.jl, because I'm not sure this has enough use to be in Base.

@wlbksy
Copy link
Contributor Author

wlbksy commented Jun 4, 2014

It's in the top post
"path2notepad++/notepad++ $file -n$line"

@wlbksy wlbksy closed this as completed Jun 4, 2014
@JeffBezanson
Copy link
Member

The issue is that we only know how to pass a line number to a fixed set of editors. The request is to be able to specify a command template that tells us where to pass the line number, so that this feature works with custom JULIA_EDITOR settings.

@JeffBezanson JeffBezanson reopened this Jun 4, 2014
@quinnj
Copy link
Member

quinnj commented Jun 4, 2014

The other thing I was just about ot make a PR for was adding in a case for notepad++ to the edit function (since we special case sublime, textmate, anyway and notepad++ is pretty big). It would be a few lines fix to support @wlbksy command out of the box.

@mgkuhn
Copy link
Contributor

mgkuhn commented Dec 11, 2020

I've tried to look for some existing practice of specifying in an environment variable not only the path to another application (e.g., editor, pager, web browser, file explorer) to invoke, but also an entire shell command, including options argument syntax. I couldn't find much so far:

man --html or man -H on Debian/Ubuntu use the following environment variable:

       BROWSER
              If  $BROWSER is set, its value is a colon-delimited list of com‐
              mands, each of which in turn is used  to  try  to  start  a  web
              browser  for  man  --html.  In each command, %s is replaced by a
              filename containing the HTML output from groff, %%  is  replaced
              by a single percent sign (%), and %c is replaced by a colon (:).

less has in addition to EDITOR also a LESSEDIT variable to specify a prototype command string:

       The prompt expansion features are also used for another purpose: if  an
       environment  variable LESSEDIT is defined, it is used as the command to
       be executed when the v command is invoked.  The LESSEDIT string is  ex‐
       panded  in  the  same way as the prompt strings.  The default value for
       LESSEDIT is:

            %E ?lm+%lm. %g

       Note that this expands to the editor name, followed by a + and the line
       number,  followed  by the shell-escaped file name.  If your editor does
       not accept the "+linenumber" syntax, or has other differences in  invo‐
       cation  syntax, the LESSEDIT variable can be changed to modify this de‐
       fault.

In the case of starting an editor, there is also the question of how to express what to do in case no line number (or column number) is specified, whether lines or columns start at 0 or 1, etc.

@mgkuhn
Copy link
Contributor

mgkuhn commented Dec 11, 2020

A simple alternative to the Julia user specifying in an environment variable how to pass a line (and column) number on to the application $JULIA_EDITOR is to simply cause Julia to set two environment variables (e.g., LINE and COLUMN) when calling $JULIA_EDITOR. This way, $JULIA_EDITOR can be pointed by the user at a simple shell-script wrapper that does convert such **env parameters into the **argv syntax required by the desired editor.

The advantage of doing this via environment variables (as opposed to command-line arguments) is that applications ignore environment variables unknown to them.

@fredrikekre
Copy link
Member

xref https://docs.julialang.org/en/v1/stdlib/InteractiveUtils/#InteractiveUtils.define_editor which might be enough to close this?

@StefanKarpinski
Copy link
Member

Indeed: the set of editors that work can be extended using define_editor to handle the case when JULIA_EDITOR is set to notepad++. If someone wants to add that definition to the set of defaults, that could be done as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop) system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests

7 participants