(Emacs/config|init)~cut my init time to just a second
I had a problem with after-init-hook which would (while supposedly keeping (emacs-init-time) under 1.2 seconds) take ages to start emacs just due to how many things were starting up using it. So I removed all the after-init-hook functions and instead aggressively demand the stuff I need and defer everything else through ":defer", ":after", ":hook" and ":general". Happy to say my boot time is now actually 1.2 seconds without compilation.
This commit is contained in:
@@ -313,31 +313,32 @@ simplicity is above all.
|
|||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(setq-default
|
(setq-default
|
||||||
mode-line-format
|
mode-line-format
|
||||||
(list
|
'("%l:%c " ;; Line and column
|
||||||
"%l:%c " ;; Line and column
|
"%p[" ;; %into file
|
||||||
"%p[" ;; %into file
|
(:eval (with-eval-after-load "evil" ;; Evil state
|
||||||
'(:eval (with-eval-after-load "evil" ;; Evil state
|
|
||||||
(upcase
|
(upcase
|
||||||
(substring
|
(substring
|
||||||
(format "%s" (if (bound-and-true-p evil-state)
|
(format "%s" (if (bound-and-true-p evil-state)
|
||||||
evil-state
|
evil-state
|
||||||
" "))
|
" "))
|
||||||
0 1))))
|
0 1))))
|
||||||
"] "
|
"] "
|
||||||
"%+%b(" ;; Buffer name
|
"%+"
|
||||||
'(:eval (format "%s" major-mode))
|
(-12 "%b")
|
||||||
") "
|
"(" ;; Buffer name
|
||||||
"%I " ;; file size
|
(:eval (format "%s" major-mode))
|
||||||
'(:eval (if (project-current)
|
") "
|
||||||
|
"%I " ;; file size
|
||||||
|
(:eval (if (project-current)
|
||||||
(project-name (project-current))))
|
(project-name (project-current))))
|
||||||
'(vc-mode vc-mode) ;; git branch
|
(vc-mode vc-mode) ;; git branch
|
||||||
" "
|
" "
|
||||||
'(:eval
|
(:eval
|
||||||
(with-eval-after-load "eglot"
|
(with-eval-after-load "eglot"
|
||||||
(if eglot--managed-mode
|
(if eglot--managed-mode
|
||||||
(eglot--mode-line-format))))
|
(eglot--mode-line-format))))
|
||||||
mode-line-misc-info
|
mode-line-misc-info
|
||||||
mode-line-end-spaces))
|
mode-line-end-spaces))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Mouse
|
** Mouse
|
||||||
Who uses a mouse? 🤮
|
Who uses a mouse? 🤮
|
||||||
@@ -492,6 +493,7 @@ Some bindings that I couldn't fit elsewhere easily.
|
|||||||
(file-leader
|
(file-leader
|
||||||
"f" #'find-file
|
"f" #'find-file
|
||||||
"F" #'find-file-other-window
|
"F" #'find-file-other-window
|
||||||
|
"t" #'find-file-other-tab
|
||||||
"s" #'save-buffer)
|
"s" #'save-buffer)
|
||||||
|
|
||||||
(buffer-leader
|
(buffer-leader
|
||||||
@@ -1624,31 +1626,14 @@ engine, which makes sense as it's primarily a text interface.
|
|||||||
:defer t
|
:defer t
|
||||||
:general
|
:general
|
||||||
(app-leader
|
(app-leader
|
||||||
"ww" #'eww
|
"w" #'eww)
|
||||||
"wb" #'+eww/bookmarks-search
|
|
||||||
"we" #'+eww/bookmarks-edit)
|
|
||||||
(nmmap
|
(nmmap
|
||||||
:keymaps 'eww-mode-map
|
:keymaps 'eww-mode-map
|
||||||
"w" #'evil-forward-word-begin
|
"w" #'evil-forward-word-begin
|
||||||
"Y" #'shr-probe-and-copy-url)
|
"Y" #'shr-probe-and-copy-url)
|
||||||
:config
|
:config
|
||||||
(with-eval-after-load "evil-collection"
|
(with-eval-after-load "evil-collection"
|
||||||
(evil-collection-eww-setup))
|
(evil-collection-eww-setup)))
|
||||||
(defun bookmark->alist (bookmark)
|
|
||||||
(cons (plist-get bookmark :title)
|
|
||||||
(plist-get bookmark :url)))
|
|
||||||
(defun +eww/bookmarks-edit nil
|
|
||||||
(interactive)
|
|
||||||
(find-file (concat eww-bookmarks-directory "eww-bookmarks")))
|
|
||||||
(defun +eww/bookmarks-search nil
|
|
||||||
(interactive)
|
|
||||||
(let ((bookmarks (mapcar #'bookmark->alist eww-bookmarks)))
|
|
||||||
(eww
|
|
||||||
(alist-get (completing-read "Bookmark: " (mapcar #'car bookmarks) nil t)
|
|
||||||
bookmarks
|
|
||||||
nil
|
|
||||||
nil
|
|
||||||
#'string=)))))
|
|
||||||
#+end_src
|
#+end_src
|
||||||
** Calendar
|
** Calendar
|
||||||
Calendar is a simple inbuilt application that helps with date
|
Calendar is a simple inbuilt application that helps with date
|
||||||
@@ -3098,45 +3083,46 @@ The default ~imenu~ support for Org-mode is god-awful. ~Imenu~ for
|
|||||||
org-mode should show me a list of headings and provide a
|
org-mode should show me a list of headings and provide a
|
||||||
completing-read interface to search them.
|
completing-read interface to search them.
|
||||||
|
|
||||||
[[file:core.org::*Counsel][Counsel]] has me covered for this as I can
|
[[*Counsel][Counsel]] has me covered for this as I can just provide it
|
||||||
just provide it a regex as an initial prompt to narrow the candidates
|
a regex as an initial prompt to narrow the candidates down to just the
|
||||||
down to just the headings then let the user go from there. I use
|
headings then let the user go from there. I use ~swiper~ when
|
||||||
~swiper~ when considering just the local file (a la ~imenu~) and
|
considering just the local file (a la ~imenu~) and ~counsel-rg~ to
|
||||||
~counsel-rg~ to search multiple org-files.
|
search multiple org-files.
|
||||||
|
|
||||||
The cherry on top is ~+org/search-config-headings~ which searches the
|
The cherry on top is ~+org/search-config-headings~ which searches the
|
||||||
org files in ~user-emacs-directory~ and provides the headings for
|
org files in ~user-emacs-directory~ and provides the headings for
|
||||||
them. This allows me to search my configuration pretty quickly.
|
them. This allows me to search my configuration pretty quickly.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package org
|
(with-eval-after-load "counsel"
|
||||||
:straight t
|
(use-package org
|
||||||
:after counsel
|
:straight t
|
||||||
:config
|
:defer t
|
||||||
(defun +org/swiper-goto ()
|
:config
|
||||||
(interactive)
|
(defun +org/swiper-goto ()
|
||||||
(swiper "^\\* "))
|
(interactive)
|
||||||
|
(swiper "^\\* "))
|
||||||
|
|
||||||
(defun +org/search-headings ()
|
(defun +org/search-headings ()
|
||||||
"Searches directory (of buffer) for org headings via counsel-rg"
|
"Searches directory (of buffer) for org headings via counsel-rg"
|
||||||
(interactive)
|
(interactive)
|
||||||
(counsel-rg "^\\* " (file-name-directory (buffer-file-name))))
|
(counsel-rg "^\\* " (file-name-directory (buffer-file-name))))
|
||||||
|
|
||||||
(defun +org/search-config-headings ()
|
(defun +org/search-config-headings ()
|
||||||
"Searches USER-EMACS-DIRECTORY for org headings via counsel-rg"
|
"Searches USER-EMACS-DIRECTORY for org headings via counsel-rg"
|
||||||
(interactive)
|
(interactive)
|
||||||
(counsel-rg "^\\* "
|
(counsel-rg "^\\* "
|
||||||
(substring user-emacs-directory 0
|
(substring user-emacs-directory 0
|
||||||
(- (length user-emacs-directory) 1))
|
(- (length user-emacs-directory) 1))
|
||||||
"--max-depth=1"))
|
"--max-depth=1"))
|
||||||
:general
|
:general
|
||||||
(file-leader
|
(file-leader
|
||||||
"p" #'+org/search-config-headings)
|
"p" #'+org/search-config-headings)
|
||||||
(search-leader
|
(search-leader
|
||||||
:keymaps 'org-mode-map
|
:keymaps 'org-mode-map
|
||||||
"I" #'+org/search-headings)
|
"I" #'+org/search-headings)
|
||||||
(nmmap
|
(nmmap
|
||||||
:keymaps 'org-mode-map
|
:keymaps 'org-mode-map
|
||||||
[remap imenu] #'+org/swiper-goto))
|
[remap imenu] #'+org/swiper-goto)))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Org Agenda
|
** Org Agenda
|
||||||
Org agenda provides a nice viewing for schedules. With org mode it's
|
Org agenda provides a nice viewing for schedules. With org mode it's
|
||||||
@@ -3308,7 +3294,11 @@ Evil org for some nice bindings.
|
|||||||
(use-package evil-org
|
(use-package evil-org
|
||||||
:straight t
|
:straight t
|
||||||
:defer t
|
:defer t
|
||||||
:hook (org-mode-hook . evil-org-mode))
|
:hook (org-mode-hook . evil-org-mode)
|
||||||
|
:general
|
||||||
|
(nmmap
|
||||||
|
:keymaps 'org-mode-map
|
||||||
|
"TAB" #'org-cycle))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Org reveal
|
** Org reveal
|
||||||
Org reveal allows one to export org files as HTML presentations via
|
Org reveal allows one to export org files as HTML presentations via
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
;; possible.
|
;; possible.
|
||||||
(let ((gc-cons-threshold most-positive-fixnum))
|
(let ((gc-cons-threshold most-positive-fixnum))
|
||||||
;; Straight
|
;; Straight
|
||||||
|
(setq straight-disable-native-compile nil
|
||||||
|
straight-use-package-by-default nil
|
||||||
|
straight-check-for-modifications 'live)
|
||||||
|
|
||||||
(defvar bootstrap-version)
|
(defvar bootstrap-version)
|
||||||
(let ((bootstrap-file
|
(let ((bootstrap-file
|
||||||
(expand-file-name
|
(expand-file-name
|
||||||
@@ -43,9 +47,7 @@
|
|||||||
(eval-print-last-sexp)))
|
(eval-print-last-sexp)))
|
||||||
(load bootstrap-file nil 'nomessage))
|
(load bootstrap-file nil 'nomessage))
|
||||||
|
|
||||||
(setq straight-disable-native-compile nil
|
(setq use-package-enable-imenu-support t
|
||||||
straight-use-package-by-default t
|
|
||||||
use-package-enable-imenu-support t
|
|
||||||
use-package-always-demand nil
|
use-package-always-demand nil
|
||||||
use-package-always-defer nil
|
use-package-always-defer nil
|
||||||
use-package-hook-name-suffix nil
|
use-package-hook-name-suffix nil
|
||||||
@@ -74,6 +76,8 @@
|
|||||||
(when (daemonp)
|
(when (daemonp)
|
||||||
(require 'general)
|
(require 'general)
|
||||||
(require 'evil)
|
(require 'evil)
|
||||||
|
(require 'ivy)
|
||||||
|
(require 'counsel)
|
||||||
(require 'notmuch)
|
(require 'notmuch)
|
||||||
(require 'company)
|
(require 'company)
|
||||||
(require 'org)
|
(require 'org)
|
||||||
|
|||||||
Reference in New Issue
Block a user