From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Andrew L. Moore" Newsgroups: gmane.emacs.devel Subject: Re: executable-set-magic update Date: Mon, 24 Jul 2017 14:22:52 -0400 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1500920620 32543 195.159.176.226 (24 Jul 2017 18:23:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Jul 2017 18:23:40 +0000 (UTC) Cc: emacs-devel@gnu.org To: monnier@iro.umontreal.ca Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 24 20:23:36 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZi0y-00081O-Ff for ged-emacs-devel@m.gmane.org; Mon, 24 Jul 2017 20:23:32 +0200 Original-Received: from localhost ([::1]:56281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZi13-0006g9-Sa for ged-emacs-devel@m.gmane.org; Mon, 24 Jul 2017 14:23:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZi0R-0006f8-3N for emacs-devel@gnu.org; Mon, 24 Jul 2017 14:22:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZi0Q-0002Z3-7j for emacs-devel@gnu.org; Mon, 24 Jul 2017 14:22:59 -0400 Original-Received: from mail-yw0-x22c.google.com ([2607:f8b0:4002:c05::22c]:33573) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZi0Q-0002YY-3E for emacs-devel@gnu.org; Mon, 24 Jul 2017 14:22:58 -0400 Original-Received: by mail-yw0-x22c.google.com with SMTP id x125so54477973ywa.0 for ; Mon, 24 Jul 2017 11:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :cc:to; bh=z/AhNpw7S4aatXD/zSWhU/8AxR5uQ6lXIvuPTL8S7yY=; b=il6cbX3Coi3j8Jryt29bSCSER9gF3mZfqCN3otbk4H0ICeX8kzHDlrlnZlH9m0pbGi s/sg3HdEXMNCkfbt6SMouqoQrNuThE93uUaHMuvCOlGDgDaeZg5TKVnFhrq/6j/3/YoV /ddoas8EcxZnevjIEUGzEwuXLtUxpLf8dMA4jE/PNb22/vryyNXtDt4ca8VTtJen1IUo jb5uO3JaEbWb06fwnF0qFJXjRuZtmc0WnBpci2tW+0gSXtmXS1/u1cPJzCS3bwOwRlip N33Qek9JM3P2aCYXjvosqwwzVr9bGeyuFz2yH8CevHh7ZFMjync2gBaG8alKElId4hO3 8J7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:cc:to; bh=z/AhNpw7S4aatXD/zSWhU/8AxR5uQ6lXIvuPTL8S7yY=; b=DEsAeI2QtqTi3mwaTg4Zd+UOIEwvu0hG5VR1llgyYQzvP+2DqAURWnH9B8EXkaxRg3 /p7CifhYR8b+N1GDBGM8pyPUYZ+mH6bLjXSio31VStx4zAf3Wxgs91QxEHLujqZhdnn0 uj1TXD/GUSigKF96XFTCW5Cgasw64Ri9jdsYaOcc5SE6Az2DdskLmaswWnqXOy3TeZvr QhnzrAtGzq48VOhqYgy+t7VFUZ8/CNPS7pvWGAQv0tWf6Mjo8A74RTpFgM/NZR1YJ/DX PEJFUWWiDpAVNsyWtlMZnJdLhr3X3pPHtPewmnfk+RipVQTwP6ANCWWsGgkVC7fGFWCm 4lEA== X-Gm-Message-State: AIVw111pzLS+1q977a2Zc2Vc6AtkSec7nR3KW5ZabF70Vpm8gOHx3aZS PZ07w2rdVShkkw== X-Received: by 10.13.243.66 with SMTP id c63mr12521493ywf.195.1500920575690; Mon, 24 Jul 2017 11:22:55 -0700 (PDT) Original-Received: from ?IPv6:2605:a601:5010:3600:4c6b:fab7:e846:5ec3? ([2605:a601:5010:3600:4c6b:fab7:e846:5ec3]) by smtp.gmail.com with ESMTPSA id c124sm4263554ywd.31.2017.07.24.11.22.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 11:22:55 -0700 (PDT) X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4002:c05::22c X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:216993 Archived-At: >> It would also be nice if `executable-set-magic=E2=80=99 were = supported beyond >> `sh-set-shell=E2=80=99 (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/...? >=20 > 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=E2=80=99t use = magic numbers, so I updated the minor mode with a variable that allows skipping files in = =E2=80=9Cproject=E2=80=9D directories. And since the minor mode leverages executable-set-magic, = it's been renamed `executable-set-magic-mode=E2=80=99: = https://github.com/slewsys/emacs-extensions/blob/master/executable-set-mag= ic.el The current implementation searches for a =E2=80=9Cproject root=E2=80=9D = 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