The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ

Install the rainbow-delimiters and rainbow-mode packages

Gergely Polonkai 6 years ago
parent c22ec1ed30
commit 2f8b03fa02
  1. 32
  2. 2
  3. 293
  4. 23
  5. 2
  6. 1254
  7. 9

@ -0,0 +1,32 @@
;;; rainbow-delimiters-autoloads.el --- automatically extracted autoloads
;;; Code:
(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "rainbow-delimiters" "rainbow-delimiters.el"
;;;;;; (22537 49997 373270 199000))
;;; Generated autoloads from rainbow-delimiters.el
(autoload 'rainbow-delimiters-mode "rainbow-delimiters" "\
Highlight nested parentheses, brackets, and braces according to their depth.
\(fn &optional ARG)" t nil)
(autoload 'rainbow-delimiters-mode-enable "rainbow-delimiters" "\
Enable `rainbow-delimiters-mode'.
\(fn)" nil nil)
(autoload 'rainbow-delimiters-mode-disable "rainbow-delimiters" "\
Disable `rainbow-delimiters-mode'.
\(fn)" nil nil)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; End:
;;; rainbow-delimiters-autoloads.el ends here

@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "rainbow-delimiters" "20160430.2358" "Highlight brackets according to their depth" 'nil :url "" :keywords '("faces" "convenience" "lisp" "tools"))

@ -0,0 +1,293 @@
;;; rainbow-delimiters.el --- Highlight brackets according to their depth -*- lexical-binding: t -*-
;; Copyright (C)
;; 2010-2013 Jeremy Rayman
;; 2013-2016 Fanael Linithien
;; Author: Jeremy Rayman <>
;; Fanael Linithien <>
;; Maintainer: Fanael Linithien <>
;; Created: 2010-09-02
;; Version: 2.1.3
;; Package-Version: 20160430.2358
;; Keywords: faces, convenience, lisp, tools
;; Homepage:
;; Note: despite `lexical-binding', there's no Emacs 24 dependency.
;; This is merely an optimization for Emacs 24+, the code is supposed to work
;; with *both* dynamic and lexical binding.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <>.
;;; Installation:
;; The recommended way is to use MELPA ( or MELPA Stable
;; ( If either is in your `package-archives', do
;; M-x package-install RET rainbow-delimiters RET
;; Otherwise, open `rainbow-delimiters.el' in Emacs and use
;; M-x package-install-from-buffer
;; Any other methods of installation are unsupported.
;;; Commentary:
;; Rainbow-delimiters is a "rainbow parentheses"-like mode which highlights
;; parentheses, brackets, and braces according to their depth. Each
;; successive level is highlighted in a different color. This makes it easy
;; to spot matching delimiters, orient yourself in the code, and tell which
;; statements are at a given level.
;; Great care has been taken to make this mode fast. You shouldn't see
;; any discernible change in scrolling or editing speed while using it,
;; even in delimiter-rich languages like Clojure, Lisp, and Scheme.
;; Usage:
;; To toggle the mode in the current buffer:
;; M-x rainbow-delimiters-mode
;; To start the mode automatically in `foo-mode', add the following to your init
;; file:
;; (add-hook 'foo-mode-hook #'rainbow-delimiters-mode)
;; To start the mode automatically in most programming modes (Emacs 24 and
;; above):
;; (add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
;; Customization:
;; To customize various options, including the color theme:
;; M-x customize-group rainbow-delimiters
;; You can specify custom colors by customizing following faces:
;; - Faces take the form `rainbow-delimiters-depth-N-face', with N being the
;; depth. Depth begins at 1, the outermost color. Faces exist for depths 1-9.
;; - The unmatched delimiter face: `rainbow-delimiters-unmatched-face'.
;; - The mismatched delimiter face: `rainbow-delimiters-mismatched-face'.
;;; Code:
(defgroup rainbow-delimiters nil
"Highlight nested parentheses, brackets, and braces according to their depth."
:prefix "rainbow-delimiters-"
:link '(url-link :tag "Website for rainbow-delimiters"
:group 'applications)
(defgroup rainbow-delimiters-faces nil
"Faces for successively nested pairs of delimiters.
When depth exceeds innermost defined face, colors cycle back through."
:group 'rainbow-delimiters
:group 'faces
:link '(custom-group-link "rainbow-delimiters")
:prefix "rainbow-delimiters-")
(defcustom rainbow-delimiters-pick-face-function
"The function used to pick a face used to highlight a delimiter.
The function should take three arguments (DEPTH MATCH LOC), where:
- DEPTH is the delimiter depth; when zero or negative, it's an unmatched
- MATCH is nil iff the delimiter is a mismatched closing delimiter.
- LOC is the location of the delimiter.
The function should return a value suitable to use as a value of the `face' text
property, or nil, in which case the delimiter is not highlighted.
The function should not move the point or mark or change the match data."
:tag "Pick face function"
:type 'function
:group 'rainbow-delimiters)
(defface rainbow-delimiters-unmatched-face
'((((background light)) (:foreground "#88090B"))
(((background dark)) (:foreground "#88090B")))
"Face to highlight unmatched closing delimiters in."
:group 'rainbow-delimiters-faces)
(defface rainbow-delimiters-mismatched-face
'((t :inherit rainbow-delimiters-unmatched-face))
"Face to highlight mismatched closing delimiters in."
:group 'rainbow-delimiters-faces)
(defmacro rainbow-delimiters--define-depth-faces ()
(let ((faces '())
(light-colors ["#707183" "#7388d6" "#909183" "#709870" "#907373"
"#6276ba" "#858580" "#80a880" "#887070"])
(dark-colors ["grey55" "#93a8c6" "#b0b1a3" "#97b098" "#aebed8"
"#b0b0b3" "#90a890" "#a2b6da" "#9cb6ad"]))
(dotimes (i 9)
(push `(defface ,(intern (format "rainbow-delimiters-depth-%d-face" (1+ i)))
'((((class color) (background light)) :foreground ,(aref light-colors i))
(((class color) (background dark)) :foreground ,(aref dark-colors i)))
,(format "Nested delimiter face, depth %d." (1+ i))
:group 'rainbow-delimiters-faces)
`(progn ,@faces))))
(defcustom rainbow-delimiters-max-face-count 9
"Number of faces defined for highlighting delimiter levels.
Determines depth at which to cycle through faces again.
It's safe to change this variable provided that for all integers from 1 to the
new value inclusive, a face `rainbow-delimiters-depth-N-face' is defined."
:type 'integer
:group 'rainbow-delimiters)
(defcustom rainbow-delimiters-outermost-only-face-count 0
"Number of faces to be used only for N outermost delimiter levels.
This should be smaller than `rainbow-delimiters-max-face-count'."
:type 'integer
:group 'rainbow-delimiters)
(defun rainbow-delimiters-default-pick-face (depth match _loc)
"Return a face name appropriate for nesting depth DEPTH.
DEPTH and MATCH are as in `rainbow-delimiters-pick-face-function'.
The returned value is either `rainbow-delimiters-unmatched-face',
`rainbow-delimiters-mismatched-face', or one of the
`rainbow-delimiters-depth-N-face' faces, obeying
`rainbow-delimiters-max-face-count' and
((<= depth 0)
((not match)
(concat "rainbow-delimiters-depth-"
(if (<= depth rainbow-delimiters-max-face-count)
;; Our nesting depth has a face defined for it.
;; Deeper than # of defined faces; cycle back through to
;; `rainbow-delimiters-outermost-only-face-count' + 1.
;; Return face # that corresponds to current nesting level.
(+ 1 rainbow-delimiters-outermost-only-face-count
(mod (- depth rainbow-delimiters-max-face-count 1)
(- rainbow-delimiters-max-face-count
(defun rainbow-delimiters--apply-color (loc depth match)
"Highlight a single delimiter at LOC according to DEPTH.
LOC is the location of the character to add text properties to.
DEPTH is the nested depth at LOC, which determines the face to use.
MATCH is nil iff it's a mismatched closing delimiter."
(let ((face (funcall rainbow-delimiters-pick-face-function depth match loc)))
(when face
(font-lock-prepend-text-property loc (1+ loc) 'face face))))
(defun rainbow-delimiters--char-ineligible-p (loc ppss delim-syntax-code)
"Return t if char at LOC should not be highlighted.
PPSS is the `parse-partial-sexp' state at LOC.
DELIM-SYNTAX-CODE is the `car' of a raw syntax descriptor at LOC.
Returns t if char at loc meets one of the following conditions:
- Inside a string.
- Inside a comment.
- Is an escaped char, e.g. ?\)"
(nth 3 ppss) ; inside string?
(nth 4 ppss) ; inside comment?
(nth 5 ppss) ; escaped according to the syntax table?
;; Note: no need to consider single-char openers, they're already handled
;; by looking at ppss.
;; Two character opener, LOC at the first character?
((/= 0 (logand #x10000 delim-syntax-code))
(/= 0 (logand #x20000 (or (car (syntax-after (1+ loc))) 0))))
;; Two character opener, LOC at the second character?
((/= 0 (logand #x20000 delim-syntax-code))
(/= 0 (logand #x10000 (or (car (syntax-after (1- loc))) 0))))
;; Main function called by font-lock.
(defun rainbow-delimiters--propertize (end)
"Highlight delimiters in region between point and END.
Used by font-lock for dynamic highlighting."
(let* ((last-ppss-pos (point))
(ppss (syntax-ppss)))
(while (> end (progn (skip-syntax-forward "^()" end)
(let* ((delim-pos (point))
(delim-syntax (syntax-after delim-pos)))
(setq ppss (parse-partial-sexp last-ppss-pos delim-pos nil nil ppss))
(setq last-ppss-pos delim-pos)
;; `skip-syntax-forward' leaves the point at the delimiter, move past
;; it.
(let ((delim-syntax-code (car delim-syntax)))
((rainbow-delimiters--char-ineligible-p delim-pos ppss delim-syntax-code)
((= 4 (logand #xFFFF delim-syntax-code))
;; The (1+ ...) is needed because `parse-partial-sexp' returns the
;; depth at the opening delimiter, not in the block being started.
(rainbow-delimiters--apply-color delim-pos (1+ (nth 0 ppss)) t))
;; Not an opening delimiter, so it's a closing delimiter.
(let ((matches-p (eq (cdr delim-syntax) (char-after (nth 1 ppss)))))
(rainbow-delimiters--apply-color delim-pos (nth 0 ppss) matches-p))))))))
;; We already fontified the delimiters, tell font-lock there's nothing more
;; to do.
;; NB: no face defined here because we apply the faces ourselves instead of
;; leaving that to font-lock.
(defconst rainbow-delimiters--font-lock-keywords
(define-minor-mode rainbow-delimiters-mode
"Highlight nested parentheses, brackets, and braces according to their depth."
nil "" nil ; No modeline lighter - it's already obvious when the mode is on.
(font-lock-remove-keywords nil rainbow-delimiters--font-lock-keywords)
(when rainbow-delimiters-mode
(font-lock-add-keywords nil rainbow-delimiters--font-lock-keywords 'append)
(set (make-local-variable 'jit-lock-contextually) t)
(when (or (bound-and-true-p syntax-begin-function)
(bound-and-true-p font-lock-beginning-of-syntax-function))
;; We're going to modify `syntax-begin-function', so flush the cache to
;; avoid getting cached values that used the old value.
(syntax-ppss-flush-cache 0))
;; `syntax-begin-function' may break the assumption we rely on that
;; `syntax-ppss' is exactly equivalent to `parse-partial-sexp' from
;; `point-min'. Just don't use it, the performance hit should be negligible.
(when (boundp 'syntax-begin-function)
(set (make-local-variable 'syntax-begin-function) nil))
;; Obsolete equivalent of `syntax-begin-function'.
(when (boundp 'font-lock-beginning-of-syntax-function)
(set (make-local-variable 'font-lock-beginning-of-syntax-function) nil)))
(when font-lock-mode
(if (fboundp 'font-lock-flush)
(with-no-warnings (font-lock-fontify-buffer)))))
(defun rainbow-delimiters-mode-enable ()
"Enable `rainbow-delimiters-mode'."
(rainbow-delimiters-mode 1))
(defun rainbow-delimiters-mode-disable ()
"Disable `rainbow-delimiters-mode'."
(rainbow-delimiters-mode 0))
(provide 'rainbow-delimiters)
;;; rainbow-delimiters.el ends here

@ -0,0 +1,23 @@
;;; rainbow-mode-autoloads.el --- automatically extracted autoloads
;;; Code:
(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "rainbow-mode" "rainbow-mode.el" (22537 49996
;;;;;; 873270 380000))
;;; Generated autoloads from rainbow-mode.el
(autoload 'rainbow-mode "rainbow-mode" "\
Colorize strings that represent colors.
This will fontify with colors the string like \"#aabbcc\" or \"blue\".
\(fn &optional ARG)" t nil)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; End:
;;; rainbow-mode-autoloads.el ends here

@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "rainbow-mode" "0.12" "Colorize color names in buffers" 'nil :url "" :keywords '("faces"))

File diff suppressed because it is too large Load Diff

@ -120,6 +120,8 @@
@ -596,6 +598,13 @@
(global-auto-revert-mode 1))
(use-package rainbow-delimiters
(add-hook 'prog-mode-hook
(use-package rainbow-mode)
;; Load my own functions
(load "gnu-c-header.el")
(load "toggle-window-split.el")