另一个下午:拖延癌晚期的绝望

描述另一个下午的另一个下午(补充,应该加上和晚上)。

在另一个我发现不适合打球、谈恋爱和看数学书的下午里(i.e. some afternoon after 手受了沉重一击,心受沉重一击),我打算翻开在我硬盘里吃灰久矣的 Zen and the Art of Motorcycle Maintenance,或许该把没喝完的鸡汤喝了,结果发现人倒霉的时候喝个鸡汤都难遂愿,鸡汤不翼而飞了。只得再做一碗,做完之后发现一个问题,我上次看到哪了?刻不容缓的问题一时半会没有答案,只好从头再来。

俄儿,我发现一口鸡汤有点甜,似乎可以分成几口吃。是以,我按下 Alt+c 打算用 org-mode 记录一下。我的 org-protocol url 还是古老的 org-protocol://capture://$key/$url/$title/$body 这种格式。于是 org-protocol 友善地提醒我 `Warning (emacs): Please update your org protocol handler to deal with new-style links.’

Enough is enough. 我更新还不行?org-protocol 官方文档 已经很老了。老到我根本找不到什么叫 new-style. 从某个邮件里终于找到了一点 new-style 的信息。结果还是没有从 Release notes 找到 new-style,最后终于发现我看的不是9.0的 release notes。总之,我终于可以开心地记笔记了。

俄儿,我发现每一个笔记都会创建一个新的 heading。 Enough is enough. 我为什么还忍受这破玩意,同一本书的笔记不能放到同一个 heading 下的破玩意?之前用的 tex 记笔记,那玩意更破。为保持我的 TeX-master 文件整洁,我给我看的每一本书都创建了一个 tex 文件。我转投 org-mode 因为它许诺我不需要为每一本书创建一个笔记文件。现在我用它为我的同一本书都创建了无数个 headings,我要它何用。

org-mode 的时候附送了一块砖。这砖太厚,我轻易不拿出来。是时候了,是时候翻一翻这块砖了。过了十分钟,我想我可以肯定这块砖上是不会有答案了。过了十分钟,我可以肯定煮菜书上也没有配方。于是只得看 duckduckgo 能不能帮我,喜剧的是我的问题也是别人的问题,悲剧的是别人的问题现在还是问题。

众所周知,如果你有用 emacs' 办不到的事情,那是你的问题,跟emacs’ 无关。我的问题确实很严重,我不会 elisp。可以使用 emacs 而不会 elisp 吗?当然可以,正如可以 enjoy watching porn without fapping. 这一次,我要好好撸一把了,既然用 (file+function "path/to/file" function-finding-location) 可以破解。我翻开了 elisp 从入门到精通。过了半个小时,我发现,我大约没法做到一个小时把这个问题解决,天要黑了,小朋友要出来游泳了。但是,我不知道怎么把 org-protocol 的信息传给这个 function-finding-location. 于是我在 reddit 发了个贴子,发完之后,跑去游泳池,果然,场子已经被小朋友给占了。

总之,这个下午我没有看数学书、谈恋爱、打球,我也没有看 Zen and the Art of Motocycle Maintenance,我没有看 org-mode manual,我更没有学 elisp,我只是在瞎折腾,浪费生命。我没药可救,我后悔不已。于是我写下了这文章以志之。我希望在接下来的日子里,我会珍爱生命,不让自己在年老时感到因为年轻的时候磋砣岁月一事无成而后悔不迭。

好吧,你要听实话。这文章不是为了告诉你,我怎么一个下午也没有解决一个问题的,也不是为了告诉你我的拖延征有多严重的,我写这个文章,只为找一件事,让我可以再拖延一个下午。

附上我现在的假想的看书流程(注意这是假想的,事实是我好久不看书了,也不写书,谢谢)。效果如下。

reading notes

我首先用 Sci-HubLibrary Genesis来下载图书或论文(elsevier 之流 go to hell, long live free access!),用 Google ScholarMathematical Reviews (自由访问万岁)来获取 bibtex 信息,将其导入后 Zotero,我可用 ZotFile 实现自动重命名,我用 fzf 来迅速找到文件,用 org mode capture 来迅速做笔记,我可以自动插入文件链接,自动获取当前页面,自动记录当前时间,用这个脚本 来预览 latex。

下面这个 bash 脚本是用 fzf 来快速打开书或者论文。

#!/bin/bash
if [[ $(uname) == 'Linux' ]]; then
    OPEN=xdg-open
    EMACS=~/.scripts/emacsclientmod
    FOLDER=/run/media/e/mdt/zotero/storage
    LOGDIR="$HOME/Sync/docs/tex/logbook/"
    logbookFile="$LOGDIR/logbook.tex"
elif [[ $(uname) == 'Darwin' ]]; then
    OPEN=open
    EMACS=emacsclient
    FOLDER=~/Onedrive/Sync/docs/tex
    LOGDIR=~/Sync/docs/tex/logbook
    logbookFile="$LOGDIR/logbook.tex"
else
    # TODO
    exit
fi

echo "working directory: $FOLDER"
cd "$FOLDER" || exit

searchFile() {
    IFS=$'\n' out=$(fzf-tmux --select-1 --exit-0 --expect=ctrl-o,ctrl-n)
    key=$(head -1 <<< "$out")
    fileName=$(head -2 <<< "$out" | tail -1)
}

preOpenFile() {
    if [ ! -f "$logFile" ]; then
        cat >"$logFile" << EOF
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "logbook"
%%% End:
EOF
        sed -i -e "/\\\end{document}/{i\\\\\input{\"${file%%.*}\"}" -e ':a;n;ba}' "$logbookFile"
    fi
}

searchFile
if [ -n "$out" ]; then
    if [ 'ctrl-n' = "$key" ]; then
        nohup zotero  >/dev/null 2>&1 &
        exit
    fi
    file="$(basename "$fileName")"
    logFile="$LOGDIR/${file%%.*}.tex"
    echo "file: $file"
    echo "logFile: $logFile"
    preOpenFile
    if [ 'ctrl-o' = "$key" ]; then
        # i3-msg "workspace 0:reading; append_layout ~/.config/i3/workspace-reading.json" &
        # i3-msg "workspace 0:reading" &
        nohup ${OPEN} "$fileName" >/dev/null 2>&1 &
    else
        nohup ${OPEN} "$fileName" >/dev/null 2>&1 &
    fi
    sleep 10
else
    exit
fi

下面是我的 zathurarc

set guioptions ''
set page-padding 0
set show-recent 30
set window-title-basename true
set window-title-page true
set statusbar-home-tilde true
set adjust-open width
set scroll-full-overlap 0.02
set selection-clipboard clipboard

map <A-o> feedkeys ":exec qpdfview $FILE<Return>"
map <A-c> feedkeys ":exec readingNotes.sh $FILE<Return>"

下面脚本 readingNotes.sh 用来获取当前页面,注意要配合上面配置中的 set window-title-page true,另外 zathuraexec 命令只支持替换 $FILE,如果能发送当前页面信息就好了。

#!/bin/bash
window_name="$(xdotool getwindowfocus getwindowname)"
page="$(perl -ne 'print $1 if m|\[([0-9]{1,})/[0-9]{1,}\]$|' <<< "$window_name")"
path="$1"
title="$(basename "$path")"
title="${title%.*}"
path="file:$path"
emacsclient "org-protocol://capture?template=r&url=$path&title=$title&body=$page"

最后是我的 .emacs.d/init.el,要加上这个脚本 才能预览 latex。这个配置必须要感谢 u/yantar92

(setq org-capture-templates
      '(("r" "reading" entry (file+function "~/Sync/docs/reading.org" org-capture-template-goto-link)
         "** P%i %U \n%?%c"
         :kill-buffer 1)))

(defun org-capture-template-goto-link ()
  "Set point for capturing at what capture target file+headline with headline set to %l would do."
  (org-capture-put :target (list 'file+headline (nth 1 (org-capture-get :target)) (org-capture-get :annotation)))
  (org-capture-put-target-region-and-position)
  (widen)
  (let ((hd (nth 2 (org-capture-get :target))))
    (goto-char (point-min))
    (if (re-search-forward
         (format org-complex-heading-regexp-format (regexp-quote hd))
         nil t)
        (goto-char (point-at-bol))
      (goto-char (point-max))
      (or (bolp) (insert "\n"))
      (insert "* " hd "\n")
      (beginning-of-line 0))))
Publié le par v dans «misc». Mots-clés: procrastination