Frequent Questions
3,237 questions
42
votes
2
answers
8k
views
How to evaluate the variables before adding them to a list?
The below obviously doesn't work and hence this question.
How do I correct the below code so that the value of somelist becomes '(("abc" . 123)) ?
(setq x "abc")
(setq y 123)
(setq somelist nil)
(...
42
votes
6
answers
18k
views
Problems with keybindings when using terminal
I have the following line in init.el:
(global-set-key [(control \;)] 'comment-region)
It works very well in GUI window, but if emacs is invoked with the -nw option then C-; doesn't comment region, ...
26
votes
1
answer
5k
views
How do I troubleshoot Emacs problems?
In a situation where Emacs is not behaving like I want, what can I do to troubleshoot the problem? What steps can I take to find and fix the problem myself?
Or, failing that, how can I gather useful ...
44
votes
1
answer
4k
views
What is the difference between a function and a command?
When posting questions and answers here, people sometimes use the terms "function" and "command" interchangeably. In other cases, people only use one of the two terms to discuss specific pieces of ...
36
votes
1
answer
6k
views
Why do regular expressions created with the regex builder use syntax different from the interactive regular expressions?
So, using the regular expression builder (M-x re-builder), finding lines that end in \ takes "\\$", while in search and replace by regex, it only takes "\$". I would have expected the regex builder ...
63
votes
12
answers
9k
views
Synchronize packages between different machines
I use emacs in different places and I want to have a similar setup and packages installed everywhere. I guess I can use a version control repository for the setup files. Since I use Prelude, that ...
57
votes
6
answers
16k
views
How to override major mode bindings
Sometimes my global keybindings are overridden by a major mode. An easy example is the following setting in my init file
(global-set-key (kbd "C-j") 'newline-and-indent)
But annoyingly this ...
46
votes
2
answers
10k
views
What's the difference between a buffer, a file, a window, and a frame?
When posing questions on this site, people sometimes talk about "windows" when they mean "frames," and "buffers" or "files" when they mean "windows." So:
Q: What is the difference between a buffer, ...
73
votes
5
answers
20k
views
How can I find out in which keymap a key is bound?
I have rebound a the 'd' key in gnus-article-mode, but its old behavior is still active when the point is on an attachment. I can see that the rebinding did not take effect there by doing C-h k d, but ...
10
votes
1
answer
2k
views
How to get the raw data for an org-mode agenda without an agenda view?
Q: How can I have org-mode return the raw data for an agenda view without actually creating an agenda view?
I'd like to access my agenda for an arbitrary day. However, I do not want to create an ...
9
votes
2
answers
4k
views
How to modify-face for a specific buffer?
I work with a lot of tabular data files and use stripe-buffer.el make them easier to read. But I also work with more than one, so I'd like to make it easier to distinguish among them as well and want ...
20
votes
2
answers
4k
views
How to bind C-i as different from TAB?
I want to make Control-i perform indent-region (basically since Xcode has built that muscle memory already).
I realise that Control-i and tab are indistinguishable in the Ascii sense, but they are in ...
37
votes
5
answers
5k
views
Is there a way to use query-replace from grep/ack/ag output modes?
I'm aware of find-grep-dired, marking the corresponding files and then pressing Q to run dired-do-query-replace-regexp on the marked files. Unfortunately that requires restarting the grep and no ...
23
votes
3
answers
5k
views
A faster method to obtain `line-number-at-pos` in large buffers
The function line-number-at-pos (when repeated about 50 times) is causing a noticeable slow-down in semi-large buffers -- e.g., 50,000 lines -- when point is near the end of the buffer. By slow-down, ...
15
votes
3
answers
7k
views
Shift+Up isn't recognized by Emacs in a terminal
Very often I use Shift+Up/Down to select a region in Emacs. It works fine in GUI mode, but when emacs is invoked with -nw option I can select lines only with Shift+Down. The Shift+Up doesn't work, I ...
5
votes
2
answers
2k
views
Defining key-bindings within `helm-map`: getting a `void-variable helm-map` error
Am going through this Helm tutorial at the moment; I pasted in the code verbatim (for now, I'll adapt it to suit my preferences later).
I did a quick google search for this particular error but it ...
91
votes
5
answers
22k
views
Advantages of setting variables with setq instead of custom.el?
I see a lot of people (extension authors and others) give configuration examples with setq:
(setq foo 'bar)
These parameters are often defined with defcustom, making them available for customization ...
33
votes
2
answers
7k
views
Is it possible to export content of subtrees without their headings?
I draft documents in org-mode and export them to LaTeX, HTML, etc. as needed. I frequently use the tag :no_export: whenever I don't want a certain subtree to show up in the output.
What I also want ...
25
votes
5
answers
16k
views
Browser-style 'tabs' for emacs?
I would like tabs like firefox but for emacs.
I found this: http://emacswiki.org/emacs/TabBarMode
But it just add to each buffer (window in Emacs terminology) a bar that shows currently open buffers....
19
votes
3
answers
9k
views
Why do I have to add each package to load-path? (or Problem with require 'package in my init file)
Each time I install a package from the Package Menu, if I try to require it in my init file I get an error unless I manually add it to the load-path:
(add-to-list 'load-path "/home/nick/.emacs.d/elpa/...
13
votes
1
answer
672
views
Why does a constant in `let` change with repeated calls? [duplicate]
Say we have such a foo function:
(defun foo (e)
(let ((lst '(a b c)))
(delq e lst)))
Then we use it in following way (sequentially evaluating one by one):
(foo 'c) ; => (a b)
(foo 'b) ; =&...
65
votes
4
answers
10k
views
Debugging a frozen Emacs
I am using mew for my e-mail. I need to use TLS with my email provider for SMTP. However, when I try to invoke that, Emacs freezes.
I would like to take this opportunity to learn more about Emacs ...
22
votes
2
answers
4k
views
When should sharp quotes be used?
I see sharp quotes being used in other people's eLisp code, and I use them myself, but I'm not completely clear on when they are appropriate and when not.
Could anyone clarify on exactly when it's ...
16
votes
1
answer
3k
views
Why can't I bind my function to a key or call it with M-x?
I wrote a function, and I want to call it via M-x, and bind it to a key. This is my function:
(defun my-function ()
(message "This is a great function"))
If I try to call it with M-x my-function,...
6
votes
2
answers
1k
views
How to define a function that calls a console process using ansi-term?
I'm using Julia within emacs, and I've found that despite the existence of ess and julia-mode, the best way for me to do that seems to be to use ansi-term and execute:
ipython3 console --kernel=julia-...
108
votes
12
answers
19k
views
How do I prevent extremely long lines making Emacs slow?
I see hugely varied performance depending on how many newlines there are in the file I'm visiting.
Here's an example. I have two JSON files:
$ wget https://github.com/Wilfred/ReVo-utilities/blob/...
19
votes
3
answers
1k
views
How to collapse undo history?
I'm working on an Emacs mode that lets you control Emacs with speech recognition. One of the problems I've ran into is that the way Emacs handles undo doesn't match how you would expect it to work ...
13
votes
1
answer
3k
views
How to apply `call-interactively` to an interactive command that accepts the universal argument?
I've read the documentation on how to make interactive calls from within Elisp, but I still can't figure out how to pass the universal argument when using call-interactively on a command that ...
4
votes
1
answer
818
views
How to create a new buffer with ivy-switch-buffer that shares a substring with an existing buffer?
Suppose I have a file opened called "analysis-evaluation.tex" and I'd like to create a new buffer called "eval". When using Ido, I would press C-j to create a new buffer rather than switching to an ...
57
votes
3
answers
17k
views
Inline verbatim and code with quotes in Org-mode
In Org-mode I can surround text with = or ~ to place text in inline verbatim or code mode.
However this fails if the text has quotes, and I couldn't find an explanation or workaround in the ...
31
votes
1
answer
42k
views
How to use pdf-tools (pdf-view-mode) in emacs?
pdf-tools includes pdf-view-mode which offers several features not present in doc-view-mode (see end of question).
Can pdf-view-mode be used as a replacement for doc-view-mode generally, or does it ...
29
votes
1
answer
18k
views
How to highlight text permanently in org-mode
I know I can use *bold*, /italic/, _underlined_, =verbatim= and ~code~, and, if you must, ‘+strike-through+’ to do some markup to text according to org-mode documentation, but they are not enough for ...
19
votes
1
answer
10k
views
how do I quickly remove lines from emacs buffer
In an emacs buffer when editing a file called "log/development.log"
how do I quickly remove all lines containing the word "Render"
18
votes
1
answer
4k
views
How do I debug an emacs crash?
I am debugging why emacs crashes when using a function from a package1. The aim of this debug process is to get useful data to submit using M-x report-emacs-bug.
To get help on how to debug emacs ...
11
votes
2
answers
6k
views
How to set emacs frame size by pixels
I can resize the emacs frame to whatever size by mouse, is there a way that the frame size be set in init.el by pixels? Or anything similar in the window manager?
10
votes
3
answers
2k
views
how to get Emacs to locate the error in my init file without relaunching?
When there's an error in one of my init files, I get a vague message like this when I launch Emacs:
Warning (initialization): An error occurred while loading /Users/im/.emacs.d/init.elc:
(wrong-type-...
9
votes
1
answer
2k
views
When to use quote for lists? Modifying quoted lists in Elisp
The Common Lisp Hyper Spec says:
The consequences are undefined if literal objects (including quoted objects) are destructively modified.
This is further motivated at the Constant Modification ...
113
votes
3
answers
39k
views
How to Restore File System Access in macOS Catalina
I updated to macOS Catalina which requires the user through pop-ups to allow any app trying to access the file system for the first time.
No such pop-up is appearing for Emacs. Running the script ...
55
votes
4
answers
4k
views
Practical benefits of new advice system in Emacs 24.4
Emacs 24.4 comes with a new advice system. The NEWS file says:
** New package nadvice.el offers lighter-weight advice facilities.
It is layered as:
*** add-function/remove-function, which ...
52
votes
8
answers
14k
views
How to treat underscore as part of the word?
I use Emacs + evil mode.
When I position the cursor on e (in normal state) in a chunk of text such as abc_def_ghi, ciw (change inner word) changes only the def part of the string, while Vim would ...
36
votes
4
answers
5k
views
When to sharp-quote a lambda expression?
Q: When, if ever, is it useful to sharp-quote a lambda, and when, if ever, must we not sharp-quote a lambda?
People use lambdas in three ways:
plain: (lambda (x) x)
quoted: '(lambda (x) x)
sharp-...
21
votes
1
answer
7k
views
What is the difference between TAB and <tab>?
I was reading the the documentation for Yasnippet mode, when I came to the section where the trigger key is defined:
It seems like Yasnippet minor mode defines the TAB key to run yas-expand using:
(...
14
votes
3
answers
7k
views
How i can open shell in current buffer?
In function "shell" this line display shell buffer and almost always its open new shell in random frame. And I have to swap the buffers, it's annoying.
...
(pop-to-buffer buffer)
...
In docs says:
...
13
votes
3
answers
3k
views
org-refile to a known fixed location
I'm trying to write a function that will take a heading and refile it to one specific location. The doc for org-refile is
(org-refile &optional GOTO DEFAULT-BUFFER RFLOC MSG)
and RFLOC is
RFLOC ...
11
votes
5
answers
3k
views
Avoiding overwriting global key bindings
Okay, this is a persistent problem for me. As I continue to use emacs more and more, I'm starting to customize it to my needs by installing the packages(and/or defining functions) and the one big ...
10
votes
3
answers
5k
views
Emacs bind key to prefix
suppose I want to bind a key to a partial key sequence (i.e. a key sequence that is a prefix of some other bound keybindings).
I've tried the obvious
(global-set-key (kbd "C-x C-x") (kbd "C-c"))
...
10
votes
2
answers
4k
views
How to build Emacs master branch (aka trunk) on MS-Windows
I took the plunge today and started out on my quest to build the most recent Emacs master branch developer build -- aka Emacs Trunk -- for MS-Windows.
I found an old blog and went through the ...
7
votes
1
answer
866
views
Multiple major modes in one buffer (e.g., python-mode & LaTeX-mode)
Using the LaTeX-package pythontex I one can insert python code into the latex document which is executed (and printed to your latex file if you want) if you run latex. I use auctex for editing latex ...
57
votes
9
answers
36k
views
Using Emacs as a full-featured C/C++ IDE
I have been trying off and on for over a year now to use Emacs as a C/C++ IDE. I have only been marginally successful thus far, but have run into a few brick walls along the way. Currently I am ...
56
votes
3
answers
6k
views
How to save a keyboard macro as a Lisp function?
Very frequently I would need to perform the set of steps requiring multiple key strokes. For the same session those steps can be recorded in a keyboard macro.
An example is saving a frequently ...