-
Notifications
You must be signed in to change notification settings - Fork 15
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
Restart doesn't retain arguments. #11
Comments
Hi @Bost, Thanks for the bug report and sorry for the delay in reply. The path to binary is the same that Emacs was started with (see You are correct about the rest of arguments, I wanted to add this feature, unfortunately there is no cross platform way to access the arguments, on Windows you cannot get the arguments at all, it requires a program which might not always be available. As such I avoided this implementing this. But now that I have request for this I guess I will implement this as a Linux only feature or something. Thanks |
Hi @iqbalansari,
For starters, please mention this in the documentation. |
Added to the |
What about the |
Hi @Georgiy-Tugai, If I remember correctly it does not retain all the arguments, only the ones that have not been processed by Emacs. From the documentation of
Interesting, are you sure of this? Can you start Emacs from the command with Thanks |
I can confirm there is only binary path while I am using emacs 26.1 on Windows 10 with command-line-args is a variable defined in ‘C source code’.
Its value is ("C:\\emacs\\bin\\emacs.exe") |
Regarding "command line arguments not retained", it looks like this mitigates the problem, even though not completely solves it: (defun my=restart-spacemacs-guix--start-gui-using-sh (&optional args)
"Start GUI version of Emacs using sh.
ARGS is the list arguments with which Emacs should be started"
(let ((command
;;;; The command arguments returned by `ps' are munched together. Whitespace
;;;; chars are not escaped, that means the emacs invocation arguments can't be
;;;; reliably separated from each other. E.g. when started with:
;;;; `emacs --eval '(setq my=var #t)'`
;;;; the `ps' returns "emacs --eval (setq my=var #t)", w/o the single quote
;;;; characters.
;;;;
;;;; However a bit of heuristic approach may be applied here. I.e. one may try
;;;; to apply `read-string` or `read-from-string` at anything what comes after
;;;; '--eval', assuming it is a valid sexp,i.e. surrounded by parens or alike.
;; (format "%s" (shell-command-to-string
;; (format "ps -ho command -p %s" (emacs-pid))))
"/path/to/emacs-start-script" ;; or "/path/to/emacs-start-script & disown"
))
(call-process "sh" nil 0 nil "-c" command)))
(advice-add #'restart-emacs--start-gui-using-sh
:override #'my=restart-spacemacs-guix--start-gui-using-sh)
The Command-line argument processing is explained here https://github.com/emacs-mirror/emacs/blob/master/src/emacs.c#L1392 Maybe some sort of strcpy(command-line-args, command-line-args-original); could be made before the |
It looks like the emacs process is not restarted the same way as it was started.
The path to the binary is different and more importantlly the start parameters are not retained:
Before restart:
After
M-x restart-emacs
:I observe this behavior in both versions: melpa 20170609.905 and also melpa-stable 0.1.1
Thx.
The text was updated successfully, but these errors were encountered: