In a *shell* buffer, if I position the cursor after typing "pass" and invoke M-: (shell-dynamic-completion-command), this should yield a completion "passwd" if /bin is in exec-path. However it errors out with error: (wrong-number-of-arguments (3 . 4) 5) completion-in-region(484 486 #f(compiled-function (string pred action) #) :exit-function #f(compiled-function (string finished) #)) apply(completion-in-region (484 486 #f(compiled-function (string pred action) #) :exit-function #f(compiled-function (string finished) #))) shell-dynamic-complete-command() eval((shell-dynamic-complete-command) t) eval-expression((shell-dynamic-complete-command) nil nil 127) funcall-interactively(eval-expression (shell-dynamic-complete-command) nil nil 127) call-interactively(eval-expression nil nil) command-execute(eval-expression) The completion data functions shell-environment-variable-completion and shell-command-completion include an :exit-function keyword value pair in the result. But this cannot be passed on to completion-in-region. (How is this exit-function to be used at all?) Commit e71564921ec760638105c910fdfae8b648724130 fixed similar issues in comint.el, and probably missed shell.el during that pass * lisp/shell.el (shell-dynamic-complete-command) (shell-dynamic-complete-environment-variable): Correctly call completion-in-region.