-;; hilit19.el, Beta 1.9 -- customizable highlighting for Emacs19.
-;; Copyright (c) 1993 Free Software Foundation, Inc.
-;;
-;; Author: Jonathan Stigelman <Stig@netcom.com>
+;;; hilit19.el --- customizable highlighting for Emacs19
+
+;; Copyright (c) 1993, 1994 Free Software Foundation, Inc.
+
+;; Author: Jonathan Stigelman <stig@hackvan.com>
;; Keywords: faces
-;;
-;; This program is free software; you can redistribute it and/or modify
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs 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 of the License, or
-;; (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs 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; if not, write to the Free Software
-;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-;;
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
;;; Commentary:
-;; hilit19.el, Beta 1.9 -- customizable highlighting for Emacs19.
-;; Supports not only source code highlighting, but also rmail, VM, and gnus.
-
-;; WHERE TO GET THE LATEST VERSION OF HILIT19.EL (possibly beta),
+;; Hilit19.el is a customizable highlighting package for Emacs19. It supports
+;; not only source code highlighting, but also Info, RMAIL, VM, gnus...
+;; Hilit19 knows (or thinks it knows) how to highlight emacs buffers in
+;; about 25 different modes.
+;;
+;; WHERE TO GET THE LATEST VERSIONS OF HILIT19.EL (beta and release),
;; PLUS LOTS OF OTHER *WAY COOL* STUFF VIA ANONYMOUS FTP:
;;
-;; netcom.com:/pub/stig/src/hilit19.el.gz
+;; ftp.hackvan.com:/pub/stig/src/elisp/hilit19.el.gz
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; $Id: hilit19.el,v 1.34 1993/07/23 05:18:37 stig Exp stig $
+;; hilit19.el,v 2.19 1993/09/08 18:44:10 stig Release
;;
;; LCD Archive Entry:
-;; emacs19/hilit19.el|Jonathan Stigelman|Stig@netcom.com
-;; |Comprehensive (and comparatively fast) regex-based highlighting for Emacs 19
-;; Thu Jul 22 21:03:46 1993|Beta 1.9||
+;; hilit19|Jonathan Stigelman|stig@hackvan.com|
+;; Comprehensive (and comparatively fast) regex-based highlighting for Emacs 19|
+;; 1993/09/08 18:44:10|Release 2.19|~/packages/hilit19.el.Z|
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;
;; SETUP -- In your .emacs:
;;
-;; (require 'hilit19) ; not intended to be autoloaded
-;;
-;; (setq hilit-mode-enable-list '(not text-mode))
-;;
+;;
+;; (cond (window-system
+;; (setq hilit-mode-enable-list '(not text-mode)
+;; hilit-background-mode 'light
+;; hilit-inhibit-hooks nil
+;; hilit-inhibit-rebinding nil)
+;;
+;; (require 'hilit19)
+;; ))
+;;
+;; If you like font-lock-mode and want to use both packages, then you can
+;; disable hilit for the modes in which you want to use font-lock by listing
+;; said modes in hilit-mode-enable-list.
+;;
;; (hilit-translate type 'RoyalBlue ; enable highlighting in C/C++
;; string nil) ; disable string highlighting
;;
;; SETUP -- Are you using the right font for Emacs?
;;
;; Emacs cannot properly find bold and italic fonts unless you specify a
-;; verbose X11 font name. Here's a good font menu:
+;; verbose X11 font name. If you specify a font for emacs in your
+;; .Xdefaults, it *MUST* be specified using the long form of the font name.
+;; Here's a good font menu:
;;
;; (setq
;; x-fixed-font-alist
;; '("Font Menu"
-;; ("Fonts"
+;; ("Misc"
;; ("6x12" "-misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-*-1")
;; ("6x13" "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-1")
;; ("lucida 13"
;;
;; KNOWN BUGS/TO DO LIST/HELP WANTED/APPLY WITHIN
;;
-;; * unbalanced double quote characters can confuse hilit19. This will be
-;; fixed, so don't bug me about it.
+;; * unbalanced, unescaped double quote characters can confuse hilit19.
+;; This will be fixed someday, so don't bug me about it.
;;
-;; * ALTHOUGH HILIT19 IS FASTER THAN FONT-LOCK-MODE, for various reasons,
-;; the speed of the package could still stand to be improved. If you care
-;; to do a little profiling and make things tighter...
+;; * ALTHOUGH HILIT19 IS FASTER THAN FONT-LOCK-MODE...
+;; For various reasons, the speed of the package could still stand to be
+;; improved. If you care to do a little profiling and make things tighter...
;;
-;; * hilit-toggle-highlight is flaky in large buffers where auto-rehighlight
-;; is numeric after toggling twice, it loses it's numeric value
+;; * hilit-toggle-highlight is flaky when auto-rehighlight is neither t nor nil.
+;; Does anyone actually USE this? I think I might just remove it.
;;
;; PROJECTS THAT YOU CAN TAKE OVER BECAUSE I DON'T MUCH CARE ABOUT THEM...
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Thanks to the following people for their input:
-;; ebert@enpc.enpc.fr (Rolf EBERT), ada, LaTeX & bibtex highlights
-;; Vivek Khera <khera@cs.duke.edu>, gnus hooks + random advice & patches
-;; brian@athe.WUstl.EDU (Brian Dunford-Shore), prolog highlights
-;; John Ladwig <jladwig@soils.umn.edu>, 1st pass nroff highlights
-;; campo@sunthpi3.difi.unipi.it (Massimo Campostrini), fortran highlights
-;; jayb@laplace.MATH.ColoState.EDU (Jay Bourland), 1st pass dired
-;; Yoshio Turner <yoshio@CS.UCLA.EDU>, modula 2 highlights
-;; Fritz Knabe <knabe@ecrc.de>, advice & patches
-;; Alon Albert <alon@milcse.rtsg.mot.com>, advice & patches
-;; dana@thumper.bellcore.com (Dana A. Chee), for breaking it...
-;; derway@ndc.com (Don Erway), for breaking it...
+;; ebert@enpc.enpc.fr (Rolf EBERT), ada, LaTeX & bibtex highlights
+;; Vivek Khera <khera@cs.duke.edu>, gnus hooks + random advice & patches
+;; brian@athe.WUstl.EDU (Brian Dunford-Shore), prolog highlights
+;; John Ladwig <jladwig@soils.umn.edu>, 1st pass nroff highlights
+;; campo@sunthpi3.difi.unipi.it (Massimo Campostrini), fortran highlights
+;; jayb@laplace.MATH.ColoState.EDU (Jay Bourland), 1st pass dired
+;; Yoshio Turner <yoshio@CS.UCLA.EDU>, modula 2 highlights
+;; Fritz Knabe <knabe@ecrc.de>, advice & patches
+;; Alon Albert <alon@milcse.rtsg.mot.com>, advice & patches
+;; dana@thumper.bellcore.com (Dana A. Chee), working on the multi-frame bug
+;; derway@ndc.com (Don Erway), for breaking it...
+;; moss_r@summer.chem.su.oz.au (Richard Moss), first pass at add-pattern
+;; Olivier Lecarme <ol@aiguemarine.unice.fr>, Pascal & Icon patterns
;;
;; With suggestions and minor regex patches from numerous others...
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
-;; HISTORY
-;;
-;; V1.9 21-July-1993 Stig@netcom.com
-;; better documentation and added the function hilit-submit-feedback.
-;; no longer rebind ^L, now C-S-l (control shift l) repaints the buffer
-;; multi-line highlights no longer cause problems when
-;; hilit-auto-rehighlight is 'visible
-;; added hilit-predefined-face-list...
-;; changed name of hilit-mode-alist to hilit-patterns-alist
-;; added hilit-message-quietly to mail-setup-hook
-;; added hilit-parser-alist which can be used to apply different patterns to
-;; different parts of a buffer. This could be integrated in a far more
-;; elegant manner, but it presently serves the purpose of not applying
-;; message header patterns to message bodies in mail-mode and it's kin.
-;; hilit-set-mode-patterns now takes a list of modes and an optional parse-fn
-;; V1.8 19-July-1993 Stig@netcom.com
-;; changed hilit-translate to be a macro so that now it mirrors setq
-;; now permit multiple layers of face-translation...
-;; hilit-lookup-face-create now parses background colors
-;; added code to check for face changes and recopy the fonts from 'default
-;; when necessary. this can be disabled if you never change fonts.
-;; you should be able to change fonts, redraw, and have all of your
-;; bold & italic faces back to normal. Should work in new frames as well.
-;; fixed typo for one of the vm hooks and included the magic patch to
-;; vm5.33 that keeps the summary window up to date.
-;; got rid of the annoying dings and delays when colors aren't available
-;; set case-fold-search to nil in highlighting-region function
-;; fixed minor bug in hilit-rehighlight-message-quietly
-;; patches to Info, LaTeX, fortran, nroff, & c++ patterns
-;; modula-2-mode support
-;; improved gnus-mark-article-hook
-;; moved timecard-mode highlights to timecard-mode itself
-;; V1.7 12-July-1993 Stig@netcom.com
-;; fix to dired patterns
-;; punted on the dual functionality in hilit-auto-highlight and added
-;; hilit-mode-enable-list, which permits users to specifically lock out
-;; modes by preventing them from being added into the hilit-mode-list
-;; incorporated defaults for dark backgrounds (see hilit-background-mode)
-;; incorporated fortran highlighting patterns
-;; patches to ada-mode and msg-header regexes
-;; added msg-separator pattern
-;; changed dired-backup to dired ignored which (which is derived from the
-;; variable completion-ignored-extensions)
-;; V1.6 5-July-1993 Stig@netcom.com
-;; added dired patterns
-;; fixed minor typo bug in mail patterns
-;; added profiling hook
-;; V1.5 5-July-1993 Stig@netcom.com
-;; changed behavior of hilit-recenter to more closely match that of recenter
-;; hilit-auto-highlight can now be a list of major-modes to highlight on find
-;; reverted to using overlays...the cost of text-properties is too high, IMHO
-;; added 'visible option to hilit-auto-rehighlight variable
-;; now highlighting support for info pages (see patch below)
-;; added hilit-yank and hilit-yank-pop which replace their analogues
-;; wrote special parsing function for strings...bug squished...faster too
-;; tuned the texinfo patterns for better performance
-;; nroff support
-;; V1.4 2-July-1993 Stig@netcom.com
-;; more efficient highlighting for news and mail
-;; switched to text properties (this may be temporary)
-;; changed regular expressions for c*mode to accomodate syntax tables
-;; minor mod to Ada parameter regexp
-;; now catch regex stack overflows and print an error
-;; string matching now uses start and end expressions to prevent overflows
-;; V1.3 28-June-1993 Stig@netcom.com
-;; added support for hexadecimal color specification under X
-;; added hilit-translate for simple color translations
-;; changed coverage of hilit-quietly...when it's quiet, it's always quiet.
-;; removed extra call to unhighlight-region in rehighlight-buffer
-;; automatically installs hooks, unless hilit-inhibit-hooks set before load
-;; installed fixes for latex
-;; V1.2 28-June-1993 Stig@netcom.com
-;; partially fixed bug in hilit-toggle-highlight
-;; added string highlighting
-;; fixed bug in hilit-lookup-face-create
-;; additions for Ada, Tex, LaTeX, and Texinfo (is scribe next? =)
-;; now highlight template decls in C++
-;; added reverse-* intelligence to hilit-lookup-face-create
-;; imported wysiwyg (overstrike replacement) stuff from my hacks to man.el
-;; sketched out a stub of a wysiwyg write file hook, care to finish it?
-;; V1.1 25-June-1993 Stig@netcom.com
-;; replaced last vestiges of original hilit.el
-;; now map default modes to major-mode values
-;; reworked face allocation so that colors don't get tied up
-;; rewrote some comments that I'd put in earlier but somehow managed to nuke
-;; V1.0 22-June-1993 Stig@netcom.com
-;; incrementally replaced just about everything...simpler, cleaner, & faster
-;; extended highlight coverage for C/C++ modes (highlight more things)
-;; added layer of indirection to face selection
-
-;;;;;; THIS WILL ALLOW INFO PAGES TO BE HILIGHTED:
-;;
-;; *** 19.15/info.el Sat Jun 19 14:47:06 1993
-;; --- 19/info.el Sun Jul 4 03:33:12 1993
-;; ***************
-;; *** 475,481 ****
-;; (setq active-expression
-;; (read (current-buffer))))))
-;; (point-max)))
-;; ! (if Info-enable-active-nodes (eval active-expression)))))
-;;
-;; (defun Info-set-mode-line ()
-;; (setq mode-line-buffer-identification
-;; --- 475,482 ----
-;; (setq active-expression
-;; (read (current-buffer))))))
-;; (point-max)))
-;; ! (if Info-enable-active-nodes (eval active-expression)))
-;; ! (run-hooks 'Info-select-hook)))
-;;
-;; (defun Info-set-mode-line ()
-;; (setq mode-line-buffer-identification
+;; hilit19.el,v
+;; Revision 2.19 1993/09/08 18:44:10 stig
+;; installed patch for elusive bug in hilit-rehighlight-region that caused
+;; hilit-unhighlight-region to hang in an infinite loop.
+;;
+;; Revision 2.18 1993/08/27 03:51:00 stig
+;; minor mods to lisp-mode and c/c++ mode patterns
+;;
+;; Revision 2.17 1993/08/25 02:19:17 stig
+;; work-around for bug in next-overlay-change that caused dired and jargon-mode
+;; to hang in an endless loop. Perhaps other modes were doing this too.
+;;
+;; Revision 2.16 1993/08/22 19:46:00 stig
+;; bug fix for next-overlay-change and accompanying change to
+;; hilit-unhighlight-region
+;;
+;; Revision 2.15 1993/08/20 12:16:22 stig
+;; minor change to fortran patterns
+;;
+;; Revision 2.14 1993/08/17 14:12:10 stig
+;; added default face mapping for 'formula' which is needed for new latex
+;; patterns.
+;;
+;; twiddled the calendar-mode patterns a bit.
+;;
+;; Revision 2.13 1993/08/16 04:33:54 stig
+;; hilit-set-mode-patterns was screwing up two part patterns. it doesn't now.
+;;
+;; Revision 2.12 1993/08/16 00:16:41 stig
+;; changed references to default-bold-italic to just bold-italic because the
+;; font for that face is maintained by emacs.
+;;
+;; the pattern matcher now starts it's searches from the end of the most
+;; recently highlighted region (which is not necessarily the end of the most
+;; recently matched regex).
+;;
+;; multiple errors in pattern matcher now just give an error instead of lots of
+;; annoying messages and dings.
+;;
+;; no longer use vm-summary-mode-hooks.
+;;
+;; some code moved from hilit-highlight-region to hilit-set-mode-patterns.
+;; This will affect you if you pass your patterns directly to
+;; hilit-highlight-region....use a pseudo-mode instead.
+;;
+;; pattern changes to C/C++, latex, texinfo, fortran, nroff, etc.
+;;
+;; Revision 2.11 1993/08/13 12:12:37 stig
+;; removed some crufty commented-out code
+;;
+;; diverged lisp-mode and emacs-lisp-mode...also added lisp keywords.
+;;
+;; Revision 2.10 1993/08/13 09:47:06 stig
+;; added calendar-mode, icon-mode and pascal-mode patterns
+;;
+;; commented out hilit-toggle-highlight because I want to phase it out entirely
+;;
+;; Revision 2.9 1993/08/13 08:44:22 stig
+;; added optional case-fold argument to hilit-set-mode-patterns, this case-fold
+;; parameter is now stored in hilit-patterns-alist.
+;;
+;; Revision 2.8 1993/08/12 22:05:03 stig
+;; fixed some typos in documentation
+;;
+;; twiddled some of the color defaults for dark backgrounds
;;
+;; always get 'mono color defaults if (not (x-display-color-p))
+;;
+;; added hilit-rehighlight-buffer-quietly to dired-after-readin-hook
+;;
+;; fixed bug in hilit-string-find that mishandled strings of the form: "\\"
+;;
+;; NEW FUNCTION: hilit-add-mode-pattern... kinda like add-hook for patterns
+;;
+;; fixed minor pattern bugs for latex-mode and emacs-lisp-mode
+;;
+;; Revision 2.7 1993/07/30 02:43:01 stig
+;; added const to the list of modifiers for C/C++ types
+;;
+;; Revision 2.6 1993/07/30 00:30:54 stig
+;; now permit selection of arbitrary subexpressions for highlighting...
+;; fixed keyword patterns for C/C++ using this technique.
+;;
+;; Revision 2.5 1993/07/28 05:02:56 stig
+;; improvements to makefile regular expressions
+;; removed about 130 lines just by compacting the big defconst for
+;; hilit-face-translation-table into a mapcar and defining a separate table
+;; of default faces.
+;;
+;; Revision 2.4 1993/07/27 14:09:05 stig
+;; documented another "known problem" to "head off gripe mail at the pass."
+;;
+;; Revision 2.3 1993/07/27 02:15:49 stig
+;; (hilit-lookup-face-create) incorporated patch which improves it's behavior
+;; with more than one frame... Still can't have bold on the same face in two
+;; differrent fonts sizes at the same time...
+;;
+;; Revision 2.2 1993/07/27 02:02:59 stig
+;; vastly improved the makefile patterns
+;; added hook for mh-show-mode
+;;
+;; Revision 2.1 1993/07/24 17:46:21 stig
+;; Phasing out Info-select-hook... Version 19.18 will use Info-selection-hook.
+;;
+;; Revision 2.0 1993/07/24 13:50:10 stig
+;; better documentation and added the function hilit-submit-feedback.
+;; C-S-l (control shift l) repaints the buffer. Other bindings are optional.
+;; multi-line highlights no longer cause problems when
+;; hilit-auto-rehighlight is 'visible
+;; added hilit-predefined-face-list...
+;; changed name of hilit-mode-alist to hilit-patterns-alist
+;; added hilit-message-quietly to mail-setup-hook
+;; added hilit-parser-alist which can be used to apply different patterns to
+;; different parts of a buffer. This could be integrated in a far more
+;; elegant manner, but it presently serves the purpose of not applying
+;; message header patterns to message bodies in mail-mode and it's kin.
+;; hilit-set-mode-patterns now takes a list of modes and an optional parse-fn
+;;
+
;;;;;; AND THIS CAN BE APPLIED TO VM 5.33L_19
;;
;; *** ../site/vm5.33L_19/vm-summary.el Fri Jun 4 22:17:11 1993
;;
;;;;;;
\f
+;;; Code:
;; User Options:
(defvar hilit-quietly nil
"* If non-nil, this inhibits progress indicators during highlighting")
-(defvar hilit-inhibit-hooks nil
- "* If non-nil, this inhibits installation of hooks for Info, gnus, & vm.")
-
-(defvar hilit-background-mode 'light
- "* 'mono inhibits color, 'dark or 'light indicate the background brightness.")
-
-(defvar hilit-mode-enable-list nil
- "* If a list of modes to exclusively enable or specifically disable.
-The sense of the list is negated if it begins with the symbol 'not'.
-Set this variable before you load hilit19.
-
-Ex: (perl-mode jargon-mode c-mode) ; just perl, C, and jargon modes
- (not text-mode) ; all modes except text mode")
-
(defvar hilit-auto-highlight t
"* T if we should highlight all buffers as we find 'em, nil to disable
automatic highlighting by the find-file hook.")
-(defvar hilit-auto-highlight-maxout 57000
+(defvar hilit-auto-highlight-maxout 60000 ; hilit19 keeps getting bigger...
"* auto-highlight is disabled in buffers larger than this")
(defvar hilit-auto-rehighlight t
"* If this is non-nil, then hilit-redraw and hilit-recenter will also
- rehighlight part or all of the current buffer. T will rehighlights the
- whole buffer, a NUMBER will rehighlight that many lines before and
- after the cursor, or the symbol 'visible' will rehighlight only the visible
- portion of the current buffer.")
+ rehighlight part or all of the current buffer. T will rehighlight the
+ whole buffer, a NUMBER will rehighlight that many lines before and after
+ the cursor, and the symbol 'visible' will rehighlight only the visible
+ portion of the current buffer. This variable is buffer-local.")
(make-variable-buffer-local 'hilit-auto-rehighlight)
-(setq-default hilit-auto-rehighlight t)
(defvar hilit-auto-rehighlight-fallback '(20000 . 100)
"* Cons of the form (THRESHOLD . FALLBACK), where FALLBACK is assigned to
-hilit-auto-rehighlight if the size of a newly opened buffer is larger than
-THRESHOLD.")
+ hilit-auto-rehighlight if the size of a newly opened buffer is larger than
+ THRESHOLD.")
(defvar hilit-face-check t
"* T slows down highlighting but permits the user to change fonts without
-losing bold and italic faces... T causes hilit-lookup-face-create to dig
-through the frame parameters for the current window every time it's called.
-If you never change fonts in emacs, set this to NIL.")
+ losing bold and italic faces... T causes hilit-lookup-face-create to dig
+ through the frame parameters for the current window every time it's called.
+ If you never change fonts in emacs, set this to NIL.")
+
+;; Variables which must be set before loading hilit19.
+
+(defvar hilit-inhibit-rebinding nil
+ "If non-nil, this inhibits replacement of recenter, yank, and yank-pop.")
+
+(defvar hilit-inhibit-hooks nil
+ "If non-nil, this inhibits installation of hooks for Info, gnus, & vm.")
+
+(defvar hilit-background-mode 'light
+ "'mono inhibits color, 'dark or 'light indicate the background brightness.")
+
+(defvar hilit-mode-enable-list nil
+ "If a list of modes to exclusively enable or specifically disable.
+The sense of the list is negated if it begins with the symbol 'not'.
+Set this variable before you load hilit19.
+
+Ex: (perl-mode jargon-mode c-mode) ; just perl, C, and jargon modes
+ (not text-mode) ; all modes except text mode")
;; Variables that are not generally modified directly
(defvar hilit-patterns-alist nil
"alist of major-mode values and default highlighting patterns
-A hilighting pattern is a list of the form (start end face), where
-start is a regex, end is a regex (or nil if it's not needed) and face
+A highlighting pattern is a list of the form (start end face), where
+start is a regex, end is either a regex or a match number for start, and face
is the name of an entry in hilit-face-translation-table, the name of a face,
or nil (which disables the pattern).
+Each entry in the alist is of the form:
+ (mode . (case-fold pattern [pattern ...]))
+
See the hilit-lookup-face-create documentation for valid face names.")
(defvar hilit-predefined-face-list (face-list)
- "List of faces which with hilit-lookup-face-create will NOT tamper.
+ "List of faces with which hilit-lookup-face-create will NOT tamper.
If hilit19 is dumped into emacs at your site, you may have to set this in
your init file.")
+(eval-when-compile (setq byte-optimize t))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Use this to report bugs:
-(defun hilit-submit-feeback ()
- "Submit via mail a bug report on stig-paren"
+(eval-when-compile (require 'reporter)) ; no compilation gripes
+
+(defun hilit-submit-feedback ()
+ "Submit feedback on hilit19 to the author: stig@hackvan.com"
(interactive)
(require 'reporter)
(and (y-or-n-p "Do you really want to submit a report on hilit19? ")
(reporter-submit-bug-report
- "Jonathan Stigelman <Stig@netcom.com>"
- "hilit19.el Beta 1.9 ($Revision: 1.34 $)"
+ "Jonathan Stigelman <stig@hackvan.com>"
+ "hilit19.el (Release 2.19)"
(and (y-or-n-p "Do you need to include a dump hilit variables? ")
(append
'(
))))
(function
(lambda ()
- (insert "\nFrame Configuration:\n====================\n"
- (prin1-to-string (frame-configuration-to-register ?F))
- "\n"
- )))
+ (and (y-or-n-p "Is this a problem with font display? ")
+ (insert "\nFrame Configuration:\n====================\n"
+ (prin1-to-string (frame-configuration-to-register ?F))
+ "\n"
+ ))))
nil
(concat
- "This is (check all that apply, or delete those that don't):\n"
+ "This is (check all that apply, and delete what's irrelevant):\n"
" [ ] a _MASSIVE_THANK_YOU_ for writing hilit19.el\n"
- " [ ] my DONATION to your vacation fund (prototype digital cash)\n"
+ " [ ] An invitation to attend the next Hackers Conference\n"
" [ ] You're a RIGHTEOUS HACKER, what are your rates?\n"
" [ ] I've used the force and read the source, but I'M CONFUSED\n"
- " [ ] a PATCH (diff -cw oldversion newversion) to fix a problem\n"
- " [ ] a REPRODUCABLE BUG that I do not believe to be an EMACS bug\n"
+ " [ ] a PATCH. (output of 'diff -uw old.el new.el' or 'diff -cw')\n"
+ " [ ] a SERIOUS AND REPRODUCABLE BUG that is not an EMACS bug\n"
" - I *swear* that it's not already mentioned in the KNOWN BUGS\n"
- " - Also, I have checked netcom.com:/pub/stig/src/hilit19.el.gz\n"
+ " - I HAVE CHECKED ftp.hackvan.com:/pub/stig/src/elisp/hilit19.el.gz\n"
" for a newer release that fixes the problem.\n"
- " [ ] ADVICE -- or an unfulfilled desire that I suspect you share\n"
+ " >> I HAVE ALSO CHECKED ftp.hackvan.com:/pub/stig/src/elisp/hl319.el.gz\n"
+ " This is the alpha version...what will become hilit19 (Beta 3.0).\n"
"\n"
- "Hey Stig, do you do anything besides hack emacs?\n"))))
+ "Hey Stig, I *know* you're busy but...\n"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; These faces are either a valid face name, or nil
;; if you want to change them, you must do so AFTER hilit19 is loaded
-(defconst hilit-face-translation-table
- (cond ((and (eq hilit-background-mode 'light) (x-display-color-p))
- ;; COLOR DEFAULTS for LIGHT backgrounds
- '(
- ;; used for C/C++ and elisp and perl
- (comment . firebrick-italic)
- (include . purple)
- (define . ForestGreen-bold)
- (defun . blue-bold)
- (decl . RoyalBlue)
- (type . nil)
- (keyword . RoyalBlue)
- (label . red-bold)
- (string . grey40)
-
- ;; some further faces for Ada
- (struct . black-bold)
- (glob-struct . magenta)
- (named-param . DarkGoldenrod)
+(defconst hilit-default-face-table
+ '(
+ ;; used for C/C++ and Emacs Lisp and perl
+ (comment firebrick-italic moccasin italic)
+ (include purple Plum1 bold-italic)
+ (define ForestGreen-bold green bold)
+ (defun blue-bold cyan-bold bold-italic)
+ (decl RoyalBlue cyan bold)
+ (type nil yellow nil)
+ (keyword RoyalBlue cyan bold-italic)
+ (label red-underline orange-underlined underline)
+ (string grey40 orange underline)
+
+ ;; some further faces for Ada
+ (struct black-bold white-bold bold)
+ (glob-struct magenta Plum1 default-bold-underline)
+ (named-param DarkGoldenrod Goldenrod underline)
- ;; and anotherone for LaTeX
- (crossref . DarkGoldenrod)
+ ;; and anotherone for LaTeX
+ (crossref DarkGoldenrod Goldenrod underline)
+ (formula Goldenrod DarkGoldenrod underline)
- (wysiwyg-bold . bold)
- (wysiwyg-underline . underline)
-
- ;; compilation buffers
- (error . red-bold)
- (warning . firebrick)
-
- ;; Makefiles (some faces borrowed from C/C++ too)
- (rule . blue-bold)
-
- ;; VM, GNUS and Text mode
- (msg-subject . blue-bold)
- (msg-from . purple-bold)
- (msg-header . firebrick-bold)
- (msg-separator . black/tan-bold)
- (msg-quote . ForestGreen)
-
- (summary-seen . grey40)
- (summary-killed . grey50)
- (summary-Xed . OliveDrab2)
- (summary-current . default/skyblue-bold)
- (summary-deleted . firebrick)
- (summary-unread . RoyalBlue)
- (summary-new . blue-bold)
-
- (gnus-group-unsubscribed . grey50)
- (gnus-group-empty . nil)
- (gnus-group-full . ForestGreen)
- (gnus-group-overflowing . firebrick)
-
- ;; dired mode
- (dired-directory . blue-bold)
- (dired-link . firebrick-italic)
- (dired-ignored . ForestGreen)
- (dired-deleted . red-bold-italic)
- (dired-marked . purple)
-
- ;; see jargon-mode.el and prep.ai.mit.edu:/pub/gnu/jargon*.txt
- (jargon-entry . blue-bold)
- (jargon-xref . purple-bold)
- ;; really used for Info-mode
- (jargon-keyword . firebrick-underline)
- ))
- ((and (eq hilit-background-mode 'dark) (x-display-color-p))
- ;; COLOR DEFAULTS for DARK backgrounds
- '(
- ;; used for C/C++ and elisp and perl
- (comment . moccasin)
- (include . Plum1)
- (define . green)
- (defun . cyan-bold)
- (decl . cyan)
- (type . yellow)
- (keyword . cyan)
- (label . orange-underlined)
- (string . orange)
-
- ;; some further faces for Ada
- (struct . white-bold)
- (glob-struct . Plum1)
- (named-param . Goldenrod)
-
- ;; and anotherone for LaTeX
- (crossref . Goldenrod)
+ ;; compilation buffers
+ (active-error default/pink-bold default/DeepPink-bold default-underline)
+ (error red-bold yellow bold)
+ (warning blue-italic green italic)
+
+ ;; Makefiles (some faces borrowed from C/C++ too)
+ (rule blue-bold-underline cyan-underline default-bold-underline)
+
+ ;; VM, GNUS and Text mode
+ (msg-subject blue-bold yellow bold)
+ (msg-from purple-bold green bold)
+ (msg-header firebrick-bold cyan italic)
+ (msg-separator black/tan-bold black/lightblue nil)
+ (msg-quote ForestGreen pink italic)
+
+ (summary-seen grey40 white nil)
+ (summary-killed grey50 white nil)
+ (summary-Xed OliveDrab2 green nil)
+ (summary-deleted firebrick white italic)
+ (summary-unread RoyalBlue yellow bold)
+ (summary-new blue-bold yellow-bold bold-italic)
+ (summary-current default/skyblue-bold green/dimgrey-bold reverse-default)
+
+ (gnus-group-unsubscribed grey50 white nil)
+ (gnus-group-empty nil nil nil)
+ (gnus-group-full ForestGreen green italic)
+ (gnus-group-overflowing firebrick red bold-italic)
+
+ ;; dired mode
+ (dired-directory blue-bold cyan bold)
+ (dired-link firebrick-italic green italic)
+ (dired-ignored ForestGreen moccasin nil)
+ (dired-deleted red-bold-italic orange bold-italic)
+ (dired-marked purple Plum1 nil)
- (wysiwyg-bold . bold)
- (wysiwyg-underline . underline)
-
- ;; compilation buffers
- (error . yellow)
- (warning . green)
-
- ;; Makefiles (some faces borrowed from C/C++ too)
- (rule . cyan)
-
- ;; VM, GNUS and Text mode
- (msg-subject . yellow)
- (msg-from . SeaGreen2)
- (msg-header . cyan)
- (msg-separator . lightblue)
- (msg-quote . green)
-
- (summary-seen . white)
- (summary-killed . white)
- (summary-Xed . green)
- (summary-current . green-bold)
- (summary-deleted . white)
- (summary-unread . yellow)
- (summary-new . yellow-bold)
-
- (gnus-group-unsubscribed . white)
- (gnus-group-empty . yellow)
- (gnus-group-full . green)
- (gnus-group-overflowing . orange)
-
- ;; dired mode
- (dired-directory . cyan)
- (dired-link . green)
- (dired-ignored . moccasin)
- (dired-deleted . orange)
- (dired-marked . Plum1)
-
- ;; see jargon-mode.el and prep.ai.mit.edu:/pub/gnu/jargon*.txt
- (jargon-entry . cyan)
- (jargon-xref . Plum1)
- ;; really used for Info-mode
- (jargon-keyword . yellow)
- ))
- (t
- ;; MONO DEFAULTS -- you lose
- '(
- ;; used for C/C++ and elisp and perl
- (comment . italic)
- (include . default-bold-italic)
- (define . bold)
- (defun . default-bold-italic)
- (decl . bold)
- (type . nil)
- (keyword . default-bold-italic)
- (label . underline)
- (string . underline)
-
- ;; some further faces for Ada
- (struct . bold)
- (named-param . underline)
- (glob-struct . default-bold-underline)
-
- ;; and another one for LaTeX
- (crossref . underline)
-
- (wysiwyg-bold . bold)
- (wysiwyg-underline . underline)
-
- ;; compilation buffers
- (error . bold)
- (warning . italic)
-
- ;; Makefiles (some faces borrowed from C/C++ too)
- (rule . bold)
-
- ;; VM, GNUS and Text mode
- (msg-subject . bold)
- (msg-from . bold)
- (msg-header . italic)
- (msg-separator . nil)
- (msg-quote . italic)
-
- (summary-seen . nil)
- (summary-killed . nil)
- (summary-Xed . nil)
- (summary-current . reverse-default)
- (summary-unread . bold)
- (summary-deleted . italic)
- (summary-new . default-bold-italic)
-
- (gnus-group-unsubscribed . nil)
- (gnus-group-empty . nil)
- (gnus-group-full . italic)
- (gnus-group-overflowing . default-bold-italic)
-
- ;; dired mode
- (dired-directory . bold)
- (dired-link . italic)
- (dired-ignored . nil)
- (dired-marked . nil)
- (dired-deleted . default-bold-italic)
-
- ;; see jargon-mode.el and prep.ai.mit.edu:/pub/gnu/jargon*.txt
- (jargon-entry . bold)
- (jargon-xref . italic)
- ;; really used for Info-mode
- (jargon-keyword . underline)
- ))
- )
- "alist that maps symbolic face-names to real face names")
+ ;; Info-mode, and jargon-mode.el and prep.ai.mit.edu:/pub/gnu/jargon*
+ (jargon-entry blue-bold cyan bold)
+ (jargon-xref purple-bold Plum1 italic)
+ (jargon-keyword firebrick-underline yellow underline)
+ )
+ "alist of default faces (face . (light-default dark-default mono-default))
+
+There is no way for the user to modify this table such that it will have any
+effect upon the translations used by hilit19. Instead, use the function
+hilit-translate AFTER hilit19 has been loaded.
+
+See also the documentation for hilit-lookup-face-create.")
+
+(defconst hilit-face-translation-table
+ (let ((index (or (and (x-display-color-p)
+ (cdr (assq hilit-background-mode
+ '((light . 1) (dark . 2)))))
+ 3)))
+ (mapcar (function (lambda (x) (cons (car x) (nth index x))))
+ hilit-default-face-table))
+ "alist that maps symbolic face-names to real face names")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; To translate one face to another...
The function hilit-lookup-face-create will repeatedly translate until no more
translations for the face exist in the translation table.
-See the documentation for hilit-lookup-face-create for names of valid faces.
-"
-;; can't have an interactive macro
-;; (interactive "SFace translate from: \nSFace translate to: ")
+See the documentation for hilit-lookup-face-create for names of valid faces."
(or (zerop (% (length args) 2))
(error "wrong number of args"))
(let (cmdl from to)
(while args
(setq from (car args) to (nth 1 args) args (nthcdr 2 args)
cmdl (cons (list 'hilit-associate ''hilit-face-translation-table
- ;; this is for reverse compatibility...
- (if (and (consp from) (eq 'quote (car from)))
- from
- (list 'quote from)) to)
+ (list 'quote from) to)
cmdl)))
(cons 'progn cmdl)))
(set-face-font face nil frame)
(set-face-underline-p face (string-match "underline" fn))
(if (string-match ".*bold" fn)
- (make-face-bold face frame 'noerr))
+ ;; make face bold in all frames
+ (make-face-bold face nil 'noerr))
(if (string-match ".*italic" fn)
- (make-face-italic face frame 'noerr))
+ ;; make face italic in all frames
+ (make-face-italic face nil 'noerr))
))
)))
face)
"Unhighlights the region from START to END, optionally in a QUIET way"
(interactive "r")
(or quietly hilit-quietly (message "Unhighlighting"))
- (while (< start end)
- (mapcar (function (lambda (ovr)
- (and (overlay-get ovr 'hilit) (delete-overlay ovr))))
- (overlays-at start))
- (setq start (next-overlay-change start)))
+ (let ((lstart 0))
+ (while (and start (> start lstart) (< start end))
+ (mapcar (function (lambda (ovr)
+ (and (overlay-get ovr 'hilit) (delete-overlay ovr))))
+ (overlays-at start))
+ (setq lstart start start (next-overlay-change start))))
(or quietly hilit-quietly (message "Done unhighlighting")))
;;;; These functions use text properties instead of overlays. Text properties
((symbolp patterns)
(setq patterns (cdr (assq patterns hilit-patterns-alist)))))
;; txt prop: (setq patterns (reverse patterns))
- (let ((prio (length patterns))
- (case-fold-search nil)
+ (let ((case-fold-search (car patterns))
+ (prio (1- (length patterns)))
;; txt prop: (buffer-read-only nil)
;; txt prop: (bm (buffer-modified-p))
- p pstart pend face mstart)
+ p pstart pend face mstart (puke-count 0))
;; txt prop: (unwind-protect
+ (setq patterns (cdr patterns)) ; remove case-fold from head of pattern
(save-excursion
(save-restriction
(narrow-to-region start end)
nil
(or quietly hilit-quietly
(message "highlighting %d: %s%s" prio pstart
- (if pend (concat " ... " pend) "")))
+ (if (stringp pend) (concat " ... " pend) "")))
(goto-char (point-min))
- (condition-case nil
+ (condition-case msg
(cond
((symbolp pstart)
;; inner loop -- special function to find pattern
(while (setq region (funcall pstart pend))
(hilit-region-set-face (car region) (cdr region)
face prio))))
- (pend
+ ((stringp pend)
;; inner loop -- regex-start ... regex-end
(while (re-search-forward pstart nil t nil)
(goto-char (setq mstart (match-beginning 0)))
(hilit-region-set-face mstart (match-end 0)
face prio)
(forward-char 1))))
- (t
+ ((numberp pend)
;; inner loop -- just one regex to match whole pattern
(while (re-search-forward pstart nil t nil)
- (hilit-region-set-face (match-beginning 0)
- (match-end 0) face prio))))
- (error (message "Unbalanced delimiters? Barfed on '%s'"
- pstart)
- (ding) (sit-for 4))))
+ (goto-char (match-end pend))
+ (hilit-region-set-face (match-beginning pend)
+ (match-end pend) face prio)))
+ (t (error "malformed pattern")))
+ (error (if (> (setq puke-count (1+ puke-count)) 1)
+ (error msg)
+ (message "Error: '%s'" msg)
+ (ding) (sit-for 4)))))
(setq prio (1- prio)
patterns (cdr patterns)))
- ))
+ ))
(or quietly hilit-quietly (message "")) ; "Done highlighting"
;; txt prop: (set-buffer-modified-p bm)) ; unwind protection
))
(defun hilit-rehighlight-region (start end &optional quietly)
"Re-highlights the region, optionally in a QUIET way"
(interactive "r")
- (setq start (apply 'min start (mapcar 'overlay-start (overlays-at start)))
- end (apply 'max end (mapcar 'overlay-end (overlays-at end))))
- (hilit-unhighlight-region start end quietly)
- (hilit-highlight-region start end nil quietly))
+ (save-restriction
+ (widen)
+ (setq start (apply 'min start (mapcar 'overlay-start (overlays-at start)))
+ end (apply 'max end (mapcar 'overlay-end (overlays-at end))))
+ (hilit-unhighlight-region start end quietly)
+ (hilit-highlight-region start end nil quietly)))
(defun hilit-rehighlight-buffer (&optional quietly)
"Re-highlights the buffer, optionally in a QUIET way"
(defalias 'hilit-highlight-buffer 'hilit-rehighlight-buffer)
-(defun hilit-toggle-highlight (arg)
- "Locally toggle highlighting. With arg, forces highlighting off."
- (interactive "P")
- ;; FIXME -- this loses numeric information in hilit-auto-rehighlight
- (setq hilit-auto-rehighlight
- (and (not arg) (not hilit-auto-rehighlight)))
- (if hilit-auto-rehighlight
- (hilit-rehighlight-buffer)
- (hilit-unhighlight-region (point-min) (point-max)))
- (message "Rehighlighting is set to %s" hilit-auto-rehighlight))
+;; Well, I want to remove this function...there's one sure way to find out if
+;; anyone uses it or not...and that's to comment it out.
+;;
+;; (defun hilit-toggle-highlight (arg)
+;; "Locally toggle highlighting. With arg, forces highlighting off."
+;; (interactive "P")
+;; ;; FIXME -- this loses numeric information in hilit-auto-rehighlight
+;; (setq hilit-auto-rehighlight
+;; (and (not arg) (not hilit-auto-rehighlight)))
+;; (if hilit-auto-rehighlight
+;; (hilit-rehighlight-buffer)
+;; (hilit-unhighlight-region (point-min) (point-max)))
+;; (message "Rehighlighting is set to %s" hilit-auto-rehighlight))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HOOKS
(if (> buffer-saved-size (car hilit-auto-rehighlight-fallback))
(setq hilit-auto-rehighlight
(cdr hilit-auto-rehighlight-fallback)))
- (if (> buffer-saved-size hilit-auto-highlight-maxout) nil
- (hilit-rehighlight-buffer)
- (set-buffer-modified-p nil)))))
+ (if (> buffer-saved-size hilit-auto-highlight-maxout)
+ nil
+ (let ((bm (buffer-modified-p)))
+ (hilit-rehighlight-buffer)
+ (set-buffer-modified-p bm))))))
(defun hilit-repaint-command (arg)
"Rehighlights according to the value of hilit-auto-rehighlight, or the
(if st
(hilit-rehighlight-region st en quietly))))
-;; (defun hilit-rehighlight-yank-region ()
-;; "Rehighlights from the beginning of the line where the region starts to
-;; the end of the line where the region ends. This could flake out on
-;; multi-line highlights (like C comments and lisp strings.)"
-;; (if hilit-auto-rehighlight
-;; (hilit-rehighlight-region
-;; (save-excursion (goto-char (region-beginning))
-;; (beginning-of-line) (point))
-;; (save-excursion (goto-char (region-end))
-;; (end-of-line) (point))
-;; t)))
-
(defun hilit-recenter (arg)
"Recenter, then rehighlight according to hilit-auto-rehighlight. If called
with an unspecified prefix argument (^U but no number), then a rehighlight of
(sit-for 0)
(hilit-repaint-command (consp arg)))
-;; (defun hilit-redraw-display (arg)
-;; "Rehighlights according to the value of hilit-auto-rehighlight, a prefix
-;; arg forces a rehighlight of the whole buffer. Otherwise just like
-;; redraw-display."
-;; (interactive "P")
-;; (hilit-redraw-internal arg)
-;; (redraw-display))
-
(defun hilit-yank (arg)
"Yank with rehighlighting"
(interactive "*P")
(let ((transient-mark-mode nil))
(yank arg)
- (hilit-rehighlight-region (region-beginning) (region-end) t)
+ (and hilit-auto-rehighlight
+ (hilit-rehighlight-region (region-beginning) (region-end) t))
(setq this-command 'yank)))
(defun hilit-yank-pop (arg)
(interactive "*p")
(let ((transient-mark-mode nil))
(yank-pop arg)
- (hilit-rehighlight-region (region-beginning) (region-end) t)
+ (and hilit-auto-rehighlight
+ (hilit-rehighlight-region (region-beginning) (region-end) t))
(setq this-command 'yank)))
;;; this line highlighting stuff is untested. play with it only if you feel
;; Initialization.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(substitute-key-definition 'yank 'hilit-yank (current-global-map))
-(substitute-key-definition 'yank-pop 'hilit-yank-pop (current-global-map))
-
-;; (substitute-key-definition 'recenter 'hilit-recenter (current-global-map))
-;; (substitute-key-definition 'redraw-display 'hilit-redraw-display
-;; (current-global-map))
+(and (not hilit-inhibit-rebinding)
+ window-system
+ (progn
+ (substitute-key-definition 'yank 'hilit-yank
+ (current-global-map))
+ (substitute-key-definition 'yank-pop 'hilit-yank-pop
+ (current-global-map))
+ (substitute-key-definition 'recenter 'hilit-recenter
+ (current-global-map))))
(global-set-key [?\C-\S-l] 'hilit-repaint-command)
(and window-system
(add-hook 'find-file-hooks 'hilit-find-file-hook t))
+(eval-when-compile (require 'gnus)) ; no compilation gripes
+
(and (not hilit-inhibit-hooks)
window-system
(condition-case c
(lambda (hook)
(add-hook hook 'hilit-rehighlight-buffer-quietly)))
'(
- Info-select-hook
- vm-summary-mode-hooks
- vm-summary-pointer-hook
- gnus-summary-prepare-hook
- gnus-group-prepare-hook
+ Info-selection-hook
+;; runs too early vm-summary-mode-hooks
+ vm-summary-pointer-hook
vm-preview-message-hook
vm-show-message-hook
- gnus-article-prepare-hook
+
rmail-show-message-hook
mail-setup-hook
- ))
+ mh-show-mode-hook
- ;; rehilight only the visible part of the summary buffer for speed.
- (add-hook 'gnus-mark-article-hook
- (function
- (lambda ()
- (or (memq gnus-current-article gnus-newsgroup-marked)
- (gnus-summary-mark-as-read gnus-current-article))
- (gnus-summary-set-current-mark)
- (save-excursion
- (set-buffer gnus-summary-buffer)
- (hilit-rehighlight-region (window-start)
- (window-end) t)
- ))))
- ;; only need prepare article hook
- ;;
- ;; (add-hook 'gnus-select-article-hook
- ;; '(lambda () (save-excursion
- ;; (set-buffer gnus-article-buffer)
- ;; (hilit-rehighlight-buffer))))
+ dired-after-readin-hook
+ ))
)
(error (message "Error loading highlight hooks: %s" c)
(ding) (sit-for 1))))
(setcdr oldentry val)
(set alist (cons (cons key val) (eval alist))))))
-(defun hilit-set-mode-patterns (modelist patterns &optional parse-fn)
- "Sets the default hilighting patterns for MODE to PATTERNS.
-See the variable hilit-mode-enable-list."
+(defun hilit-set-mode-patterns (modelist patterns
+ &optional parse-fn case-fold)
+ "Sets the default highlighting patterns for MODE to PATTERNS.
+See the variable hilit-mode-enable-list.
+
+Takes optional arguments PARSE-FN and CASE-FOLD."
+ ;; change pattern
+ (mapcar (function (lambda (p)
+ (and (stringp (car p))
+ (null (nth 1 p))
+ (setcar (cdr p) 0))))
+ patterns)
+ (setq patterns (cons case-fold patterns))
+
(or (consp modelist) (setq modelist (list modelist)))
(let (ok (flip (eq (car hilit-mode-enable-list) 'not)))
(mapcar (function
(memq m hilit-mode-enable-list)))
(and flip (setq ok (not ok)))
(and ok
- (progn
- (and parse-fn
- (hilit-associate 'hilit-parser-alist m parse-fn))
- (hilit-associate 'hilit-patterns-alist m patterns)))))
+ (progn
+ (and parse-fn
+ (hilit-associate 'hilit-parser-alist m parse-fn))
+ (hilit-associate 'hilit-patterns-alist m patterns)))))
modelist)))
+(defun hilit-add-pattern (pstart pend face &optional mode first)
+ "Highlight pstart with face for the current major-mode.
+Optionally, place the new pattern first in the pattern list"
+ (interactive "sPattern start regex: \nsPattern end regex (default none): \nxFace: ")
+
+ (and (equal pstart "") (error "Must specify starting regex"))
+ (cond ((equal pend "") (setq pend 0))
+ ((string-match "^[0-9]+$" pend) (setq pend (string-to-int pend))))
+ (or mode (setq mode major-mode))
+ (let ((old-patterns (cdr (assq mode hilit-patterns-alist)))
+ (new-pat (list pstart pend face)))
+ (cond ((not old-patterns)
+ (hilit-set-mode-patterns mode (list new-pat)))
+ (first
+ (setcdr old-patterns (cons new-pat (cdr old-patterns))))
+ (t
+ (nconc old-patterns (list new-pat)))))
+ (and (interactive-p) (hilit-rehighlight-buffer)))
+
(defun hilit-string-find (qchar)
"looks for a string and returns (start . end) or NIL. The argument QCHAR
is the character that would precede a character constant double quote.
-Finds [^QCHAR]\" ... [^\\]\""
+Finds strings delimited by double quotes. The first double quote may not be
+preceded by QCHAR and the closing double quote may not be preceded by an odd
+number of backslashes."
(let (st en)
(while (and (search-forward "\"" nil t)
(eq qchar (char-after (1- (setq st (match-beginning 0)))))))
(while (and (search-forward "\"" nil t)
- (eq ?\\ (char-after (- (setq en (point)) 2)))))
+ (save-excursion
+ (setq en (point))
+ (forward-char -1)
+ (skip-chars-backward "\\\\")
+ (forward-char 1)
+ (not (zerop (% (- en (point)) 2))))))
(and en (cons st en))))
-(hilit-set-mode-patterns
- '(c-mode c++-c-mode elec-c-mode)
- '(("/\\*" "\\*/" comment)
- ; ("\"" "[^\\]\"" string)
- (hilit-string-find ?' string)
- ;; declaration
- ("^#[ \t]*\\(undef\\|define\\).*$" nil define)
- ("^#.*$" nil include)
- ;; function decls are expected to have types on the previous line
- ("^\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun)
- ("^\\(typedef\\|struct\\|union\\|enum\\).*$" nil decl)
- ;; datatype -- black magic regular expression
- ("[ \n\t({]\\(\\(register\\|volatile\\|unsigned\\|extern\\|static\\)\\s +\\)*\\(\\(\\w\\|[$_]\\)+_t\\|float\\|double\\|void\\|char\\|short\\|int\\|long\\|FILE\\|\\(\\(struct\\|union\\|enum\\)\\([ \t]+\\(\\w\\|[$_]\\)*\\)\\)\\)\\(\\s +\\*+)?\\|[ \n\t;()]\\)" nil type)
- ;; key words
- ("\\<\\(return\\|goto\\|if\\|else\\|case\\|default\\|switch\\|break\\|continue\\|while\\|do\\|for\\)\\>" nil keyword)
- ))
+;; return types on same line...
+;; ("^[a-zA-z].*\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun)
-(hilit-set-mode-patterns
- 'c++-mode
- '(("/\\*" "\\*/" comment)
- ("//.*$" nil comment)
- ("^/.*$" nil comment)
-; ("\"" "[^\\]\"" string)
- (hilit-string-find ?' string)
- ;; declaration
- ("^#[ \t]*\\(undef\\|define\\).*$" nil define)
- ("^#.*$" nil include)
- ;; function decls are expected to have types on the previous line
- ("^\\(\\(\\w\\|[$_]\\)+::\\)?\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun)
- ("^\\(\\(\\w\\|[$_]\\)+[ \t]*::[ \t]*\\)?\\(\\(\\w\\|[$_]\\)+\\|operator.*\\)\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun)
- ("^\\(template\\|typedef\\|struct\\|union\\|class\\|enum\\|public\\|private\\|protected\\).*$" nil decl)
- ;; datatype -- black magic regular expression
- ("[ \n\t({]\\(\\(register\\|volatile\\|unsigned\\|extern\\|static\\)\\s +\\)*\\(\\(\\w\\|[$_]\\)+_t\\|float\\|double\\|void\\|char\\|short\\|int\\|long\\|FILE\\|\\(\\(struct\\|union\\|enum\\|class\\)\\([ \t]+\\(\\w\\|[$_]\\)*\\)\\)\\)\\(\\s +\\*+)?\\|[ \n\t;()]\\)" nil type)
- ;; key words
- ("\\<\\(return\\|goto\\|if\\|else\\|case\\|default\\|switch\\|break\\|continue\\|while\\|do\\|for\\|public\\|protected\\|private\\|delete\\|new\\)\\>"
- nil keyword)))
+;; On another note, a working pattern for grabbing function definitions for C is
+;;
+;; ("^[a-zA-Z_]+.*[;{]$" nil ForestGreen) ; global defns ( start at col 1 )
+;; ("^[a-zA-Z_]+.*(" ")" defun)
+;; ; defuns assumed to start at col 1, not with # or {
+;;
+;; this will make external declarations/definitions green, and function
+;; definitions the defun face. Hmmm - seems to work for me anyway.
+
+(let ((comments '(("/\\*" "\\*/" comment)))
+ (c++-comments '(("//.*$" nil comment)
+ ("^/.*$" nil comment)))
+ (strings '((hilit-string-find ?' string)))
+ (preprocessor '(("^#[ \t]*\\(undef\\|define\\).*$" "[^\\]$" define)
+ ("^#.*$" nil include))))
+
+ (hilit-set-mode-patterns
+ '(c-mode c++-c-mode elec-c-mode)
+ (append
+ comments strings preprocessor
+ '(
+ ;; function decls are expected to have types on the previous line
+ ("^\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun)
+ ("^\\(typedef\\|struct\\|union\\|enum\\).*$" nil decl)
+ ;; datatype -- black magic regular expression
+ ("[ \n\t({]\\(\\(const\\|register\\|volatile\\|unsigned\\|extern\\|static\\)\\s +\\)*\\(\\(\\w\\|[$_]\\)+_t\\|float\\|double\\|void\\|char\\|short\\|int\\|long\\|FILE\\|\\(\\(struct\\|union\\|enum\\)\\([ \t]+\\(\\w\\|[$_]\\)*\\)\\)\\)\\(\\s +\\*+)?\\|[ \n\t;()]\\)" nil type)
+ ;; key words
+ ("[^_]\\<\\(return\\|goto\\|if\\|else\\|case\\|default\\|switch\\|break\\|continue\\|while\\|do\\|for\\)\\>[^_]" 1 keyword)
+ )))
+
+ (hilit-set-mode-patterns
+ 'c++-mode
+ (append
+ comments c++-comments strings preprocessor
+ '(
+ ;; function decls are expected to have types on the previous line
+ ("^\\(\\(\\w\\|[$_]\\)+::\\)?\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun)
+ ("^\\(\\(\\w\\|[$_]\\)+[ \t]*::[ \t]*\\)?\\(\\(\\w\\|[$_]\\)+\\|operator.*\\)\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun)
+ ("^\\(template\\|typedef\\|struct\\|union\\|class\\|enum\\|public\\|private\\|protected\\).*$" nil decl)
+ ;; datatype -- black magic regular expression
+ ("[ \n\t({]\\(\\(const\\|register\\|volatile\\|unsigned\\|extern\\|static\\)\\s +\\)*\\(\\(\\w\\|[$_]\\)+_t\\|float\\|double\\|void\\|char\\|short\\|int\\|long\\|FILE\\|\\(\\(struct\\|union\\|enum\\|class\\)\\([ \t]+\\(\\w\\|[$_]\\)*\\)\\)\\)\\(\\s +\\*+)?\\|[ \n\t;()]\\)" nil type)
+ ;; key words
+ ("[^_]\\<\\(return\\|goto\\|if\\|else\\|case\\|default\\|switch\\|break\\|continue\\|while\\|do\\|for\\|public\\|protected\\|private\\|delete\\|new\\)\\>[^_]"
+ 1 keyword))))
+
+ (hilit-set-mode-patterns
+ '(objc-mode objective-C-mode)
+ (append
+ comments c++-comments strings preprocessor
+ '(
+ ;; function decls are expected to have types on the previous line
+ ("^\\(\\(\\w\\|[$_]\\)+::\\)?\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun)
+ ("^\\(\\(\\w\\|[$_]\\)+[ \t]*::[ \t]*\\)?\\(\\(\\w\\|[$_]\\)+\\|operator.*\\)\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun)
+
+ ("^\\(template\\|typedef\\|struct\\|union\\|class\\|enum\\|public\\|private\\|protected\\).*$" nil decl)
+ ;; datatype -- black magic regular expression
+ ("[ \n\t({]\\(\\(const\\|register\\|volatile\\|unsigned\\|extern\\|static\\)\\s +\\)*\\(\\(\\w\\|[$_]\\)+_t\\|float\\|double\\|void\\|char\\|short\\|int\\|long\\|FILE\\|\\(\\(struct\\|union\\|enum\\|class\\)\\([ \t]+\\(\\w\\|[$_]\\)*\\)\\)\\)\\(\\s +\\*+)?\\|[ \n\t;()]\\)" nil type)
+ ;; key words
+ ("[^_]\\<\\(return\\|goto\\|if\\|else\\|case\\|default\\|switch\\|break\\|continue\\|while\\|do\\|for\\|public\\|protected\\|private\\|interface\\|implementation\\|end\\|super\\|self\\)\\>[^_]"
+ 1 keyword))))
+ )
(hilit-set-mode-patterns
'perl-mode
(hilit-set-mode-patterns
'fortran-mode
'(("^[*Cc].*$" nil comment)
- ("[ \t]\\(call\\|program\\|subroutine\\|function\\|stop\\|return\\|end\\|include\\)[ \t\n]" nil include)
+ ("'[^'\n]*'" nil string)
("\\(^[ \t]*[0-9]+\\|[ \t]continue[ \t\n]\\|format\\)" nil define)
("[ \t]\\(do\\|do[ \t]*[0-9]+\\|go[ \t]*to[ \t]*[0-9]+\\|end[ \t]*do\\|if\\|else[ \t]*if\\|then\\|else\\|end[ \t]*if\\)[ \t\n(]" nil define)
+ ("[ \t]\\(call\\|program\\|subroutine\\|function\\|stop\\|return\\|end\\|include\\)[ \t\n]" nil include)
("[ \t]\\(parameter[\t\n ]*([^)]*)\\|data\\|save\\|common[ \t\n]*/[^/]*/\\)"
nil decl)
("^ ." nil type)
("implicit[ \t]*none" nil decl)
("\\([ \t]\\|implicit[ \t]*\\)\\(dimension\\|integer\\|real\\|double[ \t]*precision\\|character\\|logical\\|complex\\|double[ \t]*complex\\)\\([*][0-9]*\\|[ \t\n]\\)" nil keyword)
- ("'[^'\n]*'" nil string)
- ))
+ )
+ nil 'case-insensitive)
(hilit-set-mode-patterns
'(m2-mode modula-2-mode)
(hilit-string-find ?\\ string)
("^[ \t]*PROCEDURE[ \t]+\\w+[^ \t(;]*" nil defun)
("\\<\\(RECORD\\|ARRAY\\|OF\\|POINTER\\|TO\\|BEGIN\\|END\\|FOR\\|IF\\|THEN\\|ELSE\\|ELSIF\\|CASE\\|WHILE\\|DO\\|MODULE\\|FROM\\|RETURN\\|IMPORT\\|EXPORT\\|VAR\\|LOOP\\|UNTIL\\|\\DEFINITION\\|IMPLEMENTATION\\|AND\\|OR\\|NOT\\|CONST\\|TYPE\\|QUALIFIED\\)\\>" nil keyword)
- ))
+ )
+ nil 'case-insensitive)
(hilit-set-mode-patterns 'prolog-mode
'(("/\\*" "\\*/" comment)
;; various declarations/definitions
("\\\\\\(setlength\\|settowidth\\|addtolength\\|setcounter\\|addtocounter\\)" nil define)
- ("\\\\\\(\\|title\\|author\\|date\\|thanks\\){" "}" define)
+ ("\\\\\\(title\\|author\\|date\\|thanks\\){" "}" define)
("\\\\documentstyle\\(\\[.*\\]\\)?{" "}" decl)
("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\){" "}" decl)
("\\\\\\(bf\\|em\\|it\\|rm\\|sf\\|sl\\|ss\\|tt\\)\\b" nil decl)
;; label-like things
- ("\\\\item\\[" "\\]" label)
- ("\\\\item\\b" nil label)
- ("\\\\caption\\(\\[.*\\]\\)?{" "}" label)
-
+ ("\\\\item\\(\\[[^]]*\\]\\)?" nil label)
+ ("\\\\caption\\(\\[[^]]*\\]\\)?{" "}" label)
+
+ ;; formulas
+ ("[^\\]\\\\(" "\\\\)" formula) ; \( \)
+ ("[^\\]\\\\\\[" "\\\\\\]" formula) ; \[ \]
+ ("[^\\$]\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 1 formula) ; '$...$' or '$$...$$'
+
;; things that bring in external files
("\\\\\\(include\\|input\\|bibliography\\){" "}" include)
- ;; "wysiwyg" emphasis
- ("{\\\\\\(em\\|it\\|sl\\)" "}" italic)
- ("{\\\\bf" "}" bold)
+ ;; "wysiwyg" emphasis -- these don't work with nested expressions
+ ;; ("{\\\\\\(em\\|it\\|sl\\)" "}" italic)
+ ;; ("{\\\\bf" "}" bold)
("``" "''" string)
(hilit-set-mode-patterns
'compilation-mode
- '(("^[^ \t]*:[0-9]+:.*$" nil error)
- ("^[^ \t]*:[0-9]+: warning:.*$" nil warning)))
+ '(
+ ("^[-_.\"A-Za-z0-9]+\\(:\\|, line \\)[0-9]+: warning:.*$" nil warning)
+ ("^[-_.\"A-Za-z0-9]+\\(:\\|, line \\)[0-9]+:.*$" nil error)
+ ))
(hilit-set-mode-patterns
'makefile-mode
'(("^#.*$" nil comment)
("[^$]#.*$" nil comment)
;; rules
- ("^%.*$" nil rule)
+ ("^[^ \t\n]*%[^ \t\n]*[ \t]*::?[ \t]*[^ \t\n]*[ \t]*\\(#.*\\)?$" nil rule)
("^[.][A-Za-z][A-Za-z]?\..*$" nil rule)
;; variable definition
- ("^[_A-Za-z0-9]+ *\+?=" nil define)
- ("\\( \\|:=\\)[_A-Za-z0-9]+ *\\+=" nil define)
+ ("^[_A-Za-z0-9]+[ \t]*\+?=" nil define)
+ ("\\( \\|:=\\)[_A-Za-z0-9]+[ \t]*\\+=" nil define)
;; variable references
- ("\$[_A-Za-z0-9]" nil type)
- ("\${[_A-Za-z0-9]+}" nil type)
- ("\$\([_A-Za-z0-9]+\)" nil type)
+ ("\\$\\([^ \t\n{(]\\|[{(]@?[_A-Za-z0-9:.,%/=]+[)}]\\)" nil keyword)
+ ("^[A-Za-z0-9.,/_-]+[ \t]*:.*$" nil defun)
("^include " nil include)))
(let* ((header-patterns '(("^Subject:.*$" nil msg-subject)
("^From:.*$" nil msg-from)
("^--text follows this line--$" nil msg-separator)
("^[A-Za-z][A-Za-z0-9-]+:" nil msg-header)))
- (body-patterns '(("^\\(In article\\|[ \t]*\\w*[]>}|]\\).*$"
+ (body-patterns '(("^\\(In article\\|[ \t]*\\w*[]<>}|]\\).*$"
nil msg-quote)))
(message-patterns (append header-patterns body-patterns)))
(hilit-set-mode-patterns 'msg-header header-patterns)
(hilit-set-mode-patterns 'msg-body body-patterns)
- (hilit-set-mode-patterns
- '(vm-mode text-mode mail-mode rmail-mode gnus-article-mode news-reply-mode)
- message-patterns
- 'hilit-rehighlight-message))
+ (hilit-set-mode-patterns '(vm-mode text-mode mail-mode rmail-mode
+ gnus-article-mode news-reply-mode mh-show-mode)
+ message-patterns
+ 'hilit-rehighlight-message))
(hilit-set-mode-patterns
'gnus-group-mode
- '(("^U.*$" nil gnus-group-unsubscribed)
- ("^ +[01]?[0-9]:.*$" nil gnus-group-empty)
+ '(("^ U.*$" nil gnus-group-unsubscribed)
+ ("^\\*? +[01]?[0-9]:.*$" nil gnus-group-empty)
("^ +[2-9][0-9]:.*$" nil gnus-group-full)
("^ +[0-9][0-9][0-9]+:.*$" nil gnus-group-overflowing)))
-(hilit-set-mode-patterns
- 'gnus-summary-mode
- '(("^D +[0-9]+: \\[.*$" nil summary-seen)
- ("^K +[0-9]+: \\[.*$" nil summary-killed)
- ("^X +[0-9]+: \\[.*$" nil summary-Xed)
- ("^- +[0-9]+: \\[.*$" nil summary-unread)
- ("^. +[0-9]+:\\+\\[.*$" nil summary-current)
- ("^ +[0-9]+: \\[.*$" nil summary-new)
- ))
-
(hilit-set-mode-patterns
'vm-summary-mode
'(("^ .*$" nil summary-seen)
("^ N.*$" nil summary-new)))
+;;; this will match only comments w/ an even (zero is even) number of quotes...
+;;; which is still inadequate because it matches comments in multi-line strings
+;;; how anal do you want to get about never highlighting comments in strings?
+;;; I could twiddle with this forever and still it wouldn't be perfect.
+;;; (";\\([^\"\n]*\"[^\"\n]*\"\\)*[^\"\n]*$" nil comment)
+
(hilit-set-mode-patterns
- '(emacs-lisp-mode lisp-mode)
+ '(emacs-lisp-mode lisp-interaction-mode)
'(
(";.*" nil comment)
-;;; ("^;.*$" nil comment)
-;;; ("\\s ;+[ ;].*$" nil comment)
+
+;;; This almost works...but I think I'll stick with the parser function
+;;;("[^?]\\(\"\\(\"\\||\\([^\"]+\\|[\\]\\([\\][\\]\\)*\"\\)*\"\\)\\)" 1 string)
(hilit-string-find ?\\ string)
- ("^\\s *(def\\(un\\|macro\\|advice\\|subst\\)\\s " "\\()\\|nil\\)" defun)
+
+ ("^\\s *(def\\(un\\|macro\\|advice\\|alias\\|subst\\)[ \t\n]"
+ "\\()\\|nil\\)" defun)
("^\\s *(defvar\\s +\\S +" nil decl)
("^\\s *(defconst\\s +\\S +" nil define)
("^\\s *(\\(provide\\|require\\|\\(auto\\)?load\\).*$" nil include)
+ ("\\s *\\&\\(rest\\|optional\\)\\s *" nil keyword)
+ ("(\\(let\\*?\\|cond\\|if\\|or\\|and\\|map\\(car\\|concat\\)\\|prog[n1*]?\\|while\\|lambda\\|function\\|set\\([qf]\\|car\\|cdr\\)?\\|nconc\\|eval-when-compile\\|condition-case\\|unwind-protect\\|catch\\|throw\\|error\\)[ \t\n]" 1 keyword)
+ ))
+
+(hilit-set-mode-patterns
+ '(lisp-mode ilisp-mode)
+ '(
+ (";.*" nil comment)
+ ("#|" "|#" comment)
+;;; This almost works...but I think I'll stick with the parser function
+;;;("[^?]\\(\"\\(\"\\||\\([^\"]+\\|[\\]\\([\\][\\]\\)*\"\\)*\"\\)\\)" 1 string)
+ (hilit-string-find ?\\ string)
+
+ ;; this is waaaaaaaay too slow
+ ;; ("^\\s *(def\\(un\\|macro\\|advice\\|alias\\|method\\|subst\\)\\s \\S +[ \t\n]+\\(nil\\|(\\(([^()]*)\\|[^()]+\\)*)\\)" nil defun)
+ ("^\\s *(def\\(un\\|macro\\|advice\\|subst\\|method\\)\\s " "\\()\\|nil\\)" defun)
+
+ ("^\\s *(\\(def\\(var\\|type\\|parameter\\)\\|declare\\)\\s +\\S +" nil decl)
+ ("^\\s *(def\\(const\\(ant\\)?\\|class\\|struct\\)\\s \\S +[ \t\n]+" nil define)
+ ("^\\s *(\\(provide\\|require\\|\\(auto\\)?load\\).*$" nil include)
+ ("[ \t]\\&\\(key\\|rest\\|optional\\|aux\\)\\s *" nil keyword)
+ ("(\\(let\\*?\\|locally\\|cond\\|if\\*?\\|or\\|and\\|map\\(car\\|c[ao]n\\)?\\|prog[nv1*]?\\|while\\|when\\|unless\\|do\\(\\*\\|list\\|times\\)\\|list\\|lambda\\|function\\|values\\|set\\([qf]\\|car\\|cdr\\)?\\|rplac[ad]\\|nconc\\|block\\|go\\|return\\(-from\\)?\\|[ec]?\\(type\\)?case\\|multiple-value-\\(bind\\|setq\\|list\\|call\\|prog1\\)\\|unwind-protect\\|handler-case\\|catch\\|throw\\|eval-when\\(-compile\\)?\\)[ \t\n]" 1 keyword)
))
("{\\\\bf\\([^}]+\\)}" nil keyword)
("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" nil defun)
("\\\\\\(begin\\|end\\){\\([A-Za-z0-9\\*]+\\)}" nil defun)
-; ("[^\\\\]\\$\\([^$]*\\)\\$" nil string)
+ ;; ("[^\\\\]\\$\\([^$]*\\)\\$" nil string)
("\\$\\([^$]*\\)\\$" nil string)
))
("^\\.[ST]H.*$" nil defun)
;; ("^[^\\.].*\"[^\\\"]*\\(\\\\\\(.\\)[^\\\"]*\\)*\"" nil string)
("\"" "[^\\]\"" string)
- ("^\\.[A-Za-z12\\\\].*$" nil define)
+ ("^\\.[A-Z12\\\\].*$" nil define)
("\\([\\\][^ ]*\\)" nil keyword)
- ("^\\.[a-zA-Z].*$" nil keyword)))
+ ("^\\.[A-Z].*$" nil keyword))
+ nil 'case-insensitive)
(hilit-set-mode-patterns
'texinfo-mode
'(("^\\(@c\\|@comment\\)\\>.*$" nil comment)
("@\\(emph\\|strong\\|b\\|i\\){[^}]+}" nil comment)
-; seems broken
-; ("\\$[^$]*\\$" nil string)
+;; seems broken
+;; ("\\$[^$]*\\$" nil string)
("@\\(file\\|kbd\\|key\\){[^}]+}" nil string)
("^\\*.*$" nil defun)
("@\\(if\\w+\\|format\\|item\\)\\b.*$" nil defun)
("- \\(Variable\\|Function\\|Macro\\|Command\\|Special Form\\|User Option\\):.*$"
nil jargon-keyword))) ; lisp manual
+(hilit-set-mode-patterns
+ 'calendar-mode
+ '(("[A-Z][a-z]+ [0-9]+" nil define) ; month and year
+ ("S M Tu W Th F S" nil label))) ; week days
+
+(hilit-set-mode-patterns
+ 'asm-mode
+ '(("/\\*" "\\*/" comment)
+ ("^#[ \t]*\\(undef\\|define\\).*$" "[^\\]$" define)
+ ("^#.*$" nil include)
+ ;; labels
+ ("^.+:" nil defun)
+ ;; assembler directives
+ ("^[ \t]*\\..*$" nil decl)
+ ;; register names
+ ("\\$[a-z0-9]+" nil string)
+ ;; mnemonics
+ ("^[ \t]*[a-z]+" nil struct)))
+
+(hilit-set-mode-patterns
+ 'pascal-mode
+ '(("(\\*" "\\*)" comment)
+ ("{" "}" comment)
+ ;; Doesn't work when there are strings in comments....
+ ;; ("'[^']*'" nil string)
+ ("^#.*$" nil include)
+ ("^[ \t]*\\(procedure\\|function\\)[ \t]+\\w+[^ \t(;]*" nil defun)
+ ("\\<\\(program\\|begin\\|end\\)\\>" nil defun)
+ ("\\<\\(external\\|forward\\)\\>" nil include)
+ ("\\<\\(label\\|const\\|type\\|var\\)\\>" nil define)
+ ("\\<\\(record\\|array\\|file\\)\\>" nil type)
+ ("\\<\\(of\\|to\\|for\\|if\\|then\\|else\\|case\\|while\\|do\\|until\\|and\\|or\\|not\\|with\\|repeat\\)\\>" nil keyword)
+ )
+ nil 'case-insensitive)
+
+(hilit-set-mode-patterns
+ 'icon-mode
+ '(("#.*$" nil comment)
+ ("\"[^\\\"]*\\(\\\\.[^\\\"]*\\)*\"" nil string)
+ ;; charsets: these do not work because of a conflict with strings
+ ;; ("'[^\\']*\\(\\\\.[^\\']*\\)*'" nil string)
+ ("^[ \t]*procedure[ \t]+\\w+[ \t]*(" ")" defun)
+ ("^[ \t]*record.*(" ")" include)
+ ("^[ \t]*\\(global\\|link\\)[ \t\n]+[A-Za-z_0-9]+\\([ \t\n]*,[ \t\n]*[A-Za-z_0-9]+\\)*" nil include)
+ ("^[ \t]*\\(local\\|static\\)[ \t\n]+[A-Za-z_0-9]+\\([ \t\n]*,[ \t\n]*[A-Za-z_0-9]+\\)*" nil decl)
+ ("\\<\\(initial\\|end\\)\\>" nil glob-struct)
+ ("\\<\\(while\\|until\\|return\\|every\\|if\\|then\\|else\\|to\\|case\\|of\\|suspend\\|create\\|do\\|repeat\\|break\\)\\>" nil keyword)
+ ))
+
+;; as you can see, I had two similar problems for Pascal and Icon. In
+;; Pascal, strings are delimited with ' and an embedded quote is doubled,
+;; thus string syntax would be extremely simple. However, if a string
+;; occurs within a comment, the following text is considered a string.
+;;
+;; In Icon, strings are similar to C ones, but there are also charsets,
+;; delimited with simple quotes. I could not manage to use both regexps at
+;; the same time.
+
+;; The problem I have with my patterns for Icon is that this language has a
+;; string similar constant to the C one (but a string can be cut on several
+;; lines, if terminated by a dash and continued with initial blanks, like
+;; this:
+;; "This is a somewhat long -
+;; string, written on three -
+;; succesive lines"
+;; in order to insert a double quote in a string, you have to escape it
+;; with a \), bu also a character set constant (named a charset), which
+;; uses single quotes instead of double ones. It would seem intuitive to
+;; highlight both constants in the same way.
+
+
(provide 'hilit19)
;;; hilit19 ends here.