How can I set command-line parameters through `.emacs` file?Preset search isearch-string from command...

How to positively portray high and mighty characters?

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

How can I convince my reader that I will not use a certain trope?

Why is Madam Hooch not a professor?

Pull-up sequence accumulator counter

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

Find smallest index that is identical to the value in an array

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

Is my Rep in Stack-Exchange Form?

Counting occurrence of words in table is slow

Going to get married soon, should I do it on Dec 31 or Jan 1?

Finding closed forms for various addition laws on elliptic curves, FullSimplify fails even with assumptions?

What would Earth look like at night in medieval times?

Swapping rooks in a 4x4 board

Should my manager be aware of private LinkedIn approaches I receive? How to politely have this happen?

How to append a matrix element by element?

C-152 carb heat on before landing in hot weather?

How risky is real estate?

Do French speakers not use the subjunctive informally?

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

Does the Paladin's Aura of Protection affect only either her or ONE ally in range?

Is there a short way to compare many values mutually at same time without using multiple 'and's?

Using “sparkling” as a diminutive of “spark” in a poem

Does ultrasonic bath cleaning damage laboratory volumetric glassware calibration?



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

                              Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                              Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                              Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m