使用场景

在使用org mode编辑文档时经常会把剪贴板里的内容放在一个临时的地方比如scratch,需要频繁切换这两个buffer

解决办法

可以定制一个命令如下:

1
2
3
4
5
6
7
8
(defun switch-to-scratch-and-back ()
"Toggle between *scratch* buffer and the current buffer.
If the *scratch* buffer does not exist, create it."
(interactive)
(let ((scratch-buffer-name (get-buffer-create "*scratch*")))
(if (equal (current-buffer) scratch-buffer-name)
(switch-to-buffer (other-buffer))
(switch-to-buffer scratch-buffer-name (lisp-interaction-mode)))))

使用时 Meta + x + Enter + switch-to-scratch-and-back即可切换