Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change emacs settings while it's running?

Tags:

emacs

I'm very new to the Emacs text editor and have just started customizing my ~/.emacs file. I'm wondering if it's possible to change an Emacs setting while it's running. For example, if I put the following in my ~/.emacs file:

(show-paren-mode 1)

I can do the same thing when Emacs is running by typing:

M-x then scroll-step then 1.

Why doesn't this work when I want to do something like this:

(setq scroll-step 1)

When I type:

M-x then setq,

all I get is (no match). There must something I'm not understanding here.

like image 378
Andrew Gunnerson Avatar asked Dec 16 '22 04:12

Andrew Gunnerson


1 Answers

There is a few things:

  1. yes, you can change settings at run-time. If you edit your .emacs file, put your cursor after the closing parenthesis in:

    (show-paren-mode 1)
    

    And hit ctrl-x ctrl-e and it will evaluate the code.

  2. some things and variables (though very few) require them to run special things after the setting was changed. Generally there aren't too many and most variables you set will take effect immediately after doing the steps in #1.

    However, if you edit your settings using M-x customize you'll find that when you make changes there it'll make the settings active immediately, even in those special cases where something special needs to be done after a value change.

  3. M-x allows you to run "interactive" commands. Some elisp functions are supposed to be called directly by the end user, and others are really only meant when writing elisp into a file. And M-x only lets you easily do the ones that have been marked "interactive". Though M-shift-: will let you type an expression and see the results. EG, try M-shift-: followed by (1+ 2) at the prompt.

like image 171
Wes Hardaker Avatar answered Dec 23 '22 10:12

Wes Hardaker