separate vi keys set up from main emacs init file
This commit is contained in:
parent
2480252532
commit
ad1d9f08e2
133
emacs/.emacs
133
emacs/.emacs
@ -2,52 +2,6 @@
|
|||||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
||||||
(package-initialize)
|
(package-initialize)
|
||||||
|
|
||||||
(defun setup-vi-keys-for-splits (mode-map)
|
|
||||||
; https://www.gnu.org/software/emacs/manual/html_node/elisp/Conditionals.html
|
|
||||||
(unless (eq 'mode-map 'eww-mode-map)
|
|
||||||
(define-key mode-map (kbd "C-w H") 'evil-window-move-far-left)
|
|
||||||
(define-key mode-map (kbd "C-w L") 'evil-window-move-far-right))
|
|
||||||
(define-key mode-map (kbd "C-w K") 'evil-window-move-very-top)
|
|
||||||
(define-key mode-map (kbd "C-w J") 'evil-window-move-very-bottom)
|
|
||||||
|
|
||||||
(define-key mode-map (kbd "C-w v") 'evil-window-vsplit)
|
|
||||||
(define-key mode-map (kbd "C-w s") 'evil-window-split)
|
|
||||||
(define-key mode-map (kbd "C-w w") 'evil-window-next)
|
|
||||||
|
|
||||||
(define-key mode-map (kbd "C-w k") 'evil-window-up)
|
|
||||||
(define-key mode-map (kbd "C-w h") 'evil-window-left)
|
|
||||||
(define-key mode-map (kbd "C-w l") 'evil-window-right)
|
|
||||||
(define-key mode-map (kbd "C-w j") 'evil-window-down)
|
|
||||||
|
|
||||||
(define-key mode-map (kbd "C-w <") 'evil-window-decrease-width)
|
|
||||||
(define-key mode-map (kbd "C-w >") 'evil-window-increase-width)
|
|
||||||
(define-key mode-map (kbd "C-w -") 'evil-window-decrease-height)
|
|
||||||
(define-key mode-map (kbd "C-w +") 'evil-window-increase-height)
|
|
||||||
(define-key mode-map (kbd "C-w =") 'balance-windows)
|
|
||||||
(define-key mode-map (kbd "C-w |") 'evil-window-set-width))
|
|
||||||
|
|
||||||
(defun setup-w3m ()
|
|
||||||
; https://people.freebsd.org/~kiri/xemacs/repo/packages/xemacs-packages/w3m/w3m/doc/emacs-w3m.pdf
|
|
||||||
(setq w3m-use-tabs t)
|
|
||||||
|
|
||||||
(define-key w3m-mode-map "i" 'w3m-view-this-url)
|
|
||||||
(define-key w3m-mode-map "T" 'w3m-copy-buffer)
|
|
||||||
(define-key w3m-mode-map "D" 'w3m-delete-buffer)
|
|
||||||
(define-key w3m-mode-map "o" 'w3m-goto-url)
|
|
||||||
(define-key w3m-mode-map "O" 'w3m-goto-url-new-session)
|
|
||||||
(define-key w3m-mode-map "H" 'w3m-view-previous-page)
|
|
||||||
(define-key w3m-mode-map "L" 'w3m-view-next-page)
|
|
||||||
(define-key w3m-mode-map "K" 'w3m-previous-buffer)
|
|
||||||
(define-key w3m-mode-map "J" 'w3m-next-buffer)
|
|
||||||
(define-key w3m-mode-map (kbd "yy") 'w3m-print-current-url) ; copy current url
|
|
||||||
(define-key w3m-mode-map (kbd "C-y") 'w3m-scroll-down)
|
|
||||||
(define-key w3m-mode-map (kbd "C-e") 'w3m-scroll-up)
|
|
||||||
(define-key w3m-mode-map (kbd "C-f") 'w3m-scroll-up-or-next-url)
|
|
||||||
(define-key w3m-mode-map (kbd "C-b") 'w3m-scroll-down-or-previous-url)
|
|
||||||
|
|
||||||
(setup-vi-keys-for-splits w3m-mode-map)
|
|
||||||
)
|
|
||||||
|
|
||||||
;;; General
|
;;; General
|
||||||
;
|
;
|
||||||
;; Don't show welcome screen every time
|
;; Don't show welcome screen every time
|
||||||
@ -60,9 +14,6 @@
|
|||||||
;; Enable word wrap
|
;; Enable word wrap
|
||||||
;(setq-default word-wrap t)
|
;(setq-default word-wrap t)
|
||||||
;
|
;
|
||||||
;; Set default evil-mode state
|
|
||||||
(setq evil-default-state 'normal)
|
|
||||||
;
|
|
||||||
;; Wrap long lines
|
;; Wrap long lines
|
||||||
; https://www.gnu.org/software/emacs/manual/html_node/emacs/Visual-Line-Mode.html
|
; https://www.gnu.org/software/emacs/manual/html_node/emacs/Visual-Line-Mode.html
|
||||||
; http://ergoemacs.org/emacs/emacs_long_line_wrap.html
|
; http://ergoemacs.org/emacs/emacs_long_line_wrap.html
|
||||||
@ -81,10 +32,6 @@
|
|||||||
;(setq split-height-threshold nil)
|
;(setq split-height-threshold nil)
|
||||||
;(setq split-width-threshold 0)
|
;(setq split-width-threshold 0)
|
||||||
;
|
;
|
||||||
;; Set default evil states for a few modes
|
|
||||||
(evil-set-initial-state 'package-menu-mode 'normal)
|
|
||||||
(evil-set-initial-state 'calendar-mode 'emacs)
|
|
||||||
;
|
|
||||||
;; Scroll buffer without moving cursor
|
;; Scroll buffer without moving cursor
|
||||||
; https://www.emacswiki.org/emacs/Scrolling#h5o-2
|
; https://www.emacswiki.org/emacs/Scrolling#h5o-2
|
||||||
(defun gcm-scroll-down ()
|
(defun gcm-scroll-down ()
|
||||||
@ -138,6 +85,13 @@
|
|||||||
(require 'evil)
|
(require 'evil)
|
||||||
(evil-mode t)
|
(evil-mode t)
|
||||||
;
|
;
|
||||||
|
;; Set default evil-mode state
|
||||||
|
(setq evil-default-state 'normal)
|
||||||
|
;
|
||||||
|
;; Set default evil-mode states for a few modes
|
||||||
|
(evil-set-initial-state 'package-menu-mode 'normal)
|
||||||
|
(evil-set-initial-state 'calendar-mode 'emacs)
|
||||||
|
;
|
||||||
;; Make :q not quit entire emacs and just try to delete current split
|
;; Make :q not quit entire emacs and just try to delete current split
|
||||||
(evil-ex-define-cmd "q[uit]" 'evil-window-delete )
|
(evil-ex-define-cmd "q[uit]" 'evil-window-delete )
|
||||||
;
|
;
|
||||||
@ -148,8 +102,8 @@
|
|||||||
;; Shortcut to switch to last buffer
|
;; Shortcut to switch to last buffer
|
||||||
(evil-global-set-key 'normal (kbd "gl") 'evil-buffer)
|
(evil-global-set-key 'normal (kbd "gl") 'evil-buffer)
|
||||||
;
|
;
|
||||||
;; Vim digraphs
|
;; Vi keys
|
||||||
(load-file "~/.config/emacs/digraphs.el")
|
(load-file "~/.config/emacs/vi-keys.el")
|
||||||
|
|
||||||
|
|
||||||
;; Themes
|
;; Themes
|
||||||
@ -195,75 +149,6 @@
|
|||||||
;; org-agenda
|
;; org-agenda
|
||||||
; https://stackoverflow.com/questions/44094125/org-mode-c-c-a-undefined/44096106
|
; https://stackoverflow.com/questions/44094125/org-mode-c-c-a-undefined/44096106
|
||||||
(define-key global-map "\C-ca" 'org-agenda)
|
(define-key global-map "\C-ca" 'org-agenda)
|
||||||
;
|
|
||||||
;; Have a couple of vi-like keys in agenda view
|
|
||||||
; https://lists.gnu.org/archive/html/emacs-orgmode/2013-04/msg01119.html
|
|
||||||
; https://gist.github.com/amirrajan/301e74dc844a4c9ffc3830dc4268f177
|
|
||||||
(with-eval-after-load 'org-agenda
|
|
||||||
; Cursor movement
|
|
||||||
;(define-key org-agenda-mode-map "j" 'evil-next-line)
|
|
||||||
;(define-key org-agenda-mode-map "k" 'evil-previous-line))
|
|
||||||
(define-key org-agenda-mode-map "j" 'org-agenda-next-line)
|
|
||||||
(define-key org-agenda-mode-map "k" 'org-agenda-previous-line)
|
|
||||||
|
|
||||||
; Scrolling
|
|
||||||
(define-key org-agenda-mode-map (kbd "C-f") 'evil-scroll-page-down)
|
|
||||||
(define-key org-agenda-mode-map (kbd "C-b") 'evil-scroll-page-up)
|
|
||||||
;(define-key org-agenda-mode-map (kbd "C-b") 'org-agenda-show-scroll-down)
|
|
||||||
(define-key org-agenda-mode-map (kbd "C-e") 'evil-scroll-line-down)
|
|
||||||
(define-key org-agenda-mode-map (kbd "C-y") 'evil-scroll-line-up)
|
|
||||||
|
|
||||||
; Misc
|
|
||||||
(define-key org-agenda-mode-map (kbd "C-c C-g") 'org-agenda-redo-all)
|
|
||||||
; (define-key org-agenda-mode-map (kbd "g g") 'evil-goto-first-line)
|
|
||||||
; (define-key org-agenda-mode-map (kbd "g l") 'evil-buffer)
|
|
||||||
|
|
||||||
(define-key org-agenda-mode-map (kbd "h") 'evil-backward-char)
|
|
||||||
(define-key org-agenda-mode-map (kbd "C-c C-l") 'org-agenda-holidays)
|
|
||||||
|
|
||||||
(define-key org-agenda-mode-map (kbd "l") 'evil-forward-char)
|
|
||||||
(define-key org-agenda-mode-map (kbd "C-c C-l") 'org-agenda-log-mode)
|
|
||||||
|
|
||||||
(setup-vi-keys-for-splits org-agenda-mode-map))
|
|
||||||
;
|
|
||||||
;; vi keys for docview
|
|
||||||
; https://github.com/emacs-evil/evil-collection
|
|
||||||
; https://emacs.stackexchange.com/questions/7540/doc-view-mode-hook
|
|
||||||
(with-eval-after-load 'doc-view
|
|
||||||
(define-key doc-view-mode-map "j" 'doc-view-next-line-or-next-page)
|
|
||||||
(define-key doc-view-mode-map "k" 'doc-view-previous-line-or-previous-page)
|
|
||||||
(define-key doc-view-mode-map "l" 'image-forward-hscroll)
|
|
||||||
(define-key doc-view-mode-map "h" 'image-backward-hscroll)
|
|
||||||
(define-key doc-view-mode-map (kbd "C-f") 'image-scroll-up)
|
|
||||||
(define-key doc-view-mode-map (kbd "C-b") 'image-scroll-down)
|
|
||||||
(define-key doc-view-mode-map "J" 'doc-view-next-page)
|
|
||||||
(define-key doc-view-mode-map "K" 'doc-view-previous-page)
|
|
||||||
(define-key doc-view-mode-map (kbd "C-c C-k") 'doc-view-kill-proc)
|
|
||||||
(define-key doc-view-mode-map "G" 'doc-view-goto-page)
|
|
||||||
|
|
||||||
(setup-vi-keys-for-splits doc-view-mode-map))
|
|
||||||
|
|
||||||
;; vi keys for package-menu
|
|
||||||
(with-eval-after-load 'package
|
|
||||||
(define-key package-menu-mode-map "j" 'evil-next-line)
|
|
||||||
(define-key package-menu-mode-map "k" 'evil-previous-line)
|
|
||||||
(define-key package-menu-mode-map "$" 'evil-end-of-line)
|
|
||||||
(define-key package-menu-mode-map "0" 'evil-digit-argument-or-evil-beginning-of-line)
|
|
||||||
(setup-vi-keys-for-splits package-menu-mode-map))
|
|
||||||
|
|
||||||
;; vi keys for emacs-w3m
|
|
||||||
(with-eval-after-load 'w3m (setup-w3m))
|
|
||||||
|
|
||||||
;; vi keys for calendar
|
|
||||||
(with-eval-after-load 'calendar
|
|
||||||
(define-key calendar-mode-map "h" 'calendar-backward-day)
|
|
||||||
(define-key calendar-mode-map "l" 'calendar-forward-day)
|
|
||||||
(define-key calendar-mode-map "k" 'calendar-backward-week)
|
|
||||||
(define-key calendar-mode-map "j" 'calendar-forward-week)
|
|
||||||
(define-key calendar-mode-map "H" 'calendar-backward-month)
|
|
||||||
(define-key calendar-mode-map "L" 'calendar-forward-month)
|
|
||||||
(define-key calendar-mode-map "K" 'calendar-backward-year)
|
|
||||||
(define-key calendar-mode-map "J" 'calendar-forward-year))
|
|
||||||
|
|
||||||
;
|
;
|
||||||
;; Set agenda files for org-agenda
|
;; Set agenda files for org-agenda
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
- `.emacs`: `~/`
|
- `.emacs`: `~/`
|
||||||
|
- `vi-keys.el`: `~/.config/emacs/digraphs.el`
|
||||||
- `digraphs.el`: `~/.config/emacs/digraphs.el`
|
- `digraphs.el`: `~/.config/emacs/digraphs.el`
|
||||||
|
|
||||||
|
115
emacs/vi-keys.el
Normal file
115
emacs/vi-keys.el
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
(defun setup-vi-keys-for-splits (mode-map)
|
||||||
|
; https://www.gnu.org/software/emacs/manual/html_node/elisp/Conditionals.html
|
||||||
|
(define-key mode-map (kbd "C-w H") 'evil-window-move-far-left)
|
||||||
|
(define-key mode-map (kbd "C-w L") 'evil-window-move-far-right)
|
||||||
|
(define-key mode-map (kbd "C-w K") 'evil-window-move-very-top)
|
||||||
|
(define-key mode-map (kbd "C-w J") 'evil-window-move-very-bottom)
|
||||||
|
|
||||||
|
(define-key mode-map (kbd "C-w v") 'evil-window-vsplit)
|
||||||
|
(define-key mode-map (kbd "C-w s") 'evil-window-split)
|
||||||
|
(define-key mode-map (kbd "C-w w") 'evil-window-next)
|
||||||
|
|
||||||
|
(define-key mode-map (kbd "C-w k") 'evil-window-up)
|
||||||
|
(define-key mode-map (kbd "C-w h") 'evil-window-left)
|
||||||
|
(define-key mode-map (kbd "C-w l") 'evil-window-right)
|
||||||
|
(define-key mode-map (kbd "C-w j") 'evil-window-down)
|
||||||
|
|
||||||
|
(define-key mode-map (kbd "C-w <") 'evil-window-decrease-width)
|
||||||
|
(define-key mode-map (kbd "C-w >") 'evil-window-increase-width)
|
||||||
|
(define-key mode-map (kbd "C-w -") 'evil-window-decrease-height)
|
||||||
|
(define-key mode-map (kbd "C-w +") 'evil-window-increase-height)
|
||||||
|
(define-key mode-map (kbd "C-w =") 'balance-windows)
|
||||||
|
(define-key mode-map (kbd "C-w |") 'evil-window-set-width))
|
||||||
|
|
||||||
|
(defun setup-w3m ()
|
||||||
|
; https://people.freebsd.org/~kiri/xemacs/repo/packages/xemacs-packages/w3m/w3m/doc/emacs-w3m.pdf
|
||||||
|
(setq w3m-use-tabs t)
|
||||||
|
|
||||||
|
(define-key w3m-mode-map "i" 'w3m-view-this-url)
|
||||||
|
(define-key w3m-mode-map "T" 'w3m-copy-buffer)
|
||||||
|
(define-key w3m-mode-map "D" 'w3m-delete-buffer)
|
||||||
|
(define-key w3m-mode-map "o" 'w3m-goto-url)
|
||||||
|
(define-key w3m-mode-map "O" 'w3m-goto-url-new-session)
|
||||||
|
(define-key w3m-mode-map "H" 'w3m-view-previous-page)
|
||||||
|
(define-key w3m-mode-map "L" 'w3m-view-next-page)
|
||||||
|
(define-key w3m-mode-map "K" 'w3m-previous-buffer)
|
||||||
|
(define-key w3m-mode-map "J" 'w3m-next-buffer)
|
||||||
|
(define-key w3m-mode-map (kbd "yy") 'w3m-print-current-url) ; copy current url
|
||||||
|
(define-key w3m-mode-map (kbd "C-y") 'w3m-scroll-down)
|
||||||
|
(define-key w3m-mode-map (kbd "C-e") 'w3m-scroll-up)
|
||||||
|
(define-key w3m-mode-map (kbd "C-f") 'w3m-scroll-up-or-next-url)
|
||||||
|
(define-key w3m-mode-map (kbd "C-b") 'w3m-scroll-down-or-previous-url)
|
||||||
|
|
||||||
|
(setup-vi-keys-for-splits w3m-mode-map))
|
||||||
|
|
||||||
|
(defun setup-org-agenda ()
|
||||||
|
;; Have a couple of vi-like keys in agenda view
|
||||||
|
; https://lists.gnu.org/archive/html/emacs-orgmode/2013-04/msg01119.html
|
||||||
|
; https://gist.github.com/amirrajan/301e74dc844a4c9ffc3830dc4268f177
|
||||||
|
|
||||||
|
; Cursor movement
|
||||||
|
(define-key org-agenda-mode-map "j" 'org-agenda-next-line)
|
||||||
|
(define-key org-agenda-mode-map "k" 'org-agenda-previous-line)
|
||||||
|
|
||||||
|
; Scrolling
|
||||||
|
(define-key org-agenda-mode-map (kbd "C-f") 'evil-scroll-page-down)
|
||||||
|
(define-key org-agenda-mode-map (kbd "C-b") 'evil-scroll-page-up)
|
||||||
|
;(define-key org-agenda-mode-map (kbd "C-b") 'org-agenda-show-scroll-down)
|
||||||
|
(define-key org-agenda-mode-map (kbd "C-e") 'evil-scroll-line-down)
|
||||||
|
(define-key org-agenda-mode-map (kbd "C-y") 'evil-scroll-line-up)
|
||||||
|
|
||||||
|
; Misc
|
||||||
|
(define-key org-agenda-mode-map (kbd "C-c C-g") 'org-agenda-redo-all)
|
||||||
|
; (define-key org-agenda-mode-map (kbd "g g") 'evil-goto-first-line)
|
||||||
|
; (define-key org-agenda-mode-map (kbd "g l") 'evil-buffer)
|
||||||
|
|
||||||
|
(define-key org-agenda-mode-map (kbd "h") 'evil-backward-char)
|
||||||
|
(define-key org-agenda-mode-map (kbd "C-c C-l") 'org-agenda-holidays)
|
||||||
|
|
||||||
|
(define-key org-agenda-mode-map (kbd "l") 'evil-forward-char)
|
||||||
|
(define-key org-agenda-mode-map (kbd "C-c C-l") 'org-agenda-log-mode)
|
||||||
|
|
||||||
|
(setup-vi-keys-for-splits org-agenda-mode-map))
|
||||||
|
|
||||||
|
(defun setup-doc-view ()
|
||||||
|
;; vi keys for docview
|
||||||
|
; https://github.com/emacs-evil/evil-collection
|
||||||
|
; https://emacs.stackexchange.com/questions/7540/doc-view-mode-hook
|
||||||
|
(define-key doc-view-mode-map "j" 'doc-view-next-line-or-next-page)
|
||||||
|
(define-key doc-view-mode-map "k" 'doc-view-previous-line-or-previous-page)
|
||||||
|
(define-key doc-view-mode-map "l" 'image-forward-hscroll)
|
||||||
|
(define-key doc-view-mode-map "h" 'image-backward-hscroll)
|
||||||
|
(define-key doc-view-mode-map (kbd "C-f") 'image-scroll-up)
|
||||||
|
(define-key doc-view-mode-map (kbd "C-b") 'image-scroll-down)
|
||||||
|
(define-key doc-view-mode-map "J" 'doc-view-next-page)
|
||||||
|
(define-key doc-view-mode-map "K" 'doc-view-previous-page)
|
||||||
|
(define-key doc-view-mode-map (kbd "C-c C-k") 'doc-view-kill-proc)
|
||||||
|
(define-key doc-view-mode-map "G" 'doc-view-goto-page)
|
||||||
|
|
||||||
|
(setup-vi-keys-for-splits doc-view-mode-map))
|
||||||
|
|
||||||
|
(defun setup-package ()
|
||||||
|
(define-key package-menu-mode-map "j" 'evil-next-line)
|
||||||
|
(define-key package-menu-mode-map "k" 'evil-previous-line)
|
||||||
|
(define-key package-menu-mode-map "$" 'evil-end-of-line)
|
||||||
|
(define-key package-menu-mode-map "0" 'evil-digit-argument-or-evil-beginning-of-line)
|
||||||
|
(setup-vi-keys-for-splits package-menu-mode-map))
|
||||||
|
|
||||||
|
(defun setup-calendar ()
|
||||||
|
(define-key calendar-mode-map "h" 'calendar-backward-day)
|
||||||
|
(define-key calendar-mode-map "l" 'calendar-forward-day)
|
||||||
|
(define-key calendar-mode-map "k" 'calendar-backward-week)
|
||||||
|
(define-key calendar-mode-map "j" 'calendar-forward-week)
|
||||||
|
(define-key calendar-mode-map "H" 'calendar-backward-month)
|
||||||
|
(define-key calendar-mode-map "L" 'calendar-forward-month)
|
||||||
|
(define-key calendar-mode-map "K" 'calendar-backward-year)
|
||||||
|
(define-key calendar-mode-map "J" 'calendar-forward-year))
|
||||||
|
|
||||||
|
(with-eval-after-load 'org-agenda (setup-org-agenda))
|
||||||
|
(with-eval-after-load 'w3m (setup-w3m))
|
||||||
|
(with-eval-after-load 'doc-view (setup-doc-view))
|
||||||
|
(with-eval-after-load 'package (setup-package))
|
||||||
|
(with-eval-after-load 'calendar (setup-calendar))
|
||||||
|
|
||||||
|
;; Vim digraphs
|
||||||
|
(load-file "~/.config/emacs/digraphs.el")
|
Loading…
Reference in New Issue
Block a user