From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: How to visit a file and kill the current buffer? Date: Sun, 10 Sep 2017 20:37:37 +0200 Message-ID: <86k216mmby.fsf@zoho.com> References: <82eece41-ee93-636c-1917-39462ce86106@yandex.com> <20170910172408.GC522@tuxteam.de> <8a2100c6-4859-5723-8ef7-a4a7e2607f7e@yandex.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1505068727 12113 195.159.176.226 (10 Sep 2017 18:38:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 10 Sep 2017 18:38:47 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Sep 10 20:38:42 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dr77g-00029j-Qy for geh-help-gnu-emacs@m.gmane.org; Sun, 10 Sep 2017 20:38:24 +0200 Original-Received: from localhost ([::1]:53912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr77o-0008SS-17 for geh-help-gnu-emacs@m.gmane.org; Sun, 10 Sep 2017 14:38:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr77O-0008SG-MK for help-gnu-emacs@gnu.org; Sun, 10 Sep 2017 14:38:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dr77J-0007vC-Qo for help-gnu-emacs@gnu.org; Sun, 10 Sep 2017 14:38:06 -0400 Original-Received: from [195.159.176.226] (port=35711 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dr77J-0007uM-Jt for help-gnu-emacs@gnu.org; Sun, 10 Sep 2017 14:38:01 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dr772-0000EL-3W for help-gnu-emacs@gnu.org; Sun, 10 Sep 2017 20:37:44 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 43 Original-X-Complaints-To: usenet@blaine.gmane.org Mail-Copies-To: never Cancel-Lock: sha1:q3g2Hf7BlQsOsuLJrhknq9Upu3s= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114234 Archived-At: 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