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?

The use of "I" and "we" used in the same sentence and other questions

Why do some games show lights shine through walls?

How come I was asked by a CBP officer why I was in the US?

How well known and how commonly used was Huffman coding in 1979?

How often can a PC check with passive perception during a combat turn?

Why would people reject a god's purely beneficial blessing?

Is my Rep in Stack-Exchange Form?

What is this opening trap called, and how should I play afterwards? How can I refute the gambit, and play if I accept it?

Using symmetry of Riemann tensor to vanish components

Bash echo $-1 prints hb1. Why?

What do you call the action of someone tackling a stronger person?

What is this particular type of chord progression, common in classical music, called?

What is this blowing instrument used in the acoustic cover of "Taekwondo" by "Walk off the Earth"?

Analog is Obtuse!

Should I hide continue button until tasks are completed?

Is this one of the engines from the 9/11 aircraft?

Are there any vegetarian astronauts?

Simple object validator with a new API

Does anycast addressing add additional latency in any way?

What determines the "strength of impact" of a falling object on the ground, momentum or energy?

Symbolic equivalent of chmod 400

How risky is real estate?

What is the line crossing the Pacific Ocean that is shown on maps?

"It will become the talk of Paris" - translation into French



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;








1















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?










share|improve this question






























    1















    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?










    share|improve this question


























      1












      1








      1








      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?










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 8 hours ago









      Drew

      49.8k4 gold badges65 silver badges112 bronze badges




      49.8k4 gold badges65 silver badges112 bronze badges










      asked 9 hours ago









      cig0cig0

      141 bronze badge




      141 bronze badge




















          2 Answers
          2






          active

          oldest

          votes


















          1














          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 variable EMACSLOADPATH.

          • 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, …).





          share|improve this answer






























            1















            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.






            share|improve this answer



























              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
              );



              );













              draft saved

              draft discarded


















              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









              1














              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 variable EMACSLOADPATH.

              • 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, …).





              share|improve this answer



























                1














                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 variable EMACSLOADPATH.

                • 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, …).





                share|improve this answer

























                  1












                  1








                  1







                  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 variable EMACSLOADPATH.

                  • 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, …).





                  share|improve this answer













                  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 variable EMACSLOADPATH.

                  • 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, …).






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 7 hours ago









                  GillesGilles

                  13.8k4 gold badges36 silver badges75 bronze badges




                  13.8k4 gold badges36 silver badges75 bronze badges























                      1















                      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.






                      share|improve this answer





























                        1















                        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.






                        share|improve this answer



























                          1












                          1








                          1








                          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.






                          share|improve this answer
















                          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.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 6 hours ago

























                          answered 7 hours ago









                          philsphils

                          29.1k2 gold badges40 silver badges75 bronze badges




                          29.1k2 gold badges40 silver badges75 bronze badges



























                              draft saved

                              draft discarded
















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                              Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                              Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її