summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-08-06 08:59:04 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-08-07 13:19:08 -0700
commitc2f0a1c95410f4cc3bd5b05fb660f2be860330f2 (patch)
treec84305c6114a1d304d0f5e1fce8ad730b4ab3ddb
parent9fe994baa3fc929ec570964d894ce7569a3be75b (diff)
downloaddotfiles-c2f0a1c95410f4cc3bd5b05fb660f2be860330f2.tar.gz
use a list of bindings
-rw-r--r--.emacs.d/init-spw.el28
1 files changed, 10 insertions, 18 deletions
diff --git a/.emacs.d/init-spw.el b/.emacs.d/init-spw.el
index e6ed8132..5ae49497 100644
--- a/.emacs.d/init-spw.el
+++ b/.emacs.d/init-spw.el
@@ -45,20 +45,18 @@ add places the library might be available to `load-path'."
("MELPA Stable" . 5)
("MELPA" . 0)))
-(defmacro spw/bind-command-with-cycling (binding1 binding2 generator &optional on-exit map)
+(defmacro spw/bind-command-with-cycling (bindings generator &optional on-exit map)
(list 'spw/bind-command-with-cycling*
- (macroexp-quote binding1)
- (macroexp-quote binding2)
+ (macroexp-quote (if (consp (cdr bindings)) bindings (list bindings)))
`(lambda (_ret-val)
,generator)
`(lambda ()
,on-exit)
map))
-(defmacro spw/bind-command-with-ret-val-cycling (binding1 binding2 generator &optional on-exit map)
+(defmacro spw/bind-command-with-ret-val-cycling (bindings generator &optional on-exit map)
(list 'spw/bind-command-with-cycling*
- (macroexp-quote binding1)
- (macroexp-quote binding2)
+ (macroexp-quote (if (consp (cdr bindings)) bindings (list bindings)))
`(lambda (ret-val)
,generator)
`(lambda ()
@@ -74,8 +72,8 @@ add places the library might be available to `load-path'."
(let ((buffer (ring-ref buffers buffers-pos)))
,(or action '(switch-to-buffer buffer nil t))))))
-(defun spw/bind-command-with-cycling* (binding1 binding2 generator &optional on-exit map)
- (dolist (binding (remove nil (list binding1 binding2)))
+(defun spw/bind-command-with-cycling* (bindings generator &optional on-exit map)
+ (dolist (binding bindings)
(let ((binding-fn (intern (concat "spw/"
(spw/drop-prefix
"spw/"
@@ -468,8 +466,8 @@ add places the library might be available to `load-path'."
(spw/bind-command-with-cycling
;; don't select the windows we cycle through, so that the window where we
;; started becomes the most recently selected window
- ([?\C-x left] . spw/backward-other-window-noselect)
- ([?\C-x right] . spw/other-window-noselect)
+ (([?\C-x left] . spw/backward-other-window-noselect)
+ ([?\C-x right] . spw/other-window-noselect))
#'spw/other-window-noselect
;; select the destination window again with NOSELECT nil
;; TODO is not working sometimes ...?
@@ -486,8 +484,8 @@ add places the library might be available to `load-path'."
;; `switch-to-prev-buffer' and `switch-to-next-buffer' as subroutines, so
;; buffers previously shown in the selected window come up first, as
;; desired. 'w' is for "window's buffers".
- ("\C-cw" . previous-buffer)
- ("\C-cW" . next-buffer)
+ (("\C-cw" . previous-buffer)
+ ("\C-cW" . next-buffer))
(lambda (count)
(interactive "p")
(if (> count 0)
@@ -504,7 +502,6 @@ add places the library might be available to `load-path'."
(spw/bind-command-with-cycling
;; it's C-c q because this is a bit like `quit-restore-window'
("\C-cq" . winner-undo)
- nil
(lambda (count)
(interactive "p")
(if (> count 0)
@@ -517,7 +514,6 @@ add places the library might be available to `load-path'."
(with-eval-after-load 'project
(spw/bind-command-with-ret-val-cycling
("e" . project-eshell)
- nil
(spw/buffer-ring-cycle-lambda)
nil
;; bind into project-prefix-map, rather than just a remap, so that works
@@ -525,16 +521,13 @@ add places the library might be available to `load-path'."
project-prefix-map))
(spw/bind-command-with-cycling
([remap info] . info)
- nil
(spw/buffer-ring-cycle-lambda
(spw/buffer-cloned-siblings-ring (get-buffer "*info*"))))
(spw/bind-command-with-ret-val-cycling
([remap switch-to-buffer-other-window] . switch-to-buffer-other-window)
- nil
(spw/buffer-ring-cycle-lambda))
(spw/bind-command-with-ret-val-cycling
([remap display-buffer] . display-buffer)
- nil
(spw/buffer-ring-cycle-lambda
(spw/buffer-cloned-siblings-ring (window-buffer ret-val))
(with-selected-window ret-val
@@ -991,7 +984,6 @@ to be run by the OS shell."
(global-set-key "\C-ceh" #'spw/eshell-here)
(spw/bind-command-with-ret-val-cycling
("\C-cee" . spw/cycle-eshells)
- nil
(spw/buffer-ring-cycle-lambda
(and (ring-p ret-val) ret-val)))