all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
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 18:41:54 -0400	[thread overview]
Message-ID: <B51B4A74-70D8-4BD8-A873-2F3437858E4C@gmail.com> (raw)
In-Reply-To: <F8DB6EBF-B761-4B0E-B30B-ED8586817A32@gmail.com>


> On Jul 24, 2017, at 2:22 PM, Andrew L. Moore <slewsys@gmail.com> wrote:
> 
>>> 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

Oops, the “project root” search was ugly too.  Reversing the order of the functions,
hopefully it’s just inelegant now.
-AM





  reply	other threads:[~2017-07-24 22:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24 18:22 executable-set-magic update Andrew L. Moore
2017-07-24 22:41 ` Andrew L. Moore [this message]
  -- 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B51B4A74-70D8-4BD8-A873-2F3437858E4C@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.