Evaluating Lisp Expressions
There are several ways to explicitly evaluate Lisp expressions.
You can put the Lisp expressions in a file, then load the file. Suppose you place the expressions in a file named rebind.el. (Emacs Lisp filenames customarily end in .el.) You could then type M-x load-file RET rebind.el RET to cause Emacs to evaluate the contents of that file.
If you placed those expressions into your .emacs file, you could load .emacs in the same way. But after you've been using Emacs for a while, your .emacs tends to grow, and if it's very large, loading it could be slow. In that case, you wouldn't want to load the entire file just to get the effect of a couple of small changes. That brings us to our next option.
You can use the command
eval-last-sexp, which is bound to[4] C-x C-e. (Sexp[5] is an abbreviation for S-expression, which in turn is short for symbolic expression, which is another name for "Lisp expression.") This command evaluates the Lisp expression to the left of the cursor. So what you'd do is position the cursor at the end of the first line:(global-set-key "\M-?" 'help-command)▌ (global-set-key "\C-h" 'delete-backward-char)
and press C-x C-e; then move to the end of the second line:
(global-set-key "\M-?" 'help-command) (global-set-key "\C-h" 'delete-backward-char)▌
and press C-x C-e again. Note that each time you press C-x C-e, the result of evaluating
global-set-key—the special symbolnil(which we'll see again later)—is shown in Emacs's message area at the bottom ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access