Próximo: , Anterior: , Acima: Contribuindo   [Conteúdo][Índice]

22.3 A configuração perfeita

The Perfect Setup to hack on Guix is basically the perfect setup used for Guile hacking (veja Using Guile in Emacs em Guile Reference Manual). First, you need more than an editor, you need Emacs, empowered by the wonderful Geiser. To set that up, run:

guix install emacs guile emacs-geiser emacs-geiser-guile

Geiser allows for interactive and incremental development from within Emacs: code compilation and evaluation from within buffers, access to on-line documentation (docstrings), context-sensitive completion, M-. to jump to an object definition, a REPL to try out your code, and more (veja Introduction em Geiser User Manual). If you allow Emacs to load the .dir-locals.el file at the root of the project checkout, it will cause Geiser to automatically add the local Guix sources to the Guile load path.

To actually edit the code, Emacs already has a neat Scheme mode. But in addition to that, you must not miss Paredit. It provides facilities to directly operate on the syntax tree, such as raising an s-expression or wrapping it, swallowing or rejecting the following s-expression, etc.

We also provide templates for common git commit messages and package definitions in the etc/snippets directory. These templates can be used to expand short trigger strings to interactive text snippets. If you use YASnippet, you may want to add the etc/snippets/yas snippets directory to the yas-snippet-dirs variable. If you use Tempel, you may want to add the etc/snippets/tempel/* path to the tempel-path variable in Emacs.

;; Assuming the Guix checkout is in ~/src/guix.
;; Yasnippet configuration
(with-eval-after-load 'yasnippet
  (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets/yas"))
;; Tempel configuration
(with-eval-after-load 'tempel
   ;; Ensure tempel-path is a list -- it may also be a string.
   (unless (listp 'tempel-path)
     (setq tempel-path (list tempel-path)))
   (add-to-list 'tempel-path "~/src/guix/etc/snippets/tempel/*"))

Os trechos de mensagens de commit dependem de Magit para exibir arquivos "staged". Ao editar uma mensagem de commit, digite add seguido por TAB para inserir um modelo de mensagem de commit para adicionar um pacote; digite update seguido por TAB para inserir um modelo para atualizar um pacote; digite https seguido por TAB para inserir um modelo para alterar a URI da página inicial de um pacote para HTTPS.

O trecho principal para scheme-mode é acionado digitando package ... seguido de TAB. Esse trecho também insere a string de acionamento origin..., que pode ser expandida ainda mais. O trecho origin, por sua vez, pode inserir outras strings acionadoras que terminam em ..., que também podem ser expandidas.

We additionally provide insertion and automatic update of a copyright in etc/copyright.el. You may want to set your full name, mail, and load a file.

(setq user-full-name "Alice Doe")
(setq user-mail-address "")
;; Assuming the Guix checkout is in ~/src/guix.
(load-file "~/src/guix/etc/copyright.el")

To insert a copyright at the current line invoke M-x guix-copyright.

To update a copyright you need to specify a copyright-names-regexp.

(setq copyright-names-regexp
      (format "%s <%s>" user-full-name user-mail-address))

You can check if your copyright is up to date by evaluating M-x copyright-update. If you want to do it automatically after each buffer save then add (add-hook 'after-save-hook 'copyright-update) in Emacs.

22.3.1 Viewing Bugs within Emacs

Emacs has a nice minor mode called bug-reference, which, when combined with ‘emacs-debbugs’ (the Emacs package), can be used to open links such as ‘<>’ or ‘<>’ as bug report buffers. From there you can easily consult the email thread via the Gnus interface, reply or modify the bug status, all without leaving the comfort of Emacs! Below is a sample configuration to add to your ~/.emacs configuration file:

;;; Bug references.
(require 'bug-reference)
(add-hook 'prog-mode-hook #'bug-reference-prog-mode)
(add-hook 'gnus-mode-hook #'bug-reference-mode)
(add-hook 'erc-mode-hook #'bug-reference-mode)
(add-hook 'gnus-summary-mode-hook #'bug-reference-mode)
(add-hook 'gnus-article-mode-hook #'bug-reference-mode)

;;; This extends the default expression (the top-most, first expression
;;; provided to 'or') to also match URLs such as
;;; <> or <>.
;;; It is also extended to detect "Fixes: #NNNNN" git trailers.
(setq bug-reference-bug-regexp
      (rx (group (or (seq word-boundary
                          (or (seq (char "Bb") "ug"
                                   (zero-or-one " ")
                                   (zero-or-one "#"))
                              (seq (char "Pp") "atch"
                                   (zero-or-one " ")
                              (seq (char "Ff") "ixes"
                                   (zero-or-one ":")
                                   (zero-or-one " ") "#")
                              (seq "RFE"
                                   (zero-or-one " ") "#")
                              (seq "PR "
                                   (one-or-more (char "a-z+-")) "/"))
                          (group (one-or-more (char "0-9"))
                                  (seq "#" (one-or-more
                                            (char "0-9"))))))
                     (seq "<"
                          (group-n 2 (one-or-more (char "0-9")))
(setq bug-reference-url-format "")

(require 'debbugs)
(require 'debbugs-browse)
(add-hook 'bug-reference-mode-hook #'debbugs-browse-mode)
(add-hook 'bug-reference-prog-mode-hook #'debbugs-browse-mode)

;; The following allows Emacs Debbugs user to open the issue directly within
;; Emacs.
(setq debbugs-browse-url-regexp
      (rx line-start
          "http" (zero-or-one "s") "://"
          (or "debbugs" "issues.guix" "bugs")
          "" (one-or-more "/")
          (group (zero-or-one "cgi/bugreport.cgi?bug="))
          (group-n 3 (one-or-more digit))

For more information, refer to Bug Reference em The GNU Emacs Manual and Minor Mode em The Debbugs User Guide.

Próximo: Diretrizes de empacotamento, Anterior: Executando guix antes dele ser instalado, Acima: Contribuindo   [Conteúdo][Índice]