From: João Távora Date: Sat, 2 Sep 2023 09:51:24 +0000 (+0100) Subject: Eglot: slightly simplify eglot--propose-changes-as-diff X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6880ea7d2280968014603ad23f753fa50f345c76;p=emacs.git Eglot: slightly simplify eglot--propose-changes-as-diff bug#60338 * lisp/progmodes/eglot.el (eglot--propose-changes-as-diff): Simplify slightly. --- 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