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

Consider terminal emacs in EDITOR_CALLBACKS before graphical #36346

Merged
merged 1 commit into from
Jun 18, 2020

Conversation

non-Jedi
Copy link
Contributor

Since the regex r"\bemacs" matches the cmd emacs -nw, the regex
r"\bemacs\b.*\s(-nw|--no-window-system)\b" should be considered in the
EDITOR_CALLBACKS list before it.

Without this change, when JULIA_EDITOR="emacs -nw", julia tries to
open the editor with run(...; wait=false) which causes the error:

emacs: standard input is not a tty

or for emacsclient:

emacsclient: could not get terminal name
emacsclient: error executing alternate editor ""

cc @rfourquet

Since the regex r"\bemacs" matches the cmd `emacs -nw`, the regex
r"\bemacs\b.*\s(-nw|--no-window-system)\b" should be considered in the
EDITOR_CALLBACKS list before it.

Without this change, when JULIA_EDITOR="emacs -nw", julia tries to
open the editor with run(...; wait=false) which causes the error:

emacs: standard input is not a tty

or for emacsclient:

emacsclient: could not get terminal name
emacsclient: error executing alternate editor ""
@rfourquet rfourquet added the bugfix This change fixes an existing bug label Jun 18, 2020
@@ -113,15 +114,16 @@ function define_default_editors()
define_editor(r".*") do cmd, path, line
`$cmd $path`
end
define_editor([r"\bemacs", "gedit", r"\bgvim"]) do cmd, path, line
Copy link
Member

@rfourquet rfourquet Jun 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, changing r"\bemacs" to r"\bemacs\b" would also work as a fix, right?
EDIT: yeah, my experiments seem to indicate that this also work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That still matches emacs -nw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we changed this to r"\bemacs\b", then graphical emacsclient would no longer be matched, so it would end up being caught by the fallback r".*" regex which doesn't jump to line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, thank you both.

@Keno Keno merged commit 6385107 into JuliaLang:master Jun 18, 2020
@rfourquet
Copy link
Member

For people seeing this issue and wanting a fix for Julia 1.4 and 1.5, you can put the following in startup.jl:

using InteractiveUtils
InteractiveUtils.define_editor([
    "vim", "vi", "nvim", "mvim", "nano",
    r"\bemacs\b.*\s(-nw|--no-window-system)\b",
    r"\bemacsclient\b.\s*-(-?nw|t|-?tty)\b"], wait=true) do cmd, path, line
        `$cmd +$line $path`
    end

(this is copy-pasted and could be simplified but I didn't bother).

simeonschaub pushed a commit to simeonschaub/julia that referenced this pull request Jun 28, 2020
…ng#36346)

Since the regex r"\bemacs" matches the cmd `emacs -nw`, the regex
r"\bemacs\b.*\s(-nw|--no-window-system)\b" should be considered in the
EDITOR_CALLBACKS list before it.

Without this change, when JULIA_EDITOR="emacs -nw", julia tries to
open the editor with run(...; wait=false) which causes the error:

emacs: standard input is not a tty

or for emacsclient:

emacsclient: could not get terminal name
emacsclient: error executing alternate editor ""
rfourquet pushed a commit that referenced this pull request Jul 26, 2020
Since the regex r"\bemacs" matches the cmd `emacs -nw`, the regex
r"\bemacs\b.*\s(-nw|--no-window-system)\b" should be considered in the
EDITOR_CALLBACKS list before it.

Without this change, when JULIA_EDITOR="emacs -nw", julia tries to
open the editor with run(...; wait=false) which causes the error:

emacs: standard input is not a tty

or for emacsclient:

emacsclient: could not get terminal name
emacsclient: error executing alternate editor ""
(cherry picked from commit 6385107)
simeonschaub pushed a commit to simeonschaub/julia that referenced this pull request Aug 11, 2020
…ng#36346)

Since the regex r"\bemacs" matches the cmd `emacs -nw`, the regex
r"\bemacs\b.*\s(-nw|--no-window-system)\b" should be considered in the
EDITOR_CALLBACKS list before it.

Without this change, when JULIA_EDITOR="emacs -nw", julia tries to
open the editor with run(...; wait=false) which causes the error:

emacs: standard input is not a tty

or for emacsclient:

emacsclient: could not get terminal name
emacsclient: error executing alternate editor ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants