unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* scheme with vim
@ 2020-01-29 15:56 Marc Chantreux
  2020-01-29 18:34 ` Ricardo Wurmus
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Marc Chantreux @ 2020-01-29 15:56 UTC (permalink / raw)
  To: guile-user; +Cc: julien

hello people,

during the guix days 2019, i made a demo of how awesome vim is as a
scheme editor (because s-expr actually are text objects). then
during the JRES, i said to Julien i'll write a tutorial about it.

i started to write a filetype plugin and an interactive tutorial
(vimtutor inspired) but i realize i need more guile skills.

the very first start is here:

    https://github.com/eiro/vim-ft-scheme

with:

* simple completion based on searching the first letters after
  the '-' symbols (so `us-m<tab>` becomes `use-modules`).
* mappings like (d for (define |) *l for λ,
* explaination about what text objects are and how to use them

but i have some questions:

# completion

i don't know what is the good way to get the list of built-in
commands of guile so i ended up with

    aptitude search '~i ~n guile-2' -F%p |
        xargs -n1 dpkg -L |
        perl -lnE 'print if /[.]scm$/ && -f' |
    ctags -L - -f ~/.vim/ctags/guile

any better way ?

# please be quiet

a way to test a code in vim is to use the interpreter as a filter using
the ! action (:h !) or write in a pipe.  if you do that with guile, the
repl header is printed:

    GNU Guile 2.2.4
    Copyright (C) 1995-2017 Free Software Foundation, Inc.

    Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
    This program is free software, and you are welcome to redistribute it
    under certain conditions; type `,show c' for details.

i wrote a wrapper:

    guile_as_filter () {
        local x=$( mktemp /tmp/guile-as-filter-XXXXX )
        cat "$@" > $x
        guile -s $x
        rm $x
    }

then i got

    ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
    ;;;       or pass the --no-auto-compile argument to disable.
    ;;; compiling /tmp/guile-as-filter-RTGLe
    ;;; compiled /home/mc/.cache/guile/ccache/2.2-LE-8-3.A/tmp/guile-as-filter-RTGLe.go

is there a way to restrict stderr and stdout to the content produced by
the actual script ?  (also interesting for a quickfix errformat)

regards
marc





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-01-29 15:56 scheme with vim Marc Chantreux
@ 2020-01-29 18:34 ` Ricardo Wurmus
  2020-01-29 20:29   ` zimoun
  2020-02-05 12:58 ` Ricardo Wurmus
  2020-02-05 13:08 ` Ricardo Wurmus
  2 siblings, 1 reply; 13+ messages in thread
From: Ricardo Wurmus @ 2020-01-29 18:34 UTC (permalink / raw)
  To: Marc Chantreux; +Cc: julien, guile-user


Hi Marc,

> # completion
>
> i don't know what is the good way to get the list of built-in
> commands of guile so i ended up with
>
>     aptitude search '~i ~n guile-2' -F%p |
>         xargs -n1 dpkg -L |
>         perl -lnE 'print if /[.]scm$/ && -f' |
>     ctags -L - -f ~/.vim/ctags/guile
>
> any better way ?

I don’t have aptitude or dpkg on my Guix system.  What do you mean by
“built-in commands”?

--
Ricardo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-01-29 18:34 ` Ricardo Wurmus
@ 2020-01-29 20:29   ` zimoun
  2020-01-29 20:53     ` Marc Chantreux
  0 siblings, 1 reply; 13+ messages in thread
From: zimoun @ 2020-01-29 20:29 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: Julien Lepiller, guile-user

Hi Ricardo,

On Wed, 29 Jan 2020 at 19:36, Ricardo Wurmus <rekado@elephly.net> wrote:

> > i don't know what is the good way to get the list of built-in
> > commands of guile so i ended up with
> >
> >     aptitude search '~i ~n guile-2' -F%p |
> >         xargs -n1 dpkg -L |
> >         perl -lnE 'print if /[.]scm$/ && -f' |
> >     ctags -L - -f ~/.vim/ctags/guile
> >
> > any better way ?
>
> I don’t have aptitude or dpkg on my Guix system.  What do you mean by
> “built-in commands”?

The pipeline first searches in all the installed packages and matching
the name guile-2 then outputs only the complete name.
Then 'dpkg -L' lists all the files that the package has installed, and
perl filters only the filename ending by .scm.
Last, ctags indexes. :-)

Basically, the 'aptitude | dpkg | perl' feeds 'ctags' with all .scm
files that you can find there [1] and there [2].

[1] https://packages.debian.org/fr/buster/amd64/guile-2.2-dev/filelist
[2] https://packages.debian.org/fr/buster/amd64/guile-2.2-libs/filelist


Note that first 'dpkg -L' is not working if the package is not
installed and second that one can want to install the Vim pluggin
without wanting to install all the Guile toolsuite in their own
profiles.

I am sure you will come up with a more elegant trick for Guix via a
Guile script. :-)


Hope that helps.

Cheers,
simon



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-01-29 20:29   ` zimoun
@ 2020-01-29 20:53     ` Marc Chantreux
  2020-01-29 21:04       ` zimoun
  0 siblings, 1 reply; 13+ messages in thread
From: Marc Chantreux @ 2020-01-29 20:53 UTC (permalink / raw)
  To: zimoun; +Cc: Julien Lepiller, guile-user

> I am sure you will come up with a more elegant trick for Guix via a
> Guile script. :-)

yet it will be distro dependant. i expected something like
introspection, querying a state of interpreter or even parsing the
documentation to provide a ready to use list of symbols.

regards,

marc



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-01-29 20:53     ` Marc Chantreux
@ 2020-01-29 21:04       ` zimoun
  0 siblings, 0 replies; 13+ messages in thread
From: zimoun @ 2020-01-29 21:04 UTC (permalink / raw)
  To: Marc Chantreux; +Cc: Julien Lepiller, guile-user

On Wed, 29 Jan 2020 at 21:53, Marc Chantreux <mc@unistra.fr> wrote:

> yet it will be distro dependant. i expected something like
> introspection, querying a state of interpreter or even parsing the
> documentation to provide a ready to use list of symbols.

My bad!
I thought it was the mailing list related to Guix.
Sorry.


All the best,
simon



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-01-29 15:56 scheme with vim Marc Chantreux
  2020-01-29 18:34 ` Ricardo Wurmus
@ 2020-02-05 12:58 ` Ricardo Wurmus
  2020-02-05 14:26   ` Marc Chantreux
  2020-02-05 13:08 ` Ricardo Wurmus
  2 siblings, 1 reply; 13+ messages in thread
From: Ricardo Wurmus @ 2020-02-05 12:58 UTC (permalink / raw)
  To: Marc Chantreux; +Cc: julien, guile-user


Hi Marc,

> # please be quiet
>
> a way to test a code in vim is to use the interpreter as a filter using
> the ! action (:h !) or write in a pipe.  if you do that with guile, the
> repl header is printed:
>
>     GNU Guile 2.2.4
>     Copyright (C) 1995-2017 Free Software Foundation, Inc.
>
>     Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
>     This program is free software, and you are welcome to redistribute it
>     under certain conditions; type `,show c' for details.
>
> i wrote a wrapper:
>
>     guile_as_filter () {
>         local x=$( mktemp /tmp/guile-as-filter-XXXXX )
>         cat "$@" > $x
>         guile -s $x
>         rm $x
>     }
>
> then i got
>
>     ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
>     ;;;       or pass the --no-auto-compile argument to disable.
>     ;;; compiling /tmp/guile-as-filter-RTGLe
>     ;;; compiled /home/mc/.cache/guile/ccache/2.2-LE-8-3.A/tmp/guile-as-filter-RTGLe.go
>
> is there a way to restrict stderr and stdout to the content produced by
> the actual script ?  (also interesting for a quickfix errformat)

Does it make sense for your application to auto compile sources at all?
If not you can disable it by passing “--no-auto-compile” as an option to
your invocation of Guile in “guile_as_filter”.

I also wonder if perhaps it would be better to start a Guile REPL and
have vim send S-expressions to the socket instead of saving a temporary
file and starting a new Guile process every time.

--
Ricardo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-01-29 15:56 scheme with vim Marc Chantreux
  2020-01-29 18:34 ` Ricardo Wurmus
  2020-02-05 12:58 ` Ricardo Wurmus
@ 2020-02-05 13:08 ` Ricardo Wurmus
  2020-02-05 13:26   ` zimoun
  2020-02-05 13:49   ` Marc Chantreux
  2 siblings, 2 replies; 13+ messages in thread
From: Ricardo Wurmus @ 2020-02-05 13:08 UTC (permalink / raw)
  To: Marc Chantreux; +Cc: julien, guile-user


Hi Marc,

> i don't know what is the good way to get the list of built-in
> commands of guile so i ended up with
>
>     aptitude search '~i ~n guile-2' -F%p |
>         xargs -n1 dpkg -L |
>         perl -lnE 'print if /[.]scm$/ && -f' |
>     ctags -L - -f ~/.vim/ctags/guile
>
> any better way ?

I’m still not sure I understand exactly what the result of this should
be (as I’m not familiar with ctags), but you can get a list of loaded
modules and the symbols they export.

This expression, for example, will print all symbols that are exported
by the (texinfo) module:

(module-for-each (lambda (symbol variable) (display symbol)(newline))
                 (resolve-module '(texinfo) #f #f #:ensure #f))

You can get a hash table of all loaded modules with:

    (module-submodules (resolve-module '() #f #f #:ensure #f))

etc.

-- 
Ricardo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-02-05 13:08 ` Ricardo Wurmus
@ 2020-02-05 13:26   ` zimoun
  2020-02-05 13:52     ` Marc Chantreux
  2020-02-05 13:49   ` Marc Chantreux
  1 sibling, 1 reply; 13+ messages in thread
From: zimoun @ 2020-02-05 13:26 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: Julien Lepiller, guile-user

Hi,

On Wed, 5 Feb 2020 at 14:10, Ricardo Wurmus <rekado@elephly.net> wrote:

> >     ctags -L - -f ~/.vim/ctags/guile

Is 'ctags -L' a valid option?
Because I do not find the documentation about it.


All the best,
simon



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-02-05 13:08 ` Ricardo Wurmus
  2020-02-05 13:26   ` zimoun
@ 2020-02-05 13:49   ` Marc Chantreux
  1 sibling, 0 replies; 13+ messages in thread
From: Marc Chantreux @ 2020-02-05 13:49 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: julien, guile-user

hello Ricardo,

> I’m still not sure I understand exactly what the result of this should
> be (as I’m not familiar with ctags), but you can get a list of loaded
> modules and the symbols they export.

i deeply regret the way i turned my message. please forget everything
you read and start with a fresh base:

i need the list of the symbols that are available for completion. i
guess some are built-in (map, apply, define, use-module ...) and others
come from modules.

my question is: how to collect this list.

> This expression, for example, will print all symbols that are exported
> by the (texinfo) module

with GNU Guile 2.2.4, i got

    ice-9/boot-9.scm:1978:2:
    In procedure struct_vtable: Wrong type argument in position 1 (expecting struct): #f

but reading the code, i guess you just solved a part of the problem: get
the symbols available in 1 module.

so now i need all the default symbols. maybe we should just copy them
from a documentation instead of introspect the guile interpreter?

> You can get a hash table of all loaded modules with
>     (module-submodules (resolve-module '() #f #f #:ensure #f))

which means i need to run the current code. this is tricky...

probably i should write something that:

* parses the current source
* try to find the 'use-modules' s-expr
* run it
* run your code

not my current scheme level but it should be a good exercise. i guess i
need a reader.

regards
marc



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-02-05 13:26   ` zimoun
@ 2020-02-05 13:52     ` Marc Chantreux
  2020-02-05 15:39       ` zimoun
  0 siblings, 1 reply; 13+ messages in thread
From: Marc Chantreux @ 2020-02-05 13:52 UTC (permalink / raw)
  To: zimoun; +Cc: Julien Lepiller, guile-user

hello,

    > > >     ctags -L - -f ~/.vim/ctags/guile
    > 
    > Is 'ctags -L' a valid option?
    > Because I do not find the documentation about it.

--help of Exuberant Ctags 5.9~svn20110310 say:

      -L <file>
           A list of source file names are read from the specified file.

regards
marc



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-02-05 12:58 ` Ricardo Wurmus
@ 2020-02-05 14:26   ` Marc Chantreux
  0 siblings, 0 replies; 13+ messages in thread
From: Marc Chantreux @ 2020-02-05 14:26 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: julien, guile-user

hello,

sorry i missed this reply.

> Does it make sense for your application to auto compile sources at all?

not at all :)

> I also wonder if perhaps it would be better to start a Guile REPL and
> have vim send S-expressions to the socket instead of saving a temporary
> file and starting a new Guile process every time.

it should be another way to make vim work with guile but i need the
single command thing because it's the way to use the vim :make command

* run a command
* parse stderr to create a list of errors
* use the :cwindow to navigate through the commands

regards
marc



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-02-05 13:52     ` Marc Chantreux
@ 2020-02-05 15:39       ` zimoun
  2020-02-05 16:56         ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: zimoun @ 2020-02-05 15:39 UTC (permalink / raw)
  To: Marc Chantreux; +Cc: Julien Lepiller, guile-user

salut,

On Wed, 5 Feb 2020 at 15:35, Marc Chantreux <mc@unistra.fr> wrote:

>     > > >     ctags -L - -f ~/.vim/ctags/guile

>     > Is 'ctags -L' a valid option?
>     > Because I do not find the documentation about it.
>
> --help of Exuberant Ctags 5.9~svn20110310 say:
>
>       -L <file>
>            A list of source file names are read from the specified file.

Héhé. This option is not in my version:

ctags --version
ctags (GNU Emacs 26.3)
Copyright (C) 2019 Free Software Foundation, Inc.
This program is distributed under the terms in ETAGS.README


Thanks
simon



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: scheme with vim
  2020-02-05 15:39       ` zimoun
@ 2020-02-05 16:56         ` Eli Zaretskii
  0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2020-02-05 16:56 UTC (permalink / raw)
  To: zimoun; +Cc: julien, guile-user

> From: zimoun <zimon.toutoune@gmail.com>
> Date: Wed, 5 Feb 2020 16:39:00 +0100
> Cc: Julien Lepiller <julien@lepiller.eu>, guile-user@gnu.org
> 
> >     > Is 'ctags -L' a valid option?
> >     > Because I do not find the documentation about it.
> >
> > --help of Exuberant Ctags 5.9~svn20110310 say:
> >
> >       -L <file>
> >            A list of source file names are read from the specified file.
> 
> Héhé. This option is not in my version:
> 
> ctags --version
> ctags (GNU Emacs 26.3)
> Copyright (C) 2019 Free Software Foundation, Inc.
> This program is distributed under the terms in ETAGS.README

You can instead redirect the file from stdin:

  ctags -

will read the list of files from stdin, one file name per line of
input.  See "ctags --help".



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-02-05 16:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-29 15:56 scheme with vim Marc Chantreux
2020-01-29 18:34 ` Ricardo Wurmus
2020-01-29 20:29   ` zimoun
2020-01-29 20:53     ` Marc Chantreux
2020-01-29 21:04       ` zimoun
2020-02-05 12:58 ` Ricardo Wurmus
2020-02-05 14:26   ` Marc Chantreux
2020-02-05 13:08 ` Ricardo Wurmus
2020-02-05 13:26   ` zimoun
2020-02-05 13:52     ` Marc Chantreux
2020-02-05 15:39       ` zimoun
2020-02-05 16:56         ` Eli Zaretskii
2020-02-05 13:49   ` Marc Chantreux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).