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

capture basedir #90

Closed
ghost opened this issue Jun 20, 2020 · 26 comments · Fixed by #91
Closed

capture basedir #90

ghost opened this issue Jun 20, 2020 · 26 comments · Fixed by #91

Comments

@ghost
Copy link

ghost commented Jun 20, 2020

bash-4.3$ emacs --version
GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
bash-4.3$ julia --version
julia version 1.4.2
bash-4.3$ which julia
/usr/bin/julia
bash-4.3$ tree -L 1 ~/.emacs.d/elpa
/home/eric/.emacs.d/elpa
|-- archives
|-- ess-18.10.2
|-- gnupg
|-- julia-mode-0.4
|-- julia-repl-1.2.0
`-- s-1.12.0

6 directories, 0 files
bash-4.3$ 

M-x julia-repl generates in a *Warnings* buffer the below.

Warning (emacs): could not capture basedir for Julia executable julia

@tpapp
Copy link
Owner

tpapp commented Jun 20, 2020

Is the REPL working for you otherwise?

@ghost
Copy link
Author

ghost commented Jun 20, 2020

Is the REPL working for you otherwise?

Yes.

I haven't spent a lot of hours in it yet.

@tpapp
Copy link
Owner

tpapp commented Jun 20, 2020

Can you please evaluate

print("OK" * normpath(joinpath(VERSION  v"0.7-" ? JULIA_HOME : Sys.BINDIR, Base.DATAROOTDIR, "julia", "base")))
  1. in the REPL (inside Emacs), and
  2. julia started from the command line,

and post the results for both here?

@ghost
Copy link
Author

ghost commented Jun 20, 2020

The *Warnings* buffer doesn't open in uxterm Emacs, only in GUI Emacs, replacing in julia-repl-1.2.0/julia-repl.el the for <= the *Warnings* buffer doesn't open, and solves the issue.

GUI Emacs

M-x julia RET

pasting renders but the command fails

ERROR: syntax: missing comma or ) in argument list
Stacktrace:
 [1] top-level scope at none:0

M-x julia-repl RET

pasting fails to render and the command fails with the same error

uxterm Emacs

M-x julia RET

                _
    _       _ _(_)_     |  Documentation: https://docs.julialang.org
   (_)     | (_) (_)    |
    _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
   | | | | | | |/ _' |  |
   | | |_| | | | |_| |  |  Version 1.4.2 (2020-05-23)
  _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
 |__/                   |

 ┌ Warning: Terminal not fully functional
 └ @ Base client.jl:374
 julia> cd(expanduser("/home/eric/work/"))                                                                                                                                

 julia> print("OK" * normpath(joinpath(VERSION ≤ v"0.7-" ? JULIA_HOME : Sys.BINDIR, Base.DATAROOTDIR, "julia", "base")))
 OK/usr/share/julia/base
!julia> exit()

 Process julia finished at Sat Jun 20 17:36:38 2020

M-x julia-repl RET

               _                                                                                                                                                          
   _       _ _(_)_     |  Documentation: https://docs.julialang.org                                                                                                       
  (_)     | (_) (_)    |                                                                                                                                                  
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.                                                                                                           
  | | | | | | |/ _` |  |                                                                                                                                                  
  | | |_| | | | (_| |  |  Version 1.4.2 (2020-05-23)                                                                                                                      
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release                                                                                                         
|__/                   |                                                                                                                                                  
                                                                                                                                                                          
julia> print("OK" * normpath(joinpath(VERSION ≤ v"0.7-" ? JULIA_HOME : Sys.BINDIR, Base.DATAROOTDIR, "julia", "base")))                                                   
OK/usr/share/julia/base                                                                                                                                                   
julia> exit()                                                                                                                                                             

Process julia finished

uxterm Julia

bash-4.3$ julia --banner=no
julia> print("OK" * normpath(joinpath(VERSION ≤ v"0.7-" ? JULIA_HOME : Sys.BINDIR, Base.DATAROOTDIR, "julia", "base")))
OK/usr/share/julia/base
julia> exit()
bash-4.3$

@ghost
Copy link
Author

ghost commented Jun 20, 2020

@willysr

Does this look like a GUI Emacs bug or MELPA packages' bugs?

Can you reproduce on Slackware-current?

@tpapp
Copy link
Owner

tpapp commented Jun 21, 2020

This is weird, it looks like an issue related to Unicode. Do UTF8 symbols work otherwise in the REPL?

@ghost
Copy link
Author

ghost commented Jun 21, 2020

Do UTF8 symbols work otherwise in the REPL?

GUI Emacs (julia-repl)

julia> ('\u263A')
'�': Unicode U+263A (category So: Symbol, other)

julia> 

uxterm Emacs (julia-repl)

julia> ('\u263A')                                                               
'☺': Unicode U+263A (category So: Symbol, other)                                
                                                                                
julia>  

This surprised me a bit. [ess-18.10.2]

GUI Emacs (R)

> setwd('/home/eric/work/')
> 4 ≤ 5
Error: unexpected numeric constant in "4   5"
> 4 <= 5
[1] TRUE
> q()

uxterm Emacs (R)

> setwd('/home/eric/work/')                                                    
> 4 ≤ 5
Error: unexpected input in "4 ≤"
> q()

uxterm R

bash-4.3$ R -q
> 4 ≤ 5
Error: unexpected input in "4 ≤"
> q()
Save workspace image? [y/n/c]: n
bash-4.3$ 

@tpapp
Copy link
Owner

tpapp commented Jun 21, 2020

I am not sure this is a bug with julia-repl. Please investigate; and let me know if there is a workaround in julia-repl I can help with.

I could of course replace with <= in the command that gets the basedir, but it is my impression that you would still have a problem with unicode chars in regular use, so this would not help you much.

@ghost
Copy link
Author

ghost commented Jun 21, 2020

problem with unicode chars in regular use

In GUI Emacs (julia) \le [TAB] returns this and \leq [TAB] doesn't return output, where the thus converted from \le [TAB] used in 4 ≤ 5 returns ERROR: syntax: extra token "5" after end of expression.

In uxterm Emacs (julia) \le [TAB] returns this and \leq [TAB] doesn't return output, where the thus converted from \le [TAB] used in 4 ≤ 5 returns true.

In GUI Emacs (julia-repl) \le [TAB] and \leq [TAB] returns this �, and \pi [TAB] returns this �.

In uxterm Emacs (julia-repl) \le [TAB] and \leq [TAB] both return this , and \pi [TAB] returns this π, where the thus converted from \le [TAB] or \leq [TAB] used in 4 ≤ 5 returns true..

@tpapp
Copy link
Owner

tpapp commented Jun 21, 2020

Is M-x julia RET ESS? I am a bit confused which output corresponds to what now.

Which OS is this? Also, bash 4.3 is rather old, which may not be directly related but something else on your system may be.

@tpapp
Copy link
Owner

tpapp commented Jun 21, 2020

Incidentally, are you starting julia-repl after starting an ESS process? If yes, please

  1. restart Emacs
  2. do M-x julia-repl

and see what happens.

@ghost
Copy link
Author

ghost commented Jun 21, 2020

Is M-x julia RET ESS?

Yes, julia-mode was a dependency for ess.

ess 18.10.2 installed
julia-repl 1.2.0 installed
s 1.12.0 installed
julia-mode 0.4 dependency

Which OS is this?

Index of /slackware/slackware-14.2/patches/source

something else

Its' not the Emacs configure arguments.

are you starting julia-repl after starting an ESS process?

No.

GUI Emacs (julia-repl)

Going into the *Scratch* buffer and typing C-h v default-process-coding-system opens the *Help* buffer with this output.

default-process-coding-system is a variable defined in ‘C source code’.
Its value is (iso-latin-1-unix . iso-latin-1-unix)

Documentation:
Cons of coding systems used for process I/O by default.
The car part is used for decoding a process output,
the cdr part is used for encoding a text to be sent to a process.

In the *julia* buffer typing C-x RET p and setting the coding-system to utf-8-unix fixed the issue.

That is done of course after the *Warnings* buffer appeared.

uxterm Emacs (julia-repl)

Going into the *Scratch* buffer and typing C-h v default-process-coding-system opens the *Help* buffer with this output.

default-process-coding-system is a variable defined in ‘C source code’.
Its value is (utf-8-unix . utf-8-unix)

Documentation:
Cons of coding systems used for process I/O by default.
The car part is used for decoding a process output,
the cdr part is used for encoding a text to be sent to a process.

could of course replace ≤ with <= in the command that gets the basedir

I wonder if the bug shows elsewhere.

@ghost
Copy link
Author

ghost commented Jun 22, 2020

For Emacs GUI (julia-repl) adding this code to ~/.emacs.d/init.el works for the rendering.

(add-hook 'term-exec-hook
          (function
           (lambda ()
             (set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))))

could of course replace ≤ with <= in the command that gets the basedir

Yes, let's do that for the Warning.


cf: #90 (comment)

The above added hook to ~/.emacs.d/init.el has no effect on the disparity in the GUI vs. terminal ESS (R) Error output caused by the default-process-coding-system values, which even if in the GUI the values via C-x RET p are modified to utf-8-unix, the ESS R replaces numeric constant with symbol and not input, and doesn't render properly in its Error message, .

> setwd('/home/eric/work/')
> 4 ≤ 5
Error: unexpected symbol in "4 �"
>

@ghost
Copy link
Author

ghost commented Jun 22, 2020

Here's the Slackware-14-2 (from patches) emacs-26.3 package creation script.

If the GUI Emacs julia-repl unicode rendering issue doesn't show up in other GNU/Linux distributions, or other OSes, then this might be added to the README.md specifically for Slackware Linux.

If Emacs is running in a GUI and you are experiencing problems with Unicode characters in the Julia REPL, place this in your Emacs initialization files (eg .emacs):

(if (display-graphic-p)
(add-hook 'term-exec-hook
          (function
           (lambda ()
             (set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix)))))

@tpapp
Copy link
Owner

tpapp commented Jun 22, 2020

So (set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix) fixes the issue for you?

What's the default value if you don't set it (eg eval

(process-coding-system (get-buffer-process (current-buffer)))

in a term buffer)?

@ghost
Copy link
Author

ghost commented Jun 22, 2020

So (set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix) fixes the issue for you?

Yes, in the hook added in ~/.emacs.d/init.el.

default value if you don't set it

With the hook removed from ~/.emacs.d/init.el.

GUI Emacs (julia)

(iso-latin-1-unix . iso-latin-1-unix)

uxterm Emacs (julia)

(utf-8-unix . utf-8-unix)

FWIW, here is my initialisation file after installing the MELPA packages.

bash-4.3$ cat ~/.emacs.d/init.el

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

(require 'package)
(add-to-list 'package-archives
	     '("melpa-stable" . "https://stable.melpa.org/packages/"))
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages (quote (julia-repl s ess))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
bash-4.3$ 

What about rewriting the conditional if to only be implemented for julia-repl?

Should the README.md be up-to-date in promoting the use of ~/.emacs.d/init.el?

@tpapp
Copy link
Owner

tpapp commented Jun 22, 2020

I am very happy to update the README if this is a general problem but your setup seems to be an outlier (and more importantly I would prefer to understand why first), so I am not sure it would benefit users. These days you really have to go out of your way to get something other than UTF8.

An environment variable perhaps? Do you have any of LC_xxx or LANG set? Also, it is strange that GUI and terminal Emacs give different settings, is it really the same Emacs, just started with -nw?

@ghost
Copy link
Author

ghost commented Jun 22, 2020

would prefer to understand why

link removed Nov 10, 2020

But should the conditional if only be implemented for julia-repl?

An environment variable perhaps?

I followed the recommended instructions when installing Slackware-12.2 which defaulted to en_US.

I noticed in console mode that after running export LANG=da_DK.UTF-8 that some of the Danish characters did not render properly, so with subsequent Slackware releases' installations I have never set $LANG to a unicode variant.

@willysr I don't know what Slackware-current recommends?

Incidentally, this perplexes me a bit.

uxterm Emacs (julia-repl)

shell> printenv | grep LANG
da_DK.UTF-8

shell> echo $LANG
ERROR: UndefVarError: LANG not defined
Stacktrace:
 [1] top-level scope at none:0

julia>

Do you have any of LC_xxx or LANG set?

xterm

bash-4.3$ echo $LC_COLLATE && echo $LANG
C
en_US
bash-4.3$ 

uxterm

bash-4.3$ echo $LC_COLLATE && echo $LANG
C
da_DK.UTF-8
bash-4.3$

is it really the same Emacs, just started with -nw?

Link to emacs package creation script in #90 (comment).

Can't enlighten you much on that one, but in uxterm & xterm (for this issue) I've been typing emacs -nw.

bash-4.3$ ls -l /usr/bin/emacs*
lrwxrwxrwx 1 root root       14 Sep 19  2019 /usr/bin/emacs -> emacs-with-x11
-rwxr-xr-t 1 root root  9397640 Aug 29  2019 /usr/bin/emacs-26.3-no-x11
-rwxr-xr-x 1 root root 10163592 Aug 29  2019 /usr/bin/emacs-26.3-with-x11
lrwxrwxrwx 1 root root       17 Sep 19  2019 /usr/bin/emacs-no-x11 -> emacs-26.3-no-x11
lrwxrwxrwx 1 root root       19 Sep 19  2019 /usr/bin/emacs-with-x11 -> emacs-26.3-with-x11
-rwxr-xr-x 1 root root    22416 Aug 29  2019 /usr/bin/emacsclient
bash-4.3$ 

@willysr
Copy link

willysr commented Jun 22, 2020

Sorry, i never used emacs

@ghost
Copy link
Author

ghost commented Jun 22, 2020

@willysr I meant about the install $LANG setting.

@ghost
Copy link
Author

ghost commented Jun 22, 2020

@tpapp further reading (Slackware $LANG setting)
link removed Nov 10, 2020

search for 'lang.csh'

@willysr
Copy link

willysr commented Jun 22, 2020

in slackware-current:
export LANG=en_US.UTF-8

in slackware 14.2:
export LANG=en_US

@ghost
Copy link
Author

ghost commented Jun 22, 2020

Starting the GUI Emacs from uxterm without the conditional if in ~/.emacs.d/init.el the issue doesn't appear.

@ghost
Copy link
Author

ghost commented Jun 23, 2020

If $LANG is a non-unicode variant. For GUI Emacs export (eg LANG=en_US.UTF-8) and start it from the command-line, for terminal use this my be insufficient, UXTerm however is known to work for the latter.

No coding patches needed, the README.md might be edited adding something like the above.

@willysr Thanks, I can't envisage any future GUI issues when the install $LANG is a unicode variant

in slackware-current:
export LANG=en_US.UTF-8

in slackware 14.2:
export LANG=en_US

xterm (with exported unicode LANG) GUI Emacs (julia-repl)

bash-4.3$ echo $LANG
en_US
bash-4.3$ export LANG=en_US.UTF-8
bash-4.3$ 

starting emacs from the command-line, switching modes C-x C-j RET and typing M-:

Eval: (process-coding-system (get-buffer-process (current-buffer)))

returns (binary . utf-8-unix)

switching modes again C-c C-k RET and pasting 4 ≤ 5 in the REPL renders as 4 ≤ 5

julia> 4 ≤ 5
true

julia>

xterm (with exported unicode LANG) Emacs (julia-repl)

bash-4.3$ echo $LANG
en_US
bash-4.3$ export LANG=en_US.UTF-8
bash-4.3$ 

starting emacs from the command-line and pasting 4 ≤ 5 in the Julia REPL renders as 4 # 5

switching modes C-x C-j RET and typing M-:

Eval: (process-coding-system (get-buffer-process (current-buffer)))

returns (binary . utf-8-unix)

switch modes again C-c C-k RET to type exit() in the REPL


cf: #90 (comment) & #90 (comment)

xterm (with exported unicode LANG) GUI Emacs ESS (R)

bash-4.3$ echo $LANG
en_US
bash-4.3$ export LANG=en_US.UTF-8
bash-4.3$ 

starting emacs from the command-line

the Error message is identical to when run inside uxterm

> setwd('/home/eric/work/')
> 4 ≤ 5
> Error: unexpected input in "4 ≤"
> q()

The Emacs Editor

Lisp Eval

M-:
Read a single Emacs Lisp expression in the minibuffer, evaluate it, and print the value in the echo area (eval-expression).

@ghost
Copy link
Author

ghost commented Jun 24, 2020

adding this to ~/.emacs.d/init.el works

(if (display-graphic-p)
     (setenv "LANG" "da_DK.UTF-8" (set-locale-environment "da_DK.UTF-8")))

closing

@ghost ghost closed this as completed Jun 25, 2020
@tpapp
Copy link
Owner

tpapp commented Jun 25, 2020

Thanks for investigating this. I am not sure it is worth documenting this quirk of 4-year old version of Slackware for a general audience, but if people run into this I can just refer them to this issue.

This issue was closed.
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

Successfully merging a pull request may close this issue.

2 participants