diff options
Diffstat (limited to 'emacs')
| -rw-r--r-- | emacs/init.el | 580 | ||||
| -rw-r--r-- | emacs/personal-lisp/chinese.el | 18 | ||||
| -rwxr-xr-x | emacs/personal-lisp/coding-config.el | 165 | ||||
| -rw-r--r-- | emacs/personal-lisp/custom-binds.el | 20 | ||||
| -rw-r--r-- | emacs/personal-lisp/custom-funcs.el | 127 | ||||
| -rw-r--r-- | emacs/personal-lisp/evil-conf.el | 69 | ||||
| -rw-r--r-- | emacs/personal-lisp/general-text.el | 23 | ||||
| -rwxr-xr-x | emacs/personal-lisp/single-header.el | 131 | ||||
| -rw-r--r-- | emacs/personal-lisp/tex-conf.el | 47 | ||||
| -rwxr-xr-x | emacs/personal-lisp/tmu-custom-theme.el | 64 |
10 files changed, 807 insertions, 437 deletions
diff --git a/emacs/init.el b/emacs/init.el index e66b011..bf53b52 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -6,33 +6,29 @@ ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(TeX-source-correlate-method 'synctex) - '(TeX-source-correlate-mode t) - '(TeX-source-correlate-start-server t) + '(TeX-source-correlate-mode t t) + '(TeX-source-correlate-start-server t t) '(TeX-view-program-selection - '(((output-dvi has-no-display-manager) "dvi2tty") - ((output-dvi style-pstricks) "dvips and gv") - (output-dvi "Okular") (output-pdf "Okular") + '(((output-dvi has-no-display-manager) + "dvi2tty") + ((output-dvi style-pstricks) + "dvips and gv") + (output-dvi "Okular") + (output-pdf "Okular") (output-html "xdg-open"))) '(comment-style 'extra-line) '(connection-local-criteria-alist '(((:application tramp :protocol "kubernetes") tramp-kubernetes-connection-local-default-profile) ((:application tramp :protocol "flatpak") - tramp-container-connection-local-default-flatpak-profile - tramp-flatpak-connection-local-default-profile) + tramp-container-connection-local-default-flatpak-profile tramp-flatpak-connection-local-default-profile) ((:application tramp) - tramp-connection-local-default-system-profile - tramp-connection-local-default-shell-profile) - ((:application eshell) eshell-connection-default-profile))) + tramp-connection-local-default-system-profile tramp-connection-local-default-shell-profile) + ((:application eshell) + eshell-connection-default-profile))) '(connection-local-profile-alist '((tramp-flatpak-connection-local-default-profile - (tramp-remote-path "/app/bin" tramp-default-remote-path "/bin" - "/usr/bin" "/sbin" "/usr/sbin" - "/usr/local/bin" "/usr/local/sbin" - "/local/bin" "/local/freeware/bin" - "/local/gnu/bin" "/usr/freeware/bin" - "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin" - "/opt/sbin" "/opt/local/bin")) + (tramp-remote-path "/app/bin" tramp-default-remote-path "/bin" "/usr/bin" "/sbin" "/usr/sbin" "/usr/local/bin" "/usr/local/sbin" "/local/bin" "/local/freeware/bin" "/local/gnu/bin" "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin" "/opt/sbin" "/opt/local/bin")) (tramp-kubernetes-connection-local-default-profile (tramp-config-check . tramp-kubernetes--current-context-data) (tramp-extra-expand-args 97 @@ -45,147 +41,112 @@ (tramp-kubernetes--context-namespace (car tramp-current-connection)))) (tramp-container-connection-local-default-flatpak-profile - (tramp-remote-path "/app/bin" tramp-default-remote-path "/bin" - "/usr/bin" "/sbin" "/usr/sbin" - "/usr/local/bin" "/usr/local/sbin" - "/local/bin" "/local/freeware/bin" - "/local/gnu/bin" "/usr/freeware/bin" - "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin" - "/opt/sbin" "/opt/local/bin")) + (tramp-remote-path "/app/bin" tramp-default-remote-path "/bin" "/usr/bin" "/sbin" "/usr/sbin" "/usr/local/bin" "/usr/local/sbin" "/local/bin" "/local/freeware/bin" "/local/gnu/bin" "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin" "/opt/sbin" "/opt/local/bin")) (tramp-connection-local-darwin-ps-profile - (tramp-process-attributes-ps-args "-acxww" "-o" - "pid,uid,user,gid,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - "-o" "state=abcde" "-o" - "ppid,pgid,sess,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etime,pcpu,pmem,args") - (tramp-process-attributes-ps-format (pid . number) - (euid . number) - (user . string) - (egid . number) (comm . 52) - (state . 5) (ppid . number) - (pgrp . number) - (sess . number) - (ttname . string) - (tpgid . number) - (minflt . number) - (majflt . number) - (time . tramp-ps-time) - (pri . number) - (nice . number) - (vsize . number) - (rss . number) - (etime . tramp-ps-time) - (pcpu . number) - (pmem . number) (args))) + (tramp-process-attributes-ps-args "-acxww" "-o" "pid,uid,user,gid,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "-o" "state=abcde" "-o" "ppid,pgid,sess,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etime,pcpu,pmem,args") + (tramp-process-attributes-ps-format + (pid . number) + (euid . number) + (user . string) + (egid . number) + (comm . 52) + (state . 5) + (ppid . number) + (pgrp . number) + (sess . number) + (ttname . string) + (tpgid . number) + (minflt . number) + (majflt . number) + (time . tramp-ps-time) + (pri . number) + (nice . number) + (vsize . number) + (rss . number) + (etime . tramp-ps-time) + (pcpu . number) + (pmem . number) + (args))) (tramp-connection-local-busybox-ps-profile - (tramp-process-attributes-ps-args "-o" - "pid,user,group,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - "-o" "stat=abcde" "-o" - "ppid,pgid,tty,time,nice,etime,args") - (tramp-process-attributes-ps-format (pid . number) - (user . string) - (group . string) (comm . 52) - (state . 5) (ppid . number) - (pgrp . number) - (ttname . string) - (time . tramp-ps-time) - (nice . number) - (etime . tramp-ps-time) - (args))) + (tramp-process-attributes-ps-args "-o" "pid,user,group,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "-o" "stat=abcde" "-o" "ppid,pgid,tty,time,nice,etime,args") + (tramp-process-attributes-ps-format + (pid . number) + (user . string) + (group . string) + (comm . 52) + (state . 5) + (ppid . number) + (pgrp . number) + (ttname . string) + (time . tramp-ps-time) + (nice . number) + (etime . tramp-ps-time) + (args))) (tramp-connection-local-bsd-ps-profile - (tramp-process-attributes-ps-args "-acxww" "-o" - "pid,euid,user,egid,egroup,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - "-o" - "state,ppid,pgid,sid,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etimes,pcpu,pmem,args") - (tramp-process-attributes-ps-format (pid . number) - (euid . number) - (user . string) - (egid . number) - (group . string) (comm . 52) - (state . string) - (ppid . number) - (pgrp . number) - (sess . number) - (ttname . string) - (tpgid . number) - (minflt . number) - (majflt . number) - (time . tramp-ps-time) - (pri . number) - (nice . number) - (vsize . number) - (rss . number) - (etime . number) - (pcpu . number) - (pmem . number) (args))) + (tramp-process-attributes-ps-args "-acxww" "-o" "pid,euid,user,egid,egroup,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "-o" "state,ppid,pgid,sid,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etimes,pcpu,pmem,args") + (tramp-process-attributes-ps-format + (pid . number) + (euid . number) + (user . string) + (egid . number) + (group . string) + (comm . 52) + (state . string) + (ppid . number) + (pgrp . number) + (sess . number) + (ttname . string) + (tpgid . number) + (minflt . number) + (majflt . number) + (time . tramp-ps-time) + (pri . number) + (nice . number) + (vsize . number) + (rss . number) + (etime . number) + (pcpu . number) + (pmem . number) + (args))) (tramp-connection-local-default-shell-profile - (shell-file-name . "/bin/sh") (shell-command-switch . "-c")) + (shell-file-name . "/bin/sh") + (shell-command-switch . "-c")) (tramp-connection-local-default-system-profile - (path-separator . ":") (null-device . "/dev/null")) - (eshell-connection-default-profile (eshell-path-env-list)))) + (path-separator . ":") + (null-device . "/dev/null")) + (eshell-connection-default-profile + (eshell-path-env-list)))) '(custom-enabled-themes '(tmu-custom)) '(custom-safe-themes - '("6dafb31ade9ff07229faaf05c41c2ae475c44731362b792f65f3930b1a2c9cfd" - "dc77e008092a5a4aa6b6ed8e4826bebf8f2fb930a8de073bf7f458efd884cca8" - "d1ff3e66028f9c527298580d2a64f9e3280f07f9e94d4dada72b67ef15069441" - "3d4e3644e237a95683daa73e397c4c0d1ae06bbaaf8040104232591a28bc1315" - "12a07bc38295e4b06a8965db261f51ea7ea61fbf91b3ef41298bbb549d1d9403" - default)) + '("9f2e4e8b2ddbfdd392eedbc123649d94654278dee5a53b899557224416413d35" "6dafb31ade9ff07229faaf05c41c2ae475c44731362b792f65f3930b1a2c9cfd" "dc77e008092a5a4aa6b6ed8e4826bebf8f2fb930a8de073bf7f458efd884cca8" "d1ff3e66028f9c527298580d2a64f9e3280f07f9e94d4dada72b67ef15069441" "3d4e3644e237a95683daa73e397c4c0d1ae06bbaaf8040104232591a28bc1315" "12a07bc38295e4b06a8965db261f51ea7ea61fbf91b3ef41298bbb549d1d9403" default)) + '(custom-theme-directory "~/.emacs.d/personal-lisp") '(ede-project-directories - '("/home/tmu/Desktop/eway/sway" "/home/tmu/Desktop/eway/cage" - "/home/tmu/Desktop/eway/wlroots" "/home/tmu/Desktop/eway/comp" - "/home/tmu/Desktop/eway")) + '("/home/tmu/Desktop/eway/sway" "/home/tmu/Desktop/eway/cage" "/home/tmu/Desktop/eway/wlroots" "/home/tmu/Desktop/eway/comp" "/home/tmu/Desktop/eway")) '(evil-collection-mode-list - '(2048-game ag alchemist anaconda-mode apropos arc-mode atomic-chrome - auto-package-update beginend bluetooth bm bookmark - (buff-menu "buff-menu") calendar cider cmake-mode - color-rg comint company compile consult corfu crdt - (custom cus-edit) cus-theme dashboard daemons deadgrep - debbugs debug devdocs dictionary diff-hl diff-mode - dired dired-sidebar disk-usage distel doc-view docker - ebib ebuku edbi edebug ediff eglot elpaca ement - explain-pause-mode eldoc elfeed elisp-mode elisp-refs - elisp-slime-nav embark emms emoji epa ert eshell - eval-sexp-fu evil-mc eww fanyi finder flycheck flymake - forge free-keys geiser ggtags git-timemachine gited - gnus go-mode grep guix hackernews helm help helpful - hg-histedit hungry-delete ibuffer (image image-mode) - image-dired image+ imenu imenu-list (indent "indent") - indium info ivy js2-mode leetcode lispy lms log-edit - log-view lsp-ui-imenu lua-mode kotlin-mode macrostep - man (magit magit-repos magit-submodule) magit-section - magit-todos markdown-mode monky mpc mpdel mu4e - mu4e-conversation neotree newsticker notmuch nov - omnisharp org org-present org-roam osx-dictionary - outline p4 (package-menu package) pass (pdf pdf-view) - popup proced (process-menu simple) prodigy profiler - python quickrun racer racket-describe realgud reftex - replace restclient rg ripgrep rjsx-mode robe rtags - ruby-mode scheme scroll-lock selectrum sh-script - shortdoc simple simple-mpc slime sly snake so-long - speedbar tab-bar tablist tabulated-list tar-mode telega - (term term ansi-term multi-term) tetris thread tide - timer-list transmission trashed tuareg typescript-mode - vc-annotate vc-dir vc-git vdiff vertico view vlf vterm - vundo w3m wdired wgrep which-key woman xref xwidget - yaml-mode youtube-dl zmusic + '(2048-game ag alchemist anaconda-mode apropos arc-mode atomic-chrome auto-package-update beginend bluetooth bm bookmark + (buff-menu "buff-menu") + calendar cider cmake-mode color-rg comint company compile consult corfu crdt + (custom cus-edit) + cus-theme dashboard daemons deadgrep debbugs debug devdocs dictionary diff-hl diff-mode dired dired-sidebar disk-usage distel doc-view docker ebib ebuku edbi edebug ediff eglot elpaca ement explain-pause-mode eldoc elfeed elisp-mode elisp-refs elisp-slime-nav embark emms emoji epa ert eshell eval-sexp-fu evil-mc eww fanyi finder flycheck flymake forge free-keys geiser ggtags git-timemachine gited gnus go-mode grep guix hackernews helm help helpful hg-histedit hungry-delete ibuffer + (image image-mode) + image-dired image+ imenu imenu-list + (indent "indent") + indium info ivy js2-mode leetcode lispy lms log-edit log-view lsp-ui-imenu lua-mode kotlin-mode macrostep man + (magit magit-repos magit-submodule) + magit-section magit-todos markdown-mode monky mpc mpdel mu4e mu4e-conversation neotree newsticker notmuch nov omnisharp org org-present org-roam osx-dictionary outline p4 + (package-menu package) + pass + (pdf pdf-view) + popup proced + (process-menu simple) + prodigy profiler python quickrun racer racket-describe realgud reftex replace restclient rg ripgrep rjsx-mode robe rtags ruby-mode scheme scroll-lock selectrum sh-script shortdoc simple simple-mpc slime sly snake so-long speedbar tab-bar tablist tabulated-list tar-mode telega + (term term ansi-term multi-term) + tetris thread tide timer-list transmission trashed tuareg typescript-mode vc-annotate vc-dir vc-git vdiff vertico view vlf vterm vundo w3m wdired wgrep which-key woman xref xwidget yaml-mode youtube-dl zmusic (ztree ztree-diff ztree-dir))) '(helm-minibuffer-history-key "M-p") '(menu-bar-mode nil) '(package-selected-packages - '(2048-game async auctex benchmark-init bongo buffer-move - calc-prog-utils chinese-conv company-cabal company-go - dumb-jump eat emms emms-player-simple-mpv emms-state - esh-help eshell-fringe-status eshell-vterm esup evil - evil-collection evil-commentary evil-easymotion - evil-snipe evil-surround exwm eyebrowse fish-mode - flymake-diagnostic-at-point fold-this folding free-keys - frog-jump-buffer gdscript-mode gxref haskell-mode - helm-hoogle highlight hindent hydra ibuffer-project - imenu-anywhere ivy-prescient oauth2 persp-mode - persp-mode-projectile-bridge popwin pyim-basedict - pyim-cangjiedict pyim-wbdict rustic shm - sideline-flymake sideline-lsp solarized-theme - tree-sitter unicode-fonts volume workgroups xelb)) + '(counsel hide-lines 2048-game async auctex benchmark-init bongo buffer-move calc-prog-utils chinese-conv company-cabal company-go dumb-jump eat emms emms-player-simple-mpv emms-state esh-help eshell-fringe-status eshell-vterm esup evil evil-collection evil-commentary evil-easymotion evil-snipe evil-surround exwm eyebrowse fish-mode flymake-diagnostic-at-point fold-this folding free-keys frog-jump-buffer gdscript-mode gxref haskell-mode helm-hoogle highlight hindent hydra ibuffer-project imenu-anywhere ivy-prescient oauth2 persp-mode persp-mode-projectile-bridge popwin pyim-basedict pyim-cangjiedict pyim-wbdict rustic shm sideline-flymake sideline-lsp solarized-theme tree-sitter unicode-fonts volume workgroups xelb)) '(persp-restore-window-conf-method nil) '(pyim-assistant-scheme 'quanpin) '(safe-local-variable-values '((LEXICAL-binding . t))) @@ -194,8 +155,7 @@ '(tool-bar-mode nil) '(transient-mark-mode nil) '(whitespace-style - '(face trailing tabs lines-tail missing-newline-at-eof indentation - space-after-tab space-before-tab tab-mark)) + '(face trailing tabs lines-tail missing-newline-at-eof indentation space-after-tab space-before-tab tab-mark)) '(xref-show-definitions-function 'xref-show-definitions-buffer-at-bottom)) ;; (use-package benchmark-init @@ -204,71 +164,42 @@ ;; ;; To disable collection of benchmark data after init is done. ;; (add-hook 'after-init-hook 'benchmark-init/deactivate)) +;; performance stuff (setq gc-cons-threshold most-positive-fixnum) - (add-hook 'emacs-startup-hook (lambda () (setq gc-cons-threshold (expt 2 23)))) -;; Don't kill scratch ever -(with-current-buffer "*scratch*" - (emacs-lock-mode 'kill)) +;; allow using emacsclient +(load "server") +(unless (server-running-p) (server-start)) +;; buffer preferences +(with-current-buffer "*scratch*" (emacs-lock-mode 'kill)) +(setq kill-buffer-query-functions (delq 'process-kill-buffer-query-function kill-buffer-query-functions)) ;; don't ask about killing buffers +(setq confirm-kill-processes nil) ;; don't ask about kill processes + +;; enable external packages (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (package-initialize) -;; stuff I will always want +;; general editing config for everywhere (electric-pair-mode 1) (global-hl-line-mode 1) +(global-hl-todo-mode 1) (global-auto-revert-mode 1) - -;; spelling -(require 'spell-fu) -(setq ispell-personal-dictionary "/home/tmu/.aspell.en.pws") -(add-hook 'text-mode-hook (lambda () (spell-fu-mode 1))) - -;; chinese -;; (require 'unicode-fonts) -;; (unicode-fonts-setup) -(require 'pyim) -(require 'pyim-basedict) -(pyim-basedict-enable) -;; (require 'pyim-wbdict) -(setq default-input-method "pyim") -(setq pyim-default-scheme 'quanpin) -;; (pyim-wbdict-v98-morphe-enable) -;; (dolist (charset '(kana han symbol cjk-misc bopomofo)) -;; (set-fontset-font (frame-parameter nil 'font) -;; charset -;; (font-spec :family "FangSong" :size 15))) -;; (setq rime-translate-keybindings -;; '("C-f" "C-b" "C-n" "C-p" "C-g" "<left>" "<right>" "<up>" "<down>" "<prior>" "<next>" "<delete>")) -;; (setq rime-share-data-dir "~/.local/share/fcitx5/rime") -;; (setq rime-show-candidate 'popup) - -;; dictionaries -(define-prefix-command 'dict-map) -(global-set-key (kbd "M-l") 'dict-map) -(define-keymap :full nil - :parent nil - :suppress nil - :keymap nil - :name "dict-map" - :prefix 'dict-map - (kbd "w") 'sdcv-search-input - (kbd "c") (lambda () (interactive) - (activate-input-method 'pyim) - (sdcv-search-input (read-from-minibuffer "Chinese Word: " - nil nil nil - nil nil t)) - (activate-input-method nil))) +(setq-default indent-tabs-mode nil) ;; no tabs +(setq fill-column 80) +(setq whitespace-style + '(face trailing tabs missing-newline-at-eof indentation space-after-tab space-before-tab tab-mark)) ;; nice startup +(add-to-list 'default-frame-alist '(alpha-background . 90)) ;; transparancy (require 'iimage) (setq inhibit-startup-screen t) (setq initial-scratch-message (concat (propertize ";; " 'invisible t) - "</home/tmu/.emacs.d/splashLaputa.png> + "</home/tmu/.emacs.d/splashLaputa.png> ;; scratch for lisp evaluation and unsaved text ")) @@ -276,109 +207,15 @@ (with-current-buffer "*scratch*" (iimage-mode 1)))) -;; transparancy -(add-to-list 'default-frame-alist '(alpha-background . 90)) ; For all new frames -(defun toggle-frame-transparency () - "Toggle transparency." - (interactive) - (let ((alpha-transparency 90)) - (if (eq alpha-transparency (frame-parameter nil 'alpha-background)) - (set-frame-parameter nil 'alpha-background 100) - (set-frame-parameter nil 'alpha-background alpha-transparency)))) - -;; custom func keybinds -(defun wrap-region-paren () - "Wraps the region in parens. -Similar to pressing ( with the region active." - (interactive) - (let ((beg (region-beginning)) - (end (region-end))) - (save-excursion - (goto-char beg) - (insert "(") - (goto-char (+ end 1)) - (insert ")") - ))) -(defun zap-whitespace () - "zaps the whitespace around the point in both directions" - (interactive) - (push-mark) - (skip-chars-backward " \t\n") - (push-mark) - (skip-chars-forward " \t\n") - (delete-region (mark) (point)) - (pop-mark) - (goto-char (mark)) - (pop-mark)) -(defun wrap-sexp (&optional arg) - "Wraps the following sexp in a pair of parens. -Places inside the new pair, with prefix arg do the same backwards, pushing the -mark. Does the same of ARG number sexps if given" - (interactive "P") - (message "%s" arg) - (if arg - (progn - (push-mark) - (insert-pair -1 ?\( ?\))) - (insert-pair 1 ?\( ?\)))) -(global-set-key (kbd "M-w") 'copy-region-as-kill) ;;make copying not flash cursor -(global-set-key (kbd "M-(") 'wrap-region-paren) -(global-set-key (kbd "M-z") 'zap-whitespace) -(global-set-key (kbd "C-M-z") 'wrap-sexp) -;;move buffers between windows in a convient way -(require 'buffer-move) -(global-set-key (kbd "C-x -") 'buf-move-right) -;; quick window switching -(global-set-key (kbd "M-o") 'other-window) -;; get me a calculator -(global-unset-key (kbd "M-c")) -(global-set-key (kbd "M-c") 'calc) -(global-unset-key (kbd "M-k")) -(global-set-key (kbd "M-k") 'kill-current-buffer) -(global-set-key (kbd "M-K") 'kill-buffer-and-window) -(global-set-key (kbd "M-U") 'scroll-lock-mode) -(global-set-key (kbd "M-Q") 'auto-fill-mode) - -;; save/restore window config -;; (setq current-saved-layout ?0) -;; (seq-do (lambda (number) -;; (let* ((string (int-to-string number)) -;; (char (string-to-char string)) -;; (key (kbd (concat "M-" string)))) -;; (global-unset-key key) -;; (global-set-key key (lambda () -;; (interactive) -;; (window-configuration-to-register current-saved-layout) -;; (unless (window-configuration-p (car (get-register char))) -;; (window-configuration-to-register char)) -;; (jump-to-register char) -;; (setq current-saved-layout char))))) -;; '(0 1 2 3 4 5 6 7 8 9)) - -;; latex stuff -(require 'tex-mode) -(define-key latex-mode-map (kbd "C-c m") (lambda () (interactive) - (push-mark) - (insert "\\[\n\n\\]") - (indent-region (mark) (point)) - (pop-mark) - (previous-line) - (indent-for-tab-command) - )) - -;; (add-hook 'tex-mode-hook (lambda () -;; (setq-local compile-command -;; (concat "pdflatex " (shell-quote-argument (buffer-file-name)))) -;; (add-hook 'after-save-hook 'recompile 0 t))) - -;; better minibuffer complete (use-package vertico + ;; better minibuffer complete :init (vertico-mode) (vertico-flat-mode) (setq vertico-cycle t)) (use-package orderless + ;; ordering minibuffer completions :ensure t :custom (completion-styles '(orderless partial-completion flex basic)) @@ -392,160 +229,29 @@ mark. Does the same of ARG number sexps if given" :init (which-key-mode)) -;; better in-buffer completion -;; (require 'company) -;; (add-hook 'prog-mode-hook (lambda () -;; (company-mode 1))) -;; (global-unset-key (kbd "M-/")) -;; (global-set-key (kbd "M-/") 'company-complete) - -;; mail stuff -(autoload 'mu4e "~/.emacs.d/mail.el" "mu4e stuff" t) - -;; music -;; (autoload 'youtube-dl-enqueue "~/.emacs.d/youtube-dl.el" "download from youtube" t) - -;; (emms-all) -;; (require 'emms-info-native) -;; (defun emms-file-info (track) -;; "Sets info of a track based on it's file name. Expects Artist - Album - Track.ext." -;; (when (emms-track-file-p track) -;; (let* ((file-name (emms-track-name track)) -;; (tags (string-split (car (seq-reverse (string-split file-name "/"))) " - "))) -;; (emms-track-set track 'info-artist (car tags)) -;; (emms-track-set track 'info-album (car (cdr tags))) -;; (emms-track-set track 'info-title (car (cdr (cdr tags))))))) - -;; (setq emms-player-list '(emms-player-mpv) -;; emms-info-functions '(emms-file-info) -;; emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find) - -;; (require 'emms-state) -;; ;; see single header, loaded AFTER this for more about emms-state - - -;; allow using emacsclient -(load "server") -(unless (server-running-p) (server-start)) - -;; mutli frame stuff -(global-set-key (kbd "C-x C-C") 'save-buffers-kill-terminal) -(global-set-key (kbd "C-x C-c") (lambda () - (interactive) - (if (eq 1 (length (frame-list))) - ;; sole frame, exit - (save-buffers-kill-terminal) - (delete-frame)))) - -;; don't ask about killing buffers -(setq kill-buffer-query-functions (delq 'process-kill-buffer-query-function kill-buffer-query-functions)) - -;; don't ask about kill processes -(setq confirm-kill-processes nil) - -(autoload 'async-eval "~/.emacs.d/async-eval.el" "evaluate in another emacs process" t) - -;; evil mode stuff -(setq - evil-want-keybinding nil - evil-want-integration t) -;; evil-want-C-d-scroll nil -;; evil-want-C-w-delete nil -;; evil-disable-insert-state-bindings t -;; evil-respect-visual-line-mode t -(require 'evil) -(when (require 'evil-collection nil t) - (evil-collection-init)) -(evil-mode 1) -(evilem-default-keybindings "SPC") -(define-key evil-motion-state-map (kbd "TAB") 'indent-for-tab-command) -(use-package evil-surround - :ensure t - :config - (global-evil-surround-mode 1)) -(use-package evil-snipe - :ensure t - :config - (evil-snipe-mode +1) - (evil-snipe-override-mode +1) - (setq evil-snipe-scope 'buffer) - (evil-define-key 'visual evil-snipe-local-mode-map "z" 'evil-snipe-s) - (evil-define-key 'visual evil-snipe-local-mode-map "Z" 'evil-snipe-S)) -(define-key evil-insert-state-map (kbd "C-d") 'delete-char) -(define-key evil-insert-state-map (kbd "C-e") 'move-end-of-line) -(define-key evil-insert-state-map (kbd "C-a") 'move-beginning-of-line) -(define-key evil-normal-state-map (kbd "M-.") 'xref-find-definitions) -(define-key evil-normal-state-map (kbd "C-t") 'transpose-chars) - -(add-hook 'prog-mode-hook (lambda () - (modify-syntax-entry ?_ "w") )) - -(add-hook 'dired-mode-hook (lambda () - (define-key evil-normal-state-local-map (kbd "C-o") - 'dired-display-file))) - -;;; sashka bindings -;; movement -(defun evil-window-split-and-switch () - "Split the window vertically and switch to the new buffer." - (interactive) - (evil-window-split) - (other-window 1)) - -(defun evil-window-vsplit-and-switch () - "Split the window horizontally and switch to the new buffer." - (interactive) - (evil-window-vsplit) - (other-window 1)) - -(evil-define-key 'normal global-map (kbd "SPC i") 'imenu) -(evil-define-key 'normal global-map (kbd "SPC RET") 'vterm) -(evil-define-key 'normal global-map (kbd "SPC v") 'vterm) -(evil-define-key 'normal global-map (kbd "SPC !") 'abort-recursive-edit) -(evil-define-key 'normal global-map (kbd "SPC f f") 'find-file) - -(evil-define-key 'normal global-map (kbd "SPC SPC SPC j") 'evil-window-split-and-switch) -(evil-define-key 'normal global-map (kbd "SPC SPC SPC k") 'evil-window-split-and-switch) -(evil-define-key 'normal global-map (kbd "SPC SPC SPC h") 'evil-window-vsplit-and-switch) -(evil-define-key 'normal global-map (kbd "SPC SPC SPC l") 'evil-window-vsplit-and-switch) -(evil-define-key 'normal global-map (kbd "SPC SPC h") 'evil-window-left) -(evil-define-key 'normal global-map (kbd "SPC SPC j") 'evil-window-down) -(evil-define-key 'normal global-map (kbd "SPC SPC k") 'evil-window-up) -(evil-define-key 'normal global-map (kbd "SPC SPC l") 'evil-window-right) -(evil-define-key 'normal global-map (kbd "SPC SPC w") 'delete-window) -(evil-define-key 'normal global-map (kbd "SPC SPC q") 'delete-window) -(evil-define-key 'normal global-map (kbd "SPC SPC b") 'balance-windows) -(evil-define-key 'normal global-map (kbd "SPC s s") 'save-buffer) -(evil-define-key 'normal global-map (kbd "SPC s f") 'counsel-find-file) -(evil-define-key 'normal global-map (kbd "SPC s r") 'counsel-rg) -(evil-define-key 'normal global-map (kbd "SPC ;") 'frog-jump-buffer) - ;; frog jump stuff (add-hook 'frog-menu-after-init-hook (lambda () (setq-local avy-background nil))) -(load-file "~/.emacs.d/coding-config.el") - -(load-file "~/.emacs.d/exwm-pref.el") - -(load-file "~/.emacs.d/single-header.el") - -(put 'dired-find-alternate-file 'disabled nil) -(put 'upcase-region 'disabled nil) -(put 'list-timers 'disabled nil) -(put 'narrow-to-region 'disabled nil) - -;; no tabs -(setq-default indent-tabs-mode nil) - - +(load-file "~/.emacs.d/personal-lisp/custom-funcs.el") +(load-file "~/.emacs.d/personal-lisp/evil-conf.el") +(load-file "~/.emacs.d/personal-lisp/general-text.el") +(load-file "~/.emacs.d/personal-lisp/tex-conf.el") +(load-file "~/.emacs.d/personal-lisp/coding-config.el") +(load-file "~/.emacs.d/personal-lisp/single-header.el") +(load-file "~/.emacs.d/personal-lisp/chinese.el") +(load-file "~/.emacs.d/personal-lisp/custom-binds.el") +;; (load-file "~/.emacs.d/exwm-pref.el") + +;; emacs mechanically set stuff (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. - '(frog-menu-posframe-background-face ((t (:background "RoyalBlue4")))) - '(minibuffer-prompt ((t (:background "gray10" :foreground "cyan" :box nil :weight bold)))) - '(pyim-page ((t (:inherit default :background "#333333" :foreground "#dcdccc")))) - '(vterm-color-blue ((t (:inherit ansi-color-bright-green))))) + ) +(put 'dired-find-alternate-file 'disabled nil) +(put 'upcase-region 'disabled nil) (put 'downcase-region 'disabled nil) +(put 'list-timers 'disabled nil) +(put 'narrow-to-region 'disabled nil) diff --git a/emacs/personal-lisp/chinese.el b/emacs/personal-lisp/chinese.el new file mode 100644 index 0000000..4b01594 --- /dev/null +++ b/emacs/personal-lisp/chinese.el @@ -0,0 +1,18 @@ +;; chinese input stuff +;; (require 'unicode-fonts) +;; (unicode-fonts-setup) +(require 'pyim) +(require 'pyim-basedict) +(pyim-basedict-enable) +;; (require 'pyim-wbdict) +(setq default-input-method "pyim") +(setq pyim-default-scheme 'quanpin) +;; (pyim-wbdict-v98-morphe-enable) +;; (dolist (charset '(kana han symbol cjk-misc bopomofo)) +;; (set-fontset-font (frame-parameter nil 'font) +;; charset +;; (font-spec :family "FangSong" :size 15))) +;; (setq rime-translate-keybindings +;; '("C-f" "C-b" "C-n" "C-p" "C-g" "<left>" "<right>" "<up>" "<down>" "<prior>" "<next>" "<delete>")) +;; (setq rime-share-data-dir "~/.local/share/fcitx5/rime") +;; (setq rime-show-candidate 'popup) diff --git a/emacs/personal-lisp/coding-config.el b/emacs/personal-lisp/coding-config.el new file mode 100755 index 0000000..2ddfbd6 --- /dev/null +++ b/emacs/personal-lisp/coding-config.el @@ -0,0 +1,165 @@ +;; Various config specifically for programming + +(add-hook 'xref-backend-functions 'gxref-xref-backend) + +;; better commenting binds +(global-set-key (kbd "C-x C-;") 'comment-or-uncomment-region) +(global-set-key (kbd "C-x ;") 'comment-line) +(global-set-key (kbd "C-x :") 'comment-set-column) ;never gonna use but whatever + +(setq asm-comment-char ?#) ; prefer # over ; for asm comments + +;; generate tags for label names in asm files, based on asm files in the current directory +(add-hook 'asm-mode-hook + (lambda () + (add-hook 'after-save-hook + (lambda () + (shell-command + "find . -iregex '.*\\.[sS]' -exec etags -l none -r '/\\([a-zA-Z0-9\\-_]+\\):/\1/' {} +")) + 0 t))) + +;; nice eglot binds +(global-set-key (kbd "C-c f") 'eglot-code-action-quickfix) +(global-set-key (kbd "C-c C-f") 'eglot-code-actions) + +;; Find defs in various ways +(global-set-key (kbd "M-i") 'imenu) +(global-set-key (kbd "M-I") 'xref-find-definitions) + + +;; make ibuffer play with projectile +(require 'ibuffer) +(add-hook 'ibuffer-hook + (lambda () + (ibuffer-projectile-set-filter-groups) + (unless (eq ibuffer-sorting-mode 'alphabetic) + (ibuffer-do-sort-by-alphabetic)))) + +;; make shells and whatnot slightly better +(require 'comint) +(setq comint-scroll-to-bottom-on-input t) +(setq comint-scroll-to-bottom-on-output t) + +;; various folding types and binds +(autoload 'hide-lines "hide-lines" "Hide lines based on a regexp" t) +(global-set-key (kbd "C-c /") 'hide-lines) +(autoload 'fold-this "fold-this" "arbitrary folding" t) +(autoload 'fold-this-unfold-at-point "fold-this" "arbitrary folding" t) +(define-prefix-command 'fold-map) +(global-set-key (kbd "M-F") 'fold-map) +(define-keymap :full nil + :parent nil + :suppress nil + :keymap nil + :name "fold-map" + :prefix 'fold-map + (kbd "c") 'fold-this + (kbd "e") 'fold-this-unfold-at-point + (kbd "t") 'hs-toggle-hiding + (kbd "f") 'fold-this-fold-forward + (kbd "b") 'fold-this-fold-backward + (kbd "l") 'hs-hide-level) + +;; global prog stuff that differs from global/text +(add-hook 'prog-mode-hook (lambda () + (hs-minor-mode 1) + ;; (flymake-mode 1) + (spell-fu-mode 0) + (superword-mode 1) + (whitespace-mode 1) + (modify-syntax-entry ?_ "w") ) + (display-fill-column-indicator-mode 1) + (add-hook 'before-save-hook + (lambda () + (if (not (eq major-mode 'makefile-gmake-mode)) + (clean-prog-file (current-buffer)))))) + +;; haskell flavor and tags +(setq haskell-tags-on-save t) +(add-hook 'haskell-mode-hook (lambda () + (hindent 1) + (interactive-haskell-mode 1) + (eldoc-mode 1))) +(setq haskell-process-type 'cabal-repl) + +;; eshell stuff +(require 'eshell) +(require 'esh-help) +(setup-esh-help-eldoc) +(add-hook 'eshell-mode-hook (lambda () (eldoc-mode 1))) +(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode) +(require 'em-smart) +(setq eshell-where-to-jump 'begin) +(setq eshell-review-quick-commands 'not-even-short-output) +(setq eshell-smart-space-goes-to-end t) +(add-to-list 'eshell-modules-list 'eshell-smart) +(eshell-vterm-mode 1) +(setq eshell-visual-commands + (append eshell-visual-commands + '("ytfzf" "nmtui" "w3m"))) + +(add-hook 'vterm-mode-hook (lambda () (hl-line-mode 0))) +(add-hook 'eshell-mode-hook (lambda () (hl-line-mode 0))) + +(define-key vterm-mode-map (kbd "M-W") 'persp-switch-to-buffer) +(define-key vterm-mode-map (kbd "M-k") 'persp-kill-buffer) +(define-key vterm-mode-map (kbd "M-p") 'persp-key-map) + +(define-key eshell-mode-map (kbd "M-o") 'other-window) +(define-key eshell-mode-map (kbd "M-W") 'switch-buffer) +(define-key eshell-mode-map (kbd "C-l") (lambda () (interactive) (recenter-top-bottom 0))) + +;; scuffed compilation binds and prefs +(global-set-key (kbd "M-m") (lambda () + (interactive) + (if flymake-mode + (flymake-goto-next-error) + (next-error)))) +(global-set-key (kbd "M-M") 'recompile) +(setq compilation-always-kill t + compilation-scroll-output t) +;; Allow compilation buffer to be dedicated across frames +(push '("\\*compilation\\*" . (nil (reusable-frames . t))) display-buffer-alist) + + +;; better searching +(setq counsel-grep-base-command + "rg -i -M 120 --no-heading --line-number --color never '%s' %s") +(global-set-key (kbd "C-s") 'counsel-grep-or-swiper) +(global-set-key (kbd "C-S-s") 'isearch-forward) +(define-key evil-normal-state-map (kbd "C-r") 'counsel-rg) + +(require 'persp-mode) +(persp-mode 1) + +(with-eval-after-load "persp-mode" + (defvar after-switch-to-buffer-functions nil) + (defvar after-display-buffer-functions nil) + + (if (fboundp 'advice-add) + ;;Modern way + (progn + (defun after-switch-to-buffer-adv (&rest r) + (apply #'run-hook-with-args 'after-switch-to-buffer-functions r)) + (defun after-display-buffer-adv (&rest r) + (apply #'run-hook-with-args 'after-display-buffer-functions r)) + (advice-add #'switch-to-buffer :after #'after-switch-to-buffer-adv) + (advice-add #'display-buffer :after #'after-display-buffer-adv)) + + (add-hook 'after-switch-to-buffer-functions + #'(lambda (bn) (when (and persp-mode + (not persp-temporarily-display-buffer)) + (persp-add-buffer bn))))) + + (setq persp-add-buffer-on-after-change-major-mode 'free + persp-autokill-buffer-on-remove t + persp-kill-foreign-buffer-behaviour 'dont-ask) + (global-set-key (kbd "M-p") 'persp-key-map) + (global-set-key (kbd "C-x b") #'persp-switch-to-buffer) + (global-set-key (kbd "C-x B") #'switch-to-buffer) + (global-set-key (kbd "C-x C-b") (lambda () + (interactive) + (with-persp-buffer-list () (ibuffer)))) + (global-set-key (kbd "M-W") #'persp-switch-to-buffer) + (global-set-key (kbd "C-x k") #'persp-kill-buffer)) + diff --git a/emacs/personal-lisp/custom-binds.el b/emacs/personal-lisp/custom-binds.el new file mode 100644 index 0000000..92dcc69 --- /dev/null +++ b/emacs/personal-lisp/custom-binds.el @@ -0,0 +1,20 @@ +;; keyboard binds (mostly global) +(global-set-key (kbd "C-x C-C") 'save-buffers-kill-terminal) +(global-set-key (kbd "C-x C-c") 'close-or-kill) +(global-set-key (kbd "M-w") 'copy-region-as-kill) ;;make copying not flash cursor +(global-set-key (kbd "M-(") 'wrap-region-paren) +(global-set-key (kbd "M-z") 'zap-whitespace) +(global-set-key (kbd "C-M-z") 'wrap-sexp) +(require 'buffer-move) +(global-set-key (kbd "C-x -") 'buf-move-right) +(global-set-key (kbd "M-o") 'other-window) +(global-set-key (kbd "M-c") 'calc) +(global-set-key (kbd "M-k") 'kill-current-buffer) +(global-set-key (kbd "M-K") 'kill-buffer-and-window) +(global-set-key (kbd "M-U") 'scroll-lock-mode) +(global-set-key (kbd "M-Q") 'auto-fill-mode) +(require 'dired) +(define-key dired-mode-map (kbd "C-o") 'dired-display-file) +;; (add-hook 'dired-mode-hook (lambda () +;; (define-key evil-normal-state-local-map (kbd "C-o") +;; 'dired-display-file))) diff --git a/emacs/personal-lisp/custom-funcs.el b/emacs/personal-lisp/custom-funcs.el new file mode 100644 index 0000000..79946ff --- /dev/null +++ b/emacs/personal-lisp/custom-funcs.el @@ -0,0 +1,127 @@ + +;; see transparancy in init.el +(defun toggle-frame-transparency () + "Toggle transparency." + (interactive) + (let ((alpha-transparency 90)) + (if (eq alpha-transparency (frame-parameter nil 'alpha-background)) + (set-frame-parameter nil 'alpha-background 100) + (set-frame-parameter nil 'alpha-background alpha-transparency)))) + +(defun wrap-region-paren () + "Wraps the region in parens. +Similar to pressing ( with the region active." + (interactive) + (let ((beg (region-beginning)) + (end (region-end))) + (save-excursion + (goto-char beg) + (insert "(") + (goto-char (+ end 1)) + (insert ")") + ))) + +(defun zap-whitespace () + "zaps the whitespace around the point in both directions" + (interactive) + (push-mark) + (skip-chars-backward " \t\n") + (push-mark) + (skip-chars-forward " \t\n") + (delete-region (mark) (point)) + (pop-mark) + (goto-char (mark)) + (pop-mark)) + +(defun wrap-sexp (&optional arg) + "Wraps the following sexp in a pair of parens. +Places inside the new pair, with prefix arg do the same backwards, pushing the +mark. Does the same of ARG number sexps if given" + (interactive "P") + (message "%s" arg) + (if arg + (progn + (push-mark) + (insert-pair -1 ?\( ?\))) + (insert-pair 1 ?\( ?\)))) + +(defun close-or-kill () + "If this is the sole frame, kill emacs. Otherwise close the frame." + (interactive) + (if (eq 1 (length (frame-list))) + ;; sole frame, exit + (save-buffers-kill-terminal) + (delete-frame))) + +;; indent code when pasting, from +;; https://trey-jackson.blogspot.com/2008/03/emacs-tip-15-indent-yanked-code.html + +;; automatically indenting yanked text if in programming-modes +(defvar yank-indent-modes '(emacs-lisp-mode + c-mode c++-mode + tcl-mode sql-mode + perl-mode cperl-mode + java-mode jde-mode + lisp-interaction-mode + LaTeX-mode TeX-mode + rust-mode + rustic-mode) + "Modes in which to indent regions that are yanked (or yank-popped).") + +(defun yank-advised-indent-function (beg end) + "Do indentation, as long as the region isn't too large. +BEG and END define the region." + (indent-region beg end nil)) + +(defadvice yank (after yank-indent activate) + "If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)." + (if (and (not (ad-get-arg 0)) + (member major-mode yank-indent-modes)) + (let ((transient-mark-mode nil)) + (yank-advised-indent-function (region-beginning) (region-end))))) + +(defadvice yank-pop (after yank-pop-indent activate) + "If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)." + (if (and (not (ad-get-arg 0)) + (member major-mode yank-indent-modes)) + (let ((transient-mark-mode nil)) + (yank-advised-indent-function (region-beginning) (region-end))))) + +(defadvice evil-paste-before (after yank-indent activate) + "If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)." + (if (and (not (ad-get-arg 0)) + (member major-mode yank-indent-modes)) + (let ((transient-mark-mode nil)) + (yank-advised-indent-function (region-beginning) (region-end))))) + +(defadvice evil-paste-after (after yank-indent activate) + "If current mode is one of 'yank-indent-modes, indent yanked text (with prefix arg don't indent)." + (if (and (not (ad-get-arg 0)) + (member major-mode yank-indent-modes)) + (let ((transient-mark-mode nil)) + (yank-advised-indent-function (region-beginning) (region-end))))) + +(defun fold-this-fold-forward (&optional arg) + "Fold forward ARG number of sexps, defaulting to one." + (interactive "p") + (push-mark) + (forward-sexp arg) + (fold-this (mark) (point)) + (pop-mark)) + +(defun fold-this-fold-backward (&optional arg) + "Fold backward ARG number of sexps, defaulting to one." + (interactive "p") + (push-mark) + (backward-sexp arg) + (fold-this (point) (mark)) + (pop-mark)) + +(defun clean-prog-file (buffer) + "Fixes whitespace in buffer" + (save-excursion + (with-current-buffer buffer + (untabify (point-min) (point-max)) + (goto-char (point-min)) + (while (re-search-forward " +$" nil t) + (replace-match "" nil nil))))) diff --git a/emacs/personal-lisp/evil-conf.el b/emacs/personal-lisp/evil-conf.el new file mode 100644 index 0000000..7c389fe --- /dev/null +++ b/emacs/personal-lisp/evil-conf.el @@ -0,0 +1,69 @@ + +;; evil mode stuff +(setq + evil-want-keybinding nil + evil-want-integration t) +;; evil-want-C-d-scroll nil +;; evil-want-C-w-delete nil +;; evil-disable-insert-state-bindings t +;; evil-respect-visual-line-mode t +(require 'evil) +(when (require 'evil-collection nil t) + (evil-collection-init)) +(evil-mode 1) +(evilem-default-keybindings "SPC") +(define-key evil-motion-state-map (kbd "TAB") 'indent-for-tab-command) +(evil-set-initial-state 'vterm-mode 'emacs) +(use-package evil-surround + :ensure t + :config + (global-evil-surround-mode 1)) +(use-package evil-snipe + :ensure t + :config + (evil-snipe-mode +1) + (evil-snipe-override-mode +1) + (setq evil-snipe-scope 'buffer) + (evil-define-key 'visual evil-snipe-local-mode-map "z" 'evil-snipe-s) + (evil-define-key 'visual evil-snipe-local-mode-map "Z" 'evil-snipe-S)) +(define-key evil-insert-state-map (kbd "C-d") 'delete-char) +(define-key evil-insert-state-map (kbd "C-e") 'move-end-of-line) +(define-key evil-insert-state-map (kbd "C-a") 'move-beginning-of-line) +(define-key evil-normal-state-map (kbd "M-.") 'xref-find-definitions) +(define-key evil-normal-state-map (kbd "C-t") 'transpose-chars) +(define-key evil-normal-state-map (kbd "M-Z") 'suspend-frame) + +;;; sasha bindings +(defun evil-window-split-and-switch () + "Split the window vertically and switch to the new buffer." + (interactive) + (evil-window-split) + (other-window 1)) + +(defun evil-window-vsplit-and-switch () + "Split the window horizontally and switch to the new buffer." + (interactive) + (evil-window-vsplit) + (other-window 1)) + +(evil-define-key 'normal global-map (kbd "SPC i") 'imenu) +(evil-define-key 'normal global-map (kbd "SPC RET") 'vterm) +(evil-define-key 'normal global-map (kbd "SPC v") 'vterm) +(evil-define-key 'normal global-map (kbd "SPC !") 'abort-recursive-edit) +(evil-define-key 'normal global-map (kbd "SPC f f") 'find-file) + +(evil-define-key 'normal global-map (kbd "SPC SPC SPC j") 'evil-window-split-and-switch) +(evil-define-key 'normal global-map (kbd "SPC SPC SPC k") 'evil-window-split-and-switch) +(evil-define-key 'normal global-map (kbd "SPC SPC SPC h") 'evil-window-vsplit-and-switch) +(evil-define-key 'normal global-map (kbd "SPC SPC SPC l") 'evil-window-vsplit-and-switch) +(evil-define-key 'normal global-map (kbd "SPC SPC h") 'evil-window-left) +(evil-define-key 'normal global-map (kbd "SPC SPC j") 'evil-window-down) +(evil-define-key 'normal global-map (kbd "SPC SPC k") 'evil-window-up) +(evil-define-key 'normal global-map (kbd "SPC SPC l") 'evil-window-right) +(evil-define-key 'normal global-map (kbd "SPC SPC w") 'delete-window) +(evil-define-key 'normal global-map (kbd "SPC SPC q") 'delete-window) +(evil-define-key 'normal global-map (kbd "SPC SPC b") 'balance-windows) +(evil-define-key 'normal global-map (kbd "SPC s s") 'save-buffer) +(evil-define-key 'normal global-map (kbd "SPC s f") 'counsel-find-file) +(evil-define-key 'normal global-map (kbd "SPC s r") 'counsel-rg) +(evil-define-key 'normal global-map (kbd "SPC ;") 'frog-jump-buffer) diff --git a/emacs/personal-lisp/general-text.el b/emacs/personal-lisp/general-text.el new file mode 100644 index 0000000..bea3fc9 --- /dev/null +++ b/emacs/personal-lisp/general-text.el @@ -0,0 +1,23 @@ +;; General stuff for editing all text, but particularly prose + +;; spelling +(require 'spell-fu) +(setq ispell-personal-dictionary "/home/tmu/.aspell.en.pws") +(add-hook 'text-mode-hook (lambda () (spell-fu-mode 1))) + +;; dictionaries +(define-prefix-command 'dict-map) +(global-set-key (kbd "M-l") 'dict-map) +(define-keymap :full nil + :parent nil + :suppress nil + :keymap nil + :name "dict-map" + :prefix 'dict-map + (kbd "w") 'sdcv-search-input + (kbd "c") (lambda () (interactive) + (activate-input-method 'pyim) + (sdcv-search-input (read-from-minibuffer "Chinese Word: " + nil nil nil + nil nil t)) + (activate-input-method nil))) diff --git a/emacs/personal-lisp/single-header.el b/emacs/personal-lisp/single-header.el new file mode 100755 index 0000000..5ca4afc --- /dev/null +++ b/emacs/personal-lisp/single-header.el @@ -0,0 +1,131 @@ +(defvar single-header--current-header-buffer nil "Read the name") + +(defvar single-header-format '(make-header-info-string) "evaluated to fill the header") + +(defface single-header '((default . (:background "#000000" :family "Source Code Pro"))) "Face for top line") + +(require 'battery) +(defun with-face (str &rest face-plist) + (add-face-text-property 0 (length str) face-plist t str) + str) + +;; disable normal emms-state and move it to the header +;; (require 'emms-state) +;; (setq single-header-emms-state-format-string +;; '(emms-state +;; (" " emms-state +;; (emms-state-current-playing-time +;; (" " +;; (:propertize emms-state-current-playing-time +;; face emms-state-current-playing-time))) +;; (emms-state-total-playing-time +;; ("(" +;; (:propertize emms-state-total-playing-time +;; face emms-state-total-playing-time) +;; ")")) +;; emms-mode-line-string))) +;; (setq emms-state-mode-line-string "") + +(defun make-header-info-string () + "generates the mode line string that contains all the info to the right" + (let ((win (when (buffer-live-p single-header--current-header-buffer) + (get-buffer-window single-header--current-header-buffer))) + (str (concat + (format-time-string "%a, %b %+4Y-%0m-%0d ") + (with-face (format-time-string "%R ") + :weight 'bold) + (with-face (format "<%03.2f> " (car (load-average 1))) + :foreground "#da70d6") + (with-face (let* ((mi (memory-info)) + (tm (float (car mi))) + (fm (float (car (cdr mi)))) + (ts (float (car (cdr (cdr mi))))) + (fs (float (car (cdr (cdr (cdr mi))))))) + (format "{%.2f %.2f} " (- 1 (/ fm tm)) (- 1 (/ fs ts)))) + :foreground "#00ced1") + (with-face (battery-format "[%b%p%%] " (and battery-status-function (funcall battery-status-function))) + :weight 'bold) + ;; (format-mode-line single-header-emms-state-format-string) + ))) + (setq str (concat str + (cond (win (make-string + (- (window-max-chars-per-line win 'single-header) (length str)) ? )) + (t "")) + )) + (with-face str 'single-header))) + + +(setq global-mode-string '("" (:eval (concat (with-face (format " [%s] " default-directory) + :weight 'bold + :foreground "green2"))))) + +(defun single-header-init-buffer (buf) + (with-current-buffer buf + (insert "header test") + (jit-lock-mode nil) + (font-lock-mode -1) + (buffer-disable-undo) + (setq-local mode-line-format nil) + (setq-local header-line-format nil) + (setq-local cursor-type nil) + (setq-local cursor-in-non-selected-windows nil) + (setq-local overflow-newline-into-fringe nil) + (setq-local word-wrap nil) + (setq-local show-trailing-whitespace nil))) + +(defun single-header-init-window (win) + (with-selected-window win + (set-window-dedicated-p win t) + (set-window-parameter win 'no-other-window t) + (set-window-parameter win 'no-delete-other-windows t) + (set-window-margins win 0 0) + (set-window-fringes win 0 0) + (set-window-scroll-bars win 0 nil 0 nil) + (setq-local window-min-height 1) + (setq-local window-safe-min-height 1) + (let + (window-size-fixed) + (fit-window-to-buffer win 1)) + (setq-local window-size-fixed t) + (when + (fboundp 'window-preserve-size) + (window-preserve-size win nil t)))) + +(defun single-header-show (buf) + "show / make a header" + (if (buffer-live-p buf) + (let ((win (display-buffer-in-side-window buf '((side . top) + (slot . -100))))) + (single-header-init-window win)) + (single-header-make))) + +(defun single-header-make () + "create the fake header line" + (interactive) + (unless (buffer-live-p single-header--current-header-buffer) + (let ((buf (generate-new-buffer "*header*"))) + (single-header-init-buffer buf) + (setq single-header--current-header-buffer buf) + (single-header-show buf)))) + +(defun single-header-delete () + "remove an existing header buffer" + (interactive) + (when (buffer-live-p single-header--current-header-buffer) + (kill-buffer single-header--current-header-buffer))) + +(defun single-header-update () + "update the contents of the header line according to `single-header-format'" + (when (buffer-live-p single-header--current-header-buffer) + (with-current-buffer single-header--current-header-buffer + (erase-buffer) + (insert (eval single-header-format))))) + +(add-hook 'after-make-frame-functions (lambda (frame) + (with-selected-frame frame + (single-header-show single-header--current-header-buffer)))) + +;; do init frame seperately +(single-header-show single-header--current-header-buffer) +(run-with-timer 0 1 'single-header-update) + diff --git a/emacs/personal-lisp/tex-conf.el b/emacs/personal-lisp/tex-conf.el new file mode 100644 index 0000000..4592ce5 --- /dev/null +++ b/emacs/personal-lisp/tex-conf.el @@ -0,0 +1,47 @@ +;; latex stuff +(require 'tex-mode) +(define-key latex-mode-map (kbd "C-c m") (lambda () (interactive) + (push-mark) + (insert "\\[\n\n\\]") + (indent-region (mark) (point)) + (pop-mark) + (previous-line) + (indent-for-tab-command) + )) + +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;;;;;;;;;;;;;;;; LaTeX ;;;;;;;;;;;;;;;;; +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; ##### Don't forget to configure +;; ##### Okular to use emacs in +;; ##### "Configuration/Configure Okular/Editor" +;; ##### => Editor => Emacsclient. (you should see +;; ##### emacsclient -a emacs --no-wait +%l %f +;; ##### in the field "Command". + +(add-hook 'LaTeX-mode-hook 'turn-on-reftex) +(setq reftex-plug-into-AUCTeX t) + +;; ##### Always ask for the master file +;; ##### when creating a new TeX file. +(setq-default TeX-master nil) + +;; ##### Enable synctex correlation. From Okular just press +;; ##### Shift + Left click to go to the good line. +(setq TeX-source-correlate-mode t + TeX-source-correlate-start-server t) + +;; ### Set Okular as the default PDF viewer. +(eval-after-load "tex" + '(setcar (cdr (assoc 'output-pdf TeX-view-program-selection)) "Okular")) + +(add-hook 'tex-mode-hook (lambda () + (setq spell-fu-faces-exclude + '(tex-math + font-lock-builtin-face + font-lock-keyword-face + font-lock-function-name-face + font-lock-variable-name-face + font-latex-sedate-face)) + (outline-minor-mode 1))) diff --git a/emacs/personal-lisp/tmu-custom-theme.el b/emacs/personal-lisp/tmu-custom-theme.el new file mode 100755 index 0000000..37032e6 --- /dev/null +++ b/emacs/personal-lisp/tmu-custom-theme.el @@ -0,0 +1,64 @@ +(deftheme tmu-custom + "Created 2023-01-06.") + +(custom-theme-set-faces + 'tmu-custom + '(cursor ((((background light)) (:background "black")) (((background dark)) (:background "white")))) + '(fixed-pitch ((t (:family "Monospace")))) + '(variable-pitch ((((type w32)) (:foundry "outline" :family "Arial")) (t (:family "Sans Serif")))) + '(escape-glyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown")))) + '(homoglyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown")))) + '(minibuffer-prompt ((t (:weight bold :box (:line-width (1 . -1) :color "red" :style released-button) :foreground "white smoke" :background "royal blue")))) + '(highlight ((t (:background "gray30")))) + '(region ((t (:extend t :background "SeaGreen4")))) + '(shadow ((((class color grayscale) (min-colors 88) (background light)) (:foreground "grey50")) (((class color grayscale) (min-colors 88) (background dark)) (:foreground "grey70")) (((class color) (min-colors 8) (background light)) (:foreground "green")) (((class color) (min-colors 8) (background dark)) (:foreground "yellow")))) + '(secondary-selection ((t (:extend t :foreground "#f6f3e8" :background "#333366")))) + '(trailing-whitespace ((((class color) (background light)) (:background "red1")) (((class color) (background dark)) (:background "red1")) (t (:inverse-video t)))) + '(font-lock-bracket-face ((t (:inherit (font-lock-punctuation-face))))) + '(font-lock-builtin-face ((t (:foreground "chartreuse2")))) + '(font-lock-comment-delimiter-face ((default (:inherit (font-lock-comment-face))))) + '(font-lock-comment-face ((t (:foreground "orchid2")))) + '(font-lock-constant-face ((t (:foreground "maroon1")))) + '(font-lock-delimiter-face ((t (:inherit (font-lock-punctuation-face))))) + '(font-lock-doc-face ((t (:foreground "indian red")))) + '(font-lock-doc-markup-face ((t (:inherit (font-lock-constant-face))))) + '(font-lock-escape-face ((t (:inherit (font-lock-regexp-grouping-backslash))))) + '(font-lock-function-name-face ((t (:foreground "spring green")))) + '(font-lock-keyword-face ((t (:weight bold :foreground "light sea green")))) + '(font-lock-negation-char-face ((t nil))) + '(font-lock-number-face ((t nil))) + '(font-lock-misc-punctuation-face ((t (:inherit (font-lock-punctuation-face))))) + '(font-lock-operator-face ((t nil))) + '(font-lock-preprocessor-face ((t (:foreground "cornflower blue")))) + '(font-lock-property-face ((t (:inherit (font-lock-variable-name-face))))) + '(font-lock-punctuation-face ((t nil))) + '(font-lock-regexp-grouping-backslash ((t (:inherit (bold))))) + '(font-lock-regexp-grouping-construct ((t (:inherit (bold))))) + '(font-lock-string-face ((t (:foreground "Skyblue1")))) + '(font-lock-type-face ((t (:foreground "medium purple")))) + '(font-lock-variable-name-face ((t (:foreground "PaleGreen2")))) + '(font-lock-warning-face ((t (:weight bold :foreground "hot pink")))) + '(button ((t (:inherit (link))))) + '(link ((((class color) (min-colors 88) (background light)) (:underline (:color foreground-color :style line :position nil) :foreground "RoyalBlue3")) (((class color) (background light)) (:underline (:color foreground-color :style line :position nil) :foreground "blue")) (((class color) (min-colors 88) (background dark)) (:underline (:color foreground-color :style line :position nil) :foreground "cyan1")) (((class color) (background dark)) (:underline (:color foreground-color :style line :position nil) :foreground "cyan")) (t (:inherit (underline))))) + '(link-visited ((default (:inherit (link))) (((class color) (background light)) (:foreground "magenta4")) (((class color) (background dark)) (:foreground "violet")))) + '(fringe ((((class color) (background light)) (:background "grey95")) (((class color) (background dark)) (:background "grey10")) (t (:background "gray")))) + '(header-line ((t (:inherit mode-line)))) + '(tooltip ((((class color)) (:inherit (variable-pitch) :foreground "black" :background "lightyellow")) (t (:inherit (variable-pitch))))) + '(mode-line ((t (:background "black" :family "DejaVu Sans")))) + '(mode-line-buffer-id ((t (:weight bold)))) + '(mode-line-emphasis ((t (:weight bold)))) + '(mode-line-highlight ((((supports :box t) (class color) (min-colors 88)) (:box (:line-width (2 . 2) :color "grey40" :style released-button))) (t (:inherit (highlight))))) + '(mode-line-inactive ((t (:inherit mode-line :foreground "dark gray")))) + '(isearch ((((class color) (min-colors 88) (background light)) (:foreground "lightskyblue1" :background "magenta3")) (((class color) (min-colors 88) (background dark)) (:foreground "brown4" :background "palevioletred2")) (((class color) (min-colors 16)) (:foreground "cyan1" :background "magenta4")) (((class color) (min-colors 8)) (:foreground "cyan1" :background "magenta4")) (t (:inverse-video t)))) + '(isearch-fail ((((class color) (min-colors 88) (background light)) (:background "RosyBrown1")) (((class color) (min-colors 88) (background dark)) (:background "red4")) (((class color) (min-colors 16)) (:background "red")) (((class color) (min-colors 8)) (:background "red")) (((class color grayscale)) (:foreground "grey")) (t (:inverse-video t)))) + '(lazy-highlight ((((class color) (min-colors 88) (background light)) (:distant-foreground "black" :background "paleturquoise")) (((class color) (min-colors 88) (background dark)) (:distant-foreground "white" :background "paleturquoise4")) (((class color) (min-colors 16)) (:distant-foreground "white" :background "turquoise3")) (((class color) (min-colors 8)) (:distant-foreground "white" :background "turquoise3")) (t (:underline (:color foreground-color :style line :position nil))))) + '(match ((((class color) (min-colors 88) (background light)) (:background "khaki1")) (((class color) (min-colors 88) (background dark)) (:background "RoyalBlue3")) (((class color) (min-colors 8) (background light)) (:foreground "black" :background "yellow")) (((class color) (min-colors 8) (background dark)) (:foreground "white" :background "blue")) (((type tty) (class mono)) (:inverse-video t)) (t (:background "gray")))) + '(next-error ((t (:inherit (region))))) + '(query-replace ((t (:inherit (isearch))))) + '(default ((t (:family "Source Code Pro" :foundry "ADBO" :width normal :height 98 :weight regular :slant normal :underline nil :overline nil :extend nil :strike-through nil :box nil :inverse-video nil :foreground "white smoke" :background "gray10" :stipple nil :inherit nil)))) + '(frog-menu-posframe-background-face ((t (:background "RoyalBlue4")))) + '(minibuffer-prompt ((t (:background "gray10" :foreground "cyan" :box nil :weight bold)))) + '(pyim-page ((t (:inherit default :background "#333333" :foreground "#dcdccc")))) + '(vterm-color-blue ((t (:inherit ansi-color-bright-green))))) + +(provide-theme 'tmu-custom) |
