all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Juri Linkov <juri@linkov.net>
Cc: 65854@debbugs.gnu.org
Subject: bug#65854: Multi-file replacement diff
Date: Sun, 10 Sep 2023 19:58:10 +0200	[thread overview]
Message-ID: <m1fs3lewr1.fsf@eshelyaron.com> (raw)
In-Reply-To: <86sf7mgd54.fsf@mail.linkov.net> (Juri Linkov's message of "Sun,  10 Sep 2023 20:18:47 +0300")

Hi there,

Juri Linkov <juri@linkov.net> writes:

> +(defun multi-file-replace-as-diff (files-or-buffers from-string replacements regexp-flag delimited-flag)
> +  (require 'diff)
> +  (let ((inhibit-message t)
> +        (diff-buffer (get-buffer-create "*replace-diff*")))
> +    (with-current-buffer diff-buffer
> +      (buffer-disable-undo (current-buffer))
> +      (let ((inhibit-read-only t))
> +        (erase-buffer))
> +      (diff-mode))
> +    (dolist (file-or-buffer files-or-buffers)
> +      (let ((file-name (if (bufferp file-or-buffer) buffer-file-name file-or-buffer)))
> +        (when file-name
> +          (with-temp-buffer
> +            (if (bufferp file-or-buffer)
> +                (insert-buffer-substring file-or-buffer)
> +              (insert-file-contents file-or-buffer))

I wonder what happens if I call `multi-file-replace-regexp-as-diff` and
select a file `foo.txt`, that I already have open and modified in a
buffer.  IIUC, this will generate the diff based on the contents of the
file on disk, not the buffer, so it might not match when I subsequently
try to apply the diff to the buffer.  WDYT?


Eshel






  reply	other threads:[~2023-09-10 17:58 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-10 17:18 bug#65854: Multi-file replacement diff Juri Linkov
2023-09-10 17:58 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-09-11  6:33   ` Juri Linkov
2023-09-11  7:23     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11  7:38       ` Juri Linkov
2023-09-12  6:49         ` Juri Linkov
2023-09-11 12:35       ` Eli Zaretskii
2023-09-12  6:52         ` Juri Linkov
2023-09-15  6:40           ` Juri Linkov
2023-09-15  7:02             ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-15  7:38             ` Eli Zaretskii
2023-09-22  6:55               ` Juri Linkov
2023-09-22  7:25                 ` Eli Zaretskii
2023-09-22 16:02                   ` Juri Linkov
2023-09-22 16:06                     ` Eli Zaretskii
2023-09-23 17:36                       ` Juri Linkov
2023-09-23 18:56                         ` Eli Zaretskii
2023-09-24  7:37                           ` Juri Linkov
2023-09-24  8:12                             ` Eli Zaretskii
2023-09-25 18:18                               ` Juri Linkov
2023-09-24  1:43 ` Dmitry Gutov
2023-09-24  7:36   ` Juri Linkov
2023-09-24 11:09     ` Dmitry Gutov
2023-09-25 17:58       ` Juri Linkov
2023-09-26 21:39         ` Dmitry Gutov
2023-09-27 17:21           ` Juri Linkov
2023-09-30 17:42           ` Juri Linkov

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

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

  git send-email \
    --in-reply-to=m1fs3lewr1.fsf@eshelyaron.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=65854@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=me@eshelyaron.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.