【发布时间】:2021-04-26 06:52:41
【问题描述】:
目标
我希望通过引用文件user-config.org 和user-layers.org 来进一步扩展我的spacemacs 配置的模块化
模板
我通过将以下内容添加到我的 dotspacemacs/user-config 来实现前者:
(defun dotspacemacs/user-config ()
(org-babel-load-file (expand-file-name
"user-config.org" dotspacemacs-directory)))
我可以安全地试验,克隆同步,organize,版本控制user-config.org
问题
现在, dotspacemacs/user-layers 是一个变量(默认)设置在一个函数中,方式如下:
(defun dotspacemacs/layers ()
(setq-default
dotspacemacs-distribution 'spacemacs ;; not relevant
;;
;; many such default variable-value lines in between, skipped.
;;
dotspacemacs-configuration-layers
'(
;;
;; many layers auto-added/managed by spacemacs
;;
git
(python :variables python-backend 'lsp
python-lsp-server 'pyright
;; other such python configurations
python-formatter 'yapf))
;; other such default varialbe-value declarations
)
)
尝试
我尝试通过以下方式在setq-default 的末尾添加类似的继承(如user-config),
- 注意
dotspacemacs-configuration-layers不能在函数dotspacemacs/layers之外修改,因此必须在该函数中调用对文件的引用。
(defun dotspacemacs/layers ()
(setq-default
dotspacemacs-distribution 'spacemacs
;;
;; many such default variable-value lines in between, skipped.
;;
dotspacemacs-configuration-layers
'(
;; whatever spacemacs wants to auto-add
)
;; other such default variable-value declarations
)
(org-babel-load-file (expand-file-name
"user-layers.org" dotspacemacs-directory))
)
——这样user-layers.org 的格式如下:
引用org-mode文件:
- dotspacemacs 层
#+BEGIN_SRC emacs-lisp
(append dotspacemacs-configuration-layers
'(
;;
;; Other layers managed by the user
;;
git
(python :variables python-backend 'lsp
python-lsp-server 'pyright
;; other such python configurations
python-formatter 'yapf)))
#+END_SRC
失败
但是,append 似乎不会将元素添加到 seq-default 值。
我猜它附加到变量的本地 setq 值。
(我可能错了,因为 lisp 不是我的母语,python 才是。)
问题:
有没有办法通过添加另一个列表中的元素来扩展 emacs-lisp 中列表的 默认 值?
澄清:
——这样添加后,列表的默认值包含新添加的元素。
【问题讨论】:
-
鉴于This Important Note,分开纠结和(加载user-layers.el)似乎更明智。