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

22.5 完美的配置

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



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

(setq user-full-name "Alice Doe")
(setq user-mail-address "")
;; 假设 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]