X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/ed6bdcdd65a9c98b1ac60a061f66a17fd068421a..ddff3d800e7820d6d2d71f270afa90e5cc29ac71:/lisp/hilit19.el diff --git a/lisp/hilit19.el b/lisp/hilit19.el index 4813033bf5..cd19214380 100644 --- a/lisp/hilit19.el +++ b/lisp/hilit19.el @@ -1,23 +1,28 @@ -;; hilit19.el (Release 2.19) -- customizable highlighting for Emacs19. +;;; hilit19.el --- customizable highlighting for Emacs19 + ;; Copyright (c) 1993, 1994 Free Software Foundation, Inc. -;; -;; Author: Jonathan Stigelman + +;; Author: Jonathan Stigelman +;; Maintainer: FSF +;; (actually no longer maintained) ;; 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, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. ;;; Commentary: @@ -26,10 +31,9 @@ ;; 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: +;; WHERE TO GET THE LATEST VERSIONS OF HILIT19.EL (beta and release): ;; -;; netcom.com:/pub/stig/src/{Beta,Release}/hilit19.el.gz +;; http://hackvan.com/pub/stig/src/elisp/ ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; @@ -42,7 +46,7 @@ ;; hilit19.el,v 2.19 1993/09/08 18:44:10 stig Release ;; ;; LCD Archive Entry: -;; hilit19|Jonathan Stigelman|Stig@netcom.com| +;; 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| ;; @@ -146,7 +150,7 @@ ;; ;; * Moved hilit-wysiwyg-replace here from my version of man.el, this is not ;; a bug. The bug is that I don't have a reverse operation yet...just a -;; stub Wysiwyg-anything really belongs in a package of it's own. +;; stub Wysiwyg-anything really belongs in a package of its own. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; @@ -201,7 +205,7 @@ ;; 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 +;; the pattern matcher now starts its searches from the end of the most ;; recently highlighted region (which is not necessarily the end of the most ;; recently matched regex). ;; @@ -262,9 +266,9 @@ ;; 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 +;; (hilit-lookup-face-create) incorporated patch which improves its behavior ;; with more than one frame... Still can't have bold on the same face in two -;; differrent fonts sizes at the same time... +;; different fonts sizes at the same time... ;; ;; Revision 2.2 1993/07/27 02:02:59 stig ;; vastly improved the makefile patterns @@ -284,7 +288,7 @@ ;; 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. +;; message header patterns to message bodies in mail-mode and its kin. ;; hilit-set-mode-patterns now takes a list of modes and an optional parse-fn ;; @@ -401,12 +405,12 @@ your init file.") (eval-when-compile (require 'reporter)) ; no compilation gripes (defun hilit-submit-feedback () - "Submit feedback on hilit19 to the author: Stig@netcom.com" + "Submit feedback on hilit19 to hilit@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 " + "Jonathan Stigelman " "hilit19.el (Release 2.19)" (and (y-or-n-p "Do you need to include a dump hilit variables? ") (append @@ -438,11 +442,11 @@ your init file.") " [ ] 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. (output of 'diff -uw old.el new.el' or 'diff -cw')\n" - " [ ] a SERIOUS AND REPRODUCABLE BUG that is not an EMACS bug\n" + " [ ] a SERIOUS AND REPRODUCIBLE BUG that is not an EMACS bug\n" " - I *swear* that it's not already mentioned in the KNOWN BUGS\n" - " - I HAVE CHECKED netcom.com:/pub/stig/src/Beta/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" - " >> I HAVE ALSO CHECKED netcom.com:/pub/stig/src/Beta/hl319.el.gz\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, I *know* you're busy but...\n")))) @@ -454,7 +458,7 @@ your init file.") (defconst hilit-default-face-table '( - ;; used for C/C++ and elisp and perl + ;; used for C/C++ and Emacs Lisp and perl (comment firebrick-italic moccasin italic) (include purple Plum1 bold-italic) (define ForestGreen-bold green bold) @@ -470,7 +474,7 @@ your init file.") (glob-struct magenta Plum1 default-bold-underline) (named-param DarkGoldenrod Goldenrod underline) - ;; and anotherone for LaTeX + ;; and another one for LaTeX (crossref DarkGoldenrod Goldenrod underline) (formula Goldenrod DarkGoldenrod underline) @@ -559,7 +563,7 @@ See the documentation for hilit-lookup-face-create for names of valid faces." (defun hilit-lookup-face-create (face &optional force) "Get a FACE, or create it if it doesn't exist. In order for it to -properly create the face, the followwing naming convention must be used: +properly create the face, the following naming convention must be used: [reverse-](fgcolor[/bgcolor])[-bold][-italic][-underline] Example: (hilit-lookup-face-create 'comment-face) might create and return 'red @@ -783,7 +787,9 @@ non-nil." "Highlight a buffer containing a news article or mail message." (save-excursion (goto-char (point-min)) - (re-search-forward "^$" nil 'noerr) + ;; find separation between headers and body (either a blank line or + ;; the message separator line in mail-mode) + (re-search-forward "^\\(\\|--text follows this line--\\)$" nil 'noerr) (hilit-unhighlight-region (point-min) (point-max) quietly) (hilit-highlight-region (point-min) (point) 'msg-header quietly) (hilit-highlight-region (point) (point-max) 'msg-body quietly))) @@ -815,9 +821,11 @@ non-nil." (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 @@ -892,7 +900,7 @@ the entire buffer is forced." ;; ; For the Jargon-impaired, WYSIWYG === What You See Is What You Get ;; ; Sure, it sucks to type. Oh, well. ;; (defun hilit-wysiwyg-replace () -;; "Replace overstruck text with normal text that's been overlayed with the +;; "Replace overstruck text with normal text that's been overlaid with the ;; appropriate text attribute. Suitable for a find-file hook." ;; (save-excursion ;; (goto-char (point-min)) @@ -916,7 +924,7 @@ the entire buffer is forced." ;; (message "*sigh* hilit-wysiwyg-write-repair not implemented yet") ;; ;; For efficiency, this hook should copy the current buffer to a scratch -;; buffer and do it's overstriking there. Overlays are not copied, so it'll +;; buffer and do its overstriking there. Overlays are not copied, so it'll ;; be necessary to hop back and forth. This is OK since you're not fiddling ;; with--making or deleting--any overlays. THEN write the new buffer, ;; delete it, and RETURN T. << important @@ -970,35 +978,12 @@ the entire buffer is forced." vm-preview-message-hook vm-show-message-hook - gnus-article-prepare-hook - gnus-summary-prepare-hook - gnus-group-prepare-hook - rmail-show-message-hook mail-setup-hook mh-show-mode-hook dired-after-readin-hook )) - - ;; rehighlight only visible part of 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)))) ) (error (message "Error loading highlight hooks: %s" c) (ding) (sit-for 1)))) @@ -1131,7 +1116,24 @@ number of backslashes." ("[ \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))))) + 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 @@ -1248,7 +1250,7 @@ number of backslashes." ;; formulas ("[^\\]\\\\(" "\\\\)" formula) ; \( \) ("[^\\]\\\\\\[" "\\\\\\]" formula) ; \[ \] - ("[^\\$]\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 1 formula) ; '$...$' or '$$...$$' + ("[^\\$]\\(\\$\\(\\$[^$]*\\$\\|[^$]*\\)\\$\\)" 1 formula) ; '$...$' or '$$...$$' ;; things that bring in external files ("\\\\\\(include\\|input\\|bibliography\\){" "}" include) @@ -1309,21 +1311,11 @@ number of backslashes." (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) @@ -1371,10 +1363,10 @@ number of backslashes." ("^\\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 *(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\\)\\|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) + ("(\\(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) )) @@ -1450,10 +1442,21 @@ number of backslashes." (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 - ("[0-9]+\\*" nil defun) ; holidays - ("[0-9]+\\+" nil comment) ; diary days - )) + ("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 @@ -1500,7 +1503,7 @@ number of backslashes." ;; this: ;; "This is a somewhat long - ;; string, written on three - -;; succesive lines" +;; successive 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 @@ -1510,10 +1513,3 @@ number of backslashes." (provide 'hilit19) ;;; hilit19 ends here. - - -;; __________________________________________________________________________ -;; Stig@netcom.com netcom.com:/pub/stig/00-PGP-KEY -;; It's hard to be cutting-edge at your own pace... 32 DF B9 19 AE 28 D1 7A -;; Bullet-proof code cannot stand up to teflon bugs. A3 9D 0B 1A 33 13 4D 7F -