GNU bug report logs - #54975
Allow editing diffs for conveniently fixing typos in the modified file right in the diff buffer

Previous Next

Package: emacs;

Reported by: emacsq <laszlomail <at> protonmail.com>

Date: Sat, 16 Apr 2022 18:12:01 UTC

Severity: wishlist

To reply to this bug, email your comments to 54975 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#54975; Package emacs. (Sat, 16 Apr 2022 18:12:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to emacsq <laszlomail <at> protonmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 16 Apr 2022 18:12:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: emacsq <laszlomail <at> protonmail.com>
To: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
Subject: Allow editing diffs for conveniently fixing typos in the modified
 file right in the diff buffer
Date: Sat, 16 Apr 2022 18:11:41 +0000
[Message part 1 (text/plain, inline)]
One of the main usage of diff is perusing changes before committing (commit commands usually pop up a diff buffer showing the changes) . When doing this one often finds typos, small things to fix in the diff, so one has to go back the file, fix it, do a diff/commit again to see the changes, etc.

To make this case more convenient, allow editing of diffs with the changes reflected in the original file.

The key 'e' is unused in diff mode, so like in occur it can turn on editing mode for the diff buffer. When the user edits the diff, the changes are reflected in the original file. C-c C-c ends the edit mode and also saves the the modified file, so the user doesn't have to manually switch to the file to save it, before committing, for example.

Here's a simple proof of concept code with advice which demonstrates the feature (going to to edit mode and saving are not included, only the reflection of the changes, so you have to toggle the diff buffer to writable first):

(advice-add 'diff-after-change-function :after 'my-diff-after-change-function)
;;(advice-remove 'diff-after-change-function 'my-diff-after-change-function)

(defun my-diff-after-change-function (start end len)
(ignore-errors
(if (eq len 0) ;; insertion
(if (eq ?- (char-after (line-beginning-position)))
(message "changes in deleted parts are not reflected")

(let ((text (buffer-substring-no-properties start end)))
(save-selected-window
(diff-goto-source)
(forward-char (- (length text)))
(insert text))))

;; deletion
(save-selected-window
(diff-goto-source)
(delete-char len)))))
[Message part 2 (text/html, inline)]

Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Tue, 07 Jun 2022 07:07:02 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 11 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.