forked from colonelpanic/dotfiles
upgrade prefix-alternative to support multiple function definition
This commit is contained in:
parent
e6feb7cba5
commit
290acd42d5
@ -166,10 +166,20 @@
|
|||||||
(interactive "P")
|
(interactive "P")
|
||||||
(message "%s" arg))
|
(message "%s" arg))
|
||||||
|
|
||||||
(defmacro imalison:prefix-alternative (name default alternative)
|
(defmacro imalison:prefix-alternatives (name &rest alternatives)
|
||||||
`(defun ,name (arg) (interactive "P")
|
`(defun ,name (arg)
|
||||||
(if arg (call-interactively (quote ,alternative))
|
(interactive "P")
|
||||||
(call-interactively (quote ,default)))))
|
(setq arg (or arg '(1)))
|
||||||
|
(setq prefix-value (car arg))
|
||||||
|
(setq function
|
||||||
|
(cond
|
||||||
|
,@(progn
|
||||||
|
(setq last-multiple 1)
|
||||||
|
(cl-loop for alternative in alternatives
|
||||||
|
collect `((eq prefix-value ,last-multiple) (quote ,alternative))
|
||||||
|
do (setq last-multiple (* last-multiple 4))))))
|
||||||
|
(setq function (or function (car alternatives))) ; Set a defautl value for function
|
||||||
|
(call-interactively function)))
|
||||||
|
|
||||||
(defun imalison:uuid ()
|
(defun imalison:uuid ()
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -488,6 +498,7 @@ The current directory is assumed to be the project's root otherwise."
|
|||||||
(unless (eq system-type 'windows-nt)
|
(unless (eq system-type 'windows-nt)
|
||||||
(set-selection-coding-system 'utf-8))
|
(set-selection-coding-system 'utf-8))
|
||||||
(prefer-coding-system 'utf-8)
|
(prefer-coding-system 'utf-8)
|
||||||
|
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
;; use-package
|
;; use-package
|
||||||
;; =============================================================================
|
;; =============================================================================
|
||||||
@ -522,7 +533,7 @@ The current directory is assumed to be the project's root otherwise."
|
|||||||
(interactive)
|
(interactive)
|
||||||
(ansi-term (getenv "SHELL")))
|
(ansi-term (getenv "SHELL")))
|
||||||
|
|
||||||
(imalison:prefix-alternative imalison:term imalison:start-ansi-term ansi-term)
|
(imalison:prefix-alternatives imalison:term imalison:start-ansi-term ansi-term)
|
||||||
(use-package term
|
(use-package term
|
||||||
:config
|
:config
|
||||||
(progn
|
(progn
|
||||||
@ -578,13 +589,13 @@ The current directory is assumed to be the project's root otherwise."
|
|||||||
(use-package jump-char
|
(use-package jump-char
|
||||||
:bind (("C-;" . jump-char-forward)))
|
:bind (("C-;" . jump-char-forward)))
|
||||||
|
|
||||||
(imalison:prefix-alternative imalison:avy avy-goto-word-1 avy-goto-char)
|
(imalison:prefix-alternatives imalison:avy avy-goto-word-1 avy-goto-char)
|
||||||
(use-package avy
|
(use-package avy
|
||||||
:bind (("C-j" . imalison:avy)
|
:bind (("C-j" . imalison:avy)
|
||||||
("M-g l" . avy-goto-line)
|
("M-g l" . avy-goto-line)
|
||||||
("C-'" . avy-goto-char-2)))
|
("C-'" . avy-goto-char-2)))
|
||||||
|
|
||||||
(imalison:prefix-alternative imalison:ace-window ace-select-window ace-swap-window)
|
(imalison:prefix-alternatives imalison:ace-window ace-select-window ace-swap-window)
|
||||||
(use-package ace-window
|
(use-package ace-window
|
||||||
:config (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
|
:config (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
|
||||||
:bind ("C-c w" . imalison:ace-window))
|
:bind ("C-c w" . imalison:ace-window))
|
||||||
|
Loading…
Reference in New Issue
Block a user