Skip to content

Commit

Permalink
eaf & meow
Browse files Browse the repository at this point in the history
  • Loading branch information
JJPandari committed Aug 2, 2021
1 parent 5016ed3 commit 1b571a5
Show file tree
Hide file tree
Showing 18 changed files with 251 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "apheleia"]
path = extensions/apheleia
url = [email protected]:raxod502/apheleia.git
[submodule "emacs-application-framework"]
path = extensions/emacs-application-framework
url = [email protected]:manateelazycat/emacs-application-framework.git
1 change: 1 addition & 0 deletions extensions/emacs-application-framework
9 changes: 9 additions & 0 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@
(require 'init-frame-hooks)
(require 'init-themes)
(require 'init-gui-frames)
;; (require 'init-eaf)

(require 'init-osx-keys)
(require 'init-evil)
;; (require 'init-meow)
(require 'init-which-key)
(require 'init-hydra)

Expand Down Expand Up @@ -137,8 +139,15 @@
;; Allow access from emacsclient
;;----------------------------------------------------------------------------
(require 'server)
;; "unless running" is to avoid prompting error when starting a second Emacs
;; when app opened as main editor, start default server
(unless (server-running-p)
(server-start))
;; when opened as maid, start server with name "maid"
(when (string= (getenv "EMACS_SOCKET") "maid")
(unless (server-running-p "maid")
(setq server-name "maid")
(server-start)))

;;----------------------------------------------------------------------------
;; Variables configured via the interactive 'customize' interface
Expand Down
8 changes: 6 additions & 2 deletions modes/init-company.el
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
;; -*- lexical-binding: t -*-

(add-to-list 'completion-styles 'initials t)

(use-package company
Expand Down Expand Up @@ -35,9 +37,11 @@
"<tab>" 'jester/expand-yas-or-complete-company
"C-g" 'company-abort
"<escape>" (lambda! (company-abort) (evil-normal-state)))
;; M-1 ~ M-0 to select candidate 1 ~ 10
;; M-0 ~ M-9 to insert number 0 ~ 9
(dotimes (i 10)
(define-key company-active-map (read-kbd-macro (format "M-%d" i)) 'company-complete-number))
(define-key company-active-map
(read-kbd-macro (format "M-%d" i))
(eval `(lambda! (insert ,(number-to-string i))))))
;; H-1 ~ H-5 to select candidate 6 ~ 10
(cl-loop for num-key from 1 to 4
do (let ((candidate-index (+ num-key 5)))
Expand Down
3 changes: 2 additions & 1 deletion modes/init-compile.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
(add-hook 'compilation-filter-hook 'jester/colourise-compilation-buffer)
(add-hook 'compilation-mode-hook 'jester/set-shell-buffer-face))
(add-hook 'compilation-mode-hook 'jester/set-shell-buffer-face)
(add-hook 'compilation-mode-hook (lambda () (setq truncate-lines nil))))


(require-package 'alert)
Expand Down
33 changes: 33 additions & 0 deletions modes/init-eaf.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(push (expand-file-name "emacs-application-framework" jester-submodules-dir) load-path)
(use-package eaf
:init
(use-package ctable :defer t)
(use-package deferred :defer t)
(use-package epc :defer t)
:ensure nil
:demand t
:custom
(eaf-browser-continue-where-left-off t)
:config
(setq eaf-browser-dark-mode "false")
;; (setq eaf-browser-enable-adblocker "true")
(eaf-bind-key scroll_up "C-n" eaf-pdf-viewer-keybinding)
(eaf-bind-key scroll_down "C-p" eaf-pdf-viewer-keybinding)
(eaf-bind-key take_photo "p" eaf-camera-keybinding)
(eaf-bind-key nil "M-q" eaf-browser-keybinding)

(require 'eaf-evil)

(define-key key-translation-map (kbd "SPC")
(lambda (prompt)
(if (derived-mode-p 'eaf-mode)
(pcase eaf--buffer-app-name
("browser" (if (string= (eaf-call-sync "call_function" eaf--buffer-id "is_focus") "True")
(kbd "SPC")
(kbd eaf-evil-leader-key)))
("pdf-viewer" (kbd eaf-evil-leader-key))
("image-viewer" (kbd eaf-evil-leader-key))
(_ (kbd "SPC")))
(kbd "SPC")))))

(provide 'init-eaf)
2 changes: 0 additions & 2 deletions modes/init-editing-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@
;;----------------------------------------------------------------------------
;; Move lines up and down.
;;----------------------------------------------------------------------------
;; (define-key evil-visual-state-map "J" (concat ":m '>+1" (kbd "RET") "gv=gv"))
;; (define-key evil-visual-state-map "K" (concat ":m '<-2" (kbd "RET") "gv=gv"))
(defun jester/move-line-up (count)
"Move `prefix-arg' lines up."
(interactive "p")
Expand Down
57 changes: 54 additions & 3 deletions modes/init-evil.el
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,42 @@
(define-key evil-multiedit-insert-state-map (kbd "<tab>") 'jester/yas-or-company-or-hippie)
)


(use-package evil-mc
:init
;; don't bind any keys
(setq evil-mc-key-map (make-sparse-keymap))
;; TODO quit on esc, pause on enter
(general-define-key
:states '(normal visual)
"K" 'evil-mc-make-all-cursors
"M-n" 'evil-mc-make-and-goto-next-match
"M-p" 'evil-mc-make-and-goto-prev-match
"M-j" 'evil-mc-make-cursor-move-next-line
"M-k" 'evil-mc-make-cursor-move-prev-line
"<M-return>" 'jester/evil-mc-toggle-cursors-pause
"<M-backspace>" 'evil-mc-undo-all-cursors)
(defun jester/evil-mc-toggle-cursors-pause ()
"Toggle between pausing or resuming all cursors."
(interactive)
(if evil-mc-frozen
(evil-mc-resume-cursors)
(evil-mc-pause-cursors)))
:commands (evil-mc-make-all-cursors evil-mc-make-cursor-here
evil-mc-make-cursor-move-next-line evil-mc-make-cursor-move-prev-line
evil-mc-make-and-goto-next-match evil-mc-make-and-goto-prev-match)
:config
;; FIXME activate mode after using some command may be buggy, but it's the only way to lazy-load evil-mc now.
(global-evil-mc-mode 1)

;; Add custom commands to whitelisted commands
;; TODO not work
(dolist (fn '(string-inflection-kebab-case
string-inflection-camelcase string-inflection-lower-camelcase
jester/expand-yas-or-complete-company))
(push (cons fn '((:default . evil-mc-execute-default-call)))
evil-mc-custom-known-commands)))


(use-package evil-ediff
:init
Expand Down Expand Up @@ -405,7 +441,8 @@
"t o" 'just-one-space
;; NOTE: "a" "d" "." "'" are still there for the taking
"," 'evil-indent
"!" 'shell-command)
"!" 'shell-command
"'" 'evil-use-register)

;;----------------------------------------------------------------------------
;; With-major-leader keys...
Expand Down Expand Up @@ -439,8 +476,7 @@

gitconfig-mode-map
diff-mode-map)
"<return>" (general-predicate-dispatch 'switch-to-buffer
(and (featurep 'lsp-ui) lsp-ui-peek-mode) 'lsp-ui-peek--goto-xref))
"<return>" 'switch-to-buffer)

(general-define-key
:states '(visual)
Expand Down Expand Up @@ -508,6 +544,21 @@
;;----------------------------------------------------------------------------
;; Some functions.
;;----------------------------------------------------------------------------
(defun jester/evil-paste-after--from-copy-register (&optional count)
"So often do we paste from the copy register, let's make it a command and bind it to a key and forget about \"0p"
(interactive "p")
(evil-paste-after (or count 1) ?0))

(defun jester/evil-paste-before--from-copy-register (&optional count)
"So often do we paste from the copy register, let's make it a command and bind it to a key and forget about \"0p"
(interactive "p")
(evil-paste-before (or count 1) ?0))

(general-define-key
:states '(normal visual)
"z p" 'jester/evil-paste-after--from-copy-register
"z P" 'jester/evil-paste-before--from-copy-register)

(setq isearch-lazy-count t)
;; TODO use symbol-overlay ... or?
(evil-define-command jester/evil-normal-search-forward (&optional count)
Expand Down
4 changes: 2 additions & 2 deletions modes/init-face.el
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
:states '(normal visual motion)
:keymaps '(prog-mode-map css-mode yaml-mode conf-mode markdown-mode help-mode)
"<tab>" 'jester/probably-symbol-overlay-put
"M-n" 'symbol-overlay-jump-next
"M-p" 'symbol-overlay-jump-prev)
"H-n" 'symbol-overlay-jump-next
"H-p" 'symbol-overlay-jump-prev)
(jester/with-leader "o p" 'jester/probably-symbol-overlay-put)
;; don't bind any key
(setq symbol-overlay-map (make-sparse-keymap))
Expand Down
9 changes: 6 additions & 3 deletions modes/init-ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,12 @@ If called interactively, let the user select start directory first."

(use-package ivy-prescient
:custom ((ivy-prescient-retain-classic-highlighting t)
(ivy-prescient-enable-filtering nil)
(ivy-prescient-sort-commands
'(:not ivy-switch-buffer swiper swiper-isearch counsel-rg counsel-ag counsel-imenu)))
(ivy-prescient-enable-filtering nil))
:init
;; FIXME: put this in :custom doesn't work?
(setq ivy-prescient-sort-commands
'(:not ivy-switch-buffer swiper swiper-isearch counsel-rg counsel-ag counsel-imenu
ivy-xref-show-defs ivy-xref-show-xrefs))
:demand t
:after (ivy counsel prescient)
:config
Expand Down
2 changes: 1 addition & 1 deletion modes/init-javascript.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
(xref-find-definitions (xref-backend-identifier-at-point (xref-find-backend)))
(condition-case err
(js2-jump-to-definition)
(xref-find-definitions (xref-backend-identifier-at-point (xref-find-backend))))))
(error (xref-find-definitions (xref-backend-identifier-at-point (xref-find-backend)))))))
(general-define-key
:states '(normal motion)
:keymaps '(js2-mode-map)
Expand Down
1 change: 1 addition & 0 deletions modes/init-keyfreq.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
newline
org-self-insert-command
awesome-pair-space
term-send-raw
;; cursor moving commands
forward-char
backward-char
Expand Down
107 changes: 107 additions & 0 deletions modes/init-meow.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
(defun meow-setup ()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
(meow-motion-overwrite-define-key
'("j" . meow-next)
'("k" . meow-prev))
(meow-leader-define-key
;; SPC j/k will run the original command in MOTION state.
'("j" . meow-motion-origin-command)
'("k" . meow-motion-origin-command)
;; Use SPC (0-9) for digit arguments.
'("1" . meow-digit-argument)
'("2" . meow-digit-argument)
'("3" . meow-digit-argument)
'("4" . meow-digit-argument)
'("5" . meow-digit-argument)
'("6" . meow-digit-argument)
'("7" . meow-digit-argument)
'("8" . meow-digit-argument)
'("9" . meow-digit-argument)
'("0" . meow-digit-argument)
'("/" . meow-keypad-describe-key)
'("?" . meow-cheatsheet))
(meow-normal-define-key
'("0" . meow-expand-0)
'("9" . meow-expand-9)
'("8" . meow-expand-8)
'("7" . meow-expand-7)
'("6" . meow-expand-6)
'("5" . meow-expand-5)
'("4" . meow-expand-4)
'("3" . meow-expand-3)
'("2" . meow-expand-2)
'("1" . meow-expand-1)
'("-" . negative-argument)
'(";" . meow-reverse)
'("," . meow-inner-of-thing)
'("." . meow-bounds-of-thing)
'("[" . meow-beginning-of-thing)
'("]" . meow-end-of-thing)
'("a" . meow-append)
'("A" . meow-open-below)
'("b" . meow-back-word)
'("B" . meow-back-symbol)
'("c" . meow-change)
'("C" . meow-change-save)
'("d" . meow-C-d)
'("D" . meow-backward-delete)
'("e" . meow-next-word)
'("E" . meow-next-symbol)
'("f" . meow-find)
'("F" . meow-find-expand)
'("g" . meow-cancel)
'("G" . meow-grab)
'("h" . meow-left)
'("H" . meow-left-expand)
'("i" . meow-insert)
'("I" . meow-open-above)
'("j" . meow-next)
'("J" . meow-next-expand)
'("k" . meow-prev)
'("K" . meow-prev-expand)
'("l" . meow-right)
'("L" . meow-right-expand)
'("m" . meow-join)
'("n" . meow-search)
'("N" . meow-pop-search)
'("o" . meow-block)
'("O" . meow-block-expand)
'("p" . meow-yank)
'("P" . meow-yank-pop)
'("q" . meow-quit)
'("Q" . meow-goto-line)
'("r" . meow-replace)
'("R" . meow-swap-grab)
'("s" . meow-kill)
'("t" . meow-till)
'("T" . meow-till-expand)
'("u" . meow-undo)
'("U" . meow-undo-in-selection)
'("v" . meow-visit)
'("V" . meow-kmacro-matches)
'("w" . meow-mark-word)
'("W" . meow-mark-symbol)
'("x" . meow-line)
'("X" . meow-kmacro-lines)
'("y" . meow-save)
'("Y" . meow-sync-grab)
'("z" . meow-pop-selection)
'("Z" . meow-pop-all-selection)
'("&" . meow-query-replace)
'("%" . meow-query-replace-regexp)
'("'" . repeat)
'("\\" . quoted-insert)
'("<escape>" . meow-last-buffer)))

(use-package meow
:demand t
:init
(meow-global-mode 1)
:config
(meow-setup)
;; If you want relative line number in NORMAL state(for display-line-numbers-mode)
(meow-setup-line-number)
;; If you need setup indicator, see `meow-indicator' for customizing by hand.
(meow-setup-indicator))

(provide 'init-meow)
1 change: 0 additions & 1 deletion modes/init-paredit.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
awesome-pair-open-round awesome-pair-open-bracket awesome-pair-open-curly
awesome-pair-close-round awesome-pair-close-bracket awesome-pair-close-curly
awesome-pair-wrap-round-pair)
:bind (("M-u" . (lambda () (interactive) )))
:init
(general-define-key
:states '(insert emacs)
Expand Down
12 changes: 6 additions & 6 deletions modes/init-php.el
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(add-hook 'php-mode-hook (lambda () (progn
(electric-indent-local-mode -1)
(modify-syntax-entry ?$ "\_" php-mode-syntax-table))))
(use-package php-mode
:config
(modify-syntax-entry ?$ "\_" php-mode-syntax-table))

(evil-define-key 'insert c-mode-map (kbd "C-l") (lambda () (interactive) (insert "->")))
(evil-define-key 'insert php-mode-map (kbd "C-l") (lambda () (interactive) (insert "->")))
(evil-define-key 'insert php-mode-map (kbd "C-j") (lambda () (interactive) (insert " => ")))
;; (evil-define-key 'insert c-mode-map (kbd "C-l") (lambda () (interactive) (insert "->")))
;; (evil-define-key 'insert php-mode-map (kbd "C-l") (lambda () (interactive) (insert "->")))
;; (evil-define-key 'insert php-mode-map (kbd "C-j") (lambda () (interactive) (insert " => ")))


(provide 'init-php)
5 changes: 4 additions & 1 deletion modes/init-themes.el
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
(require-package 'solarized-theme)
(require-package 'color-theme-sanityinc-tomorrow)
(require-package 'doom-themes)
(require-package 'base16-theme)
(require-package 'zenburn-theme)

(setq solarized-use-variable-pitch nil
solarized-scale-org-headlines nil
solarized-scale-outline-headlines nil)

;; If you don't customize it, this is the theme you get.
(setq custom-enabled-themes '(solarized-light))
(setq custom-enabled-themes (if (string= (getenv "EMACS_SOCKET") "maid")
'(doom-tomorrow-night)
'(solarized-light)))

;; Ensure that themes will be applied even if they have not been customized
(defun reapply-themes ()
Expand Down
Loading

0 comments on commit 1b571a5

Please sign in to comment.