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;








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




















          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 6 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 5 hours ago

























                          answered 6 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

                              ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

                              Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

                              19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу