From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: emacsq Newsgroups: gmane.emacs.help Subject: Re: editing a VC diff to modify the current version Date: Fri, 25 Feb 2022 16:19:01 +0000 Message-ID: References: Reply-To: emacsq Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25439"; mail-complaints-to="usenet@ciao.gmane.io" To: emacsq via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 25 17:21:42 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNdLh-0006Hv-5F for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 25 Feb 2022 17:21:41 +0100 Original-Received: from localhost ([::1]:40982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNdLg-0006wE-2W for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 25 Feb 2022 11:21:40 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNdJE-0005I4-Po for help-gnu-emacs@gnu.org; Fri, 25 Feb 2022 11:19:09 -0500 Original-Received: from mail-40130.protonmail.ch ([185.70.40.130]:22442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNdJC-0000rN-8K for help-gnu-emacs@gnu.org; Fri, 25 Feb 2022 11:19:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1645805942; bh=CnI7nbbJXDSkPeL0PZn4c2SiMuqmoXSU0u8R9c//NYQ=; h=Date:To:From:Reply-To:Subject:Message-ID:In-Reply-To:References: From:To:Cc:Date:Subject:Reply-To:Feedback-ID:Message-ID; b=IHPEtHcqUidbs4dQv3ozOgdJCJiFVgjtbmnptGHzEgK+kaA6s/kqpJhx17o1q15SI i3xQWJ9SYYVyuoTwFdz+PoZ17I5h6HtvTIH0yGxTnE5fX6IpDWXMVBoL6CmMSvwX6y Jg7d8wStndZvOiEtPzy+ljvz1HtmrhJl5S+rXEbx3lfFa0DO7N9c8oepnB60ahCZBq G/AW1jY4+vD1lKJmGQlTM6puuVt1PLDptXZRtCk7HyCn9V8Uqruhp0n/VbIBSBOhbz sShXh6j59EA+wsu5QHUaudEJNWmYZlCllaGfAC60vwaWexxaG0+PYxvqDzpbE12PgY PN3o6DBeX9a1A== In-Reply-To: Received-SPF: pass client-ip=185.70.40.130; envelope-from=laszlomail@protonmail.com; helo=mail-40130.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:136187 Archived-At: > > With vscode you can actually edit the diff and the changes are > > reflected back to the current version, so you don't have to go back to > > the file, do the modifications, make a diff again to see everything is > > right, etc. > > Sounds like a great feature. Here's a quick hack for emacs. If you activate this then after making the diff editable you can make simple fixes in the diff and they are reflected back to the current file. Adding newlines doesn't seem to work, but fixing typos, making edits within lines do. If one mainly uses diffs to review changes before committing then automatic saving of the current file can also be added, so one doesn't have to go back to the file just to save the changes made in the diff. (advice-add 'diff-after-change-function :after 'my-diff-after-change-functi= on) ;;(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)))))