How can I set command-line parameters through `.emacs` file?Preset search isearch-string from command lineloading a new init file within EmacsSet a variable to a Windows path in init fileHow can I override initial-buffer-choice if I specify a filename at command line?Starting emacs with eshell and file from command line argumentRun elisp from command line in running emacsSet an Elisp var on the command line and read it in the init fileTesting if emacs was invoked with a file to visitemacs (v24.3.1): command line '--' before the file nameHow to make `emacs` shell command switch to existing emacs process, if it exists?
What is this blowing instrument used in the acoustic cover of "Taekwondo" by "Walk off the Earth"?
Does the posterior necessarily follow the same conditional dependence structure as the prior?
How can Charles Proxy change settings without admin rights after first time?
Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback
Do sudoku answers always have a single minimal clue set?
What is the line crossing the Pacific Ocean that is shown on maps?
Does Hubble need to dump momentum of its reaction wheels?
Layout of complex table
How often can a PC check with passive perception during a combat turn?
Find smallest index that is identical to the value in an array
Averting Real Women Don’t Wear Dresses
How well known and how commonly used was Huffman coding in 1979?
Using symmetry of Riemann tensor to vanish components
Mount a folder with a space on Linux
Why aren't (poly-)cotton tents more popular?
How could mana leakage be dangerous to a elf?
Syntax Error with 'if'
Calculating the partial sum of a expl3 sequence
Could Sauron have read Tom Bombadil's mind if Tom had held the Palantir?
Bash echo $-1 prints hb1. Why?
Ending: accusative or not?
Why does the numerical solution of an ODE move away from an unstable equilibrium?
Counting occurrence of words in table is slow
Fedora boot screen shows both Fedora logo and Lenovo logo. Why and How?
How can I set command-line parameters through `.emacs` file?
Preset search isearch-string from command lineloading a new init file within EmacsSet a variable to a Windows path in init fileHow can I override initial-buffer-choice if I specify a filename at command line?Starting emacs with eshell and file from command line argumentRun elisp from command line in running emacsSet an Elisp var on the command line and read it in the init fileTesting if emacs was invoked with a file to visitemacs (v24.3.1): command line '--' before the file nameHow to make `emacs` shell command switch to existing emacs process, if it exists?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Is it possible to set Emacs start-up command-line flags such as -nw
and -q
in an init file? If it is, how can I do that?
init-file command-line-arguments
add a comment |
Is it possible to set Emacs start-up command-line flags such as -nw
and -q
in an init file? If it is, how can I do that?
init-file command-line-arguments
add a comment |
Is it possible to set Emacs start-up command-line flags such as -nw
and -q
in an init file? If it is, how can I do that?
init-file command-line-arguments
Is it possible to set Emacs start-up command-line flags such as -nw
and -q
in an init file? If it is, how can I do that?
init-file command-line-arguments
init-file command-line-arguments
edited 7 hours ago
Drew
49.8k4 gold badges65 silver badges112 bronze badges
49.8k4 gold badges65 silver badges112 bronze badges
asked 8 hours ago
cig0cig0
141 bronze badge
141 bronze badge
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can modify the command line arguments in an init file if you want. But if you do that after Emacs has processed the argument, it won't have any effect.
Emacs processes command line arguments in two places: in the C startup code, and in startup.el
. The C startup code processes arguments before it executes any Lisp code, so there's no way to influence that from an init file. As of Emacs 26.2, the following options are handled in C: --version
, --chdir
, -t
, -nw
, --batch
, --script
, -daemon
, --bg-daemon
, --fg-daemon
, --help
, --no-loadup
, --no-site-lisp
, --no-build-details
, --module-assertions
and (partially) --display
.
So in particular there's no way to completely prevent the initialization of the window system (-nw
) from Lisp.
You can modify other options from a Lisp file that's loaded before startup.el
processes the command line. The main relevant steps are:
- Load
subdirs.el
from directories on the load path. You can control this with the environment variableEMACSLOADPATH
. - Process some command line options (code), including the ones that control what init files to load (e.g.
-Q
,-q
) and a few user interface variables (including-display
). - Finish initializing the window system and create the initial frame.
- Load
site-start.el
(prevented by-Q
) and the user init file (.emacs
or other name, prevented by-q
or-batch
). - Call
package-initialize
. - Process remaining command line options (code), including options that control the appearance of Emacs and options to run code and open files (
-l
,--eval
,--find-file
, …).
add a comment |
Is it possible to set Emacs start-up command-line flags such as
-nw
and-q
in an init file? If it is, how can I do that?
In general, no, you can't do that -- and your second example option is precisely what I would have used to explain why:
-q
(aka --no-init-file
) tells Emacs not to load your init file, so trying to set that option in your init file does not make sense.
That said... some arguments are processed after loading the init file, and so for certain arguments you could populate the command-line-args
variable in your init file to imitate using them on the command line. These options include:
--directory
--eval
--execute
--file
--find-file
--funcall
--insert
--kill
--load
--no-desktop
--no-splash
--visit
e.g.:
(setq command-line-args
(append command-line-args '("--eval"
"(message "hello")")))
I would not expect there to be any benefit to jumping through such hoops to use these "Action options" in your init file, as there are more direct ways of performing the actions.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "583"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f51195%2fhow-can-i-set-command-line-parameters-through-emacs-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can modify the command line arguments in an init file if you want. But if you do that after Emacs has processed the argument, it won't have any effect.
Emacs processes command line arguments in two places: in the C startup code, and in startup.el
. The C startup code processes arguments before it executes any Lisp code, so there's no way to influence that from an init file. As of Emacs 26.2, the following options are handled in C: --version
, --chdir
, -t
, -nw
, --batch
, --script
, -daemon
, --bg-daemon
, --fg-daemon
, --help
, --no-loadup
, --no-site-lisp
, --no-build-details
, --module-assertions
and (partially) --display
.
So in particular there's no way to completely prevent the initialization of the window system (-nw
) from Lisp.
You can modify other options from a Lisp file that's loaded before startup.el
processes the command line. The main relevant steps are:
- Load
subdirs.el
from directories on the load path. You can control this with the environment variableEMACSLOADPATH
. - Process some command line options (code), including the ones that control what init files to load (e.g.
-Q
,-q
) and a few user interface variables (including-display
). - Finish initializing the window system and create the initial frame.
- Load
site-start.el
(prevented by-Q
) and the user init file (.emacs
or other name, prevented by-q
or-batch
). - Call
package-initialize
. - Process remaining command line options (code), including options that control the appearance of Emacs and options to run code and open files (
-l
,--eval
,--find-file
, …).
add a comment |
You can modify the command line arguments in an init file if you want. But if you do that after Emacs has processed the argument, it won't have any effect.
Emacs processes command line arguments in two places: in the C startup code, and in startup.el
. The C startup code processes arguments before it executes any Lisp code, so there's no way to influence that from an init file. As of Emacs 26.2, the following options are handled in C: --version
, --chdir
, -t
, -nw
, --batch
, --script
, -daemon
, --bg-daemon
, --fg-daemon
, --help
, --no-loadup
, --no-site-lisp
, --no-build-details
, --module-assertions
and (partially) --display
.
So in particular there's no way to completely prevent the initialization of the window system (-nw
) from Lisp.
You can modify other options from a Lisp file that's loaded before startup.el
processes the command line. The main relevant steps are:
- Load
subdirs.el
from directories on the load path. You can control this with the environment variableEMACSLOADPATH
. - Process some command line options (code), including the ones that control what init files to load (e.g.
-Q
,-q
) and a few user interface variables (including-display
). - Finish initializing the window system and create the initial frame.
- Load
site-start.el
(prevented by-Q
) and the user init file (.emacs
or other name, prevented by-q
or-batch
). - Call
package-initialize
. - Process remaining command line options (code), including options that control the appearance of Emacs and options to run code and open files (
-l
,--eval
,--find-file
, …).
add a comment |
You can modify the command line arguments in an init file if you want. But if you do that after Emacs has processed the argument, it won't have any effect.
Emacs processes command line arguments in two places: in the C startup code, and in startup.el
. The C startup code processes arguments before it executes any Lisp code, so there's no way to influence that from an init file. As of Emacs 26.2, the following options are handled in C: --version
, --chdir
, -t
, -nw
, --batch
, --script
, -daemon
, --bg-daemon
, --fg-daemon
, --help
, --no-loadup
, --no-site-lisp
, --no-build-details
, --module-assertions
and (partially) --display
.
So in particular there's no way to completely prevent the initialization of the window system (-nw
) from Lisp.
You can modify other options from a Lisp file that's loaded before startup.el
processes the command line. The main relevant steps are:
- Load
subdirs.el
from directories on the load path. You can control this with the environment variableEMACSLOADPATH
. - Process some command line options (code), including the ones that control what init files to load (e.g.
-Q
,-q
) and a few user interface variables (including-display
). - Finish initializing the window system and create the initial frame.
- Load
site-start.el
(prevented by-Q
) and the user init file (.emacs
or other name, prevented by-q
or-batch
). - Call
package-initialize
. - Process remaining command line options (code), including options that control the appearance of Emacs and options to run code and open files (
-l
,--eval
,--find-file
, …).
You can modify the command line arguments in an init file if you want. But if you do that after Emacs has processed the argument, it won't have any effect.
Emacs processes command line arguments in two places: in the C startup code, and in startup.el
. The C startup code processes arguments before it executes any Lisp code, so there's no way to influence that from an init file. As of Emacs 26.2, the following options are handled in C: --version
, --chdir
, -t
, -nw
, --batch
, --script
, -daemon
, --bg-daemon
, --fg-daemon
, --help
, --no-loadup
, --no-site-lisp
, --no-build-details
, --module-assertions
and (partially) --display
.
So in particular there's no way to completely prevent the initialization of the window system (-nw
) from Lisp.
You can modify other options from a Lisp file that's loaded before startup.el
processes the command line. The main relevant steps are:
- Load
subdirs.el
from directories on the load path. You can control this with the environment variableEMACSLOADPATH
. - Process some command line options (code), including the ones that control what init files to load (e.g.
-Q
,-q
) and a few user interface variables (including-display
). - Finish initializing the window system and create the initial frame.
- Load
site-start.el
(prevented by-Q
) and the user init file (.emacs
or other name, prevented by-q
or-batch
). - Call
package-initialize
. - Process remaining command line options (code), including options that control the appearance of Emacs and options to run code and open files (
-l
,--eval
,--find-file
, …).
answered 6 hours ago
Gilles♦Gilles
13.8k4 gold badges36 silver badges75 bronze badges
13.8k4 gold badges36 silver badges75 bronze badges
add a comment |
add a comment |
Is it possible to set Emacs start-up command-line flags such as
-nw
and-q
in an init file? If it is, how can I do that?
In general, no, you can't do that -- and your second example option is precisely what I would have used to explain why:
-q
(aka --no-init-file
) tells Emacs not to load your init file, so trying to set that option in your init file does not make sense.
That said... some arguments are processed after loading the init file, and so for certain arguments you could populate the command-line-args
variable in your init file to imitate using them on the command line. These options include:
--directory
--eval
--execute
--file
--find-file
--funcall
--insert
--kill
--load
--no-desktop
--no-splash
--visit
e.g.:
(setq command-line-args
(append command-line-args '("--eval"
"(message "hello")")))
I would not expect there to be any benefit to jumping through such hoops to use these "Action options" in your init file, as there are more direct ways of performing the actions.
add a comment |
Is it possible to set Emacs start-up command-line flags such as
-nw
and-q
in an init file? If it is, how can I do that?
In general, no, you can't do that -- and your second example option is precisely what I would have used to explain why:
-q
(aka --no-init-file
) tells Emacs not to load your init file, so trying to set that option in your init file does not make sense.
That said... some arguments are processed after loading the init file, and so for certain arguments you could populate the command-line-args
variable in your init file to imitate using them on the command line. These options include:
--directory
--eval
--execute
--file
--find-file
--funcall
--insert
--kill
--load
--no-desktop
--no-splash
--visit
e.g.:
(setq command-line-args
(append command-line-args '("--eval"
"(message "hello")")))
I would not expect there to be any benefit to jumping through such hoops to use these "Action options" in your init file, as there are more direct ways of performing the actions.
add a comment |
Is it possible to set Emacs start-up command-line flags such as
-nw
and-q
in an init file? If it is, how can I do that?
In general, no, you can't do that -- and your second example option is precisely what I would have used to explain why:
-q
(aka --no-init-file
) tells Emacs not to load your init file, so trying to set that option in your init file does not make sense.
That said... some arguments are processed after loading the init file, and so for certain arguments you could populate the command-line-args
variable in your init file to imitate using them on the command line. These options include:
--directory
--eval
--execute
--file
--find-file
--funcall
--insert
--kill
--load
--no-desktop
--no-splash
--visit
e.g.:
(setq command-line-args
(append command-line-args '("--eval"
"(message "hello")")))
I would not expect there to be any benefit to jumping through such hoops to use these "Action options" in your init file, as there are more direct ways of performing the actions.
Is it possible to set Emacs start-up command-line flags such as
-nw
and-q
in an init file? If it is, how can I do that?
In general, no, you can't do that -- and your second example option is precisely what I would have used to explain why:
-q
(aka --no-init-file
) tells Emacs not to load your init file, so trying to set that option in your init file does not make sense.
That said... some arguments are processed after loading the init file, and so for certain arguments you could populate the command-line-args
variable in your init file to imitate using them on the command line. These options include:
--directory
--eval
--execute
--file
--find-file
--funcall
--insert
--kill
--load
--no-desktop
--no-splash
--visit
e.g.:
(setq command-line-args
(append command-line-args '("--eval"
"(message "hello")")))
I would not expect there to be any benefit to jumping through such hoops to use these "Action options" in your init file, as there are more direct ways of performing the actions.
edited 5 hours ago
answered 6 hours ago
philsphils
29.1k2 gold badges40 silver badges75 bronze badges
29.1k2 gold badges40 silver badges75 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Emacs Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f51195%2fhow-can-i-set-command-line-parameters-through-emacs-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown