unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to visit a file and kill the current buffer?
Date: Sun, 10 Sep 2017 20:37:37 +0200	[thread overview]
Message-ID: <86k216mmby.fsf@zoho.com> (raw)
In-Reply-To: 8a2100c6-4859-5723-8ef7-a4a7e2607f7e@yandex.com

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.

Still,

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

-- 
underground experts united
http://user.it.uu.se/~embe8573




  reply	other threads:[~2017-09-10 18:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-10 17:13 How to visit a file and kill the current buffer? Mario Castelán Castro
2017-09-10 17:24 ` tomas
2017-09-10 17:48   ` Mario Castelán Castro
2017-09-10 18:37     ` Emanuel Berg [this message]
2017-09-10 19:14       ` tomas
     [not found]       ` <mailman.265.1505070877.14750.help-gnu-emacs@gnu.org>
2017-09-10 22:13         ` Emanuel Berg
2017-09-10 18:01 ` Eli Zaretskii
2017-09-10 18:18   ` Drew Adams
2017-09-10 18:16 ` Drew Adams
     [not found] <mailman.245.1505063646.14750.help-gnu-emacs@gnu.org>
2017-09-10 18:15 ` Marco Wahl
2017-09-10 18:27   ` Mario Castelán Castro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86k216mmby.fsf@zoho.com \
    --to=moasen@zoho.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).