From c60fe319067def014c18fe81babdd3ccef6581f7 Mon Sep 17 00:00:00 2001 From: SouthFox Date: Wed, 19 Jun 2024 00:33:12 +0800 Subject: [PATCH] [post] new post --- content/daily/2024-06-18.md | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 content/daily/2024-06-18.md diff --git a/content/daily/2024-06-18.md b/content/daily/2024-06-18.md new file mode 100644 index 0000000..16e7ccc --- /dev/null +++ b/content/daily/2024-06-18.md @@ -0,0 +1,46 @@ ++++ +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 折腾继续 {#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)](https://www.gnu.org/software/emacs/manual/html_node/elisp/Yes_002dor_002dNo-Queries.html) + +第二点,emacs 也提供了 `async-shell-command` ,来异步执行命令,同时将命令的输出缓冲定义为 `*Messages*` 。 [Single Shell (GNU Emacs Manual)](https://www.gnu.org/software/emacs/manual/html_node/emacs/Single-Shell.html) + +之后折腾完的函数成了这个样子: + +```emacs-lisp +(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!")) +```