Drew
  • Member for 7 years, 4 months
  • Last seen this week
Advantages of setting variables with setq instead of custom.el?
Accepted answer
104 votes

Some people might think it is simpler to use setq. Some people might think it is more lispy. In reality, it is naive in the general case. It is true that for some user options it does not matter. ...

View answer
What are the major features planned for GNU Emacs 25?
Accepted answer
66 votes

You have already installed a development build of (what will become) Emacs 25. (Emacs 25 has not yet been released.) So use C-h N to read the NEWS. It is specifically an outline description of all ...

View answer
How to disable auto-indentation of new lines?
Accepted answer
55 votes

Disable electric-indent-mode: (when (fboundp 'electric-indent-mode) (electric-indent-mode -1)) That works with any Emacs version. This annoyance or shiny-new-feature, depending on your point of view,...

View answer
How to replace an element of an alist?
46 votes

While @Dan's answer is a perfectly fine solution, it is unnecessary. One of the reasons Emacs uses an alist here is that with an alist you can simply add a new element to the front of the list and it ...

View answer
Current path in Dired or Dired+ to clipboard
Accepted answer
34 votes

Move the cursor to the directory header line (where the directory is shown - e.g., use M-<), then hit w. That copies the directory name to the kill ring. (w copies any file name from Dired, and it ...

View answer
what does "let*" ( let asterisk) mean in elisp
Accepted answer
30 votes

It means that when there is more than one binding the variables are bound sequentially, so that each can depend on the values bound to those that are bound before it, i.e., those that come before it ...

View answer
Match two spaces with incremental search
Accepted answer
30 votes

Use M-s SPC during Isearch to toggle matching whitespace literally. When matching literally, each SPC char you type is matched individually. (This used to be the default Emacs behavior, BTW.) To ...

View answer
Elisp for applying command to only the selected region
Accepted answer
30 votes

(defun some-function (beginning end) (interactive "r") (if (use-region-p) (message "The region is active, and is from %d to %d" beginning end) (message "The region is still there (from % ...

View answer
How to switch off the sounds?
Accepted answer
29 votes

Turn off the bell, use the visual bell instead, or replace bell-ringing by some other visual indication. You can set ring-bell-function to a function such as ignore, to just turn off all indication. ...

View answer
How do I clear a buffer completely with elisp?
Accepted answer
29 votes

Have you tried erase-buffer? erase-buffer is an interactive built-in function in `C source code'. (erase-buffer) Delete the entire contents of the current buffer. Any narrowing restriction in ...

View answer
What's the difference between push and add-to-list?
Accepted answer
28 votes

What #zck mentions is one difference. But if that were the only difference then you could ask about cl-pushnew and add-to-list. Another important difference: add-to-list is a function, which means ...

View answer
Convention about using C-x or C-c as prefix keys
Accepted answer
26 votes

If you are talking about binding keys for your own use, then this is the rule: You can bind any keys you like. If you want to be sure not to bind a key that might already be bound then use C-c ...

View answer
What's the difference between setq and defvar
Accepted answer
25 votes

You should ask Emacs this question: C-h i, choose the Elisp manual (m Elisp), and search the index for "defvar" (i defvar). That takes you to node Defining Variables. Emacs tells you that defvar ...

View answer
How to strip decorations (text properties) from a string?
Accepted answer
24 votes

[Your propertized string looks wrong - perhaps you copied it wrong. foo has only 3 characters, so it is impossible for it to be fontified on chars 0 to 4 (i.e., chars 0, 1, 2, and 3 - that's 4 chars)....

View answer
What was Emacs like back in the 80s?
Accepted answer
24 votes

Emacs predates GNU Emacs and thus predates Emacs Lisp. In most of the 80s, Emacs was only what we now call terminal-mode (and only one frame), and there was no mouse, menu-bar, tool-bar, fringe, ...

View answer
How to reset color theme?
Accepted answer
24 votes

Are you sure that you are using color themes and not Emacs custom themes? Color themes are defined by library color-theme.el. Custom themes are available starting with Emacs 24 - and they are not the ...

View answer
How to input special character, such as Celsius symbol, and common greek letters?
23 votes

The standard Emacs way to do this is C-x 8 RET followed by either the Unicode code point (a natural number) or the Unicode name of the character. Completion is available for the name. If you use ...

View answer
Is '(a . b) really a list?
Accepted answer
22 votes

It satisfies listp, so in that sense it is a list. listp just tests whether something is a cons or nil (aka ()), on the one hand, or something else, on the other hand. A proper list or true list (or ...

View answer
Programmatically insert files into Dired buffer
Accepted answer
21 votes

C-h f dired tells you the answer. Just pass to dired, as the DIRNAME argument, a list that has as its car the Dired buffer name you want (any string) and as cdr the list of file names you want listed ...

View answer
Function that returns parent directory absolute path
Accepted answer
20 votes

file-name-directory does what you request. However, (file-name-directory "/home/sk/parent/") (with a trailing slash) returns that same directory, not its parent. This does what I'm guessing you ...

View answer
Swap two variables in Elisp
20 votes

This is the elegant idiom I use ;-). (setq a (prog1 b (setq b a)))

View answer
Is there a function to insert the correct `(kbd "...")` by pressing the key?
Accepted answer
20 votes

Not sure exactly what you are asking. But C-h k followed by hitting the key shows you exactly what string you need to pass to kbd. For example, C-h k f6 shows you <f6>. Here is a command that ...

View answer
How can I see the changes made to a modified buffer since the last save?
18 votes

Command ediff-current-file: ediff-current-file is an interactive autoloaded Lisp function in `ediff.el'. (ediff-current-file) Start ediff between current buffer and its file on disk. This command ...

View answer
How to act on rectangles beyond the end-of-line?
18 votes

Another answer: use M-x picture-mode. You can kill or copy rectangles through the middle of tab chars etc., send them to registers, etc.

View answer
What is the usefulness of `exchange-point-and-mark`?
17 votes

Ask Emacs: C-h r i exchange-point-and-mark RET or, better, C-h r i C-x C-x RET. This takes you to the information shown below. This is what the Emacs manual, node Setting Mark says in answer to your ...

View answer
Elisp regexps ^ and $ vs ` and '
Accepted answer
16 votes

Your string might have an embedded newline character, in which case \' matches the end of the string but $ matches just before the newline char. To quote the Elisp manual, node Regexp Special: ...

View answer
How to use the calendar
16 votes

You ask a very general question about using this feature and how to find a detailed description of it, what its possibilities are, and how they work. The answer is to ask Emacs. Use C-h r to consult ...

View answer
What options are there for writing better non-programming text in Emacs?
16 votes

The EmacsWiki category Writing is the place to start. It lists dozens of libraries that support writing text using Emacs, with one-liner descriptions and links to the detail pages. There is no sense ...

View answer
Opening a new file whose parent directory doesn't exist yet
16 votes

You don't need to do that, if that's your question. C-x C-f /some/new/directory/newfile.txt Emacs prints a message to let you know that the directory /some/new/directory/ does not yet exist: Use M-x ...

View answer
How to select and delete a column of text in emacs?
15 votes

If you select the rectangle, which in Emacs terms means make it an active rectangular region, then C-w does just what you expect. Use C-x SPC to activate a rectangular region that you want to kill. ...

View answer
1
2 3 4 5
60