unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25187: Initialization of `shell-mode-map' is not safe
@ 2016-12-12 23:08 Alexander Shukaev
  2019-10-09  7:24 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Shukaev @ 2016-12-12 23:08 UTC (permalink / raw)
  To: 25187

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





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

* bug#25187: Initialization of `shell-mode-map' is not safe
  2016-12-12 23:08 bug#25187: Initialization of `shell-mode-map' is not safe Alexander Shukaev
@ 2019-10-09  7:24 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-09  7:24 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: 25187

Alexander Shukaev <emacs@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





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

end of thread, other threads:[~2019-10-09  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-12 23:08 bug#25187: Initialization of `shell-mode-map' is not safe Alexander Shukaev
2019-10-09  7:24 ` Lars Ingebrigtsen

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).