Subject: bug#6632: closed (Re: bug#6632: 23.2.50; dired-mode should use [remap ...] instead of hard-coded overriding of global key bindings)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 22 Jul 2010 11:57:02 +0000

Your bug report

#6632: 23.2.50; dired-mode should use [remap ...] instead of hard-coded overriding of global key bindings

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
6632: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6632
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#6632: 23.2.50; dired-mode should use [remap ...] instead of hard-coded overriding of global key bindings
From: Juanma Barranquero <[email-masked]>
To: Teemu Likonen <[email-masked]>
Cc: [email-masked]
Date: Thu, 22 Jul 2010 13:57:00 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On Wed, Jul 14, 2010 at 17:58, Teemu Likonen <[email-masked]> wrote:

> The attached patch fixes this for dired-mode.

Committed, thanks.

    Juanma

Subject: 23.2.50; dired-mode should use [remap ...] instead of hard-coded overriding of global key bindings
From: Teemu Likonen <[email-masked]>
To: [email-masked]
Date: Wed, 14 Jul 2010 18:58:13 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

dired-mode uses hard-coding when it rebinds some global key bindings.
For example, there is the following line in dired.el file:

    (define-key map "\C-n" 'dired-next-line)

Therefore it overrides the global C-n key, whatever its command is in
user's keymap. The command should be bound like this:

    (define-key map [remap next-line] 'dired-next-line)

Using [remap ...] is preferred because it makes it possible for user to
redefine the global keymap they way she wishes and keys will still
automatically get their mode-specific behaviour. The attached patch
fixes this for dired-mode.

diff --git a/lisp/dired.el b/lisp/dired.el
index c3d1435..0e5cc22 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1380,10 +1380,8 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
     (define-key map ">" 'dired-next-dirline)
     (define-key map "^" 'dired-up-directory)
     (define-key map " "  'dired-next-line)
-    (define-key map "\C-n" 'dired-next-line)
-    (define-key map "\C-p" 'dired-previous-line)
-    (define-key map [down] 'dired-next-line)
-    (define-key map [up] 'dired-previous-line)
+    (define-key map [remap next-line] 'dired-next-line)
+    (define-key map [remap previous-line] 'dired-previous-line)
     ;; hiding
     (define-key map "$" 'dired-hide-subdir)
     (define-key map "\M-$" 'dired-hide-all)
@@ -1393,7 +1391,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
     (define-key map (kbd "M-s f C-s")   'dired-isearch-filenames)
     (define-key map (kbd "M-s f M-C-s") 'dired-isearch-filenames-regexp)
     ;; misc
-    (define-key map "\C-x\C-q" 'dired-toggle-read-only)
+    (define-key map [remap toggle-read-only] 'dired-toggle-read-only)
     (define-key map "?" 'dired-summary)
     (define-key map "\177" 'dired-unmark-backward)
     (define-key map [remap undo] 'dired-undo)