From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wilhelm Kirschbaum Newsgroups: gmane.emacs.bugs Subject: bug#64939: 30.0.50; The default auto-mode-interpreter-regexp does not match env with flags Date: Sun, 30 Jul 2023 10:28:14 +0200 Message-ID: <87351591ue.fsf@gmail.com> References: <87mszebgwy.fsf@gmail.com> <83zg3eknjd.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26822"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.3; emacs 30.0.50 Cc: 64939@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 30 12:13:00 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qQ3Q4-0006lE-Jv for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 Jul 2023 12:13:00 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQ2sG-0005Pg-2L; Sun, 30 Jul 2023 05:38:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQ2sE-0005PX-Qk for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2023 05:38:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQ2sE-0002un-In for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2023 05:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qQ2sE-00043B-Es for bug-gnu-emacs@gnu.org; Sun, 30 Jul 2023 05:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Wilhelm Kirschbaum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Jul 2023 09:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64939 X-GNU-PR-Package: emacs Original-Received: via spool by 64939-submit@debbugs.gnu.org id=B64939.169070987815558 (code B ref 64939); Sun, 30 Jul 2023 09:38:02 +0000 Original-Received: (at 64939) by debbugs.gnu.org; 30 Jul 2023 09:37:58 +0000 Original-Received: from localhost ([127.0.0.1]:49398 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQ2s9-00042r-Iu for submit@debbugs.gnu.org; Sun, 30 Jul 2023 05:37:57 -0400 Original-Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:45553) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQ2s7-00042f-Vx for 64939@debbugs.gnu.org; Sun, 30 Jul 2023 05:37:56 -0400 Original-Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-31771a876b5so2946154f8f.3 for <64939@debbugs.gnu.org>; Sun, 30 Jul 2023 02:37:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690709870; x=1691314670; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=HbOAtIPIDddQoTEVCp9Dy6NPKxzL3wlJdryWUGlRIhQ=; b=ShP/GQCEynF0xdWPOBCCS6mmgcNJkuGSc4cjHEf7mzF9hvc5TyutE5Cy/PQSA9Hpv+ sVZQ9RuNBFCIsQkM/lmz5iZA+UWiiNSJkjMo6yb/Wciib6JeowKX3YE7e2paPf4CGqUp 2a3NYv5cLswMX82VKRySEP0A98ZUTP0LwhGbSEMXJ5jaumELClRWVfLUnyYbrMTgXqeH 403XbZ4GKFtXDClATy5a6wMKW2dEFZfevXe9YbkR9LEugBXOIlUVxwsKXc2KbQYlqBc8 VxUgEHCbB1hwwRcmgC2ksl230eX6tYuJ0FQVxwmmftzlu04aYBTFaiM+nz9X1TQgb9QP 6ZBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690709870; x=1691314670; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HbOAtIPIDddQoTEVCp9Dy6NPKxzL3wlJdryWUGlRIhQ=; b=ZDmGizCCW4WUsImj+8Hryey2rzdh/Npa6ISippukstl8Ni2dT2vqoeMOQUhw2w0GPZ vMDVTBeBvaXmFdzuaKTSw3adAN3YNEGD9N53iohSwu14606DAKoi8aYn7+e9Rt45n9nt /jyAFtYJ0o3PghBZp382LMzF9MrJ4UKzm78km7xgBMtFJIvqYw1z44l0eEMTZVs7q/yk Ay2t5IE4YYaW/rMZIvZxvqhDRIFZWkf7HBuBc1Xu2DXeGGn/5pDUOLPPSPScGs2uxUeu Iil2laRRratMKzSCp7h50KjrxSkqyiWNZslA5SlDMkvVC5I08RsAi84h92jSznE/y/If ekfA== X-Gm-Message-State: ABy/qLaq66IF45MqZ6mDINTMH3Efq/ZmBRzMD6Ur+lSn6qmd3MrH7O9d L4zJVEPr6/fhRW/5vMScxcJJD9X/cj4= X-Google-Smtp-Source: APBJJlEgyhoDjQjY5bFiY5QEEESvq7Lh0OIJ+jQyEJWHUyqkuEHojwVa5GLISzwOC3B7lHTKO4+55w== X-Received: by 2002:adf:fc0b:0:b0:317:6cca:a68a with SMTP id i11-20020adffc0b000000b003176ccaa68amr4754498wrr.41.1690709869608; Sun, 30 Jul 2023 02:37:49 -0700 (PDT) Original-Received: from melissa.local ([2c0f:ef18:1431:0:b09:9616:db04:c248]) by smtp.gmail.com with ESMTPSA id i7-20020a5d4387000000b003176aa612b1sm9689755wrq.38.2023.07.30.02.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 02:37:49 -0700 (PDT) In-reply-to: <83zg3eknjd.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:266362 Archived-At: Eli Zaretskii writes: >> From: Wilhelm Kirschbaum >> Date: Sat, 29 Jul 2023 22:08:19 +0200 >> >> >> A file without an extension will load ruby-mode if the first >> line >> is: >> >> #!/usr/bin/env ruby >> >> but not when the first line is: >> >> #!/usr/bin/env -S ruby -e 'puts 123' >> >> Is there any reason why the latter should not be matched by the >> default >> `auto-mode-interpreter-regexp' value in 'files.el'? > > That line _is_ matched by auto-mode-interpreter-regexp: > > (string-match-p auto-mode-interpreter-regexp "#!/usr/bin/env > -S ruby -e 'puts 123'") => 0 > > The problem is how to find the name of the interpreter if the > text > after "/usr/bin/env" includes more than one word? Once we start > using > command-line switches and their arguments, and take into > consideration > that many GNU/Linux programs can freely intersperse options and > non-option arguments on the command line in any order, where > does this > end? > I am hoping there is some way of effectively matching command-line switches for '/usr/bin/env', but sounds like it is perhaps too complex? This probably ends with a match to some common command-line variations for the '/usr/bin/env' program. It is not complete now, so make it guess slightly better is perhaps appropriate? >> A more useful example I stumbled on today while working on a >> language >> server after adding: >> >> `(add-to-list 'interpreter-mode-alist '("elixir" >> . elixir-ts-mode))' >> >> >> #!/usr/bin/env -S elixir --erl "-kernel >> standard_io_encoding >> latin1" > > How about making a script that invokes elixir with those > arguments, > and then augment interpreter-mode-alist to name that script > instead? That is an option, but then I have to convince the maintainers of all the packages I work on to make this change, vs my editor handling this. Even locally changing the regexp means that the match index has changed, so can't see this working without a patch. If this is perhaps too much work and/or uncertainty for negligible benefit to users, then it won't cause distress on my side :). Wilhelm