What is the difference between setq and set-variable in emacs lisp. When should I use setq and when should I set-variable.
What is the difference between setq and set-variable in emacs lisp. When should I
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
set-variableis an interactive command, meaning that you can type M-x set-variable RET to be interactively prompted for a variable name and value.setqis not an interactive command, meaning it’s only suitable for writing in Emacs Lisp code. Personally, I never useset-variablein my Lisp code, only interactively, when I want to give a value to a variable that has an immediate effect on my text editing, such as (for example) settingindent-tabs-modetotornil.Another difference is that
setqcan set multiple variables at once. For example, in my .emacs file on OS X I have:set-variablecan’t do that.