From ff199d7afe570d3e6f98e603302827a4b8b3237c Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Wed, 19 Oct 2022 23:49:40 +0800 Subject: [PATCH] add mwim --- .gitmodules | 3 +++ init.el | 23 ++++++++++++----------- lisp/init-built-in.el | 3 --- lisp/init-edit.el | 7 +++++++ lisp/init-git.el | 1 + lisp/init-theme.el | 23 +++++++++++++++++++++++ site-lisp/mwim | 1 + 7 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 lisp/init-theme.el create mode 160000 site-lisp/mwim diff --git a/.gitmodules b/.gitmodules index b7ccee5..fceb92d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ [submodule "site-lisp/symbol-overlay"] path = site-lisp/symbol-overlay url = https://github.com/wolray/symbol-overlay.git +[submodule "site-lisp/mwim"] + path = site-lisp/mwim + url = https://github.com/alezost/mwim.el.git diff --git a/init.el b/init.el index 218f519..cec4bf9 100644 --- a/init.el +++ b/init.el @@ -1,37 +1,37 @@ ;; -*- coding: utf-8; lexical-binding: t; -*- -(defvar creature-gc-cons-threshold +(defvar creature/gc-cons-threshold (if (display-graphic-p) (* 64 1024 1024) (* 16 1024 1024)) "The default value to use for `gc-cons-threshold'. If freezing sometimes, decrease it. If stuttering, increase it.") -(defvar creature-gc-cons-upper-limit +(defvar creature/gc-cons-upper-limit (if (display-graphic-p) (* 512 1024 1024) (* 128 1024 1024)) "The temporary value for `gc-cons-threshold' to defer it.") -(defvar creature-gc-timer (run-with-idle-timer 10 t #'garbage-collect) +(defvar creature/gc-timer (run-with-idle-timer 10 t #'garbage-collect) "Run garbage collection when idle 10s.") (defvar default-file-name-handler-alist file-name-handler-alist "Temporary `file-name-handler-alist' for restore after startup.") ;; Speed up startup -(defun creature-enlarge-gc-cons-threshold () +(defun creature/enlarge-gc-cons-threshold () "Enlarge garbage collection threshold." (setq gc-cons-percentage 0.6 - gc-cons-threshold creature-gc-cons-upper-limit)) + gc-cons-threshold creature/gc-cons-upper-limit)) -(defun creature-normalize-gc-cons-threshold () +(defun creature/normalize-gc-cons-threshold () "Normalize garbage collection threshold." (setq gc-cons-percentage 0.1 - gc-cons-threshold creature-gc-cons-threshold)) + gc-cons-threshold creature/gc-cons-threshold)) -(creature-enlarge-gc-cons-threshold) +(creature/enlarge-gc-cons-threshold) (setq file-name-handler-alist nil) (add-hook 'emacs-startup-hook (lambda () - (creature-normalize-gc-cons-threshold) + (creature/normalize-gc-cons-threshold) (setq file-name-handler-alist default-file-name-handler-alist) (setq read-process-output-max (* 1024 1024)) @@ -45,9 +45,9 @@ If freezing sometimes, decrease it. If stuttering, increase it.") ;; Avoid GC while minibuffer active. (add-hook 'minibuffer-setup-hook - #'creature-enlarge-gc-cons-threshold) + #'creature/enlarge-gc-cons-threshold) (add-hook 'minibuffer-exit-hook - #'creature-normalize-gc-cons-threshold))) + #'creature/normalize-gc-cons-threshold))) (defconst creature/config-dir (file-name-directory @@ -101,6 +101,7 @@ If freezing sometimes, decrease it. If stuttering, increase it.") (require 'init-built-in) (require 'init-git) (require 'init-edit) +(require 'init-theme) (require 'which-key) (setq which-key-show-early-on-C-h t) diff --git a/lisp/init-built-in.el b/lisp/init-built-in.el index a289ccb..e9beb6a 100644 --- a/lisp/init-built-in.el +++ b/lisp/init-built-in.el @@ -27,9 +27,6 @@ ;; Highlight trail whitespace (setq show-trailing-whitespace t) -(global-whitespace-mode 1) - - ;; Save minibuffer history (savehist-mode) (setq history-length 1000 diff --git a/lisp/init-edit.el b/lisp/init-edit.el index 45fa466..c58c873 100644 --- a/lisp/init-edit.el +++ b/lisp/init-edit.el @@ -1,4 +1,5 @@ ;; -*- coding: utf-8; lexical-binding: t; -*- + (require 'lazy-load) ;;; symbol-overlay-map @@ -19,4 +20,10 @@ "symbol-overlay") +;;; mwim +(lazy-load-global-keys + '(("C-a" . mwim-beginning-of-code-or-line) + ("C-e" . mwim-end-of-code-or-line)) + "mwim") + (provide 'init-edit) diff --git a/lisp/init-git.el b/lisp/init-git.el index 31afa34..4ea60c5 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -1,4 +1,5 @@ ;; -*- coding: utf-8; lexical-binding: t; -*- + (require 'lazy-load) (lazy-load-global-keys '(("C-x g" . magit-status)) diff --git a/lisp/init-theme.el b/lisp/init-theme.el new file mode 100644 index 0000000..24f138c --- /dev/null +++ b/lisp/init-theme.el @@ -0,0 +1,23 @@ +;; -*- coding: utf-8; lexical-binding: t; -*- + +;; Pulse +(defvar creature/pulse-enable t + "Whether enable pulse for scroll and switch window.") + +(defun creature/pulse-line (&rest _) + "Pulse the current line." + (when creature/pulse-enable + (pulse-momentary-highlight-one-line (point)))) + +;; pulse setup, like beacon +(with-eval-after-load 'pulse + (setq pulse-delay 0.04)) + +(dolist (command '(scroll-up + scroll-down + recenter)) + (advice-add command :after #'creature/pulse-line)) +(add-to-list 'window-selection-change-functions #'creature/pulse-line) + + +(provide 'init-theme) diff --git a/site-lisp/mwim b/site-lisp/mwim new file mode 160000 index 0000000..b4f3edb --- /dev/null +++ b/site-lisp/mwim @@ -0,0 +1 @@ +Subproject commit b4f3edb4c0fb8f8b71cecbf8095c2c25a8ffbf85