unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Emacs and Geiser: Completion for Guix specific code?
@ 2022-11-16 11:07 Mekeor Melire
  2022-11-16 11:49 ` Mekeor Melire
  2022-11-16 14:51 ` Luis Felipe
  0 siblings, 2 replies; 5+ messages in thread
From: Mekeor Melire @ 2022-11-16 11:07 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

Hello,

when editing a Guix system declaration (system.scm) with GNU Emacs and
Geiser (and corfu.el), can I get completion for Guix specific code?
Right now, I only get completion suggestions based on generic Guile
modules. E.g. completing "(ope" (by pressing C-M-i) does not offer
"(operating-system", but only "(open" etc. from module (guile). Is there
any way to get completion for the Guix-specific code?

You can reproduce the reported behaviour as follows.

1. Save the attached mre.el and mre.scm files somewhere.
2. Modify the path to the Guix repository inside mre.el.
3. Make sure you have these packages installed, e.g. with a guix-shell:

   guix shell emacs emacs-corfu emacs-corfu-doc emacs-geiser \
     emacs-geiser-guile guile

4. Open that directory in a shell, navigate to the saved files, and
   launch Emacs:

   emacs -Q -l mre.el

5. In Emacs, open mre.scm, start Geiser with M-x geiser RET, navigate
   the cursor to "(opeHERE", and press C-M-i (which runs
   completion-at-point). You'll see that it does not suggest
   "operating-system". (Even if you have compiled all Guix inside your
   local clone of its repository.)

Kindly
Mekeor



[-- Attachment #2: mre.el --]
[-- Type: text/plain, Size: 327 bytes --]

(require 'corfu)
(setq
  corfu-auto t
  corfu-auto-prefix 0
  corfu-quit-no-match t)
(global-corfu-mode)

;; optional:
(require 'corfu-doc)
(add-to-list 'corfu-mode-hook #'corfu-doc-mode)

(require 'geiser-guile)
(with-eval-after-load 'geiser-guile
  (add-to-list 'geiser-guile-load-path "/home/user/path/to/guix/repository"))

[-- Attachment #3: mre.scm --]
[-- Type: text/plain, Size: 55 bytes --]

(use-modules
 (gnu)
 (gnu system)
 (guix utils))

(ope

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

* Re: Emacs and Geiser: Completion for Guix specific code?
  2022-11-16 11:07 Emacs and Geiser: Completion for Guix specific code? Mekeor Melire
@ 2022-11-16 11:49 ` Mekeor Melire
  2022-11-16 14:51 ` Luis Felipe
  1 sibling, 0 replies; 5+ messages in thread
From: Mekeor Melire @ 2022-11-16 11:49 UTC (permalink / raw)
  To: Mekeor Melire; +Cc: help-guix

[-- Attachment #1: Type: text/plain, Size: 89 bytes --]

Sorry, I think the attached files were not separated well. Maybe it's
better this time!


[-- Attachment #2: mre.el --]
[-- Type: text/plain, Size: 327 bytes --]

(require 'corfu)
(setq
  corfu-auto t
  corfu-auto-prefix 0
  corfu-quit-no-match t)
(global-corfu-mode)

;; optional:
(require 'corfu-doc)
(add-to-list 'corfu-mode-hook #'corfu-doc-mode)

(require 'geiser-guile)
(with-eval-after-load 'geiser-guile
  (add-to-list 'geiser-guile-load-path "/home/user/path/to/guix/repository"))

[-- Attachment #3: mre.scm --]
[-- Type: text/plain, Size: 55 bytes --]

(use-modules
 (gnu)
 (gnu system)
 (guix utils))

(ope

[-- Attachment #4: Type: text/plain, Size: 1683 bytes --]


2022-11-16 / 11:07 / mekeor@posteo.de:

> Hello,
>
> when editing a Guix system declaration (system.scm) with GNU Emacs and
> Geiser (and corfu.el), can I get completion for Guix specific code?
> Right now, I only get completion suggestions based on generic Guile
> modules. E.g. completing "(ope" (by pressing C-M-i) does not offer
> "(operating-system", but only "(open" etc. from module (guile). Is there
> any way to get completion for the Guix-specific code?
>
> You can reproduce the reported behaviour as follows.
>
> 1. Save the attached mre.el and mre.scm files somewhere.
> 2. Modify the path to the Guix repository inside mre.el.
> 3. Make sure you have these packages installed, e.g. with a guix-shell:
>
>    guix shell emacs emacs-corfu emacs-corfu-doc emacs-geiser \
>      emacs-geiser-guile guile
>
> 4. Open that directory in a shell, navigate to the saved files, and
>    launch Emacs:
>
>    emacs -Q -l mre.el
>
> 5. In Emacs, open mre.scm, start Geiser with M-x geiser RET, navigate
>    the cursor to "(opeHERE", and press C-M-i (which runs
>    completion-at-point). You'll see that it does not suggest
>    "operating-system". (Even if you have compiled all Guix inside your
>    local clone of its repository.)
>
> Kindly
> Mekeor
>
>
> (require 'corfu)
> (setq
>   corfu-auto t
>   corfu-auto-prefix 0
>   corfu-quit-no-match t)
> (global-corfu-mode)
>
> ;; optional:
> (require 'corfu-doc)
> (add-to-list 'corfu-mode-hook #'corfu-doc-mode)
>
> (require 'geiser-guile)
> (with-eval-after-load 'geiser-guile
>   (add-to-list 'geiser-guile-load-path "/home/user/path/to/guix/repository"))
>
> (use-modules
>  (gnu)
>  (gnu system)
>  (guix utils))
>
> (ope

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

* Re: Emacs and Geiser: Completion for Guix specific code?
  2022-11-16 11:07 Emacs and Geiser: Completion for Guix specific code? Mekeor Melire
  2022-11-16 11:49 ` Mekeor Melire
@ 2022-11-16 14:51 ` Luis Felipe
  2022-11-16 16:41   ` Mekeor Melire
  1 sibling, 1 reply; 5+ messages in thread
From: Luis Felipe @ 2022-11-16 14:51 UTC (permalink / raw)
  To: Mekeor Melire; +Cc: help-guix


[-- Attachment #1.1: Type: text/plain, Size: 1572 bytes --]

Hi Mekeor,


------- Original Message -------
On Wednesday, November 16th, 2022 at 11:07, Mekeor Melire <mekeor@posteo.de> wrote:

> Hello,
> 

> when editing a Guix system declaration (system.scm) with GNU Emacs and
> Geiser (and corfu.el), can I get completion for Guix specific code?

You should be able to. I can get completion for Guix or any other library, although not automatically as with IDEs for other languages.


> Right now, I only get completion suggestions based on generic Guile
> modules. E.g. completing "(ope" (by pressing C-M-i) does not offer
> "(operating-system", but only "(open" etc. from module (guile). Is there
> any way to get completion for the Guix-specific code?

As far as I know, you can only get completion for symbols defined in other modules and libraries if

1. The library is in Guile's load path and
2. The module import is evaluated

The first requirement is handled automatically when the library is installed with Guix. The second one too, if you are typing in a REPL. If you are typing in a file, it isn't; you have to command the evaluation yourself. For example, in Guix System, I start Emacs, visit a file, and run geiser-guile. Then, to call Guix's "package-direct-inputs", I type the following

  (use-modules (guix packages))

  ;;; C-c C-B to evaluate the buffer and get completion for symbols in (guix packages)
  ;;; Then, start typing and press C-M-i. It should complete.
  (package-di

  ;;; If you don't evaluate the module imports, completion won't work.

Does that work for you?

[-- Attachment #1.2: publickey - luis.felipe.la@protonmail.com - 0x12DE1598.asc --]
[-- Type: application/pgp-keys, Size: 1722 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 509 bytes --]

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

* Re: Emacs and Geiser: Completion for Guix specific code?
  2022-11-16 14:51 ` Luis Felipe
@ 2022-11-16 16:41   ` Mekeor Melire
  2022-11-16 23:27     ` Luis Felipe
  0 siblings, 1 reply; 5+ messages in thread
From: Mekeor Melire @ 2022-11-16 16:41 UTC (permalink / raw)
  To: Luis Felipe; +Cc: Mekeor Melire, help-guix

2022-11-16 / 14:51 / luis.felipe.la@protonmail.com:

> Hi Mekeor,

Hello Luis Felipe,

> On Wednesday, November 16th, 2022 at 11:07, Mekeor Melire <mekeor@posteo.de> wrote:

> As far as I know, you can only get completion for symbols defined in other modules and libraries if
>
> 1. The library is in Guile's load path and
> 2. The module import is evaluated
>
> The first requirement is handled automatically when the library is installed
> with Guix. The second one too, if you are typing in a REPL. If you are typing in
> a file, it isn't; you have to command the evaluation yourself. For example, in
> Guix System, I start Emacs, visit a file, and run geiser-guile. Then, to call
> Guix's "package-direct-inputs", I type the following
>
>   (use-modules (guix packages))
>
>   ;;; C-c C-B to evaluate the buffer and get completion for symbols in (guix packages)
>   ;;; Then, start typing and press C-M-i. It should complete.
>   (package-di
>
>   ;;; If you don't evaluate the module imports, completion won't work.
>
> Does that work for you?


Yippie, it works! I just needed to run geiser-eval-buffer, bound to C-c
C-b. Now it completes imported identifiers as well, yay! :) Thank you
very much.

Still, a pity/bummer that it completion does not consider record-fields.
E.g. within the (operating-system) record, the completion could know
that I want to specify one of the record-fields, rather than suggesting
arbitrary identifiers. (Maybe it's because Scheme is not a typed
language.) Nevertheless, it's very helpful and nice.

Kindly
Mekeor


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

* Re: Emacs and Geiser: Completion for Guix specific code?
  2022-11-16 16:41   ` Mekeor Melire
@ 2022-11-16 23:27     ` Luis Felipe
  0 siblings, 0 replies; 5+ messages in thread
From: Luis Felipe @ 2022-11-16 23:27 UTC (permalink / raw)
  To: Mekeor Melire; +Cc: help-guix


[-- Attachment #1.1: Type: text/plain, Size: 656 bytes --]

On Wednesday, November 16th, 2022 at 16:41, Mekeor Melire <mekeor@posteo.de> wrote:

> Yippie, it works! I just needed to run geiser-eval-buffer, bound to C-c
> C-b. Now it completes imported identifiers as well, yay! :) Thank you
> very much.

Great :)


> Still, a pity/bummer that it completion does not consider record-fields.
> E.g. within the (operating-system) record, the completion could know
> that I want to specify one of the record-fields, rather than suggesting
> arbitrary identifiers. (Maybe it's because Scheme is not a typed
> language.) Nevertheless, it's very helpful and nice.

I don't the reason, but I'd like that too.

[-- Attachment #1.2: publickey - luis.felipe.la@protonmail.com - 0x12DE1598.asc --]
[-- Type: application/pgp-keys, Size: 1722 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 509 bytes --]

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

end of thread, other threads:[~2022-11-16 23:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 11:07 Emacs and Geiser: Completion for Guix specific code? Mekeor Melire
2022-11-16 11:49 ` Mekeor Melire
2022-11-16 14:51 ` Luis Felipe
2022-11-16 16:41   ` Mekeor Melire
2022-11-16 23:27     ` Luis Felipe

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).