lisp/progmodes/executable.el does not appear to support magic numbers of the form `#/usr/bin/env interpreter’. One way to extend support is via the attached diff which merely adds a new variable `executable-interpreter-path-absolute’. Set the new variable to nil and variable `executable-prefix’ to “#!/usr/bin/env “. It would also be nice if `executable-set-magic’ were supported beyond `sh-set-shell’ (in lisp/progmodes/sh-script.el), so I implemented a minor mode that adds the following hook to find-file: (defun script-set-magic () "Look up interpreter associated with current major mode in `script-set-magic-alist' and call `executable-set-magic'." (let ((interpreter (alist-get major-mode script-set-magic-alist))) (if interpreter (executable-set-magic interpreter))) ) The minor mode file is available as: -AM