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.

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