1

Before I probably re-invent the wheel, has anyone written a function (or perhaps there's one somewhere in Emacs already) to parse the shebang line of the current buffer (or some specified buffer). For example, if the first line of the buffer is #!/path/to/executable -flags, I would like the function to return /path/to/executable (not including the flags). If the buffer doesn't have a shebang line, it should just return nil, I guess. Bonus points if it handles the #!/usr/bin/env executable case as well and returns either just executable or the full path to executable in that scenario.

1

1 Answer 1

1

You could always look at how auto-mode-interpreter-regexp and interpreter-mode-alist are used by set-auto-mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.