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.

2934 lines
102 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. ox-reveal
  60. poporg
  61. projectile
  62. rainbow-delimiters
  63. rust-mode
  64. shrink-path
  65. tide
  66. typescript-mode
  67. ;; use-package
  68. web-mode
  69. which-key))
  70. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
  71. (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/"))
  72. (when (not package-archive-contents)
  73. (package-refresh-contents))
  74. (package-initialize)
  75. (dolist (p my-packages)
  76. (when (not (package-installed-p p))
  77. (package-install p)))
  78. (server-start)
  79. (require 'better-defaults)
  80. ;; Instead of the annoying giant warning icon, just flash the modeline.
  81. ;; (this happens when you do something like C-g)
  82. (setq ring-bell-function
  83. (lambda ()
  84. (let ((orig-fg (face-foreground 'mode-line)))
  85. (set-face-foreground 'mode-line "#F2804F")
  86. (run-with-idle-timer 0.1 nil
  87. (lambda (fg) (set-face-foreground 'mode-line fg))
  88. orig-fg))))
  89. (defun set-frame-size-according-to-resolution ()
  90. "Set the Emacs window size on startup."
  91. (interactive)
  92. (if window-system
  93. (progn
  94. ;; WIDTH
  95. (if (> (x-display-pixel-width) 1280)
  96. ;; Large Screen (only show 120 cols)
  97. (add-to-list 'default-frame-alist (cons 'width 240))
  98. ;; Small Screen (fill window)
  99. (add-to-list 'default-frame-alist (cons 'width (/ (x-display-pixel-width) (frame-char-width)))))
  100. ;; HEIGHT
  101. (if (> (x-display-pixel-height) 1080)
  102. ;; Large Screen (only fill half screen)
  103. (add-to-list 'default-frame-alist (cons 'height (/ (/ (x-display-pixel-height) 2)
  104. (frame-char-height))))
  105. ;; Small Screen (fill window)
  106. (add-to-list 'default-frame-alist (cons 'height (/ (x-display-pixel-height) (frame-char-height)))))
  107. )))
  108. ;; (set-frame-size-according-to-resolution)
  109. (defun window-px-width ()
  110. "Get the width of the Emacs window in pixels."
  111. (interactive)
  112. (* (* (window-total-width) 2.874) (frame-char-width)))
  113. (defun window-px-left-pos ()
  114. "Calculate the left position of the Emacs window."
  115. (interactive)
  116. (/ (- (x-display-pixel-width) (window-px-width)) 2))
  117. ;; (add-to-list 'default-frame-alist (cons 'top 0))
  118. ;; (add-to-list 'default-frame-alist (cons 'left 1000))
  119. (put 'narrow-to-region 'disabled nil)
  120. (put 'upcase-region 'disabled nil)
  121. (put 'downcase-region 'disabled nil)
  122. (require 'dashboard)
  123. (dashboard-setup-startup-hook)
  124. ;; Set the title
  125. (setq dashboard-banner-logo-title "Let's begin...")
  126. ;; Set the banner
  127. (setq dashboard-startup-banner "~/.emacs.d/public/emacs-logo-350.png")
  128. ;; Value can be
  129. ;; 'official which displays the official emacs logo
  130. ;; 'logo which displays an alternative emacs logo
  131. ;; 1, 2 or 3 which displays one of the text banners
  132. ;; "path/to/your/image.png" which displays whatever image you would prefer
  133. ;; Content is not centered by default. To center, set
  134. (setq dashboard-center-content t)
  135. ;; To enable shortcut "jump" indicators for each section, set
  136. (setq dashboard-show-shortcuts t)
  137. (setq show-week-agenda-p t)
  138. (setq dashboard-org-agenda-categories '("work" "tasks"))
  139. (setq dashboard-items '((recents . 10)
  140. (bookmarks . 5)
  141. (projects . 5)
  142. ;; (agenda . 5)
  143. ;; (registers . 5)
  144. ))
  145. (add-to-list 'dashboard-items '(agenda) t)
  146. (defvar backup-dir (expand-file-name "~/.emacs.d/backup/"))
  147. (defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/"))
  148. (setq initial-scratch-message nil
  149. backup-directory-alist (list (cons ".*" backup-dir))
  150. auto-save-list-file-prefix autosave-dir
  151. auto-save-file-name-transforms `((".*" ,autosave-dir t)))
  152. (menu-bar-mode 0)
  153. (scroll-bar-mode 0)
  154. (tool-bar-mode 0)
  155. (setq auth-sources '("~/.authinfo.gpg"))
  156. (set-default 'truncate-lines t)
  157. (setq fill-column 80)
  158. ;; (add-hook 'text-mode-hook
  159. ;; (lambda ()
  160. ;; (when (y-or-n-p "Auto Fill mode? ")
  161. ;; (turn-on-auto-fill))))
  162. (setq whitespace-style '(face empty tabs lines-tail trailing))
  163. (global-whitespace-mode t)
  164. ;; (load-theme 'doom-city-lights t)
  165. ;; (load-theme 'doom-dracula t)
  166. ;; (load-theme 'doom-nord t)
  167. (load-theme 'doom-one t)
  168. ;; (load-theme 'doom-spacegrey t)
  169. ;; (load-theme 'base16-ocean t)
  170. (load-theme 'base16-onedark t)
  171. (global-linum-mode t)
  172. (global-auto-revert-mode t)
  173. (defalias 'yes-or-no-p 'y-or-n-p)
  174. (defvar diary-file (expand-file-name "~/.emacs.d/diary/main"))
  175. (add-hook 'diary-list-entries-hook 'diary-sort-entries t)
  176. (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
  177. (add-hook 'diary-mark-entries-hook 'diary-mark-included-diary-files)
  178. (add-hook 'calendar-today-visible-hook 'calendar-mark-today)
  179. (setq calendar-latitude 44
  180. calendar-longitude -97
  181. calendar-location-name "Hayti, SD")
  182. (require 'font-lock)
  183. (defvar openhab-mode-hook nil)
  184. (defvar openhab-mode-map
  185. (let ((map (make-keymap)))
  186. (define-key map "\C-j" 'newline-and-indent)
  187. map)
  188. "Keymap for OPENHAB major mode.")
  189. (add-to-list 'auto-mode-alist '("\\.sitemap\\'" . openhab-mode))
  190. (add-to-list 'auto-mode-alist '("\\.items\\'" . openhab-mode))
  191. (add-to-list 'auto-mode-alist '("\\.rules\\'" . openhab-mode))
  192. (add-to-list 'auto-mode-alist '("\\.things\\'" . openhab-mode))
  193. (defconst openhab-font-lock-keywords
  194. `(
  195. ("\<.*\>" . font-lock-constant-face)
  196. (,(regexp-opt
  197. '(
  198. ;; KEYWORDS
  199. "Selection" "Slider" "List" "Setpoint" "Video" "Chart" "Webview" "Colorpicker"
  200. "Timer" "Number" "String"
  201. "Switch" "Rollershutter" "Number" "String" "Dimmer" "Contact" "DateTime" "Color"
  202. "Text" "Group" "Image" "Frame"
  203. "Thing" "Bridge"
  204. "Time" "System"
  205. "sitemap"
  206. "rule" "when" "then" "end"
  207. "if" "val"
  208. "import" "var" "say" "postUpdate" "switch" "println" "case" "or" "sendCommand"
  209. )
  210. 'words)
  211. (1 font-lock-keyword-face))
  212. (,(regexp-opt
  213. '(
  214. "ON" "OFF" "on" "off"
  215. "AND" "OR" "NAND" "NOR" "AVG" "SUM" "MAX" "MIN"
  216. "true" "false"
  217. )
  218. 'words)
  219. (1 font-lock-constant-face))
  220. (,(regexp-opt
  221. '(
  222. "name" "label" "item" "period" "refresh" "icon" "mappings" "minValue" "maxValue" "step" "switchsupport" "url" "height" "refresh" "visibility" "valuecolor"
  223. )
  224. 'words)
  225. (1 font-lock-type-face))
  226. ("\(.*\)" . font-lock-variable-name-face)
  227. ("[^a-zA-Z0-9_:]\\([0-9]*\\)[^a-zA-Z0-9_:]" . (1 font-lock-variable-name-face))
  228. ("\s@\s" . font-lock-variable-name-face)
  229. ("\s\\([a-zA-Z0-9_:]*\\)\\(\s\\|$\\)" . (1 font-lock-type-face))
  230. ("=\\([a-zA-Z_]*\\)" . (1 font-lock-string-face))
  231. ("\\([a-zA-Z]*\\)=" . (1 font-lock-type-face))
  232. )
  233. "The regexps to highlight in openHAB mode.")
  234. (defvar openhab-mode-syntax-table
  235. (let ((st (make-syntax-table)))
  236. (modify-syntax-entry ?/ ". 12b" st) ;; C-style comments // ...
  237. (modify-syntax-entry ?\n "> b" st) ;; \n ends comment
  238. ;; Block comments /*...*/
  239. (modify-syntax-entry ?\/ ". 14" st)
  240. (modify-syntax-entry ?* ". 23" st)
  241. st)
  242. "Syntax table for openhab-mode.")
  243. (defun openhab-mode ()
  244. "Major mode for editing OPENHAB config files."
  245. (interactive)
  246. (kill-all-local-variables)
  247. (set-syntax-table openhab-mode-syntax-table)
  248. (use-local-map openhab-mode-map)
  249. (set (make-local-variable 'font-lock-defaults) '(openhab-font-lock-keywords nil t))
  250. (electric-pair-mode -1)
  251. (flycheck-mode -1)
  252. (setq major-mode 'openhab-mode)
  253. (setq mode-name "OpenHAB")
  254. (run-hooks 'openhab-mode-hook))
  255. (provide 'openhab-mode)
  256. ;;; hyperspace.el --- Get there from here -*- lexical-binding: t; -*-
  257. ;; Copyright (C) 2017-2019 Ian Eure
  258. ;; Author: Ian Eure <ian@retrospec.tv>
  259. ;; URL: https://github.com/ieure/hyperspace-el
  260. ;; Version: 0.8.4
  261. ;; Package-Requires: ((emacs "25") (s "1.12.0"))
  262. ;; Keywords: tools, convenience
  263. ;; This program is free software; you can redistribute it and/or modify
  264. ;; it under the terms of the GNU General Public License as published by
  265. ;; the Free Software Foundation, either version 3 of the License, or
  266. ;; (at your option) any later version.
  267. ;; This program is distributed in the hope that it will be useful,
  268. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  269. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  270. ;; GNU General Public License for more details.
  271. ;; You should have received a copy of the GNU General Public License
  272. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  273. ;;; Commentary:
  274. ;; Hyperspace is a way to get nearly anywhere from wherever you are,
  275. ;; whether that's within Emacs or on the web. It's somewhere in
  276. ;; between Quicksilver and keyword URLs, giving you a single,
  277. ;; consistent interface to get directly where you want to go. It’s
  278. ;; for things that you use often, but not often enough to justify a
  279. ;; dedicated binding.
  280. ;;
  281. ;; When you enter Hyperspace, it prompts you where to go:
  282. ;;
  283. ;; HS:
  284. ;;
  285. ;; This prompt expects a keyword and a query. The keyword picks where
  286. ;; you want to go, and the remainder of the input is an optional
  287. ;; argument which can be used to further search or direct you within
  288. ;; that space.
  289. ;;
  290. ;; Some concrete examples:
  291. ;;
  292. ;; | *If you enter* | *then Hyperspace* |
  293. ;; |------------------+----------------------------------------------------------|
  294. ;; | "el" | opens info node "(elisp)Top" |
  295. ;; | "el eval-region" | searches for "eval-region" in the elisp Info index |
  296. ;; | "bb" | shows all BBDB entries |
  297. ;; | "bb kenneth" | shows all BBDB entries with a name matching "kenneth" |
  298. ;; | "ddg foo" | searches DuckDuckGo for "foo" using browse-url |
  299. ;; | "wp foo" | searches Wikipedia for "foo" using browse-url |
  300. ;;
  301. ;;; Code:
  302. (require 'subr-x)
  303. (require 's)
  304. ;; Action helpers
  305. (defun hyperspace-action->browse-url-pattern (pattern query)
  306. "Browse a URL former from PATTERN and QUERY."
  307. (browse-url (format pattern query)))
  308. (defun hyperspace-action->info (node &optional query)
  309. "Open an Info buffer for NODE.
  310. If QUERY is present, look it up in the index."
  311. (info node)
  312. (when query
  313. (Info-index query)))
  314. ;; Package definitions
  315. (defvar hyperspace-history nil
  316. "History of Hyperspace actions.")
  317. (defgroup hyperspace nil
  318. "Getting there from here"
  319. :prefix "hyperspace-"
  320. :group 'applications)
  321. (defcustom hyperspace-actions
  322. '(("ddg" . "https://duckduckgo.com/?q=%s")
  323. ("dis" . "https://duckduckgo.com/?q=%s&iax=images&ia=images")
  324. ("wp" . "https://en.wikipedia.org/wiki/%s")
  325. ("g" . "https://www.google.com/search?q=%s")
  326. ("gi" . "https://www.google.com/search?tbm=isch&q=%s")
  327. ("gm" . "https://www.google.com/maps/search/%s")
  328. ("yt" . "https://www.youtube.com/results?search_query=%s")
  329. ("clp" . "https://portland.craigslist.org/search/sss?query=%s")
  330. ("eb" . "https://www.ebay.com/sch/i.html?_nkw=%s")
  331. ("nf" . "https://www.netflix.com/search?q=%s")
  332. ("sh" . (lambda (query) (interactive) (shell-command query)))
  333. ("imdb" . "https://www.imdb.com/find?q=peter+jackson&s=all")
  334. ("bb" . bbdb-search-name)
  335. ("el" . (apply-partially #'hyperspace-action->info "(elisp)Top"))
  336. ("av" . apropos-variable)
  337. ("ac" . apropos-command)
  338. ("af" . (lambda (query) (apropos-command query t))))
  339. "Where Hyperspace should send you.
  340. Hyperspace actions are a cons of (KEYWORD . DISPATCHER). When
  341. Hyperspace is invoked, the keyword is extracted from the user
  342. input and looked up in this alist. The remainder of the
  343. string is passed to the dispatcher as its QUERY argument.
  344. DISPATCHER can be a function which performs the action.
  345. DISPATCHER can also be an expression which returns a function
  346. to perform the action.
  347. Finally, DISPATCHER can be a string with a URL pattern containing
  348. '%s'. The '%s' will be replaced with the query, and the URL browsed."
  349. :group 'hyperspace
  350. :type '(alist :key-type (string :tag "Keyword")
  351. :value-type (choice
  352. (function :tag "Function")
  353. (string :tag "URL Pattern")
  354. (sexp :tag "Expression"))))
  355. (defcustom hyperspace-default-action
  356. (caar hyperspace-actions)
  357. "A place to go if you don't specify one."
  358. :group 'hyperspace
  359. :type `(radio
  360. ,@(mapcar (lambda (action) (list 'const (car action))) hyperspace-actions)))
  361. (defcustom hyperspace-max-region-size 256
  362. "Maximum size of a region to consider for a Hyperspace query.
  363. If the region is active when Hyperspace is invoked, it's used
  364. as the default query, unless it's more than this number of
  365. characters."
  366. :group 'hyperspace
  367. :type 'integer)
  368. (defun hyperspace--cleanup (text)
  369. "Clean TEXT so it can be used for a Hyperspace query."
  370. (save-match-data
  371. (string-trim
  372. (replace-regexp-in-string (rx (1+ (or blank "\n"))) " " text))))
  373. (defun hyperspace--initial-text ()
  374. "Return the initial text.
  375. This is whatever's in the active region, but cleaned up."
  376. (when (use-region-p)
  377. (let* ((start (region-beginning))
  378. (end (region-end))
  379. (size (- end start)))
  380. (when (<= size hyperspace-max-region-size)
  381. (hyperspace--cleanup
  382. (buffer-substring-no-properties start end))))))
  383. (defun hyperspace--initial (initial-text)
  384. "Turn INITIAL-TEXT into INITIAL-CONTENTS for reading."
  385. (when initial-text (cons (concat " " initial-text) 1)))
  386. (defun hyperspace--process-input (text)
  387. "Process TEXT into an actionable keyword and query."
  388. (let ((kw-text (s-split-up-to "\\s-+" text 1)))
  389. (if (assoc (car kw-text) hyperspace-actions)
  390. kw-text
  391. (list hyperspace-default-action text))))
  392. (defun hyperspace--query ()
  393. "Ask the user for the Hyperspace action and query.
  394. Returns (KEYWORD . QUERY).
  395. If the region isn't active, the user is prompted for the
  396. action and query.
  397. If the region is active, its text is used as the initial value
  398. for the query, and the user enters the action.
  399. If a prefix argument is specified and the region is active,
  400. `HYPERSPACE-DEFAULT-ACTION' is chosen without prompting."
  401. (let ((initial (hyperspace--initial-text)))
  402. (if (and initial current-prefix-arg)
  403. (list hyperspace-default-action initial)
  404. (hyperspace--process-input
  405. (read-from-minibuffer "HS: " (hyperspace--initial initial) nil nil
  406. 'hyperspace-history)))))
  407. (defun hyperspace--evalable-p (form)
  408. "Can FORM be evaluated?"
  409. (and (listp form)
  410. (or (functionp (car form))
  411. (subrp (car form)))))
  412. (defun hyperspace--dispatch (action &optional query)
  413. "Execute ACTION, with optional QUERY argument."
  414. (pcase action
  415. ((pred functionp) (funcall action query))
  416. ((pred hyperspace--evalable-p) (funcall (eval action) query))
  417. ((pred stringp) (hyperspace-action->browse-url-pattern action query))
  418. (_ (error "Unknown action"))))
  419. ;;;###autoload
  420. (defun hyperspace (keyword &optional query)
  421. "Execute action for keyword KEYWORD, with optional QUERY."
  422. (interactive (hyperspace--query))
  423. (let ((action (cdr (assoc keyword hyperspace-actions))))
  424. (hyperspace--dispatch (or action hyperspace-default-action) query)))
  425. ;;;###autoload
  426. (defun hyperspace-enter (&optional query)
  427. "Enter Hyperspace, sending QUERY to the default action.
  428. If the region is active, use that as the query for
  429. hyperspace-default-action. Otherwise, prompt the user."
  430. (interactive (list (hyperspace--initial-text)))
  431. (hyperspace
  432. hyperspace-default-action
  433. (or query
  434. (read-from-minibuffer
  435. (format "HS: %s " hyperspace-default-action) nil nil
  436. 'hyperspace-history))))
  437. ;; Minor mode
  438. (defvar hyperspace-minor-mode-map
  439. (let ((kmap (make-sparse-keymap)))
  440. (define-key kmap (kbd "H-SPC") #'hyperspace)
  441. (define-key kmap (kbd "<H-return>") #'hyperspace-enter)
  442. kmap))
  443. ;;;###autoload
  444. (define-minor-mode hyperspace-minor-mode
  445. "Global (universal) minor mode to jump from here to there."
  446. nil nil hyperspace-minor-mode-map
  447. :group 'hyperspace
  448. :global t)
  449. (provide 'hyperspace)
  450. ;;; hyperspace.el ends here
  451. (require 'which-key)
  452. (which-key-setup-minibuffer)
  453. (which-key-mode)
  454. (require 'fic-mode)
  455. (add-hook 'js-mode-hook 'fic-mode)
  456. (require 'company)
  457. (add-hook 'after-init-hook 'global-company-mode)
  458. (setq company-dabbrev-downcase nil)
  459. (setq company-idle-delay 0.1)
  460. (require 'diminish)
  461. (diminish 'auto-revert-mode)
  462. (eval-after-load "company" '(diminish 'company-mode))
  463. (eval-after-load "counsel" '(diminish 'counsel-mode))
  464. (eval-after-load "elpy" '(diminish 'elpy-mode))
  465. (eval-after-load "go-mode" '(diminish 'go-mode))
  466. (eval-after-load "go-playground" '(diminish 'go-playground-mode))
  467. (eval-after-load "gorepl-mode" '(diminish 'gorepl-mode))
  468. (eval-after-load "flycheck" '(diminish 'flycheck-mode))
  469. (eval-after-load "ivy" '(diminish 'ivy-mode))
  470. (eval-after-load "projectile" '(diminish 'projectile-mode))
  471. (eval-after-load "which-key" '(diminish 'which-key-mode))
  472. (defun dired-mode-setup ()
  473. "Will run as hook for `dired-mode'."
  474. (dired-hide-details-mode nil))
  475. (add-hook 'dired-mode-hook 'dired-mode-setup)
  476. (require 'ivy-hydra)
  477. (require 'ivy)
  478. (require 'swiper)
  479. (ivy-mode 1)
  480. (counsel-mode)
  481. (setq ivy-use-virtual-buffers t
  482. enable-recursive-minibuffers t
  483. ivy-height 25
  484. ivy-initial-inputs-alist nil
  485. ivy-extra-directories nil)
  486. (global-set-key (kbd "C-s") 'swiper)
  487. (global-set-key (kbd "C-c C-r") 'ivy-resume)
  488. (global-set-key (kbd "M-x") 'counsel-M-x)
  489. (global-set-key (kbd "C-x C-f") 'counsel-find-file)
  490. (global-set-key (kbd "C-c g") 'counsel-git)
  491. (global-set-key (kbd "C-c j") 'counsel-git-grep)
  492. (global-set-key (kbd "C-c k") 'counsel-ag)
  493. (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
  494. (defun ivy-open-current-typed-path ()
  495. (interactive)
  496. (when ivy--directory
  497. (let* ((dir ivy--directory)
  498. (text-typed ivy-text)
  499. (path (concat dir text-typed)))
  500. (delete-minibuffer-contents)
  501. (ivy--done path))))
  502. (define-key ivy-minibuffer-map (kbd "<return>") 'ivy-alt-done)
  503. (define-key ivy-minibuffer-map (kbd "C-f") 'ivy-open-current-typed-path)
  504. (autoload 'ledger-mode "ledger-mode" "A major mode for Ledger" t)
  505. (add-to-list 'load-path
  506. (expand-file-name "/path/to/ledger/source/lisp/"))
  507. (add-to-list 'auto-mode-alist '("\\.ledger$" . ledger-mode))
  508. (require 'magit)
  509. (global-set-key (kbd "C-x g") 'magit-status)
  510. (global-set-key (kbd "C-c g") 'magit-status)
  511. (setq magit-completing-read-function 'ivy-completing-read)
  512. (add-to-list 'exec-path "/home/locust/.local/bin")
  513. (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu/mu4e")
  514. (require 'mu4e)
  515. (setq mu4e-maildir "~/Mail"
  516. mu4e-mu-binary "/usr/local/bin/mu"
  517. mu4e-change-filenames-when-moving t ;; Rename files when moving (required by mbsync)
  518. mu4e-compose-in-new-frame t ;; New compose gets new frame
  519. mu4e-context-policy 'pick-first
  520. mu4e-get-mail-command "mbsync -a" ;; MBSYNC is the mail cmd
  521. mu4e-html2text-command "/usr/local/bin/w3m -T text/html" ;; HTML to text command
  522. mu4e-headers-include-related nil ;; Stop threading in INBOX
  523. mu4e-sent-messages-behavior 'delete ;; Delete sent messages
  524. mu4e-update-interval 300 ;; 5 mins
  525. mu4e-use-fancy-chars t ;; use 'fancy' chars
  526. mu4e-user-mail-address-list '("lolson@eaglecrk.com"
  527. "lolson@vlocity.com"
  528. "olson.levi@gmail.com")
  529. mu4e-view-show-images t ;; attempt to show images
  530. mu4e-view-image-max-width 400 ;; max image size
  531. message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n" ;; customize the reply-quote-string
  532. message-citation-line-function 'message-insert-formatted-citation-line ;; choose to use the formatted string
  533. message-kill-buffer-on-exit t ;; don't keep messages around
  534. send-mail-function 'smtpmail-send-it ;; Default email send function
  535. smtpmail-default-smtp-server "smtp.gmail.com"
  536. smtpmail-smtp-service 587
  537. )
  538. ;; (defun leo/convert-message-set-point ()
  539. ;; "Set the point to the start of the message body."
  540. ;; (interactive)
  541. ;; (beginning-of-buffer)
  542. ;; (search-forward "--text follows this line--")
  543. ;; (forward-char)
  544. ;; )
  545. ;; (defun leo/convert-message-from-markdown ()
  546. ;; "Convert a markdown flavored mail buffer to html w/mime support."
  547. ;; (interactive)
  548. ;; (if (y-or-n-p "Convert to HTML? ")
  549. ;; ((leo/convert-message-set-point)
  550. ;; (save-excursion
  551. ;; (message-goto-body)
  552. ;; (shell-command-on-region (point) (point-max) "~/.emacs.d/scripts/expand-mime.sh" nil t)))
  553. ;; (message "Aborting."))
  554. ;; )
  555. (setq mu4e-contexts
  556. `(
  557. ;; ,(make-mu4e-context
  558. ;; :name "Vlocity"
  559. ;; :enter-func (lambda () (mu4e-message "Entering Vlocity"))
  560. ;; :leave-func (lambda () (mu4e-message "Leaving Vlocity"))
  561. ;; ;; we match based on the contact-fields of the message
  562. ;; :match-func (lambda (msg)
  563. ;; (when msg
  564. ;; (string= (mu4e-message-field msg :maildir) "/Vlocity")))
  565. ;; :vars '( ( user-mail-address . "lolson@vlocity.com" )
  566. ;; ( smtpmail-mail-address . "lolson@vlocity.com" )
  567. ;; ( smtpmail-smtp-user . "lolson@vlocity.com" )
  568. ;; ( smtpmail-smtp-server . "smtp.gmail.com" )
  569. ;; ( user-full-name . "Levi Olson" )
  570. ;; ( mu4e-compose-signature .
  571. ;; (concat
  572. ;; "Levi Olson\n"
  573. ;; "Senior UI Developer"))
  574. ;; ( mu4e-sent-folder . "/Vlocity/[Gmail].Sent Mail" )
  575. ;; ( mu4e-drafts-folder . "/Vlocity/[Gmail].Drafts" )
  576. ;; ( mu4e-trash-folder . "/Vlocity/[Gmail].Trash" )
  577. ;; ( mu4e-maildir-shortcuts . (("/Vlocity/INBOX" . ?i)
  578. ;; ("/Vlocity/[Gmail].Sent Mail" . ?s)
  579. ;; ("/Vlocity/[Gmail].Trash" . ?t)
  580. ;; ("/Vlocity/[Gmail].All Mail" . ?a)))))
  581. ,(make-mu4e-context
  582. :name "EagleCreek"
  583. :enter-func (lambda () (mu4e-message "Entering EagleCreek"))
  584. :leave-func (lambda () (mu4e-message "Leaving EagleCreek"))
  585. ;; we match based on the contact-fields of the message
  586. :match-func (lambda (msg)
  587. (when msg
  588. (string= (mu4e-message-field msg :maildir) "/eaglecrk")))
  589. :vars '( ( user-mail-address . "lolson@eaglecrk.com" )
  590. ( smtpmail-mail-address . "lolson@eaglecrk.com" )
  591. ( smtpmail-smtp-user . "lolson@eaglecrk.com" )
  592. ( smtpmail-smtp-server . "smtp.office365.com" )
  593. ( user-full-name . "Levi Olson" )
  594. ;; ( mu4e-compose-signature .
  595. ;; (concat
  596. ;; "Levi Olson\n"
  597. ;; "Eagle Creek Software Services\n"
  598. ;; "Senior Application Developer Consultant\n"))
  599. ( mu4e-sent-folder . "/eaglecrk/Sent Items" )
  600. ( mu4e-drafts-folder . "/eaglecrk/Drafts" )
  601. ( mu4e-trash-folder . "/eaglecrk/Deleted Items" )
  602. ( mu4e-maildir-shortcuts . (("/eaglecrk/Inbox" . ?i)
  603. ("/eaglecrk/Sent Items" . ?s)
  604. ("/eaglecrk/Deleted Items" . ?t)
  605. ("/eaglecrk/Archive" . ?a)))))
  606. ;; ,(make-mu4e-context
  607. ;; :name "Gmail"
  608. ;; :enter-func (lambda () (mu4e-message "Entering Gmail"))
  609. ;; :leave-func (lambda () (mu4e-message "Leaving Gmail"))
  610. ;; ;; this matches maildir /Arkham and its sub-directories
  611. ;; :match-func (lambda (msg)
  612. ;; (when msg
  613. ;; (string= (mu4e-message-field msg :maildir) "/Gmail")))
  614. ;; :vars '( ( user-mail-address . "olson.levi@gmail.com" )
  615. ;; ( smtpmail-mail-address . "olson.levi@gmail.com" )
  616. ;; ( smtpmail-smtp-user . "olson.levi@gmail.com" )
  617. ;; ( smtpmail-smtp-server . "smtp.gmail.com" )
  618. ;; ( user-full-name . "Levi Olson" )
  619. ;; ( mu4e-compose-signature .
  620. ;; (concat
  621. ;; "Levi\n"))
  622. ;; ( mu4e-sent-folder . "/Gmail/[Gmail].Sent Mail" )
  623. ;; ( mu4e-drafts-folder . "/Gmail/[Gmail].Drafts" )
  624. ;; ( mu4e-trash-folder . "/Gmail/[Gmail].Trash" )
  625. ;; ( mu4e-maildir-shortcuts . (("/Gmail/INBOX" . ?i)
  626. ;; ("/Gmail/[Gmail].Sent Mail" . ?s)
  627. ;; ("/Gmail/[Gmail].Trash" . ?t)
  628. ;; ("/Gmail/[Gmail].All Mail" . ?a))
  629. ;; )))
  630. ))
  631. ;; Add option to view HTML in browser
  632. (add-to-list 'mu4e-headers-actions
  633. '("in browser" . mu4e-action-view-in-browser) t)
  634. (add-to-list 'mu4e-view-actions
  635. '("in browser" . mu4e-action-view-in-browser) t)
  636. (defun my-message-current-line-cited-p ()
  637. "Indicate whether the line at point is a cited line."
  638. (save-match-data
  639. (string-match (concat "^" message-cite-prefix-regexp)
  640. (buffer-substring (line-beginning-position) (line-end-position)))))
  641. (defun my-message-says-attachment-p ()
  642. "Return t if the message suggests there can be an attachment."
  643. (save-excursion
  644. (goto-char (point-min))
  645. (save-match-data
  646. (let (search-result)
  647. (while
  648. (and (setq search-result (re-search-forward "\\(attach\\|pdf\\|file\\)" nil t))
  649. (my-message-current-line-cited-p)))
  650. search-result))))
  651. (defun my-message-has-attachment-p ()
  652. "Return t if the message has an attachment."
  653. (save-excursion
  654. (goto-char (point-min))
  655. (save-match-data
  656. (re-search-forward "<#part" nil t))))
  657. (defun my-message-pre-send-check-attachment ()
  658. (when (and (my-message-says-attachment-p)
  659. (not (my-message-has-attachment-p)))
  660. (unless
  661. (y-or-n-p "No attachment. Send anyway?")
  662. (error "It seems that an attachment is needed, but none was found. Aborting sending."))))
  663. (add-hook 'message-send-hook 'my-message-pre-send-check-attachment)
  664. (require 'projectile)
  665. (require 'counsel-projectile)
  666. (projectile-mode)
  667. (setq projectile-mode-line '(:eval (format " %s" (projectile-project-name)))
  668. projectile-remember-window-configs t
  669. projectile-completion-system 'ivy)
  670. (counsel-projectile-mode)
  671. (autoload 'poporg-dwim "poporg" nil t)
  672. (global-set-key (kbd "C-c \"") 'poporg-dwim)
  673. ;;; notify.el --- notification front-end
  674. ;; Copyright (C) 2008 Mark A. Hershberger
  675. ;; Original Author: Mark A. Hershberger <mhersberger@intrahealth.org>
  676. ;; Modified by Andrey Kotlarski <m00naticus@gmail.com>
  677. ;; Modified by Andrew Gwozdziewycz <git@apgwoz.com>
  678. ;; Modified by Aidan Gauland <aidalgol@no8wireless.co.nz> October 2011
  679. ;; Modified by Olivier Sirven <the.slaa@gmail.com> November 2013
  680. ;; Keywords: extensions, convenience, lisp
  681. ;; This file is free software; you can redistribute it and/or modify
  682. ;; it under the terms of the GNU General Public License as published by
  683. ;; the Free Software Foundation; either version 2, or (at your option)
  684. ;; any later version.
  685. ;; This file is distributed in the hope that it will be useful,
  686. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  687. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  688. ;; GNU General Public License for more details.
  689. ;; You should have received a copy of the GNU General Public License
  690. ;; along with GNU Emacs; see the file COPYING. If not, write to
  691. ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  692. ;; Boston, MA 02111-1307, USA.
  693. ;;; Commentary:
  694. ;; This provides a single function, `notify', that will produce a notify
  695. ;; pop-up via D-Bus, libnotify, simple message or growl.
  696. ;; To use, just put (autoload 'notify "notify" "Notify TITLE, BODY.")
  697. ;; in your init file. You may override default chosen notification
  698. ;; method by assigning `notify-method' to one of 'notify-via-dbus
  699. ;; 'notify-via-libnotify or 'notify-via-message
  700. ;;; Code:
  701. (defvar notify-defaults (list :app "Emacs" :icon "emacs" :timeout 5000
  702. :urgency "low"
  703. :category "emacs.message")
  704. "Notification settings' defaults.
  705. May be overridden with key-value additional arguments to `notify'.")
  706. (defvar notify-delay '(0 5 0)
  707. "Minimum time allowed between notifications in time format.")
  708. (defvar notify-last-notification '(0 0 0) "Time of last notification.")
  709. (defvar notify-method 'notify-via-growl "Notification method among
  710. 'notify-via-dbus, 'notify-via-libnotify, 'notify-via-message or
  711. 'notify-via-growl")
  712. ;; determine notification method unless already set
  713. ;; prefer growl > D-Bus > libnotify > message
  714. (cond
  715. ((null notify-method)
  716. (setq notify-method
  717. (cond
  718. ((executable-find "growlnotify") 'notify-via-growl)
  719. ((and (require 'dbus nil t)
  720. (dbus-ping :session "org.freedesktop.Notifications"))
  721. (defvar notify-id 0 "Current D-Bus notification id.")
  722. 'notify-via-dbus)
  723. ((executable-find "notify-send") 'notify-via-libnotify)
  724. (t 'notify-via-message))))
  725. ((eq notify-method 'notify-via-dbus) ;housekeeping for pre-chosen DBus
  726. (if (and (require 'dbus nil t)
  727. (dbus-ping :session "org.freedesktop.Notifications"))
  728. (defvar notify-id 0 "Current D-Bus notification id.")
  729. (setq notify-method (if (executable-find "notify-send")
  730. 'notify-via-libnotify
  731. 'notify-via-message))))
  732. ((and (eq notify-method 'notify-via-libnotify)
  733. (not (executable-find "notify-send"))) ;housekeeping for pre-chosen libnotify
  734. (setq notify-method
  735. (if (and (require 'dbus nil t)
  736. (dbus-ping :session "org.freedesktop.Notifications"))
  737. (progn
  738. (defvar notify-id 0 "Current D-Bus notification id.")
  739. 'notify-via-dbus)
  740. 'notify-via-message)))
  741. ((and (eq notify-method 'notify-via-growl)
  742. (not (executable-find "growlnotify")))
  743. (setq notify-method 'notify-via-message)))
  744. (defun notify-via-dbus (title body)
  745. "Send notification with TITLE, BODY `D-Bus'."
  746. (dbus-call-method :session "org.freedesktop.Notifications"
  747. "/org/freedesktop/Notifications"
  748. "org.freedesktop.Notifications" "Notify"
  749. (get 'notify-defaults :app)
  750. (setq notify-id (+ notify-id 1))
  751. (get 'notify-defaults :icon) title body '(:array)
  752. '(:array :signature "{sv}") ':int32
  753. (get 'notify-defaults :timeout)))
  754. (defun notify-via-libnotify (title body)
  755. "Notify with TITLE, BODY via `libnotify'."
  756. (call-process "notify-send" nil 0 nil
  757. title body "-t"
  758. (number-to-string (get 'notify-defaults :timeout))
  759. "-i" (get 'notify-defaults :icon)
  760. "-u" (get 'notify-defaults :urgency)
  761. "-c" (get 'notify-defaults :category)))
  762. (defun notify-via-message (title body)
  763. "Notify TITLE, BODY with a simple message."
  764. (message "%s: %s" title body))
  765. (defun notify-via-growl (title body)
  766. "Notify TITLE, BODY with a growl"
  767. (call-process "growlnotify" nil 0 nil
  768. "-a" (get 'notify-defaults :app)
  769. "-n" (get 'notify-defaults :category)
  770. "-t" (notify-via-growl-stringify title)
  771. "-m" (notify-via-growl-stringify body)))
  772. (defun notify-via-growl-stringify (thing)
  773. (cond ((null thing) "")
  774. ((stringp thing) thing)
  775. (t (format "%s" thing))))
  776. (defun keywords-to-properties (symbol args &optional defaults)
  777. "Add to SYMBOL's property list key-values from ARGS and DEFAULTS."
  778. (when (consp defaults)
  779. (keywords-to-properties symbol defaults))
  780. (while args
  781. (put symbol (car args) (cadr args))
  782. (setq args (cddr args))))
  783. ;;;###autoload
  784. (defun notify (title body &rest args)
  785. "Notify TITLE, BODY via `notify-method'.
  786. ARGS may be amongst :timeout, :icon, :urgency, :app and :category."
  787. (when (time-less-p notify-delay
  788. (time-since notify-last-notification))
  789. (or (eq notify-method 'notify-via-message)
  790. (keywords-to-properties 'notify-defaults args
  791. notify-defaults))
  792. (setq notify-last-notification (current-time))
  793. (funcall notify-method title body)))
  794. (provide 'notify)
  795. ;;; notify.el ends here
  796. (require 'jabber)
  797. (setq jabber-history-enabled t
  798. jabber-use-global-history nil
  799. jabber-backlog-number 40
  800. jabber-backlog-days 30
  801. jabber-alert-presence-message-function (lambda (_who _oldstatus _newstatus _statustext) nil)
  802. )
  803. (setq jabber-account-list '(
  804. ("olson.levi@gmail.com"
  805. (:network-server . "talk.google.com")
  806. (:connection-type . ssl))
  807. ;; ("lolson@vlocity.com"
  808. ;; (:network-server . "talk.google.com")
  809. ;; (:connection-type . ssl))
  810. ))
  811. (defvar my-chat-prompt "[%t] %n>\n" "Customized chat prompt")
  812. (when (featurep 'jabber)
  813. (setq
  814. jabber-chat-foreign-prompt-format my-chat-prompt
  815. jabber-chat-local-prompt-format my-chat-prompt
  816. jabber-groupchat-prompt-format my-chat-prompt
  817. jabber-muc-private-foreign-prompt-format "[%t] %g/%n>\n"
  818. )
  819. )
  820. (defun notify-jabber-notify (from buf text _proposed-alert)
  821. "(jabber.el hook) Notify of new Jabber chat messages via notify.el"
  822. (when (or jabber-message-alert-same-buffer
  823. (not (memq (selected-window) (get-buffer-window-list buf))))
  824. (if (jabber-muc-sender-p from)
  825. (notify (format "(PM) %s"
  826. (jabber-jid-displayname (jabber-jid-user from)))
  827. (format "%s: %s" (jabber-jid-resource from) text)))
  828. (notify (format "%s" (jabber-jid-displayname from))
  829. text)))
  830. ;; (add-hook 'jabber-alert-message-hooks 'notify-jabber-notify)
  831. ;; (require 'autosmiley)
  832. ;; (add-hook 'jabber-chat-mode-hook 'autosmiley-mode)
  833. (defun jabber ()
  834. (interactive)
  835. (jabber-connect-all)
  836. (switch-to-buffer "*-jabber-roster-*"))
  837. (defun hyperspace-action->mu4e (&optional query)
  838. "Search mu4e with QUERY.
  839. If QUERY is unspecified, use the first bookmark in variable
  840. mu4e-bookmarks and update mail and index."
  841. (mu4e-headers-search (or query (caar mu4e-bookmarks)))
  842. (unless query
  843. (mu4e-update-mail-and-index nil)))
  844. (add-to-list 'hyperspace-actions '("m4" . hyperspace-action->mu4e))
  845. (defun hyperspace-action->elfeed (&optional query)
  846. "Load elfeed, optionally searching for QUERY."
  847. (elfeed)
  848. (if query
  849. (elfeed-search-set-filter query)
  850. (elfeed-search-fetch nil)))
  851. (add-to-list 'hyperspace-actions '("lf" . hyperspace-action->elfeed))
  852. (defun find-user-init-file ()
  853. "Edit the `~/.emacs.d/init.org' file."
  854. (interactive)
  855. (find-file "~/.emacs.d/init.org"))
  856. (defun find-todo-file ()
  857. "Edit the `~/todo.org' file."
  858. (interactive)
  859. (find-file "~/Dropbox/Org/todo.org"))
  860. (defun load-user-init-file ()
  861. "LO: Reload the `~/.emacs.d/init.elc' file."
  862. (interactive)
  863. (load-file "~/.emacs.d/init.elc"))
  864. (defun leo-swiper ()
  865. "LO: Custom swiper."
  866. (interactive)
  867. (let ((word (thing-at-point 'symbol)))
  868. (if word (swiper (format "%s" word)))
  869. (unless word (swiper (format ""))))
  870. )
  871. (defun jump-to-symbol-internal (&optional backwardp)
  872. "Jumps to the next symbol near the point if such a symbol exists. If BACKWARDP is non-nil it jumps backward."
  873. (let* ((point (point))
  874. (bounds (find-tag-default-bounds))
  875. (beg (car bounds)) (end (cdr bounds))
  876. (str (isearch-symbol-regexp (find-tag-default)))
  877. (search (if backwardp 'search-backward-regexp
  878. 'search-forward-regexp)))
  879. (goto-char (if backwardp beg end))
  880. (funcall search str nil t)
  881. (cond ((<= beg (point) end) (goto-char point))
  882. (backwardp (forward-char (- point beg)))
  883. (t (backward-char (- end point))))))
  884. (defun jump-to-previous-like-this ()
  885. "Jumps to the previous occurrence of the symbol at point."
  886. (interactive)
  887. (jump-to-symbol-internal t))
  888. (defun jump-to-next-like-this ()
  889. "Jumps to the next occurrence of the symbol at point."
  890. (interactive)
  891. (jump-to-symbol-internal))
  892. (defun match-paren (arg)
  893. "Go to the matching paren if on a paren; otherwise insert ARG (a literal % sign)."
  894. (interactive "p")
  895. (cond ((looking-at "\\s(") (forward-list 1))
  896. ((looking-back "\\s(" 2) (backward-char 1) (forward-list 1))
  897. ((looking-at "\\s)") (forward-char 1) (backward-list 1))
  898. ((looking-back "\\s)" 2) (backward-list 1))
  899. (t (self-insert-command (or arg 1)))))
  900. (defun kill-this-buffer-unless-scratch ()
  901. "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."
  902. (interactive)
  903. (if (not (string= (buffer-name) "*scratch*"))
  904. (kill-this-buffer)
  905. (delete-region (point-min) (point-max))
  906. (switch-to-buffer (other-buffer))
  907. (bury-buffer "*scratch*")))
  908. (defun delete-backward-sentence ()
  909. "LO: Delete to the beginning of the sentence/line."
  910. (interactive)
  911. (delete-region (point) (progn (backward-sentence) (point))))
  912. (defun delete-backward-to-boundary (arg)
  913. "LO: Delete backward to the previous word boundary. With ARG, do this many times."
  914. (interactive "p")
  915. (let ((a (point))
  916. (b (progn
  917. (backward-word arg)
  918. (forward-word)
  919. (point))))
  920. (if (< a b)
  921. (delete-region a (progn (backward-word arg) (point)))
  922. (if (= a b)
  923. (delete-region a (progn (backward-word arg) (point)))
  924. (delete-region a b)))))
  925. (defun comment-or-uncomment-region-or-line ()
  926. "Comments or uncomments the region or the current line if there's no active region."
  927. (interactive)
  928. (let (beg end)
  929. (if (region-active-p)
  930. (setq beg (region-beginning) end (region-end))
  931. (setq beg (line-beginning-position) end (line-end-position)))
  932. (comment-or-uncomment-region beg end)))
  933. (defun fold-toggle (column)
  934. "Code folding by COLUMN."
  935. (interactive "P")
  936. (set-selective-display
  937. (or column
  938. (unless selective-display
  939. (1+ (current-column))))))
  940. (defun new-line-below ()
  941. "LO: Create a new line below current line."
  942. (interactive)
  943. (move-end-of-line 1)
  944. (newline-and-indent))
  945. (defun new-line-above ()
  946. "LO: Create a new line above current line."
  947. (interactive)
  948. (move-beginning-of-line 1)
  949. (newline)
  950. (forward-line -1))
  951. (defun duplicate-thing (comment)
  952. "LO: Duplicates the current line, or the region if active. If an argument (COMMENT) is given, the duplicated region will be commented out."
  953. (interactive "P")
  954. (save-excursion
  955. (let ((start (if (region-active-p) (region-beginning) (point-at-bol)))
  956. (end (if (region-active-p) (region-end) (point-at-eol))))
  957. (goto-char end)
  958. (unless (region-active-p)
  959. (newline))
  960. (insert (buffer-substring start end))
  961. (when comment (comment-region start end)))))
  962. (defun tidy ()
  963. "LO: Ident, untabify and unwhitespacify current buffer, or region if active."
  964. (interactive)
  965. (let ((beg (if (region-active-p) (region-beginning) (point-min)))
  966. (end (if (region-active-p) (region-end) (point-max))))
  967. (let ((inhibit-message t))
  968. (indent-region beg end))
  969. (whitespace-cleanup)
  970. (untabify beg (if (< end (point-max)) end (point-max)))
  971. (if (region-active-p) (message "Indenting Region...Done") (message "Indenting File...Done"))))
  972. (defun phil-columns ()
  973. "LO: Good 'ol Phil-Columns."
  974. (interactive)
  975. (message "Good 'ol fill-columns")
  976. (with-output-to-temp-buffer "*PHIL-COLUMN*"
  977. (shell-command "mpv --no-video 'https://www.youtube.com/watch?v=YkADj0TPrJA&t=3m16s' > /dev/null 2>&1 & sleep 8; pkill mpv"))
  978. (other-window 1)
  979. (delete-window))
  980. (declare-function first "Goto FIRST shell.")
  981. (declare-function goto-non-shell-buffer "Goto something other than a shell buffer.")
  982. (declare-function switch-shell "Switch shell.")
  983. (let ((last-shell ""))
  984. (defun toggle-shell ()
  985. (interactive)
  986. (cond ((string-match-p "^\\*shell<[1-9][0-9]*>\\*$" (buffer-name))
  987. (goto-non-shell-buffer))
  988. ((get-buffer last-shell) (switch-to-buffer last-shell))
  989. (t (shell (setq last-shell "*shell<1>*")))))
  990. (defun switch-shell (n)
  991. (let ((buffer-name (format "*shell<%d>*" n)))
  992. (setq last-shell buffer-name)
  993. (cond ((get-buffer buffer-name)
  994. (switch-to-buffer buffer-name))
  995. (t (shell buffer-name)
  996. (rename-buffer buffer-name)))))
  997. (defun goto-non-shell-buffer ()
  998. (let* ((r "^\\*shell<[1-9][0-9]*>\\*$")
  999. (shell-buffer-p (lambda (b) (string-match-p r (buffer-name b))))
  1000. (non-shells (cl-remove-if shell-buffer-p (buffer-list))))
  1001. (when non-shells
  1002. (switch-to-buffer (first non-shells))))))
  1003. (defadvice shell (after kill-with-no-query nil activate)
  1004. "."
  1005. (set-process-query-on-exit-flag (get-buffer-process ad-return-value) nil))
  1006. (declare-function comint-truncate-buffer ".")
  1007. (defun clear-comint ()
  1008. "Run `comint-truncate-buffer' with the `comint-buffer-maximum-size' set to zero."
  1009. (interactive)
  1010. (let ((comint-buffer-maximum-size 0))
  1011. (comint-truncate-buffer)))
  1012. (defun c-setup ()
  1013. "Compile."
  1014. (local-set-key (kbd "C-c C-c") 'compile))
  1015. (require 'company)
  1016. (add-hook 'comint-mode-hook (lambda () (local-set-key (kbd "c-l") 'clear-comint)))
  1017. (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
  1018. (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
  1019. (add-hook 'c-mode-common-hook 'c-setup)
  1020. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  1021. (defvar company-active-map (make-keymap)
  1022. "company mode keymap.")
  1023. (defvar custom-bindings (make-keymap)
  1024. "a keymap of custom bindings.")
  1025. (define-key custom-bindings (kbd "M-p") 'jump-to-previous-like-this)
  1026. (define-key custom-bindings (kbd "M-r") 'fill-paragraph)
  1027. (define-key custom-bindings (kbd "M-n") 'jump-to-next-like-this)
  1028. (define-key custom-bindings (kbd "M-<tab>") 'switch-to-next-buffer)
  1029. (define-key custom-bindings (kbd "M-<backspace>")'delete-backward-to-boundary)
  1030. (define-key custom-bindings (kbd "C-<backspace>")'delete-backward-to-boundary)
  1031. (define-key custom-bindings (kbd "C-}") 'mc/mark-next-like-this)
  1032. (define-key custom-bindings (kbd "C-)") 'mc/unmark-next-like-this)
  1033. (define-key custom-bindings (kbd "C-{") 'mc/mark-previous-like-this)
  1034. (define-key custom-bindings (kbd "C-(") 'mc/unmark-previous-like-this)
  1035. (define-key custom-bindings (kbd "C-'") 'mc-hide-unmatched-lines-mode)
  1036. (define-key custom-bindings (kbd "C-c 1") 'mc/insert-numbers)
  1037. (define-key custom-bindings (kbd "C-c s") 'mc/sort-regions)
  1038. (define-key custom-bindings "%" 'match-paren)
  1039. (define-key custom-bindings (kbd "C-x .") 'dash-at-point)
  1040. (define-key custom-bindings (kbd "C-x ,") 'dash-at-point-with-docset)
  1041. (define-key custom-bindings (kbd "C-s") 'leo-swiper)
  1042. (define-key custom-bindings (kbd "C-x C-l m") 'mu4e)
  1043. (define-key custom-bindings (kbd "C-x C-o t") 'find-todo-file)
  1044. (define-key custom-bindings (kbd "C-x C-l j") 'jabber)
  1045. (define-key custom-bindings (kbd "C-x C-l f") 'elfeed)
  1046. (define-key custom-bindings (kbd "C-x C-l a") 'org-agenda)
  1047. (define-key custom-bindings (kbd "C-,") 'org-cycle-agenda-files)
  1048. (define-key custom-bindings (kbd "C-x C-l c") 'calendar)
  1049. (define-key custom-bindings (kbd "M-SPC") #'hyperspace)
  1050. ;; (dolist (n (number-sequence 1 9))
  1051. ;; (global-set-key (kbd (concat "M-" (int-to-string n)))
  1052. ;; (lambda () (interactive) (switch-shell n))))
  1053. (define-key company-active-map (kbd "C-d") 'company-show-doc-buffer)
  1054. (define-key company-active-map (kbd "C-n") 'company-select-next)
  1055. (define-key company-active-map (kbd "C-p") 'company-select-previous)
  1056. (define-key company-active-map (kbd "<tab>") 'company-complete)
  1057. (define-key custom-bindings (kbd "C-c p") 'counsel-projectile-switch-project)
  1058. (define-key custom-bindings (kbd "C-c f") 'counsel-projectile-find-file)
  1059. (define-key custom-bindings (kbd "C-c c") 'ivy-resume)
  1060. (define-key custom-bindings (kbd "C-c m") 'magit-status)
  1061. (define-key custom-bindings (kbd "C-c D") 'define-word-at-point)
  1062. (define-key custom-bindings (kbd "C-@") 'er/expand-region)
  1063. (define-key custom-bindings (kbd "C-#") 'er/contract-region)
  1064. (define-key custom-bindings (kbd "C-S-c C-S-c") 'mc/edit-lines)
  1065. (define-key custom-bindings (kbd "C-c b") 'ivy-switch-buffer)
  1066. (define-key custom-bindings (kbd "C-c l") 'org-store-link)
  1067. (define-key custom-bindings (kbd "C-c t") 'org-set-tags)
  1068. (define-key custom-bindings (kbd "M-u") 'upcase-dwim)
  1069. (define-key custom-bindings (kbd "M-c") 'capitalize-dwim)
  1070. (define-key custom-bindings (kbd "M-l") 'downcase-dwim)
  1071. (define-key custom-bindings (kbd "M-o") 'other-window)
  1072. (define-key custom-bindings (kbd "C-c s") 'ispell-word)
  1073. (define-key custom-bindings (kbd "C-c C-d") 'org-capture)
  1074. (define-key custom-bindings (kbd "C-c <up>") 'windmove-up)
  1075. (define-key custom-bindings (kbd "C-c <down>") 'windmove-down)
  1076. (define-key custom-bindings (kbd "C-c <left>") 'windmove-left)
  1077. (define-key custom-bindings (kbd "C-c <right>") 'windmove-right)
  1078. (define-key custom-bindings (kbd "C-c a") (lambda () (interactive) (org-agenda nil "n")))
  1079. (define-key custom-bindings (kbd "C-c e") 'find-user-init-file)
  1080. (define-key custom-bindings (kbd "C-x f") 'phil-columns)
  1081. (define-key custom-bindings (kbd "C-x k") 'kill-this-buffer-unless-scratch)
  1082. (define-key custom-bindings (kbd "C-c d") 'duplicate-thing)
  1083. (define-key custom-bindings (kbd "C-;") 'comment-or-uncomment-region-or-line)
  1084. (define-key custom-bindings (kbd "C-o") 'new-line-below)
  1085. (define-key custom-bindings (kbd "C-S-o") 'new-line-above)
  1086. (define-key custom-bindings (kbd "<C-tab>") 'tidy)
  1087. (define-key custom-bindings (kbd "M-q") 'kill-this-buffer)
  1088. ;; (define-key custom-bindings (kbd "M-RET") '(lambda () (interactive) (term (getenv "SHELL"))))
  1089. (define-minor-mode custom-bindings-mode
  1090. "A mode that activates custom-bindings."
  1091. t nil custom-bindings)
  1092. (require 'rainbow-delimiters)
  1093. (global-flycheck-mode)
  1094. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  1095. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
  1096. (setq-default indent-tabs-mode nil
  1097. tab-width 4)
  1098. (defvaralias 'c-basic-offset 'tab-width)
  1099. (defvaralias 'cperl-indent-level 'tab-width)
  1100. (electric-pair-mode 1)
  1101. (show-paren-mode 1)
  1102. (require 'dockerfile-mode)
  1103. (add-to-list 'auto-mode-alist '("Dockerfile*\\'" . dockerfile-mode))
  1104. (require 'gitignore-mode)
  1105. (add-to-list 'auto-mode-alist '("gitignore\\'" . gitignore-mode))
  1106. ;; Workaround to get Projectile to work again
  1107. (setq projectile-git-submodule-command nil)
  1108. (require 'json-mode)
  1109. (add-to-list 'auto-mode-alist '("\\.json\\'" . json-mode))
  1110. (require 'web-mode)
  1111. (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
  1112. (elpy-enable)
  1113. (setq python-shell-interpreter "jupyter"
  1114. python-shell-interpreter-args "console --simple-prompt")
  1115. (when (require 'flycheck nil t)
  1116. (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  1117. (add-hook 'elpy-mode-hook 'flycheck-mode))
  1118. (require 'py-autopep8)
  1119. (setq py-autopep8-options '("--ignore=E501"))
  1120. (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
  1121. (require 'go-mode)
  1122. (require 'go-playground)
  1123. (require 'gorepl-mode)
  1124. (require 'company-go)
  1125. (add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
  1126. (add-hook 'go-mode-hook (lambda ()
  1127. (add-hook 'before-save-hook 'gofmt-before-save)
  1128. (local-set-key (kbd "M-.") 'godef-jump)
  1129. (local-set-key (kbd "M-,") 'pop-tag-mark)
  1130. (local-set-key (kbd "C-c C-c") (lambda ()
  1131. (interactive)
  1132. (ansi-term)
  1133. (comint-send-string "*ansi-term*" "make\n")))
  1134. (set (make-local-variable 'company-backends) '(company-go))
  1135. (setq company-tooltip-limit 20
  1136. company-echo-delay 0
  1137. company-begin-commands '(self-insert-command))
  1138. (gorepl-mode)))
  1139. (defun set-exec-path-from-shell-PATH ()
  1140. (let ((path-from-shell (replace-regexp-in-string
  1141. "[ \t\n]*$"
  1142. ""
  1143. (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
  1144. (setenv "PATH" path-from-shell)
  1145. (setq eshell-path-env path-from-shell)
  1146. (setq exec-path (split-string path-from-shell path-separator))))
  1147. (when window-system (set-exec-path-from-shell-PATH))
  1148. (setenv "GOPATH" "/home/locust/go")
  1149. (add-to-list 'exec-path "/home/locust/go/bin")
  1150. (add-to-list 'exec-path "/usr/local/bin")
  1151. (defun setup-tide-mode ()
  1152. "Tide setup function."
  1153. (interactive)
  1154. (tide-setup)
  1155. (flycheck-mode +1)
  1156. (setq flycheck-check-syntax-automatically '(save mode-enabled))
  1157. (eldoc-mode +1)
  1158. (tide-hl-identifier-mode +1)
  1159. (company-mode +1))
  1160. ;; aligns annotation to the right hand side
  1161. (setq company-tooltip-align-annotations t)
  1162. ;; formats the buffer before saving
  1163. (add-hook 'before-save-hook 'tide-format-before-save)
  1164. (add-hook 'typescript-mode-hook #'setup-tide-mode)
  1165. (require 'typescript-mode)
  1166. (require 'tide)
  1167. (add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
  1168. (add-hook 'typescript-mode-hook
  1169. '(lambda ()
  1170. (set (make-local-variable 'company-backends) '(company-tide))
  1171. (setq company-tooltip-limit 20
  1172. company-echo-delay 0
  1173. company-begin-commands '(self-insert-command)
  1174. tide-format-options '(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t :placeOpenBraceOnNewLineForFunctions nil))
  1175. (tide-setup)))
  1176. (require 'web-mode)
  1177. (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
  1178. (add-hook 'web-mode-hook
  1179. (lambda ()
  1180. (when (string-equal "tsx" (file-name-extension buffer-file-name))
  1181. (setup-tide-mode))))
  1182. ;; enable typescript-tslint checker
  1183. (flycheck-add-mode 'typescript-tslint 'web-mode)
  1184. (require 'web-mode)
  1185. (add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
  1186. (add-hook 'web-mode-hook
  1187. (lambda ()
  1188. (when (string-equal "jsx" (file-name-extension buffer-file-name))
  1189. (setup-tide-mode))))
  1190. ;; configure jsx-tide checker to run after your default jsx checker
  1191. (flycheck-add-mode 'javascript-eslint 'web-mode)
  1192. (flycheck-add-next-checker 'javascript-eslint 'jsx-tide 'append)
  1193. (org-babel-do-load-languages
  1194. 'org-babel-load-languages
  1195. '((js . t)
  1196. (shell . t)
  1197. (emacs-lisp . t)))
  1198. (setq org-todo-keywords
  1199. '((sequence "TODO(t)" "|" "DONE(d)")
  1200. (sequence "BUG(b)" "|" "INPROGRESS(i)" "FIXED(f)")
  1201. (sequence "TEST(T)" "NOTEST(N)" "|" "COMPLETE(C)")
  1202. (sequence "|" "CANCELED(c)")
  1203. (sequence "|" "NEEDCLARIFICATION(n)")
  1204. (sequence "|" "PROVIDEUPDATE(p)")
  1205. (sequence "|" "WAITING(w)")
  1206. ))
  1207. (setq org-agenda-files
  1208. '("~/Dropbox/Org/todo.org"
  1209. "~/Dropbox/Org/archive.org"
  1210. "~/Dropbox/Org/diary/eaglecrk.org"))
  1211. (setq org-refile-targets
  1212. '((nil :maxlevel . 3)
  1213. (org-agenda-files :maxlevel . 3)))
  1214. ;; (add-hook 'focus-in-hook
  1215. ;; (lambda () (progn
  1216. ;; (setq org-tags-column (- 5 (frame-width)))) (org-align-all-tags)))
  1217. ;; (add-hook 'focus-out-hook
  1218. ;; (lambda () (progn
  1219. ;; (setq org-tags-column (- 5 (frame-width)))) (org-align-all-tags)))
  1220. (defvar org-src-tab-acts-natively)
  1221. (setq org-src-tab-acts-natively t)
  1222. (defvar org-confirm-babel-evaluate)
  1223. (defun my-org-confirm-babel-evaluate (lang _body)
  1224. "Execute certain languages without confirming.
  1225. Takes LANG to allow and BODY to execute."
  1226. (not (or (string= lang "js")
  1227. (string= lang "restclient")
  1228. (string= lang "emacs-lisp")
  1229. (string= lang "elisp")
  1230. (string= lang "sh")
  1231. (string= lang "shell"))))
  1232. (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
  1233. (add-to-list 'org-structure-template-alist
  1234. (list "e" (concat "#+BEGIN_SRC emacs-lisp :results silent\n"
  1235. "\n"
  1236. "#+END_SRC")))
  1237. (add-to-list 'org-structure-template-alist
  1238. (list "j" (concat "#+BEGIN_SRC js :cmd \"/usr/local/bin/babel-node\" :results output code\n"
  1239. "\n"
  1240. "#+END_SRC")))
  1241. (add-to-list 'org-structure-template-alist
  1242. (list "r" (concat "#+BEGIN_SRC restclient :results raw\n"
  1243. "\n"
  1244. "#+END_SRC")))
  1245. (setq org-directory "~/Dropbox/Org"
  1246. org-default-notes-file (concat org-directory "/todo.org")
  1247. org-startup-folded t
  1248. org-startup-indented t
  1249. org-startup-align-all-tables t
  1250. org-startup-with-inline-images t
  1251. org-startup-with-latex-preview t
  1252. org-log-done t
  1253. org-log-done-with-time t
  1254. org-log-into-drawer t
  1255. org-hide-leading-stars t
  1256. org-pretty-entities t
  1257. )
  1258. (require 'org-protocol)
  1259. (setq org-capture-templates
  1260. '(("t" "new task" entry (file+headline "~/Dropbox/Org/todo.org" "Tasks")
  1261. "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
  1262. ("n" "new note" entry (file+headline org-default-notes-file "Notes")
  1263. "* %?\n%i\n")
  1264. ("l" "store link" entry (file+olp org-default-notes-file "Links" "Unfiled")
  1265. "* %a\n%?\n")
  1266. ("d" "store link w/drawer" entry (file+olp org-default-notes-file "Links" "Unfiled")
  1267. "* %?\n%l\n:COPIED_TEXT:\n %i\n:END:\n")
  1268. ))
  1269. (defun my-org-config ()
  1270. "Activate org and yas in 'org-mode' buffers."
  1271. (yas-minor-mode)
  1272. (lambda ()
  1273. (local-set-key (kbd "M-RET") 'org-insert-todo-heading)
  1274. (global-set-key (kbd "C-c c") nil)
  1275. (local-set-key (kbd "C-c c i") 'org-clock-in)
  1276. (local-set-key (kbd "C-c c o") 'org-clock-out)
  1277. )
  1278. )
  1279. (add-hook 'org-mode-hook #'my-org-config)
  1280. (require 'ox-reveal)
  1281. (setq org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js"
  1282. org-reveal-klipsify-src t)
  1283. ;;store org-mode links to messages
  1284. (require 'org-mu4e)
  1285. ;;store link to message if in header view, not to header query
  1286. (setq org-mu4e-link-query-in-headers-mode nil)
  1287. (elfeed-org)
  1288. (setq rmh-elfeed-org-files (list "~/Dropbox/Org/elfeed.org"))
  1289. (defun leo/elfeed-search (arg)
  1290. "Search for ARG in feed."
  1291. (interactive)
  1292. (elfeed-search-set-filter arg))
  1293. (define-key elfeed-search-mode-map "a" (lambda () (interactive) (leo/elfeed-search "")))
  1294. (define-key elfeed-search-mode-map "e" (lambda () (interactive) (leo/elfeed-search "+emacs")))
  1295. (define-key elfeed-search-mode-map "d" (lambda () (interactive) (leo/elfeed-search "+daily")))
  1296. (define-key elfeed-search-mode-map "x" (lambda () (interactive) (leo/elfeed-search "xkcd")))
  1297. (cond ((member "PragmataPro Mono Liga" (font-family-list))
  1298. (set-face-attribute 'default nil :font "PragmataPro Mono Liga-13")))
  1299. (add-hook 'org-mode-hook 'org-bullets-mode)
  1300. (set-face-attribute 'org-level-1 nil :height 1.3)
  1301. (set-face-attribute 'org-level-2 nil :height 1.1)
  1302. (set-face-attribute 'org-level-3 nil :height 1.05)
  1303. (set-face-attribute 'org-level-4 nil :height 1.05)
  1304. (set-face-attribute 'org-scheduled-today nil :height 1.0)
  1305. (set-face-attribute 'org-agenda-date-today nil :height 1.1)
  1306. ;; (set-face-attribute 'org-table nil :foreground "#008787")
  1307. ;;; rainbow-mode.el --- Colorize color names in buffers
  1308. ;; Copyright (C) 2010-2018 Free Software Foundation, Inc
  1309. ;; Author: Julien Danjou <julien@danjou.info>
  1310. ;; Keywords: faces
  1311. ;; Version: 1.0.1
  1312. ;; This file is part of GNU Emacs.
  1313. ;; GNU Emacs is free software: you can redistribute it and/or modify
  1314. ;; it under the terms of the GNU General Public License as published by
  1315. ;; the Free Software Foundation, either version 3 of the License, or
  1316. ;; (at your option) any later version.
  1317. ;; GNU Emacs is distributed in the hope that it will be useful,
  1318. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  1319. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1320. ;; GNU General Public License for more details.
  1321. ;; You should have received a copy of the GNU General Public License
  1322. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  1323. ;;; Commentary:
  1324. ;;
  1325. ;; This minor mode sets background color to strings that match color
  1326. ;; names, e.g. #0000ff is displayed in white with a blue background.
  1327. ;;
  1328. ;;; Code:
  1329. (eval-when-compile
  1330. (require 'cl))
  1331. (require 'regexp-opt)
  1332. (require 'faces)
  1333. (require 'color)
  1334. (unless (require 'xterm-color nil t)
  1335. (require 'ansi-color))
  1336. (defgroup rainbow nil
  1337. "Show color strings with a background color."
  1338. :tag "Rainbow"
  1339. :group 'help)
  1340. ;;; Hexadecimal colors
  1341. (defvar rainbow-hexadecimal-colors-font-lock-keywords
  1342. '(("[^&]\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}\\)"
  1343. (1 (rainbow-colorize-itself 1)))
  1344. ("^\\(#\\(?:[0-9a-fA-F]\\{3\\}\\)+\\{1,4\\}\\)"
  1345. (0 (rainbow-colorize-itself)))
  1346. ("[Rr][Gg][Bb]:[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}/[0-9a-fA-F]\\{1,4\\}"
  1347. (0 (rainbow-colorize-itself)))
  1348. ("[Rr][Gg][Bb][Ii]:[0-9.]+/[0-9.]+/[0-9.]+"
  1349. (0 (rainbow-colorize-itself)))
  1350. ("\\(?:[Cc][Ii][Ee]\\(?:[Xx][Yy][Zz]\\|[Uu][Vv][Yy]\\|[Xx][Yy][Yy]\\|[Ll][Aa][Bb]\\|[Ll][Uu][Vv]\\)\\|[Tt][Ee][Kk][Hh][Vv][Cc]\\):[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?/[+-]?[0-9.]+\\(?:[Ee][+-]?[0-9]+\\)?"
  1351. (0 (rainbow-colorize-itself))))
  1352. "Font-lock keywords to add for hexadecimal colors.")
  1353. ;;; rgb() colors
  1354. (defvar rainbow-html-rgb-colors-font-lock-keywords
  1355. '(("rgb(\s*\\([0-9]\\{1,3\\}\\(?:\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*)"
  1356. (0 (rainbow-colorize-rgb)))
  1357. ("rgba(\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\\.[0-9]\\)?\\(?:\s*%\\)?\\)\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)"
  1358. (0 (rainbow-colorize-rgb)))
  1359. ("hsl(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*)"
  1360. (0 (rainbow-colorize-hsl)))
  1361. ("hsla(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)"
  1362. (0 (rainbow-colorize-hsl))))
  1363. "Font-lock keywords to add for RGB colors.")
  1364. ;;; HTML colors
  1365. (defvar rainbow-html-colors-font-lock-keywords nil
  1366. "Font-lock keywords to add for HTML colors.")
  1367. (make-variable-buffer-local 'rainbow-html-colors-font-lock-keywords)
  1368. (defcustom rainbow-html-colors-alist
  1369. '(("AliceBlue" . "#F0F8FF")
  1370. ("AntiqueWhite" . "#FAEBD7")
  1371. ("Aqua" . "#00FFFF")
  1372. ("Aquamarine" . "#7FFFD4")
  1373. ("Azure" . "#F0FFFF")
  1374. ("Beige" . "#F5F5DC")
  1375. ("Bisque" . "#FFE4C4")
  1376. ("Black" . "#000000")
  1377. ("BlanchedAlmond" . "#FFEBCD")
  1378. ("Blue" . "#0000FF")
  1379. ("BlueViolet" . "#8A2BE2")
  1380. ("Brown" . "#A52A2A")
  1381. ("BurlyWood" . "#DEB887")
  1382. ("CadetBlue" . "#5F9EA0")
  1383. ("Chartreuse" . "#7FFF00")
  1384. ("Chocolate" . "#D2691E")
  1385. ("Coral" . "#FF7F50")
  1386. ("CornflowerBlue" . "#6495ED")
  1387. ("Cornsilk" . "#FFF8DC")
  1388. ("Crimson" . "#DC143C")
  1389. ("Cyan" . "#00FFFF")
  1390. ("DarkBlue" . "#00008B")
  1391. ("DarkCyan" . "#008B8B")
  1392. ("DarkGoldenRod" . "#B8860B")
  1393. ("DarkGray" . "#A9A9A9")
  1394. ("DarkGrey" . "#A9A9A9")
  1395. ("DarkGreen" . "#006400")
  1396. ("DarkKhaki" . "#BDB76B")
  1397. ("DarkMagenta" . "#8B008B")
  1398. ("DarkOliveGreen" . "#556B2F")
  1399. ("Darkorange" . "#FF8C00")
  1400. ("DarkOrchid" . "#9932CC")
  1401. ("DarkRed" . "#8B0000")
  1402. ("DarkSalmon" . "#E9967A")
  1403. ("DarkSeaGreen" . "#8FBC8F")
  1404. ("DarkSlateBlue" . "#483D8B")
  1405. ("DarkSlateGray" . "#2F4F4F")
  1406. ("DarkSlateGrey" . "#2F4F4F")
  1407. ("DarkTurquoise" . "#00CED1")
  1408. ("DarkViolet" . "#9400D3")
  1409. ("DeepPink" . "#FF1493")
  1410. ("DeepSkyBlue" . "#00BFFF")
  1411. ("DimGray" . "#696969")
  1412. ("DimGrey" . "#696969")
  1413. ("DodgerBlue" . "#1E90FF")
  1414. ("FireBrick" . "#B22222")
  1415. ("FloralWhite" . "#FFFAF0")
  1416. ("ForestGreen" . "#228B22")
  1417. ("Fuchsia" . "#FF00FF")
  1418. ("Gainsboro" . "#DCDCDC")
  1419. ("GhostWhite" . "#F8F8FF")
  1420. ("Gold" . "#FFD700")
  1421. ("GoldenRod" . "#DAA520")
  1422. ("Gray" . "#808080")
  1423. ("Grey" . "#808080")
  1424. ("Green" . "#008000")
  1425. ("GreenYellow" . "#ADFF2F")
  1426. ("HoneyDew" . "#F0FFF0")
  1427. ("HotPink" . "#FF69B4")
  1428. ("IndianRed" . "#CD5C5C")
  1429. ("Indigo" . "#4B0082")
  1430. ("Ivory" . "#FFFFF0")
  1431. ("Khaki" . "#F0E68C")
  1432. ("Lavender" . "#E6E6FA")
  1433. ("LavenderBlush" . "#FFF0F5")
  1434. ("LawnGreen" . "#7CFC00")
  1435. ("LemonChiffon" . "#FFFACD")
  1436. ("LightBlue" . "#ADD8E6")
  1437. ("LightCoral" . "#F08080")
  1438. ("LightCyan" . "#E0FFFF")
  1439. ("LightGoldenRodYellow" . "#FAFAD2")
  1440. ("LightGray" . "#D3D3D3")
  1441. ("LightGrey" . "#D3D3D3")
  1442. ("LightGreen" . "#90EE90")
  1443. ("LightPink" . "#FFB6C1")
  1444. ("LightSalmon" . "#FFA07A")
  1445. ("LightSeaGreen" . "#20B2AA")
  1446. ("LightSkyBlue" . "#87CEFA")
  1447. ("LightSlateGray" . "#778899")
  1448. ("LightSlateGrey" . "#778899")
  1449. ("LightSteelBlue" . "#B0C4DE")
  1450. ("LightYellow" . "#FFFFE0")
  1451. ("Lime" . "#00FF00")
  1452. ("LimeGreen" . "#32CD32")
  1453. ("Linen" . "#FAF0E6")
  1454. ("Magenta" . "#FF00FF")
  1455. ("Maroon" . "#800000")
  1456. ("MediumAquaMarine" . "#66CDAA")
  1457. ("MediumBlue" . "#0000CD")
  1458. ("MediumOrchid" . "#BA55D3")
  1459. ("MediumPurple" . "#9370D8")
  1460. ("MediumSeaGreen" . "#3CB371")
  1461. ("MediumSlateBlue" . "#7B68EE")
  1462. ("MediumSpringGreen" . "#00FA9A")
  1463. ("MediumTurquoise" . "#48D1CC")
  1464. ("MediumVioletRed" . "#C71585")
  1465. ("MidnightBlue" . "#191970")
  1466. ("MintCream" . "#F5FFFA")
  1467. ("MistyRose" . "#FFE4E1")
  1468. ("Moccasin" . "#FFE4B5")
  1469. ("NavajoWhite" . "#FFDEAD")
  1470. ("Navy" . "#000080")
  1471. ("OldLace" . "#FDF5E6")
  1472. ("Olive" . "#808000")
  1473. ("OliveDrab" . "#6B8E23")
  1474. ("Orange" . "#FFA500")
  1475. ("OrangeRed" . "#FF4500")
  1476. ("Orchid" . "#DA70D6")
  1477. ("PaleGoldenRod" . "#EEE8AA")
  1478. ("PaleGreen" . "#98FB98")
  1479. ("PaleTurquoise" . "#AFEEEE")
  1480. ("PaleVioletRed" . "#D87093")
  1481. ("PapayaWhip" . "#FFEFD5")
  1482. ("PeachPuff" . "#FFDAB9")
  1483. ("Peru" . "#CD853F")
  1484. ("Pink" . "#FFC0CB")
  1485. ("Plum" . "#DDA0DD")
  1486. ("PowderBlue" . "#B0E0E6")
  1487. ("Purple" . "#800080")
  1488. ("Red" . "#FF0000")
  1489. ("RosyBrown" . "#BC8F8F")
  1490. ("RoyalBlue" . "#4169E1")
  1491. ("SaddleBrown" . "#8B4513")
  1492. ("Salmon" . "#FA8072")
  1493. ("SandyBrown" . "#F4A460")
  1494. ("SeaGreen" . "#2E8B57")
  1495. ("SeaShell" . "#FFF5EE")
  1496. ("Sienna" . "#A0522D")
  1497. ("Silver" . "#C0C0C0")
  1498. ("SkyBlue" . "#87CEEB")
  1499. ("SlateBlue" . "#6A5ACD")
  1500. ("SlateGray" . "#708090")
  1501. ("SlateGrey" . "#708090")
  1502. ("Snow" . "#FFFAFA")
  1503. ("SpringGreen" . "#00FF7F")
  1504. ("SteelBlue" . "#4682B4")
  1505. ("Tan" . "#D2B48C")
  1506. ("Teal" . "#008080")
  1507. ("Thistle" . "#D8BFD8")
  1508. ("Tomato" . "#FF6347")
  1509. ("Turquoise" . "#40E0D0")
  1510. ("Violet" . "#EE82EE")
  1511. ("Wheat" . "#F5DEB3")
  1512. ("White" . "#FFFFFF")
  1513. ("WhiteSmoke" . "#F5F5F5")
  1514. ("Yellow" . "#FFFF00")
  1515. ("YellowGreen" . "#9ACD32"))
  1516. "Alist of HTML colors.
  1517. Each entry should have the form (COLOR-NAME . HEXADECIMAL-COLOR)."
  1518. :type 'alist
  1519. :group 'rainbow)
  1520. (defcustom rainbow-html-colors-major-mode-list
  1521. '(html-mode css-mode php-mode nxml-mode xml-mode)
  1522. "List of major mode where HTML colors are enabled when
  1523. `rainbow-html-colors' is set to auto."
  1524. :type '(repeat (symbol :tag "Major-Mode"))
  1525. :group 'rainbow)
  1526. (defcustom rainbow-html-colors 'auto
  1527. "When to enable HTML colors.
  1528. If set to t, the HTML colors will be enabled. If set to nil, the
  1529. HTML colors will not be enabled. If set to auto, the HTML colors
  1530. will be enabled if a major mode has been detected from the
  1531. `rainbow-html-colors-major-mode-list'."
  1532. :type '(choice (symbol :tag "enable in certain modes" auto)
  1533. (symbol :tag "enable globally" t)
  1534. (symbol :tag "disable" nil))
  1535. :group 'rainbow)
  1536. ;;; X colors
  1537. (defvar rainbow-x-colors-font-lock-keywords
  1538. `((,(regexp-opt (x-defined-colors) 'words)
  1539. (0 (rainbow-colorize-itself))))
  1540. "Font-lock keywords to add for X colors.")
  1541. (defcustom rainbow-x-colors-major-mode-list
  1542. '(emacs-lisp-mode lisp-interaction-mode c-mode c++-mode java-mode)
  1543. "List of major mode where X colors are enabled when
  1544. `rainbow-x-colors' is set to auto."
  1545. :type '(repeat (symbol :tag "Major-Mode"))
  1546. :group 'rainbow)
  1547. (defcustom rainbow-x-colors 'auto
  1548. "When to enable X colors.
  1549. If set to t, the X colors will be enabled. If set to nil, the
  1550. X colors will not be enabled. If set to auto, the X colors
  1551. will be enabled if a major mode has been detected from the
  1552. `rainbow-x-colors-major-mode-list'."
  1553. :type '(choice (symbol :tag "enable in certain modes" auto)
  1554. (symbol :tag "enable globally" t)
  1555. (symbol :tag "disable" nil))
  1556. :group 'rainbow)
  1557. ;;; LaTeX colors
  1558. (defvar rainbow-latex-rgb-colors-font-lock-keywords
  1559. '(("{rgb}{\\([0-9.]+\\),\s*\\([0-9.]+\\),\s*\\([0-9.]+\\)}"
  1560. (0 (rainbow-colorize-rgb-float)))
  1561. ("{RGB}{\\([0-9]\\{1,3\\}\\),\s*\\([0-9]\\{1,3\\}\\),\s*\\([0-9]\\{1,3\\}\\)}"
  1562. (0 (rainbow-colorize-rgb)))
  1563. ("{HTML}{\\([0-9A-Fa-f]\\{6\\}\\)}"
  1564. (0 (rainbow-colorize-hexadecimal-without-sharp))))
  1565. "Font-lock keywords to add for LaTeX colors.")
  1566. (defcustom rainbow-latex-colors-major-mode-list
  1567. '(latex-mode)
  1568. "List of major mode where LaTeX colors are enabled when
  1569. `rainbow-x-colors' is set to auto."
  1570. :type '(repeat (symbol :tag "Major-Mode"))
  1571. :group 'rainbow)
  1572. (defcustom rainbow-latex-colors 'auto
  1573. "When to enable LaTeX colors.
  1574. If set to t, the LaTeX colors will be enabled. If set to nil, the
  1575. LaTeX colors will not be enabled. If set to auto, the LaTeX colors
  1576. will be enabled if a major mode has been detected from the
  1577. `rainbow-latex-colors-major-mode-list'."
  1578. :type '(choice (symbol :tag "enable in certain modes" auto)
  1579. (symbol :tag "enable globally" t)
  1580. (symbol :tag "disable" nil))
  1581. :group 'rainbow)
  1582. ;;; Shell colors
  1583. (defvar rainbow-ansi-colors-font-lock-keywords
  1584. '(("\\(\\\\[eE]\\|\\\\033\\|\\\\x1[bB]\\|\033\\)\\[\\([0-9;]*m\\)"
  1585. (0 (rainbow-colorize-ansi))))
  1586. "Font-lock keywords to add for ANSI colors.")
  1587. (defcustom rainbow-ansi-colors-major-mode-list
  1588. '(sh-mode c-mode c++-mode)
  1589. "List of major mode where ANSI colors are enabled when
  1590. `rainbow-ansi-colors' is set to auto."
  1591. :type '(repeat (symbol :tag "Major-Mode"))
  1592. :group 'rainbow)
  1593. (defcustom rainbow-ansi-colors 'auto
  1594. "When to enable ANSI colors.
  1595. If set to t, the ANSI colors will be enabled. If set to nil, the
  1596. ANSI colors will not be enabled. If set to auto, the ANSI colors
  1597. will be enabled if a major mode has been detected from the
  1598. `rainbow-ansi-colors-major-mode-list'."
  1599. :type '(choice (symbol :tag "enable in certain modes" auto)
  1600. (symbol :tag "enable globally" t)
  1601. (symbol :tag "disable" nil))
  1602. :group 'rainbow)
  1603. ;;; R colors
  1604. (defvar rainbow-r-colors-font-lock-keywords nil
  1605. "Font-lock keywords to add for R colors.")
  1606. (make-variable-buffer-local 'rainbow-r-colors-font-lock-keywords)
  1607. ;; use the following code to generate the list in R
  1608. ;; output_colors <- function(colors) {for(color in colors) {col <- col2rgb(color); cat(sprintf("(\"%s\" . \"#%02X%02X%02X\")\n",color,col[1],col[2],col[3]));}}
  1609. ;; output_colors(colors())
  1610. (defcustom rainbow-r-colors-alist
  1611. '(("white" . "#FFFFFF")
  1612. ("aliceblue" . "#F0F8FF")
  1613. ("antiquewhite" . "#FAEBD7")
  1614. ("antiquewhite1" . "#FFEFDB")
  1615. ("antiquewhite2" . "#EEDFCC")
  1616. ("antiquewhite3" . "#CDC0B0")
  1617. ("antiquewhite4" . "#8B8378")
  1618. ("aquamarine" . "#7FFFD4")
  1619. ("aquamarine1" . "#7FFFD4")
  1620. ("aquamarine2" . "#76EEC6")
  1621. ("aquamarine3" . "#66CDAA")
  1622. ("aquamarine4" . "#458B74")
  1623. ("azure" . "#F0FFFF")
  1624. ("azure1" . "#F0FFFF")
  1625. ("azure2" . "#E0EEEE")
  1626. ("azure3" . "#C1CDCD")
  1627. ("azure4" . "#838B8B")
  1628. ("beige" . "#F5F5DC")
  1629. ("bisque" . "#FFE4C4")
  1630. ("bisque1" . "#FFE4C4")
  1631. ("bisque2" . "#EED5B7")
  1632. ("bisque3" . "#CDB79E")
  1633. ("bisque4" . "#8B7D6B")
  1634. ("black" . "#000000")
  1635. ("blanchedalmond" . "#FFEBCD")
  1636. ("blue" . "#0000FF")
  1637. ("blue1" . "#0000FF")
  1638. ("blue2" . "#0000EE")
  1639. ("blue3" . "#0000CD")
  1640. ("blue4" . "#00008B")
  1641. ("blueviolet" . "#8A2BE2")
  1642. ("brown" . "#A52A2A")
  1643. ("brown1" . "#FF4040")
  1644. ("brown2" . "#EE3B3B")
  1645. ("brown3" . "#CD3333")
  1646. ("brown4" . "#8B2323")
  1647. ("burlywood" . "#DEB887")
  1648. ("burlywood1" . "#FFD39B")
  1649. ("burlywood2" . "#EEC591")
  1650. ("burlywood3" . "#CDAA7D")
  1651. ("burlywood4" . "#8B7355")
  1652. ("cadetblue" . "#5F9EA0")
  1653. ("cadetblue1" . "#98F5FF")
  1654. ("cadetblue2" . "#8EE5EE")
  1655. ("cadetblue3" . "#7AC5CD")
  1656. ("cadetblue4" . "#53868B")
  1657. ("chartreuse" . "#7FFF00")
  1658. ("chartreuse1" . "#7FFF00")
  1659. ("chartreuse2" . "#76EE00")
  1660. ("chartreuse3" . "#66CD00")
  1661. ("chartreuse4" . "#458B00")
  1662. ("chocolate" . "#D2691E")
  1663. ("chocolate1" . "#FF7F24")
  1664. ("chocolate2" . "#EE7621")
  1665. ("chocolate3" . "#CD661D")
  1666. ("chocolate4" . "#8B4513")
  1667. ("coral" . "#FF7F50")
  1668. ("coral1" . "#FF7256")
  1669. ("coral2" . "#EE6A50")
  1670. ("coral3" . "#CD5B45")
  1671. ("coral4" . "#8B3E2F")
  1672. ("cornflowerblue" . "#6495ED")
  1673. ("cornsilk" . "#FFF8DC")
  1674. ("cornsilk1" . "#FFF8DC")
  1675. ("cornsilk2" . "#EEE8CD")
  1676. ("cornsilk3" . "#CDC8B1")
  1677. ("cornsilk4" . "#8B8878")
  1678. ("cyan" . "#00FFFF")
  1679. ("cyan1" . "#00FFFF")
  1680. ("cyan2" . "#00EEEE")
  1681. ("cyan3" . "#00CDCD")
  1682. ("cyan4" . "#008B8B")
  1683. ("darkblue" . "#00008B")
  1684. ("darkcyan" . "#008B8B")
  1685. ("darkgoldenrod" . "#B8860B")
  1686. ("darkgoldenrod1" . "#FFB90F")
  1687. ("darkgoldenrod2" . "#EEAD0E")
  1688. ("darkgoldenrod3" . "#CD950C")
  1689. ("darkgoldenrod4" . "#8B6508")
  1690. ("darkgray" . "#A9A9A9")
  1691. ("darkgreen" . "#006400")
  1692. ("darkgrey" . "#A9A9A9")
  1693. ("darkkhaki" . "#BDB76B")
  1694. ("darkmagenta" . "#8B008B")
  1695. ("darkolivegreen" . "#556B2F")
  1696. ("darkolivegreen1" . "#CAFF70")
  1697. ("darkolivegreen2" . "#BCEE68")
  1698. ("darkolivegreen3" . "#A2CD5A")
  1699. ("darkolivegreen4" . "#6E8B3D")
  1700. ("darkorange" . "#FF8C00")
  1701. ("darkorange1" . "#FF7F00")
  1702. ("darkorange2" . "#EE7600")
  1703. ("darkorange3" . "#CD6600")
  1704. ("darkorange4" . "#8B4500")
  1705. ("darkorchid" . "#9932CC")
  1706. ("darkorchid1" . "#BF3EFF")
  1707. ("darkorchid2" . "#B23AEE")
  1708. ("darkorchid3" . "#9A32CD")
  1709. ("darkorchid4" . "#68228B")
  1710. ("darkred" . "#8B0000")
  1711. ("darksalmon" . "#E9967A")
  1712. ("darkseagreen" . "#8FBC8F")
  1713. ("darkseagreen1" . "#C1FFC1")
  1714. ("darkseagreen2" . "#B4EEB4")
  1715. ("darkseagreen3" . "#9BCD9B")
  1716. ("darkseagreen4" . "#698B69")
  1717. ("darkslateblue" . "#483D8B")
  1718. ("darkslategray" . "#2F4F4F")
  1719. ("darkslategray1" . "#97FFFF")
  1720. ("darkslategray2" . "#8DEEEE")
  1721. ("darkslategray3" . "#79CDCD")
  1722. ("darkslategray4" . "#528B8B")
  1723. ("darkslategrey" . "#2F4F4F")
  1724. ("darkturquoise" . "#00CED1")
  1725. ("darkviolet" . "#9400D3")
  1726. ("deeppink" . "#FF1493")
  1727. ("deeppink1" . "#FF1493")
  1728. ("deeppink2" . "#EE1289")
  1729. ("deeppink3" . "#CD1076")
  1730. ("deeppink4" . "#8B0A50")
  1731. ("deepskyblue" . "#00BFFF")
  1732. ("deepskyblue1" . "#00BFFF")
  1733. ("deepskyblue2" . "#00B2EE")
  1734. ("deepskyblue3" . "#009ACD")
  1735. ("deepskyblue4" . "#00688B")
  1736. ("dimgray" . "#696969")
  1737. ("dimgrey" . "#696969")
  1738. ("dodgerblue" . "#1E90FF")
  1739. ("dodgerblue1" . "#1E90FF")
  1740. ("dodgerblue2" . "#1C86EE")
  1741. ("dodgerblue3" . "#1874CD")
  1742. ("dodgerblue4" . "#104E8B")
  1743. ("firebrick" . "#B22222")
  1744. ("firebrick1" . "#FF3030")
  1745. ("firebrick2" . "#EE2C2C")
  1746. ("firebrick3" . "#CD2626")
  1747. ("firebrick4" . "#8B1A1A")
  1748. ("floralwhite" . "#FFFAF0")
  1749. ("forestgreen" . "#228B22")
  1750. ("gainsboro" . "#DCDCDC")
  1751. ("ghostwhite" . "#F8F8FF")
  1752. ("gold" . "#FFD700")
  1753. ("gold1" . "#FFD700")
  1754. ("gold2" . "#EEC900")
  1755. ("gold3" . "#CDAD00")
  1756. ("gold4" . "#8B7500")
  1757. ("goldenrod" . "#DAA520")
  1758. ("goldenrod1" . "#FFC125")
  1759. ("goldenrod2" . "#EEB422")
  1760. ("goldenrod3" . "#CD9B1D")
  1761. ("goldenrod4" . "#8B6914")
  1762. ("gray" . "#BEBEBE")
  1763. ("gray0" . "#000000")
  1764. ("gray1" . "#030303")
  1765. ("gray2" . "#050505")
  1766. ("gray3" . "#080808")
  1767. ("gray4" . "#0A0A0A")
  1768. ("gray5" . "#0D0D0D")
  1769. ("gray6" . "#0F0F0F")
  1770. ("gray7" . "#121212")
  1771. ("gray8" . "#141414")
  1772. ("gray9" . "#171717")
  1773. ("gray10" . "#1A1A1A")
  1774. ("gray11" . "#1C1C1C")
  1775. ("gray12" . "#1F1F1F")
  1776. ("gray13" . "#212121")
  1777. ("gray14" . "#242424")
  1778. ("gray15" . "#262626")
  1779. ("gray16" . "#292929")
  1780. ("gray17" . "#2B2B2B")
  1781. ("gray18" . "#2E2E2E")
  1782. ("gray19" . "#303030")
  1783. ("gray20" . "#333333")
  1784. ("gray21" . "#363636")
  1785. ("gray22" . "#383838")
  1786. ("gray23" . "#3B3B3B")
  1787. ("gray24" . "#3D3D3D")
  1788. ("gray25" . "#404040")
  1789. ("gray26" . "#424242")
  1790. ("gray27" . "#454545")
  1791. ("gray28" . "#474747")
  1792. ("gray29" . "#4A4A4A")
  1793. ("gray30" . "#4D4D4D")
  1794. ("gray31" . "#4F4F4F")
  1795. ("gray32" . "#525252")
  1796. ("gray33" . "#545454")
  1797. ("gray34" . "#575757")
  1798. ("gray35" . "#595959")
  1799. ("gray36" . "#5C5C5C")
  1800. ("gray37" . "#5E5E5E")
  1801. ("gray38" . "#616161")
  1802. ("gray39" . "#636363")
  1803. ("gray40" . "#666666")
  1804. ("gray41" . "#696969")
  1805. ("gray42" . "#6B6B6B")
  1806. ("gray43" . "#6E6E6E")
  1807. ("gray44" . "#707070")
  1808. ("gray45" . "#737373")
  1809. ("gray46" . "#757575")
  1810. ("gray47" . "#787878")
  1811. ("gray48" . "#7A7A7A")
  1812. ("gray49" . "#7D7D7D")
  1813. ("gray50" . "#7F7F7F")
  1814. ("gray51" . "#828282")
  1815. ("gray52" . "#858585")
  1816. ("gray53" . "#878787")
  1817. ("gray54" . "#8A8A8A")
  1818. ("gray55" . "#8C8C8C")
  1819. ("gray56" . "#8F8F8F")
  1820. ("gray57" . "#919191")
  1821. ("gray58" . "#949494")
  1822. ("gray59" . "#969696")
  1823. ("gray60" . "#999999")
  1824. ("gray61" . "#9C9C9C")
  1825. ("gray62" . "#9E9E9E")
  1826. ("gray63" . "#A1A1A1")
  1827. ("gray64" . "#A3A3A3")
  1828. ("gray65" . "#A6A6A6")
  1829. ("gray66" . "#A8A8A8")
  1830. ("gray67" . "#ABABAB")
  1831. ("gray68" . "#ADADAD")
  1832. ("gray69" . "#B0B0B0")
  1833. ("gray70" . "#B3B3B3")
  1834. ("gray71" . "#B5B5B5")
  1835. ("gray72" . "#B8B8B8")
  1836. ("gray73" . "#BABABA")
  1837. ("gray74" . "#BDBDBD")
  1838. ("gray75" . "#BFBFBF")
  1839. ("gray76" . "#C2C2C2")
  1840. ("gray77" . "#C4C4C4")
  1841. ("gray78" . "#C7C7C7")
  1842. ("gray79" . "#C9C9C9")
  1843. ("gray80" . "#CCCCCC")
  1844. ("gray81" . "#CFCFCF")
  1845. ("gray82" . "#D1D1D1")
  1846. ("gray83" . "#D4D4D4")
  1847. ("gray84" . "#D6D6D6")
  1848. ("gray85" . "#D9D9D9")
  1849. ("gray86" . "#DBDBDB")
  1850. ("gray87" . "#DEDEDE")
  1851. ("gray88" . "#E0E0E0")
  1852. ("gray89" . "#E3E3E3")
  1853. ("gray90" . "#E5E5E5")
  1854. ("gray91" . "#E8E8E8")
  1855. ("gray92" . "#EBEBEB")
  1856. ("gray93" . "#EDEDED")
  1857. ("gray94" . "#F0F0F0")
  1858. ("gray95" . "#F2F2F2")
  1859. ("gray96" . "#F5F5F5")
  1860. ("gray97" . "#F7F7F7")
  1861. ("gray98" . "#FAFAFA")
  1862. ("gray99" . "#FCFCFC")
  1863. ("gray100" . "#FFFFFF")
  1864. ("green" . "#00FF00")
  1865. ("green1" . "#00FF00")
  1866. ("green2" . "#00EE00")
  1867. ("green3" . "#00CD00")
  1868. ("green4" . "#008B00")
  1869. ("greenyellow" . "#ADFF2F")
  1870. ("grey" . "#BEBEBE")
  1871. ("grey0" . "#000000")
  1872. ("grey1" . "#030303")
  1873. ("grey2" . "#050505")
  1874. ("grey3" . "#080808")
  1875. ("grey4" . "#0A0A0A")
  1876. ("grey5" . "#0D0D0D")
  1877. ("grey6" . "#0F0F0F")
  1878. ("grey7" . "#121212")
  1879. ("grey8" . "#141414")
  1880. ("grey9" . "#171717")
  1881. ("grey10" . "#1A1A1A")
  1882. ("grey11" . "#1C1C1C")
  1883. ("grey12" . "#1F1F1F")
  1884. ("grey13" . "#212121")
  1885. ("grey14" . "#242424")
  1886. ("grey15" . "#262626")
  1887. ("grey16" . "#292929")
  1888. ("grey17" . "#2B2B2B")
  1889. ("grey18" . "#2E2E2E")
  1890. ("grey19" . "#303030")
  1891. ("grey20" . "#333333")
  1892. ("grey21" . "#363636")
  1893. ("grey22" . "#383838")
  1894. ("grey23" . "#3B3B3B")
  1895. ("grey24" . "#3D3D3D")
  1896. ("grey25" . "#404040")
  1897. ("grey26" . "#424242")
  1898. ("grey27" . "#454545")
  1899. ("grey28" . "#474747")
  1900. ("grey29" . "#4A4A4A")
  1901. ("grey30" . "#4D4D4D")
  1902. ("grey31" . "#4F4F4F")
  1903. ("grey32" . "#525252")
  1904. ("grey33" . "#545454")
  1905. ("grey34" . "#575757")
  1906. ("grey35" . "#595959")
  1907. ("grey36" . "#5C5C5C")
  1908. ("grey37" . "#5E5E5E")
  1909. ("grey38" . "#616161")
  1910. ("grey39" . "#636363")
  1911. ("grey40" . "#666666")
  1912. ("grey41" . "#696969")
  1913. ("grey42" . "#6B6B6B")
  1914. ("grey43" . "#6E6E6E")
  1915. ("grey44" . "#707070")
  1916. ("grey45" . "#737373")
  1917. ("grey46" . "#757575")
  1918. ("grey47" . "#787878")
  1919. ("grey48" . "#7A7A7A")
  1920. ("grey49" . "#7D7D7D")
  1921. ("grey50" . "#7F7F7F")
  1922. ("grey51" . "#828282")
  1923. ("grey52" . "#858585")
  1924. ("grey53" . "#878787")
  1925. ("grey54" . "#8A8A8A")
  1926. ("grey55" . "#8C8C8C")
  1927. ("grey56" . "#8F8F8F")
  1928. ("grey57" . "#919191")
  1929. ("grey58" . "#949494")
  1930. ("grey59" . "#969696")
  1931. ("grey60" . "#999999")
  1932. ("grey61" . "#9C9C9C")
  1933. ("grey62" . "#9E9E9E")
  1934. ("grey63" . "#A1A1A1")
  1935. ("grey64" . "#A3A3A3")
  1936. ("grey65" . "#A6A6A6")
  1937. ("grey66" . "#A8A8A8")
  1938. ("grey67" . "#ABABAB")
  1939. ("grey68" . "#ADADAD")
  1940. ("grey69" . "#B0B0B0")
  1941. ("grey70" . "#B3B3B3")
  1942. ("grey71" . "#B5B5B5")
  1943. ("grey72" . "#B8B8B8")
  1944. ("grey73" . "#BABABA")
  1945. ("grey74" . "#BDBDBD")
  1946. ("grey75" . "#BFBFBF")
  1947. ("grey76" . "#C2C2C2")
  1948. ("grey77" . "#C4C4C4")
  1949. ("grey78" . "#C7C7C7")
  1950. ("grey79" . "#C9C9C9")
  1951. ("grey80" . "#CCCCCC")
  1952. ("grey81" . "#CFCFCF")
  1953. ("grey82" . "#D1D1D1")
  1954. ("grey83" . "#D4D4D4")
  1955. ("grey84" . "#D6D6D6")
  1956. ("grey85" . "#D9D9D9")
  1957. ("grey86" . "#DBDBDB")
  1958. ("grey87" . "#DEDEDE")
  1959. ("grey88" . "#E0E0E0")
  1960. ("grey89" . "#E3E3E3")
  1961. ("grey90" . "#E5E5E5")
  1962. ("grey91" . "#E8E8E8")
  1963. ("grey92" . "#EBEBEB")
  1964. ("grey93" . "#EDEDED")
  1965. ("grey94" . "#F0F0F0")
  1966. ("grey95" . "#F2F2F2")
  1967. ("grey96" . "#F5F5F5")
  1968. ("grey97" . "#F7F7F7")
  1969. ("grey98" . "#FAFAFA")
  1970. ("grey99" . "#FCFCFC")
  1971. ("grey100" . "#FFFFFF")
  1972. ("honeydew" . "#F0FFF0")
  1973. ("honeydew1" . "#F0FFF0")
  1974. ("honeydew2" . "#E0EEE0")
  1975. ("honeydew3" . "#C1CDC1")
  1976. ("honeydew4" . "#838B83")
  1977. ("hotpink" . "#FF69B4")
  1978. ("hotpink1" . "#FF6EB4")
  1979. ("hotpink2" . "#EE6AA7")
  1980. ("hotpink3" . "#CD6090")
  1981. ("hotpink4" . "#8B3A62")
  1982. ("indianred" . "#CD5C5C")
  1983. ("indianred1" . "#FF6A6A")
  1984. ("indianred2" . "#EE6363")
  1985. ("indianred3" . "#CD5555")
  1986. ("indianred4" . "#8B3A3A")
  1987. ("ivory" . "#FFFFF0")
  1988. ("ivory1" . "#FFFFF0")
  1989. ("ivory2" . "#EEEEE0")
  1990. ("ivory3" . "#CDCDC1")
  1991. ("ivory4" . "#8B8B83")
  1992. ("khaki" . "#F0E68C")
  1993. ("khaki1" . "#FFF68F")
  1994. ("khaki2" . "#EEE685")
  1995. ("khaki3" . "#CDC673")
  1996. ("khaki4" . "#8B864E")
  1997. ("lavender" . "#E6E6FA")
  1998. ("lavenderblush" . "#FFF0F5")
  1999. ("lavenderblush1" . "#FFF0F5")
  2000. ("lavenderblush2" . "#EEE0E5")
  2001. ("lavenderblush3" . "#CDC1C5")
  2002. ("lavenderblush4" . "#8B8386")
  2003. ("lawngreen" . "#7CFC00")
  2004. ("lemonchiffon" . "#FFFACD")
  2005. ("lemonchiffon1" . "#FFFACD")
  2006. ("lemonchiffon2" . "#EEE9BF")
  2007. ("lemonchiffon3" . "#CDC9A5")
  2008. ("lemonchiffon4" . "#8B8970")
  2009. ("lightblue" . "#ADD8E6")
  2010. ("lightblue1" . "#BFEFFF")
  2011. ("lightblue2" . "#B2DFEE")
  2012. ("lightblue3" . "#9AC0CD")
  2013. ("lightblue4" . "#68838B")
  2014. ("lightcoral" . "#F08080")
  2015. ("lightcyan" . "#E0FFFF")
  2016. ("lightcyan1" . "#E0FFFF")
  2017. ("lightcyan2" . "#D1EEEE")
  2018. ("lightcyan3" . "#B4CDCD")
  2019. ("lightcyan4" . "#7A8B8B")
  2020. ("lightgoldenrod" . "#EEDD82")
  2021. ("lightgoldenrod1" . "#FFEC8B")
  2022. ("lightgoldenrod2" . "#EEDC82")
  2023. ("lightgoldenrod3" . "#CDBE70")
  2024. ("lightgoldenrod4" . "#8B814C")
  2025. ("lightgoldenrodyellow" . "#FAFAD2")
  2026. ("lightgray" . "#D3D3D3")
  2027. ("lightgreen" . "#90EE90")
  2028. ("lightgrey" . "#D3D3D3")
  2029. ("lightpink" . "#FFB6C1")
  2030. ("lightpink1" . "#FFAEB9")
  2031. ("lightpink2" . "#EEA2AD")
  2032. ("lightpink3" . "#CD8C95")
  2033. ("lightpink4" . "#8B5F65")
  2034. ("lightsalmon" . "#FFA07A")
  2035. ("lightsalmon1" . "#FFA07A")
  2036. ("lightsalmon2" . "#EE9572")
  2037. ("lightsalmon3" . "#CD8162")
  2038. ("lightsalmon4" . "#8B5742")
  2039. ("lightseagreen" . "#20B2AA")
  2040. ("lightskyblue" . "#87CEFA")
  2041. ("lightskyblue1" . "#B0E2FF")
  2042. ("lightskyblue2" . "#A4D3EE")
  2043. ("lightskyblue3" . "#8DB6CD")
  2044. ("lightskyblue4" . "#607B8B")
  2045. ("lightslateblue" . "#8470FF")
  2046. ("lightslategray" . "#778899")
  2047. ("lightslategrey" . "#778899")
  2048. ("lightsteelblue" . "#B0C4DE")
  2049. ("lightsteelblue1" . "#CAE1FF")
  2050. ("lightsteelblue2" . "#BCD2EE")
  2051. ("lightsteelblue3" . "#A2B5CD")
  2052. ("lightsteelblue4" . "#6E7B8B")
  2053. ("lightyellow" . "#FFFFE0")
  2054. ("lightyellow1" . "#FFFFE0")
  2055. ("lightyellow2" . "#EEEED1")
  2056. ("lightyellow3" . "#CDCDB4")
  2057. ("lightyellow4" . "#8B8B7A")
  2058. ("limegreen" . "#32CD32")
  2059. ("linen" . "#FAF0E6")
  2060. ("magenta" . "#FF00FF")
  2061. ("magenta1" . "#FF00FF")
  2062. ("magenta2" . "#EE00EE")
  2063. ("magenta3" . "#CD00CD")
  2064. ("magenta4" . "#8B008B")
  2065. ("maroon" . "#B03060")
  2066. ("maroon1" . "#FF34B3")
  2067. ("maroon2" . "#EE30A7")
  2068. ("maroon3" . "#CD2990")
  2069. ("maroon4" . "#8B1C62")
  2070. ("mediumaquamarine" . "#66CDAA")
  2071. ("mediumblue" . "#0000CD")
  2072. ("mediumorchid" . "#BA55D3")
  2073. ("mediumorchid1" . "#E066FF")
  2074. ("mediumorchid2" . "#D15FEE")
  2075. ("mediumorchid3" . "#B452CD")
  2076. ("mediumorchid4" . "#7A378B")
  2077. ("mediumpurple" . "#9370DB")
  2078. ("mediumpurple1" . "#AB82FF")
  2079. ("mediumpurple2" . "#9F79EE")
  2080. ("mediumpurple3" . "#8968CD")
  2081. ("mediumpurple4" . "#5D478B")
  2082. ("mediumseagreen" . "#3CB371")
  2083. ("mediumslateblue" . "#7B68EE")
  2084. ("mediumspringgreen" . "#00FA9A")
  2085. ("mediumturquoise" . "#48D1CC")
  2086. ("mediumvioletred" . "#C71585")
  2087. ("midnightblue" . "#191970")
  2088. ("mintcream" . "#F5FFFA")
  2089. ("mistyrose" . "#FFE4E1")
  2090. ("mistyrose1" . "#FFE4E1")
  2091. ("mistyrose2" . "#EED5D2")
  2092. ("mistyrose3" . "#CDB7B5")
  2093. ("mistyrose4" . "#8B7D7B")
  2094. ("moccasin" . "#FFE4B5")
  2095. ("navajowhite" . "#FFDEAD")
  2096. ("navajowhite1" . "#FFDEAD")
  2097. ("navajowhite2" . "#EECFA1")
  2098. ("navajowhite3" . "#CDB38B")
  2099. ("navajowhite4" . "#8B795E")
  2100. ("navy" . "#000080")
  2101. ("navyblue" . "#000080")
  2102. ("oldlace" . "#FDF5E6")
  2103. ("olivedrab" . "#6B8E23")
  2104. ("olivedrab1" . "#C0FF3E")
  2105. ("olivedrab2" . "#B3EE3A")
  2106. ("olivedrab3" . "#9ACD32")
  2107. ("olivedrab4" . "#698B22")
  2108. ("orange" . "#FFA500")
  2109. ("orange1" . "#FFA500")
  2110. ("orange2" . "#EE9A00")
  2111. ("orange3" . "#CD8500")
  2112. ("orange4" . "#8B5A00")
  2113. ("orangered" . "#FF4500")
  2114. ("orangered1" . "#FF4500")
  2115. ("orangered2" . "#EE4000")
  2116. ("orangered3" . "#CD3700")
  2117. ("orangered4" . "#8B2500")
  2118. ("orchid" . "#DA70D6")
  2119. ("orchid1" . "#FF83FA")
  2120. ("orchid2" . "#EE7AE9")
  2121. ("orchid3" . "#CD69C9")
  2122. ("orchid4" . "#8B4789")
  2123. ("palegoldenrod" . "#EEE8AA")
  2124. ("palegreen" . "#98FB98")
  2125. ("palegreen1" . "#9AFF9A")
  2126. ("palegreen2" . "#90EE90")
  2127. ("palegreen3" . "#7CCD7C")
  2128. ("palegreen4" . "#548B54")
  2129. ("paleturquoise" . "#AFEEEE")
  2130. ("paleturquoise1" . "#BBFFFF")
  2131. ("paleturquoise2" . "#AEEEEE")
  2132. ("paleturquoise3" . "#96CDCD")
  2133. ("paleturquoise4" . "#668B8B")
  2134. ("palevioletred" . "#DB7093")
  2135. ("palevioletred1" . "#FF82AB")
  2136. ("palevioletred2" . "#EE799F")
  2137. ("palevioletred3" . "#CD6889")
  2138. ("palevioletred4" . "#8B475D")
  2139. ("papayawhip" . "#FFEFD5")
  2140. ("peachpuff" . "#FFDAB9")
  2141. ("peachpuff1" . "#FFDAB9")
  2142. ("peachpuff2" . "#EECBAD")
  2143. ("peachpuff3" . "#CDAF95")
  2144. ("peachpuff4" . "#8B7765")
  2145. ("peru" . "#CD853F")
  2146. ("pink" . "#FFC0CB")
  2147. ("pink1" . "#FFB5C5")
  2148. ("pink2" . "#EEA9B8")
  2149. ("pink3" . "#CD919E")
  2150. ("pink4" . "#8B636C")
  2151. ("plum" . "#DDA0DD")
  2152. ("plum1" . "#FFBBFF")
  2153. ("plum2" . "#EEAEEE")
  2154. ("plum3" . "#CD96CD")
  2155. ("plum4" . "#8B668B")
  2156. ("powderblue" . "#B0E0E6")
  2157. ("purple" . "#A020F0")
  2158. ("purple1" . "#9B30FF")
  2159. ("purple2" . "#912CEE")
  2160. ("purple3" . "#7D26CD")
  2161. ("purple4" . "#551A8B")
  2162. ("red" . "#FF0000")
  2163. ("red1" . "#FF0000")
  2164. ("red2" . "#EE0000")
  2165. ("red3" . "#CD0000")
  2166. ("red4" . "#8B0000")
  2167. ("rosybrown" . "#BC8F8F")
  2168. ("rosybrown1" . "#FFC1C1")
  2169. ("rosybrown2" . "#EEB4B4")
  2170. ("rosybrown3" . "#CD9B9B")
  2171. ("rosybrown4" . "#8B6969")
  2172. ("royalblue" . "#4169E1")
  2173. ("royalblue1" . "#4876FF")
  2174. ("royalblue2" . "#436EEE")
  2175. ("royalblue3" . "#3A5FCD")
  2176. ("royalblue4" . "#27408B")
  2177. ("saddlebrown" . "#8B4513")
  2178. ("salmon" . "#FA8072")
  2179. ("salmon1" . "#FF8C69")
  2180. ("salmon2" . "#EE8262")
  2181. ("salmon3" . "#CD7054")
  2182. ("salmon4" . "#8B4C39")
  2183. ("sandybrown" . "#F4A460")
  2184. ("seagreen" . "#2E8B57")
  2185. ("seagreen1" . "#54FF9F")
  2186. ("seagreen2" . "#4EEE94")
  2187. ("seagreen3" . "#43CD80")
  2188. ("seagreen4" . "#2E8B57")
  2189. ("seashell" . "#FFF5EE")
  2190. ("seashell1" . "#FFF5EE")
  2191. ("seashell2" . "#EEE5DE")
  2192. ("seashell3" . "#CDC5BF")
  2193. ("seashell4" . "#8B8682")
  2194. ("sienna" . "#A0522D")
  2195. ("sienna1" . "#FF8247")
  2196. ("sienna2" . "#EE7942")
  2197. ("sienna3" . "#CD6839")
  2198. ("sienna4" . "#8B4726")
  2199. ("skyblue" . "#87CEEB")
  2200. ("skyblue1" . "#87CEFF")
  2201. ("skyblue2" . "#7EC0EE")
  2202. ("skyblue3" . "#6CA6CD")
  2203. ("skyblue4" . "#4A708B")
  2204. ("slateblue" . "#6A5ACD")
  2205. ("slateblue1" . "#836FFF")
  2206. ("slateblue2" . "#7A67EE")
  2207. ("slateblue3" . "#6959CD")
  2208. ("slateblue4" . "#473C8B")
  2209. ("slategray" . "#708090")
  2210. ("slategray1" . "#C6E2FF")
  2211. ("slategray2" . "#B9D3EE")
  2212. ("slategray3" . "#9FB6CD")
  2213. ("slategray4" . "#6C7B8B")
  2214. ("slategrey" . "#708090")
  2215. ("snow" . "#FFFAFA")
  2216. ("snow1" . "#FFFAFA")
  2217. ("snow2" . "#EEE9E9")
  2218. ("snow3" . "#CDC9C9")
  2219. ("snow4" . "#8B8989")
  2220. ("springgreen" . "#00FF7F")
  2221. ("springgreen1" . "#00FF7F")
  2222. ("springgreen2" . "#00EE76")
  2223. ("springgreen3" . "#00CD66")
  2224. ("springgreen4" . "#008B45")
  2225. ("steelblue" . "#4682B4")
  2226. ("steelblue1" . "#63B8FF")
  2227. ("steelblue2" . "#5CACEE")
  2228. ("steelblue3" . "#4F94CD")
  2229. ("steelblue4" . "#36648B")
  2230. ("tan" . "#D2B48C")
  2231. ("tan1" . "#FFA54F")
  2232. ("tan2" . "#EE9A49")
  2233. ("tan3" . "#CD853F")
  2234. ("tan4" . "#8B5A2B")
  2235. ("thistle" . "#D8BFD8")
  2236. ("thistle1" . "#FFE1FF")
  2237. ("thistle2" . "#EED2EE")
  2238. ("thistle3" . "#CDB5CD")
  2239. ("thistle4" . "#8B7B8B")
  2240. ("tomato" . "#FF6347")
  2241. ("tomato1" . "#FF6347")
  2242. ("tomato2" . "#EE5C42")
  2243. ("tomato3" . "#CD4F39")
  2244. ("tomato4" . "#8B3626")
  2245. ("turquoise" . "#40E0D0")
  2246. ("turquoise1" . "#00F5FF")
  2247. ("turquoise2" . "#00E5EE")
  2248. ("turquoise3" . "#00C5CD")
  2249. ("turquoise4" . "#00868B")
  2250. ("violet" . "#EE82EE")
  2251. ("violetred" . "#D02090")
  2252. ("violetred1" . "#FF3E96")
  2253. ("violetred2" . "#EE3A8C")
  2254. ("violetred3" . "#CD3278")
  2255. ("violetred4" . "#8B2252")
  2256. ("wheat" . "#F5DEB3")
  2257. ("wheat1" . "#FFE7BA")
  2258. ("wheat2" . "#EED8AE")
  2259. ("wheat3" . "#CDBA96")
  2260. ("wheat4" . "#8B7E66")
  2261. ("whitesmoke" . "#F5F5F5")
  2262. ("yellow" . "#FFFF00")
  2263. ("yellow1" . "#FFFF00")
  2264. ("yellow2" . "#EEEE00")
  2265. ("yellow3" . "#CDCD00")
  2266. ("yellow4" . "#8B8B00")
  2267. ("yellowgreen" . "#9ACD32"))
  2268. "Alist of R colors.
  2269. Each entry should have the form (COLOR-NAME . HEXADECIMAL-COLOR)."
  2270. :type 'alist
  2271. :group 'rainbow)
  2272. (defcustom rainbow-r-colors-major-mode-list
  2273. '(ess-mode)
  2274. "List of major mode where R colors are enabled when
  2275. `rainbow-r-colors' is set to auto."
  2276. :type '(repeat (symbol :tag "Major-Mode"))
  2277. :group 'rainbow)
  2278. (defcustom rainbow-r-colors 'auto
  2279. "When to enable R colors.
  2280. If set to t, the R colors will be enabled. If set to nil, the
  2281. R colors will not be enabled. If set to auto, the R colors
  2282. will be enabled if a major mode has been detected from the
  2283. `rainbow-r-colors-major-mode-list'."
  2284. :type '(choice (symbol :tag "enable in certain modes" auto)
  2285. (symbol :tag "enable globally" t)
  2286. (symbol :tag "disable" nil))
  2287. :group 'rainbow)
  2288. ;;; Functions
  2289. (defun rainbow-colorize-match (color &optional match)
  2290. "Return a matched string propertized with a face whose
  2291. background is COLOR. The foreground is computed using
  2292. `rainbow-color-luminance', and is either white or black."
  2293. (let ((match (or match 0)))
  2294. (put-text-property
  2295. (match-beginning match) (match-end match)
  2296. 'face `((:foreground ,(if (> 0.5 (rainbow-x-color-luminance color))
  2297. "white" "black"))
  2298. (:background ,color)))))
  2299. (defun rainbow-colorize-itself (&optional match)
  2300. "Colorize a match with itself."
  2301. (rainbow-colorize-match (match-string-no-properties (or match 0)) match))
  2302. (defun rainbow-colorize-hexadecimal-without-sharp ()
  2303. "Colorize an hexadecimal colors and prepend # to it."
  2304. (rainbow-colorize-match (concat "#" (match-string-no-properties 1))))
  2305. (defun rainbow-colorize-by-assoc (assoc-list)
  2306. "Colorize a match with its association from ASSOC-LIST."
  2307. (rainbow-colorize-match (cdr (assoc-string (match-string-no-properties 0)
  2308. assoc-list t))))
  2309. (defun rainbow-rgb-relative-to-absolute (number)
  2310. "Convert a relative NUMBER to absolute. If NUMBER is absolute, return NUMBER.
  2311. This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\".
  2312. If the percentage value is above 100, it's converted to 100."
  2313. (let ((string-length (- (length number) 1)))
  2314. ;; Is this a number with %?
  2315. (if (eq (elt number string-length) ?%)
  2316. (/ (* (min (string-to-number (substring number 0 string-length)) 100) 255) 100)
  2317. (string-to-number number))))
  2318. (defun rainbow-colorize-hsl ()
  2319. "Colorize a match with itself."
  2320. (let ((h (/ (string-to-number (match-string-no-properties 1)) 360.0))
  2321. (s (/ (string-to-number (match-string-no-properties 2)) 100.0))
  2322. (l (/ (string-to-number (match-string-no-properties 3)) 100.0)))
  2323. (rainbow-colorize-match
  2324. (multiple-value-bind (r g b)
  2325. (color-hsl-to-rgb h s l)
  2326. (format "#%02X%02X%02X" (* r 255) (* g 255) (* b 255))))))
  2327. (defun rainbow-colorize-rgb ()
  2328. "Colorize a match with itself."
  2329. (let ((r (rainbow-rgb-relative-to-absolute (match-string-no-properties 1)))
  2330. (g (rainbow-rgb-relative-to-absolute (match-string-no-properties 2)))
  2331. (b (rainbow-rgb-relative-to-absolute (match-string-no-properties 3))))
  2332. (rainbow-colorize-match (format "#%02X%02X%02X" r g b))))
  2333. (defun rainbow-colorize-rgb-float ()
  2334. "Colorize a match with itself, with relative value."
  2335. (let ((r (* (string-to-number (match-string-no-properties 1)) 255.0))
  2336. (g (* (string-to-number (match-string-no-properties 2)) 255.0))
  2337. (b (* (string-to-number (match-string-no-properties 3)) 255.0)))
  2338. (rainbow-colorize-match (format "#%02X%02X%02X" r g b))))
  2339. (defvar ansi-color-context)
  2340. (defvar xterm-color-current)
  2341. (defun rainbow-colorize-ansi ()
  2342. "Return a matched string propertized with ansi color face."
  2343. (let ((xterm-color? (featurep 'xterm-color))
  2344. (string (match-string-no-properties 0))
  2345. color)
  2346. (save-match-data
  2347. (let* ((replaced (concat
  2348. (replace-regexp-in-string
  2349. "^\\(\\\\[eE]\\|\\\\033\\|\\\\x1[bB]\\)"
  2350. "\033" string) "x"))
  2351. xterm-color-current
  2352. ansi-color-context
  2353. (applied (funcall (if xterm-color?
  2354. 'xterm-color-filter
  2355. 'ansi-color-apply)
  2356. replaced))
  2357. (face-property (get-text-property
  2358. 0
  2359. (if xterm-color? 'face 'font-lock-face)
  2360. applied)))
  2361. (unless (listp (or (car-safe face-property) face-property))
  2362. (setq face-property (list face-property)))
  2363. (setq color (funcall (if xterm-color? 'cadr 'cdr)
  2364. (or (assq (if xterm-color?
  2365. :foreground
  2366. 'foreground-color)
  2367. face-property)
  2368. (assq (if xterm-color?
  2369. :background
  2370. 'background-color)
  2371. face-property))))))
  2372. (when color
  2373. (rainbow-colorize-match color))))
  2374. (defun rainbow-color-luminance (red green blue)
  2375. "Calculate the luminance of color composed of RED, GREEN and BLUE.
  2376. Return a value between 0 and 1."
  2377. (/ (+ (* .2126 red) (* .7152 green) (* .0722 blue)) 256))
  2378. (defun rainbow-x-color-luminance (color)
  2379. "Calculate the luminance of a color string (e.g. \"#ffaa00\", \"blue\").
  2380. Return a value between 0 and 1."
  2381. (let* ((values (x-color-values color))
  2382. (r (/ (car values) 256.0))
  2383. (g (/ (cadr values) 256.0))
  2384. (b (/ (caddr values) 256.0)))
  2385. (rainbow-color-luminance r g b)))
  2386. ;;; Mode
  2387. (defun rainbow-turn-on ()
  2388. "Turn on raibow-mode."
  2389. (font-lock-add-keywords nil
  2390. rainbow-hexadecimal-colors-font-lock-keywords
  2391. t)
  2392. ;; Activate X colors?
  2393. (when (or (eq rainbow-x-colors t)
  2394. (and (eq rainbow-x-colors 'auto)
  2395. (memq major-mode rainbow-x-colors-major-mode-list)))
  2396. (font-lock-add-keywords nil
  2397. rainbow-x-colors-font-lock-keywords
  2398. t))
  2399. ;; Activate LaTeX colors?
  2400. (when (or (eq rainbow-latex-colors t)
  2401. (and (eq rainbow-latex-colors 'auto)
  2402. (memq major-mode rainbow-latex-colors-major-mode-list)))
  2403. (font-lock-add-keywords nil
  2404. rainbow-latex-rgb-colors-font-lock-keywords
  2405. t))
  2406. ;; Activate ANSI colors?
  2407. (when (or (eq rainbow-ansi-colors t)
  2408. (and (eq rainbow-ansi-colors 'auto)
  2409. (memq major-mode rainbow-ansi-colors-major-mode-list)))
  2410. (font-lock-add-keywords nil
  2411. rainbow-ansi-colors-font-lock-keywords
  2412. t))
  2413. ;; Activate HTML colors?
  2414. (when (or (eq rainbow-html-colors t)
  2415. (and (eq rainbow-html-colors 'auto)
  2416. (memq major-mode rainbow-html-colors-major-mode-list)))
  2417. (setq rainbow-html-colors-font-lock-keywords
  2418. `((,(regexp-opt (mapcar 'car rainbow-html-colors-alist) 'words)
  2419. (0 (rainbow-colorize-by-assoc rainbow-html-colors-alist)))))
  2420. (font-lock-add-keywords nil
  2421. `(,@rainbow-html-colors-font-lock-keywords
  2422. ,@rainbow-html-rgb-colors-font-lock-keywords)
  2423. t))
  2424. ;; Activate R colors?
  2425. (when (or (eq rainbow-r-colors t)
  2426. (and (eq rainbow-r-colors 'auto)
  2427. (memq major-mode rainbow-r-colors-major-mode-list)))
  2428. (setq rainbow-r-colors-font-lock-keywords
  2429. `((,(regexp-opt (mapcar 'car rainbow-r-colors-alist) 'words)
  2430. (0 (rainbow-colorize-by-assoc rainbow-r-colors-alist)))))
  2431. (font-lock-add-keywords nil
  2432. rainbow-r-colors-font-lock-keywords
  2433. t)))
  2434. (defun rainbow-turn-off ()
  2435. "Turn off rainbow-mode."
  2436. (font-lock-remove-keywords
  2437. nil
  2438. `(,@rainbow-hexadecimal-colors-font-lock-keywords
  2439. ,@rainbow-x-colors-font-lock-keywords
  2440. ,@rainbow-latex-rgb-colors-font-lock-keywords
  2441. ,@rainbow-r-colors-font-lock-keywords
  2442. ,@rainbow-html-colors-font-lock-keywords
  2443. ,@rainbow-html-rgb-colors-font-lock-keywords)))
  2444. ;;;###autoload
  2445. (define-minor-mode rainbow-mode
  2446. "Colorize strings that represent colors.
  2447. This will fontify with colors the string like \"#aabbcc\" or \"blue\"."
  2448. :lighter " Rbow"
  2449. (progn
  2450. (if rainbow-mode
  2451. (rainbow-turn-on)
  2452. (rainbow-turn-off))
  2453. ;; Call font-lock-mode to refresh the buffer when used e.g. interactively
  2454. (font-lock-mode 1)))
  2455. ;;;; ChangeLog:
  2456. ;; 2018-05-21 Julien Danjou <julien@danjou.info>
  2457. ;;
  2458. ;; * rainbow-mode/rainbow-mode.el: do not fail if face-property is a symbol
  2459. ;;
  2460. ;; It turns out there are cases when `face-property' can be just a symbol
  2461. ;; and we need to protect our selves from that, i.e. `car' should not fail.
  2462. ;; Hence,
  2463. ;; `car-safe' is there and if it's `nil', then fall back to `face-property'
  2464. ;; as is.
  2465. ;;
  2466. ;; See https://github.com/tarsius/hl-todo/issues/17
  2467. ;;
  2468. ;; 2018-03-26 Julien Danjou <julien@danjou.info>
  2469. ;;
  2470. ;; rainbow-mode: release 1.0
  2471. ;;
  2472. ;; 2018-03-26 Jonas Bernoulli <jonas@bernoul.li>
  2473. ;;
  2474. ;; Allow outline-minor-mode to find section headings
  2475. ;;
  2476. ;; 2018-03-26 Jonas Bernoulli <jonas@bernoul.li>
  2477. ;;
  2478. ;; Set type of customizable options
  2479. ;;
  2480. ;; 2018-03-26 Jonas Bernoulli <jonas@bernoul.li>
  2481. ;;
  2482. ;; Enforce use of spaces for indentation
  2483. ;;
  2484. ;; Also untabify some code added by a contributor who, unlike you, has not
  2485. ;; globally set `indent-tabs-mode' to nil.
  2486. ;;
  2487. ;; 2017-05-29 Julien Danjou <julien@danjou.info>
  2488. ;;
  2489. ;; Fix `rainbow-color-luminance' docstring
  2490. ;;
  2491. ;; 2015-10-12 Julien Danjou <julien@danjou.info>
  2492. ;;
  2493. ;; rainbow: add font-lock at the end
  2494. ;;
  2495. ;; See https://github.com/fxbois/web-mode/issues/612
  2496. ;;
  2497. ;; 2015-03-06 Julien Danjou <julien@danjou.info>
  2498. ;;
  2499. ;; rainbow: fix font-lock-mode refresh
  2500. ;;
  2501. ;; 2014-10-15 Stefan Monnier <monnier@iro.umontreal.ca>
  2502. ;;
  2503. ;; * packages/rainbow-mode/rainbow-mode.el (ansi-color-context)
  2504. ;; (xterm-color-current): Declare.
  2505. ;;
  2506. ;; 2014-09-07 Julien Danjou <julien@danjou.info>
  2507. ;;
  2508. ;; rainbow-mode: support float in CSS and limit to 100%
  2509. ;;
  2510. ;; 2013-08-05 Julien Danjou <julien@danjou.info>
  2511. ;;
  2512. ;; rainbow-mode: 0.9, allow spaces in LaTeX colors
  2513. ;;
  2514. ;; 2013-05-03 Julien Danjou <julien@danjou.info>
  2515. ;;
  2516. ;; rainbow-mode: add support for R, bump version to 0.8
  2517. ;;
  2518. ;; Signed-off-by: Julien Danjou <julien@danjou.info>
  2519. ;;
  2520. ;; 2013-02-26 Julien Danjou <julien@danjou.info>
  2521. ;;
  2522. ;; rainbow-mode: version 0.7
  2523. ;;
  2524. ;; * rainbow-mode.el: don't activate font-lock-mode
  2525. ;;
  2526. ;; 2012-12-11 Julien Danjou <julien@danjou.info>
  2527. ;;
  2528. ;; * rainbow-mode: update to 0.6, add support for ANSI coloring
  2529. ;;
  2530. ;; 2012-11-26 Julien Danjou <julien@danjou.info>
  2531. ;;
  2532. ;; rainbow-mode: fix some LaTex docstrings
  2533. ;;
  2534. ;; 2012-11-14 Julien Danjou <julien@danjou.info>
  2535. ;;
  2536. ;; rainbow-mode: version 0.5
  2537. ;;
  2538. ;; * rainbow-mode.el: fix syntax error on
  2539. ;; `rainbow-hexadecimal-colors-font-lock-keywords'.
  2540. ;;
  2541. ;; 2012-11-09 Julien Danjou <julien@danjou.info>
  2542. ;;
  2543. ;; rainbow-mode: version 0.4
  2544. ;;
  2545. ;; * rainbow-mode.el: Use functions from color package to colorize HSL
  2546. ;; rather
  2547. ;; than our own copy.
  2548. ;;
  2549. ;; 2012-11-09 Julien Danjou <julien@danjou.info>
  2550. ;;
  2551. ;; rainbow-mode 0.3
  2552. ;;
  2553. ;; * rainbow-mode.el: avoid colorizing HTML entities
  2554. ;;
  2555. ;; 2011-09-23 Julien Danjou <julien@danjou.info>
  2556. ;;
  2557. ;; Update rainbow-mode to version 0.2
  2558. ;;
  2559. ;; 2011-07-01 Chong Yidong <cyd@stupidchicken.com>
  2560. ;;
  2561. ;; Give every package its own directory in packages/ including single-file
  2562. ;; packages.
  2563. ;;
  2564. (provide 'rainbow-mode)
  2565. ;; Local Variables:
  2566. ;; indent-tabs-mode: nil
  2567. ;; End:
  2568. ;;; rainbow-mode.el ends here
  2569. (require 'doom-modeline)
  2570. (doom-modeline-mode 1)
  2571. ;; How tall the mode-line should be (only respected in GUI Emacs).
  2572. (setq doom-modeline-height 30)
  2573. ;; How wide the mode-line bar should be (only respected in GUI Emacs).
  2574. (setq doom-modeline-bar-width 4)
  2575. ;; Determines the style used by `doom-modeline-buffer-file-name'.
  2576. ;;
  2577. ;; Given ~/Projects/FOSS/emacs/lisp/comint.el
  2578. ;; truncate-upto-project => ~/P/F/emacs/lisp/comint.el
  2579. ;; truncate-from-project => ~/Projects/FOSS/emacs/l/comint.el
  2580. ;; truncate-with-project => emacs/l/comint.el
  2581. ;; truncate-except-project => ~/P/F/emacs/l/comint.el
  2582. ;; truncate-upto-root => ~/P/F/e/lisp/comint.el
  2583. ;; truncate-all => ~/P/F/e/l/comint.el
  2584. ;; relative-from-project => emacs/lisp/comint.el
  2585. ;; relative-to-project => lisp/comint.el
  2586. ;; file-name => comint.el
  2587. ;; buffer-name => comint.el<2> (uniquify buffer name)
  2588. ;;
  2589. ;; If you are expereicing the laggy issue, especially while editing remote files
  2590. ;; with tramp, please try `file-name' style.
  2591. ;; Please refer to https://github.com/bbatsov/projectile/issues/657.
  2592. (setq doom-modeline-buffer-file-name-style 'truncate-upto-project)
  2593. ;; What executable of Python will be used (if nil nothing will be showed).
  2594. (setq doom-modeline-python-executable "python")
  2595. ;; Whether show `all-the-icons' or not (if nil nothing will be showed).
  2596. (setq doom-modeline-icon t)
  2597. ;; Whether show the icon for major mode. It respects `doom-modeline-icon'.
  2598. (setq doom-modeline-major-mode-icon t)
  2599. ;; Display color icons for `major-mode'. It respects `all-the-icons-color-icons'.
  2600. (setq doom-modeline-major-mode-color-icon nil)
  2601. ;; Whether display minor modes or not. Non-nil to display in mode-line.
  2602. (setq doom-modeline-minor-modes nil)
  2603. ;; If non-nil, a word count will be added to the selection-info modeline segment.
  2604. (setq doom-modeline-enable-word-count nil)
  2605. ;; If non-nil, only display one number for checker information if applicable.
  2606. (setq doom-modeline-checker-simple-format t)
  2607. ;; Whether display perspective name or not. Non-nil to display in mode-line.
  2608. (setq doom-modeline-persp-name t)
  2609. ;; Whether display `lsp' state or not. Non-nil to display in mode-line.
  2610. (setq doom-modeline-lsp t)
  2611. ;; Whether display github notifications or not. Requires `ghub` package.
  2612. (setq doom-modeline-github nil)
  2613. ;; The interval of checking github.
  2614. (setq doom-modeline-github-interval (* 30 60))
  2615. ;; Whether display environment version or not.
  2616. (setq doom-modeline-env-version t)
  2617. ;; Whether display mu4e notifications or not. Requires `mu4e-alert' package.
  2618. (setq doom-modeline-mu4e t)