GNU bug report logs - #25187
Initialization of `shell-mode-map' is not safe

Previous Next

Package: emacs;

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

Date: Mon, 12 Dec 2016 23:13:01 UTC

Severity: minor

Tags: easy, 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 25187 in the body.
You can then email your comments to 25187 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#25187; Package emacs. (Mon, 12 Dec 2016 23:13:01 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. (Mon, 12 Dec 2016 23:13:01 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 `shell-mode-map' is not safe
Date: Tue, 13 Dec 2016 00:08:07 +0100
Hi,

consider

(defvar shell-mode-map
  (let ((map (nconc (make-sparse-keymap) comint-mode-map)))
    (define-key map "\C-c\C-f" 'shell-forward-command)
    (define-key map "\C-c\C-b" 'shell-backward-command)
    (define-key map "\t" 'completion-at-point)
    (define-key map (kbd "M-RET") 'shell-resync-dirs)
    (define-key map "\M-?" 'comint-dynamic-list-filename-completions)
    (define-key map [menu-bar completion]
      (cons "Complete"
	    (copy-keymap (lookup-key comint-mode-map [menu-bar completion]))))
    (define-key-after (lookup-key map [menu-bar completion])
      [complete-env-variable] '("Complete Env. Variable Name" .
				shell-dynamic-complete-environment-variable)
      'complete-file)
    (define-key-after (lookup-key map [menu-bar completion])
      [expand-directory] '("Expand Directory Reference" .
			   shell-replace-by-expanded-directory)
      'complete-expand)
    map))

from 'shell.el'.  When somebody decides to customize `comint-mode-map' 
by, for example, first wiping it out and then filling it again,

(with-eval-after-load 'comint	
  ;; Wipe `comint-mode-map':
  (setcdr comint-mode-map nil)
  ;; Fill `comint-mode-map':
  ...)

then when the `shell' feature is loaded, it will inevitably fail because 
`(lookup-key comint-mode-map [menu-bar completion])' may no longer 
return a keymap but rather nil or a number.

Looking forward for fix.

Regards,
Alexander




Added tag(s) easy. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Mon, 12 Jun 2017 00:34:02 GMT) Full text and rfc822 format available.

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

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alexander Shukaev <emacs <at> Alexander.Shukaev.name>
Cc: 25187 <at> debbugs.gnu.org
Subject: Re: bug#25187: Initialization of `shell-mode-map' is not safe
Date: Wed, 09 Oct 2019 09:24:15 +0200
Alexander Shukaev <emacs <at> Alexander.Shukaev.name> writes:

> consider
>
> (defvar shell-mode-map
>   (let ((map (nconc (make-sparse-keymap) comint-mode-map)))

[...]

> from 'shell.el'.  When somebody decides to customize `comint-mode-map'
> by, for example, first wiping it out and then filling it again,
>
> (with-eval-after-load 'comint	
>   ;; Wipe `comint-mode-map':
>   (setcdr comint-mode-map nil)
>   ;; Fill `comint-mode-map':
>   ...)
>
> then when the `shell' feature is loaded, it will inevitably fail
> because `(lookup-key comint-mode-map [menu-bar completion])' may no
> longer return a keymap but rather nil or a number.

I've now fixed this in Emacs 27 by just removing the nconc from the
shell mode map -- shell-mode is derived from comint-mode, so it
automatically inherits its map.

-- 
(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:25:04 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 25187 <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:25:04 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 5 years and 306 days ago.

Previous Next


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