GNU bug report logs - #25190
Initialization of `dired-mode-map' in by the `dired-x' feature is not safe

Previous Next

Package: emacs;

Reported by: Alexander Shukaev <emacs <at> Alexander.Shukaev.name>

Date: Tue, 13 Dec 2016 00:53:02 UTC

Severity: minor

Tags: fixed

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25190 in the body.
You can then email your comments to 25190 AT debbugs.gnu.org in the normal way.

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#25190; Package emacs. (Tue, 13 Dec 2016 00:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alexander Shukaev <emacs <at> Alexander.Shukaev.name>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 13 Dec 2016 00:53:02 GMT) Full text and rfc822 format available.

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

From: Alexander Shukaev <emacs <at> Alexander.Shukaev.name>
To: bug-gnu-emacs <at> gnu.org
Subject: Initialization of `dired-mode-map' in by the `dired-x' feature is not
 safe
Date: Tue, 13 Dec 2016 01:52:31 +0100
Hi,

consider the two

;;; KEY BINDINGS.

(define-key dired-mode-map "\C-x\M-o" 'dired-omit-mode)
(define-key dired-mode-map "*O" 'dired-mark-omitted)
(define-key dired-mode-map "\M-(" 'dired-mark-sexp)
(define-key dired-mode-map "*(" 'dired-mark-sexp)
(define-key dired-mode-map "*." 'dired-mark-extension)
(define-key dired-mode-map "\M-!" 'dired-smart-shell-command)
(define-key dired-mode-map "\M-G" 'dired-goto-subdir)
(define-key dired-mode-map "F" 'dired-do-find-marked-files)
(define-key dired-mode-map "Y"  'dired-do-relsymlink)
(define-key dired-mode-map "%Y" 'dired-do-relsymlink-regexp)
(define-key dired-mode-map "V" 'dired-do-run-mail)

;;; MENU BINDINGS

(require 'easymenu)

(let ((menu (lookup-key dired-mode-map [menu-bar])))
  (easy-menu-add-item menu '("Operate")
                      ["Find Files" dired-do-find-marked-files
                       :help "Find current or marked files"]
                      "Shell Command...")
  (easy-menu-add-item menu '("Operate")
                      ["Relative Symlink to..." dired-do-relsymlink
                       :visible (fboundp 'make-symbolic-link)
                       :help "Make relative symbolic links for current or \
marked files"]
                      "Hardlink to...")
  (easy-menu-add-item menu '("Mark")
                      ["Flag Extension..." dired-flag-extension
                       :help "Flag files with a certain extension for 
deletion"]
                      "Mark Executables")
  (easy-menu-add-item menu '("Mark")
                      ["Mark Extension..." dired-mark-extension
                       :help "Mark files with a certain extension"]
                      "Unmark All")
  (easy-menu-add-item menu '("Mark")
                      ["Mark Omitted" dired-mark-omitted
                       :help "Mark files matching `dired-omit-files' \
and `dired-omit-extensions'"]
                      "Unmark All")
  (easy-menu-add-item menu '("Regexp")
                      ["Relative Symlink..." dired-do-relsymlink-regexp
                       :visible (fboundp 'make-symbolic-link)
                       :help "Make relative symbolic links for files \
matching regexp"]
                      "Hardlink...")
  (easy-menu-add-item menu '("Immediate")
                      ["Omit Mode" dired-omit-mode
                       :style toggle :selected dired-omit-mode
                       :help "Enable or disable omitting 
\"uninteresting\" \
files"]
                      "Refresh"))

sections.  Both can easily fail.  For instance,

(define-key dired-mode-map "%Y" 'dired-do-relsymlink-regexp)

assumes that the "%" prefix command has been defined in `dired-mode-map' 
which is not at all true for any customization.  The 
`easy-menu-add-item' calls suffers from similar issue.  It should be 
possible to conditionally disable these code sections or even remove 
them altogether as they are maldesigned.

Looking forward to fix.

P.S. Just a side question: why `dired-x' is not yet merged into `dired'? 
 IMO, makes no sense to maintain separate extension packages of the 
main package when they are already built-in anyway.

Regards,
Alexander




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25190; Package emacs. (Tue, 13 Dec 2016 02:19:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Alexander Shukaev <emacs <at> Alexander.Shukaev.name>
Cc: 25190 <at> debbugs.gnu.org
Subject: Re: bug#25190: Initialization of `dired-mode-map' in by the `dired-x'
 feature is not safe
Date: Mon, 12 Dec 2016 21:18:47 -0500
Alexander Shukaev wrote:

> P.S. Just a side question: why `dired-x' is not yet merged into
> dired'?

Since dired-x hasn't changed qualitatively in 5 years, neither has my
answer to this question. :)

http://lists.gnu.org/archive/html/emacs-devel/2011-03/msg00718.html

(Just IMO.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25190; Package emacs. (Tue, 13 Dec 2016 03:06:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Glenn Morris <rgm <at> gnu.org>, Alexander Shukaev
 <emacs <at> Alexander.Shukaev.name>
Cc: 25190 <at> debbugs.gnu.org
Subject: RE: bug#25190: Initialization of `dired-mode-map' in by the `dired-x'
 feature is not safe
Date: Mon, 12 Dec 2016 19:04:48 -0800 (PST)
> > P.S. Just a side question: why `dired-x' is not yet merged into
> > dired'?
> 
> Since dired-x hasn't changed qualitatively in 5 years, neither has my
> answer to this question. :)
> 
> http://lists.gnu.org/archive/html/emacs-devel/2011-03/msg00718.html
> (Just IMO.)

Yes, well, those (such as Glenn and Stefan) in that thread who
claimed to want to keep only a bit of dired-x and toss the
rest, claiming that it is only "cruft" are also people who
have admitted that they hardly, if ever, use Dired.

There are plenty of other people, myself included, who use not
only dired.el but dired-x.el and dired-aux.el, all the time.

I don't think it's useful to rehash the previous thread,
which went nowhere, and certainly not here, in a bug thread
that is not related.

But we should not particularly be listening to non-users of
Dired about tossing parts of it out.  (Just IMO.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25190; Package emacs. (Wed, 09 Oct 2019 07:42:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alexander Shukaev <emacs <at> Alexander.Shukaev.name>
Cc: 25190 <at> debbugs.gnu.org
Subject: Re: bug#25190: Initialization of `dired-mode-map' in by the
 `dired-x' feature is not safe
Date: Wed, 09 Oct 2019 09:41:02 +0200
Alexander Shukaev <emacs <at> Alexander.Shukaev.name> writes:

> consider the two
>
> ;;; KEY BINDINGS.
>
> (define-key dired-mode-map "\C-x\M-o" 'dired-omit-mode)
> (define-key dired-mode-map "*O" 'dired-mark-omitted)

[...]

> sections.  Both can easily fail.  For instance,
>
> (define-key dired-mode-map "%Y" 'dired-do-relsymlink-regexp)
>
> assumes that the "%" prefix command has been defined in
> `dired-mode-map' which is not at all true for any customization.  The 
> `easy-menu-add-item' calls suffers from similar issue.  It should be
> possible to conditionally disable these code sections or even remove 
> them altogether as they are maldesigned.

I've now added some checks to Emacs 27 to ensure that dired-x doesn't
try to define keys in sub-keymaps that doesn't exist.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 09 Oct 2019 07:42:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 25190 <at> debbugs.gnu.org and Alexander Shukaev <emacs <at> Alexander.Shukaev.name> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 09 Oct 2019 07:42:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 06 Nov 2019 12:24:15 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 173 days ago.

Previous Next


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