Human Readable Emacs Configuration using Org mode
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.

2042 lines
72 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
  1. ;;; -*- lexical-binding: t -*-
  2. ;;; DO NOT EDIT THIS FILE DIRECTLY
  3. ;;; EDIT ~init.org~ instead
  4. ;; (setq byte-compile-warnings nil)
  5. (defun tangle-init ()
  6. "If the current buffer is 'init.org' the code-blocks are tangled, and the tangled file is compiled."
  7. (when (equal (buffer-file-name)
  8. (expand-file-name (concat user-emacs-directory "init.org")))
  9. ;; Avoid running hooks when tangling.
  10. (let ((prog-mode-hook nil))
  11. (org-babel-tangle)
  12. (byte-compile-file (concat user-emacs-directory "init.el")))))
  13. (add-hook 'after-save-hook 'tangle-init)
  14. (require 'package)
  15. (package-initialize)
  16. (defvar my-packages
  17. '(all-the-icons
  18. amx
  19. anzu
  20. base16-theme
  21. bbdb
  22. better-defaults
  23. company
  24. company-go
  25. counsel
  26. counsel-projectile
  27. dash-at-point
  28. dashboard
  29. diminish
  30. dockerfile-mode
  31. doom-modeline
  32. doom-themes
  33. ein
  34. eldoc-eval
  35. elfeed
  36. elfeed-org
  37. elpy
  38. emmet-mode
  39. excorporate
  40. expand-region
  41. fic-mode
  42. flycheck
  43. gitignore-mode
  44. go-mode
  45. go-playground
  46. gorepl-mode
  47. iedit
  48. indium
  49. ivy
  50. ivy-hydra
  51. jabber
  52. json-mode
  53. ledger-mode
  54. magit
  55. markdown-mode
  56. material-theme
  57. multiple-cursors
  58. org-bullets
  59. org-link-minor-mode
  60. ox-reveal
  61. poporg
  62. projectile
  63. rainbow-delimiters
  64. rainbow-mode
  65. rust-mode
  66. shrink-path
  67. tide
  68. typescript-mode
  69. ;; use-package
  70. web-mode
  71. which-key))
  72. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
  73. (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/"))
  74. (when (not package-archive-contents)
  75. (package-refresh-contents))
  76. (package-initialize)
  77. (dolist (p my-packages)
  78. (when (not (package-installed-p p))
  79. (package-install p)))
  80. (server-start)
  81. (require 'better-defaults)
  82. ;; Instead of the annoying giant warning icon, just flash the modeline.
  83. ;; (this happens when you do something like C-g)
  84. (setq ring-bell-function
  85. (lambda ()
  86. (let ((orig-fg (face-foreground 'mode-line)))
  87. (set-face-foreground 'mode-line "#F2804F")
  88. (run-with-idle-timer 0.1 nil
  89. (lambda (fg) (set-face-foreground 'mode-line fg))
  90. orig-fg))))
  91. (defun set-frame-size-according-to-resolution ()
  92. "Set the Emacs window size on startup."
  93. (interactive)
  94. (if window-system
  95. (progn
  96. ;; WIDTH
  97. (if (> (x-display-pixel-width) 1280)
  98. ;; Large Screen (only show 120 cols)
  99. (add-to-list 'default-frame-alist (cons 'width 240))
  100. ;; Small Screen (fill window)
  101. (add-to-list 'default-frame-alist (cons 'width (/ (x-display-pixel-width) (frame-char-width)))))
  102. ;; HEIGHT
  103. (if (> (x-display-pixel-height) 1080)
  104. ;; Large Screen (only fill half screen)
  105. (add-to-list 'default-frame-alist (cons 'height (/ (/ (x-display-pixel-height) 2)
  106. (frame-char-height))))
  107. ;; Small Screen (fill window)
  108. (add-to-list 'default-frame-alist (cons 'height (/ (x-display-pixel-height) (frame-char-height)))))
  109. )))
  110. ;; (set-frame-size-according-to-resolution)
  111. (defun window-px-width ()
  112. "Get the width of the Emacs window in pixels."
  113. (interactive)
  114. (* (* (window-total-width) 2.874) (frame-char-width)))
  115. (defun window-px-left-pos ()
  116. "Calculate the left position of the Emacs window."
  117. (interactive)
  118. (/ (- (x-display-pixel-width) (window-px-width)) 2))
  119. ;; (add-to-list 'default-frame-alist (cons 'top 0))
  120. ;; (add-to-list 'default-frame-alist (cons 'left 1000))
  121. (put 'narrow-to-region 'disabled nil)
  122. (put 'upcase-region 'disabled nil)
  123. (put 'downcase-region 'disabled nil)
  124. (require 'dashboard)
  125. (dashboard-setup-startup-hook)
  126. ;; Set the title
  127. (setq dashboard-banner-logo-title "Let's begin...")
  128. ;; Set the banner
  129. (setq dashboard-startup-banner "~/.emacs.d/public/emacs-logo-350.png")
  130. ;; Value can be
  131. ;; 'official which displays the official emacs logo
  132. ;; 'logo which displays an alternative emacs logo
  133. ;; 1, 2 or 3 which displays one of the text banners
  134. ;; "path/to/your/image.png" which displays whatever image you would prefer
  135. ;; Content is not centered by default. To center, set
  136. (setq dashboard-center-content t)
  137. ;; To enable shortcut "jump" indicators for each section, set
  138. (setq dashboard-show-shortcuts t)
  139. (setq show-week-agenda-p t)
  140. (setq dashboard-org-agenda-categories '("work" "tasks"))
  141. (setq dashboard-items '((recents . 10)
  142. (bookmarks . 5)
  143. (projects . 5)
  144. ;; (agenda . 5)
  145. ;; (registers . 5)
  146. ))
  147. (add-to-list 'dashboard-items '(agenda) t)
  148. (defvar backup-dir (expand-file-name "~/.emacs.d/backup/"))
  149. (defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/"))
  150. (setq initial-scratch-message nil
  151. backup-directory-alist (list (cons ".*" backup-dir))
  152. auto-save-list-file-prefix autosave-dir
  153. auto-save-file-name-transforms `((".*" ,autosave-dir t)))
  154. (menu-bar-mode 0)
  155. (scroll-bar-mode 0)
  156. (tool-bar-mode 0)
  157. (setq auth-sources '("~/.authinfo.gpg"))
  158. (set-default 'truncate-lines t)
  159. (setq fill-column 80)
  160. ;; (add-hook 'text-mode-hook
  161. ;; (lambda ()
  162. ;; (when (y-or-n-p "Auto Fill mode? ")
  163. ;; (turn-on-auto-fill))))
  164. (setq whitespace-style '(face empty tabs lines-tail trailing))
  165. (global-whitespace-mode t)
  166. ;; (load-theme 'doom-city-lights t)
  167. ;; (load-theme 'doom-dracula t)
  168. ;; (load-theme 'doom-nord t)
  169. (load-theme 'doom-one t)
  170. ;; (load-theme 'doom-spacegrey t)
  171. ;; (load-theme 'base16-ocean t)
  172. (load-theme 'base16-onedark t)
  173. (global-linum-mode t)
  174. (global-auto-revert-mode t)
  175. (defalias 'yes-or-no-p 'y-or-n-p)
  176. (defvar diary-file (expand-file-name "~/.emacs.d/diary/main"))
  177. (add-hook 'diary-list-entries-hook 'diary-sort-entries t)
  178. (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
  179. (add-hook 'diary-mark-entries-hook 'diary-mark-included-diary-files)
  180. (add-hook 'calendar-today-visible-hook 'calendar-mark-today)
  181. (setq calendar-latitude 44
  182. calendar-longitude -97
  183. calendar-location-name "Hayti, SD")
  184. (require 'font-lock)
  185. (defvar openhab-mode-hook nil)
  186. (defvar openhab-mode-map
  187. (let ((map (make-keymap)))
  188. (define-key map "\C-j" 'newline-and-indent)
  189. map)
  190. "Keymap for OPENHAB major mode.")
  191. (add-to-list 'auto-mode-alist '("\\.sitemap\\'" . openhab-mode))
  192. (add-to-list 'auto-mode-alist '("\\.items\\'" . openhab-mode))
  193. (add-to-list 'auto-mode-alist '("\\.rules\\'" . openhab-mode))
  194. (add-to-list 'auto-mode-alist '("\\.things\\'" . openhab-mode))
  195. (defconst openhab-font-lock-keywords
  196. `(
  197. ("\<.*\>" . font-lock-constant-face)
  198. (,(regexp-opt
  199. '(
  200. ;; KEYWORDS
  201. "Selection" "Slider" "List" "Setpoint" "Video" "Chart" "Webview" "Colorpicker"
  202. "Timer" "Number" "String"
  203. "Switch" "Rollershutter" "Number" "String" "Dimmer" "Contact" "DateTime" "Color"
  204. "Text" "Group" "Image" "Frame"
  205. "Thing" "Bridge"
  206. "Time" "System"
  207. "sitemap"
  208. "rule" "when" "then" "end"
  209. "if" "val"
  210. "import" "var" "say" "postUpdate" "switch" "println" "case" "or" "sendCommand"
  211. )
  212. 'words)
  213. (1 font-lock-keyword-face))
  214. (,(regexp-opt
  215. '(
  216. "ON" "OFF" "on" "off"
  217. "AND" "OR" "NAND" "NOR" "AVG" "SUM" "MAX" "MIN"
  218. "true" "false"
  219. )
  220. 'words)
  221. (1 font-lock-constant-face))
  222. (,(regexp-opt
  223. '(
  224. "name" "label" "item" "period" "refresh" "icon" "mappings" "minValue" "maxValue" "step" "switchsupport" "url" "height" "refresh" "visibility" "valuecolor"
  225. )
  226. 'words)
  227. (1 font-lock-type-face))
  228. ("\(.*\)" . font-lock-variable-name-face)
  229. ("[^a-zA-Z0-9_:]\\([0-9]*\\)[^a-zA-Z0-9_:]" . (1 font-lock-variable-name-face))
  230. ("\s@\s" . font-lock-variable-name-face)
  231. ("\s\\([a-zA-Z0-9_:]*\\)\\(\s\\|$\\)" . (1 font-lock-type-face))
  232. ("=\\([a-zA-Z_]*\\)" . (1 font-lock-string-face))
  233. ("\\([a-zA-Z]*\\)=" . (1 font-lock-type-face))
  234. )
  235. "The regexps to highlight in openHAB mode.")
  236. (defvar openhab-mode-syntax-table
  237. (let ((st (make-syntax-table)))
  238. (modify-syntax-entry ?/ ". 12b" st) ;; C-style comments // ...
  239. (modify-syntax-entry ?\n "> b" st) ;; \n ends comment
  240. ;; Block comments /*...*/
  241. (modify-syntax-entry ?\/ ". 14" st)
  242. (modify-syntax-entry ?* ". 23" st)
  243. st)
  244. "Syntax table for openhab-mode.")
  245. (defun openhab-mode ()
  246. "Major mode for editing OPENHAB config files."
  247. (interactive)
  248. (kill-all-local-variables)
  249. (set-syntax-table openhab-mode-syntax-table)
  250. (use-local-map openhab-mode-map)
  251. (set (make-local-variable 'font-lock-defaults) '(openhab-font-lock-keywords nil t))
  252. (electric-pair-mode -1)
  253. (flycheck-mode -1)
  254. (setq major-mode 'openhab-mode)
  255. (setq mode-name "OpenHAB")
  256. (run-hooks 'openhab-mode-hook))
  257. (provide 'openhab-mode)
  258. ;;; hyperspace.el --- Get there from here -*- lexical-binding: t; -*-
  259. ;; Copyright (C) 2017-2019 Ian Eure
  260. ;; Author: Ian Eure <ian@retrospec.tv>
  261. ;; URL: https://github.com/ieure/hyperspace-el
  262. ;; Version: 0.8.4
  263. ;; Package-Requires: ((emacs "25") (s "1.12.0"))
  264. ;; Keywords: tools, convenience
  265. ;; This program is free software; you can redistribute it and/or modify
  266. ;; it under the terms of the GNU General Public License as published by
  267. ;; the Free Software Foundation, either version 3 of the License, or
  268. ;; (at your option) any later version.
  269. ;; This program is distributed in the hope that it will be useful,
  270. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  271. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  272. ;; GNU General Public License for more details.
  273. ;; You should have received a copy of the GNU General Public License
  274. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  275. ;;; Commentary:
  276. ;; Hyperspace is a way to get nearly anywhere from wherever you are,
  277. ;; whether that's within Emacs or on the web. It's somewhere in
  278. ;; between Quicksilver and keyword URLs, giving you a single,
  279. ;; consistent interface to get directly where you want to go. It’s
  280. ;; for things that you use often, but not often enough to justify a
  281. ;; dedicated binding.
  282. ;;
  283. ;; When you enter Hyperspace, it prompts you where to go:
  284. ;;
  285. ;; HS:
  286. ;;
  287. ;; This prompt expects a keyword and a query. The keyword picks where
  288. ;; you want to go, and the remainder of the input is an optional
  289. ;; argument which can be used to further search or direct you within
  290. ;; that space.
  291. ;;
  292. ;; Some concrete examples:
  293. ;;
  294. ;; | *If you enter* | *then Hyperspace* |
  295. ;; |------------------+----------------------------------------------------------|
  296. ;; | "el" | opens info node "(elisp)Top" |
  297. ;; | "el eval-region" | searches for "eval-region" in the elisp Info index |
  298. ;; | "bb" | shows all BBDB entries |
  299. ;; | "bb kenneth" | shows all BBDB entries with a name matching "kenneth" |
  300. ;; | "ddg foo" | searches DuckDuckGo for "foo" using browse-url |
  301. ;; | "wp foo" | searches Wikipedia for "foo" using browse-url |
  302. ;;
  303. ;;; Code:
  304. (require 'subr-x)
  305. (require 's)
  306. ;; Action helpers
  307. (defun hyperspace-action->browse-url-pattern (pattern query)
  308. "Browse a URL former from PATTERN and QUERY."
  309. (browse-url (format pattern query)))
  310. (defun hyperspace-action->info (node &optional query)
  311. "Open an Info buffer for NODE.
  312. If QUERY is present, look it up in the index."
  313. (info node)
  314. (when query
  315. (Info-index query)))
  316. ;; Package definitions
  317. (defvar hyperspace-history nil
  318. "History of Hyperspace actions.")
  319. (defgroup hyperspace nil
  320. "Getting there from here"
  321. :prefix "hyperspace-"
  322. :group 'applications)
  323. (defcustom hyperspace-actions
  324. '(("ddg" . "https://duckduckgo.com/?q=%s")
  325. ("dis" . "https://duckduckgo.com/?q=%s&iax=images&ia=images")
  326. ("wp" . "https://en.wikipedia.org/wiki/%s")
  327. ("g" . "https://www.google.com/search?q=%s")
  328. ("gi" . "https://www.google.com/search?tbm=isch&q=%s")
  329. ("gm" . "https://www.google.com/maps/search/%s")
  330. ("yt" . "https://www.youtube.com/results?search_query=%s")
  331. ("clp" . "https://portland.craigslist.org/search/sss?query=%s")
  332. ("eb" . "https://www.ebay.com/sch/i.html?_nkw=%s")
  333. ("nf" . "https://www.netflix.com/search?q=%s")
  334. ("sh" . (lambda (query) (interactive) (shell-command query)))
  335. ("imdb" . "https://www.imdb.com/find?q=peter+jackson&s=all")
  336. ("bb" . bbdb-search-name)
  337. ("el" . (apply-partially #'hyperspace-action->info "(elisp)Top"))
  338. ("av" . apropos-variable)
  339. ("ac" . apropos-command)
  340. ("af" . (lambda (query) (apropos-command query t))))
  341. "Where Hyperspace should send you.
  342. Hyperspace actions are a cons of (KEYWORD . DISPATCHER). When
  343. Hyperspace is invoked, the keyword is extracted from the user
  344. input and looked up in this alist. The remainder of the
  345. string is passed to the dispatcher as its QUERY argument.
  346. DISPATCHER can be a function which performs the action.
  347. DISPATCHER can also be an expression which returns a function
  348. to perform the action.
  349. Finally, DISPATCHER can be a string with a URL pattern containing
  350. '%s'. The '%s' will be replaced with the query, and the URL browsed."
  351. :group 'hyperspace
  352. :type '(alist :key-type (string :tag "Keyword")
  353. :value-type (choice
  354. (function :tag "Function")
  355. (string :tag "URL Pattern")
  356. (sexp :tag "Expression"))))
  357. (defcustom hyperspace-default-action
  358. (caar hyperspace-actions)
  359. "A place to go if you don't specify one."
  360. :group 'hyperspace
  361. :type `(radio
  362. ,@(mapcar (lambda (action) (list 'const (car action))) hyperspace-actions)))
  363. (defcustom hyperspace-max-region-size 256
  364. "Maximum size of a region to consider for a Hyperspace query.
  365. If the region is active when Hyperspace is invoked, it's used
  366. as the default query, unless it's more than this number of
  367. characters."
  368. :group 'hyperspace
  369. :type 'integer)
  370. (defun hyperspace--cleanup (text)
  371. "Clean TEXT so it can be used for a Hyperspace query."
  372. (save-match-data
  373. (string-trim
  374. (replace-regexp-in-string (rx (1+ (or blank "\n"))) " " text))))
  375. (defun hyperspace--initial-text ()
  376. "Return the initial text.
  377. This is whatever's in the active region, but cleaned up."
  378. (when (use-region-p)
  379. (let* ((start (region-beginning))
  380. (end (region-end))
  381. (size (- end start)))
  382. (when (<= size hyperspace-max-region-size)
  383. (hyperspace--cleanup
  384. (buffer-substring-no-properties start end))))))
  385. (defun hyperspace--initial (initial-text)
  386. "Turn INITIAL-TEXT into INITIAL-CONTENTS for reading."
  387. (when initial-text (cons (concat " " initial-text) 1)))
  388. (defun hyperspace--process-input (text)
  389. "Process TEXT into an actionable keyword and query."
  390. (let ((kw-text (s-split-up-to "\\s-+" text 1)))
  391. (if (assoc (car kw-text) hyperspace-actions)
  392. kw-text
  393. (list hyperspace-default-action text))))
  394. (defun hyperspace--query ()
  395. "Ask the user for the Hyperspace action and query.
  396. Returns (KEYWORD . QUERY).
  397. If the region isn't active, the user is prompted for the
  398. action and query.
  399. If the region is active, its text is used as the initial value
  400. for the query, and the user enters the action.
  401. If a prefix argument is specified and the region is active,
  402. `HYPERSPACE-DEFAULT-ACTION' is chosen without prompting."
  403. (let ((initial (hyperspace--initial-text)))
  404. (if (and initial current-prefix-arg)
  405. (list hyperspace-default-action initial)
  406. (hyperspace--process-input
  407. (read-from-minibuffer "HS: " (hyperspace--initial initial) nil nil
  408. 'hyperspace-history)))))
  409. (defun hyperspace--evalable-p (form)
  410. "Can FORM be evaluated?"
  411. (and (listp form)
  412. (or (functionp (car form))
  413. (subrp (car form)))))
  414. (defun hyperspace--dispatch (action &optional query)
  415. "Execute ACTION, with optional QUERY argument."
  416. (pcase action
  417. ((pred functionp) (funcall action query))
  418. ((pred hyperspace--evalable-p) (funcall (eval action) query))
  419. ((pred stringp) (hyperspace-action->browse-url-pattern action query))
  420. (_ (error "Unknown action"))))
  421. ;;;###autoload
  422. (defun hyperspace (keyword &optional query)
  423. "Execute action for keyword KEYWORD, with optional QUERY."
  424. (interactive (hyperspace--query))
  425. (let ((action (cdr (assoc keyword hyperspace-actions))))
  426. (hyperspace--dispatch (or action hyperspace-default-action) query)))
  427. ;;;###autoload
  428. (defun hyperspace-enter (&optional query)
  429. "Enter Hyperspace, sending QUERY to the default action.
  430. If the region is active, use that as the query for
  431. hyperspace-default-action. Otherwise, prompt the user."
  432. (interactive (list (hyperspace--initial-text)))
  433. (hyperspace
  434. hyperspace-default-action
  435. (or query
  436. (read-from-minibuffer
  437. (format "HS: %s " hyperspace-default-action) nil nil
  438. 'hyperspace-history))))
  439. ;; Minor mode
  440. (defvar hyperspace-minor-mode-map
  441. (let ((kmap (make-sparse-keymap)))
  442. (define-key kmap (kbd "H-SPC") #'hyperspace)
  443. (define-key kmap (kbd "<H-return>") #'hyperspace-enter)
  444. kmap))
  445. ;;;###autoload
  446. (define-minor-mode hyperspace-minor-mode
  447. "Global (universal) minor mode to jump from here to there."
  448. nil nil hyperspace-minor-mode-map
  449. :group 'hyperspace
  450. :global t)
  451. (provide 'hyperspace)
  452. ;;; hyperspace.el ends here
  453. (require 'which-key)
  454. (which-key-setup-minibuffer)
  455. (which-key-mode)
  456. (require 'fic-mode)
  457. (add-hook 'js-mode-hook 'fic-mode)
  458. (require 'company)
  459. (add-hook 'after-init-hook 'global-company-mode)
  460. (setq company-dabbrev-downcase nil)
  461. (setq company-idle-delay 0.1)
  462. (require 'diminish)
  463. (diminish 'auto-revert-mode)
  464. (eval-after-load "company" '(diminish 'company-mode))
  465. (eval-after-load "counsel" '(diminish 'counsel-mode))
  466. (eval-after-load "elpy" '(diminish 'elpy-mode))
  467. (eval-after-load "go-mode" '(diminish 'go-mode))
  468. (eval-after-load "go-playground" '(diminish 'go-playground-mode))
  469. (eval-after-load "gorepl-mode" '(diminish 'gorepl-mode))
  470. (eval-after-load "flycheck" '(diminish 'flycheck-mode))
  471. (eval-after-load "ivy" '(diminish 'ivy-mode))
  472. (eval-after-load "projectile" '(diminish 'projectile-mode))
  473. (eval-after-load "which-key" '(diminish 'which-key-mode))
  474. (defun dired-mode-setup ()
  475. "Will run as hook for `dired-mode'."
  476. (dired-hide-details-mode nil))
  477. (add-hook 'dired-mode-hook 'dired-mode-setup)
  478. (add-hook 'artist-mode-hook
  479. (lambda ()
  480. (setq compilation-read-command nil)
  481. (set
  482. (make-local-variable 'compile-command)
  483. (format "java -jar /home/locust/scripts/java/ditaa0_9.jar -E %s | awk -F': ' '{print $2}' | awk NF | tail -n1 | xargs -I{} feh {}"
  484. (buffer-file-name)))))
  485. (add-to-list 'auto-mode-alist '("\\.uml\\'" . artist-mode))
  486. (require 'ivy-hydra)
  487. (require 'ivy)
  488. (require 'swiper)
  489. (ivy-mode 1)
  490. (counsel-mode)
  491. (setq ivy-use-virtual-buffers t
  492. enable-recursive-minibuffers t
  493. ivy-height 25
  494. ivy-initial-inputs-alist nil
  495. ivy-extra-directories nil)
  496. (global-set-key (kbd "C-s") 'swiper)
  497. (global-set-key (kbd "C-c C-r") 'ivy-resume)
  498. (global-set-key (kbd "M-x") 'counsel-M-x)
  499. (global-set-key (kbd "C-x C-f") 'counsel-find-file)
  500. (global-set-key (kbd "C-c g") 'counsel-git)
  501. (global-set-key (kbd "C-c j") 'counsel-git-grep)
  502. (global-set-key (kbd "C-c k") 'counsel-ag)
  503. (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
  504. (defun ivy-open-current-typed-path ()
  505. (interactive)
  506. (when ivy--directory
  507. (let* ((dir ivy--directory)
  508. (text-typed ivy-text)
  509. (path (concat dir text-typed)))
  510. (delete-minibuffer-contents)
  511. (ivy--done path))))
  512. (define-key ivy-minibuffer-map (kbd "<return>") 'ivy-alt-done)
  513. (define-key ivy-minibuffer-map (kbd "C-f") 'ivy-open-current-typed-path)
  514. (autoload 'ledger-mode "ledger-mode" "A major mode for Ledger" t)
  515. (add-to-list 'load-path
  516. (expand-file-name "/path/to/ledger/source/lisp/"))
  517. (add-to-list 'auto-mode-alist '("\\.ledger$" . ledger-mode))
  518. (require 'magit)
  519. (global-set-key (kbd "C-x g") 'magit-status)
  520. (global-set-key (kbd "C-c g") 'magit-status)
  521. (setq magit-completing-read-function 'ivy-completing-read)
  522. (add-to-list 'exec-path "/home/locust/.local/bin")
  523. ;; (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu/mu4e")
  524. (add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
  525. (require 'mu4e)
  526. (setq mu4e-maildir "/home/locust/Mail"
  527. mu4e-mu-binary "/usr/bin/mu"
  528. mu4e-change-filenames-when-moving t ;; Rename files when moving (required by mbsync)
  529. mu4e-compose-in-new-frame t ;; New compose gets new frame
  530. mu4e-context-policy 'pick-first
  531. mu4e-get-mail-command "mbsync -a" ;; MBSYNC is the mail cmd
  532. mu4e-html2text-command "/usr/bin/w3m -T text/html" ;; HTML to text command
  533. mu4e-headers-include-related nil ;; Stop threading in INBOX
  534. mu4e-sent-messages-behavior 'delete ;; Delete sent messages
  535. mu4e-update-interval 300 ;; 5 mins
  536. mu4e-use-fancy-chars t ;; use 'fancy' chars
  537. mu4e-user-mail-address-list '("lolson@eaglecrk.com"
  538. "olson.levi@gmail.com")
  539. mu4e-view-show-images t ;; attempt to show images
  540. mu4e-view-image-max-width 400 ;; max image size
  541. message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n" ;; customize the reply-quote-string
  542. message-citation-line-function 'message-insert-formatted-citation-line ;; choose to use the formatted string
  543. message-kill-buffer-on-exit t ;; don't keep messages around
  544. send-mail-function 'smtpmail-send-it ;; Default email send function
  545. smtpmail-default-smtp-server "smtp.gmail.com"
  546. smtpmail-smtp-service 587
  547. )
  548. ;; (defun leo/convert-message-set-point ()
  549. ;; "Set the point to the start of the message body."
  550. ;; (interactive)
  551. ;; (beginning-of-buffer)
  552. ;; (search-forward "--text follows this line--")
  553. ;; (forward-char)
  554. ;; )
  555. ;; (defun leo/convert-message-from-markdown ()
  556. ;; "Convert a markdown flavored mail buffer to html w/mime support."
  557. ;; (interactive)
  558. ;; (if (y-or-n-p "Convert to HTML? ")
  559. ;; ((leo/convert-message-set-point)
  560. ;; (save-excursion
  561. ;; (message-goto-body)
  562. ;; (shell-command-on-region (point) (point-max) "~/.emacs.d/scripts/expand-mime.sh" nil t)))
  563. ;; (message "Aborting."))
  564. ;; )
  565. (setq mu4e-contexts
  566. `(
  567. ;; ,(make-mu4e-context
  568. ;; :name "Vlocity"
  569. ;; :enter-func (lambda () (mu4e-message "Entering Vlocity"))
  570. ;; :leave-func (lambda () (mu4e-message "Leaving Vlocity"))
  571. ;; ;; we match based on the contact-fields of the message
  572. ;; :match-func (lambda (msg)
  573. ;; (when msg
  574. ;; (string= (mu4e-message-field msg :maildir) "/Vlocity")))
  575. ;; :vars '( ( user-mail-address . "lolson@vlocity.com" )
  576. ;; ( smtpmail-mail-address . "lolson@vlocity.com" )
  577. ;; ( smtpmail-smtp-user . "lolson@vlocity.com" )
  578. ;; ( smtpmail-smtp-server . "smtp.gmail.com" )
  579. ;; ( user-full-name . "Levi Olson" )
  580. ;; ( mu4e-compose-signature .
  581. ;; (concat
  582. ;; "Levi Olson\n"
  583. ;; "Senior UI Developer"))
  584. ;; ( mu4e-sent-folder . "/Vlocity/[Gmail].Sent Mail" )
  585. ;; ( mu4e-drafts-folder . "/Vlocity/[Gmail].Drafts" )
  586. ;; ( mu4e-trash-folder . "/Vlocity/[Gmail].Trash" )
  587. ;; ( mu4e-maildir-shortcuts . (("/Vlocity/INBOX" . ?i)
  588. ;; ("/Vlocity/[Gmail].Sent Mail" . ?s)
  589. ;; ("/Vlocity/[Gmail].Trash" . ?t)
  590. ;; ("/Vlocity/[Gmail].All Mail" . ?a)))))
  591. ,(make-mu4e-context
  592. :name "EagleCreek"
  593. :enter-func (lambda () (mu4e-message "Entering EagleCreek"))
  594. :leave-func (lambda () (mu4e-message "Leaving EagleCreek"))
  595. ;; we match based on the contact-fields of the message
  596. :match-func (lambda (msg)
  597. (when msg
  598. (string= (mu4e-message-field msg :maildir) "/eaglecrk")))
  599. :vars '( ( user-mail-address . "lolson@eaglecrk.com" )
  600. ( smtpmail-mail-address . "lolson@eaglecrk.com" )
  601. ( smtpmail-smtp-user . "lolson@eaglecrk.com" )
  602. ( smtpmail-smtp-server . "smtp.office365.com" )
  603. ( user-full-name . "Levi Olson" )
  604. ;; ( mu4e-compose-signature .
  605. ;; (concat
  606. ;; "Levi Olson\n"
  607. ;; "Eagle Creek Software Services\n"
  608. ;; "Senior Application Developer Consultant\n"))
  609. ( mu4e-sent-folder . "/eaglecrk/Sent Items" )
  610. ( mu4e-refile-folder . "/eaglecrk/Archive" )
  611. ( mu4e-drafts-folder . "/eaglecrk/Drafts" )
  612. ( mu4e-trash-folder . "/eaglecrk/Deleted Items" )
  613. ( mu4e-maildir-shortcuts . (("/eaglecrk/Inbox" . ?i)
  614. ("/eaglecrk/Sent Items" . ?s)
  615. ("/eaglecrk/Deleted Items" . ?t)
  616. ("/eaglecrk/Archive" . ?a)
  617. ))))
  618. ,(make-mu4e-context
  619. :name "Gmail"
  620. :enter-func (lambda () (mu4e-message "Entering Gmail"))
  621. :leave-func (lambda () (mu4e-message "Leaving Gmail"))
  622. ;; this matches maildir /Arkham and its sub-directories
  623. :match-func (lambda (msg)
  624. (when msg
  625. (string= (mu4e-message-field msg :maildir) "/gmail")))
  626. :vars '( ( user-mail-address . "olson.levi@gmail.com" )
  627. ( smtpmail-mail-address . "olson.levi@gmail.com" )
  628. ( smtpmail-smtp-user . "olson.levi@gmail.com" )
  629. ( smtpmail-smtp-server . "smtp.gmail.com" )
  630. ( user-full-name . "Levi Olson" )
  631. ( mu4e-compose-signature .
  632. (concat
  633. "Levi\n"))
  634. ( mu4e-sent-folder . "/gmail/[Gmail]/Sent Mail" )
  635. ( mu4e-refile-folder . "/gmail/[Gmail]/All Mail" )
  636. ( mu4e-drafts-folder . "/gmail/[Gmail]/Drafts" )
  637. ( mu4e-trash-folder . "/gmail/[Gmail]/Trash" )
  638. ( mu4e-maildir-shortcuts . (("/gmail/Inbox" . ?i)
  639. ("/gmail/[Gmail]/Sent Mail" . ?s)
  640. ("/gmail/[Gmail]/Trash" . ?t)
  641. ("/gmail/[Gmail]/All Mail" . ?a)
  642. ))))
  643. ))
  644. ;; Add option to view HTML in browser
  645. (add-to-list 'mu4e-headers-actions
  646. '("in browser" . mu4e-action-view-in-browser) t)
  647. (add-to-list 'mu4e-view-actions
  648. '("in browser" . mu4e-action-view-in-browser) t)
  649. (defun my-message-current-line-cited-p ()
  650. "Indicate whether the line at point is a cited line."
  651. (save-match-data
  652. (string-match (concat "^" message-cite-prefix-regexp)
  653. (buffer-substring (line-beginning-position) (line-end-position)))))
  654. (defun my-message-says-attachment-p ()
  655. "Return t if the message suggests there can be an attachment."
  656. (save-excursion
  657. (goto-char (point-min))
  658. (save-match-data
  659. (let (search-result)
  660. (while
  661. (and (setq search-result (re-search-forward "\\(attach\\|pdf\\|file\\)" nil t))
  662. (my-message-current-line-cited-p)))
  663. search-result))))
  664. (defun my-message-has-attachment-p ()
  665. "Return t if the message has an attachment."
  666. (save-excursion
  667. (goto-char (point-min))
  668. (save-match-data
  669. (re-search-forward "<#part" nil t))))
  670. (defun my-message-pre-send-check-attachment ()
  671. (when (and (my-message-says-attachment-p)
  672. (not (my-message-has-attachment-p)))
  673. (unless
  674. (y-or-n-p "No attachment. Send anyway?")
  675. (error "It seems that an attachment is needed, but none was found. Aborting sending."))))
  676. (add-hook 'message-send-hook 'my-message-pre-send-check-attachment)
  677. (require 'projectile)
  678. (require 'counsel-projectile)
  679. (projectile-mode)
  680. (setq projectile-mode-line '(:eval (format " %s" (projectile-project-name)))
  681. projectile-remember-window-configs t
  682. projectile-completion-system 'ivy)
  683. (counsel-projectile-mode)
  684. (autoload 'poporg-dwim "poporg" nil t)
  685. (global-set-key (kbd "C-c \"") 'poporg-dwim)
  686. ;;; notify.el --- notification front-end
  687. ;; Copyright (C) 2008 Mark A. Hershberger
  688. ;; Original Author: Mark A. Hershberger <mhersberger@intrahealth.org>
  689. ;; Modified by Andrey Kotlarski <m00naticus@gmail.com>
  690. ;; Modified by Andrew Gwozdziewycz <git@apgwoz.com>
  691. ;; Modified by Aidan Gauland <aidalgol@no8wireless.co.nz> October 2011
  692. ;; Modified by Olivier Sirven <the.slaa@gmail.com> November 2013
  693. ;; Keywords: extensions, convenience, lisp
  694. ;; This file is free software; you can redistribute it and/or modify
  695. ;; it under the terms of the GNU General Public License as published by
  696. ;; the Free Software Foundation; either version 2, or (at your option)
  697. ;; any later version.
  698. ;; This file is distributed in the hope that it will be useful,
  699. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  700. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  701. ;; GNU General Public License for more details.
  702. ;; You should have received a copy of the GNU General Public License
  703. ;; along with GNU Emacs; see the file COPYING. If not, write to
  704. ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  705. ;; Boston, MA 02111-1307, USA.
  706. ;;; Commentary:
  707. ;; This provides a single function, `notify', that will produce a notify
  708. ;; pop-up via D-Bus, libnotify, simple message or growl.
  709. ;; To use, just put (autoload 'notify "notify" "Notify TITLE, BODY.")
  710. ;; in your init file. You may override default chosen notification
  711. ;; method by assigning `notify-method' to one of 'notify-via-dbus
  712. ;; 'notify-via-libnotify or 'notify-via-message
  713. ;;; Code:
  714. (defvar notify-defaults (list :app "Emacs" :icon "emacs" :timeout 5000
  715. :urgency "low"
  716. :category "emacs.message")
  717. "Notification settings' defaults.
  718. May be overridden with key-value additional arguments to `notify'.")
  719. (defvar notify-delay '(0 5 0)
  720. "Minimum time allowed between notifications in time format.")
  721. (defvar notify-last-notification '(0 0 0) "Time of last notification.")
  722. (defvar notify-method 'notify-via-growl "Notification method among
  723. 'notify-via-dbus, 'notify-via-libnotify, 'notify-via-message or
  724. 'notify-via-growl")
  725. ;; determine notification method unless already set
  726. ;; prefer growl > D-Bus > libnotify > message
  727. (cond
  728. ((null notify-method)
  729. (setq notify-method
  730. (cond
  731. ((executable-find "growlnotify") 'notify-via-growl)
  732. ((and (require 'dbus nil t)
  733. (dbus-ping :session "org.freedesktop.Notifications"))
  734. (defvar notify-id 0 "Current D-Bus notification id.")
  735. 'notify-via-dbus)
  736. ((executable-find "notify-send") 'notify-via-libnotify)
  737. (t 'notify-via-message))))
  738. ((eq notify-method 'notify-via-dbus) ;housekeeping for pre-chosen DBus
  739. (if (and (require 'dbus nil t)
  740. (dbus-ping :session "org.freedesktop.Notifications"))
  741. (defvar notify-id 0 "Current D-Bus notification id.")
  742. (setq notify-method (if (executable-find "notify-send")
  743. 'notify-via-libnotify
  744. 'notify-via-message))))
  745. ((and (eq notify-method 'notify-via-libnotify)
  746. (not (executable-find "notify-send"))) ;housekeeping for pre-chosen libnotify
  747. (setq notify-method
  748. (if (and (require 'dbus nil t)
  749. (dbus-ping :session "org.freedesktop.Notifications"))
  750. (progn
  751. (defvar notify-id 0 "Current D-Bus notification id.")
  752. 'notify-via-dbus)
  753. 'notify-via-message)))
  754. ((and (eq notify-method 'notify-via-growl)
  755. (not (executable-find "growlnotify")))
  756. (setq notify-method 'notify-via-message)))
  757. (defun notify-via-dbus (title body)
  758. "Send notification with TITLE, BODY `D-Bus'."
  759. (dbus-call-method :session "org.freedesktop.Notifications"
  760. "/org/freedesktop/Notifications"
  761. "org.freedesktop.Notifications" "Notify"
  762. (get 'notify-defaults :app)
  763. (setq notify-id (+ notify-id 1))
  764. (get 'notify-defaults :icon) title body '(:array)
  765. '(:array :signature "{sv}") ':int32
  766. (get 'notify-defaults :timeout)))
  767. (defun notify-via-libnotify (title body)
  768. "Notify with TITLE, BODY via `libnotify'."
  769. (call-process "notify-send" nil 0 nil
  770. title body "-t"
  771. (number-to-string (get 'notify-defaults :timeout))
  772. "-i" (get 'notify-defaults :icon)
  773. "-u" (get 'notify-defaults :urgency)
  774. "-c" (get 'notify-defaults :category)))
  775. (defun notify-via-message (title body)
  776. "Notify TITLE, BODY with a simple message."
  777. (message "%s: %s" title body))
  778. (defun notify-via-growl (title body)
  779. "Notify TITLE, BODY with a growl"
  780. (call-process "growlnotify" nil 0 nil
  781. "-a" (get 'notify-defaults :app)
  782. "-n" (get 'notify-defaults :category)
  783. "-t" (notify-via-growl-stringify title)
  784. "-m" (notify-via-growl-stringify body)))
  785. (defun notify-via-growl-stringify (thing)
  786. (cond ((null thing) "")
  787. ((stringp thing) thing)
  788. (t (format "%s" thing))))
  789. (defun keywords-to-properties (symbol args &optional defaults)
  790. "Add to SYMBOL's property list key-values from ARGS and DEFAULTS."
  791. (when (consp defaults)
  792. (keywords-to-properties symbol defaults))
  793. (while args
  794. (put symbol (car args) (cadr args))
  795. (setq args (cddr args))))
  796. ;;;###autoload
  797. (defun notify (title body &rest args)
  798. "Notify TITLE, BODY via `notify-method'.
  799. ARGS may be amongst :timeout, :icon, :urgency, :app and :category."
  800. (when (time-less-p notify-delay
  801. (time-since notify-last-notification))
  802. (or (eq notify-method 'notify-via-message)
  803. (keywords-to-properties 'notify-defaults args
  804. notify-defaults))
  805. (setq notify-last-notification (current-time))
  806. (funcall notify-method title body)))
  807. (provide 'notify)
  808. ;;; notify.el ends here
  809. (require 'jabber)
  810. (setq jabber-history-enabled t
  811. jabber-use-global-history nil
  812. jabber-backlog-number 40
  813. jabber-backlog-days 30
  814. jabber-alert-presence-message-function (lambda (_who _oldstatus _newstatus _statustext) nil)
  815. )
  816. (setq jabber-account-list '(
  817. ("olson.levi@gmail.com"
  818. (:network-server . "talk.google.com")
  819. (:connection-type . ssl))
  820. ;; ("lolson@vlocity.com"
  821. ;; (:network-server . "talk.google.com")
  822. ;; (:connection-type . ssl))
  823. ))
  824. (defvar my-chat-prompt "[%t] %n>\n" "Customized chat prompt")
  825. (when (featurep 'jabber)
  826. (setq
  827. jabber-chat-foreign-prompt-format my-chat-prompt
  828. jabber-chat-local-prompt-format my-chat-prompt
  829. jabber-groupchat-prompt-format my-chat-prompt
  830. jabber-muc-private-foreign-prompt-format "[%t] %g/%n>\n"
  831. )
  832. )
  833. (defun notify-jabber-notify (from buf text _proposed-alert)
  834. "(jabber.el hook) Notify of new Jabber chat messages via notify.el"
  835. (when (or jabber-message-alert-same-buffer
  836. (not (memq (selected-window) (get-buffer-window-list buf))))
  837. (if (jabber-muc-sender-p from)
  838. (notify (format "(PM) %s"
  839. (jabber-jid-displayname (jabber-jid-user from)))
  840. (format "%s: %s" (jabber-jid-resource from) text)))
  841. (notify (format "%s" (jabber-jid-displayname from))
  842. text)))
  843. ;; (add-hook 'jabber-alert-message-hooks 'notify-jabber-notify)
  844. ;; (require 'autosmiley)
  845. ;; (add-hook 'jabber-chat-mode-hook 'autosmiley-mode)
  846. (defun jabber ()
  847. (interactive)
  848. (jabber-connect-all)
  849. (switch-to-buffer "*-jabber-roster-*"))
  850. (defun hyperspace-action->mu4e (&optional query)
  851. "Search mu4e with QUERY.
  852. If QUERY is unspecified, use the first bookmark in variable
  853. mu4e-bookmarks and update mail and index."
  854. (mu4e-headers-search (or query (caar mu4e-bookmarks)))
  855. (unless query
  856. (mu4e-update-mail-and-index nil)))
  857. (add-to-list 'hyperspace-actions '("m4" . hyperspace-action->mu4e))
  858. (defun hyperspace-action->elfeed (&optional query)
  859. "Load elfeed, optionally searching for QUERY."
  860. (elfeed)
  861. (if query
  862. (elfeed-search-set-filter query)
  863. (elfeed-search-fetch nil)))
  864. (add-to-list 'hyperspace-actions '("lf" . hyperspace-action->elfeed))
  865. (defun find-user-init-file ()
  866. "Edit the `~/.emacs.d/init.org' file."
  867. (interactive)
  868. (find-file "~/.emacs.d/init.org"))
  869. (defun find-todo-file ()
  870. "Edit the `~/todo.org' file."
  871. (interactive)
  872. (find-file "~/Dropbox/Org/todo.org"))
  873. (defun load-user-init-file ()
  874. "LO: Reload the `~/.emacs.d/init.elc' file."
  875. (interactive)
  876. (load-file "~/.emacs.d/init.elc"))
  877. (defun leo-swiper ()
  878. "LO: Custom swiper."
  879. (interactive)
  880. (let ((word (thing-at-point 'symbol)))
  881. (if word (swiper (format "%s" word)))
  882. (unless word (swiper (format ""))))
  883. )
  884. (defun jump-to-symbol-internal (&optional backwardp)
  885. "Jumps to the next symbol near the point if such a symbol exists. If BACKWARDP is non-nil it jumps backward."
  886. (let* ((point (point))
  887. (bounds (find-tag-default-bounds))
  888. (beg (car bounds)) (end (cdr bounds))
  889. (str (isearch-symbol-regexp (find-tag-default)))
  890. (search (if backwardp 'search-backward-regexp
  891. 'search-forward-regexp)))
  892. (goto-char (if backwardp beg end))
  893. (funcall search str nil t)
  894. (cond ((<= beg (point) end) (goto-char point))
  895. (backwardp (forward-char (- point beg)))
  896. (t (backward-char (- end point))))))
  897. (defun jump-to-previous-like-this ()
  898. "Jumps to the previous occurrence of the symbol at point."
  899. (interactive)
  900. (jump-to-symbol-internal t))
  901. (defun jump-to-next-like-this ()
  902. "Jumps to the next occurrence of the symbol at point."
  903. (interactive)
  904. (jump-to-symbol-internal))
  905. (defun match-paren (arg)
  906. "Go to the matching paren if on a paren; otherwise insert ARG (a literal % sign)."
  907. (interactive "p")
  908. (cond ((looking-at "\\s(") (forward-list 1))
  909. ((looking-back "\\s(" 2) (backward-char 1) (forward-list 1))
  910. ((looking-at "\\s)") (forward-char 1) (backward-list 1))
  911. ((looking-back "\\s)" 2) (backward-list 1))
  912. (t (self-insert-command (or arg 1)))))
  913. (defun kill-this-buffer-unless-scratch ()
  914. "Works like `kill-this-buffer' unless the current buffer is the *scratch* buffer. In which case the buffer content is deleted and the buffer is buried."
  915. (interactive)
  916. (if (not (string= (buffer-name) "*scratch*"))
  917. (kill-this-buffer)
  918. (delete-region (point-min) (point-max))
  919. (switch-to-buffer (other-buffer))
  920. (bury-buffer "*scratch*")))
  921. (defun delete-backward-sentence ()
  922. "LO: Delete to the beginning of the sentence/line."
  923. (interactive)
  924. (delete-region (point) (progn (backward-sentence) (point))))
  925. (defun delete-backward-to-boundary (arg)
  926. "LO: Delete backward to the previous word boundary. With ARG, do this many times."
  927. (interactive "p")
  928. (let ((a (point))
  929. (b (progn
  930. (backward-word arg)
  931. (forward-word)
  932. (point))))
  933. (if (< a b)
  934. (delete-region a (progn (backward-word arg) (point)))
  935. (if (= a b)
  936. (delete-region a (progn (backward-word arg) (point)))
  937. (delete-region a b)))))
  938. (defun comment-or-uncomment-region-or-line ()
  939. "Comments or uncomments the region or the current line if there's no active region."
  940. (interactive)
  941. (let (beg end)
  942. (if (region-active-p)
  943. (setq beg (region-beginning) end (region-end))
  944. (setq beg (line-beginning-position) end (line-end-position)))
  945. (comment-or-uncomment-region beg end)))
  946. (defun fold-toggle (column)
  947. "Code folding by COLUMN."
  948. (interactive "P")
  949. (set-selective-display
  950. (or column
  951. (unless selective-display
  952. (1+ (current-column))))))
  953. (defun new-line-below ()
  954. "LO: Create a new line below current line."
  955. (interactive)
  956. (move-end-of-line 1)
  957. (newline-and-indent))
  958. (defun new-line-above ()
  959. "LO: Create a new line above current line."
  960. (interactive)
  961. (move-beginning-of-line 1)
  962. (newline)
  963. (forward-line -1))
  964. (defun duplicate-thing (comment)
  965. "LO: Duplicates the current line, or the region if active. If an argument (COMMENT) is given, the duplicated region will be commented out."
  966. (interactive "P")
  967. (save-excursion
  968. (let ((start (if (region-active-p) (region-beginning) (point-at-bol)))
  969. (end (if (region-active-p) (region-end) (point-at-eol))))
  970. (goto-char end)
  971. (unless (region-active-p)
  972. (newline))
  973. (insert (buffer-substring start end))
  974. (when comment (comment-region start end)))))
  975. (defun tidy ()
  976. "LO: Ident, untabify and unwhitespacify current buffer, or region if active."
  977. (interactive)
  978. (let ((beg (if (region-active-p) (region-beginning) (point-min)))
  979. (end (if (region-active-p) (region-end) (point-max))))
  980. (let ((inhibit-message t))
  981. (indent-region beg end))
  982. (whitespace-cleanup)
  983. (untabify beg (if (< end (point-max)) end (point-max)))
  984. (if (region-active-p) (message "Indenting Region...Done") (message "Indenting File...Done"))))
  985. (defun phil-columns ()
  986. "LO: Good 'ol Phil-Columns."
  987. (interactive)
  988. (message "Good 'ol fill-columns")
  989. (with-output-to-temp-buffer "*PHIL-COLUMN*"
  990. (shell-command "mpv --no-video 'https://www.youtube.com/watch?v=YkADj0TPrJA&t=3m16s' > /dev/null 2>&1 & sleep 8; pkill mpv"))
  991. (other-window 1)
  992. (delete-window))
  993. (declare-function first "Goto FIRST shell.")
  994. (declare-function goto-non-shell-buffer "Goto something other than a shell buffer.")
  995. (declare-function switch-shell "Switch shell.")
  996. (let ((last-shell ""))
  997. (defun toggle-shell ()
  998. (interactive)
  999. (cond ((string-match-p "^\\*shell<[1-9][0-9]*>\\*$" (buffer-name))
  1000. (goto-non-shell-buffer))
  1001. ((get-buffer last-shell) (switch-to-buffer last-shell))
  1002. (t (shell (setq last-shell "*shell<1>*")))))
  1003. (defun switch-shell (n)
  1004. (let ((buffer-name (format "*shell<%d>*" n)))
  1005. (setq last-shell buffer-name)
  1006. (cond ((get-buffer buffer-name)
  1007. (switch-to-buffer buffer-name))
  1008. (t (shell buffer-name)
  1009. (rename-buffer buffer-name)))))
  1010. (defun goto-non-shell-buffer ()
  1011. (let* ((r "^\\*shell<[1-9][0-9]*>\\*$")
  1012. (shell-buffer-p (lambda (b) (string-match-p r (buffer-name b))))
  1013. (non-shells (cl-remove-if shell-buffer-p (buffer-list))))
  1014. (when non-shells
  1015. (switch-to-buffer (first non-shells))))))
  1016. (defadvice shell (after kill-with-no-query nil activate)
  1017. "."
  1018. (set-process-query-on-exit-flag (get-buffer-process ad-return-value) nil))
  1019. (declare-function comint-truncate-buffer ".")
  1020. (defun clear-comint ()
  1021. "Run `comint-truncate-buffer' with the `comint-buffer-maximum-size' set to zero."
  1022. (interactive)
  1023. (let ((comint-buffer-maximum-size 0))
  1024. (comint-truncate-buffer)))
  1025. (defun c-setup ()
  1026. "Compile."
  1027. (local-set-key (kbd "C-c C-c") 'compile))
  1028. (require 'company)
  1029. (add-hook 'comint-mode-hook (lambda () (local-set-key (kbd "c-l") 'clear-comint)))
  1030. (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
  1031. (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
  1032. (add-hook 'c-mode-common-hook 'c-setup)
  1033. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  1034. (defvar company-active-map (make-keymap)
  1035. "company mode keymap.")
  1036. (defvar artist-mode-map (make-keymap)
  1037. "artist mode keymap.")
  1038. (defvar custom-bindings (make-keymap)
  1039. "a keymap of custom bindings.")
  1040. (define-key custom-bindings (kbd "M-p") 'jump-to-previous-like-this)
  1041. (define-key custom-bindings (kbd "M-r") 'fill-paragraph)
  1042. (define-key custom-bindings (kbd "M-n") 'jump-to-next-like-this)
  1043. (define-key custom-bindings (kbd "M-<tab>") 'switch-to-next-buffer)
  1044. (define-key custom-bindings (kbd "M-<backspace>")'delete-backward-to-boundary)
  1045. (define-key custom-bindings (kbd "C-<backspace>")'delete-backward-to-boundary)
  1046. (define-key custom-bindings (kbd "C-}") 'mc/mark-next-like-this)
  1047. (define-key custom-bindings (kbd "C-)") 'mc/unmark-next-like-this)
  1048. (define-key custom-bindings (kbd "C-{") 'mc/mark-previous-like-this)
  1049. (define-key custom-bindings (kbd "C-(") 'mc/unmark-previous-like-this)
  1050. (define-key custom-bindings (kbd "C-'") 'mc-hide-unmatched-lines-mode)
  1051. (define-key custom-bindings (kbd "C-c 1") 'mc/insert-numbers)
  1052. (define-key custom-bindings (kbd "C-c s") 'mc/sort-regions)
  1053. (define-key custom-bindings "%" 'match-paren)
  1054. (define-key custom-bindings (kbd "C-x .") 'dash-at-point)
  1055. (define-key custom-bindings (kbd "C-x ,") 'dash-at-point-with-docset)
  1056. (define-key custom-bindings (kbd "C-s") 'leo-swiper)
  1057. (define-key custom-bindings (kbd "C-x C-l m") 'mu4e)
  1058. (define-key custom-bindings (kbd "C-x C-o t") 'find-todo-file)
  1059. (define-key custom-bindings (kbd "C-x C-l j") 'jabber)
  1060. (define-key custom-bindings (kbd "C-x C-l f") 'elfeed)
  1061. (define-key custom-bindings (kbd "C-x C-l a") 'org-agenda)
  1062. (define-key custom-bindings (kbd "C-,") 'org-cycle-agenda-files)
  1063. (define-key custom-bindings (kbd "C-x C-l c") 'calendar)
  1064. (define-key custom-bindings (kbd "M-SPC") #'hyperspace)
  1065. ;; (dolist (n (number-sequence 1 9))
  1066. ;; (global-set-key (kbd (concat "M-" (int-to-string n)))
  1067. ;; (lambda () (interactive) (switch-shell n))))
  1068. (define-key company-active-map (kbd "C-d") 'company-show-doc-buffer)
  1069. (define-key company-active-map (kbd "C-n") 'company-select-next)
  1070. (define-key company-active-map (kbd "C-p") 'company-select-previous)
  1071. (define-key company-active-map (kbd "<tab>") 'company-complete)
  1072. (define-key custom-bindings (kbd "C-c p") 'counsel-projectile-switch-project)
  1073. (define-key custom-bindings (kbd "C-c f") 'counsel-projectile-find-file)
  1074. (define-key custom-bindings (kbd "C-c c") 'ivy-resume)
  1075. (define-key custom-bindings (kbd "C-c m") 'magit-status)
  1076. (define-key custom-bindings (kbd "C-c D") 'define-word-at-point)
  1077. (define-key custom-bindings (kbd "C-@") 'er/expand-region)
  1078. (define-key custom-bindings (kbd "C-#") 'er/contract-region)
  1079. (define-key custom-bindings (kbd "C-S-c C-S-c") 'mc/edit-lines)
  1080. (define-key custom-bindings (kbd "C-c b") 'ivy-switch-buffer)
  1081. (define-key custom-bindings (kbd "C-c l") 'org-store-link)
  1082. (define-key custom-bindings (kbd "C-c t") 'org-set-tags)
  1083. (define-key custom-bindings (kbd "M-u") 'upcase-dwim)
  1084. (define-key custom-bindings (kbd "M-c") 'capitalize-dwim)
  1085. (define-key custom-bindings (kbd "M-l") 'downcase-dwim)
  1086. (define-key custom-bindings (kbd "M-o") 'other-window)
  1087. (define-key custom-bindings (kbd "C-c s") 'ispell-word)
  1088. (define-key custom-bindings (kbd "C-c C-d") 'org-capture)
  1089. (define-key custom-bindings (kbd "C-c <up>") 'windmove-up)
  1090. (define-key custom-bindings (kbd "C-c <down>") 'windmove-down)
  1091. (define-key custom-bindings (kbd "C-c <left>") 'windmove-left)
  1092. (define-key custom-bindings (kbd "C-c <right>") 'windmove-right)
  1093. (define-key custom-bindings (kbd "C-c a") (lambda () (interactive) (org-agenda nil "n")))
  1094. (define-key custom-bindings (kbd "C-c e") 'find-user-init-file)
  1095. (define-key custom-bindings (kbd "C-x f") 'phil-columns)
  1096. (define-key custom-bindings (kbd "C-x k") 'kill-this-buffer-unless-scratch)
  1097. (define-key custom-bindings (kbd "C-c d") 'duplicate-thing)
  1098. (define-key custom-bindings (kbd "C-;") 'comment-or-uncomment-region-or-line)
  1099. (define-key custom-bindings (kbd "C-o") 'new-line-below)
  1100. (define-key custom-bindings (kbd "C-S-o") 'new-line-above)
  1101. (define-key custom-bindings (kbd "<C-tab>") 'tidy)
  1102. (define-key custom-bindings (kbd "M-q")
  1103. (lambda ()
  1104. (interactive)
  1105. (kill-this-buffer)
  1106. (delete-window)
  1107. (message nil)
  1108. (message "Done")
  1109. ))
  1110. ;; (define-key custom-bindings (kbd "M-RET") '(lambda () (interactive) (term (getenv "SHELL"))))
  1111. (define-key artist-mode-map (kbd "C-c C-c") 'compile)
  1112. (define-minor-mode custom-bindings-mode
  1113. "A mode that activates custom-bindings."
  1114. t nil custom-bindings)
  1115. (require 'rainbow-delimiters)
  1116. (global-flycheck-mode)
  1117. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  1118. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
  1119. (setq-default indent-tabs-mode nil
  1120. tab-width 4)
  1121. (defvaralias 'c-basic-offset 'tab-width)
  1122. (defvaralias 'cperl-indent-level 'tab-width)
  1123. (electric-pair-mode 1)
  1124. (show-paren-mode 1)
  1125. (require 'dockerfile-mode)
  1126. (add-to-list 'auto-mode-alist '("Dockerfile*\\'" . dockerfile-mode))
  1127. (require 'gitignore-mode)
  1128. (add-to-list 'auto-mode-alist '("gitignore\\'" . gitignore-mode))
  1129. ;; Workaround to get Projectile to work again
  1130. (setq projectile-git-submodule-command nil)
  1131. (require 'json-mode)
  1132. (add-to-list 'auto-mode-alist '("\\.json\\'" . json-mode))
  1133. (require 'web-mode)
  1134. (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
  1135. (elpy-enable)
  1136. (setq python-shell-interpreter "jupyter"
  1137. python-shell-interpreter-args "console --simple-prompt")
  1138. (when (require 'flycheck nil t)
  1139. (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  1140. (add-hook 'elpy-mode-hook 'flycheck-mode))
  1141. (require 'py-autopep8)
  1142. (setq py-autopep8-options '("--ignore=E501"))
  1143. (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
  1144. (require 'go-mode)
  1145. (require 'go-playground)
  1146. (require 'gorepl-mode)
  1147. (require 'company-go)
  1148. (add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
  1149. (add-hook 'go-mode-hook (lambda ()
  1150. (add-hook 'before-save-hook 'gofmt-before-save)
  1151. (local-set-key (kbd "M-.") 'godef-jump)
  1152. (local-set-key (kbd "M-,") 'pop-tag-mark)
  1153. (local-set-key (kbd "C-c C-c") (lambda ()
  1154. (interactive)
  1155. (ansi-term)
  1156. (comint-send-string "*ansi-term*" "make\n")))
  1157. (set (make-local-variable 'company-backends) '(company-go))
  1158. (setq company-tooltip-limit 20
  1159. company-echo-delay 0
  1160. company-begin-commands '(self-insert-command))
  1161. (gorepl-mode)))
  1162. (defun set-exec-path-from-shell-PATH ()
  1163. (let ((path-from-shell (replace-regexp-in-string
  1164. "[ \t\n]*$"
  1165. ""
  1166. (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
  1167. (setenv "PATH" path-from-shell)
  1168. (setq eshell-path-env path-from-shell)
  1169. (setq exec-path (split-string path-from-shell path-separator))))
  1170. (when window-system (set-exec-path-from-shell-PATH))
  1171. (setenv "GOPATH" "/home/locust/go")
  1172. (add-to-list 'exec-path "/home/locust/go/bin")
  1173. (add-to-list 'exec-path "/usr/local/bin")
  1174. (defun setup-tide-mode ()
  1175. "Tide setup function."
  1176. (interactive)
  1177. (tide-setup)
  1178. (flycheck-mode +1)
  1179. (setq flycheck-check-syntax-automatically '(save mode-enabled))
  1180. (eldoc-mode +1)
  1181. (tide-hl-identifier-mode +1)
  1182. (company-mode +1))
  1183. ;; aligns annotation to the right hand side
  1184. (setq company-tooltip-align-annotations t)
  1185. ;; formats the buffer before saving
  1186. (add-hook 'before-save-hook 'tide-format-before-save)
  1187. (add-hook 'typescript-mode-hook #'setup-tide-mode)
  1188. (require 'typescript-mode)
  1189. (require 'tide)
  1190. (add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
  1191. (add-hook 'typescript-mode-hook
  1192. '(lambda ()
  1193. (set (make-local-variable 'company-backends) '(company-tide))
  1194. (setq company-tooltip-limit 20
  1195. company-echo-delay 0
  1196. company-begin-commands '(self-insert-command)
  1197. tide-format-options '(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t :placeOpenBraceOnNewLineForFunctions nil))
  1198. (tide-setup)))
  1199. (require 'web-mode)
  1200. (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
  1201. (add-hook 'web-mode-hook
  1202. (lambda ()
  1203. (when (string-equal "tsx" (file-name-extension buffer-file-name))
  1204. (setup-tide-mode))))
  1205. ;; enable typescript-tslint checker
  1206. (flycheck-add-mode 'typescript-tslint 'web-mode)
  1207. (require 'web-mode)
  1208. (add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
  1209. (add-hook 'web-mode-hook
  1210. (lambda ()
  1211. (when (string-equal "jsx" (file-name-extension buffer-file-name))
  1212. (setup-tide-mode))))
  1213. ;; configure jsx-tide checker to run after your default jsx checker
  1214. (flycheck-add-mode 'javascript-eslint 'web-mode)
  1215. (flycheck-add-next-checker 'javascript-eslint 'jsx-tide 'append)
  1216. (org-babel-do-load-languages
  1217. 'org-babel-load-languages
  1218. '((js . t)
  1219. (shell . t)
  1220. (emacs-lisp . t)))
  1221. (setq org-todo-keywords
  1222. '((sequence "TODO(t)" "|" "DONE(d)")
  1223. (sequence "BUG(b)" "|" "INPROGRESS(i)" "FIXED(f)")
  1224. (sequence "TEST(T)" "NOTEST(N)" "|" "COMPLETE(C)")
  1225. (sequence "|" "CANCELED(c)")
  1226. (sequence "|" "NEEDCLARIFICATION(n)")
  1227. (sequence "|" "PROVIDEUPDATE(p)")
  1228. (sequence "|" "WAITING(w)")
  1229. ))
  1230. (setq org-agenda-files
  1231. '("~/Dropbox/Org/todo.org"
  1232. "~/Dropbox/Org/archive.org"
  1233. "~/Dropbox/Org/diary/eaglecrk.org"))
  1234. (setq org-refile-targets
  1235. '((nil :maxlevel . 3)
  1236. (org-agenda-files :maxlevel . 3)))
  1237. ;; (add-hook 'focus-in-hook
  1238. ;; (lambda () (progn
  1239. ;; (setq org-tags-column (- 5 (frame-width)))) (org-align-all-tags)))
  1240. ;; (add-hook 'focus-out-hook
  1241. ;; (lambda () (progn
  1242. ;; (setq org-tags-column (- 5 (frame-width)))) (org-align-all-tags)))
  1243. (defvar org-src-tab-acts-natively)
  1244. (setq org-src-tab-acts-natively t)
  1245. (defvar org-confirm-babel-evaluate)
  1246. (defun my-org-confirm-babel-evaluate (lang _body)
  1247. "Execute certain languages without confirming.
  1248. Takes LANG to allow and BODY to execute."
  1249. (not (or (string= lang "js")
  1250. (string= lang "restclient")
  1251. (string= lang "emacs-lisp")
  1252. (string= lang "elisp")
  1253. (string= lang "sh")
  1254. (string= lang "shell"))))
  1255. (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
  1256. (add-to-list 'org-structure-template-alist
  1257. (list "e" (concat "#+BEGIN_SRC emacs-lisp :results silent\n"
  1258. "\n"
  1259. "#+END_SRC")))
  1260. (add-to-list 'org-structure-template-alist
  1261. (list "j" (concat "#+BEGIN_SRC js :cmd \"/usr/local/bin/babel-node\" :results output code\n"
  1262. "\n"
  1263. "#+END_SRC")))
  1264. (add-to-list 'org-structure-template-alist
  1265. (list "r" (concat "#+BEGIN_SRC restclient :results raw\n"
  1266. "\n"
  1267. "#+END_SRC")))
  1268. (setq org-directory "~/Dropbox/Org"
  1269. org-default-notes-file (concat org-directory "/todo.org")
  1270. org-startup-folded t
  1271. org-startup-indented t
  1272. org-startup-align-all-tables t
  1273. org-startup-with-inline-images t
  1274. org-startup-with-latex-preview t
  1275. org-log-done t
  1276. org-log-done-with-time t
  1277. org-log-into-drawer t
  1278. org-hide-leading-stars t
  1279. org-pretty-entities t
  1280. org-use-property-inheritance t
  1281. org-html-validation-link nil
  1282. org-html-text-markup-alist '((bold . "<b>%s</b>")
  1283. (code . "<code>%s</code>")
  1284. (italic . "<i>%s</i>")
  1285. (strike-through . "<del>%s</del>")
  1286. (underline . "<span class=\"underline\">%s</span>")
  1287. (verbatim . "<code class=\"verbatim\">%s</code>"))
  1288. )
  1289. (require 'org-protocol)
  1290. ;; Ensure the following is in ~/.config/mimeapps.list
  1291. ;;
  1292. ;; [Default Applications]
  1293. ;; x-scheme-handler/org-protocol=userapp-emacsclient.desktop
  1294. (setq org-capture-templates
  1295. '(("t" "new task" entry (file+headline "~/Dropbox/Org/todo.org" "Tasks")
  1296. "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
  1297. ("n" "new note" entry (file+headline org-default-notes-file "Notes")
  1298. "* %?\n%i\n")
  1299. ("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
  1300. "* %a\n%?\n")
  1301. ("d" "store link w/drawer" entry (file+olp org-default-notes-file "Links" "Unfiled")
  1302. "* %?\n%l\n:COPIED_TEXT:\n %i\n:END:\n")
  1303. ("f" "dotfile" entry (file+headline "~/Dropbox/Org/dotfiles.org" "Other")
  1304. "* %?\n:PROPERTIES:\n:CUSTOM_ID: %(org-id-get-create)\n:END:\n")
  1305. ))
  1306. (defun my-org-config ()
  1307. "Activate org and yas in 'org-mode' buffers."
  1308. (yas-minor-mode)
  1309. (lambda ()
  1310. (local-set-key (kbd "M-RET") 'org-insert-todo-heading)
  1311. (global-set-key (kbd "C-c c") nil)
  1312. (local-set-key (kbd "C-c c i") 'org-clock-in)
  1313. (local-set-key (kbd "C-c c o") 'org-clock-out)
  1314. )
  1315. )
  1316. (add-hook 'org-mode-hook #'my-org-config)
  1317. (require 'ox-reveal)
  1318. (setq org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js"
  1319. org-reveal-klipsify-src t)
  1320. ;;store org-mode links to messages
  1321. (require 'org-mu4e)
  1322. ;;store link to message if in header view, not to header query
  1323. (setq org-mu4e-link-query-in-headers-mode nil)
  1324. (elfeed-org)
  1325. (setq rmh-elfeed-org-files (list "~/Dropbox/Org/elfeed.org"))
  1326. (defun leo/elfeed-search (arg)
  1327. "Search for ARG in feed."
  1328. (interactive)
  1329. (elfeed-search-set-filter arg))
  1330. (define-key elfeed-search-mode-map "a" (lambda () (interactive) (leo/elfeed-search "")))
  1331. (define-key elfeed-search-mode-map "e" (lambda () (interactive) (leo/elfeed-search "+emacs")))
  1332. (define-key elfeed-search-mode-map "d" (lambda () (interactive) (leo/elfeed-search "+daily")))
  1333. (define-key elfeed-search-mode-map "x" (lambda () (interactive) (leo/elfeed-search "xkcd")))
  1334. ;; Enable ligatures without prettify-symbols
  1335. (provide 'add-pragmatapro-symbol-keywords)
  1336. (defconst pragmatapro-fontlock-keywords-alist
  1337. (mapcar (lambda (regex-char-pair)
  1338. `(,(car regex-char-pair)
  1339. (0 (prog1 ()
  1340. (compose-region (match-beginning 1)
  1341. (match-end 1)
  1342. ,(concat (list ?\C-i)
  1343. (list (decode-char 'ucs (cadr regex-char-pair)))))))))
  1344. '(("\\(\\[ERROR\\]\\)" #XE380)
  1345. ("\\(\\[DEBUG\\]\\)" #XE381)
  1346. ("\\(\\[INFO\\]\\)" #XE382)
  1347. ("\\(\\[WARN\\]\\)" #XE383)
  1348. ("\\(\\[WARNING\\]\\)" #XE384)
  1349. ("\\(\\[ERR\\]\\)" #XE385)
  1350. ("\\(\\[FATAL\\]\\)" #XE386)
  1351. ("\\(\\[TRACE\\]\\)" #XE387)
  1352. ("\\(!!\\)" #XE900)
  1353. ("\\(!=\\)" #XE901)
  1354. ("\\(!==\\)" #XE902)
  1355. ("\\(!!!\\)" #XE903)
  1356. ("\\(!≡\\)" #XE904)
  1357. ("\\(!≡≡\\)" #XE905)
  1358. ("[^<]\\(!>\\)" #XE906)
  1359. ("\\(#(\\)" #XE920)
  1360. ("\\(#_\\)" #XE921)
  1361. ("\\(#{\\)" #XE922)
  1362. ("\\(#\\?\\)" #XE923)
  1363. ("[^<]\\(#>\\)" #XE924)
  1364. ("\\(##\\)" #XE925)
  1365. ("\\(%=\\)" #XE930)
  1366. ("[^<]\\(%>\\)" #XE931)
  1367. ("\\(&%\\)" #XE940)
  1368. ("\\(&&\\)" #XE941)
  1369. ("\\(&\\*\\)" #XE942)
  1370. ("\\(&\\+\\)" #XE943)
  1371. ("\\(&-\\)" #XE944)
  1372. ("\\(&/\\)" #XE945)
  1373. ("\\(&=\\)" #XE946)
  1374. ("\\(&&&\\)" #XE947)
  1375. ("[^<]\\(&>\\)" #XE948)
  1376. ("\\(\\*\\*\\*\\)" #XE960)
  1377. ("\\(\\*=\\)" #XE961)
  1378. ("\\(\\*/\\)" #XE962)
  1379. ("[^<]\\(\\*>\\)" #XE963)
  1380. ("\\(\\+\\+\\)" #XE970)
  1381. ("\\(\\+\\+\\+\\)" #XE971)
  1382. ("[^\\+]\\(\\+=\\)" #XE972)
  1383. ("[^<]\\(\\+>\\)" #XE973)
  1384. ("\\(\\+\\+=\\)" #XE974)
  1385. ("\\(--\\)" #XE980)
  1386. ("[^-]\\(-<\\)" #XE981)
  1387. ("\\(-<<\\)" #XE982)
  1388. ("\\(-=\\)" #XE983)
  1389. ("[^|]\\(->\\)" #XE984)
  1390. ("[^|]\\(->>\\)" #XE985)
  1391. ("\\(---\\)" #XE986)
  1392. ("\\(-->\\)" #XE987)
  1393. ("\\(-\\+-\\)" #XE988)
  1394. ("\\(-\\\\/\\)" #XE989)
  1395. ("[^\\^]\\(\\.\\.\\)" #XE990)
  1396. ("\\(\\.\\.\\.\\)" #XE991)
  1397. ("\\(\\.\\.<\\)" #XE992)
  1398. ("\\(\\.>\\)" #XE993)
  1399. ("\\(\\.~\\)" #XE994)
  1400. ("\\(\\.=\\)" #XE995)
  1401. ("\\(/\\*\\)" #XE9A0)
  1402. ("\\(//\\)" #XE9A1)
  1403. ("[^<]\\(/>\\)" #XE9A2)
  1404. ("[^=]\\(/=\\)" #XE9A3)
  1405. ("\\(/==\\)" #XE9A4)
  1406. ("\\(///\\)" #XE9A5)
  1407. ("\\(/\\*\\*\\)" #XE9A6)
  1408. ("\\(::\\)" #XE9B0)
  1409. ("\\(:=\\)" #XE9B1)
  1410. ("[^≡]\\(:≡\\)" #XE9B2)
  1411. ("\\(:>\\)" #XE9B3)
  1412. ("\\(:=>\\)" #XE9B4)
  1413. ("\\(<\\*\\)" #XE9C1)
  1414. ("\\(<\\*>\\)" #XE9C2)
  1415. ("[^<]\\(<-\\)" #XE9C4)
  1416. ("[^-]\\(<<\\)" #XE9C5)
  1417. ("\\(<<<\\)" #XE9C6)
  1418. ("\\(<<=\\)" #XE9C7)
  1419. ("[^<]\\(<=\\)" #XE9C8)
  1420. ("\\(<=>\\)" #XE9C9)
  1421. ("\\(<>\\)" #XE9CA)
  1422. ("\\(<<-\\)" #XE9CC)
  1423. ("\\(<|\\)" #XE9CD)
  1424. ("\\(<|>\\)" #XE9CB)
  1425. ("\\(<=<\\)" #XE9CE)
  1426. ("[^<]\\(<~\\)" #XE9CF)
  1427. ("\\(<~~\\)" #XE9D0)
  1428. ("\\(<<~\\)" #XE9D1)
  1429. ("\\(<\\$\\)" #XE9D2)
  1430. ("\\(<\\$>\\)" #XE9C0)
  1431. ("\\(<\\+\\)" #XE9D3)
  1432. ("\\(<\\+>\\)" #XE9C3)
  1433. ("\\(<~>\\)" #XE9E0)
  1434. ("\\(<\\*\\*>\\)" #XE9E1)
  1435. ("\\(<<\\^\\)" #XE9E2)
  1436. ("\\(<!\\)" #XE9E3)
  1437. ("\\(<!>\\)" #XE9D4)
  1438. ("\\(<@\\)" #XE9E4)
  1439. ("\\(<#\\)" #XE9E5)
  1440. ("\\(<#>\\)" #XE9D6)
  1441. ("\\(<%\\)" #XE9E6)
  1442. ("\\(<%>\\)" #XE9D7)
  1443. ("[^<]\\(<\\^\\)" #XE9E7)
  1444. ("\\(<&\\)" #XE9E8)
  1445. ("\\(<&>\\)" #XE9D9)
  1446. ("\\(<\\?\\)" #XE9E9)
  1447. ("\\(<\\.\\)" #XE9EA)
  1448. ("\\(<\\.>\\)" #XE9DB)
  1449. ("\\(</\\)" #XE9EB)
  1450. ("\\(</>\\)" #XE9DC)
  1451. ("\\(<\\\\\\)" #XE9EC)
  1452. ("\\(<\"\\)" #XE9ED)
  1453. ("\\(<\">\\)" #XE9DE)
  1454. ("\\(<:\\)" #XE9EE)
  1455. ("\\(<:>\\)" #XE9DF)
  1456. ("\\(<->\\)" #XE9EF)
  1457. ("\\(<!--\\)" #XE9F0)
  1458. ("\\(<--\\)" #XE9F1)
  1459. ("\\(<~<\\)" #XE9F2)
  1460. ("\\(<==>\\)" #XE9F3)
  1461. ("\\(==<\\)" #XEA00)
  1462. ("[^/!<=>]\\(==\\)[^><=]" #XEA01)
  1463. ("\\(===\\)" #XEA02)
  1464. ("[^<]\\(==>\\)" #XEA03)
  1465. ("[^=:<]\\(=>\\)" #XEA04)
  1466. ("\\(=~\\)" #XEA05)
  1467. ("\\(=>>\\)" #XEA06)
  1468. ("\\(=/=\\)" #XEA07)
  1469. ("[^!]\\(≡≡\\)" #XEA10)
  1470. ("\\(≡≡≡\\)" #XEA11)
  1471. ("\\(≡:≡\\)" #XEA12)
  1472. ("[^>]\\(>-\\)" #XEA20)
  1473. ("\\(>=\\)" #XEA21)
  1474. ("[^=-]\\(>>\\)" #XEA22)
  1475. ("\\(>>-\\)" #XEA23)
  1476. ("\\(>==\\)" #XEA24)
  1477. ("\\(>>>\\)" #XEA25)
  1478. ("\\(>=>\\)" #XEA26)
  1479. ("\\(>>\\^\\)" #XEA27)
  1480. ("\\(\\?\\?\\)" #XEA40)
  1481. ("\\(\\?~\\)" #XEA41)
  1482. ("\\(\\?=\\)" #XEA42)
  1483. ("\\(\\?>\\)" #XEA43)
  1484. ("\\(<\\?>\\)" #XE9DA)
  1485. ("\\(\\?\\?\\?\\)" #XEA44)
  1486. ("\\(\\^=\\)" #XEA48)
  1487. ("\\(\\^\\.\\)" #XEA49)
  1488. ("\\(\\^\\?\\)" #XEA4A)
  1489. ("\\(\\^\\.\\.\\)" #XEA4B)
  1490. ("\\(\\^<<\\)" #XEA4C)
  1491. ("\\(\\^>\\)" #XEA4E)
  1492. ("\\(\\^>>\\)" #XEA4D)
  1493. ("\\(<\\^>\\)" #XE9D8)
  1494. ("[^\\\\]\\(\\\\\\\\\\)" #XEA50)
  1495. ("[^<]\\(\\\\>\\)" #XEA51)
  1496. ("\\(<\\\\>\\)" #XE9DD)
  1497. ("\\(\\\\/-\\)" #XEA52)
  1498. ("\\(@>\\)" #XEA57)
  1499. ("\\(<@>\\)" #XE9D5)
  1500. ("\\(|=\\)" #XEA60)
  1501. ("\\(||\\)" #XEA61)
  1502. ("[^<]\\(|>\\)" #XEA62)
  1503. ("\\(|||\\)" #XEA63)
  1504. ("\\(|\\+|\\)" #XEA64)
  1505. ("\\(|->\\)" #XEA65)
  1506. ("\\(|-->\\)" #XEA66)
  1507. ("\\(|=>\\)" #XEA67)
  1508. ("\\(|==>\\)" #XEA68)
  1509. ("\\(~=\\)" #XEA70)
  1510. ("[^~<]\\(~>\\)" #XEA71)
  1511. ("\\(~~>\\)" #XEA72)
  1512. ("\\(~>>\\)" #XEA73)
  1513. ("[^<]\\(\">\\)" #XEA90))))
  1514. (defun add-pragmatapro-symbol-keywords ()
  1515. (font-lock-add-keywords nil pragmatapro-fontlock-keywords-alist))
  1516. (add-hook 'prog-mode-hook
  1517. #'add-pragmatapro-symbol-keywords)
  1518. ;; Enable Org mode checkbox ligatures without prettify-symbols
  1519. (provide 'add-checkbox-symbol-keywords)
  1520. (defconst checkbox-fontlock-keywords-alist
  1521. (mapcar (lambda (regex-char-pair)
  1522. `(,(car regex-char-pair)
  1523. (0 (prog1 ()
  1524. (compose-region (match-beginning 1)
  1525. (match-end 1)
  1526. ,(concat (list ?\C-i)
  1527. (list (decode-char 'ucs (cadr regex-char-pair)))))))))
  1528. '(("\\(\\[ \\]\\)" #XF096);2B1C
  1529. ("\\(\\[-\\]\\)" #XF147);29C7;F458
  1530. ("\\(\\[X\\]\\)" #XF046);2BBD
  1531. )))
  1532. (defun add-checkbox-symbol-keywords ()
  1533. (font-lock-add-keywords nil checkbox-fontlock-keywords-alist))
  1534. (add-hook 'org-mode-hook
  1535. #'add-checkbox-symbol-keywords)
  1536. ;; All ligatures (for testing)
  1537. ;; [ERROR]
  1538. ;; [DEBUG]
  1539. ;; [INFO]
  1540. ;; [WARN]
  1541. ;; [WARNING]
  1542. ;; [ERR]
  1543. ;; [FATAL]
  1544. ;; [TRACE]
  1545. ;; !!
  1546. ;; !=
  1547. ;; !==
  1548. ;; !!!
  1549. ;; !≡
  1550. ;; !≡≡
  1551. ;; !>
  1552. ;; #(
  1553. ;; #_
  1554. ;; #{
  1555. ;; #?
  1556. ;; #>
  1557. ;; ##
  1558. ;; %=
  1559. ;; %>
  1560. ;; &%
  1561. ;; &&
  1562. ;; &*
  1563. ;; &+
  1564. ;; &-
  1565. ;; &/
  1566. ;; &=
  1567. ;; &&&
  1568. ;; &>
  1569. ;; ***
  1570. ;; *=
  1571. ;; */
  1572. ;; *>
  1573. ;; ++
  1574. ;; +++
  1575. ;; +=
  1576. ;; +>
  1577. ;; ++=
  1578. ;; --
  1579. ;; -<
  1580. ;; -<<
  1581. ;; -=
  1582. ;; ->
  1583. ;; ->>
  1584. ;; ---
  1585. ;; -->
  1586. ;; -+-
  1587. ;; -\/
  1588. ;; ..
  1589. ;; ...
  1590. ;; ..<
  1591. ;; .>
  1592. ;; .~
  1593. ;; .=
  1594. ;; /*
  1595. ;; //
  1596. ;; />
  1597. ;; /=
  1598. ;; /==
  1599. ;; ///
  1600. ;; /**
  1601. ;; ::
  1602. ;; :=
  1603. ;; :≡
  1604. ;; :>
  1605. ;; :=>
  1606. ;; <$>
  1607. ;; <*
  1608. ;; <*>
  1609. ;; <+>
  1610. ;; <-
  1611. ;; <<
  1612. ;; <<<
  1613. ;; <<=
  1614. ;; <=
  1615. ;; <=>
  1616. ;; <>
  1617. ;; <|>
  1618. ;; <<-
  1619. ;; <|
  1620. ;; <=<
  1621. ;; <~
  1622. ;; <~~
  1623. ;; <<~
  1624. ;; <$
  1625. ;; <+
  1626. ;; <!>
  1627. ;; <@>
  1628. ;; <#>
  1629. ;; <%>
  1630. ;; <^>
  1631. ;; <&>
  1632. ;; <?>
  1633. ;; <.>
  1634. ;; </>
  1635. ;; <\>
  1636. ;; <">
  1637. ;; <:>
  1638. ;; <~>
  1639. ;; <**>
  1640. ;; <<^
  1641. ;; <!
  1642. ;; <@
  1643. ;; <#
  1644. ;; <%
  1645. ;; <^
  1646. ;; <&
  1647. ;; <?
  1648. ;; <.
  1649. ;; </
  1650. ;; <\
  1651. ;; <"
  1652. ;; <:
  1653. ;; <->
  1654. ;; <!--
  1655. ;; <--
  1656. ;; <~<
  1657. ;; <==>
  1658. ;; ==<
  1659. ;; ==
  1660. ;; ===
  1661. ;; ==>
  1662. ;; =>
  1663. ;; =~
  1664. ;; =>>
  1665. ;; =/=
  1666. ;; ≡≡
  1667. ;; ≡≡≡
  1668. ;; ≡:≡
  1669. ;; >-
  1670. ;; >=
  1671. ;; >>
  1672. ;; >>-
  1673. ;; >==
  1674. ;; >>>
  1675. ;; >=>
  1676. ;; >>^
  1677. ;; ??
  1678. ;; ?~
  1679. ;; ?=
  1680. ;; ?>
  1681. ;; ???
  1682. ;; ^=
  1683. ;; ^.
  1684. ;; ^?
  1685. ;; ^..
  1686. ;; ^<<
  1687. ;; ^>>
  1688. ;; ^>
  1689. ;; \\
  1690. ;; \>
  1691. ;; \/-
  1692. ;; @>
  1693. ;; |=
  1694. ;; ||
  1695. ;; |>
  1696. ;; |||
  1697. ;; |+|
  1698. ;; |->
  1699. ;; |-->
  1700. ;; |=>
  1701. ;; |==>
  1702. ;; ~=
  1703. ;; ~>
  1704. ;; ~~>
  1705. ;; ~>>
  1706. ;; ">
  1707. (cond ((member "PragmataPro Liga" (font-family-list))
  1708. (set-face-attribute 'default nil :font "PragmataPro Liga-13")))
  1709. ;; (cond ((member "IBM Plex Mono Thin" (font-family-list))
  1710. ;; (set-face-attribute 'default nil :font "IBM Plex Mono Thin-13")))
  1711. ;; (cond ((member "IBM Plex Mono" (font-family-list))
  1712. ;; (set-face-attribute 'default nil :font "IBM Plex Mono-12")))
  1713. (add-hook 'org-mode-hook 'org-bullets-mode)
  1714. (set-face-attribute 'org-level-1 nil :height 1.3)
  1715. (set-face-attribute 'org-level-2 nil :height 1.1)
  1716. (set-face-attribute 'org-level-3 nil :height 1.05)
  1717. (set-face-attribute 'org-level-4 nil :height 1.05)
  1718. (set-face-attribute 'org-scheduled-today nil :height 1.0)
  1719. (set-face-attribute 'org-agenda-date-today nil :height 1.1)
  1720. ;; (set-face-attribute 'org-table nil :foreground "#008787")
  1721. (require 'doom-modeline)
  1722. (doom-modeline-mode 1)
  1723. ;; How tall the mode-line should be (only respected in GUI Emacs).
  1724. (setq doom-modeline-height 30)
  1725. ;; How wide the mode-line bar should be (only respected in GUI Emacs).
  1726. (setq doom-modeline-bar-width 4)
  1727. ;; Determines the style used by `doom-modeline-buffer-file-name'.
  1728. ;;
  1729. ;; Given ~/Projects/FOSS/emacs/lisp/comint.el
  1730. ;; truncate-upto-project => ~/P/F/emacs/lisp/comint.el
  1731. ;; truncate-from-project => ~/Projects/FOSS/emacs/l/comint.el
  1732. ;; truncate-with-project => emacs/l/comint.el
  1733. ;; truncate-except-project => ~/P/F/emacs/l/comint.el
  1734. ;; truncate-upto-root => ~/P/F/e/lisp/comint.el
  1735. ;; truncate-all => ~/P/F/e/l/comint.el
  1736. ;; relative-from-project => emacs/lisp/comint.el
  1737. ;; relative-to-project => lisp/comint.el
  1738. ;; file-name => comint.el
  1739. ;; buffer-name => comint.el<2> (uniquify buffer name)
  1740. ;;
  1741. ;; If you are expereicing the laggy issue, especially while editing remote files
  1742. ;; with tramp, please try `file-name' style.
  1743. ;; Please refer to https://github.com/bbatsov/projectile/issues/657.
  1744. (setq doom-modeline-buffer-file-name-style 'truncate-upto-project)
  1745. ;; What executable of Python will be used (if nil nothing will be showed).
  1746. (setq doom-modeline-python-executable "python")
  1747. ;; Whether show `all-the-icons' or not (if nil nothing will be showed).
  1748. (setq doom-modeline-icon t)
  1749. ;; Whether show the icon for major mode. It respects `doom-modeline-icon'.
  1750. (setq doom-modeline-major-mode-icon t)
  1751. ;; Display color icons for `major-mode'. It respects `all-the-icons-color-icons'.
  1752. (setq doom-modeline-major-mode-color-icon nil)
  1753. ;; Whether display minor modes or not. Non-nil to display in mode-line.
  1754. (setq doom-modeline-minor-modes nil)
  1755. ;; If non-nil, a word count will be added to the selection-info modeline segment.
  1756. (setq doom-modeline-enable-word-count nil)
  1757. ;; If non-nil, only display one number for checker information if applicable.
  1758. (setq doom-modeline-checker-simple-format t)
  1759. ;; Whether display perspective name or not. Non-nil to display in mode-line.
  1760. (setq doom-modeline-persp-name t)
  1761. ;; Whether display `lsp' state or not. Non-nil to display in mode-line.
  1762. (setq doom-modeline-lsp t)
  1763. ;; Whether display github notifications or not. Requires `ghub` package.
  1764. (setq doom-modeline-github nil)
  1765. ;; The interval of checking github.
  1766. (setq doom-modeline-github-interval (* 30 60))
  1767. ;; Whether display environment version or not.
  1768. (setq doom-modeline-env-version t)
  1769. ;; Whether display mu4e notifications or not. Requires `mu4e-alert' package.
  1770. (setq doom-modeline-mu4e t)