bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#65854: Multi-file replacement diff


From: Eshel Yaron
Subject: bug#65854: Multi-file replacement diff
Date: Sun, 10 Sep 2023 19:58:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

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 via email to

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