garden/content/daily/2024-06-18.md
SouthFox c60fe31906
All checks were successful
/ deploy (push) Successful in 53s
[post] new post
2024-06-19 00:33:12 +08:00

2 KiB
Raw Blame History

+++ title = 2024-06-18 author = ["SouthFox"] date = 2024-06-18T08:22:00+08:00 lastmod = 2024-06-19T00:33:10+08:00 tags = ["publish"] draft = false +++

梦记

在做一个针对幽默感的试卷,最后甚至还要写作文?写了一点后不想写了。 之后梦见自己起床已是九点,去到隔壁房间但出现了我哥他甚至是语文科代表在收作业。

想找本来抄抄但在那左选右选的,似乎还有人在做词?

Emacs 折腾继续

继续昨天 [2024-06-17]({{< relref "2024-06-17.md" >}}) 的折腾里 [来把 org-roam 笔记发布出去吧]({{< relref "../articles/来把 org-roam 笔记发布出去吧.md" >}}) 的发布函数,因为昨天加装的函数存在两个问题:

  • 有时候可能要处理多个文件不想直接 push
  • push 的网络操作会卡住整个程序

对于第一点,搜到了 yes-or-no-p 这个函数,可以在下面的小缓冲里询问 y 或 n 然后根据回答给表达式赋值。 Yes-or-No Queries (GNU Emacs Lisp Reference Manual)

第二点emacs 也提供了 async-shell-command ,来异步执行命令,同时将命令的输出缓冲定义为 *Messages*Single Shell (GNU Emacs Manual)

之后折腾完的函数成了这个样子:

(defun my/org-roam-publish ()
  "Publish current file"
  (interactive)
  (org-roam-update-org-id-locations)
  (org-roam-set-keyword "filetags" ":publish:")
  (save-buffer)
  (org-hugo-export-wim-to-md)
  (async-shell-command (concat
                        "cd " org-hugo-base-dir
                        " && " "git add ."
                        (if (yes-or-no-p "Push now?")
                            (concat " && " "git commit -m '[post] new post'"
                                    " && " "git push"))) "*Messages*")
  (message "publish nwe post!"))