Changing faces one at a time, outside customize









up vote
3
down vote

favorite












Is there a way to change faces one at a time, outside of customize?



In my custom-file I see a big blob of face customizations that starts with:



(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
...


So I suppose custom-set-faces is not the right function to use for changing just one face, but I'm not sure what is.



Any suggestions?










share|improve this question

























    up vote
    3
    down vote

    favorite












    Is there a way to change faces one at a time, outside of customize?



    In my custom-file I see a big blob of face customizations that starts with:



    (custom-set-faces
    ;; custom-set-faces was added by Custom.
    ;; If you edit it by hand, you could mess it up, so be careful.
    ;; Your init file should contain only one such instance.
    ;; If there is more than one, they won't work right.
    ...


    So I suppose custom-set-faces is not the right function to use for changing just one face, but I'm not sure what is.



    Any suggestions?










    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      Is there a way to change faces one at a time, outside of customize?



      In my custom-file I see a big blob of face customizations that starts with:



      (custom-set-faces
      ;; custom-set-faces was added by Custom.
      ;; If you edit it by hand, you could mess it up, so be careful.
      ;; Your init file should contain only one such instance.
      ;; If there is more than one, they won't work right.
      ...


      So I suppose custom-set-faces is not the right function to use for changing just one face, but I'm not sure what is.



      Any suggestions?










      share|improve this question













      Is there a way to change faces one at a time, outside of customize?



      In my custom-file I see a big blob of face customizations that starts with:



      (custom-set-faces
      ;; custom-set-faces was added by Custom.
      ;; If you edit it by hand, you could mess it up, so be careful.
      ;; Your init file should contain only one such instance.
      ;; If there is more than one, they won't work right.
      ...


      So I suppose custom-set-faces is not the right function to use for changing just one face, but I'm not sure what is.



      Any suggestions?







      faces






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 14:27









      izkon

      566113




      566113




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          You can use custom-set-faces or custom-theme-set-faces, with a list of one face - no problem. Or you can use modify-face. Or, as @erikstokes mentions, you can use set-face-attribute.



          Note that the Elisp manual, node Attribute Functions, says this about set-face-attribute (but it doesn't say why):




          This function is mostly intended for internal usage.




          Note too that in the case of user options (variables), there are the single-option functions customize-set-variable and customize-set-value, which are companions to the multiple-option function custom-set-variables that is written to your custom-file (or init file). They are also commands, letting you choose the option using completion.



          But for faces there is no such single-face companion function (and no command, other than customize-face).






          share|improve this answer






















          • For some reason custom-set-options does not appear in my custom-file (nor in C-h f custom-set-options). Instead, it uses custom-set-variables.
            – izkon
            Nov 10 at 18:25










          • Sorry, I meant custom-set-variables - I updated the answer to correct that.
            – Drew
            Nov 10 at 18:38

















          up vote
          1
          down vote













          set-face-attribute is the function you want. For example to make comments green and bold:



          (set-face-attribute 'font-lock-comment-face nil
          :foreground "Green"
          :weight 'bold)


          There are also helper functions set-face-foreground and set-face-background for the common case of just changing the color of the face.






          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',
            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%2f45895%2fchanging-faces-one-at-a-time-outside-customize%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








            up vote
            4
            down vote



            accepted










            You can use custom-set-faces or custom-theme-set-faces, with a list of one face - no problem. Or you can use modify-face. Or, as @erikstokes mentions, you can use set-face-attribute.



            Note that the Elisp manual, node Attribute Functions, says this about set-face-attribute (but it doesn't say why):




            This function is mostly intended for internal usage.




            Note too that in the case of user options (variables), there are the single-option functions customize-set-variable and customize-set-value, which are companions to the multiple-option function custom-set-variables that is written to your custom-file (or init file). They are also commands, letting you choose the option using completion.



            But for faces there is no such single-face companion function (and no command, other than customize-face).






            share|improve this answer






















            • For some reason custom-set-options does not appear in my custom-file (nor in C-h f custom-set-options). Instead, it uses custom-set-variables.
              – izkon
              Nov 10 at 18:25










            • Sorry, I meant custom-set-variables - I updated the answer to correct that.
              – Drew
              Nov 10 at 18:38














            up vote
            4
            down vote



            accepted










            You can use custom-set-faces or custom-theme-set-faces, with a list of one face - no problem. Or you can use modify-face. Or, as @erikstokes mentions, you can use set-face-attribute.



            Note that the Elisp manual, node Attribute Functions, says this about set-face-attribute (but it doesn't say why):




            This function is mostly intended for internal usage.




            Note too that in the case of user options (variables), there are the single-option functions customize-set-variable and customize-set-value, which are companions to the multiple-option function custom-set-variables that is written to your custom-file (or init file). They are also commands, letting you choose the option using completion.



            But for faces there is no such single-face companion function (and no command, other than customize-face).






            share|improve this answer






















            • For some reason custom-set-options does not appear in my custom-file (nor in C-h f custom-set-options). Instead, it uses custom-set-variables.
              – izkon
              Nov 10 at 18:25










            • Sorry, I meant custom-set-variables - I updated the answer to correct that.
              – Drew
              Nov 10 at 18:38












            up vote
            4
            down vote



            accepted







            up vote
            4
            down vote



            accepted






            You can use custom-set-faces or custom-theme-set-faces, with a list of one face - no problem. Or you can use modify-face. Or, as @erikstokes mentions, you can use set-face-attribute.



            Note that the Elisp manual, node Attribute Functions, says this about set-face-attribute (but it doesn't say why):




            This function is mostly intended for internal usage.




            Note too that in the case of user options (variables), there are the single-option functions customize-set-variable and customize-set-value, which are companions to the multiple-option function custom-set-variables that is written to your custom-file (or init file). They are also commands, letting you choose the option using completion.



            But for faces there is no such single-face companion function (and no command, other than customize-face).






            share|improve this answer














            You can use custom-set-faces or custom-theme-set-faces, with a list of one face - no problem. Or you can use modify-face. Or, as @erikstokes mentions, you can use set-face-attribute.



            Note that the Elisp manual, node Attribute Functions, says this about set-face-attribute (but it doesn't say why):




            This function is mostly intended for internal usage.




            Note too that in the case of user options (variables), there are the single-option functions customize-set-variable and customize-set-value, which are companions to the multiple-option function custom-set-variables that is written to your custom-file (or init file). They are also commands, letting you choose the option using completion.



            But for faces there is no such single-face companion function (and no command, other than customize-face).







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 10 at 18:38

























            answered Nov 10 at 17:32









            Drew

            46.3k461103




            46.3k461103











            • For some reason custom-set-options does not appear in my custom-file (nor in C-h f custom-set-options). Instead, it uses custom-set-variables.
              – izkon
              Nov 10 at 18:25










            • Sorry, I meant custom-set-variables - I updated the answer to correct that.
              – Drew
              Nov 10 at 18:38
















            • For some reason custom-set-options does not appear in my custom-file (nor in C-h f custom-set-options). Instead, it uses custom-set-variables.
              – izkon
              Nov 10 at 18:25










            • Sorry, I meant custom-set-variables - I updated the answer to correct that.
              – Drew
              Nov 10 at 18:38















            For some reason custom-set-options does not appear in my custom-file (nor in C-h f custom-set-options). Instead, it uses custom-set-variables.
            – izkon
            Nov 10 at 18:25




            For some reason custom-set-options does not appear in my custom-file (nor in C-h f custom-set-options). Instead, it uses custom-set-variables.
            – izkon
            Nov 10 at 18:25












            Sorry, I meant custom-set-variables - I updated the answer to correct that.
            – Drew
            Nov 10 at 18:38




            Sorry, I meant custom-set-variables - I updated the answer to correct that.
            – Drew
            Nov 10 at 18:38










            up vote
            1
            down vote













            set-face-attribute is the function you want. For example to make comments green and bold:



            (set-face-attribute 'font-lock-comment-face nil
            :foreground "Green"
            :weight 'bold)


            There are also helper functions set-face-foreground and set-face-background for the common case of just changing the color of the face.






            share|improve this answer
























              up vote
              1
              down vote













              set-face-attribute is the function you want. For example to make comments green and bold:



              (set-face-attribute 'font-lock-comment-face nil
              :foreground "Green"
              :weight 'bold)


              There are also helper functions set-face-foreground and set-face-background for the common case of just changing the color of the face.






              share|improve this answer






















                up vote
                1
                down vote










                up vote
                1
                down vote









                set-face-attribute is the function you want. For example to make comments green and bold:



                (set-face-attribute 'font-lock-comment-face nil
                :foreground "Green"
                :weight 'bold)


                There are also helper functions set-face-foreground and set-face-background for the common case of just changing the color of the face.






                share|improve this answer












                set-face-attribute is the function you want. For example to make comments green and bold:



                (set-face-attribute 'font-lock-comment-face nil
                :foreground "Green"
                :weight 'bold)


                There are also helper functions set-face-foreground and set-face-background for the common case of just changing the color of the face.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 14:53









                erikstokes

                8,96322142




                8,96322142



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f45895%2fchanging-faces-one-at-a-time-outside-customize%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

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    政党

                    天津地下鉄3号線