emacs-devel
[Top][All Lists]
Advanced

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

Re: rename buffer but overwrite already existing one


From: Uwe Brauer
Subject: Re: rename buffer but overwrite already existing one
Date: Mon, 23 Mar 2020 20:43:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>>> "AS" == Andreas Schwab <address@hidden> writes:

   > On Mär 23 2020, Uwe Brauer wrote:
   >>>>> "EZ" == Eli Zaretskii <address@hidden> writes:
   >> 
   >> >> From: Uwe Brauer <address@hidden>
   >> >> Date: Mon, 23 Mar 2020 19:05:23 +0100
   >> >> 
   >> >> Couldn't rename-buffer, optionally, overwrite the content of a buffer.
   >> 
   >> > Yes, but it's called copy-to-buffer, not rename-buffer.
   >> 
   >> Thanks for pointing this out to me, but I have to mark the whole buffer
   >> first, which is a but inconvenient, I say.
   >> 
   >> Couldn't there an argument added so that with the argument the whole
   >> buffer is copied?

   > It's easy to define your own function that calls copy-to-buffer with
   > (point-min), (point-max).

That is what I thought

(defun my-copy-to-buffer (buffer)
  "Copy to specified BUFFER the whole buffer."
  (interactive "BCopy to buffer: \n")
  (let ((oldbuf (current-buffer)))
    (with-current-buffer (get-buffer-create buffer)
      (barf-if-buffer-read-only)
      (erase-buffer)
      (save-excursion
        (insert-buffer-substring oldbuf (point-min) (point-max))))))


Does not work zero bytes where copied, there is something I miss, obviously.

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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