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 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 (see Introduction in 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.

真正编辑代码时别忘了 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.

;; 假设 Guix 签出在 ~/src/guix 中。
;; Yasnippet 配置
(with-eval-after-load 'yasnippet
  (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets/yas"))
;; Tempel 配置
(with-eval-after-load 'tempel
   ;; 确保 tempel-path 是一个列表——它也可以是一个字符串。
   (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片段更进一步的可能插入其它以...结尾的触发字符串,它们可以被继续展开。

我们在etc/copyright.el 中额外提供了版权的插入和自动更新。你也许会想要设置你的全名,邮箱以及加载一个文件。

(setq user-full-name "Alice Doe")
(setq user-mail-address "alice@mail.org")
;; 假设 Guix 签出在 ~/src/guix。
(load-file "~/src/guix/etc/copyright.el")

要在当前行插入版权信息,调用M-x guix-copyright

要更新一个版权信息,你需要指定 copyright-names-regexp

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

你可以通过执行 M-x copyright-update 检查版权信息是否已更新。若你想要在每次缓存区保存后自动做这件事,就在 Emacs 中添加 (add-hook 'after-save-hook 'copyright-update)


Next: Alternative Setups, Previous: 在安装之前运行Guix, Up: 贡献   [Contents][Index]