unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8284: 24.0.50; M-q badly bound in diff-mode
@ 2011-03-18 14:18 Julien Danjou
  2011-03-18 19:19 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Danjou @ 2011-03-18 14:18 UTC (permalink / raw)
  To: 8284

Hi there,

The `diff-mode' keymap `diff-mode-shared-map' inherit from
`special-mode-map' which defines M-q as `quit-window'.

This is *very* annoying when editing diff file build with
git-format-patch. I sometimes add some text/comments in it, and press
M-q to run `fill-paragraph'. But this calls `quit-window' and pisses me
off.

I don't know what is the best way to fix this, therefore I'm not
including any patch in this report, but would do it if possible. :-)

-- 
Julien Danjou
❱ http://julien.danjou.info





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#8284: 24.0.50; M-q badly bound in diff-mode
  2011-03-18 14:18 bug#8284: 24.0.50; M-q badly bound in diff-mode Julien Danjou
@ 2011-03-18 19:19 ` Stefan Monnier
  2011-03-18 19:52   ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2011-03-18 19:19 UTC (permalink / raw)
  To: Julien Danjou; +Cc: 8284

> The `diff-mode' keymap `diff-mode-shared-map' inherit from
> `special-mode-map' which defines M-q as `quit-window'.

> This is *very* annoying when editing diff file build with
> git-format-patch. I sometimes add some text/comments in it, and press
> M-q to run `fill-paragraph'. But this calls `quit-window' and pisses
> me off.

> I don't know what is the best way to fix this, therefore I'm not
> including any patch in this report, but would do it if possible. :-)

When editing the buffer, diff-mode should not be considered as
a special-mode.  But I see that what you write is not quite what
happens: M-q is not inherited from special-mode-map, it's that `q' is
inherited from special-mode-map into diff-mode-shared-map which is bound
to ESC, thus giving us a binding for M-q.

So I think that diff-mode-map should shadow diff-mode-shared-map's
q binding.  I think the patch below does it.


        Stefan


=== modified file 'lisp/vc/diff-mode.el'
--- lisp/vc/diff-mode.el	2011-03-14 03:40:18 +0000
+++ lisp/vc/diff-mode.el	2011-03-18 19:18:38 +0000
@@ -122,8 +122,7 @@
     ("\C-m" . diff-goto-source)
     ([mouse-2] . diff-goto-source)
     ;; From XEmacs' diff-mode.
-    ;; Standard M-w is useful, so don't change M-W.
-    ;;("W" . widen)
+    ("W" . widen)
     ;;("." . diff-goto-source)		;display-buffer
     ;;("f" . diff-goto-source)		;find-file
     ("o" . diff-goto-source)		;other-window
@@ -135,17 +134,21 @@
     ;; Not useful if you have to metafy them.
     ;;(" " . scroll-up)
     ;;("\177" . scroll-down)
-    ;; Standard M-a is useful, so don't change M-A.
-    ;;("A" . diff-ediff-patch)
-    ;; Standard M-r is useful, so don't change M-r or M-R.
-    ;;("r" . diff-restrict-view)
-    ;;("R" . diff-reverse-direction)
-    )
+    ("A" . diff-ediff-patch)
+    ("r" . diff-restrict-view)
+    ("R" . diff-reverse-direction))
   "Basic keymap for `diff-mode', bound to various prefix keys."
   :inherit special-mode-map)
 
 (easy-mmode-defmap diff-mode-map
-  `(("\e" . ,diff-mode-shared-map)
+  `(("\e" . ,(let ((map (make-sparse-keymap)))
+               ;; We want to inherit most bindings from diff-mode-shared-map,
+               ;; but not all since they may hide useful M-<foo> global
+               ;; bindings when editing.
+               (set-keymap-parent map diff-mode-shared-map)
+               (dolist (key '("A" "r" "R" "g" "q" "W"))
+                 (define-key map key nil))
+               map))
     ;; From compilation-minor-mode.
     ("\C-c\C-c" . diff-goto-source)
     ;; By analogy with the global C-x 4 a binding.






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#8284: 24.0.50; M-q badly bound in diff-mode
  2011-03-18 19:19 ` Stefan Monnier
@ 2011-03-18 19:52   ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2011-03-18 19:52 UTC (permalink / raw)
  To: Julien Danjou; +Cc: 8284-done

> q binding.  I think the patch below does it.

It appears to fix it, indeed.  Installed,


        Stefan





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-18 19:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-18 14:18 bug#8284: 24.0.50; M-q badly bound in diff-mode Julien Danjou
2011-03-18 19:19 ` Stefan Monnier
2011-03-18 19:52   ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).