SouthFox's Garden

Search IconA magnifying glass icon. 搜索

2024-06-18

梦记

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

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

Emacs 折腾继续

继续昨天 2024-06-17 的折腾里 来把 org-roam 笔记发布出去吧 的发布函数,因为昨天加装的函数存在两个问题:

  • 有时候可能要处理多个文件不想直接 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!"))

反向链接

    评论