[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to visit a file and kill the current buffer?

From: Emanuel Berg
Subject: Re: How to visit a file and kill the current buffer?
Date: Sun, 10 Sep 2017 20:37:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Mario Castelán Castro wrote:

>> I think you are looking for
>> replace-buffer-contents, bound to C-x v
> I can neither find that function by name
> (“C-h f”) nor by invoking it directly with
> “M-x”.

I don't have that either and what's more for me
`C-x v' is a prefix key.

But anyway, why do you want to kill buffers?
You don't have to kill the old buffers just
because you open a new file!

You can do something like this (the below code)
- however, I strongly disencourage from doing
this, because it'll explode in your face
like instantly!

Just to take one example, remember that Emacs
isn't just about editing files. It is also
about running programs, for example Gnus,
a shell, or actually just about anything.
Because opening/finding files is so common,
it (the keyboard shortcut) will enter your
muscle memory and you will unintentionally kill
all kinds of buffers before long.


    (defun find-file-kill-buffer (filename &optional wildcards)
       (find-file-read-args "Find file: "
      (let ((buffer (current-buffer)))
        (when (find-file filename wildcards)
          (when buffer (kill-buffer buffer) ))))

underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]