summaryrefslogtreecommitdiff
path: root/emacs/inits/14-movement.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/inits/14-movement.el')
-rw-r--r--emacs/inits/14-movement.el170
1 files changed, 170 insertions, 0 deletions
diff --git a/emacs/inits/14-movement.el b/emacs/inits/14-movement.el
new file mode 100644
index 0000000..a1b27f6
--- /dev/null
+++ b/emacs/inits/14-movement.el
@@ -0,0 +1,170 @@
+;; Time-stamp: <2019-08-14 11:59:46 (tslil@basingstoke)>
+
+;; (eval-after-load "tiny-menu"
+;; (progn
+;; (defun hexl-input-smart ()
+;; (hexl-insert-char (0xc-string-to-number (read-string "Input: ")) 1))
+
+;; (setq tiny-menu-forever t
+;; tiny-menu-items '(("hexl-menu"
+;; ("hexl"
+;; ((?i "Insert" hexl-input-smart)
+;; (?b "Byte" hexl-forward-char)
+;; (?e "bytE" hexl-backward-char)
+;; (?s "Short" hexl-forward-short)
+;; (?t "shorT" hexl-backward-short))))
+;; ))))
+
+;; (add-hook 'hexl-mode-hook
+;; (lambda ()
+;; (require '0xc)
+;; (require 'tiny-menu)
+;; (define-key hexl-mode-map (kbd "M-l")
+;; (lambda () (interactive) (tiny-menu "hexl-menu")))))
+
+;; -------------------------------------------------------------------
+;; Repeated key presses for region, deletion, and movement
+
+(use-package expand-region :ensure t
+ :bind ("C-r" . er/expand-region)
+ :config
+ (setq expand-region-fast-keys-enabled t
+ expand-region-contract-fast-key "c"
+ expand-region-reset-fast-key "e"
+ expand-region-autocopy-register "i"))
+
+(use-package viking-mode
+ :disabled
+ :after expand-region
+ :bind (:map viking-mode-map
+ ("C-d" . nil)
+ ("C-c d" . viking-kill-thing-at-point))
+ :config
+ (setq viking-use-expand-region-when-loaded t
+ viking-really-delete nil)
+ (viking-global-mode))
+
+;; (defun goto-begin-dwim ()
+;; "Read the source."
+;; (interactive)
+;; (let ((iter (viking-last-key-repeats))
+;; (lisp (memq major-mode '(emacs-lisp-mode
+;; lisp-mode
+;; scheme-mode
+;; slime-repl-mode))))
+;; (if lisp
+;; (cond
+;; ((= iter 1) (back-to-indentation))
+;; ((= iter 2) (backward-sexp))
+;; ((= iter 3) (beginning-of-defun))
+;; (t (beginning-of-defun 1)))
+;; (cond
+;; ((= iter 1) (back-to-indentation))
+;; ((= iter 2) (beginning-of-line))
+;; ((= iter 3) (backward-paragraph))
+;; (t (goto-char (point-min)))))))
+
+;; (defun goto-end-dwim ()
+;; "Read the source."
+;; (interactive)
+;; (let ((iter (viking-last-key-repeats))
+;; (lisp (memq major-mode '(emacs-lisp-mode lisp-mode scheme-mode slime-repl-mode))))
+;; (if lisp
+;; (cond
+;; ((= iter 1) (end-of-line))
+;; ((= iter 2) (end-of-defun))
+;; (t (end-of-defun 1)))
+;; (if (< (point) (point-at-eol)) (end-of-line)
+;; (forward-paragraph)))))
+
+;; (global-set-key (kbd "C-a") 'goto-begin-dwim)
+;; (global-set-key (kbd "C-e") 'goto-end-dwim)
+
+;; -------------------------------------------------------------------
+;; Window switching
+(use-package switch-window :ensure t
+ :bind (("C-x o" . switch-window)
+ ("C-x C-o" . other-frame)
+ ("C-c o" . switch-window)
+ ("C-c n" . switch-window-then-maximize)
+ :map switch-window-extra-map
+ ("u" . switch-window-mvborder-up)
+ ("e" . switch-window-mvborder-down)
+ ("n" . switch-window-mvborder-left)
+ ("o" . switch-window-mvborder-right)
+ ("i" . nil)
+ ("j" . nil)
+ ("k" . nil)
+ ("l" . nil))
+ :config
+ (setq switch-window-input-style 'minibuffer
+ switch-window-shortcut-style 'qwerty
+ switch-window-multiple-frames nil
+ switch-window-qwerty-shortcuts
+ '("a" "s" "t" "h" "n" "e" "o" "i" "d" "r" "w" "f" "u" "p")))
+
+;; -------------------------------------------------------------------
+;; Character jumping
+(use-package avy
+ :ensure t
+ :demand
+ :bind (("C-," . avy-goto-char-timer)
+ ("C-." . avy-goto-char-in-line)
+ ("M-g s" . avy-goto-word-or-subword-1)
+ ("M-g w" . avy-goto-word-1)
+ ("M-g a" . avy-goto-word-0)
+ ("M-g M-g" . avy-goto-line))
+ :config
+ (setq avy-keys '(?a ?s ?t ?h ?n ?e ?o ?i ?d ?r ?u ?p)
+ avy-dispatch-alist '((?w . avy-action-kill-move)
+ (?W . avy-action-kill-stay)
+ (?j . avy-action-teleport)
+ (?m . avy-action-mark)
+ (?c . avy-action-copy)
+ (?y . avy-action-yank)
+ (?i . avy-action-ispell)
+ (?z . avy-action-zap-to-char))))
+
+;; -------------------------------------------------------------------
+;; General stuff
+
+(global-set-key (kbd "C-M-e") 'end-of-buffer)
+(global-set-key (kbd "C-M-a") 'beginning-of-buffer)
+
+(global-set-key (kbd "M-h") 'backward-kill-word)
+
+(global-set-key (kbd "M-z") 'zap-up-to-char)
+
+;; Fast movement
+(global-set-key (kbd "M-n") 'scroll-up-command)
+(global-set-key (kbd "M-p") 'scroll-down-command)
+
+(global-set-key (kbd "C-S-n")
+ (lambda () (interactive) (ignore-errors (forward-line 5))))
+
+(global-set-key (kbd "C-S-p")
+ (lambda () (interactive) (ignore-errors (forward-line -5))))
+
+(global-set-key (kbd "C-S-f")
+ (lambda () (interactive) (ignore-errors (forward-char 5))))
+
+(global-set-key (kbd "C-S-b")
+ (lambda () (interactive) (ignore-errors (backward-char 5))))
+
+;; Hardcore mode
+(defconst hardcore-nav-mode t)
+(when hardcore-nav-mode
+ (global-set-key (kbd "<right>") nil)
+ (global-set-key (kbd "<left>") nil)
+ (global-set-key (kbd "<up>") nil)
+ (global-set-key (kbd "<down>") nil)
+ (global-set-key (kbd "S-<right>") nil)
+ (global-set-key (kbd "S-<left>") nil)
+ (global-set-key (kbd "S-<up>") nil)
+ (global-set-key (kbd "C-<down>") nil)
+ (global-set-key (kbd "C-<right>") nil)
+ (global-set-key (kbd "C-<left>") nil)
+ (global-set-key (kbd "C-<up>") nil)
+ (global-set-key (kbd "C-<down>") nil)
+ (global-set-key (kbd "<Home>") nil)
+ (global-set-key (kbd "<End>") nil))