Subject: Special mode-class for diff-mode

From: Juri Linkov <[email-masked]>
Date: Sat, 01 Feb 2025 19:33:03 +0200

Tags: patch

Visiting a diff file and trying to copy lines with 'w' (diff-kill-ring-save)
does something unexpected since view-mode overrides 'w' with
'View-scroll-page-backward-set-page-size' for non-nil 'view-read-only'.

Here is the fix like for all modes that use single-letter keys:

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 77807fc4f35..b88dd4bf736 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1550,6 +1550,7 @@ diff-mode-read-only
 (defvar whitespace-style)
 (defvar whitespace-trailing-regexp)
 
+(put 'diff-mode 'mode-class 'special)
 ;;;###autoload
 (define-derived-mode diff-mode fundamental-mode "Diff"
   "Major mode for viewing/editing context diffs.