My attempt to optimize my emacs load time <1 second
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

912 lines
31 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. ;;; 08-custom-packages --- Provide all the use-package declarations
  2. ;;; Commentary:
  3. ;;
  4. ;; See https://github.com/jwiegley/use-package for help
  5. ;; USE PACKAGE help
  6. ;; (use-package package-here
  7. ;; :commands (cmd cmd-all cmd-etc) ;; List commands used to ":defer" the package
  8. ;; :bind-keymap
  9. ;; ("M-q" . package-here-keymap) ;; Setup an entire keymap using Prefix "M-q"
  10. ;; :bind
  11. ;; (("M-s" . cmd) ;; Available Globally
  12. ;; :map here-mode-map
  13. ;; ("C-t" . cmd-all) ;; Available only in "here-mode"
  14. ;; ("C-e" . cmd-etc)) ;; Available only in "here-mode"
  15. ;; :init
  16. ;; (setq stuff t) ;; declar vars etc...
  17. ;; :config
  18. ;; (here-mode 1) ;; eval stuff here after the init
  19. ;;
  20. ;; (use-package ruby-mode
  21. ;; :mode "\\.rb\\'"
  22. ;; :interpreter "ruby"
  23. ;;
  24. ;; ;; OR when the package name isn't the same as the =mode=
  25. ;; (use-package python
  26. ;; :mode ("\\.py\\'" . python-mode)
  27. ;; :interpreter ("python" . python-mode))
  28. ;;
  29. ;; USE ":defer" when you aren't using either :commands, :bind, :bind*, :bind-keymap, :bind-keymap*, :mode, :interpreter, or :hook
  30. ;; (use-package deferred-package
  31. ;; :defer t)
  32. ;;; Code:
  33. (use-package use-package-ensure-system-package
  34. :defer t)
  35. ;; https://github.com/emacs-dashboard/emacs-dashboard
  36. (use-package dashboard
  37. :ensure t
  38. :init
  39. (setq dashboard-items '((recents . 10)
  40. (bookmarks . 10)
  41. (agenda . 3)
  42. (projects . 5)
  43. ))
  44. (setq dashboard-center-content t)
  45. (setq dashboard-banner-logo-title "Let's do this...")
  46. (setq dashboard-startup-banner 1)
  47. (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
  48. ;; (setq dashboard-show-shortcuts t)
  49. ;; (setq show-week-agenda-p t)
  50. ;; (setq dashboard-org-agenda-categories '("eaglecrk"))
  51. (dashboard-setup-startup-hook))
  52. (use-package ag
  53. :if (eq system-type 'gnu/linux)
  54. :commands ag
  55. :ensure-system-package
  56. ("/usr/bin/ag" . "sudo apt install silversearcher-ag"))
  57. ;; https://melpa.org/#/async
  58. (use-package async
  59. :disabled
  60. :commands (async-start async-start-process))
  61. ;; https://github.com/myrjola/diminish.el
  62. (use-package diminish
  63. :ensure t)
  64. ;; https://elpa.gnu.org/packages/delight.html
  65. (use-package delight
  66. :ensure t)
  67. ;; https://github.com/winterTTr/ace-jump-mode
  68. (use-package ace-jump-mode
  69. :disabled
  70. :bind
  71. (("C-c SPC" . just-one-space)
  72. ("M-SPC" . ace-jump-mode)))
  73. ;; https://github.com/jacktasia/dumb-jump
  74. (use-package dumb-jump
  75. :disabled
  76. :hook js-mode
  77. :bind (
  78. ("M-." . dumb-jump-go)
  79. ("M-," . dumb-jump-back)
  80. ("M->" . dumb-jump-quick-look)
  81. )
  82. :config
  83. (setq dumb-jump-selector 'ivy)
  84. (setq dumb-jump-force-searcher 'rg))
  85. ;; https://github.com/NicolasPetton/zerodark-theme
  86. (use-package zerodark-theme
  87. :demand t
  88. :init
  89. (setq max-specpdl-size 3000)
  90. (setq max-lisp-eval-depth 3000)
  91. :config
  92. (load-theme 'zerodark t)
  93. (zerodark-setup-modeline-format))
  94. ;; ;; https://github.com/belak/base16-emacs
  95. ;; (use-package base16-theme
  96. ;; :disabled
  97. ;; :config
  98. ;; (load-theme 'base16-tomorrow t))
  99. ;; https://github.com/Malabarba/beacon
  100. (use-package beacon
  101. :disabled
  102. :commands beacon-mode
  103. :diminish
  104. :init
  105. (setq beacon-size 70
  106. beacon-color "#5B6268"
  107. beacon-blink-delay 0.1
  108. beacon-blink-duration 0.4
  109. beacon-blink-when-focused t)
  110. (beacon-mode 1))
  111. ;; https://github.com/iqbalansari/emacs-emojify
  112. (use-package emojify
  113. :disabled
  114. :defer 25
  115. :config
  116. (global-emojify-mode 1))
  117. ;; https://github.com/hrs/engine-mode
  118. (use-package engine-mode
  119. :commands (engine/get-query engine/execute-search)
  120. :config
  121. ;; C-x / to start
  122. (defengine google "https://www.google.com/search?q=%s"
  123. :keybinding "a")
  124. (defengine github "https://github.com/search?q=%s"
  125. :keybinding "g")
  126. (defengine vlocity "https://success.vlocity.com/s/searchunifylightning?searchString=%s"
  127. :keybinding "v")
  128. (defengine duckduckgo "https://duckduckgo.com/?q=%s"
  129. :keybinding "d")
  130. (defengine melpa "https://melpa.org/#/?q=%s"
  131. :keybinding "m")
  132. (engine-mode 1))
  133. ;; Calendars integration via built-in Diary mode - independent of Org-mode
  134. (setq diary-file "~/.emacs.d/diary/diary"
  135. diary-location "~/.emacs.d/diary/")
  136. ;; calendars you want to download
  137. ;; each item links to a remote iCal calendar
  138. (setq calendars
  139. '(("calendar" . "https://outlook.office365.com/owa/calendar/e5ed2f2ca7cc4e1d9a79a936cb5f57d5@eaglecrk.com/59b7a490c28447108f632f56b83123645556575710540309817/calendar.ics")
  140. ))
  141. (defun getcal (url file)
  142. "Download ics file and add it to file"
  143. (let ((tmpfile (url-file-local-copy url)))
  144. (icalendar-import-file tmpfile file)
  145. (kill-buffer (car (last (split-string tmpfile "/"))))))
  146. (defun getcals ()
  147. "Load a set of ICS calendars into Emacs diary files"
  148. (interactive)
  149. (mapcar #'(lambda (x)
  150. (let ((file (concat diary-location (car x)))
  151. (url (cdr x)))
  152. (message (concat "Loading " url " into " file))
  153. (find-file file)
  154. ;; (flush-lines "^[& ]") ;; if you import ical as non marking
  155. (erase-buffer) ;; to avoid duplicating events
  156. (getcal url file)
  157. ))
  158. calendars)
  159. (message "Retrieved Calendar"))
  160. ;; import the ical calendar files into one file that Emacs diary and calendar can properly work with
  161. ;;(icalendar-import-file "~/emacs.d/diary/calendar.ics"
  162. ;; "~/emacs.d/diary/diary")
  163. ;; Fetch some better view of the calendars
  164. (add-hook 'diary-list-entries-hook 'diary-sort-entries t)
  165. (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
  166. (add-hook 'diary-mark-entries-hook 'diary-mark-included-diary-files)
  167. ;; (add-hook 'org-agenda-cleanup-fancy-diary-hook 'getcals)
  168. ;; https://github.com/Fanael/rainbow-delimiters
  169. (use-package rainbow-delimiters
  170. :hook (prog-mode . rainbow-delimiters-mode))
  171. ;; rainbow-mode
  172. (use-package rainbow-mode
  173. :hook prog-mode)
  174. ;; M-x all-the-icons-install-fonts
  175. (use-package all-the-icons
  176. :demand t
  177. :config
  178. (setq inhibit-compacting-font-caches t))
  179. (use-package amx
  180. :commands amx-mode)
  181. ;; https://github.com/abo-abo/swiper
  182. (use-package counsel
  183. :bind
  184. ("M-x" . counsel-M-x)
  185. ("C-c k" . counsel-rg)
  186. ("C-x C-f" . counsel-find-file)
  187. ("C-x f" . counsel-recentf)
  188. ("C-x C-d" . counsel-dired)
  189. ("C-x p" . counsel-package)
  190. ("C-x b" . counsel-bookmark)
  191. ("C-x c" . counsel-colors-web)
  192. ("C-c C-d" . counsel-org-capture)
  193. ;; Describe Replacements
  194. ("C-h f" . counsel-describe-function)
  195. ("C-h v" . counsel-describe-variable)
  196. ("C-h b" . counsel-descbinds)
  197. ("M-y" . counsel-yank-pop)
  198. ;; Ivy
  199. ("C-c b" . ivy-switch-buffer)
  200. ("C-c c" . ivy-resume)
  201. ;; Swiper
  202. ("C-s" . swiper)
  203. :config
  204. (ivy-mode 1)
  205. (amx-mode 1)
  206. )
  207. ;; https://github.com/magnars/expand-region.el
  208. (use-package expand-region
  209. :bind
  210. ("C-@" . er/expand-region)
  211. ("C-#" . er/contract-region))
  212. ;; https://github.com/thanhvg/emacs-howdoyou
  213. (use-package howdoyou
  214. :bind
  215. ("C-c h q" . howdoyou-query)
  216. ("C-c h n" . howdoyou-next-link)
  217. ("C-c h p" . howdoyou-previous-link)
  218. ("C-c h f" . howdoyou-go-back-to-first-link)
  219. ("C-c h r" . howdoyou-reload-link))
  220. (use-package counsel-web
  221. :ensure t)
  222. (defun my/howdoyou-with-suggestions ()
  223. "Call `howdoyou-query' with suggestions from `counsel-web-suggest'."
  224. (interactive)
  225. (counsel-web-suggest nil
  226. "How Do You: "
  227. #'counsel-web-suggest--google
  228. (lambda (x)
  229. (howdoyou-query x))))
  230. ;; https://github.com/magnars/multiple-cursors.el
  231. (use-package multiple-cursors
  232. :bind
  233. ("C-}" . mc/mark-next-like-this)
  234. ("C-)" . mc/unmark-next-like-this)
  235. ("C-{" . mc/mark-previous-like-this)
  236. ("C-(" . mc/unmark-previous-like-this))
  237. ;; https://github.com/skeeto/elfeed
  238. (use-package elfeed
  239. :bind
  240. ("C-x C-l e" . elfeed)
  241. (:map elfeed-search-mode-map
  242. ("a" . (lambda () (interactive) (elfeed-search-set-filter "")))
  243. ("e" . (lambda () (interactive) (elfeed-search-set-filter "+emacs")))
  244. ("x" . (lambda () (interactive) (elfeed-search-set-filter "xkcd")))
  245. ("=" . elfeed-search-set-filter))
  246. :init
  247. (setq elfeed-feeds
  248. '(
  249. ("https://insideevs.com/rss/make/tesla/" news tesla ev)
  250. ("https://insideevs.com/rss/make/rivian/" news rivian ev)
  251. ("https://insideevs.com/rss/category/battery-tech/" news battery ev)
  252. ("https://www.google.com/alerts/feeds/13353713273807811484/17577790586956417498" news google cybertruck tesla ev)
  253. ("https://www.google.com/alerts/feeds/13353713273807811484/2710948715805064535" news google tesla ev)
  254. ("https://www.google.com/alerts/feeds/13353713273807811484/17638090915837343269" news google pixel4)
  255. ("https://teslapodcast.libsyn.com/rss" podcast tesla ev)
  256. ("http://feeds.twit.tv/sn.xml" podcast security twit)
  257. ("https://feeds.fireside.fm/linuxunplugged/rss" podcast linux)
  258. ("https://latenightlinux.com/feed/all" podcast linux)
  259. ("https://www.youtube.com/feeds/videos.xml?channel_id=UCbgBDBrwsikmtoLqtpc59Bw" youtube 3dp)
  260. ("http://www.reddit.com/r/emacs/.rss" emacs)
  261. ("http://telescoper.wordpress.com/feed/" daily)
  262. ("http://xkcd.com/rss.xml" daily)
  263. ("http://pragmaticemacs.com/feed/" emacs)
  264. ("http://endlessparentheses.com/atom.xml" emacs)
  265. ("http://feeds.feedburner.com/XahsEmacsBlog" emacs)
  266. ("http://emacs.stackexchange.com/feeds" emacs)
  267. ))
  268. :config
  269. (defun yt-dl-it (url)
  270. "Downloads the URL in an async shell"
  271. (let ((default-directory "~/Videos"))
  272. (async-shell-command (format "youtube-dl %s" url))))
  273. (defun elfeed-youtube-dl (&optional use-generic-p)
  274. "Youtube-DL link"
  275. (interactive "P")
  276. (let ((entries (elfeed-search-selected)))
  277. (cl-loop for entry in entries
  278. do (elfeed-untag entry 'unread)
  279. when (elfeed-entry-link entry)
  280. do (yt-dl-it it))
  281. (mapc #'elfeed-search-update-entry entries)
  282. (unless (use-region-p) (forward-line))))
  283. (define-key elfeed-search-mode-map (kbd "d") 'elfeed-youtube-dl)
  284. (elfeed-update))
  285. ;; https://github.com/rmuslimov/browse-at-remote
  286. (use-package browse-at-remote
  287. :bind ("C-c B" . browse-at-remote))
  288. ;; https://github.com/justbur/emacs-which-key
  289. (use-package which-key
  290. :diminish
  291. :defer 5
  292. :config
  293. (which-key-setup-minibuffer)
  294. (which-key-mode))
  295. ;; https://github.com/lewang/fic-mode
  296. (use-package fic-mode
  297. ;; :hook (prog-mode js-mode)
  298. :custom-face
  299. (fic-face ((t :foreground "red" :weight bold)))
  300. (fic-author-face ((t :foreground "red" :underline t))))
  301. ;; https://github.com/joaotavora/yasnippet
  302. (use-package yasnippet
  303. :commands yas-reload-all
  304. :hook (prog-mode . yas-minor-mode)
  305. :init
  306. (setq yas-snippet-dirs (list (concat user-emacs-directory "snippets")))
  307. :config
  308. (yas-reload-all))
  309. ;; https://company-mode.github.io/
  310. (use-package company
  311. :defer 25
  312. :commands company-mode
  313. :hook (
  314. (prog-mode . company-mode)
  315. (ledger-mode . company-mode)
  316. )
  317. :bind
  318. (:map company-active-map
  319. ("M-n" . nil)
  320. ("M-p" . nil)
  321. ("C-n" . company-select-next)
  322. ("C-p" . company-select-previous))
  323. :config
  324. (setq company-idle-delay 0.1)
  325. (setq company-minimum-prefix-length 3)
  326. (setq company-dabbrev-downcase nil))
  327. ;; https://github.com/pashky/restclient.el
  328. (use-package restclient
  329. :mode ("\\.rest\\'" . restclient-mode))
  330. ;; https://github.com/iquiw/company-restclient
  331. (use-package company-restclient
  332. :after (company restclient))
  333. ;; https://github.com/magit/magit
  334. (use-package magit
  335. :bind
  336. ("C-x g" . magit-status)
  337. ("C-c g" . magit-status))
  338. ;; This is used in `rg-menu'
  339. (use-package rg
  340. :defer t)
  341. ;; This is used in `projectile'
  342. (use-package ripgrep
  343. :commands rg-project)
  344. ;; https://github.com/bbatsov/projectile
  345. (use-package projectile
  346. :delight '(:eval (concat " [" (projectile-project-name) "]"))
  347. :bind (
  348. ("C-c p" . projectile-command-map)
  349. :map projectile-command-map
  350. ("s r" . rg-project)
  351. )
  352. :init
  353. (setq projectile-completion-system 'ivy)
  354. :config
  355. (projectile-mode 1))
  356. ;; https://github.com/ledger/ledger-mode
  357. (use-package ledger-mode
  358. :disabled
  359. :mode ("\\.dat\\'" "\\.ledger\\'")
  360. :bind
  361. (("C-x C-l l" . (lambda () (interactive) (find-file "~/Documents/finance-records/ledger.dat")))
  362. :map ledger-mode-map
  363. ("M-q" . leo/kill-this-buffer-unless-scratch)
  364. ("C-<tab>" . ledger-mode-clean-buffer)
  365. ("<backtab>" . ledger-post-align-dwim)
  366. )
  367. :hook
  368. (ledger-mode . (lambda ()
  369. (setq tab-always-indent 'complete)
  370. (setq-local completion-cycle-threshold t)
  371. (setq-local ledger-complete-in-steps t)
  372. ))
  373. )
  374. ;; https://github.com/magit/git-modes
  375. (use-package gitignore-mode
  376. :mode ("\\.gitignore\\'"))
  377. ;; https://github.com/magit/git-modes
  378. (use-package gitconfig-mode
  379. :mode ("\\.gitconfig\\'"))
  380. ;; http://web-mode.org/
  381. (use-package web-mode
  382. :hook (html-mode nxml-mode))
  383. ;; JAVASCRIPT SECTION
  384. (use-package lsp-mode
  385. :straight (:host github :repo "emacs-lsp/lsp-mode" :branch "master")
  386. ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
  387. :init (setq lsp-keymap-prefix "C-c l")
  388. :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
  389. (js-mode . lsp)
  390. (css-mode . lsp)
  391. (yaml-mode . lsp)
  392. ;; if you want which-key integration
  393. (lsp-mode . lsp-enable-which-key-integration))
  394. :bind
  395. (
  396. :map js-mode-map
  397. ("M-." . lsp-find-definition)
  398. )
  399. :commands lsp)
  400. (use-package lsp-ui
  401. :straight (:host github :repo "emacs-lsp/lsp-ui" :branch "master")
  402. :commands lsp-ui-mode)
  403. (use-package company-lsp
  404. :straight (:host github :repo "tigersoldier/company-lsp" :branch "master")
  405. :commands company-lsp)
  406. (use-package lsp-ivy
  407. :straight (:host github :repo "emacs-lsp/lsp-ivy" :branch "master")
  408. :commands lsp-ivy-workspace-symbol)
  409. (use-package lsp-treemacs
  410. :straight (:host github :repo "emacs-lsp/lsp-treemacs" :branch "master")
  411. :commands lsp-treemacs-errors-list)
  412. (use-package js2-mode
  413. :disabled
  414. :mode ("\\.js\\'"))
  415. (use-package typescript-mode
  416. :disabled
  417. :mode ("\\.js\\'"))
  418. (use-package tide
  419. :disabled
  420. :ensure t
  421. :after (typescript-mode company flycheck)
  422. :hook ((typescript-mode . tide-setup)
  423. (typescript-mode . tide-hl-identifier-mode)
  424. (before-save . tide-format-before-save))
  425. :bind (
  426. ("M-?" . tide-references)
  427. ("M-r" . tide-rename-symbol)
  428. ("M-/" . tide-jsdoc-template)
  429. ("M-o" . tide-organize-imports)
  430. ))
  431. ;; https://github.com/smihica/emmet-mode
  432. (use-package emmet-mode
  433. :hook (html-mode web-mode css-mode))
  434. (use-package dash-at-point
  435. :if (eq system-type 'darwin)
  436. :ensure-system-package
  437. ("/Applications/Dash.app" . "brew cask install dash"))
  438. ;; https://github.com/joshwnj/json-mode
  439. (use-package json-mode
  440. :mode "\\.json\\'")
  441. ;; https://github.com/mojochao/npm-mode
  442. ;; Disabled in favor of just running npm commands in comint buffer via
  443. ;; (leo/exec-process "npm run start" "npm-start" t)
  444. (use-package npm-mode
  445. :disabled
  446. :defer 10
  447. :custom
  448. (npm-mode-command-prefix "C-c r"))
  449. ;; https://github.com/antonj/scss-mode
  450. (use-package scss-mode
  451. :mode ("\\.s?css\\'" . scss-mode))
  452. ;; https://github.com/yoshiki/yaml-mode
  453. (use-package yaml-mode
  454. :mode ("\\.ya?ml\\'" . yaml-mode))
  455. ;; https://github.com/kwrooijen/cargo.el
  456. (use-package cargo
  457. :hook (rust-mode . cargo-minor-mode))
  458. ;; https://github.com/flycheck/flycheck
  459. (use-package flycheck
  460. :diminish
  461. :preface
  462. (defvar flycheck-emacs-lisp-load-path)
  463. :init
  464. (setq flycheck-emacs-lisp-load-path 'inherit)
  465. (global-flycheck-mode))
  466. ;; Mu4e
  467. (use-package mu4e
  468. :load-path "/usr/local/share/emacs/site-lisp/mu/mu4e"
  469. :commands mu4e
  470. :bind
  471. (
  472. ("C-x C-l m" . mu4e)
  473. ;; :map mu4e-headers-mode-map
  474. )
  475. :config
  476. (setq mu4e-maildir (expand-file-name "~/Maildir")
  477. mu4e-mu-binary "/usr/local/bin/mu"
  478. mail-user-agent 'mu4e-user-agent
  479. mu4e-change-filenames-when-moving t ;; Rename files when moving (required by mbsync)
  480. mu4e-compose-in-new-frame t ;; New compose gets new frame
  481. mu4e-context-policy 'pick-first
  482. mu4e-get-mail-command "true" ; /Users/leviolson/scripts/bash/get-email.sh
  483. ;; Get mail automatically (outside emacs) via brew services
  484. ;; "mbsync -a && mu index && open bitbar://refreshPlugin?name=mail.sh"
  485. ;; MBSYNC is the mail cmd
  486. mu4e-html2text-command "/usr/local/bin/w3m -T text/html" ;; HTML to text command
  487. mu4e-headers-include-related nil ;; Stop threading in INBOX
  488. mu4e-sent-messages-behavior 'delete ;; Delete sent messages
  489. mu4e-update-interval 60 ;; 1 min
  490. mu4e-use-fancy-chars t ;; use 'fancy' chars
  491. mu4e-user-mail-address-list '("lolson@eaglecrk.com")
  492. mu4e-view-show-images t ;; attempt to show images
  493. mu4e-view-image-max-width 400 ;; max image size
  494. message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n" ;; customize the reply-quote-string
  495. message-citation-line-function 'message-insert-formatted-citation-line ;; choose to use the formatted string
  496. message-kill-buffer-on-exit t ;; don't keep messages around
  497. send-mail-function 'smtpmail-send-it ;; Default email send function
  498. smtpmail-default-smtp-server "smtp.office365.com"
  499. smtpmail-smtp-service 587
  500. )
  501. (setq mu4e-contexts
  502. `(
  503. ,(make-mu4e-context
  504. :name "EagleCreek"
  505. :enter-func (lambda () (mu4e-message "Entering EagleCreek"))
  506. :leave-func (lambda () (mu4e-message "Leaving EagleCreek"))
  507. ;; we match based on the contact-fields of the message
  508. :match-func (lambda (msg)
  509. (when msg
  510. (string= (mu4e-message-field msg :maildir) "/eaglecrk")))
  511. :vars '( ( user-mail-address . "lolson@eaglecrk.com" )
  512. ( smtpmail-mail-address . "lolson@eaglecrk.com" )
  513. ( smtpmail-smtp-user . "lolson@eaglecrk.com" )
  514. ( smtpmail-smtp-server . "smtp.office365.com" )
  515. ( user-full-name . "Levi Olson" )
  516. ( mu4e-compose-signature .
  517. (concat
  518. "Levi Olson\n"
  519. "Eagle Creek Software Services\n"
  520. "Senior Application Developer Consultant\n"))
  521. ( mu4e-sent-folder . "/eaglecrk/Sent Items" )
  522. ( mu4e-refile-folder . "/eaglecrk/Archive" )
  523. ( mu4e-drafts-folder . "/eaglecrk/Drafts" )
  524. ( mu4e-trash-folder . "/eaglecrk/Deleted Items" )
  525. ( mu4e-maildir-shortcuts . (("/eaglecrk/Inbox" . ?i)
  526. ("/eaglecrk/Sent Items" . ?s)
  527. ("/eaglecrk/Deleted Items" . ?t)
  528. ("/eaglecrk/Archive" . ?a)
  529. ))))
  530. ;; ,(make-mu4e-context
  531. ;; :name "Gmail"
  532. ;; :enter-func (lambda () (mu4e-message "Entering Gmail"))
  533. ;; :leave-func (lambda () (mu4e-message "Leaving Gmail"))
  534. ;; ;; this matches maildir /Arkham and its sub-directories
  535. ;; :match-func (lambda (msg)
  536. ;; (when msg
  537. ;; (string= (mu4e-message-field msg :maildir) "/gmail")))
  538. ;; :vars '( ( user-mail-address . "olson.levi@gmail.com" )
  539. ;; ( smtpmail-mail-address . "olson.levi@gmail.com" )
  540. ;; ( smtpmail-smtp-user . "olson.levi@gmail.com" )
  541. ;; ( smtpmail-smtp-server . "smtp.gmail.com" )
  542. ;; ( user-full-name . "Levi Olson" )
  543. ;; ( mu4e-compose-signature .
  544. ;; (concat
  545. ;; "Levi\n"))
  546. ;; ( mu4e-sent-folder . "/gmail/[Gmail]/Sent Mail" )
  547. ;; ( mu4e-refile-folder . "/gmail/[Gmail]/All Mail" )
  548. ;; ( mu4e-drafts-folder . "/gmail/[Gmail]/Drafts" )
  549. ;; ( mu4e-trash-folder . "/gmail/[Gmail]/Trash" )
  550. ;; ( mu4e-maildir-shortcuts . (("/gmail/Inbox" . ?i)
  551. ;; ("/gmail/[Gmail]/Sent Mail" . ?s)
  552. ;; ("/gmail/[Gmail]/Trash" . ?t)
  553. ;; ("/gmail/[Gmail]/All Mail" . ?a)
  554. ;; ))))
  555. ))
  556. ;; Add option to view HTML in browser
  557. (add-to-list 'mu4e-headers-actions
  558. '("in browser" . mu4e-action-view-in-browser) t)
  559. (add-to-list 'mu4e-view-actions
  560. '("in browser" . mu4e-action-view-in-browser) t)
  561. (defun my-message-current-line-cited-p ()
  562. "Indicate whether the line at point is a cited line."
  563. (save-match-data
  564. (string-match (concat "^" message-cite-prefix-regexp)
  565. (buffer-substring (line-beginning-position) (line-end-position)))))
  566. (defun my-message-says-attachment-p ()
  567. "Return t if the message suggests there can be an attachment."
  568. (save-excursion
  569. (goto-char (point-min))
  570. (save-match-data
  571. (let (search-result)
  572. (while
  573. (and (setq search-result (re-search-forward "\\(attach\\|pdf\\|file\\)" nil t))
  574. (my-message-current-line-cited-p)))
  575. search-result))))
  576. (defun my-message-has-attachment-p ()
  577. "Return t if the message has an attachment."
  578. (save-excursion
  579. (goto-char (point-min))
  580. (save-match-data
  581. (re-search-forward "<#part" nil t))))
  582. (defun my-message-pre-send-check-attachment ()
  583. (when (and (my-message-says-attachment-p)
  584. (not (my-message-has-attachment-p)))
  585. (unless
  586. (y-or-n-p "No attachment, send anyway? ")
  587. (error "It seems that an attachment is needed, but none was found. Aborting sending"))))
  588. (add-hook 'message-send-hook 'my-message-pre-send-check-attachment))
  589. ;; https://orgmode.org/elpa.html
  590. (use-package org
  591. :commands org-capture
  592. :ensure org-plus-contrib
  593. :mode ("\\.org\\'" . org-mode)
  594. :bind (
  595. ("C-," . org-cycle-agenda-files)
  596. ("C-c C-d" . org-capture)
  597. ("C-x C-l a" . org-agenda)
  598. :map org-mode-map
  599. ("M-RET" . org-insert-todo-heading)
  600. ("M-n" . leo/org-narrow-next-tree)
  601. ("M-p" . leo/org-narrow-prev-tree)
  602. ("M-P" . leo/org-present)
  603. )
  604. :preface
  605. (defvar org-html-validation-link)
  606. (defvar org-html-text-markup-alist)
  607. (defvar org-capture-templates)
  608. :init
  609. (setq org-agenda-files '("~/Org/todo.org"
  610. "~/Org/personal.org"
  611. "~/Org/archive.org"
  612. ))
  613. (setq org-agenda-include-diary t)
  614. (add-to-list 'safe-local-variable-values '(eval leo/deft-insert-boilerplate))
  615. (setq org-todo-keywords '((sequence "TODO(t)" "|" "DONE(d)")
  616. (sequence "BUG(b)" "INPROGRESS(i)" "|" "FIXED(f)")
  617. (sequence "TEST(T)" "NOTEST(N)" "|" "COMPLETE(C)")
  618. (sequence "QUESTION(Q)" "|" "ANSWERED(A)")
  619. (sequence "|" "CANCELED(c)")
  620. (sequence "|" "NEEDCLARIFICATION(n)")
  621. (sequence "|" "PROVIDEUPDATE(p)")
  622. (sequence "WAITING(w)" "|"))
  623. org-refile-targets '((nil :maxlevel . 3)
  624. (org-agenda-files :maxlevel . 3))
  625. org-directory "~/Org"
  626. org-default-notes-file (concat org-directory "/todo.org")
  627. org-src-fontify-natively t
  628. org-startup-folded t
  629. org-startup-indented t
  630. org-startup-align-all-tables t
  631. org-startup-with-inline-images t
  632. org-startup-with-latex-preview t
  633. org-src-tab-acts-natively t
  634. org-confirm-babel-evaluate nil
  635. org-log-done t
  636. org-log-done-with-time t
  637. org-log-into-drawer t
  638. org-hide-leading-stars t
  639. org-pretty-entities t
  640. org-use-property-inheritance t
  641. org-html-validation-link nil
  642. org-html-text-markup-alist '((bold . "<b>%s</b>")
  643. (code . "<code>%s</code>")
  644. (italic . "<i>%s</i>")
  645. (strike-through . "<del>%s</del>")
  646. (underline . "<span class=\"underline\">%s</span>")
  647. (verbatim . "<code class=\"verbatim\">%s</code>"))
  648. )
  649. :config
  650. (add-hook 'focus-in-hook
  651. (lambda () (progn
  652. (setq org-tags-column (- 4 (window-body-width)))) (org-align-tags t)))
  653. (add-hook 'focus-out-hook
  654. (lambda () (progn
  655. (setq org-tags-column (- 4 (window-body-width)))) (org-align-tags t)))
  656. (defun org-src-disable-flycheck-doc ()
  657. "Disable flycheck comment doc string checking when (C-c ') ing a file."
  658. (interactive)
  659. (setq flycheck-disabled-checkers '(emacs-lisp-checkdoc)))
  660. (add-to-list 'org-src-mode-hook 'org-src-disable-flycheck-doc)
  661. (when (version<= "9.2" (org-version))
  662. (require 'org-tempo))
  663. (org-babel-do-load-languages 'org-babel-load-languages '((js . t)
  664. (shell . t)
  665. (restclient . t)
  666. (emacs-lisp . t)))
  667. (setq org-capture-templates
  668. '(("t" "new task" entry (file+headline "~/Org/todo.org" "Tasks")
  669. "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
  670. ("n" "new note" entry (file+headline org-default-notes-file "Notes")
  671. "* %?\n%i\n")
  672. ("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
  673. "* %a\n%?\n")
  674. ("d" "store link w/drawer" entry (file+olp org-default-notes-file "Links" "Unfiled")
  675. "* %?\n%l\n:COPIED_TEXT:\n %i\n:END:\n")
  676. ))
  677. (setq org-structure-template-alist
  678. '(("r" . "src restclient :results raw")
  679. ("j" . "src js :cmd \"/usr/local/bin/babel-node\" :results output code")
  680. ("e" . "src emacs-lisp :results silent")
  681. ("a" . "export ascii")
  682. ("c" . "center")
  683. ("C" . "comment")
  684. ("E" . "export")
  685. ("h" . "export html")
  686. ("l" . "export latex")
  687. ("q" . "quote")
  688. ("s" . "src")
  689. ("v" . "verse")))
  690. (defconst checkbox-fontlock-keywords-alist
  691. (mapcar (lambda (regex-char-pair)
  692. `(,(car regex-char-pair)
  693. (0 (prog1 ()
  694. (compose-region (match-beginning 1)
  695. (match-end 1)
  696. ,(concat (list ?\C-i)
  697. (list (decode-char 'ucs (cadr regex-char-pair)))))))))
  698. '(("\\(\\[ \\]\\)" #XF096);2B1C
  699. ("\\(\\[-\\]\\)" #XF147);29C7;F458
  700. ("\\(\\[X\\]\\)" #XF046);2BBD
  701. )))
  702. (defun add-checkbox-symbol-keywords ()
  703. "Add checkbox font to font-lock."
  704. (font-lock-add-keywords nil checkbox-fontlock-keywords-alist))
  705. (add-hook 'org-mode-hook 'add-checkbox-symbol-keywords)
  706. )
  707. ;; https://github.com/seanohalpin/org-link-minor-mode
  708. (use-package org-link-minor-mode
  709. :straight (:host github :repo "seanohalpin/org-link-minor-mode" :branch "master")
  710. :commands org-link-minor-mode)
  711. (use-package ob-restclient
  712. :ensure t
  713. :config
  714. (setq org-babel-default-header-args:restclient
  715. `((:results . "output"))))
  716. ;; https://github.com/astahlman/ob-async
  717. ;; Run a begin_src block asynchronously via :async
  718. (use-package ob-async
  719. :disabled
  720. :ensure t
  721. :after org)
  722. ;; https://github.com/sabof/org-bullets
  723. (use-package org-bullets
  724. :hook (org-mode . org-bullets-mode)
  725. :config
  726. (setq org-bullets-bullet-list '( "" "" "" "" "" "" ""))
  727. (set-face-attribute 'org-level-1 nil :height 1.5)
  728. (set-face-attribute 'org-level-2 nil :height 1.0)
  729. (set-face-attribute 'org-level-3 nil :height 1.0)
  730. (set-face-attribute 'org-level-4 nil :height 1.0)
  731. (set-face-attribute 'org-level-5 nil :height 1.0)
  732. (set-face-attribute 'org-scheduled-today nil :height 2.0)
  733. (set-face-attribute 'org-agenda-date-today nil :height 2.0))
  734. ;; https://orgmode.org/worg/org-contrib/org-protocol.html
  735. (use-package org-protocol
  736. :ensure org-plus-contrib
  737. :after org)
  738. ;; https://github.com/marsmining/ox-twbs
  739. (use-package ox-twbs
  740. :defer 10
  741. :after org)
  742. (use-package ox-extra
  743. :defer 10
  744. :ensure org-plus-contrib
  745. :after org
  746. :config
  747. (ox-extras-activate '(ignore-headlines)))
  748. ;; https://github.com/yjwen/org-reveal
  749. (use-package ox-reveal
  750. :defer 10
  751. :after org)
  752. ;; https://github.com/jethrokuan/org-roam/
  753. (use-package org-roam
  754. :ensure t
  755. :demand t
  756. :hook
  757. (org-mode . org-roam-mode)
  758. :straight (:host github :repo "jethrokuan/org-roam" :branch "master")
  759. :config
  760. ;; (org-roam--build-cache-async)
  761. ;; (setq org-roam-graphviz-executable "/usr/local/Cellar/graphviz/2.42.2/bin/dot")
  762. ;; (setq org-roam-graph-viewer "/usr/bin/open")
  763. (setq org-roam-directory "~/Org/Roam/")
  764. (setq org-roam-link-title-format "r::%s")
  765. :bind
  766. ("C-c n l" . org-roam)
  767. ("C-c n t" . org-roam-today)
  768. ("C-c n f" . org-roam-find-file)
  769. ("C-c n i" . org-roam-insert)
  770. ("C-c n g" . org-roam-show-graph))
  771. ;; https://github.com/jrblevin/deft
  772. (use-package deft
  773. :bind
  774. ("C-c n d" . deft)
  775. :custom
  776. (deft-recursive t)
  777. (deft-use-filter-string-for-filename t)
  778. (deft-default-extension "org")
  779. (deft-directory "~/Org/Roam/"))
  780. ;; https://github.com/hniksic/emacs-htmlize
  781. (use-package htmlize
  782. :defer 10
  783. :after org)
  784. ;; https://github.com/jwiegley/use-package/blob/master/bind-key.el
  785. (use-package bind-key
  786. :bind
  787. ("C-<tab>" . leo/tidy)
  788. ("C-;" . leo/comment-or-uncomment-region-or-line)
  789. ("C-c e" . leo/find-user-init-file)
  790. ("M-q" . leo/kill-this-buffer-unless-scratch)
  791. ("C-c d" . leo/duplicate-thing)
  792. ("M-n" . leo/jump-to-next-symbol)
  793. ("M-p" . leo/jump-to-prev-symbol)
  794. ("M-u" . upcase-dwim)
  795. ("M-c" . capitalize-dwim)
  796. ("M-l" . downcase-dwim)
  797. )
  798. ;; https://github.com/nflath/sudo-edit
  799. (use-package sudo-edit
  800. :commands (sudo-edit))
  801. (provide '08-custom-packages)
  802. ;;; 08-custom-packages.el ends here