From 6880ea7d2280968014603ad23f753fa50f345c76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sat, 2 Sep 2023 10:51:24 +0100 Subject: [PATCH] Eglot: slightly simplify eglot--propose-changes-as-diff bug#60338 * lisp/progmodes/eglot.el (eglot--propose-changes-as-diff): Simplify slightly. --- lisp/progmodes/eglot.el | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 586d532efc3..2bc5351145d 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3480,28 +3480,21 @@ of PREPARED, ready to apply with C-c C-a. PREPARED is a list ((FILENAME EDITS VERSION)...)." (with-current-buffer (get-buffer-create "*EGLOT proposed server changes*") (buffer-disable-undo (current-buffer)) - (let ((buffer-read-only t)) - (diff-mode)) (let ((inhibit-read-only t) (target (current-buffer))) + (diff-mode) (erase-buffer) (pcase-dolist (`(,path ,edits ,_) prepared) (with-temp-buffer (let* ((diff (current-buffer)) (existing-buf (find-buffer-visiting path)) (existing-buf-label (prin1-to-string existing-buf))) - ;; `existing-buf' might be an unsaved buffer, so we do - ;; this complicated little dance to diff it with a - ;; temporary file with the proposed changes applied. (with-temp-buffer (if existing-buf - (let ((temp (current-buffer))) - (with-current-buffer existing-buf - (copy-to-buffer temp (point-min) (point-max)))) + (insert-buffer-substring existing-buf) (insert-file-contents path)) (eglot--apply-text-edits edits nil t) - (diff-no-select (or existing-buf path) (current-buffer) - nil t diff) + (diff-no-select (or existing-buf path) (current-buffer) nil t diff) (when existing-buf ;; Here we have to pretend the label of the unsaved ;; buffer is the actual file, just so that we can -- 2.39.2