为什么私有层里面的代码不会被执行?

(defconst XYLayer-packages
  '(
    (org :location built-in)
    (linum :location built-in)
    )
  )

(defun XYLayer/post-init-linum()
  (use-package linum
    :defer t
    :config
    (progn
      (message ">>> Linum mode was loaded"))))

上面的代码理论上来说 linum 被加载后就会被调用呀?没反应呀???linum 模式已经被调用了呀!

关于 :location build-in 的文档没找到呀。

如果要执行 post-init-xxx, 你必须在某个地方找到 init-xxx,如果没有 init-xxx, 你这里就不应该用 post-init,而应该改成 init

但是文档说了一个插件只能有一个 init 呀?这怎么能保证不冲突呢?我有怎么能直到这个插件有没有被 init 过呢?

换成 init 就好了,但是还是上面的问题。

我有怎么能知道这个插件有没有被 init 过呢?

如果冲突了,你看看Message buffer 里面会有警告的。。。

没有聪明点的办法么。。。。还有关于 location 我并没有找到 build-in 的文档诶

现在是这样的,


(defun XYLayer/init-linum()
  (use-package linum
    :defer t
    :config
    (progn
      (global-linum-mode 1)
      (linum-relative-global-mode 1)
      )))

但是显示,

Error (use-package): linum :config: Symbol’s function definition is void: linum-relative-global-mode

我已经 defer 了呀 :frowning:

我在 customiz-group 中做的设置的内容,也被后来修改了。我该如何知道,这个值是什么时候在什么地方被修改的呢?

@XCREATES

在 config 的前面添加 :commands (linum-relative-global-mode) 试试

(defun XYLayer/init-linum()
  (use-package linum
    :defer t
    :commands
    (linum-relative-global-mode)
    :config
    (progn
      (global-linum-mode 1)
      )))

现在的样子,并没有用。

;;  __             __   ___  __   __        __
;; |  \  /\  |\ | / _` |__  |__) /  \ |  | /__`
;; |__/ /~~\ | \| \__> |___ |  \ \__/ \__/ .__/
;; --------------------------------------------
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(global-linum-mode t)
 '(linum-relative-global-mode t)
 '(package-selected-packages
 ;; 后面的省略了

上面是我用 custmoize group 改的变量,然后 global-linum-mode 有效, 但是 linum-realtvie-global-mode 显示被修改成 nil 了

我一会弄一个给你,我现在在 fix 一些问题。

1 个赞

我的层在下面

https://github.com/li-xinyang/TL_Dotfile/tree/master/spacemacs_private_layer/XYLayer

(setq guanghui-packages
      '(
        linum-relative
        ))
(defun guanghui/post-init-linum-relative ()
  (progn
    (add-hook 'prog-mode-hook 'linum-mode)
    (with-eval-after-load 'linum-mode
      (linum-relative-on))))

只在编程模式下面开启行号,因为行号在大的 org 文件里面比较卡,建议不开启。

1 个赞

你如何找到 这个是 linum-relative mode 的呢?然后你如何确定这个不需要 :location build-int 呢?

还是不行。。。。放弃了 我全部塞 .spacemacs 里面吧 暂时不写自己的 layer 了 5555

1 个赞

linum-relative-global-mode 是一个单独的 mode ,你可以通过 SPC h d f 查看 linum-relative-global-mode 的定义

linum-relative-global-mode is an interactive autoloaded Lisp function in
`linum-relative.el'.

貌似没什么好办法判断一个 package 是否已经被另外一个 layer 所拥有(init),但是你会收到 Warning

1 个赞

我配了两天的 private layer 不成,我暂时决定把所有配置都塞到 spaqcemacs 文件里面了。我去你 github 没找到你的配置呀,还想学习下嘞。

昂有早期抄子龙的配置,后来基于 spacemacs-base 配置的,因为有个人信息又懒得 git 就只放网盘了。

1 个赞

好哒 我躶体全放 github 了。。。包括每天的任务清单,可以用黑话写嘛。 :sunglasses:

重点是 嘛😂

1 个赞

有个变通方法可以试试:在.spacemacs中定义default-layer为你自已的layer

1 个赞

我去看看什么是 default-layer,和它的设置方法。谢谢

可以在post-init中定义with-eval-after-load来给package添加配置。