Skip to content
Browse files

restructure part#2

  • Loading branch information...
1 parent 6dc220b commit 638a4c37e8c644e49c9f8fa98209c08d9cdcd176 @azer committed Oct 11, 2011
View
3 .gitignore
@@ -0,0 +1,3 @@
+./tmp/*
+tmpac-comphist.dat
+lib/js2.elc
View
15 .gitmodules
@@ -13,3 +13,18 @@
[submodule "android-mode"]
path = lib/android-mode
url = git://github.com/remvee/android-mode.git
+[submodule "lib/auto-complete"]
+ path = lib/auto-complete
+ url = http://cx4a.org/repo/auto-complete.git
+[submodule "lib/align-cljlet"]
+ path = lib/align-cljlet
+ url = https://github.com/gstamp/align-cljlet.git
+[submodule "lib/durendal"]
+ path = lib/durendal
+ url = https://github.com/technomancy/durendal.git
+[submodule "lib/smex"]
+ path = lib/smex
+ url = https://github.com/nonsequitur/smex.git
+[submodule "lib/undo-tree"]
+ path = lib/undo-tree
+ url = http://www.dr-qubit.org/git/undo-tree.git
View
18 Makefile
@@ -0,0 +1,18 @@
+all:
+ @echo "Building...";
+ @cd lib/auto-complete/dict; \
+ @ln -s javascript-mode js2-mode;
+
+ @cd lib/js2-mode; \
+ @emacs --batch -f batch-byte-compile js2-mode.el; \
+ @mv js2-mode.elc ../.;
+ echo "build successful."
+
+install:
+ @mkdir bak;
+ @mv -f ~/.emacs* bak/.;
+ @mv -f ~/.config/emacsfiles bak/.;
+ @echo "Old configuration moved into ./bak/"
+ @mkdir -p ~/.local/share/snippets;
+ @echo "Locate snippets in ~/.local/share/snippets"
+ @ln -s init.el ~/
View
1 README
@@ -1 +0,0 @@
-my emacs configuration
View
30 README.markdown
@@ -0,0 +1,30 @@
+this is the repository of the configuration of my emacs.
+
+profiles
+========
+this configuration comes with a profile mechanism that lets user splitting and loading the configurations of particular uses.
+As seen in the source code tree, profiles/ directory contains 4 different modules; default.el, dev.el, irc.el, org.el, android.el. To specify one, pass emacs name of the file simply;
+
+```bash
+ $ emacs dev
+```
+
+It'll load what I need for my development environment. See usage for details.
+
+install
+=======
+```bash
+ $ git clone git@github.com:azer/emacsfiles.git
+ $ cd emacsfiles
+ $ make install
+```
+
+usage
+=====
+```bash
+ $ emacs # load only default profile
+ $ emacs dev # what is needed for the dev environment
+ $ emacs irc # erc and twittering-mode
+ $ emacs org # org-mode configurations
+ $ emacs android # load android emulator in addition to dev profile
+```
View
1 conf/android.el
@@ -0,0 +1 @@
+(setq android-mode-sdk-dir "~/opt/android")
View
45 conf/auto-complete.el
@@ -0,0 +1,45 @@
+;;auto-complete mode
+(add-lib-path "auto-complete")
+(require 'auto-complete)
+(require 'auto-complete-config)
+(ac-config-default)
+(ac-flyspell-workaround)
+(add-to-list 'ac-dictionary-directories (concat +emacs-lib-dir+ "/auto-complete/dict"))
+
+
+(setq ac-comphist-file (concat +emacs-tmp-dir+ "ac-comphist.dat"))
+
+(global-auto-complete-mode t)
+(setq ac-auto-show-menu t)
+(setq ac-dwim t)
+(setq ac-use-menu-map t)
+(setq ac-quick-help-delay 1)
+(setq ac-quick-help-height 60)
+
+(set-default 'ac-sources
+ '(ac-source-dictionary
+ ac-source-words-in-buffer
+ ac-source-words-in-same-mode-buffers
+ ac-source-words-in-all-buffer))
+
+(dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
+ sass-mode yaml-mode csv-mode espresso-mode haskell-mode
+ html-mode nxml-mode sh-mode smarty-mode clojure-mode
+ lisp-mode javascript-mode textile-mode markdown-mode tuareg-mode))
+ (add-to-list 'ac-modes mode))
+
+
+;;ac-slime auto-complete plugin
+(add-lib-path "ac-slime")
+(require 'ac-slime)
+(add-hook 'slime-mode-hook 'set-up-slime-ac)
+(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
+
+
+;;Key triggers
+(ac-set-trigger-key "TAB")
+(define-key ac-completing-map (kbd "C-M-n") 'ac-next)
+(define-key ac-completing-map (kbd "C-M-p") 'ac-previous)
+(define-key ac-completing-map "\t" 'ac-complete)
+(define-key ac-completing-map "\r" nil)
+
View
5 conf/bindings.el
@@ -0,0 +1,5 @@
+(global-set-key [up] nil)
+(global-set-key [down] nil)
+(global-set-key [left] nil)
+(global-set-key [right] nil)
+
View
38 conf/clojure.el
@@ -0,0 +1,38 @@
+(add-lib-path "clojure-mode")
+(require 'clojure-mode)
+(require 'rainbow-parens)
+(require 'rainbow-delimiters)
+
+
+(add-hook 'clojure-mode-hook 'rainbow-delimiters-mode)
+(add-hook 'clojure-mode-hook 'rainbow-paren-mode)
+
+(eval-after-load 'clojure-mode
+ '(font-lock-add-keywords
+ 'clojure-mode `(("(\\(fn\\)[\[[:space:]]"
+ (0 (progn (compose-region (match-beginning 1)
+ (match-end 1) "λ")
+ nil))))))
+
+(eval-after-load 'clojure-mode
+ '(font-lock-add-keywords
+ 'clojure-mode `(("\\(#\\)("
+ (0 (progn (compose-region (match-beginning 1)
+ (match-end 1) "ƒ")
+ nil))))))
+
+(eval-after-load 'clojure-mode
+ '(font-lock-add-keywords
+ 'clojure-mode `(("\\(#\\){"
+ (0 (progn (compose-region (match-beginning 1)
+ (match-end 1) "")
+ nil))))))
+
+(eval-after-load 'find-file-in-project
+ '(add-to-list 'ffip-patterns "*.clj"))
+
+
+;;command to align let statements
+;;To use: M-x align-cljlet
+(add-lib-path "align-cljlet")
+(require 'align-cljlet)
View
9 lib/set-colors.el → conf/colors.el
@@ -1,7 +1,10 @@
-(defun set-colors ()
+(require 'color-theme)
+(color-theme-initialize)
+
+(defun theme-1 ()
(interactive)
(color-theme-install
- '(set-colors
+ '(theme-1
((background-color . "#050005")
(foreground-color . "#FFFFFF")
(background-mode . dark)
@@ -22,4 +25,4 @@
(font-lock-type-face ((t (:foreground "#C1E400"))))
)))
-(provide 'set-colors)
+(theme-1)
View
53 conf/core.el
@@ -0,0 +1,53 @@
+(defalias 'yes-or-no-p 'y-or-n-p)
+
+(setq make-backup-files nil)
+(setq auto-save-default nil)
+(setq confirm-kill-emacs nil)
+
+(setq visible-bell t
+ column-number-mode t
+ echo-keystrokes 0.1
+ font-lock-maximum-decoration t
+ inhibit-startup-message t
+ transient-mark-mode t
+ color-theme-is-global t
+ shift-select-mode nil
+ mouse-yank-at-point t
+ require-final-newline t
+ truncate-partial-width-windows nil
+ delete-by-moving-to-trash nil
+ uniquify-buffer-name-style 'forward
+ ediff-window-setup-function 'ediff-setup-windows-plain
+ xterm-mouse-mode t)
+
+(setq locale-coding-system 'utf-8)
+(set-terminal-coding-system 'utf-8)
+(set-keyboard-coding-system 'utf-8)
+(set-selection-coding-system 'utf-8)
+(prefer-coding-system 'utf-8)
+(ansi-color-for-comint-mode-on)
+
+(set-default 'indent-tabs-mode nil)
+(auto-compression-mode t)
+
+(random t) ;; Seed the random-number generator
+
+(setq diff-switches "-u")
+
+;; make emacs use the clipboard
+(setq x-select-enable-clipboard t)
+
+(setq confirm-nonexistent-file-or-buffer nil)
+
+;;remove all trailing whitespace and trailing blank lines before saving the file
+(add-hook 'before-save-hook 'delete-trailing-whitespace)
+(add-hook 'before-save-hook 'delete-trailing-blank-lines)
+
+(defun delete-trailing-blank-lines ()
+ "Deletes all blank lines at the end of the file."
+ (interactive)
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-max))
+ (delete-blank-lines))))
View
3 conf/durendal.el
@@ -0,0 +1,3 @@
+(add-lib-path "durendal")
+(require 'durendal)
+(durendal-enable)
View
5 conf/erc.el
@@ -0,0 +1,5 @@
+(setq erc-truncate-buffer-on-save t)
+(defvar erc-insert-post-hook)
+(add-hook 'erc-insert-post-hook
+ 'erc-truncate-buffer)
+(setq erc-max-buffer-size 20000)
View
3 conf/highlight-flash.el
@@ -0,0 +1,3 @@
+(require 'highlight)
+(require 'eval-sexp-fu)
+(setq eval-sexp-fu-flash-duration 0.5)
View
7 conf/ido.el
@@ -0,0 +1,7 @@
+(ido-mode t)
+(setq ido-enable-prefix nil
+ ido-enable-flex-matching t
+ ido-create-new-buffer 'always
+ ido-use-filename-at-point 'guess
+ ido-max-prospects 10)
+
View
2 conf/js2.el
@@ -0,0 +1,2 @@
+(autoload 'js2-mode "js2-mode" nil t)
+(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
View
12 conf/lisp.el
@@ -0,0 +1,12 @@
+(show-paren-mode 1)
+
+(define-key lisp-mode-shared-map (kbd "RET") 'reindent-then-newline-and-indent)
+
+(defun turn-on-paredit ()
+ (paredit-mode t))
+
+(dolist (x '(scheme emacs-lisp lisp clojure))
+ (add-hook
+ (intern (concat (symbol-name x) "-mode-hook")) 'turn-on-paredit)
+ (add-hook
+ (intern (concat (symbol-name x) "-mode-hook")) 'rainbow-paren-mode))
View
23 conf/org.el
@@ -0,0 +1,23 @@
+(global-set-key (kbd "C-c C-o") 'org-iswitchb)
+
+;;(setq org-agenda-files +org-files+)
+(define-key global-map "\C-cl" 'org-store-link)
+(define-key global-map "\C-ca" 'org-agenda)
+
+(setq org-log-done 'time)
+(setq org-use-fast-todo-selection t)
+
+(setq org-todo-keyword-faces (quote (("TODO" :foreground "red" :weight bold)
+ ("STARTED" :foreground "blue" :weight bold)
+ ("DONE" :foreground "forest green" :weight bold)
+ ("WAITING" :foreground "orange" :weight bold)
+ ("SOMEDAY" :foreground "magenta" :weight bold)
+ ("CANCELLED" :foreground "forest green" :weight bold)
+ ("QUOTE" :foreground "red" :weight bold)
+ ("QUOTED" :foreground "magenta" :weight bold)
+ ("APPROVED" :foreground "forest green" :weight bold)
+ ("EXPIRED" :foreground "forest green" :weight bold)
+ ("REJECTED" :foreground "forest green" :weight bold)
+ ("OPEN" :foreground "blue" :weight bold))))
+
+(run-at-time "00:59" 3600 'org-save-all-org-buffers)
View
5 conf/paredit.el
@@ -0,0 +1,5 @@
+(eval-after-load 'paredit
+ ;; need a binding that works in the terminal
+ '(define-key paredit-mode-map (kbd "M-)") 'paredit-forward-slurp-sexp))
+
+(require 'paredit)
View
10 conf/slime.el
@@ -0,0 +1,10 @@
+(add-lib-path "slime")
+(require 'slime)
+
+(eval-after-load "slime"
+ '(progn (slime-setup '(slime-repl))
+ (defun paredit-mode-enable () (paredit-mode 1))
+ (add-hook 'slime-repl-mode-hook 'paredit-mode-enable)
+ (add-hook 'slime-repl-mode-hook 'clojure-mode-font-lock-setup)
+ (setq slime-protocol-version 'ignore)))
+(slime-setup '(slime-scratch slime-editing-commands))
View
7 conf/smex.el
@@ -0,0 +1,7 @@
+(add-lib-path "smex")
+(require 'smex)
+(smex-initialize)
+(global-set-key (kbd "M-x") 'smex)
+(global-set-key (kbd "M-X") 'smex-major-mode-commands)
+;; This is your old M-x.
+(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
View
1 conf/twitter.el
@@ -0,0 +1 @@
+(setq twittering-use-master-password t)
View
13 conf/ui.el
@@ -0,0 +1,13 @@
+(tool-bar-mode -1)
+(menu-bar-mode -1)
+(scroll-bar-mode -1)
+(set-default-font "Inconsolata:pixelsize=16:foundry=unknown:weight=normal:slant=normal:width=normal:spacing=100:scalable=true")
+(set-face-attribute 'default nil :height 100)
+
+;;highlight current line
+(global-hl-line-mode 1)
+(set-face-background 'hl-line "#111")
+
+;;set cursor colour
+(set-cursor-color "yellow")
+
View
3 conf/undo-tree.el
@@ -0,0 +1,3 @@
+(add-lib-path "undo-tree")
+(require 'undo-tree)
+(global-undo-tree-mode)
View
2 conf/yasnippet.el
@@ -0,0 +1,2 @@
+(yas/initialize)
+(yas/load-directory "~/.local/share/snippets")
View
33 init.el
@@ -0,0 +1,33 @@
+(defconst +home-dir+ "~")
+(defconst +emacs-dir+ (concat +home-dir+ "/.config/emacsfiles"))
+(defconst +emacs-profiles-dir+ (concat +emacs-dir+ "/profiles"))
+(defconst +emacs-lib-dir+ (concat +emacs-dir+ "/lib"))
+(defconst +emacs-conf-dir+ (concat +emacs-dir+ "/conf"))
+(defconst +emacs-tmp-dir+ (concat +emacs-dir+ "/tmp"))
+
+(defun add-load-path (p)
+ (add-to-list 'load-path (concat +emacs-dir+ "/" p)))
+
+(defun add-lib-path (p)
+ (add-to-list 'load-path (concat +emacs-lib-dir+ "/" p)))
+
+(defun load-conf-file (f)
+ (load-file (concat +emacs-conf-dir+ "/" f)))
+
+(defun load-lib-file (f)
+ (load-file (concat +emacs-lib-dir+ "/" f)))
+
+(defun load-profile(p)
+ (message (format "Loading profile: \"%s\"..." p))
+ (load-file (concat +emacs-profiles-dir+ "/" p ".el")))
+
+(add-load-path "")
+(add-load-path "lib")
+
+(load-profile "default")
+
+(add-to-list 'command-switch-alist '("dev" . (lambda (n) (load-profile "dev"))))
+(add-to-list 'command-switch-alist '("irc" . (lambda (n) (load-profile "irc"))))
+(add-to-list 'command-switch-alist '("org" . (lambda (n) (load-profile "org"))))
+(add-to-list 'command-switch-alist '("android" . (lambda (n) (load-profile "android"))))
+
View
74 lib/ac-slime.el
@@ -0,0 +1,74 @@
+;;----------------------------------------------------------------------------
+;; An auto-complete source using slime completions
+;;
+;; Author: Steve Purcell <steve at sanityinc dot com>
+;;
+;; Usage:
+;; (require 'ac-slime)
+;; (add-hook 'slime-mode-hook 'set-up-slime-ac)
+;; (add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
+;;----------------------------------------------------------------------------
+
+(eval-when-compile (require 'cl))
+
+(defun ac-source-slime-fuzzy-candidates ()
+ "Return a possibly-empty list of fuzzy completions for the symbol at point."
+ (if (slime-connected-p)
+ (let ((slime-fuzzy-completion-limit 50))
+ (mapcar 'car (car (slime-fuzzy-completions ac-prefix))))))
+
+(defun ac-source-slime-simple-candidates ()
+ "Return a possibly-empty list of completions for the symbol at point."
+ (if (slime-connected-p)
+ (car (slime-simple-completions ac-prefix))))
+
+(defvar ac-slime-current-doc nil "Holds slime docstring for current symbol")
+(defun ac-slime-documentation (symbol-name)
+ (let ((symbol-name (substring-no-properties symbol-name)))
+ (slime-eval `(swank:documentation-symbol ,symbol-name))))
+
+(defun ac-slime-init ()
+ (setq ac-slime-current-doc nil))
+
+(defface ac-slime-menu-face
+ '((t (:inherit 'ac-candidate-face)))
+ "Face for slime candidate menu."
+ :group 'auto-complete)
+
+(defface ac-slime-selection-face
+ '((t (:inherit 'ac-selection-face)))
+ "Face for the slime selected candidate."
+ :group 'auto-complete)
+
+(defvar ac-source-slime-fuzzy
+ '((init . ac-slime-init)
+ (candidates . ac-source-slime-fuzzy-candidates)
+ (candidate-face . ac-slime-menu-face)
+ (selection-face . ac-slime-selection-face)
+ (prefix . slime-symbol-start-pos)
+ (symbol . "l")
+ (document . ac-slime-documentation))
+ "Source for fuzzy slime completion")
+
+(defvar ac-source-slime-simple
+ '((init . ac-slime-init)
+ (candidates . ac-source-slime-simple-candidates)
+ (candidate-face . ac-slime-menu-face)
+ (selection-face . ac-slime-selection-face)
+ (prefix . slime-symbol-start-pos)
+ (symbol . "l")
+ (document . ac-slime-documentation))
+ "Source for slime completion")
+
+
+(defun set-up-slime-ac (&optional fuzzy)
+ "Add an optionally-fuzzy slime completion source to the
+front of `ac-sources' for the current buffer."
+ (interactive)
+ (setq ac-sources (add-to-list 'ac-sources
+ (if fuzzy
+ 'ac-source-slime-fuzzy
+ 'ac-source-slime-simple))))
+
+
+(provide 'ac-slime)
1 lib/align-cljlet
@@ -0,0 +1 @@
+Subproject commit a458001d8539cd5c39af9ae84c871ee6e36a0651
1 lib/auto-complete
@@ -0,0 +1 @@
+Subproject commit 09a5fbd52ffdcce046d4552b70cfa5acb7f58d67
View
215 lib/dircolors.el
@@ -0,0 +1,215 @@
+
+;;; dircolors.el -- provide the same facility of ls --color inside emacs
+
+;; Copyright (C) 2000 Padioleau yoann <padiolea@irisa.fr>
+;; Copyright (C) 2000 Besson fr�d�ric <fbesson@irisa.fr>
+
+;; This file 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 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; Emacs Lisp Archive Entry
+;; Filename: dircolors.el
+;; Author: Padioleau Yoann <padiolea@irisa.fr>
+;; Version: 1.0
+
+;;; Goal
+; try to colorize the buffers of emacs as ls --color do in a terminal
+; so if you try C-x b TAB or C-x C-f, you will see directory in blue
+; c source file in yellow, object file in gray, ....
+; it helps a lot to find the file you want to open
+
+;;; Usage
+; Add the following lines to ~/.emacs or an equivalent
+; (require 'dircolors)
+; you can customize this module by :
+; - changing the colors of some faces for example with
+; (set-face-foreground 'dircolors-face-asm "blue")
+; - adding some faces/extension for example with
+; (make-face 'myface-modula)
+; (set-face-foreground 'myface-modula "yellow")
+; (setq dircolors-extension (cons '(("mod" "md3") myface-modula) dircolors-extension)
+; - make dircolors working for other emacs buffer
+; (add-hook 'completion-list-mode-hook 'dircolors)
+; (remove-hook 'completion-list-mode-hook 'dircolors)
+
+;;; Code
+
+;; generic functions not included in emacs
+
+(provide 'dircolors)
+
+(defun join-string(xs &optional sep)
+ (cond ((null xs) "")
+ ((null (cdr xs)) (car xs))
+ (t (concat (car xs) (or sep " ") (join-string (cdr xs) sep)))))
+
+(defun map-apply(func xs)
+ (mapcar #'(lambda (l)(apply func l)) xs))
+
+;; here start the real code
+
+;; configuration variables
+(defvar dircolors-face-color
+ '(
+ (dircolors-face-dir "orange" )
+ (dircolors-face-text "red")
+ (dircolors-face-doc "red")
+ (dircolors-face-html "magenta" )
+ (dircolors-face-package "firebrick" )
+ (dircolors-face-tar "firebrick" )
+ (dircolors-face-dos "darkred" )
+ (dircolors-face-sound "yellow" )
+ (dircolors-face-img "yellow" )
+ (dircolors-face-ps "brown" )
+ (dircolors-face-backup "darkslategrey" )
+ (dircolors-face-make "seagreen" )
+ (dircolors-face-paddb "Orange" )
+ (dircolors-face-lang "lightblue" )
+ (dircolors-face-emacs "purple" )
+ (dircolors-face-lang-interface "deepskyblue" )
+ (dircolors-face-yacc "dodgerblue" )
+ (dircolors-face-objet "orangered" )
+ (dircolors-face-exec "red" )
+ (dircolors-face-asm "Tan" )
+ (dircolors-face-compress "firebrick" )
+ ))
+
+(defvar dircolors-extension
+ '(
+ (("txt" "doc" "tex" "texi" "man" "w" "text" "md" "markdown"
+ (r "README") (r "readme")
+ ) dircolors-face-doc)
+ (("htm" "html" "html\\.gz" "htm\\.gz" "xml")
+ dircolors-face-html)
+ (("rpm" "deb" ) dircolors-face-package)
+ (("tar" "tgz" "tar.gz" "tar.bz2" "zip" "rar") dircolors-face-tar)
+ (("cmd" "exe" "com" "bat") dircolors-face-dos)
+ (("mp3" "s3m" "mod" "au" "wav") dircolors-face-sound)
+ (("jpg" "gif" "bmp" "xbm" "tif"
+ "xpm" "jpeg" "fig" "png"
+ ) dircolors-face-img)
+ (("ps" "pdf" "ps\\.gz" "eps" "dvi") dircolors-face-ps)
+ (("bak" "BAK" (r "\\.save")) dircolors-face-backup)
+ (((r "akefile")) dircolors-face-make)
+ (("db") dircolors-face-paddb)
+ (("ml"
+ "hs" "lhs"
+ "scm" "sc"
+ "p" "pas"
+ "c" "cpp" "c\\+\\+"
+ "cc"
+ "pm" "pl" "m"
+ "bet" "sql"
+ "java" "sty" "xsl" "awk"
+ "ik" "rb" "yaml" "yml" "clj"
+ ) dircolors-face-lang)
+ (( "el" "emacs") dircolors-face-emacs)
+
+ (("mli"
+ "h" "hpp" "hh"
+ ) dircolors-face-lang-interface)
+ (("ly" "mly" "mll"
+ "l" "y"
+ "l\\+\\+" "y\\+\\+"
+ "ll" "yy") dircolors-face-yacc)
+ (("class" "o" "cmi" "cmo" "zi" "zo") dircolors-face-objet)
+ (("") dircolors-face-exec)
+ (("asm" "s" "S" ) dircolors-face-asm)
+ ; last because can conflict
+ (("gz" ) dircolors-face-compress)
+ )
+ "the syntax is (extension list face), where extension can be either of the
+ simple form string in which case it is interpreted as an extension
+ for example \"txt\" will colorise all string that ends with .txt
+ or can be of the form (r regexp)"
+ )
+
+
+;; Internal variable
+(defvar dircolors-font-lock-keywords nil )
+
+
+;; compiling
+
+(defun dircolors-compile-extension (e)
+ " string | ( r * string) -> regexp"
+ (if (stringp e)
+ (concat "\\w*\\." e "\\>")
+ (concat "\\w*" (cadr e) "\\w*\\>") ;regexp '(r "reg")
+ ))
+
+
+(defun dircolors-compile-extension-list (l face)
+ "(extension list * face) -> regexp list * face"
+ (list
+ (join-string (mapcar 'dircolors-compile-extension l) "\\|")
+ face)
+ )
+
+
+
+(defun dircolors-boot ()
+ "Initialisation..."
+ ;; create faces
+ (map-apply (lambda (symb face)
+ (set-face-foreground (make-face symb) face)
+ )
+ dircolors-face-color)
+ ;; compile spec
+ (setq dircolors-font-lock-keywords
+ (cons
+ '("\\w*/" dircolors-face-dir)
+ (map-apply (lambda (l face) (dircolors-compile-extension-list l face))
+ dircolors-extension)
+ ))
+ )
+
+
+(defun dircolors()
+ (interactive)
+ (save-excursion
+ (let ( (rd-only buffer-read-only))
+ (condition-case nil
+ (progn
+ ;; chars _ - + . are word constituent
+ (modify-syntax-entry ?_ "w")
+ (modify-syntax-entry ?- "w")
+ (modify-syntax-entry ?+ "w")
+ (modify-syntax-entry ?. "w")
+
+ (toggle-read-only -1)
+
+ ;; direct search seems faster than font-lock-mode
+ (map-apply (lambda (regexp face)
+ (goto-char (point-min))
+ (while (re-search-forward regexp (point-max) t)
+ (let ( (begin (match-beginning 0)) (end (match-end 0)))
+ (remove-text-properties begin end '(face nil))
+ (add-text-properties begin end
+ (list 'face face)))
+ )
+ )
+ dircolors-font-lock-keywords)
+ (toggle-read-only (if rd-only 1 -1 ))
+ )
+ (t (toggle-read-only (if rd-only 1 -1)))
+ )
+ )))
+
+;;; run
+(dircolors-boot)
+
+(add-hook 'completion-list-mode-hook 'dircolors)
+(add-hook 'buffer-menu-mode-hook 'dircolors)
1 lib/durendal
@@ -0,0 +1 @@
+Subproject commit 9b44a0ffb5a0bcfbdf51f11e7c3dec40156d82f8
View
470 lib/eval-sexp-fu.el
@@ -0,0 +1,470 @@
+;;; eval-sexp-fu.el --- Tiny functionality enhancements for evaluating sexps.
+
+;; Copyright (C) 2009 Takeshi Banse <takebi@laafc.net>
+;; Author: Takeshi Banse <takebi@laafc.net>
+;; Keywords: lisp, highlight, convenience
+
+;; 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, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+;;
+;; Tiny functionality enhancements for evaluating sexps.
+;; This package provides:
+;; - Flashing the sexps during the evaluation.
+;; - `eval-last-sexp' variants (inner-list/inner-sexp).
+
+;;; Installation:
+;;
+;; Put the highlight.el to your load-path.
+;; Then require this package.
+
+;;; Commands:
+;;
+;; Below are complete command list:
+;;
+;; `eval-sexp-fu-flash-mode'
+;; Toggle EvalSexpFuFlash mode on or off. If this mode is on, some `eval-last-sexp'-ish commands will highlight the sexps during evaluation.
+;; `turn-on-eval-sexp-fu-flash-mode'
+;; Unequivocally turn on EvalSexpFuFlash mode
+;; `eval-sexp-fu-eval-sexp-inner-list'
+;; Evaluate the list _currently_ pointed at as sexp; print value in minibuffer.
+;; `eval-sexp-fu-eval-sexp-inner-sexp'
+;; Evaluate the sexp _currently_ pointed; print value in minibuffer.
+;;
+;;; Customizable Options:
+;;
+;; Below are customizable option list:
+;;
+;; `eval-sexp-fu-flash-face'
+;; *Face to use for showing the sexps' overlay during the evaluation.
+;; default = (quote eval-sexp-fu-flash)
+;; `eval-sexp-fu-flash-error-face'
+;; *Face to use for showing the sexps' overlay if the evaluation signaled any error. The error highlighting is take into account only if non-nil value.
+;; default = (quote eval-sexp-fu-flash-error)
+;; `eval-sexp-fu-flash-duration'
+;; *For time duration, highlight the evaluating sexps.
+;; default = 0.15
+;; `eval-sexp-fu-flash-error-duration'
+;; *For time duration, highlight the evaluating sexps signaled errors.
+;; default = 0.3
+;; `eval-sexp-fu-flash-function'
+;; *Function to be used to create all of the actual flashing implementations.
+;; default = (quote eval-sexp-fu-flash-default)
+;; `eval-sexp-fu-flash-doit-function'
+;; *Function to use for flashing the sexps.
+;; default = (quote eval-sexp-fu-flash-doit-simple)
+
+;;; Note:
+;;
+;; For SLIME user, this package registers the setup clauses which set up the
+;; flashers and the several interactive commands at `eval-after-load' the
+;; 'slime phase. The interactive commands bellow will be defined,
+;; `eval-sexp-fu-slime-eval-expression-inner-list',
+;; `eval-sexp-fu-slime-eval-expression-inner-sexp'
+;; and the pprint variants respectively.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'highlight)
+
+(defgroup eval-sexp-fu nil
+ "Tiny functionality enhancements for evaluating sexps."
+ :prefix "eval-sexp-fu-"
+ :group 'eval-sexp-fu)
+
+;;; Flashing the sexps during the evaluation for just an eye candy.
+(defface eval-sexp-fu-flash
+ '((((class color)) (:background "blue" :foreground "white" :bold t))
+ (t (:inverse-video t)))
+ "Face for highlighting sexps during evaluation."
+ :group 'eval-sexp-fu)
+(defface eval-sexp-fu-flash-error
+ '((((class color)) (:foreground "red" :bold t))
+ (t (:inverse-video t)))
+ "Face for highlighting sexps signaled errors during evaluation."
+ :group 'eval-sexp-fu)
+
+(defcustom eval-sexp-fu-flash-face 'eval-sexp-fu-flash
+ "*Face to use for showing the sexps' overlay during the evaluation."
+ :type 'face
+ :group 'eval-sexp-fu)
+(defcustom eval-sexp-fu-flash-error-face 'eval-sexp-fu-flash-error
+ "*Face to use for showing the sexps' overlay if the evaluation signaled any error. The error highlighting is take into account only if non-nil value."
+ :type 'face
+ :group 'eval-sexp-fu)
+(defcustom eval-sexp-fu-flash-duration 0.15
+ "*For time duration, highlight the evaluating sexps."
+ :type 'number
+ :group 'eval-sexp-fu)
+(defcustom eval-sexp-fu-flash-error-duration 0.3
+ "*For time duration, highlight the evaluating sexps signaled errors."
+ :type 'number
+ :group 'eval-sexp-fu)
+(defcustom eval-sexp-fu-flash-function 'eval-sexp-fu-flash-default
+ "*Function to be used to create all of the actual flashing implementations."
+ :type 'function
+ :group 'eval-sexp-fu)
+
+(defun esf-hl-highlight-bounds (bounds face buf)
+ (with-current-buffer buf
+ (hlt-highlight-region (car bounds) (cdr bounds) face)))
+(defun esf-hl-unhighlight-bounds (bounds buf)
+ (with-current-buffer buf
+ (hlt-unhighlight-region (car bounds) (cdr bounds))))
+(defun esf-flash-error-bounds (bounds buf face)
+ (when face
+ (let ((flash-error
+ (lambda (bounds buf face)
+ (esf-hl-highlight-bounds bounds face buf)
+ (run-at-time eval-sexp-fu-flash-error-duration nil
+ 'esf-hl-unhighlight-bounds
+ bounds buf))))
+ (run-with-idle-timer (max eval-sexp-fu-flash-error-duration
+ eval-sexp-fu-flash-duration)
+ nil flash-error
+ bounds buf face))))
+(defun* eval-sexp-fu-flash (bounds &optional (face eval-sexp-fu-flash-face) (eface eval-sexp-fu-flash-error-face))
+ "BOUNS is either the cell or the function returns, such that (BEGIN . END).
+Reurn the 4 values; bounds, highlighting, un-highlighting and error flashing procedure. This function is convenient to use with `define-eval-sexp-fu-flash-command'."
+ (when (ignore-errors (preceding-sexp))
+ (flet ((bounds () (if (functionp bounds) (funcall bounds) bounds)))
+ (let ((b (bounds)) (buf (current-buffer)))
+ (when b
+ (funcall eval-sexp-fu-flash-function b face eface buf))))))
+(defun eval-sexp-fu-flash-default (bounds face eface buf)
+ "Create all of the actual flashing implementations. See also `eval-sexp-fu-flash'."
+ (lexical-let ((bounds bounds) (face face) (eface eface) (buf buf))
+ (values bounds
+ (apply-partially 'esf-hl-highlight-bounds bounds face buf)
+ (apply-partially 'esf-hl-unhighlight-bounds bounds buf)
+ (apply-partially 'esf-flash-error-bounds bounds buf eface))))
+
+(defcustom eval-sexp-fu-flash-doit-function 'eval-sexp-fu-flash-doit-simple
+ "*Function to use for flashing the sexps.
+
+Please see the actual implementations:
+- `eval-sexp-fu-flash-doit-simple'
+- `eval-sexp-fu-flash-doit-hold-on-error'"
+ :type 'function
+ :group 'eval-sexp-fu)
+(defun eval-sexp-fu-flash-doit (do-it-thunk hi unhi)
+ (funcall eval-sexp-fu-flash-doit-function do-it-thunk hi unhi))
+(defun eval-sexp-fu-flash-doit-simple (do-it-thunk hi unhi)
+ (funcall hi)
+ (run-at-time eval-sexp-fu-flash-duration nil unhi)
+ (funcall do-it-thunk))
+(defun eval-sexp-fu-flash-doit-hold-on-error (do-it-thunk hi unhi)
+ (funcall hi)
+ (unwind-protect
+ (funcall do-it-thunk)
+ (run-at-time eval-sexp-fu-flash-duration nil unhi)))
+
+(defmacro esf-konstantly (v)
+ `(lambda (&rest _it) ,v))
+(defmacro esf-unwind-protect-with-tracking (normallyp body unwind)
+ (declare (indent 2))
+ `(let (,normallyp)
+ (unwind-protect
+ (prog1 ,body
+ (setq ,normallyp t))
+ ,unwind)))
+(defun esf-flash-doit (do-it-thunk hi unhi eflash)
+ (esf-unwind-protect-with-tracking ret
+ (eval-sexp-fu-flash-doit do-it-thunk hi unhi)
+ (unless ret
+ (funcall eflash))))
+
+;; Entry point.
+(defmacro define-eval-sexp-fu-flash-command (command form)
+ "Install the flasher implemented as the COMMAND's around advice.
+
+FORM is expected to return 4 values;
+- A bounds (BEGIN . END) to be highlighted or nil.
+- An actual highlighting procedure takes 0 arguments.
+- An actual un-highliting procedure takes 0 arguments.
+- An actual flashing error procedure takes 0 arguments.
+See also `eval-sexp-fu-flash'."
+ (declare (indent 1))
+ `(defadvice ,command (around eval-sexp-fu-flash-region activate)
+ (if eval-sexp-fu-flash-mode
+ (multiple-value-bind (bounds hi unhi eflash) ,form
+ (if bounds
+ (esf-flash-doit (esf-konstantly ad-do-it) hi unhi eflash)
+ ad-do-it))
+ ad-do-it)))
+(define-minor-mode eval-sexp-fu-flash-mode
+ "Toggle EvalSexpFuFlash mode on or off. If this mode is on, some `eval-last-sexp'-ish commands will highlight the sexps during evaluation."
+ :init-value t :global t)
+(defun turn-on-eval-sexp-fu-flash-mode ()
+ "Unequivocally turn on EvalSexpFuFlash mode
+ (see also `eval-sexp-fu-flash-mode')."
+ (interactive)
+ (eval-sexp-fu-flash-mode 1))
+
+;;; eval-inner- stuff.
+(defun esf-funcall-and-eval-last-sexp (before eval-last-sexp)
+ "Call 0 arg procedure BEFORE then call interactive command EVAL-LAST-SEXP."
+ (save-excursion
+ (funcall before)
+ (call-interactively eval-last-sexp)))
+
+(require 'rx)
+(defun esf-forward-inner-sexp0 ()
+ (flet ((poss ()
+ (let
+ ((prev (save-excursion (backward-sexp) (forward-sexp) (point)))
+ (next (save-excursion (forward-sexp) (backward-sexp) (point))))
+ (list prev (line-number-at-pos prev)
+ next (line-number-at-pos next)
+ (point) (line-number-at-pos)))))
+ (cond ((looking-at (rx (or (syntax symbol) (syntax word)
+ (syntax open-parenthesis))))
+ (forward-sexp))
+ (t (destructuring-bind (pp pl np nl cp cl) (poss)
+ (cond ((and (<= pp cp) (<= cp np))
+ (cond ((= pl cl) (backward-sexp))
+ ((= nl cl))
+ ((< (- cl pl) (- nl cl)) (backward-sexp))
+ ((< (- nl cl) (- cl pl)))
+ (t (backward-sexp)))
+ (forward-sexp))
+ (t (backward-sexp) (forward-sexp))))))))
+(defun esf-forward-inner-sexp ()
+ (condition-case nil
+ (esf-forward-inner-sexp0)
+ (scan-error nil)))
+(defun esf-backward-up-inner-list0 (steps)
+ (unless steps (setq steps 1))
+ (when (looking-at (rx (syntax open-parenthesis))) (decf steps))
+ (dotimes (_ steps) (backward-up-list)))
+(defun esf-backward-up-inner-list (steps)
+ (condition-case nil
+ (esf-backward-up-inner-list0 steps)
+ (scan-error nil)))
+(defun esf-end-of-backward-up-inner-list (steps)
+ (esf-backward-up-inner-list steps)
+ (esf-forward-inner-sexp))
+
+(defun eval-sexp-fu-eval-sexp-inner-list (&optional arg)
+ "Evaluate the list _currently_ pointed at as sexp; print value in minibuffer.
+
+Interactivelly with numeric prefix argument, call to `backward-up-list' happens several times. This function is an \"Evaluate this N lists, please.\" thing."
+ (interactive "P")
+ (esf-funcall-and-eval-last-sexp (apply-partially
+ 'esf-end-of-backward-up-inner-list arg)
+ 'esf-eval-last-sexp))
+(defun eval-sexp-fu-eval-sexp-inner-sexp ()
+ "Evaluate the sexp _currently_ pointed; print value in minibuffer."
+ (interactive)
+ (esf-funcall-and-eval-last-sexp 'esf-forward-inner-sexp 'esf-eval-last-sexp))
+
+(defmacro define-esf-eval-last-sexp-1 (command-name eval-last-sexp)
+ "Define an interactive command COMMAND-NAME kind of EVAL-LAST-SEXP
+such that ignores any prefix arguments."
+ `(defun ,command-name ()
+ (interactive)
+ (let (current-prefix-arg)
+ (call-interactively ',eval-last-sexp))))
+(define-esf-eval-last-sexp-1 esf-eval-last-sexp eval-last-sexp)
+
+;; Piece of code which defines the above inner-{sexp,list} functions.
+;; This makes it possible to batch install the
+;; eval-sexp-fu-eval-sexp-inner-{sexp,list} with below form.
+;; * (define-eval-sexp-fu-eval-sexp eval-sexp-fu-eval-sexp eval-last-sexp)
+;; Used by making the `slime-eval-last-expression' variant functions.
+(defmacro define-esf-eval-sexp* (eval-last-sexp inner-sexp inner-list)
+ "Based on EVAL-LAST-SEXP, define INNER-SEXP and INNER-LIST interactive commands."
+ (declare (indent 1))
+ `(progn
+ (defun ,inner-sexp ()
+ (interactive)
+ (esf-funcall-and-eval-last-sexp 'esf-forward-inner-sexp
+ ',eval-last-sexp))
+ (defun ,inner-list (&optional arg)
+ (interactive "P")
+ (esf-funcall-and-eval-last-sexp (apply-partially
+ 'esf-end-of-backward-up-inner-list arg)
+ ',eval-last-sexp))))
+(defmacro define-eval-sexp-fu-eval-sexp (command-name-prefix eval-last-sexp)
+ "Define -inner-sexp and -inner-list interactive commands prefixed by COMMAND-NAME-PREFIX based on EVAL-LAST-SEXP. Actual work is done by `define-esf-eval-sexp*'."
+ (let ((esf-eval-last-sexp-1
+ (intern (format "esf-%s-1" (symbol-name eval-last-sexp)))))
+ `(progn
+ (define-esf-eval-last-sexp-1 ,esf-eval-last-sexp-1 ,eval-last-sexp)
+ (define-esf-eval-sexp* ,esf-eval-last-sexp-1
+ ,@(mapcar (lambda (post)
+ (intern (concat (symbol-name command-name-prefix) post)))
+ '("-inner-sexp" "-inner-list"))))))
+
+;;; initialize.
+(defun esf-initialize ()
+ (define-eval-sexp-fu-flash-command eval-last-sexp
+ (eval-sexp-fu-flash (save-excursion
+ (backward-char)
+ (bounds-of-thing-at-point 'sexp))))
+ (define-eval-sexp-fu-flash-command eval-defun
+ (eval-sexp-fu-flash (save-excursion
+ (end-of-defun)
+ (beginning-of-defun)
+ (bounds-of-thing-at-point 'sexp))))
+ (eval-after-load 'eev
+ '(progn
+ ;; `eek-eval-last-sexp' is defined in eev.el.
+ (define-eval-sexp-fu-flash-command eek-eval-last-sexp
+ (eval-sexp-fu-flash (cons (save-excursion (eek-backward-sexp))
+ (point)))))))
+(defun esf-initialize-slime ()
+ (define-eval-sexp-fu-flash-command slime-eval-last-expression
+ (eval-sexp-fu-flash (save-excursion
+ (backward-char)
+ (bounds-of-thing-at-point 'sexp))))
+ (define-eval-sexp-fu-flash-command slime-pprint-eval-last-expression
+ (eval-sexp-fu-flash (save-excursion
+ (backward-char)
+ (bounds-of-thing-at-point 'sexp))))
+ (define-eval-sexp-fu-flash-command slime-eval-defun
+ (eval-sexp-fu-flash (save-excursion
+ (slime-end-of-defun)
+ (slime-beginning-of-defun)
+ (bounds-of-thing-at-point 'sexp))))
+ (progn
+ ;; Defines:
+ ;; `eval-sexp-fu-slime-eval-expression-inner-list',
+ ;; `eval-sexp-fu-slime-eval-expression-inner-sexp'
+ ;; and the pprint variants respectively.
+ (define-eval-sexp-fu-eval-sexp eval-sexp-fu-slime-eval-expression
+ slime-eval-last-expression)
+ (define-eval-sexp-fu-eval-sexp eval-sexp-fu-slime-pprint-eval-expression
+ slime-pprint-eval-last-expression)))
+
+(eval-when (load eval)
+ (esf-initialize)
+ (eval-after-load 'slime
+ '(esf-initialize-slime)))
+
+(dont-compile
+ (when (fboundp 'expectations)
+ (expectations
+ (desc "esf-forward-inner-sexp0")
+ (expect ?p
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "s+exp")
+ (goto-char (point-min))
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (expect ?p
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "s+exp")
+ (goto-char (1+ (point-min)))
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (expect ?\)
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "s(exp)")
+ (goto-char (1+ (point-min)))
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (desc "esf-forward-inner-sexp0 same line, but far near the next")
+ ;; Always previous, is this OK?
+ (expect ?0
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "sexp0 sexp1")
+ (goto-char (+ (point-min) 7))
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (desc "esf-forward-inner-sexp0 across lines")
+ (expect ?0
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "sexp0\n\n\n\nsexp1")
+ (goto-char (point-min))
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (expect ?0
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "sexp0\n\n\n\nsexp1")
+ (goto-char (point-min))
+ (forward-line)
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (expect ?1
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "sexp0\n\n\n\nsexp1")
+ (goto-char (point-min))
+ (forward-line 3)
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (expect ?1
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "sexp0\n\n\n\nsexp1")
+ (goto-char (point-min))
+ (forward-line 3)
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (expect ?1
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "sexp0\n\n\n\nsexp1")
+ (goto-char (point-min))
+ (forward-line 4)
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (desc "esf-forward-inner-sexp0 across lines (equal delta)")
+ ;; Always previous lines', is this OK?
+ (expect ?0
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "sexp0\n\n\n\nsexp1")
+ (goto-char (point-min))
+ (forward-line 2)
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (desc "esf-forward-inner-sexp0 no more")
+ (expect ?0
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "sexp0\n\n")
+ (goto-char (point-max))
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (desc "esf-forward-inner-sexp0 no less")
+ (expect ?0
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "\n\nsexp0")
+ (goto-char (point-min))
+ (esf-forward-inner-sexp0)
+ (char-before)))
+ (desc "esf-forward-inner-sexp0 no any")
+ (expect 5
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "\n\n\n\n")
+ (goto-char (point-min))
+ (esf-forward-inner-sexp0)
+ (point)))
+ )))
+
+(provide 'eval-sexp-fu)
+;;; eval-sexp-fu.el ends here
View
1,821 lib/highlight.el
@@ -0,0 +1,1821 @@
+;;; highlight.el --- Highlighting commands.
+;;
+;; Filename: highlight.el
+;; Description: Highlighting commands.
+;; Author: Drew Adams
+;; Maintainer: Drew Adams
+;; Copyright (C) 1995-2010, Drew Adams, all rights reserved.
+;; Created: Wed Oct 11 15:07:46 1995
+;; Version: 21.0
+;; Last-Updated: Fri Jan 15 13:18:50 2010 (-0800)
+;; By: dradams
+;; Update #: 2540
+;; URL: http://www.emacswiki.org/cgi-bin/wiki/highlight.el
+;; Keywords: faces, help, local
+;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x
+;;
+;; Features that might be required by this library:
+;;
+;; `apropos', `apropos+', `avoid', `faces', `faces+', `fit-frame',
+;; `frame-fns', `help+20', `info', `info+', `menu-bar',
+;; `menu-bar+', `misc-cmds', `misc-fns', `second-sel', `strings',
+;; `thingatpt', `thingatpt+', `unaccent', `w32browser-dlgopen',
+;; `wid-edit', `wid-edit+', `widget'.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+;;
+;; Highlighting commands.
+;;
+;; More description below.
+
+;;(@> "Index")
+;;
+;; Index
+;; -----
+;;
+;; If you have library `linkd.el' and Emacs 22 or later, load
+;; `linkd.el' and turn on `linkd-mode' now. It lets you easily
+;; navigate around the sections of this doc. Linkd mode will
+;; highlight this Index, as well as the cross-references and section
+;; headings throughout this file. You can get `linkd.el' here:
+;; http://dto.freeshell.org/notebook/Linkd.html.
+;;
+;; (@> "Things Defined Here")
+;; (@> "Documentation")
+;; (@* "Library `facemenu+.el' Puts Highlight on the Menu")
+;; (@* "User Option `hlt-use-overlays-flag'")
+;; (@* "Commands")
+;; (@* "User Option `hlt-act-on-any-face-flag'")
+;; (@* "Hiding and Showing Text")
+;; (@* "What Gets Highlighted: Region, Buffer, New Text You Type")
+;; (@* "Interference by Font Lock")
+;; (@* "Suggested Bindings")
+;; (@* "Relation to Hi-Lock Mode")
+;; (@* "Commands That Won't Work in Emacs 20")
+;; (@* "To Do")
+;; (@> "Change log")
+;; (@> "Menu-Bar Region Menu")
+;; (@> "Variables and Faces")
+;; (@> "Misc Functions - Emacs 20+")
+;; (@> "Misc Functions - Emacs 21+")
+;; (@> "Functions for Use with Icicles - Emacs 21+")
+;; (@> "Functions for Highlighting Propertized Text - Emacs 21+")
+;; (@> "General functions")
+
+;;(@* "Things Defined Here")
+;;
+;; Things Defined Here
+;; -------------------
+;;
+;; Commands defined here:
+;;
+;; `hlt-choose-default-face', `hlt-choose-faces',
+;; `hlt-choose-invisible-faces', `hlt-choose-visible-faces',
+;; `hlt-eraser', `hlt-eraser-mouse', `hlt-hide',
+;; `hlt-hide-default-face', `hlt-hide-only', `hlt-highlight',
+;; `hlt-highlight-all-prop', `hlt-highlighter',
+;; `hlt-highlighter-mouse', `hlt-highlight-property-with-value',
+;; `hlt-highlight-regexp-region', `hlt-highlight-regexp-to-end',
+;; `hlt-highlight-region', `hlt-highlight-single-quotations',
+;; `hlt-mouse-face-each-line', `hlt-next-highlight',
+;; `hlt-previous-highlight', `hlt-replace-highlight-face',
+;; `hlt-show', `hlt-show-default-face', `hlt-show-only',
+;; `hlt-toggle-act-on-any-face-flag',
+;; `hlt-toggle-link-highlighting',
+;; `hlt-toggle-property-highlighting',
+;; `hlt-toggle-use-overlays-flag', `hlt-unhighlight-all-prop',
+;; `hlt-unhighlight-region', `hlt-unhighlight-region-for-face'.
+;;
+;; User options (variables) defined here:
+;;
+;; `hlt-act-on-any-face-flag', `hlt-max-region-no-warning',
+;; `hlt-use-overlays-flag'.
+;;
+;; Faces defined here:
+;;
+;; `hlt-property-highlight', `minibuffer-prompt' (for Emacs 20).
+;;
+;; Non-interactive functions defined here:
+;;
+;; `hlt-add-listifying', `hlt-add-to-invisibility-spec',
+;; `hlt-delete-highlight-overlay', `hlt-highlight-faces-in-buffer',
+;; `hlt-flat-list', `hlt-highlight-faces-in-buffer',
+;; `hlt-listify-invisibility-spec',
+;; `hlt-mouse-toggle-link-highlighting',
+;; `hlt-mouse-toggle-property-highlighting',
+;; `hlt-region-or-buffer-limits', `hlt-set-intersection',
+;; `hlt-set-union'.
+;;
+;; Internal variables defined here:
+;;
+;; `hlt-last-face', `hlt-last-regexp',
+;; `hlt-previous-use-overlays-flag-value',
+;; `hlt-prop-highlighting-state'.
+
+;;(@* "Documentation")
+;;
+;; Documentation
+;; -------------
+;;
+;;(@* "Library `facemenu+.el' Puts Highlight on the Menu")
+;; ** Library `facemenu+.el' Puts Highlight on the Menu **
+;;
+;; If you load library `facemenu+.el' after you load library
+;; `highlight.el', then the commands defined here will also be
+;; available on a Highlight submenu in the Text Properties menus.
+;;
+;;(@* "User Option `hlt-use-overlays-flag'")
+;; ** User Option `hlt-use-overlays-flag'
+;;
+;; You can highlight text in two ways using this library, depending
+;; on the value of user option `hlt-use-overlays-flag':
+;;
+;; - non-nil means to highlight using overlays
+;; - nil means to highlight using text properties
+;;
+;; Overlays are independent from the text itself. They are not
+;; picked up when you copy and paste text. By default, highlighting
+;; uses overlays.
+;;
+;; Although highlighting recognizes only nil and non-nil values for
+;; `hlt-use-overlays-flag', other actions can have different
+;; behavior, depending on the non-nil value. If it is `only' (the
+;; default value), then only overlay highlighting is affected. If it
+;; is any other non-nil value, then both overlay highlighting and
+;; text-property highlighting are effected. This is the case, for
+;; instance, for unhighlighting and for navigating among highlights.
+;;
+;; For example, for unhighlighting, if `hlt-use-overlays-flag' is
+;; non-nil, then overlay highlighting is removed. If it is not
+;; `only', then text-property highlighting is removed. A value of
+;; nil thus removes both overlays and text properties.
+;;
+;; Keep this sensitivity to the value of `hlt-use-overlays-flag' in
+;; mind. For example, if you change the value after adding some
+;; highlighting, then that highlighting might not be removed by
+;; unhighlighting, unless you change the value back again.
+;;
+;; You can toggle the value of `hlt-use-overlays-flag' at any time
+;; between nil and its previous non-nil value, using command
+;; `hlt-toggle-use-overlays-flag'.
+;;
+;;(@* "Commands")
+;; ** Commands **
+;;
+;; You can use any face to highlight, and you can apply a mouse face
+;; instead of a face, if you like. A mouse face shows up only when
+;; the mouse pointer is over it.
+;;
+;; The commands you will use the most often are probably
+;; `hlt-highlight', `hlt-highlighter', `hlt-next-highlight', and
+;; `hlt-previous-highlight'. You might also often use the various
+;; commands to hide and show highlighted text.
+;;
+;; You can use command `hlt-highlight' to highlight the region,
+;; highlight a regexp throughout the region, or unhighlight the
+;; region, depending on the prefix argument. It combines most of the
+;; behavior of commands `hlt-highlight-regexp-region',
+;; `hlt-highlight-region', and `hlt-unhighlight-region'. Command
+;; `hlt-highlight-regexp-to-end' highlights a regexp from the text
+;; cursor position to the end of the buffer.
+;;
+;; Command `hlt-highlighter' lets you highlight text by simply
+;; dragging the mouse, just as you would use a highlighter (marker).
+;; You can thus highlight text the same way that you drag the mouse
+;; to define the region.
+;;
+;; If you use Emacs 21 or later, you can use various commands that
+;; highlight and unhighlight text that has certain text properties
+;; with given values. You can use them to highlight all text in the
+;; region or buffer that has a given property value. An example is
+;; highlighting all links (text with property `mouse-face'). These
+;; commands are:
+;;
+;; `hlt-highlight-all-prop' - Highlight text that has a given
+;; property with any (non-nil) value.
+;;
+;; `hlt-highlight-property-with-value' - Highlight text that has a
+;; given property with certain values.
+;;
+;; `hlt-unhighlight-all-prop' - Unhighlight highlighted propertized
+;; text.
+;;
+;; `hlt-mouse-toggle-link-highlighting' - Alternately highlight and
+;; unhighlight links on a mouse click.
+;;
+;; `hlt-toggle-link-highlighting' - Alternately highlight and
+;; unhighlight links.
+;;
+;; `hlt-mouse-toggle-property-highlighting' - Alternately highlight
+;; and unhighlight propertized text on a
+;; mouse click.
+;;
+;; `hlt-toggle-property-highlighting' - Alternately highlight and
+;; unhighlight propertized text.
+;;
+;; As always for library `highlight.el', this "highlighting" can use
+;; property `mouse-face' instead of `face'. You could, for example,
+;; highlight, using `mouse-face', all text that has property `foo' -
+;; or that has property `face', for that matter.
+;;
+;; If you use Emacs 21 or later, you can use commands
+;; `hlt-next-highlight' and `hlt-previous-highlight' to navigate
+;; among highlights of a given face.
+;;
+;; You can unhighlight the region using command
+;; `hlt-unhighlight-region' (or using `C--' with `hlt-highlight').
+;; If you use overlay highlighting, then you can use command
+;; `hlt-unhighlight-region-for-face' to unhighlight the region for an
+;; individual highlighting face - other highlighting faces remain.
+;;
+;; You can replace a highlighting face in the region by another,
+;; using command `hlt-replace-highlight-face'. With a prefix
+;; argument, property `mouse-face' is used, not property `face'.
+;;
+;; Command `hlt-eraser' lets you delete highlighting by dragging the
+;; mouse. However, its behavior is quite different for overlays and
+;; text properties, and it is perhaps different from you expect - see
+;; the `hlt-eraser' doc string.
+;;
+;;(@* "User Option `hlt-act-on-any-face-flag'")
+;; ** User Option `hlt-act-on-any-face-flag' **
+;;
+;; Library `highlight' generally acts only on faces that it controls,
+;; that is, faces that you have explicitly asked it to use for
+;; highlighting. It sets the text property or overlay property
+;; `hlt-highlight' on such highlighted text, so that it can recognize
+;; which faces it has responsibility for.
+;;
+;; Sometimes, you might want to hide and show text other than that
+;; controlled by library `highlight'. Similarly, you might sometimes
+;; want to navigate among faces other than those used for
+;; highlighting. You can control this using option
+;; `hlt-act-on-any-face-flag', which you can toggle at any time using
+;; command `hlt-toggle-act-on-any-face-flag'.
+;;
+;;(@* "Hiding and Showing Text")
+;; ** Hiding and Showing Text **
+;;
+;; You can hide and show text that you have highlighted. You will
+;; want to read the Emacs-Lisp manual (Elisp), section Invisible
+;; Text, to understand better what this entails. In particular, you
+;; should understand that for library `highlight.el', hiding text
+;; means adding the symbol naming the face to be hidden to both:
+;;
+;; 1. a text or overlay `invisible' property, making the text or
+;; overlay susceptible to being hidden by buffer-local variable
+;; `buffer-invisibility-spec', and
+;;
+;; 2. the buffer's `buffer-invisibility-spec', so that it in fact
+;; becomes hidden.
+;;
+;; After text has been hidden this way, and unless the highlighting
+;; as been removed completely by unhighlighting the text, the
+;; `invisible' property of that text keeps the names of the faces
+;; that have been applied to that text and hidden previously, even
+;; after you show that text again. Showing a hidden face simply
+;; removes it from the `buffer-invisibility-spec'; it does not change
+;; any `invisible' properties.
+;;
+;; For example, if you hide face `foo' at some buffer position:
+;;
+;; 1. The `invisible' property of the text or overlay at that
+;; position is updated to include `foo'. If there are no other
+;; faces that have been applied to this text and then hidden, the
+;; `invisible' property is just (`foo').
+;;
+;; 2. `buffer-invisibility-spec' is also updated to include `foo'.
+;; This hides all text properties and overlay properties with
+;; `invisible' property `foo', throughout the buffer. If there
+;; are no other invisible faces in the buffer, then
+;; `buffer-invisibility-spec' has value (foo).
+;;
+;; If you then show face `foo' at that same buffer position, there is
+;; no change to the `invisible' property. `buffer-invisibility-spec'
+;; is updated, by removing `foo': if it was (foo), it becomes ().
+;;
+;; There are several commands for hiding and showing highlighted
+;; text. The basic commands for hiding and showing are
+;; `hlt-hide-default-face' and `hlt-show-default-face', which you can
+;; use to hide and show the face last used for highlighting. With a
+;; prefix argument, you are prompted for a different face to hide; it
+;; then becomes the default face for highlighting. You can also
+;; change the default highlighting face at any time using command
+;; `hlt-choose-default-face'.
+;;
+;; The other hide and show commands depend on your also using
+;; Icicles, which is a set of libraries that offer enhanced
+;; completion. The Icicles-dependent commands are the following:
+;;
+;; `hlt-choose-faces', `hlt-choose-invisible-faces',
+;; `hlt-choose-visible-faces', `hlt-hide', `hlt-hide-only',
+;; `hlt-show', `hlt-show-only'.
+;;
+;; These are all multi-commands, which means that they each let you
+;; choose multiple completion candidates or all candidates that match
+;; your current input (a regexp). You can use command `hlt-hide' to
+;; hide any number of visible faces. Any text is hidden that has
+;; that face as a text property or an overlay property, depending on
+;; the value of `hlt-use-overlays-flag'.
+;;
+;; Command `hlt-show' is the opposite of `hlt-hide': it shows
+;; invisible text that has the faces you choose. Neither `hlt-hide'
+;; nor `hlt-show' has any effect on other faces, besides those you
+;; choose to hide or show, respectively; they each do only one thing,
+;; hide or show.
+;;
+;; Command `hlt-hide-only' hides the faces you choose, and shows all
+;; other faces, and command `hlt-show-only' does the opposite. You
+;; can thus use these commands to specify exactly what faces should
+;; be invisible and visible. Empty input means none: If you choose
+;; no faces to hide (that is, hit `RET' with an empty minibuffer),
+;; then all faces will be made visible; if you choose no faces to
+;; show, then all will be hidden.
+;;
+;; Currently, face attributes for highlighting are combined when
+;; overlays overlap, but the same is not true for text properties.
+;; For example, if you highlight a word with face `foo', and then you
+;; highlight it with face `bar', only `bar' remains as the face for
+;; that word. With overlays, the attributes of the two faces are
+;; composed. When you hide or show faces, this behavior difference
+;; has an effect.
+;;
+;; You can hide text using the commands in this library for any of
+;; the purposes that you might use invisible text in Emacs. This
+;; gives you an easy, interactive way to control which sections of
+;; text are seen by search and other Emacs tools. Use the regexp
+;; highlighting commands, for instance, to highlight text
+;; syntactically, and then hide that highlighted text. Or use
+;; `hlt-highlighter' to sweep over text that you want to hide with
+;; the mouse.
+;;
+;; Hiding and showing faces also provides a "conditional text"
+;; feature similar to that available in desktop publishing
+;; applications such as Adobe's Framemaker. Publishers often use
+;; such a feature to produce different output documents from the same
+;; source document ("single sourcing"). You can use this feature
+;; similarly, if you have an application (printing is one example)
+;; that is sensitive to whether text is visible or invisible. One
+;; caveat: Emacs faces are not saved when you save your file.
+;;
+;;(@* "What Gets Highlighted: Region, Buffer, New Text You Type")
+;; ** What Gets Highlighted: Region, Buffer, New Text You Type **
+;;
+;; All mention of the "region" in this commentary should really say
+;; "region or buffer". If the region is active and non-empty, then
+;; only the text in the region is targeted by the commands in this
+;; library. This lets you easily control the scope of operations.
+;;
+;; If the region is not active or it is empty, then:
+;;
+;; - If `hlt-use-overlays-flag' is nil and there is no prefix arg,
+;; then the face is applied to the next characters that you type.
+;;
+;; - Otherwise, the face is applied to the entire buffer (or the
+;; current restriction, if the buffer is narrowed).
+;;
+;;(@* "Interference by Font Lock")
+;; ** Interference by Font Lock **
+;;
+;; If you use Emacs 22 or later, then you can use this library in
+;; conjunction with library `font-lock+.el'. That will prevent
+;; font-locking from removing any highlighting face properties that
+;; you apply using the commands defined here.
+;;
+;; Otherwise, when `hlt-use-overlays-flag' is nil, font-lock
+;; highlighting will interfere with the highlighting of this library.
+;; In most cases, you will be able to highlight text, but sooner or
+;; later font-lock will erase that highlighting when it refontifies
+;; the buffer. If `hlt-use-overlays-flag' is non-nil, there is no
+;; such problem : font-lock has no effect on overlays.
+;;
+;;(@* "Suggested Bindings")
+;; ** Suggested Bindings **
+;;
+;; This library adds menu items to the Region submenu of the Edit
+;; menu-bar menu, if you have a Region submenu. To obtain this menu,
+;; load library `menu-bar+.el'.
+;;
+;; Otherwise, library `highlight.el' makes no key bindings. Here are
+;; some suggested bindings (`C-x y', `C-x mouse-2', `C-x S-mouse-2',
+;; `S-C-p', and `S-C-n'):
+;;
+;; (define-key ctl-x-map [(control ?y)] 'hlt-highlight)
+;; (define-key ctl-x-map [(down-mouse-2)] 'hlt-highlighter)
+;; (define-key ctl-x-map [(S-down-mouse-2)] 'hlt-eraser)
+;; (global-set-key [(shift control ?p)] ; Emacs 21 or later
+;; 'hlt-previous-highlight)
+;; (global-set-key [(shift control ?n)] ; Emacs 21 or later
+;; 'hlt-next-highlight)
+;;
+;; You might also want to bind `hlt-choose-default-face', which you
+;; can use to change the current default highlighting face.
+;;
+;;(@* "Relation to Hi-Lock Mode")
+;; ** Relation to Hi-Lock Mode **
+;;
+;; The features of this library are complementary to those of the
+;; standard Emacs library `hi-lock.el', so you can use the two
+;; libraries together.
+;;
+;;(@* "Commands That Won't Work in Emacs 20")
+;; ** Commands That Won't Work in Emacs 20 **
+;;
+;; The following commands and options work only for Emacs versions
+;; more recent than Emacs 20:
+;;
+;; `hlt-act-on-any-face-flag', `hlt-choose-faces',
+;; `hlt-choose-invisible-faces', `hlt-choose-visible-faces',
+;; `hlt-hide', `hlt-hide-default-face', `hlt-hide-only',
+;; `hlt-highlight-property-with-value', `hlt-next-highlight',
+;; `hlt-previous-highlight', `hlt-show', `hlt-show-default-face',
+;; `hlt-show-only', `hlt-toggle-act-on-any-face-flag'.
+;;
+;;(@* "To Do")
+;; ** To Do **
+;;
+;; 1. Add commands to show and hide boolean combinations of faces.
+;;
+;; 2. Faces are not accumulated as text properties.
+;; Highlighting with one face completely replaces the previous
+;; highlight. Overlays don't have this limitation. Text
+;; properties need not have it either, but they do, for now.
+;;
+;;(@* "Acknowledgement")
+;; ** Acknowledgement **
+;;
+;; Parts of this library are based on a library of the same name
+;; written and copyrighted by Dave Brennan, brennan@hal.com, in 1992.
+;; I haven't been able to locate that file, so my change log is the
+;; only record I have of what our relative contributions are.
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Change log:
+;;
+;;(@* "Change log")
+;;
+;; 2009/09/24 dadams
+;; Removed hlt-no-op - use function ignore instead.
+;; 2009/08/02 dadams
+;; Added: hlt(-mouse)-toggle-(link|property)-highlighting, hlt-(un)highlight-all-prop,
+;; hlt-property-highlight, hlt-prop-highlighting-state.
+;; 2009/07/31 dadams
+;; Added: hlt-highlight-property-with-value, hlt-flat-list, hlt-set-intersection.
+;; 2009/04/26 dadams
+;; hlt-mouse-face-each-line: Bind inhibit-field-text-motion to t, for real eol.
+;; 2008/01/17 dadams
+;; Removed soft require of icicles.el.
+;; 2007/11/27 dadams
+;; hlt-highlight-regexp-region: If available, use icicle-read-string-completing.
+;; 2007/08/12 dadams
+;; Moved here from menu-bar+.el: Add to Edit>Region menu. Soft require menu-bar.el.
+;; 2007/06/07 dadams
+;; Use face-name-history or icicle-face-name-history, if defined, else face-name-history.
+;; 2007/06/05 dadams
+;; Added: hlt-(highlighter|eraser)-mouse.
+;; 2007/06/04 dadams
+;; Added: hlt-previous-use-overlays-flag-value.
+;; hlt-use-overlays-flag: 3 values now; default is only.
+;; hlt-eraser, hlt-unhighlight-region, hlt-hide-default-face, hlt-next-highlight:
+;; Treat non-only, non-nil hlt-use-overlays-flag.
+;; hlt-toggle-use-overlays-flag: Use hlt-previous-use-overlays-flag-value.
+;; Updated doc.
+;; 2007/06/03 dadams
+;; Added: hlt-toggle-use-overlays-flag.
+;; Don't even define hlt-act-on-any-face-flag for Emacs 20.
+;; Renamed no-op to hlt-no-op. Removed soft require of misc-cmds.el.
+;; 2007/06/02 dadams
+;; Added: hlt-act-on-any-face-flag, hlt-add-listifying, hlt-add-to-invisibility-spec,
+;; hlt-choose(-(in)visible)-faces, hlt-(hide|show)(-default-face|-only),
+;; hlt-highlight-faces-in-buffer, hlt-set-union, hlt-toggle-act-on-any-face-flag.
+;; Renamed: highlight-use-overlays-flag to hlt-use-overlays-flag,
+;; highlight-max-region-no-warning to hlt-max-region-no-warning,
+;; highlight-last-regexp to hlt-last-regexp, highlight-last-face to hlt-last-face,
+;; highlight-face to hlt-choose-default-face,
+;; highlight-highlighter to hlt-highlighter, highlight-eraser to hlt-eraser,
+;; mouse-face-each-line to hlt-mouse-face-each-line,
+;; unhighlight-region(-for-face) to hlt-unhighlight-region(-for-face).
+;; hlt-highlighter, hlt-highlight-region, hlt-mouse-face-each-line:
+;; Also put face as hlt-highlight property.
+;; hlt-eraser: Also remove hlt-highlight property.
+;; hlt-highlight-region, hlt-unhighlight-region, hlt-replace-highlight-face,
+;; hlt-next-highlight, hlt-mouse-face-each-line, hlt-highlight-regexp-region:
+;; Made start, end, and regexp args optional too. Default for non-interactive too.
+;; hlt-unhighlight-region-for-face: Made all args optional. Default them.
+;; hlt-unhighlight-region: Only remove highlighting for FACE, not all faces.
+;; hlt-highlight-single-quotations: Update hlt-last-face.
+;; hlt-next-highlight:
+;; Respect hlt-act-on-any-face-flag. Return a cons of the limits. Added no-error-p arg.
+;; hlt-previous-highlight: Added no-error-p arg.
+;; Added soft require of Icicles.
+;; 2007/04/02 dadams
+;; Renamed highlight-region-beg-end to highlight-region-or-buffer-limits.
+;; 2007/03/25 dadams
+;; highlight-highlighter, highlight-eraser, highlight-region, unhighlight-region:
+;; Use font-lock-ignore property.
+;; highlight-regexp-*: Use hi-lock-regexp-history or regexp-history.
+;; 2007/03/23 dadams
+;; highlight-region:
+;; If no region and no overlay, apply face to next char typed & add to facemenu menu.
+;; highlight-highlighter: Don't create overlay unless highlight-use-overlays-flag.
+;; highlight-highlighter, highlight-region, highlight-eraser:
+;; Don't bother to call font-lock-after-fontify-buffer.
+;; highlight-highlighter, highlight-region: Prepare for possible font-lock-ignore prop.
+;; highlight: Removed message.
+;; 2007/03/20 dadams
+;; highlight-face: Add face as arg. Added final message.
+;; 2007/03/17 dadams
+;; Added: highlight-(next|previous)-highlight, highlight-region-beg-end,
+;; highlight-eraser.
+;; highlight-region, highlight-regexp-to-end, highlight-regexp-region:
+;; Interactively, use highlight-last-face as the face.
+;; highlight-single-quotations: Added prefix arg, meaning prompt for face.
+;; highlight-region, highlight-regexp-region, unhighlight-region(-for-face),
+;; *-replace-face, *-single-quotations: If no region, then use whole buffer.
+;; highlight-single-quotations:
+;; Use highlight-regexp-region, not highlight-regexp-to-end. Msg if interactive.
+;; highlight-regexp-region: Ensure move past match in loop. Face is optional now.
+;; mouse-face-each-line: Added args start, end, face, msg-p. Restrict to region.
+;; Removed: mouse-face-following-lines.
+;; highlight-region: Added msg-p arg and progress message.
+;; unhighlight-region, highlight-replace-face: Simple message, no where part.
+;; unhighlight-region: Changed order of optional args, for consistency.
+;; highlight-highlighter:
+;; Make overlay once, and move it. Initialize end-point to start-point.
+;; 2007/03/16 dadams
+;; Renamed highlight-regexp to highlight-regexp-to-end, because Emacs now uses that name.
+;; Renamed max-highlight-w-o-warning to highlight-max-region-no-warning.
+;; Added: highlight-use-overlays-flag, highlight-last-face, highlight-face,
+;; highlight-highlighter, unhighlight-region-for-face,
+;; highlight-replace-face, highlight-delete-overlay.
+;; highlight-single-quotations: Read the face name.
+;; highlight-single-quotations, highlight-region, highlight-regexp-to-end,
+;; highlight-regexp-region: Set highlight-last-face.
+;; unhighlight-region, highlight-region, mouse-face-following-lines,
+;; mouse-face-each-line: Respect highlight-use-overlays-flag.
+;; unhighlight-region, mouse-face-*: Added optional face arg.
+;; highlight-max-region-no-warning: defvar -> defcustom.
+;; highlight-regexp-region: Use mouse-p when call highlight-region.
+;; 2006/03/31 dadams
+;; No longer use display-in-minibuffer.
+;; 2005/12/18 dadams
+;; Use minibuffer-prompt face. Removed require of def-face-const.el.
+;; highlight-single-quotations: defsubst -> defun.
+;; 2004/10/13 dadams
+;; Updated for Emacs 21: highlight-region: Bind
+;; inhibit-modification-hooks to non-nil to prevent Emacs 21
+;; font-lock from refontifying (removing highlighting)
+;; 2004/10/12 dadams
+;; highlight-region: Use font-lock-after-fontify-buffer instead of
+;; lazy-lock-after-fontify-buffer.
+;; 2004/03/16 dadams
+;; highlight-region: Prevent put-text-property from removing highlighting
+;; 1996/04/26 dadams
+;; Put escaped newlines on long-line strings.
+;; 1996/04/25 dadams
+;; 1. Added highlight-single-quotations.
+;; 2. highlight-regexp, highlight-regexp-region: Added new optional arg NTH.
+;; 1996/04/25 dadams
+;; Added mouse-face-following-lines.
+;; 1996/04/04 dadams
+;; 1. highlight: Removed RAW-PREFIX, DISPLAY-MSGS args. Made PREFIX optional.
+;; Set current-prefix-arg to nil so called fns don't use it as mouse-p.
+;; 2. highlight-regexp, highlight-regexp-region: Added MOUSE-P arg.
+;; 1996/02/27 dadams
+;; Added mouse-face-each-line.
+;; 1996/02/26 dadams
+;; unhighlight-region: Added new arg MOUSE-P.
+;; 1996/02/12 dadams
+;; highlight-region: Added optional arg MOUSE-P.
+;; 1996/02/06 dadams
+;; Put variable-interactive property on appropriate user option vars.
+;; 1996/02/01 dadams
+;; highlight: Just call subfunctions interactively.
+;; highlight-region, highlight-regexp, highlight-regexp-region: Use
+;; read-face-name
+;; 1996/01/08 dadams
+;; highlight-regexp, highlight-regexp-region: message -> display-in-minibuffer.
+;; 1995/11/09 dadams
+;; highlight-region: FACE arg is optional.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; 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 2, 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
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Code:
+
+(and (< emacs-major-version 20) (eval-when-compile (require 'cl))) ;; when, unless
+
+(require 'frame-fns nil t) ;; (no error if not found): flash-ding
+(when (< emacs-major-version 21) (require 'faces+ nil t)) ;; (no error if not found):
+ ;; read-face-name
+(require 'menu-bar+ nil t) ;; (no error if not found): menu-bar-edit-region-menu
+;; (require 'icicles nil t) ;; (no error if not found): icicle-define-command,
+ ;; icicle-delete-if, icicle-delete-if-not,
+ ;; icicle-make-face-candidate, icicle-read-string-completing.
+
+;; Quiet the byte-compiler for Emacs 20
+(defvar hi-lock-mode)
+(defvar hlt-act-on-any-face-flag)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;(@* "Menu-Bar Region Menu")
+
+;;; Menu-Bar Region Menu --------------------------------
+
+(when (boundp 'menu-bar-edit-region-menu) ; Defined in `menu-bar+.el'.
+ (define-key menu-bar-edit-region-menu [separator-highlight] '("--"))
+ (define-key menu-bar-edit-region-menu [hlt-unhighlight-region]
+ '(menu-item "Unhighlight" hlt-unhighlight-region
+ :help "Remove highlighting (faces) in region"
+ :enable (and mark-active (not buffer-read-only))))
+ (define-key menu-bar-edit-region-menu [hlt-highlight-regexp-region]
+ '(menu-item "Highlight Regexp..." hlt-highlight-regexp-region
+ :help "Highlight parts of selection that match a regular expression"
+ :enable (and mark-active (not buffer-read-only))))
+ (define-key menu-bar-edit-region-menu [hlt-highlight-region]
+ '(menu-item "Highlight..." hlt-highlight-region :help "Highlight all text in the selection"
+ :enable (and mark-active (not buffer-read-only)))))
+
+;;(@* "Variables and Faces")
+
+;;; Variables and Faces --------------------------------
+
+;; This is defined in `faces.el', Emacs 22. This definition is adapted to Emacs 20.
+;;;###autoload
+(unless (facep 'minibuffer-prompt)
+ (defface minibuffer-prompt '((((background dark)) (:foreground "cyan"))
+ (t (:foreground "dark blue")))
+ "Face for minibuffer prompts."
+ :group 'basic-faces))
+
+;;;###autoload
+(when (fboundp 'next-single-char-property-change) ; Don't bother, for Emacs 20.
+ (defface hlt-property-highlight '((((background dark)) (:background "Navy"))
+ (t (:background "Wheat")))
+ "*Face used to highlight all links."
+ :group 'faces)
+ (defcustom hlt-act-on-any-face-flag nil
+ "*Non-nil means highlight actions apply to all text with a face.
+nil means that they apply only to text that has been highlighted.
+Consult the doc for particular actions, to see if they are affected by
+this option."
+ :type 'boolean :group 'editing :group 'convenience :group 'wp :group 'faces)
+
+ (defvar hlt-prop-highlighting-state '(nil . nil)
+ "Cons indicating state of property highlighting.
+The car indicates whether property highlighting is on.
+The cdr is the position of the last mouse click that changed state, as
+a marker."))
+
+;;;###autoload
+(defcustom hlt-max-region-no-warning 100000
+ "*Max size (chars) of region to highlight without confirmation.
+This is used only for highlighting of a regexp, which can be slow."
+ :type 'integer :group 'editing :group 'convenience :group 'wp)
+
+;;;###autoload
+(defcustom hlt-use-overlays-flag 'only
+ "*Non-nil means use overlays to highlight; nil means use text properties.
+This value also affects some actions, such as unhighlighting, for text
+that is highlighted. If the value is `only' (the default value), then
+those actions only affect overlay highlighting. Otherwise, they
+affect both kinds of highlighting."
+ :type '(choice
+ (const :tag "Highlight using text properties, not overlays" nil)
+ (const :tag "Highlight using overlays, not text properties" only)
+ (sexp :tag
+ "Highlight using overlays, but act also on highlight text properties" t))
+ :group 'editing :group 'convenience :group 'wp :group 'faces)
+
+(defvar hlt-last-regexp nil "The last regexp highlighted.")
+(defvar hlt-last-face 'highlight "The last face used by highlight commands.")
+(defvar hlt-previous-use-overlays-flag-value nil "Previous value of `hlt-use-overlays-flag'.")
+
+;;(@* "Misc Functions - Emacs 20+")
+
+;;; Misc Functions - Emacs 20+ ---------------------------------------
+
+;;;###autoload
+(defun hlt-choose-default-face (face)
+ "Choose a face for highlighting."
+ (interactive (list (read-face-name "Use highlighting face: ")))
+ (setq hlt-last-face face)
+ (when (interactive-p) (message "Highlighting will now use face `%s'" face)))
+
+;; Bind this to, for instance, `C-x mouse-2'.
+;;;###autoload
+(defun hlt-highlighter (start-event)
+ "Highlight the text you drag the mouse over.
+The face used is the last face that was used for highlighting.
+You can use command `hlt-choose-default-face' to choose a different face."
+ (interactive "e")
+ (save-excursion
+ (run-hooks 'mouse-leave-buffer-hook) ; Let temporary modes like isearch turn off.
+ (let* ((original-window (selected-window))
+ (echo-keystrokes 0)
+ (start-posn (event-start start-event))
+ (start-point (posn-point start-posn))
+ (end-point start-point)
+ (start-window (posn-window start-posn)))
+ (let ((read-only buffer-read-only)
+ (modified-p (buffer-modified-p))
+ (inhibit-modification-hooks t)
+ (overlay (and hlt-use-overlays-flag
+ (make-overlay start-point start-point)))
+ ;; Otherwise, `put-text-property' calls this, which removes highlight.
+ (font-lock-fontify-region-function 'ignore)
+ event)
+ (setq buffer-read-only nil)
+ (track-mouse
+ (while (progn (setq event (read-event))
+ (or (mouse-movement-p event)
+ (memq (car-safe event) '(switch-frame select-window))))
+ (unless (memq (car-safe event) '(switch-frame select-window))
+ (setq end-point (posn-point (event-end event))))
+ (cond (hlt-use-overlays-flag
+ (setq overlay (move-overlay overlay start-point end-point))
+ (overlay-put overlay 'face hlt-last-face)
+ (overlay-put overlay 'hlt-highlight hlt-last-face))
+ (t
+ (put-text-property start-point end-point 'face hlt-last-face)
+ (put-text-property start-point end-point 'hlt-highlight hlt-last-face)
+ (put-text-property start-point end-point 'font-lock-ignore t)
+ ))))
+ (setq buffer-read-only read-only)
+ (set-buffer-modified-p modified-p)))))
+
+;; Bind this to, for instance, `C-x S-mouse-2'.
+;;;###autoload
+(defun hlt-eraser (start-event)
+ "Erase highlights that you click or drag the mouse over.
+If `hlt-use-overlays-flag' is non-nil, then overlay highlighting is
+removed for the last face that was used for highlighting. (You can
+use command `hlt-choose-default-face' first to choose a different
+face.) If `hlt-use-overlays-flag' is not `only', then text-property
+highlighting is removed for *ALL* faces (not just highlighting faces).
+This means, in particular, that a value of nil erases both overlays
+for the last face and text properties for all faces.
+
+Note: When text properties are affected, this is like using an eraser:
+only characters you drag over lose their faces. But when overlays are
+affected, an overlay is erased as soon as any part of it is touched.
+You need not drag over the entire overlay to delete it, and there is
+no way to erase only part of it."
+ (interactive "e")
+ (save-excursion
+ (run-hooks 'mouse-leave-buffer-hook) ; Let temporary modes like isearch turn off.
+ (let* ((original-window (selected-window))
+ (echo-keystrokes 0)
+ (start-posn (event-start start-event))
+ (start-point (posn-point start-posn))
+ (end-point start-point)
+ (start-window (posn-window start-posn)))
+ (let ((read-only buffer-read-only)
+ (modified-p (buffer-modified-p))
+ (inhibit-modification-hooks t)
+ ;; Otherwise, `put-text-property' calls this, which removes highlight.
+ (font-lock-fontify-region-function 'ignore)
+ event)
+ (setq buffer-read-only nil)
+ (track-mouse
+ (while (progn (setq event (read-event))
+ (or (mouse-movement-p event)
+ (memq (car-safe event) '(switch-frame select-window))))
+ (unless (memq (car-safe event) '(switch-frame select-window))
+ (setq end-point (posn-point (event-end event))))
+ (when hlt-use-overlays-flag
+ (mapcar (lambda (o) (hlt-delete-highlight-overlay o hlt-last-face))
+ (overlays-in start-point end-point)))
+ (unless (eq 'only hlt-use-overlays-flag)
+ (remove-text-properties start-point end-point
+ '(face nil hlt-highlight nil font-lock-ignore nil)))))
+ (setq buffer-read-only read-only)
+ (set-buffer-modified-p modified-p)))))
+
+(defun hlt-highlighter-mouse ()
+ "Same as `hlt-highlighter', but for binding to a menu item."
+ (interactive)
+ (message "Drag mouse to highlight text") (sleep-for 1)
+ (hlt-highlighter (read-event)))
+
+(defun hlt-eraser-mouse ()
+ "Same as `hlt-eraser', but for binding to a menu item."
+ (interactive)
+ (message "Drag mouse over to erase highlighting") (sleep-for 1)
+ (hlt-eraser (read-event)))
+
+;; Bind this to, for instance, `C-x C-y'.
+;;;###autoload
+(defun hlt-highlight (&optional prefix)
+ "Highlight region, regexp (PREFIX +), or unhighlight region (PREFIX -).
+PREFIX arg non-negative means `hlt-highlight-regexp-region'
+PREFIX arg negative means `hlt-unhighlight-region'
+PREFIX arg nil means `hlt-highlight-region'.
+If the region is not active or it is empty, then use the whole buffer.
+The face used is the last face that was used for highlighting.
+You can use command `hlt-choose-default-face' to choose a different face."
+ (interactive "P")
+ (setq current-prefix-arg nil) ; No mouse-p.
+ (if prefix
+ (if (natnump (prefix-numeric-value prefix))
+ (call-interactively 'hlt-highlight-regexp-region)
+ (save-excursion (call-interactively 'hlt-unhighlight-region)))
+ (call-interactively 'hlt-highlight-region)))
+
+;;;###autoload
+(defun hlt-highlight-region (&optional start end face msg-p mouse-p)
+ "Highlight the region or new input.
+Optional args START and END are the limits of the area to act on.
+ They default to the region limits.
+Optional 3rd arg FACE is the face to use.
+ Interactively, this is the last face that was used for highlighting.
+ (You can use command `hlt-choose-default-face' to choose a different face.)
+Optional 4th arg MSG-P non-nil means to display a progress message.
+Optional 5th arg MOUSE-P non-nil means use the `mouse-face' property,
+ not the `face' property.
+Interactively, MOUSE-P is provided by the prefix arg.
+
+If the region is not active or it is empty, then:
+ - If `hlt-use-overlays-flag' is non-nil, apply FACE to the
+ entire buffer. If MOUSE-P is non-nil, use the `mouse-face'
+ property; otherwise, use the `face' property.
+ - Else, if MOUSE-P is non-nil, then apply FACE as the `mouse-face'
+ property to the whole buffer.
+ - Else, if interactive, apply FACE to the next character you type,
+ and add FACE to the facemenu menu.
+ - Else, apply FACE as the `face' property to the whole buffer."
+ (interactive `(,@(hlt-region-or-buffer-limits) nil t ,current-prefix-arg))
+ (unless (and start end) (let ((start-end (hlt-region-or-buffer-limits)))
+ (setq start (car start-end)
+ end (cadr start-end))))
+ (if face (setq hlt-last-face face) (setq face hlt-last-face))
+ (when (and msg-p (or mark-active mouse-p)) (message "Highlighting..."))
+ (let ((read-only buffer-read-only)
+ (modified-p (buffer-modified-p))
+ (inhibit-modification-hooks t)
+ ;; Otherwise, `put-text-property' calls this, which removes highlight.
+ (font-lock-fontify-region-function 'ignore)
+ overlay)
+ (setq buffer-read-only nil)
+ (cond (hlt-use-overlays-flag
+ (setq overlay (make-overlay start end))
+ (overlay-put overlay (if mouse-p 'mouse-face 'face) face)
+ (overlay-put overlay 'hlt-highlight face))
+ (mouse-p (put-text-property start end 'mouse-face face))
+ ((interactive-p)
+ (message "Text you type now will have face `%s'." face)
+ (facemenu-add-new-face face)
+ ;; It is `facemenu-add-face' that either uses region or next insert.
+ (facemenu-add-face face (and mark-active start) (and mark-active end))
+ (when (and mark-active start end (/= start end))
+ (put-text-property start end 'hlt-highlight face)
+ (put-text-property start end 'font-lock-ignore t)))
+ (t (put-text-property start end 'face face)
+ (put-text-property start end 'hlt-highlight face)
+ (put-text-property start end 'font-lock-ignore t)))
+ (setq buffer-read-only read-only)
+ (set-buffer-modified-p modified-p))
+ (let ((remove-msg (substitute-command-keys
+ "`\\[negative-argument] \\[hlt-highlight]' to remove highlighting.")))
+ (when (and msg-p (or mark-active mouse-p))
+ (message "Highlighting... done. %s" remove-msg))))
+
+;;;###autoload
+(defun hlt-highlight-regexp-region (&optional start end regexp face msg-p mouse-p nth)
+ "Highlight regular expression REGEXP in region.
+If the region is not active or it is empty, then use the whole buffer.
+Optional args START and END are the limits of the area to act on.
+ They default to the region limits.
+Optional 4th arg FACE is the face to use.
+ Interactively, this is the last face that was used for highlighting.
+ (You can use command `hlt-choose-default-face' to choose a different face.)
+Optional 5th arg MSG-P:
+ t means to treat this as an interactive call when deciding to
+ display all messages.
+ non-nil & non-t means to display only error and warning messages.
+Optional 6th arg MOUSE-P non-nil means to use `mouse-face' property,
+ not `face'. Interactively, this is provided by the prefix arg.
+Optional 7th arg NTH determines which regexp subgroup is highlighted.
+ If nil or 0, the entire regexp is highlighted. Otherwise, the NTH
+ regexp subgroup (\"\\\\(...\\\\)\" expression) is highlighted.
+ (NTH is not available interactively.)"
+ (interactive
+ `(,@(hlt-region-or-buffer-limits)
+ ,(if (fboundp 'icicle-read-string-completing)
+ (icicle-read-string-completing "Regexp to highlight: "
+ hlt-last-regexp
+ (lambda (c) (string-match "regexp" (symbol-name c)))
+ (if (and (boundp 'hi-lock-mode) hi-lock-mode)
+ 'hi-lock-regexp-history
+ 'regexp-history))
+ (read-string "Regexp to highlight: "
+ nil (if (and (boundp 'hi-lock-mode) hi-lock-mode)
+ 'hi-lock-regexp-history
+ 'regexp-history)
+ hlt-last-regexp))
+ nil t ,current-prefix-arg)) ; interactive-p means to display all msgs.
+ (unless (and start end) (let ((start-end (hlt-region-or-buffer-limits)))
+ (setq start (car start-end)
+ end (cadr start-end))))
+ (unless regexp (setq regexp hlt-last-regexp))
+ (unless (stringp regexp) ; Else re-search-forward gets an error
+ (error "HIGHLIGHT-REGEXP-REGION: REGEXP arg is not a string: `%S'" regexp))
+ (if face (setq hlt-last-face face) (setq face hlt-last-face))
+ (let ((reg-size (abs (- end start))))
+ (when (and msg-p
+ (> reg-size hlt-max-region-no-warning)
+ (not (progn
+ (and (fboundp 'flash-ding) ; In `frame-fns.el'
+ (flash-ding 'no-terminate-macros (selected-frame)))
+ (y-or-n-p (substitute-command-keys
+ (format "Lots of highlighting slows \
+things down. Do you really want to highlight up to %d chars? "
+ reg-size))))))
+ (error "OK, highlighting was cancelled")))
+ (when (eq t msg-p) (message (concat "Highlighting occurrences of `" regexp "'...")))
+ (save-excursion
+ (goto-char start)
+ (while (and (< start end) (not (eobp)) (re-search-forward regexp end t))
+ (condition-case nil
+ (progn (forward-char 1) (setq start (1+ (point))))
+ (end-of-buffer (setq start end)))
+ (hlt-highlight-region (match-beginning (or nth 0))
+ (match-end (or nth 0)) face nil mouse-p)))
+ (when (eq t msg-p)
+ (message "Highlighting occurrences of `%s' done. %s" regexp
+ (substitute-command-keys
+ "`\\[negative-argument] \\[highlight]' to remove highlighting.")))
+ (setq hlt-last-regexp regexp))
+
+;;;###autoload
+(defun hlt-highlight-regexp-to-end (regexp &optional face msg-p mouse-p nth)
+ "Highlight text after cursor that matches REGEXP.
+Optional 2nd arg FACE is the face to use.
+ Interactively, this is the last face that was used for highlighting.
+ (You can use command `hlt-choose-default-face' to choose a different face.)
+Optional 3rd arg MSG-P non-nil means display a progress message.
+Optional 4th arg MOUSE-P non-nil means to use `mouse-face' property,
+ not `face'. Interactively, this is provided by the prefix arg.
+Optional 5th arg NTH determines which regexp subgroup is highlighted.
+ If nil or 0, the entire regexp is highlighted. Otherwise, the NTH
+ regexp subgroup (\"\\\\(...\\\\)\" expression) is highlighted.
+ (NTH is not available interactively.)"
+ (interactive
+ (list (read-string "Regexp to highlight after cursor: " nil
+ (if (and (boundp 'hi-lock-mode) hi-lock-mode)
+ 'hi-lock-regexp-history
+ 'regexp-history)
+ hlt-last-regexp)
+ nil 'msg-p current-prefix-arg))
+ (if face (setq hlt-last-face face) (setq face hlt-last-face))
+ (let ((remove-msg
+ (and msg-p
+ (substitute-command-keys
+ "`\\[negative-argument] \\[highlight]' to remove highlighting."))))
+ (when msg-p
+ (message "Highlighting occurrences of `%s' after cursor..." regexp))
+ (hlt-highlight-regexp-region (point) (point-max) regexp face
+ (and msg-p 'error-msgs-only) mouse-p nth)
+ (when msg-p
+ (message "Highlighting occurrences of `%s' done. %s" regexp remove-msg)))
+ (setq hlt-last-regexp regexp))
+
+;;;###autoload
+(defun hlt-unhighlight-region (&optional start end face msg-p mouse-p)
+ "Remove all highlighting in region.
+If the region is not active or it is empty, then use the whole buffer.
+If `hlt-use-overlays-flag' is non-nil, then overlay highlighting is
+removed. If `hlt-use-overlays-flag' is not `only', then text-property
+highlighting is removed. This means, in particular, that a value of
+nil removes both overlays and text properties.
+
+Optional args START and END are the limits of the area to act on.
+ They default to the region limits.
+Optional 3rd arg FACE non-nil means delete only highlighting that uses
+ FACE. Nil means delete all highlighting.
+Optional 4th argument MSG-P non-nil means display a progress message.
+Optional 5th arg MOUSE-P non-nil means use `mouse-face' property, not
+ `face'. Interactively, MOUSE-P is provided by the prefix arg."
+ (interactive `(,@(hlt-region-or-buffer-limits) nil t ,current-prefix-arg))
+ (unless (and start end) (let ((start-end (hlt-region-or-buffer-limits)))
+ (setq start (car start-end)
+ end (cadr start-end))))
+ (when msg-p (message "Removing highlighting..."))
+ (let ((read-only-p buffer-read-only)
+ (modified-p (buffer-modified-p)))
+ (setq buffer-read-only nil)
+ (when hlt-use-overlays-flag
+ (mapcar (lambda (o) (hlt-delete-highlight-overlay o face)) (overlays-in start end)))
+ (unless (eq 'only hlt-use-overlays-flag)
+ (let ((beg start)
+ hi-face)
+ (while (< beg end)
+ (when (setq hi-face (get-text-property beg 'hlt-highlight))
+ (when (or (null face) (eq hi-face face))
+ ;; $$$ Really, we should remove only the part of the `face'
+ ;; property that belongs to Highlight, and set the value to be
+ ;; the same as it is, but without hlt-last-face.
+ (remove-text-properties
+ beg (1+ beg) (if mouse-p
+ '(mouse-face nil hlt-highlight nil font-lock-ignore nil)
+ '(face nil hlt-highlight nil font-lock-ignore nil)))))
+ (setq beg (1+ beg)))))
+ (setq buffer-read-only read-only-p)
+ (set-buffer-modified-p modified-p))
+ (when msg-p (message "Removing highlighting... done.")))
+
+;;;###autoload
+(defun hlt-unhighlight-region-for-face (&optional face start end mouse-p)
+ "Remove highlighting that uses FACE in region.
+Same as `hlt-unhighlight-region', but removes only highlighting
+that uses FACE. Interactively, you are prompted for the face.
+
+This works only for overlay highlighting, not text-property
+highlighting.
+
+Optional arg FACE is the face to use.
+ Interactively, this is the last face that was used for highlighting.
+ (You can use command `hlt-choose-default-face' to choose a different face.)
+Optional args START and END are the limits of the area to act on.
+ They default to the region limits.
+Optional arg MOUSE-P non-nil means use `mouse-face' property, not
+ `face'. Interactively, MOUSE-P is provided by the prefix arg."
+ (interactive `(,(read-face-name "Remove highlight overlays that use face: ")
+ ,@(hlt-region-or-buffer-limits) ,current-prefix-arg))
+ (if face (setq hlt-last-face face) (setq face hlt-last-face))
+ (unless (and start end) (let ((start-end (hlt-region-or-buffer-limits)))
+ (setq start (car start-end)
+ end (cadr start-end))))
+ (hlt-unhighlight-region start end face (interactive-p) mouse-p))
+
+(defun hlt-delete-highlight-overlay (overlay &optional face)
+ "Delete OVERLAY if it was created by highlighting (library `highlight').
+Optional arg FACE is a face symbol. If non-nil, then delete only
+overlays with that FACE."
+ (let ((highlight-face (overlay-get overlay 'hlt-highlight)))
+ (when (and highlight-face (or (not face) (eq face highlight-face)))
+ (delete-overlay overlay))))
+
+;;;###autoload
+(defun hlt-replace-highlight-face (old-face new-face &optional start end msg-p mouse-p)
+ "Replace OLD-FACE by NEW-FACE in all highlights in the region.
+If the region is not active or it is empty, then use the whole buffer.
+With a prefix argument, replace OLD-FACE as the `mouse-face' property,
+ not the `face' property.
+Other arguments:
+Optional args START and END are the limits of the area to act on.
+ They default to the region limits.
+Optional 5th argument MSG-P non-nil means display a progress message.
+Optional 6th arg MOUSE-P non-nil means use `mouse-face' property, not
+ `face'. Interactively, MOUSE-P is provided by the prefix arg.
+
+This works only for overlay highlighting, not text-property
+highlighting."
+ (interactive `(,(read-face-name "Replace face in region highlights. Old face: ")
+ ,(read-face-name "New face: ")
+ ,@(hlt-region-or-buffer-limits) t ,current-prefix-arg))
+ (unless (and start end) (let ((start-end (hlt-region-or-buffer-limits)))
+ (setq start (car start-end)
+ end (cadr start-end))))
+ (when msg-p (message "Replacing highlighting face `%s'..." old-face))
+ (let ((read-only-p buffer-read-only)
+ (modified-p (buffer-modified-p)))
+ (setq buffer-read-only nil)
+ (mapcar (lambda (o)
+ (when (eq old-face (overlay-get o (if mouse-p 'mouse-face 'face)))
+ (overlay-put o (if mouse-p 'mouse-face 'face) new-face)
+ (overlay-put o 'hlt-highlight new-face)))
+ (overlays-in start end))
+ (setq buffer-read-only read-only-p)
+ (set-buffer-modified-p modified-p))
+ (setq hlt-last-face new-face)
+ (when msg-p (message "Replacing highlighting face `%s'... done." old-face)))
+
+;;;###autoload
+(defun hlt-highlight-single-quotations (&optional face)
+ "Highlight single-quoted text in the region.
+This means, for example, commands and keys between `'s: `foobar'.
+If the region is not active or it is empty, then use the whole buffer.
+With a prefix argument, prompt for the highlighting face to use.
+Otherwise, use the last face used for highlighting.
+ You can also use command `hlt-choose-default-face' to choose a different face."
+ (interactive "P")
+ (if face
+ (setq face (read-face-name "Use highlighting face: ") hlt-last-face face)
+ (setq face hlt-last-face))
+ (apply #'hlt-highlight-regexp-region
+ (append (hlt-region-or-buffer-limits)
+ (list "`\\([^']+\\)'" face (and (interactive-p) t) nil 1))))
+
+;;;###autoload
+(defun hlt-mouse-face-each-line (&optional start end face msg-p)
+ "Put `mouse-face' on each line of buffer in region.
+If the region is active and not empty, then limit mouse-face
+highlighting to the region. Otherwise, use the whole buffer.
+With a prefix argument, prompt for the highlighting face to use.
+Otherwise, use the last face used for highlighting.
+ You can also use command `hlt-choose-default-face' to choose a different face.
+Optional args START and END are the limits of the area to act on.
+ They default to the region limits.
+Optional arg MSG-P non-nil means display a progress message."
+ (interactive `(,@(hlt-region-or-buffer-limits) ,current-prefix-arg t))
+ (unless (and start end) (let ((start-end (hlt-region-or-buffer-limits)))
+ (setq start (car start-end)
+ end (cadr start-end))))
+ (if face
+ (setq face (read-face-name "Use highlighting face: ") hlt-last-face face)
+ (setq face hlt-last-face))
+ (when msg-p (message "Putting mouse face `%s' on each line..." face))
+ (let ((buffer-read-only nil)
+ (inhibit-field-text-motion t) ; Just to be sure, for `end-of-line'.
+ overl