I want to be able to make the changes to my .emacs file without having to reload Emacs.
I found three questions which sort of answer what I am asking (you can find them here, here and here), but the problem is that the change I have just made is to a toggle, and as the comments to two of the answers (a1, a2) to those questions explain, the solutions given there (such as M-x reload-file or M-x eval-buffer) don't apply to toggles.
I imagine there is a way of toggling the variable again with a command, but if there is a way to reload the whole .emacs and have the all the toggles re-evaluated without having to specify them, I would prefer.
In any case, I would also appreciate if someone told me how to toggle the value of a variable so that if I just changed one toggle I can do it with a command rather than re-start Emacs just for that (I am new to Emacs). I don't know how useful this information is, but the change I applied was the following (which I got from this answer to another question):
(setq skeleton-pair t)
(setq skeleton-pair-on-word t)
(global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "<") 'skeleton-pair-insert-maybe)
Edit: I included the above in .emacs and reloaded Emacs, so that the changes took effect. Then I commented all of it out and tried M-x load-file. This doesn't work. The suggestion below (C-x C-e by PP works if I am using it to evaluate the toggle first time, but not when I want to undo it). I would like something that would evaluate the commenting out, if such thing exists...
Thanks :)
You can use the command load-file ( M-x load-file , then press return twice to accept the default filename, which is the current file being edited). You can also just move the point to the end of any sexp and press C-x C-e to execute just that sexp.
To change the read-only status of a buffer, use C-x C-q (toggle read-only-mode ). To change file permissions, you can run dired on the file's directory ( C-x d ), search for the file by C-s and use M to change its mode.
Commands in emacs are either control characters (hold down the <Ctrl> key while typing another character) or are prefixed by one of a set of reserved characters: <Esc> or <Ctrl>-X.
Buffers in Emacs editing are objects that have distinct names and hold text that can be edited. Buffers appear to Lisp programs as a special data type. You can think of the contents of a buffer as a string that you can extend; insertions and deletions may occur in any part of the buffer.
Some things you might want to try:
M-x load-file
(then when prompted, type ~/.emacs
enter). M-x means press the meta key (usually Esc
on Linux and Windows desktops) then press the ordinary x
character key.
Or, while your .emacs
file is open, place your prompt just after a close bracket for the function you want to execute and type Ctrl-X
, Ctrl-E
. This executes that block enclosed within the nearest set of parenthesis to the left of the cursor.
This last technique I use frequently for complicated search-and-replaces. Say I'm editing an XML file and I want to move close tags onto the line before: I would type into my current XML buffer (query-replace-regexp "[ \r\n\t]*</" "</")
, then place my cursor immediately after the closing parenthesis, and type Ctrl-X
, Ctrl-E
.
I included the above in .emacs and reloaded Emacs, so that the changes took effect. Then I commented all of it out and tried M-x load-file. This doesn't work.
It doesn't work because when you started Emacs you set a few variables and keys. Reloading .emacs
with these commands commented out does not undo them. You'll have to overwrite the settings manually to undo them with
(setq variable-name nil)
and
M-x global-unset-key
enter followed by the key you want to unset.
I take it that you want to experiment with turning on/off skeleton-pair?
I'd be tempted to do this by having:
(setq skeleton-pair t) ; turns skeleton-pair on
(setq skeleton-pair nil) ; turns skeleton-pair off
In the .emacs, and pressing C-x C-e next to the closing parenthesis for the particular version I want to try. Of course I'd have to remember to make sure that the .emacs only has the final setting that I want in it so it does the right thing next time I start up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With