3,771
questions
198
votes
3
answers
43k
views
How to have Emacs auto-refresh all buffers when files have changed on disk?
I have a non-emacs global search and replace function that causes my disk files to become more up-to-date than my emacs buffers (en masse). Is there any way to tell emacs to refresh all the buffers ...
160
votes
10
answers
48k
views
Is there a (repeat-last-command) in Emacs?
Frequently, I've dug into apropos and docs looking for something like the following only to give up to get back to the task at hand:
(repeat-last-command)
do the last C- or M- command I just ...
155
votes
14
answers
65k
views
How to achieve code folding effects in Emacs?
What's the best way to achieve something like code folding, or the type of cycling that org-mode uses. What would be the best solution in elisp to create this type of behavior?
EDIT:
I'm sorry I was ...
148
votes
6
answers
48k
views
How do I byte-compile everything in my .emacs.d directory?
I have decided to check out Emacs, and I liked it very much. Now, I'm using the Emacs Starter Kit, which sort of provides better defaults and some nice customizations to default install of Emacs.
I ...
131
votes
1
answer
5k
views
Emacs Ruby autocomplete almost working
I've been updating my emacs config with the use of Rsense to allow for an autocomplete drop down box to appear whilst typing code. This works well in most files except I've found it doesn't allow me ...
128
votes
4
answers
20k
views
emacs/elisp: What is the hash (pound, number sign, octothorp) symbol used for?
What does this do?
(add-hook 'compilation-mode-hook #'my-setup-compile-mode)
...and is it different than
(add-hook 'compilation-mode-hook 'my-setup-compile-mode)
124
votes
14
answers
64k
views
The function to show current file's full path in mini buffer
I need to get the full path of the file that I'm editing with emacs.
Is there a function for that?
If not, what would be the elisp function for getting that?
How can I copy the result (path name) to ...
114
votes
1
answer
25k
views
The difference between setq and setq-default in Emacs Lisp
I have a question about Emacs Lisp. What is the difference between setq and setq-default?
Tutorials say setq takes effect in the local buffer while setq-default affects all buffers.
For example, ...
112
votes
10
answers
72k
views
How do I set the size of Emacs' window?
I'm trying to detect the size of the screen I'm starting emacs on, and adjust the size and position the window it is starting in (I guess that's the frame in emacs-speak) accordingly. I'm trying to ...
111
votes
4
answers
30k
views
In Emacs Lisp, how do I check if a variable is defined?
In Emacs Lisp, how do I check if a variable is defined?
110
votes
2
answers
30k
views
emacs, unsplit a particular window split
I often want to unsplit window as follows:
+--------------+-------------+ +--------------+-------------+
| | | | | |
| ...
109
votes
8
answers
23k
views
How to determine operating system in elisp?
How do I programmatically determine which OS Emacs is running under in ELisp?
I would like to run different code in .emacs depending on the OS.
107
votes
12
answers
41k
views
Close all buffers besides the current one in Emacs
How do I close all but the current buffer in Emacs? Similar to "Close other tabs" feature in modern web browsers?
87
votes
2
answers
14k
views
Convert Symbol to a String in Elisp
How can I convert a symbol type into a string in Emacs lisp?
I wasn't able to find a symbol-to-string function or anything similar.
83
votes
11
answers
23k
views
Emacs - Error when calling (server-start)
I am currently using GNU Emacs 23.0.93.1 in Windows Vista SP1. In my .emacs file I make a call to (server-start) and that is causing an error with the message The directory ~/.emacs.d/server is unsafe....
83
votes
1
answer
19k
views
eval-after-load vs. mode hook
Is there a difference between setting things for a mode using eval-after-load and using the mode hook?
I've seen some code where define-key is used inside a major mode hook, and some other code where ...
81
votes
2
answers
20k
views
How can you write multiple statements in elisp 'if' statement?
In elisp, there is an 'if' case where I would like to perform many different things:
(if condition
(do-something)
(do-another-thing)
...)
However, (do-another-thing) is executed in the ...
79
votes
6
answers
32k
views
Command to clear shell while using emacs shell
Is there a builtin command to clear shell while using shell in emacs?
If not, is there an elisp function to achieve the same?
76
votes
3
answers
17k
views
Filtering text through a shell command in Emacs
In vi[m] there is the ! command which lets me pipe text through a shell command -- like sort or indent -- and get the filtered text back into the buffer. Is there an equivalent in emacs?
76
votes
3
answers
28k
views
How can I check if a file exists using Emacs Lisp?
I would like emacs to mark files that are generated as read-only when they're opened. The part of the puzzle that I'm missing is how to check if a file "exists". I currently have the following:
;;
;...
74
votes
15
answers
69k
views
How do I create an empty file in emacs?
How can I create an empty file from emacs, ideally from within a dired buffer?
For example, I've just opened a Python module in dired mode, created a new directory, opened that in dired, and now need ...
72
votes
8
answers
21k
views
What is the correct way to join multiple path components into a single complete path in emacs lisp?
Suppose I have variables dir and file containing strings representing a directory and a filename, respectively . What is the proper way in emacs lisp to join them into a full path to the file?
For ...
69
votes
5
answers
26k
views
How to debug elisp?
Normally the easiest way to debug is using printf. What can I do to debug emacs-lisp? How can I print something to emacs editor from elisp? Or is there any way to debug elisp code?
For example, how ...
65
votes
4
answers
22k
views
REPL for Emacs Lisp
What are some REPLs for Emacs Lisp?
Is there only one that is within Emacs?
Are there some that run inside terminal outside Emacs?
60
votes
7
answers
20k
views
emacs lisp, how to get buffer major mode?
I have tried to search Google and look in the manual, but still cannot find how to get major mode of a buffer object. Can you help me with an example or a reference. Thanks
only solution I could ...
59
votes
3
answers
40k
views
Concatenate strings in elisp
I need to concatenate path string as follows, so I added the following lines to my .emacs file:
(setq org_base_path "~/smcho/time/")
(setq org-default-notes-file-path (concatenate 'string ...
58
votes
10
answers
8k
views
How to live with Emacs Lisp dynamic scoping?
I've learned Clojure previously and really like the language. I also love Emacs and have hacked some simple stuff with Emacs Lisp. There is one thing which prevents me mentally from doing anything ...
57
votes
2
answers
23k
views
What are the major differences between Emacs Lisp and Common Lisp? [closed]
I want to learn the lisp language, since my editor is emacs, I prefer emacs lisp.
Can anyone give me some suggestions to learn lisp, emacs lisp, or common lisp?
What are the major differences ...
56
votes
9
answers
12k
views
emacs list-buffers behavior
In GNU emacs, every time I hit Ctrl-x Ctrl-b to see all of my buffers, the window is split to show the buffer list, or if I have my window already split in 2 (for instance, I will have a shell running ...
55
votes
3
answers
6k
views
How can I get Emacs to revert all unchanged buffers when switching branches in git?
Often, when I switch branches in git, if the files are open in emacs, then emacs asks if I want to revert them (as it thinks they've changed on disk) even though the contents are identical.
Firstly I'...
53
votes
29
answers
16k
views
What's in your .emacs?
I've switched computers a few times recently, and somewhere along the way I lost my .emacs. I'm trying to build it up again, but while I'm at it, I thought I'd pick up other good configurations that ...
52
votes
5
answers
5k
views
Confusing about the Emacs custom system
There are several similar setting functions:
set & setq
set-default
defcustom
custom-set-value
custom-set-variables
customize-set-value
customize-set-variable
so, what's the difference between ...
52
votes
10
answers
21k
views
How to modularize an emacs configuration?
I've decided to rewrite my .emacs from the ground up, and I want to setup something that's modular, in order to avoid a dreaded 1k+ LoC init.el file...
I think there are some basic concerns that each ...
51
votes
2
answers
18k
views
How to capture standard output of a shell command in elisp?
I want to run a shell command within Emacs and capture the full output to a variable. Is there a way to do this? For example, I would like to be able to set hello-string to "hello" in the following ...
51
votes
7
answers
17k
views
Ctrl+U in emacs when using evil key bindings
I'm using the wonderful evil package for vim bindings in emacs.
The one key that is not right is Ctrl+U. It is still the emacs prefix, rather than "up".
Does anybody have a solution for that in some ...
51
votes
3
answers
18k
views
Elisp List Contains a Value
How do you check, in elisp, if a list contains a value? so the following would return t:
(contains 3 '(1 2 3))
but
(contains 5 '(1 2 3))
would return nil.
51
votes
4
answers
13k
views
How can I check if a current buffer exists in Emacs?
I would like to write a function which takes action if a give buffer name already exists. For example:
(if (buffer-exists "my-buffer-name")
; do something
)
Does elisp have a function that ...
50
votes
2
answers
10k
views
emacs lisp call function with prefix argument programmatically
I want to call a function from some elisp code as if I had called it interactively with a prefix argument. Specifically, I want to call grep with a prefix.
The closest I've gotten to making it work ...
50
votes
9
answers
16k
views
Render Markdown in Emacs buffer
Is it possible to present Markdown rendered in an Emacs buffer using Emacs' own buffer text formatting capabilities? Emacs in graphical environments has rich text presentation capabilities (font ...
46
votes
3
answers
14k
views
Hiding markup elements in org-mode
There are plenty structural markup elements in org-mode like *bold* or /italic/, but they are visible in the org-mode text, which is good, if the file is intended for export, and bad, if it is ...
46
votes
4
answers
6k
views
Tips for profiling misbehaving Emacs Lisp?
I customize Emacs a lot. Recently, I added something to my .emacs configuration that sporadically pegs my CPU at 100%, but I really don't know what it is.
If I press C-g a bunch of times, eventually ...
45
votes
15
answers
16k
views
How to maximize Emacs on Windows at startup?
This is driving me crazy: I simply want Emacs to maximize to whatever screen resolution I have at startup. Ideally I like a cross-platform (Windows & Linux) solution that works on any screen ...
44
votes
6
answers
20k
views
Emacs comment/uncomment current line [duplicate]
I know there's already an Emacs question on this, and that it was closed, but I find it quite relevant and important.
Basically, I want to comment/uncomment the current line. I was expecting this to ...
44
votes
2
answers
19k
views
Get rid of "reference to free variable" byte-compilation warnings
I'm writing an emacs major mode, which uses buffer-local variables to store some state:
(defun foo-mode ()
"My nice major mode"
(interactive)
(kill-all-local-variables)
(setq mode-name "foo")
...
44
votes
4
answers
31k
views
How easily change font size in spacemacs?
How do change the font size in spacemacs? Do I need to download additional packages such as source code font?
I tried changing the font size in the configuration file, but the font size does not ...
44
votes
3
answers
13k
views
How to remove a key from a minor-mode keymap in Emacs?
I have globally assigned C-c/ to ace-jump-mode but reftex-mode (a minor mode for citations used with AucTeX) overrides this key with some function I never use.
I tried local-unset-key but it only ...
44
votes
3
answers
7k
views
When should Emacs #'function syntax be used?
Basically, when should I use Emacs Lisp's function procedure? I haven't found any examples in which there's a difference in behavior if you pass functions as arguments 'like-this or #'like-this. In ...
44
votes
4
answers
14k
views
elisp regexp search in strings, not buffers
I have been searching everywhere in the emacs lisp documentation for how to regular expressions search into a string. All I find is how to do this in buffers.
Is there something I'm missing? Should ...
43
votes
5
answers
13k
views
Bind key to increase / decrease font size in emacs
In my terminal (I have terminator) I can use the key combinations Ctrl + and Ctrl - to increase / decrease the font size.
In emacs I can do the following to set the font-height:
(set-face-attribute '...
43
votes
8
answers
26k
views
lisp filter out results from list not matching predicate
I am trying to learn lisp, using emacs dialect and I have a question.
let us say list has some members, for which predicate evaluates to false. how do I create a new list without those members? ...