Next: , Previous: , Up: 贡献   [Contents][Index]


22.3 完美的配置

折腾 Guix 的完美配置也是折腾 Guile 的完美配置 see Using Guile in Emacs in Guile Reference Manual)。首先,你需要的不仅是一个编辑器,你需要 Emacs,以及美妙的 Geiser。为此,运行:

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

Geiser 允许在 Emacs 里进行交互式的、增长式的开发:buffer 里的代码补全和执行,获取一行的文档 (docstrings),上下文敏感的补全,M-. 跳转到对象定义,测试代码的 REPL,及更多(see Introduction in Geiser User Manual)。为了方便的 Guix 开发,请确保修改 Guile 的加载路径 (load path) 以使其能从你的项目里找到源代码文件:

;; 假设Guix项目在 ~/src/guix.
(with-eval-after-load 'geiser-guile
  (add-to-list 'geiser-guile-load-path "~/src/guix"))

真正编辑代码时别忘了 Emacs 自带了方便的 Scheme 模式。而且,一定不要错过 Paredit。它提供了直接操作语法树的的功能,例如,用 S- 表达式替换父节点,为 S- 表达式添加、删除前后的括号,删除后面的 S- 表达式,等等。

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/*"))

commit信息片段显示staged文件需要依赖Magit。编辑commit信息时,输入add,然后按TAB就可以插入一段用于新增软件包的模板;输入update,然后按TAB可以插入一段更新软件包的模板;输入https然后按TAB可以插入一段修改主页URI为HTTPS的模板。

scheme-mode最重要的模板可以通过输入package...,然后按TAB触发。这个片段还插入了触发字符串origin...,以进一步展开。origin片段更进一步的可能插入其它以...结尾的触发字符串,它们可以被继续展开。

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 "alice@mail.org")
;; 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.


Next: 打包指导, Previous: 在安装之前运行Guix, Up: 贡献   [Contents][Index]