Hot answers tagged

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 ...
sds's user avatar
  • 6,104
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 ...
Stefan's user avatar
  • 26.3k
18 votes

Spacemacs: kill buffer and kill window in one command?

spacemacs binding for kill-buffer-and-window: Cx,4,0
sjas's user avatar
  • 301
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.
Name's user avatar
  • 7,809
17 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.
Wilfred Hughes's user avatar
14 votes
Accepted

Insert into specific buffer (not the active buffer)?

Perhaps something like: (with-current-buffer "*scratch*" (insert "Test")) is what you want.
John Kitchin's user avatar
  • 11.8k
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.
user2739472's user avatar
13 votes

Meaning of CRM column in buffer list from `C-x C-b`?

`C' shows `>' if you have marked the buffer to be displayed, `D' if you have marked it for deletion, and `.' for the buffer from which you came (current). `R' shows `%' if the ...
Drew's user avatar
  • 77k
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 ...
Kaushal Modi's user avatar
  • 25.6k
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/...
Stuart Hickinbottom's user avatar
11 votes

How to persistently move the cursor in a buffer other than the current one?

This was a pretty cool question, I learned a lot that I didn't know while trying to figure this out. What I learned was that each window has its own value for point. This is important because it means ...
Jules's user avatar
  • 1,225
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 ...
glucas's user avatar
  • 20.5k
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 ...
Stefan's user avatar
  • 26.3k
10 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 ...
Vera Johanna's user avatar
9 votes

How do I do live Markdown previewing as I'm writing it?

As of markdown-mode 2.1, this is functionality is provided in markdown-live-preview-mode (bound to C-c C-c l). It uses eww for rendering the HTML. Screenshot:
Wilfred Hughes's user avatar
9 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 ...
aplaice's user avatar
  • 2,156
9 votes
Accepted

org-babel result to a separate buffer

I've looked through documentation but it seems like there's no such option. Surprising that org does not offer :output buffer option. Maybe this is in the works for future org versions. ... place ...
Emacs User's user avatar
  • 5,633
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.
sid-kap's user avatar
  • 544
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-...
sds's user avatar
  • 6,104
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-...
glucas's user avatar
  • 20.5k
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 ...
phils's user avatar
  • 50.4k
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. ...
phils's user avatar
  • 50.4k
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 ...
Y. E.'s user avatar
  • 765
8 votes

Kill process buffer without confirmation?

Or the simpler one would be : (setq kill-buffer-query-functions nil) Inspired from abo-abo config
azzamsa's user avatar
  • 634
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 ...
mclear's user avatar
  • 1,535
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 ...
InHarmsWay's user avatar
  • 1,319
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) "...
mithos's user avatar
  • 81
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 ...
Eduardo Ochs's user avatar
7 votes

How to persistently move the cursor in a buffer other than the current one?

(Jules Tamagnan's answer identifies the problem, I'll expand on it.) Your solutions with save-excursion or save-excursion do in fact work! You can see it by checking the value of (point) in that ...
Gilles 'SO- stop being evil''s user avatar

Only top scored, non community-wiki answers of a minimum length are eligible