From: "Andrew L. Moore" <slewsys@gmail.com>
To: monnier@iro.umontreal.ca
Cc: emacs-devel@gnu.org
Subject: Re: executable-set-magic update
Date: Mon, 24 Jul 2017 14:22:52 -0400 [thread overview]
Message-ID: <F8DB6EBF-B761-4B0E-B30B-ED8586817A32@gmail.com> (raw)
>> 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)))
>> )
> Stefan Monnier wrote:
> Doesn't this add a #! to every file using modes like
> js/ruby/awk/perl/python/...?
>
> In multi-file programs, only the main file needs a "#!", so I don't
> understand why adding #! to all files would make sense.
Stefan,
Sorry I missed your comment. Yeah, script libraries don’t use magic numbers, so
I updated the minor mode with a variable that allows skipping files in “project”
directories. And since the minor mode leverages executable-set-magic, it's been
renamed `executable-set-magic-mode’:
https://github.com/slewsys/emacs-extensions/blob/master/executable-set-magic.el
The current implementation searches for a “project root” in the file path
by brute force. Hopefully that can be updated with something more elegant.
In the mean time, function `executable-set-magic' only seems to be leveraged
by lisp/progmodes/sh-script.el for shell scripts. So an alternative to
extending it might be removing it, e.g., to an external library.
-AM
next reply other threads:[~2017-07-24 18:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 18:22 Andrew L. Moore [this message]
2017-07-24 22:41 ` executable-set-magic update Andrew L. Moore
-- strict thread matches above, loose matches on Subject: below --
2017-06-09 21:31 Andrew L. Moore
2017-06-10 7:17 ` Eli Zaretskii
2017-06-10 19:31 ` Andrew L. Moore
2017-07-22 7:36 ` Eli Zaretskii
2017-06-10 12:26 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=F8DB6EBF-B761-4B0E-B30B-ED8586817A32@gmail.com \
--to=slewsys@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).