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.

Ed Sabol
  • 141
  • 6

1 Answers1

1

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

phils
  • 48,657
  • 3
  • 76
  • 115