重复执行 Org mode 代码块时,如果结果相同,高亮下能更容易确认执行成功了。
仿照 M-.
(xref-find-definitions
) 用 pulse.el
临时高亮下执行的结果:
(defun chunyang-org-babel-highlight-result ()
"Highlight the result of the current source block.
Adapt from `org-babel-remove-result'."
(interactive)
(let ((location (org-babel-where-is-src-block-result nil nil)))
(when location
(save-excursion
(goto-char location)
(when (looking-at (concat org-babel-result-regexp ".*$"))
(pulse-momentary-highlight-region
(1+ (match-end 0))
(progn (forward-line 1) (org-babel-result-end))))))))
并且设置 C-c C-c
(org-ctrl-c-ctrl-c
) 在恰当的时候自动调用它:
(add-hook 'org-babel-after-execute-hook
(defun chunyang-org-babel-highlight-result-maybe ()
(when (eq this-command 'org-ctrl-c-ctrl-c)
(chunyang-org-babel-highlight-result))))