我想做一次击键,比如说C-F12
来做delete-other-windows
或winner-undo
。我认为如果我已经学习了Emacs Lisp编程并设置了一个布尔标志,这很容易。也就是说,如果先前它运行delete-other-window
,现在它将运行winner-undo
。
你是如何在Emacs Lisp中做到的?
由于
答案 0 :(得分:3)
尝试这样的事情
(setq c-f12-winner-undo t)
(define-key (current-global-map) [C-f12]
(lambda()
(interactive)
(if c-f12-winner-undo
(winner-undo)
(delete-other-windows))
(setq c-f12-winner-undo (not c-f12-winner-undo))))
答案 1 :(得分:1)
(defun swdev-toggle-sole-window ()
(interactive)
(if (cdr (window-list))
(delete-other-windows)
(winner-undo)))
(global-set-key (kbd "<C-f12>") 'swdev-toggle-sole-window)
swdev-toggle-sole-window
的函数,不带任何参数。M-x
或通过键绑定进行调用。C-f12
。答案 2 :(得分:1)
这是使用Emacs的recenter-top-bottom功能采用的方法的解决方案:
(defun delete-other-window-or-winner-undo ()
"call delete-other-window on first invocation and winner-undo on subsequent invocations"
(interactive)
(if (eq this-command last-command)
(winner-undo)
(delete-other-windows)))
(global-set-key (kbd "<C-f12>") 'delete-other-window-or-winner-undo)