summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-01-24 01:43:50 +0800
committerJSDurand <mmemmew@gmail.com>2022-01-24 01:43:50 +0800
commit3f70a8d1fbc048bf88abd996547d19a15a0006e7 (patch)
tree7551262e23c94cdede742c3f49d84ff5d9bc868a
parent316bc0fd14404ecafbb8e8b0f1e9d366f2833197 (diff)
Cleanup init file
Add short-cuts to conveniently load some frequently used configurations. I used to load those configurations only through manual invocations of custom functions. Now I got tired of this practice. So I add some convenient lazy loading to save me some trouble.
-rw-r--r--init.el120
1 files changed, 76 insertions, 44 deletions
diff --git a/init.el b/init.el
index 8f2b8c1..fac7f99 100644
--- a/init.el
+++ b/init.el
@@ -72,6 +72,7 @@ then FUNCTION-NAME will be defined as DEF after loading.
If FUNCTION-NAME is already a valid function, this advices the
function instead of redefining the function, and REDEFINE-P has
no effect."
+ (declare (indent 2))
(cond
((fboundp function-name)
`(let ((advice-symbol (intern
@@ -110,14 +111,20 @@ no effect."
(load-config "modeline.el")
+;;; Prepare for ELisp
+
(add-hook 'emacs-lisp-mode-hook
(lambda () (set 'mode-name "ELisp")))
(prepare-in-hook-once prepare-elisp emacs-lisp-mode-hook "elisp.el")
+(prepare-in-hook-once prepare-skeleton emacs-lisp-mode-hook "skeleton-conf.el")
+
+;;; Prepare for C
+
(prepare-in-hook-once prepare-c c-mode-hook "c-conf.el")
-(prepare-in-hook-once prepare-skeleton emacs-lisp-mode-hook "skeleton-conf.el")
+;;; Prepare for Org
(prepare-in-hook-once prepare-org org-mode-hook "org-conf.el")
@@ -127,31 +134,29 @@ no effect."
(define-key global-map (vector 3 99) #'prepare-org)
(define-key global-map (vector 3 ?l) #'prepare-org)
-;;;###autoload
-(load-after-function durand-battery "battery-conf.el" "Display battery information." nil
- (display-battery-mode 1))
-
-;;;###autoload
-(load-after-function durand-time "time-conf.el" "Display time information." nil
- (display-time-mode 1))
+;;; Prepare for mu4e
-;;;###autoload
(load-after-function durand-mu4e "mail.el" "Open mu4e." t (mu4e))
(define-key global-map (vector 3 109) #'durand-mu4e)
+;;; Prepare for PDF
+
(add-to-list 'auto-mode-alist (cons "pdf$" #'pdf-view-mode))
-;;;###autoload
-(load-after-function prepare-skeletons "skeleton-conf.el" "Load skeletons." nil)
+(load-after-function pdf-view-mode "pdf.el"
+ "Fake mode that loads the pacakge." nil (pdf-view-mode))
-;;;###autoload
-(load-after-function pdf-view-mode "pdf.el" "Fake mode that loads the pacakge." nil
- (pdf-view-mode))
+;;; Prepare for skeletons
+
+(load-after-function prepare-skeletons "skeleton-conf.el"
+ "Load skeletons." nil)
+
+;;; Prepare for GLSL
;;;###autoload
-(load-after-function glsl-mode "glsl-conf.el" "Fake mode that loads the package." nil
- (glsl-mode))
+(load-after-function glsl-mode "glsl-conf.el"
+ "Fake mode that loads the package." nil (glsl-mode))
(add-to-list 'auto-mode-alist (cons "\\.frag$" #'glsl-mode))
(add-to-list 'auto-mode-alist (cons "\\.vert$" #'glsl-mode))
@@ -187,13 +192,13 @@ no effect."
;;; outline
(load-after-function durand-maybe-enable-outline "outline-conf.el"
- "Load my outline configurations" nil)
+ "Load my outline configurations" nil)
;;; bongo
;;;###autoload
-(load-after-function bongo "bongo.el" "Listen to music in Emacs." nil
- (bongo))
+(load-after-function bongo "bongo.el"
+ "Listen to music in Emacs." nil (bongo))
;;; My PDF facilities
@@ -223,8 +228,8 @@ no effect."
;;; gnus
-(load-after-function gnus "gnus-conf.el" "Fake function to load gnus." nil
- (gnus))
+(load-after-function gnus "gnus-conf.el"
+ "Fake function to load gnus." nil (gnus))
(define-key global-map (vector 3 ?g) #'gnus)
(define-key global-map (vector ?\H-g) #'gnus)
@@ -258,9 +263,9 @@ no effect."
;;; Eshell
-(load-after-function eshell "eshell-conf.el" "Load Eshell and launch it." nil
- (eshell)
- (eshell-start-track-command-time))
+(load-after-function eshell "eshell-conf.el"
+ "Load Eshell and launch it." nil
+ (eshell) (eshell-start-track-command-time))
;;; tab configurations
@@ -280,15 +285,15 @@ no effect."
;;; elfeed
-(load-after-function elfeed "elfeed-conf.el" "Load elfeed and launch it." nil
- (elfeed))
+(load-after-function elfeed "elfeed-conf.el"
+ "Load elfeed and launch it." nil (elfeed))
(define-key global-map (vector 3 101) #'elfeed)
;;; rime configuration to input Chinese.
-(load-after-function prepare-rime "rime-conf.el" "Load rime and launch it." nil
- (durand-set-input-method))
+(load-after-function prepare-rime "rime-conf.el"
+ "Load rime and launch it." nil (durand-set-input-method))
;; The effect of super is to apply bitwise or to the key with
;; (ash 1 23). The codes are as follows.
@@ -303,23 +308,16 @@ no effect."
;;; magit
-(load-after-function magit "magit-conf.el" "Load magit and launch it." nil
- (defalias 'magit 'magit-status)
- (magit))
+(load-after-function magit "magit-conf.el"
+ "Load magit and launch it." nil
+ (defalias 'magit 'magit-status)
+ (magit))
(define-key global-map (vector ?\C-x ?g) 'magit)
;;; eww
-(load-after-function
- eww "eww-conf.el" "Load eww and launch it." nil
- (apply #'eww
- (let* ((uris (eww-suggested-uris))
- (prompt (concat "Enter URL or keywords"
- (if uris (format " (default %s)" (car uris)) "")
- ": ")))
- (list (read-string prompt nil 'eww-prompt-history uris)
- (prefix-numeric-value current-prefix-arg)))))
+(load-after-function eww "eww-conf.el" "Load eww and launch it." nil)
(define-key global-map (vector 3 ?v ?w) #'eww)
(define-key global-map (vector ?\s-w) #'eww)
@@ -328,9 +326,23 @@ no effect."
(load-config "view-conf.el")
+;;; Prepare battery
+
+(load-after-function durand-battery "battery-conf.el"
+ "Display battery information." nil (display-battery-mode 1))
+
+(define-key durand-view-map (vector ?b) #'durand-battery)
+
+;;;###autoload
+(load-after-function durand-time "time-conf.el"
+ "Display time information." nil (display-time-mode 1))
+
+(define-key durand-view-map (vector ?T) #'durand-time)
+
;;; flymake
(prepare-in-hook-once prepare-flymake prog-mode-hook "flymake-conf.el")
+
(define-key global-map (vector ?\s-m) #'prepare-flymake)
;;; Don't let s-q quit as I oft press that by accident.
@@ -358,10 +370,8 @@ no effect."
;;; Go-mode
-(load-after-function
- go-mode "go-conf.el"
- "Load Go-mode configurations and lauch it." nil
- (go-mode))
+(load-after-function go-mode "go-conf.el"
+ "Load Go-mode configurations and lauch it." nil (go-mode))
(cond
((assoc "\\.go$" auto-mode-alist #'string=)
@@ -375,12 +385,34 @@ no effect."
(cond ((display-mouse-p) (mouse-avoidance-mode 'cat-and-mouse)))
+;;; Bookmark conf
+
+(load-after-function blist "bookmark-conf.el"
+ "Load my configurations for bookmarks and list bookmarks." nil
+ (blist))
+
+(define-key ctl-x-r-map (vector ?l) #'blist)
+
+;;; Wifi and Bluetooth stuff
+
+(load-after-function durand-prepare-wifi-bluetooth
+ "wifi-bluetooth-conf.el"
+ "Load my configurations to manipulate Wifi and Bluetooth status."
+ nil)
+
+(define-key global-map (vector 3 ?w ?w) #'durand-prepare-wifi-bluetooth)
+(define-key global-map (vector 3 ?w ?b) #'durand-prepare-wifi-bluetooth)
+(define-key global-map (vector 3 ?w ?l) #'durand-prepare-wifi-bluetooth)
+(define-key global-map (vector 3 ?w ?j) #'durand-prepare-wifi-bluetooth)
+
;;; server
;; (cond
;; ((bound-and-true-p server-process))
;; ((server-start)))
+;;; Reset the garbage collection threshold
+
(setq gc-cons-threshold (* 2 1024 1024))
(provide 'init)