guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Auto-detect Guile in a text editor


From: Tkprom
Subject: Re: Auto-detect Guile in a text editor
Date: Tue, 23 Oct 2018 11:36:21 +0000

On Tuesday, 23 October 2018 13:07, HiPhish <address@hidden> wrote:

> Hello Schemers
>
> When I open a Scheme file (Neo)vim the file type is set to "scheme", but I
> would like to be able to detect that it is not just Scheme, but Guile Scheme.
> So far I have set up the editor to scan the first line for a shebang and if
> the word "guile" appears to set the file type to "scheme.guile":
>
> if getline(1) =~? '\v^#!.[Gg]uile'
> let &filetype .= '.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 ashebang 
> or some other manual hing to the head of every script? How does Emacs
> do it?
>
> And while I'm at that topic, what is the proper way of writing a shebang 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 Guix
> store? A common solution is to abuse env:
>
> #!/usr/bin/env guile
>
> But now I cannot pass arguments (like '-s') to Guile, because everything
> 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 else, I 
suppose there is going to be some guess-work involved. For example, often 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 Guile 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]