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.

2885 lines
101 KiB

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