From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tk Newsgroups: gmane.lisp.guile.user Subject: Re: Auto-detect Guile in a text editor Date: Tue, 23 Oct 2018 12:33:02 +0000 Message-ID: <-uG2OuTcvsm-Fop1DIG5bO5EiFqS6FJvPQ1xdP4A35k_2Zkm1eWzqbzl82h-imuTeXUaKTk7LOnrqXFOuNpb_z_dfjR3vlI7scjOZOeEzVg=@protonmail.com> References: <1602509.cW4D3zthmT@aleksandar-ixtreme-m5740> Reply-To: Tk NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1540297922 3256 195.159.176.226 (23 Oct 2018 12:32:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 23 Oct 2018 12:32:02 +0000 (UTC) Cc: "guile-user@gnu.org" , HiPhish To: Tkprom Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Oct 23 14:31:58 2018 Return-path: Envelope-to: guile-user@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 1gEvqn-0000es-4W for guile-user@m.gmane.org; Tue, 23 Oct 2018 14:31:57 +0200 Original-Received: from localhost ([::1]:41053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEvst-000755-G6 for guile-user@m.gmane.org; Tue, 23 Oct 2018 08:34:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEvsK-00074z-TY for guile-user@gnu.org; Tue, 23 Oct 2018 08:33:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEvs7-0000Jl-JD for guile-user@gnu.org; Tue, 23 Oct 2018 08:33:25 -0400 Original-Received: from mail4.protonmail.ch ([185.70.40.27]:61504) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEvs3-0000ER-0r for guile-user@gnu.org; Tue, 23 Oct 2018 08:33:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1540297989; bh=AOxbPBPs29DOg8R/xTjz0n6pbSh/npebvLy1przBkYE=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References: Feedback-ID:From; b=KH+uf/7Am4GfGRzll5Vw4R6wLUdZXYbQzuLTgaBVtoygBspiBV65eO1JJhcZX3J2b T9dYe9u0L1Fs92H+75hh4bFGsrtBWg/lQ6tRESy0YciBQdomg8QE9DkF+IYscxnXZ0 fB5eepLJrYqF8otIbQzy+DnTqU0mzId+dzbIhh4M= In-Reply-To: Feedback-ID: H-HDHPDhHGpnHYYqEeeELdj-Ly2a7MuykpUWpBFgfQ1BCJpPfO2vKz9YpJUb7-VnGIEXLb5c-uxqytN6PxXV2Q==:Ext:ProtonMail X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 185.70.40.27 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14943 Archived-At: =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Tuesday, 23 October 2018 13:36, Tkprom wrote: > On Tuesday, 23 October 2018 13:07, HiPhish hiphish@posteo.de wrote: > > > Hello Schemers > > When I open a Scheme file (Neo)vim the file type is set to "scheme", bu= t I > > would like to be able to detect that it is not just Scheme, but Guile S= cheme. > > So far I have set up the editor to scan the first line for a shebang an= d if > > the word "guile" appears to set the file type to "scheme.guile": > > if getline(1) =3D~? '\v^#!.[Gg]uile' > > let &filetype .=3D '.guile' > > endif > > If you are not familiar with Vim, the important part is the regex > > '^#!.[Gg]uile'. This works OK, but is there a better way than adding as= hebang or some other manual hing to the head of every script? How does Emac= s > > do it? > > And while I'm at that topic, what is the proper way of writing a sheban= g when > > I don't know where Guile is installed to? For example, the Guile manual > > frequently uses > > #!/usr/local/bin/guile > > but what if I have Guile installed via Guix and it is somewhere in my G= uix > > store? A common solution is to abuse env: > > #!/usr/bin/env guile > > But now I cannot pass arguments (like '-s') to Guile, because everythin= g > > following the first space will be treated as one argument to 'env'. Is = there a > > solution or am I just overthinking things? > > Hi, > > Maybe you could look into how Geiser does it in Emacs. As far as I know, = Geiser is a de-facto Guile IDE for Emacs (http://www.nongnu.org/geiser/). > > Your approach will only work for the she-banged scripts. For anything els= e, I suppose there is going to be some guess-work involved. For example, of= ten used Guile constructs are "define-module", #:use-module, use-modules ..= . they all usually appear at the top. Ditto "ice-9" . Scan top 20-50 lines = for those keywords and there is a high probability the Scheme file is a Gui= le file if it contains any of those. > > About your second question: yes, that sucks! This is why i stopped using = executable guile scripts and am now just doing: > > $ guile my-program.scm options to the program > > Perhaps someone else has a better solution. > > Hope this helps, > > Tk One more thing: since the current attempts at standardisation of Scheme lan= guage are pushing for uniformity among different implementations (I know, I= know, it may never happen), perhaps scanning for dialect-specific usage is= not the nicest approach. I prefer the approach where leaving a comment marker somewhere would activa= te the required functionality. For example, in Emacs, you could write somet= hing like, ; -*- mode: Scheme; eval: (whatever-minor-guile-mode-is-used 1); -*- .