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.

Full log


View this message in rfc822 format

From: Alexander Shukaev <emacs <at> Alexander.Shukaev.name>
To: 25187 <at> debbugs.gnu.org
Subject: bug#25187: 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




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.