28
votes
Accepted
Why is (point-min) much more popular than 1?
How do you know that the buffer is not narrowed?
Unless you have widened it right before you called the function, you cannot be sure.
Moreover, "great software" is often defined as "being used in ...
18
votes
How do I find text across many open buffers?
swiper-all from the swiper package provides a tool for doing this. It's even incremental, so it updates as you type.
18
votes
Why is (point-min) much more popular than 1?
To complement sds's answer (with which I fully agree), despite appearances, (point-min) can be more efficient than 1. In terms of execution speed, my tests don't see any measurable difference, but in ...
18
votes
Spacemacs: kill buffer and kill window in one command?
spacemacs binding for kill-buffer-and-window:
Cx,4,0
18
votes
Find position in file by character number
Depending on what is that number, e.g., 47 (line, character-position, etc) you can do M-x goto-line 47 or M-x-goto-char 47.
15
votes
Accepted
Insert into specific buffer (not the active buffer)?
Perhaps something like:
(with-current-buffer "*scratch*" (insert "Test"))
is what you want.
14
votes
how to name buffers (*shell*)
Go to the buffer you want to rename, in your case *shell*. Then type M-x rename-buffer and enter the new name for this buffer.
13
votes
Accepted
Revert all open buffers (and ignore errors)
Original
Here is my slightly improved version of the snippet in the question. Reviewing my VC history, I confirm that the below snippet started out as the snippet posted by the OP. So I do pay ...
12
votes
Accepted
How to add a timestamp to each entry in Emacs' *Messages* buffer?
I have the following snippet in my init.el, which was adapted from an original I found in the following Reddit thread:
http://www.reddit.com/r/emacs/comments/16tzu9/...
11
votes
Accepted
How to check, if a file is already visited?
(get-file-buffer filename) returns the buffer visiting filename, or nil if there is none.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-File-Name.html
Edit: justbur proposes using ...
11
votes
Accepted
How can I kill all unmodified buffers / files and delete their related frames?
One way would be to use ibuffer:
Open ibuffer (I have it bound to a key, but M-x ibuffer will work.)
Mark all modified buffers: * m
Toggle the marks, so that unmodified buffers are marked instead: t
...
10
votes
Set column widths in `ibuffer`
If what you care about is seeing the entire buffer-name column, specifically, you can do it without "customising" anything, by using ibuffer-switch-format, bound to ` within ibuffer.
The function ...
10
votes
Accepted
`switch-to-buffer` vs. `pop-to-buffer-same-window`
The difference is that pop-to-buffer-same-window doesn't insist as much about using the same window.
Historically, switch-to-buffer has been used for 2 purposes:
change which buffer is shown in the ...
10
votes
Accepted
Removing buffers from buffer list
Given you have multiple buffers open, use
C-x C-b
to open the buffer list. You will be given a nice list of all the buffers currently in memory. Make sure you have the current window that displays ...
9
votes
Accepted
Spacemacs: kill buffer and kill window in one command?
Spacemacs has recently added two shortcuts for kill-buffer-and-window: SPC b x and SPC w x.
9
votes
Accepted
How to insert a formatted string into a specific buffer?
An example of what you are trying to do is contained in the manual.
You need either with-current-buffer or save-current-buffer:
(with-current-buffer destination-buffer
(insert (propertize (format-...
9
votes
Accepted
how to open all files from specific path as read-only buffer
You can also do this using using dir locals and associating one or more directories with a directory class. For example:
;; Define a read-only directory class
(dir-locals-set-class-variables 'read-...
9
votes
Accepted
Remapping C-x C-b to Open List of Buffers in Same Window
I highly recommend using ibuffer in place of the default list-buffers command. This will provide not only the behaviour you're after, but also a tremendous amount of additional functionality in terms ...
9
votes
Accepted
How can I kill buffers based on mode?
You can use M-x ibuffer which I recommend binding to C-xC-b to replace the default (or whatever binding you prefer).
Use %m to mark buffers by matching a regexp against the displayed mode-name (e.g. ...
9
votes
Accepted
Automatically Uniquify Certain Buffers
Since Emacs 28.1, customize uniquify-buffer-name-style user option:
** User option 'uniquify-buffer-name-style' can now be a function.
This user option can be one of the predefined styles or a ...
8
votes
Kill process buffer without confirmation?
Or the simpler one would be :
(setq kill-buffer-query-functions nil)
Inspired from abo-abo config
8
votes
Spacemacs: kill buffer and kill window in one command?
Use kill-buffer-and-window to close a buffer and its window. But this will keep emacs running. If you also want to kill emacs (the equivalent of :q) then try evil-quit-all if you're using evil, and ...
8
votes
Accepted
Dired-like browser for buffers?
What you want is built-in to emacs. Put (require 'ibuffer) in your config file, then bind a key to 'ibuffer:
(global-set-key "\C-x\C-b" 'ibuffer)
Be sure to check out its help documentation. It has ...
8
votes
How to add a timestamp to each entry in Emacs' *Messages* buffer?
The translation of @xinfatang's simple solution to the new advice-add syntax as a wrapper around the message function is:
(defun my-message-with-timestamp (old-func fmt-string &rest args)
"...
8
votes
Accepted
How to make "M-x man" buffers use all the available width of the screen?
Try (setq Man-width-max 160), or (setq Man-width-max nil).
The documentation of Man-width-max says:
This variable was introduced, or its default value was changed, in
version 27.1 of Emacs.
Maximum ...
8
votes
Accepted
Filter text of buffer in a grep-like way
I want the text not matching the pattern to be gone
M-x keep-lines will delete lines not matching the pattern (i.e. only keep the lines which match). flush-lines does the opposite, deleting lines ...
7
votes
Accepted
How to track user changes in the buffer?
To react to buffer changes, you generally want to use after-change-functions (or sometimes before-change-functions).
These hooks are run everytime some part of the buffer is modified, either by ...
7
votes
Accepted
Simple method for creating multiple eww buffers
You are correct that eww does not automatically create new buffers for you. But I have been using this trick from ergoemacs.org and it works great!
With the below eval'ed, each time you do M-x eww ...
7
votes
Accepted
How to make emacs automatically kill buffer after invoking delete-file command?
I wrote this method, which differs slightly from the one in the other answer:
(defun delete-file-visited-by-buffer (buffername)
"Delete the file visited by the buffer named BUFFERNAME."
(...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
buffers × 597window × 81
frames × 45
files × 43
org-mode × 23
helm × 21
window-splitting × 20
kill-buffer × 20
hooks × 17
init-file × 16
emacsclient × 15
dired × 14
major-mode × 14
debugging × 12
start-up × 11
ido × 11
spacemacs × 10
shell × 9
saving × 9
ibuffer × 9
faces × 8
minibuffer × 8
commands × 8
find-file × 8
customize × 7