summaryrefslogtreecommitdiff
path: root/init.el
diff options
context:
space:
mode:
Diffstat (limited to 'init.el')
-rw-r--r--init.el92
1 files changed, 67 insertions, 25 deletions
diff --git a/init.el b/init.el
index 2cd1ac7..253fbf8 100644
--- a/init.el
+++ b/init.el
@@ -1,10 +1,28 @@
-;;; -*- lexical-binding: t; -*-
+;;; init.el --- My configurations for GNU Emacs -*- lexical-binding: t; -*-
-;;; garbage collection threshold maneuvre
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+
+;;; Code:
+
+;; Garbage collection threshold maneuvre
(setq gc-cons-threshold (* 512 1024 1024))
-;;; tell me the start time at start-up
+;;; Tell me the start time at start-up
;;;###autoload
(defun message-start-time ()
@@ -19,11 +37,14 @@
;;;###autoload
(defvar load-file-directory (cond ((stringp load-file-name) (file-name-directory load-file-name))
(t default-directory))
- "The directory to load files")
+ "The directory to load files.")
+
+;; If this is a `defmacro', then the start time will be very long...
;;;###autoload
(defsubst load-config (file-name)
- "Conviently load configuration files in the same directory as this file."
+ "Conviently load configuration file FILE-NAME in the same \
+directory as `load-file-directory'."
(load-file (expand-file-name file-name load-file-directory)))
;;;###autoload
@@ -33,7 +54,7 @@
;;;###autoload
(defmacro prepare-in-hook-once (entry-name hook file)
- "Define a function called ENTRY-NAME that loads FILE in HOOK once."
+ "Define a function called ENTRY-NAME to load FILE in HOOK once."
`(progn
(defun ,entry-name ()
(interactive)
@@ -45,17 +66,28 @@
(defmacro load-after-function (function-name file-path doc redefine-p &rest def)
"Load FILE-PATH after FUNCTION-NAME.
After loading, execute DEF.
-Finally if REDEFINE-P is non-nil,
+Finally if REDEFINE-P is non-nil,
then FUNCTION-NAME will be defined as DEF after loading.
-If FUNCTION-NAME is already a valid function, this won't do anything."
+If FUNCTION-NAME is already a valid function, this advices the
+function instead of redefining the function, and REDEFINE-P has
+no effect."
(cond
- ((fboundp function-name))
- (t
- `(defun ,function-name ()
+ ((fboundp function-name)
+ `(let ((advice-symbol (intern
+ (format "%s-advice"
+ (symbol-name ',function-name)))))
+ (defalias advice-symbol
+ (lambda (&rest _args)
+ ,(format "Advice for %s.\nThis is generated by `load-after-function'." function-name)
+ (advice-remove ',function-name advice-symbol)
+ (load-file (expand-file-name ,file-path load-file-directory))
+ ,@def))
+ (advice-add ',function-name :after advice-symbol)))
+ (`(defun ,function-name ()
,doc
(interactive)
- (load-config ,file-path)
+ (load-file (expand-file-name ,file-path load-file-directory))
,@def
,(cond
(redefine-p
@@ -134,17 +166,13 @@ If FUNCTION-NAME is already a valid function, this won't do anything."
;;; gnus
-(load-config "gnus-conf.el")
-
-;;; comb
+(load-after-function gnus "gnus-conf.el" "Fake function to load gnus." nil
+ (gnus))
-;; (load-config "comb/comb.el")
-;; (load-config "comb/comb-annotation.el")
+(define-key global-map (vector 3 ?g) #'gnus)
;;; Completion framework configurations
-;; TODO: Write my own completion styles library
-;; (load-config "comb/orderless-conf.el")
(load-config "completion-conf.el")
;;; dired configurations
@@ -152,13 +180,27 @@ If FUNCTION-NAME is already a valid function, this won't do anything."
(prepare-in-hook-once prepare-dired dired-mode-hook "dired-conf.el")
(add-hook 'dired-mode-hook 'dired-hide-details-mode)
+;;; Registers
+
+(use-package "rlist" 'rlist
+ (define-key global-map (vector ?\C-x ?r ?L) #'rlist-list-registers)
+ (setq rlist-expert t))
+
;;; ibuffer
(load-config "ibuffer.el")
-;;; center buffer
+;;; Olivetti mode
+
+(use-package "olivetti" 'olivetti
+ (durand-hide-minor-mode olivetti-mode olivetti " Oli")
+ (setq-default olivetti-body-width 80))
+;; (load-config "center-buffer.el")
+
+;;; Eshell
-(load-config "center-buffer.el")
+(load-after-function eshell "eshell-conf.el" "Load Eshell and launch it." nil
+ (eshell))
;;; tab configurations
@@ -172,10 +214,6 @@ If FUNCTION-NAME is already a valid function, this won't do anything."
(prepare-in-hook-once prepare-text text-mode-hook "text-conf.el")
-;;; embark
-
-;; (load-config "embark-conf.el")
-
;;; magit
(load-after-function magit "magit-conf.el" "Load magit and launch it." nil
@@ -224,3 +262,7 @@ If FUNCTION-NAME is already a valid function, this won't do anything."
;; ((server-start)))
(setq gc-cons-threshold (* 2 1024 1024))
+
+(provide 'init)
+
+;;; init.el ends here