Org: complicate package! statement for dev and use

This commit is contained in:
TEC 2021-05-01 20:26:21 +08:00
parent df5c95068e
commit b52bb68535
Signed by: tec
GPG Key ID: 779591AFDB81F06C
1 changed files with 39 additions and 3 deletions

View File

@ -1620,9 +1620,45 @@ I think the latest AucTeX may be a bit dodgy, so
#+end_src
*** Org Mode
Use ~HEAD~ for development.
#+begin_src emacs-lisp
(package! org-mode :pin nil)
There are actually three possible package statements I may want to use for Org.
If I'm on a machine where I can push changes, I want to be able to develop Org.
I can check this by checking the content of the SSH key =~/.ssh/id_ed25519.pub=.
1. If this key exists and there isn't a repo at
=$straight-base-dir/straight/repos/org-mode= with the right remote, we should
install it as such.
2. If the key exists and repo are both set up, the package should just be ignored.
3. If the key does not exist, the Org's ~HEAD~ should just be used
To account for this situation properly, we need a short script to determine the
correct package statement needed.
#+name: org-pkg-statement
#+begin_src emacs-lisp :tangle no
(setq doom-first-input-hook nil) ; HACK temporary bugfix
(load (expand-file-name "core/core.el" user-emacs-directory) nil t) ; for `doom-local-dir'
(let ((dev-key (and (file-exists-p "~/.ssh/id_ed25519.pub")
(= 0 (shell-command "cat ~/.ssh/id_ed25519.pub | grep -q AAAAC3NzaC1lZDI1NTE5AAAAIOZZqcJOLdN+QFHKyW8ST2zz750+8TdvO9IT5geXpQVt"))))
(dev-pkg (let ((default-directory (expand-file-name "straight/repos/org-mode" doom-local-dir)))
(and (file-exists-p default-directory)
(string= "git@code.orgmode.org:bzg/org-mode.git\n" (shell-command-to-string "git remote get-url origin"))))))
(prin1-to-string
(cond ((and dev-key dev-pkg)
`(package! org-mode
:recipe (:local-repo ,(expand-file-name "straight/repos/org-mode" doom-local-dir)
:files ("*.el" "lisp/*.el" "contrib/lisp/*.el" "contrib/scripts"))
:pin nil))
(dev-key
`(package! org-mode
:recipe (:host nil :repo "git@code.orgmode.org:bzg/org-mode.git"
:files ("*.el" "lisp/*.el" "contrib/lisp/*.el" "contrib/scripts"))
:pin nil)
(t `(package! org-mode :pin nil))))))
#+end_src
#+begin_src emacs-lisp :noweb no-export
<<org-pkg-statement()>>
#+end_src
**** Improve agenda/capture