Mercurial > emacs
changeset 83285:865f9b91fdbe
Merged from miles@gnu.org--gnu-2005 (patch 56-58, 232-239)
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-232
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-233
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-234
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-235
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-236
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-237
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-238
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-239
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-56
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-57
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-58
Collapse feature addition/removal within single ChangeLog entry
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-325
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Fri, 08 Apr 2005 16:25:22 +0000 |
parents | 360860a0006f (current diff) 2d12aad1548c (diff) |
children | 9deb6323655c |
files | admin/FOR-RELEASE lisp/ChangeLog lisp/fast-lock.el lisp/lazy-lock.el lisp/progmodes/tcl.el lisp/simple.el lisp/startup.el lisp/term/xterm.el lispref/ChangeLog man/ChangeLog man/frames.texi src/emacs.c src/xdisp.c |
diffstat | 63 files changed, 2556 insertions(+), 2251 deletions(-) [+] |
line wrap: on
line diff
--- a/admin/FOR-RELEASE Mon Apr 04 16:43:15 2005 +0000 +++ b/admin/FOR-RELEASE Fri Apr 08 16:25:22 2005 +0000 @@ -182,7 +182,7 @@ man/rmail.texi Chong Yidong man/screen.texi "Luc Teirlinck" Chong Yidong man/search.texi "Luc Teirlinck" Chong Yidong -man/sending.texi Chong Yidong +man/sending.texi Chong Yidong "Luc Teirlinck" man/text.texi "Luc Teirlinck" Chong Yidong man/trouble.texi Chong Yidong man/windows.texi "Luc Teirlinck" Chong Yidong @@ -263,12 +263,12 @@ etc/TUTORIAL rms etc/TUTORIAL.bg Ognyan Kulev <ogi@fmi.uni-sofia.bg> etc/TUTORIAL.cn -etc/TUTORIAL.cs -etc/TUTORIAL.de +etc/TUTORIAL.cs Pavel Janík <Pavel@Janik.cz> +etc/TUTORIAL.de Werner LEMBERG <wl@gnu.org> etc/TUTORIAL.es Marcelo Toledo -etc/TUTORIAL.fr -etc/TUTORIAL.it -etc/TUTORIAL.ja +etc/TUTORIAL.fr Thien-Thi Nguyen +etc/TUTORIAL.it Thien-Thi Nguyen +etc/TUTORIAL.ja Kenichi Handa <handa@m17n.org> etc/TUTORIAL.ko etc/TUTORIAL.nl Lute Kamstra etc/TUTORIAL.pl @@ -276,7 +276,7 @@ etc/TUTORIAL.ro etc/TUTORIAL.ru etc/TUTORIAL.sk -etc/TUTORIAL.sl +etc/TUTORIAL.sl Primoz PETERLIN <primoz.peterlin@biofiz.mf.uni-lj.si> etc/TUTORIAL.sv Mats Lidell <matsl@contactor.se> etc/TUTORIAL.th etc/TUTORIAL.zh
--- a/etc/ChangeLog Mon Apr 04 16:43:15 2005 +0000 +++ b/etc/ChangeLog Fri Apr 08 16:25:22 2005 +0000 @@ -1,3 +1,24 @@ +2005-04-08 Kenichi Handa <handa@m17n.org> + + * TUTORIAL.ja: Updated header, contents synchronized with + TUTORIAL (CVS-1.61). + +2005-04-06 Pavel Jan,Am(Bk <Pavel@Janik.cz> + + * TUTORIAL.cs: Updated header. + +2005-04-05 Werner Lemberg <wl@gnu.org> + + * TUTORIAL.de: Updated header. + +2005-04-05 Marcelo Toledo <marcelo@marcelotoledo.org> + + * TUTORIAL.translators: Added the field Maintainer. + +2005-04-04 Thien-Thi Nguyen <ttn@gnu.org> + + * TUTORIAL.it: Move "copying conditions at end" sentence after title. + 2005-04-04 Thien-Thi Nguyen <ttn@gnu.org> * TUTORIAL.ja: Update text before first period. @@ -21,10 +42,10 @@ * TUTORIAL.bg: Fix title line; Applied TUTORIAL changes in revision 1.59, "Emacs" is not transliterated to cyrillic anymore; - Minor fixes; by Ognyan Kulev <ogi@fmi.uni-sofia.bg>. + Minor fixes; patch by Ognyan Kulev <ogi@fmi.uni-sofia.bg>. * TUTORIAL.sv: Sync some other changes with the TUTORIAL version - 1.61 in CVS by Mats Lidell <matsl@contactor.se>. + 1.61 in CVS patch by Mats Lidell <matsl@contactor.se>. 2005-04-01 Lute Kamstra <lute@gnu.org>
--- a/etc/NEWS Mon Apr 04 16:43:15 2005 +0000 +++ b/etc/NEWS Fri Apr 08 16:25:22 2005 +0000 @@ -118,6 +118,8 @@ M-t (transpose-words) M-q (fill-paragraph) +** fast-lock.el and lazy-lock.el are obsolete. Use jit-lock.el instead. + ** iso-acc.el is now obsolete. Use one of the latin input methods instead. --- @@ -350,7 +352,7 @@ ** Telnet now prompts you for a port number with C-u M-x telnet. +++ -** New command line option -Q. +** New command line option -Q or --bare-bones. This is like using -q --no-site-file, but in addition it also disables the menu-bar, the tool-bar, the scroll-bars, tool tips, the blinking
--- a/etc/TUTORIAL.cs Mon Apr 04 16:43:15 2005 +0000 +++ b/etc/TUTORIAL.cs Fri Apr 08 16:25:22 2005 +0000 @@ -1,5 +1,5 @@ -tutoriál k Emacsu. -Copyright (c) 1985 Free Software Foundation, Inc; podmínky viz na konci. +Tutoriál k Emacsu. Podmínky viz na konci. +Copyright (c) 1985, 1996, 1998, 2001, 2002, 2005 Free Software Foundation. Do èe¹tiny pøelo¾il Milan Zamazal <pdm@zamazal.org>. Máte pøed sebou tutoriál k Emacsu.
--- a/etc/TUTORIAL.de Mon Apr 04 16:43:15 2005 +0000 +++ b/etc/TUTORIAL.de Fri Apr 08 16:25:22 2005 +0000 @@ -1,4 +1,5 @@ -Einführung in Emacs. (c) 2002, 2003 Free Software Foundation, Inc. +Einführung in Emacs. Siehe Dateiende für Vervielfältigungsbedingungen. +(c) 2002, 2003, 2005 Free Software Foundation, Inc. Emacs-Befehle beinhalten im allgemeinen die CONTROL-Taste (manchmal auch als CTRL, CTL oder STRG beschriftet) sowie die META-Taste (auch
--- a/etc/TUTORIAL.it Mon Apr 04 16:43:15 2005 +0000 +++ b/etc/TUTORIAL.it Fri Apr 08 16:25:22 2005 +0000 @@ -1,5 +1,5 @@ -Esercitazione di Emacs. Copyright (c) 2003 Free Software Foundation, Inc. -Condizioni d'uso alla fine del file. +Esercitazione di Emacs. Condizioni d'uso alla fine del file. +Copyright (c) 2003 Free Software Foundation, Inc. I comandi di Emacs comportano generalmente l'uso del tasto CONTROL (a volte indicato con CTRL o CTL) o del tasto META (a volte indicato con EDIT @@ -817,7 +817,7 @@ testo e osserva come Emacs interrompe le righe a 20 caratteri. Infine torna di nuovo a un margine di 70 caratteri con C-x f. -Se si modifica il testo all'interno di un paragrafo la modalità +Se si modifica il testo all'interno di un paragrafo la modalità "Auto Fill" non lo risistema. Per risistemare i margini di un paragrafo
--- a/etc/TUTORIAL.ja Mon Apr 04 16:43:15 2005 +0000 +++ b/etc/TUTORIAL.ja Fri Apr 08 16:25:22 2005 +0000 @@ -1,5 +1,5 @@ -Emacs $BF~Lg%,%$%I(B. -Copyright (c) 1985, 1996, 1998, 2001, 2002 Free Software Foundation. +Emacs $BF~Lg%,%$%I(B. $BK\%U%!%$%k$NCx:n8"$K$D$$$F$O:G8e$r8fMw2<$5$$!#(B +Copyright (c) 1985, 1996, 1998, 2001, 2002, 2005 Free Software Foundation. Emacs $B$N%3%^%s%I$rF~NO$9$k$K$O!"0lHL$K%3%s%H%m!<%k%-!<!J%-!<%H%C%W$K(B CONTROL $B$H$+(B CTRL $B$H$+(B CTL $B$H=q$$$F$"$k!K$d%a%?%-!<!J%-!<%H%C%W$K(B META @@ -372,7 +372,7 @@ $B>C5n$7$?J8>O$rI|3h$5$;$kA`:n$r:FF~!J(Byanking$B!K$H8F$S$^$9!#>C$7$?J8>O$O!"(B $B85$HF1$8>l=j$K$G$b85$H$O0c$&>l=j$K$G$b!"$5$i$K$OJL$N%U%!%$%k$K$b:FF~$G(B -$B$-$^$9!#$^$?!"2?EY$b:FF~$7$FJ8>O$N%3%T!<$rJ#?t:n$k$3$H$b$G$-$^$9!#(B +$B$-$^$9!#$^$?!"2?EY$b:FF~$9$k$3$H$GJ8>O$N%3%T!<$rJ#?t:n$k$3$H$b$G$-$^$9!#(B $B:FF~$N$?$a$N%3%^%s%I$O(B C-y $B$G$9!#$3$l$O!":G8e$K>C5n$7$?J8>O$r8=:_%+!<(B $B%=%k$,$"$k0LCV$K:FF~$7$^$9!#(B @@ -592,7 +592,7 @@ $B;H$$$^$9!#$=$l$K$O!"0J2<$N#2$D$N<oN`$,$"$j$^$9!#(B C-x $BJ8;z$K$h$k3HD%!#B3$1$F0lJ8;z$rF~NO$7$^$9!#(B - ESC x $BL>A0$K$h$k3HD%!#B3$1$F%3%^%s%I$NL>A0$rF~NO$7$^$9!#(B + M-x $BL>A0$K$h$k3HD%!#B3$1$F%3%^%s%I$NL>A0$rF~NO$7$^$9!#(B $B$3$l$i$O!"0lHLE*$K$OJXMx$@$1$l$I$b!"$3$l$^$G8+$F$-$?$b$N$[$I$OIQHK$KMQ(B $B$$$i$l$J$$%3%^%s%I$G$9!#(BC-x C-f $B!J%U%!%$%k$r3+$/!K$d(B C-x C-s$B!J%U%!%$%k(B @@ -1027,7 +1027,7 @@ $B!v$3$NK]LuHG$K$D$$$F$N<U<-(B ========================== -$B$3$NJ8=q$O(B Emacs Ver.21 $BIUB0$N1Q8lHG$NF~Lg%,%$%I$rF|K\8l$KK]Lu$7$?$b$N(B +$B$3$NJ8=q$O(B Emacs Ver.22 $BIUB0$N1Q8lHG$NF~Lg%,%$%I$rF|K\8l$KK]Lu$7$?$b$N(B $B$G$9!#$=$N:]!"(BEmacs Ver. 20 $BImB0$NF|K\8lHGF~Lg%,%$%I$r%Y!<%9$K$7$^$7$?!#(B Emacs Ver. 20 $BImB0$NF|K\8lHGF~Lg%,%$%I$O!"(BMule $BIUB0$NF|K\8l%,%$%I$r;2(B $B9M$K$7$?$b$N$G!"$=$N85$O(B SANETO Takanori $B;a$,F|K\8l(B MicroEmacs(kemacs) @@ -1048,7 +1048,7 @@ This version of the tutorial, like GNU Emacs, is copyrighted, and comes with permission to distribute copies on certain conditions: -Copyright (c) 1985, 1996, 1998, 2001, 2002 Free Software Foundation +Copyright (c) 1985, 1996, 1998, 2001, 2002, 2005 Free Software Foundation Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the
--- a/etc/TUTORIAL.translators Mon Apr 04 16:43:15 2005 +0000 +++ b/etc/TUTORIAL.translators Fri Apr 08 16:25:22 2005 +0000 @@ -1,28 +1,89 @@ -This file contains the list of translators of the tutorial. +This file contains the list of translators and maintainers of the +tutorial. + +* TUTORIAL.bg: +Author: Ognyan Kulev <ogi@fmi.uni-sofia.bg> +Maintainer: Ognyan Kulev <ogi@fmi.uni-sofia.bg> + +* TUTORIAL.cn: +Author: Chao-Hong Liu <chliu@gnu.org> +Maintainer: Chao-Hong Liu <chliu@gnu.org> + +* TUTORIAL.cs: +Author: Milan Zamazal <pdm@zamazal.org> + Pavel JanÃk <Pavel@Janik.cz> +Maintainer: Milan Zamazal <pdm@zamazal.org> + Pavel JanÃk <Pavel@Janik.cz> + +* TUTORIAL.de: +Author: Werner Lemberg <wl@gnu.org> +Maintainer: Werner Lemberg <wl@gnu.org> + +* TUTORIAL.es: +Author: Rafael Sepúlveda <drs@gnulinux.org.mx> +Maintainer: Rafael Sepúlveda <drs@gnulinux.org.mx> + +* TUTORIAL.fr: +Author: Éric Jacoboni <jaco@teaser.fr> +Maintainer: Éric Jacoboni <jaco@teaser.fr> + +* TUTORIAL.it: +Author: Alfredo Finelli <alfredofnl@tiscali.it> + Italian GNU Translation Group <tp@lists.linux.it> +Maintainer: Alfredo Finelli <alfredofnl@tiscali.it> + Italian GNU Translation Group <tp@lists.linux.it> + +* TUTORIAL.ja: +Author: Kenichi Handa <handa@m17n.org> +Maintainer: Kenichi Handa <handa@m17n.org> + +* TUTORIAL.ko: +Author: Koaunghi Un <koaunghi@ling.cnu.ac.kr> +Maintainer: Maintainer needed. -TUTORIAL.bg: Ognyan Kulev <ogi@fmi.uni-sofia.bg> -TUTORIAL.cn: Chao-Hong Liu <chliu@gnu.org> -TUTORIAL.cs: Milan Zamazal <pdm@zamazal.org> - Pavel JanÃk <Pavel@Janik.cz> -TUTORIAL.de: Werner Lemberg <wl@gnu.org> -TUTORIAL.es: Rafael Sepúlveda <drs@gnulinux.org.mx> -TUTORIAL.fr: Éric Jacoboni <jaco@teaser.fr> -TUTORIAL.it: Alfredo Finelli <alfredofnl@tiscali.it> - Italian GNU Translation Group <tp@lists.linux.it> -TUTORIAL.ja: Kenichi Handa <handa@m17n.org> -TUTORIAL.ko: Koaunghi Un <koaunghi@ling.cnu.ac.kr> -TUTORIAL.nl: Pieter Schoenmakers <tiggr@tiggr.net> -TUTORIAL.pl: BeatÄ™ WierzchoÅ‚owskÄ… <beataw@orient.uw.edu.pl> - Janusz S. Bien <jsbien@mail.uw.edu.pl> -TUTORIAL.pt_BR: Marcelo Toledo <marcelo@marcelotoledo.org> -TUTORIAL.ro: Tudor Hulubei <tudor@gnu.org> -TUTORIAL.ru: Alex Ott <ottalex@narod.ru> -TUTORIAL.sk: Miroslav VaÅ¡ko <vasko@debian.cz> - Pavel JanÃk <Pavel@Janik.cz> -TUTORIAL.sl: Primož Peterlin <primoz.peterlin@biofiz.mf.uni-lj.si> -TUTORIAL.sv: Mats Lidell <matsl@contactor.se> -TUTORIAL.th: Virach Sornlertlamvanich <virach@nectec.or.th> -TUTORIAL.zh: Chao-Hong Liu <chliu@gnu.org> +* TUTORIAL.nl: +Author: Pieter Schoenmakers <tiggr@tiggr.net> +Maintainer: Pieter Schoenmakers <tiggr@tiggr.net> + +* TUTORIAL.pl: +Author: BeatÄ™ WierzchoÅ‚owskÄ… <beataw@orient.uw.edu.pl> + Janusz S. Bien <jsbien@mail.uw.edu.pl> +Maintainer: BeatÄ™ WierzchoÅ‚owskÄ… <beataw@orient.uw.edu.pl> + Janusz S. Bien <jsbien@mail.uw.edu.pl> + +* TUTORIAL.pt_BR: +Author: Marcelo Toledo <marcelo@marcelotoledo.org> +Maintainer: Marcelo Toledo <marcelo@marcelotoledo.org> + +* TUTORIAL.ro: +Author: Tudor Hulubei <tudor@gnu.org> +Maintainer: Maintainer needed. + +* TUTORIAL.ru: +Author: Alex Ott <ottalex@narod.ru> +Maintainer: Alex Ott <ottalex@narod.ru> + +* TUTORIAL.sk: +Author: Miroslav VaÅ¡ko <vasko@debian.cz> + Pavel JanÃk <Pavel@Janik.cz> +Maintainer: Pavel JanÃk <Pavel@Janik.cz> + +* TUTORIAL.sl: +Author: Primož Peterlin <primoz.peterlin@biofiz.mf.uni-lj.si> +Maintainer: Primož Peterlin <primoz.peterlin@biofiz.mf.uni-lj.si> + +* TUTORIAL.sv: +Author: Mats Lidell <matsl@contactor.se> +Maintainer: Mats Lidell <matsl@contactor.se> + +* TUTORIAL.th: +Author: Virach Sornlertlamvanich <virach@nectec.or.th> +Maintainer: Virach Sornlertlamvanich <virach@nectec.or.th> + +* TUTORIAL.zh: +Author: Chao-Hong Liu <chliu@gnu.org> +Maintainer: Chao-Hong Liu <chliu@gnu.org> + ;;; Local Variables: ;;; coding: utf-8
--- a/leim/ChangeLog Mon Apr 04 16:43:15 2005 +0000 +++ b/leim/ChangeLog Fri Apr 08 16:25:22 2005 +0000 @@ -1,3 +1,8 @@ +2005-04-06 Kenichi Handa <handa@m17n.org> + + * quail/sgml-input.el ("sgml"): Enable quail-completion by typing + TAB. + 2005-03-26 Kenichi Handa <handa@m17n.org> * quail/latin-ltx.el ("TeX"): Enable quail-completion by typing
--- a/leim/quail/sgml-input.el Mon Apr 04 16:43:15 2005 +0000 +++ b/leim/quail/sgml-input.el Fri Apr 08 16:25:22 2005 +0000 @@ -40,7 +40,8 @@ HTMLspecial and HTMLsymbol. E.g.: á -> á" - nil t nil nil nil nil nil nil nil nil t) + '(("\t" . quail-completion)) + t nil nil nil nil nil nil nil nil t) (quail-define-rules ("&Aacgr;" ?\Ά) ;; GREEK CAPITAL LETTER ALPHA WITH TONOS
--- a/lisp/ChangeLog Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/ChangeLog Fri Apr 08 16:25:22 2005 +0000 @@ -1,3 +1,137 @@ +2005-04-07 Luc Teirlinck <teirllm@auburn.edu> + + * ielm.el (ielm-prompt-read-only): Doc fix. + + * comint.el (comint-prompt-read-only): Doc fix. + +2005-04-07 Benjamin Rutt <brutt@bloomington.in.us> + + * ffap.el (ffap-pass-wildcards-to-dired): New user option to + ensure dired always handles wildcards passed to ffap. + (find-file-at-point): Use it. + (ffap-dired-wildcards): Doc fix. + +2005-04-07 Juri Linkov <juri@jurta.org> + + * simple.el (next-error-overlay-arrow-position): New defvar. + Put "=>" on its property `overlay-arrow-string'. Add it to + `overlay-arrow-variable-list'. + + * progmodes/compile.el (compilation-setup): + Set `next-error-overlay-arrow-position' to nil. Also set it to + nil in the local hook `kill-buffer-hook'. Make local variable + `overlay-arrow-string' and set it to "=>". + (compilation-goto-locus): Set BOL position to + `next-error-overlay-arrow-position' instead of + `overlay-arrow-position'. + + * info.el (Info-mode): Add `Info-kill-buffer' to `kill-buffer-hook' + locally instead of adding it to the global hook. + (Info-kill-buffer): Move up. + +2005-04-06 Dan Nicolaescu <dann@ics.uci.edu> + + * term/xterm.el (xterm-standard-colors): Update color values from + xterm-200. + +2005-04-06 Stefan Monnier <monnier@iro.umontreal.ca> + + * textmodes/tex-mode.el (tex-font-lock-keywords-2): Add \bfseries. + + * fast-lock.el: + * lazy-lock.el: Move them to the obsolete subdir. + +2005-04-06 JUAN-LEON Lahoz Garcia <juanleon1@gmail.com> + + * wdired.el (wdired-advise-functions, wdired-add-skip-in-replace) + (wdired-add-replace-advice): Remove. + (wdired-change-to-wdired-mode): Use query-replace-skip-read-only. + +2005-04-06 Kim F. Storm <storm@cua.dk> + + * startup.el (command-line): Add --bare-bones alias for -Q. + +2005-04-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * term/mac-win.el: Use create-fontset-from-mac-roman-font to + create the startup fontset if a font specification ends with + `mac-roman'. + +2005-04-06 Lute Kamstra <lute@gnu.org> + + * add-log.el (change-log-font-lock-keywords): Complete 2005-04-03 + change. + + * emacs-lisp/copyright.el (copyright-update-year): Replace the + right subexpression. Suggested by Jay Bingham <jay.bingham@hp.com>. + +2005-04-05 Lute Kamstra <lute@gnu.org> + + * generic.el (generic-mode-internal): Fix 2005-03-31 change. + (define-generic-mode): Ditto. Fix debug declaration. + + * generic-x.el (show-tabs-tab-face, show-tabs-space-face): + Put them in the generic-x group. + + * calendar/timeclock.el (timeclock): Doc fix. + + * generic.el (define-generic-mode): Don't use custom-current-group. + Document default :group value. + * emacs-lisp/easy-mmode.el (define-minor-mode): Ditto. + (define-global-minor-mode): Don't use custom-current-group. + +2005-04-05 Glenn Morris <gmorris@ast.cam.ac.uk> + + * startup.el (command-line-1): Display startup-echo-area-message + when fancy splash screen is in use. + + * progmodes/sh-script.el (sh-builtins) <bash>: Add `caller'. + (sh-escaped-newline): New face. + (sh-font-lock-keywords) <shell>: Improve regexp for escaped + newline, and use sh-escaped-newline face. + + * progmodes/tcl.el (tcl-escaped-newline): New face. + (tcl-builtin-list): New variable. + (tcl-set-font-lock-keywords): Add builtins, variables, and escaped + newlines. Fix keywords subexpression number. + +2005-04-05 Carsten Dominik <dominik@science.uva.nl> + + * textmodes/org.el (org-diary-default-entry): Fix call to + `add-to-diary-entry'. + +2005-04-05 Kim F. Storm <storm@cua.dk> + + * ediff-init.el: Use (featurep 'xemacs). + +2005-04-05 David Ponce <david@dponce.com> + + * cus-edit.el (face): Derive from symbol widget. Display sample + of the current face on the fly. + (widget-face-sample-face-get, widget-face-notify): New functions. + (widget-face-value-create): Remove. + + * wid-edit.el (widget-field-end): Temporarily remove field + narrowing before to call `get-char-property'. + +2005-04-04 Jay Belanger <belanger@truman.edu> + + * calc/calc-aent.el (math-read-replacement-list): Add subscripts. + (math-read-subscripts): New variable. + (math-read-preprocess-string): Process subscripts. + +2005-04-04 Luc Teirlinck <teirllm@auburn.edu> + + * comint.el (comint-prompt-read-only): Doc fix. + + * dired.el (dired-copy-filename-as-kill): Make `-' arg behave like + `-1'. Doc fix. + +2005-04-04 Carsten Dominik <dominik@science.uva.nl> + + * textmodes/org.el (org-insert-mode-line-in-empty-file): + Change default value to nil. + 2005-04-04 Lute Kamstra <lute@gnu.org> * autorevert.el (auto-revert-mode): Specify :group. @@ -50,11 +184,11 @@ 2005-04-03 Marcelo Toledo <marcelo@marcelotoledo.org> - * add-log.el (change-log-font-lock-keywords): The manual - describing a Change Log entry, says: (...) "Aside from these - header lines, every line in the change log starts with a space or - a tab.". The font-lock was not highlighting lines started with - spaces, added support for it. + * add-log.el (change-log-font-lock-keywords): The manual + describing a Change Log entry, says: (...) "Aside from these + header lines, every line in the change log starts with a space or + a tab.". The font-lock was not highlighting lines started with + spaces, added support for it. 2005-04-03 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> @@ -82,7 +216,7 @@ * generic-x.el: Specify :group for all generic modes. * desktop.el (desktop-no-desktop-file-hook) - (desktop-after-read-hook): Fix docstring. + (desktop-after-read-hook): Doc fix. 2005-04-02 Luc Teirlinck <teirllm@auburn.edu> @@ -196,12 +330,12 @@ 2005-03-31 Karl Berry <karl@freefriends.org> - * textmodes/tex-mode.el (tex-compile): shell-quote-argument, + * textmodes/tex-mode.el (tex-compile): Use shell-quote-argument, not comint-quote-filename. 2005-03-31 Olive Lin <olive.lin@versateladsl.be> (tiny change) - * textmodes/tex-mode.el (tex-start-tex) shell-quote-argument, + * textmodes/tex-mode.el (tex-start-tex) Use shell-quote-argument, not comint-quote-filename. 2005-03-31 Thien-Thi Nguyen <ttn@gnu.org> @@ -1612,7 +1746,7 @@ (debug-entry-code): New const. (debug-on-entry-1): Use it. -2005-02-28 Chong Yidong" <cyd@stupidchicken.com> (tiny change) +2005-02-28 Chong Yidong <cyd@stupidchicken.com> * international/utf-16.el (ccl-encode-mule-utf-16le): Fix BUFFER_MAGNIFICATION to 2.
--- a/lisp/ChangeLog.5 Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/ChangeLog.5 Fri Apr 08 16:25:22 2005 +0000 @@ -1063,7 +1063,7 @@ * vc-hooks.el (vc-status): If vc-locking-user returns a number, compare it to (user-uid). -1995-05-11 James Thompson <thompson@wg2.waii.com> +1995-05-11 Jim Thompson <thompson@wg2.waii.com> * ps-print.el: Miscellaneous fixes for better compatibility with XEmacs 19.12.
--- a/lisp/add-log.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/add-log.el Fri Apr 08 16:25:22 2005 +0000 @@ -225,8 +225,8 @@ (2 'change-log-email-face))) ;; ;; File names. - ("^\\(?: +\\|\t\\)\\* \\([^ ,:([\n]+\\)" - (1 'change-log-file-face) + ("^\\( +\\|\t\\)\\* \\([^ ,:([\n]+\\)" + (2 'change-log-file-face) ;; Possibly further names in a list: ("\\=, \\([^ ,:([\n]+\\)" nil nil (1 'change-log-file-face)) ;; Possibly a parenthesized list of names: @@ -236,8 +236,8 @@ nil nil (1 'change-log-list-face))) ;; ;; Function or variable names. - ("^\t(\\([^(),\n]+\\|(\\(setf\\|SETF\\) [^() ,\n]+)\\)" - (1 'change-log-list-face) + ("^\\( +\\|\t\\)(\\([^(),\n]+\\|(\\(setf\\|SETF\\) [^() ,\n]+)\\)" + (2 'change-log-list-face) ("\\=, *\\([^(),\n]+\\|(\\(setf\\|SETF\\) [^() ,\n]+)\\)" nil nil (1 'change-log-list-face))) ;; @@ -250,8 +250,8 @@ ;; Acknowledgements. ;; Don't include plain "From" because that is vague; ;; we want to encourage people to say something more specific. - ("\\(^\t\\| \\)\\(Patch\\(es\\)? by\\|Report\\(ed by\\| from\\)\\|Suggest\\(ed by\\|ion from\\)\\)" - 2 'change-log-acknowledgement-face)) + ("\\(^\\( +\\|\t\\)\\| \\)\\(Patch\\(es\\)? by\\|Report\\(ed by\\| from\\)\\|Suggest\\(ed by\\|ion from\\)\\)" + 3 'change-log-acknowledgement-face)) "Additional expressions to highlight in Change Log mode.") (defvar change-log-mode-map
--- a/lisp/calc/calc-aent.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/calc/calc-aent.el Fri Apr 08 16:25:22 2005 +0000 @@ -519,7 +519,22 @@ ("â½" "(") ; ( ("â¾" ")") ; ) ("â¿" "n") ; n - ("â±" "i")) ; i + ("â±" "i") ; i + ;; subscripts + ("â‚€" "0") ; 0 + ("â‚" "1") ; 1 + ("â‚‚" "2") ; 2 + ("₃" "3") ; 3 + ("â‚„" "4") ; 4 + ("â‚…" "5") ; 5 + ("₆" "6") ; 6 + ("₇" "7") ; 7 + ("₈" "8") ; 8 + ("₉" "9") ; 9 + ("â‚Š" "+") ; + + ("â‚‹" "-") ; - + ("â‚" "(") ; ( + ("â‚Ž" ")")) ; ) "A list whose elements (old new) indicate replacements to make in Calc algebraic input.") @@ -527,11 +542,18 @@ "â°Â¹Â²Â³â´âµâ¶â·â¸â¹âºâ»â½â¾â¿â±" ; 0123456789+-()ni "A string consisting of the superscripts allowed by Calc.") +(defvar math-read-subscripts + "â‚€â‚₂₃₄₅₆₇₈₉₊₋â‚â‚Ž" ; 0123456789+-() + "A string consisting of the subscripts allowed by Calc.") + (defun math-read-preprocess-string (str) "Replace some substrings of STR by Calc equivalents." (setq str (replace-regexp-in-string (concat "[" math-read-superscripts "]+") "^(\\&)" str)) + (setq str + (replace-regexp-in-string (concat "[" math-read-subscripts "]+") + "_(\\&)" str)) (let ((rep-list math-read-replacement-list)) (while rep-list (setq str
--- a/lisp/calendar/timeclock.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/calendar/timeclock.el Fri Apr 08 16:25:22 2005 +0000 @@ -1,6 +1,6 @@ ;;; timeclock.el --- mode for keeping track of how much you work -;; Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. ;; Author: John Wiegley <johnw@gnu.org> ;; Created: 25 Mar 1999 @@ -78,7 +78,7 @@ ;;; Code: (defgroup timeclock nil - "Keeping track time of the time that gets spent." + "Keeping track of the time that gets spent." :group 'data) ;;; User Variables:
--- a/lisp/comint.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/comint.el Fri Apr 08 16:25:22 2005 +0000 @@ -186,11 +186,11 @@ \(add-hook 'comint-mode-hook (lambda () - (define-key comint-mode-map \"\C-w\" 'comint-kill-region) + (define-key comint-mode-map \"\\C-w\" 'comint-kill-region) (define-key comint-mode-map [C-S-backspace] 'comint-kill-whole-line))) -If you sometimes use comint-mode on text-only terminals or with `emacs-nw', +If you sometimes use comint-mode on text-only terminals or with `emacs -nw', you might wish to use another binding for `comint-kill-whole-line'." :type 'boolean :group 'comint
--- a/lisp/cus-edit.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/cus-edit.el Fri Apr 08 16:25:22 2005 +0000 @@ -3296,65 +3296,37 @@ (defvar widget-face-prompt-value-history nil "History of input to `widget-face-prompt-value'.") -(define-widget 'face 'restricted-sexp - "A Lisp face name." +(define-widget 'face 'symbol + "A Lisp face name (with sample)." + :format "%t: (%{sample%}) %v" + :tag "Face" + :value 'default + :sample-face-get 'widget-face-sample-face-get + :notify 'widget-face-notify + :match (lambda (widget value) (facep value)) :complete-function (lambda () (interactive) (lisp-complete-symbol 'facep)) - :prompt-value 'widget-field-prompt-value - :prompt-internal 'widget-symbol-prompt-internal :prompt-match 'facep :prompt-history 'widget-face-prompt-value-history - :value-create 'widget-face-value-create - :action 'widget-field-action - :match-alternatives '(facep) :validate (lambda (widget) (unless (facep (widget-value widget)) - (widget-put widget :error (format "Invalid face: %S" - (widget-value widget))) - widget)) - :value 'ignore - :tag "Function") - - -;;; There is a bug here: the sample doesn't get redisplayed -;;; in the new font when you specify one. Does anyone know how to -;;; make that work? -- rms. - -(defun widget-face-value-create (widget) - "Create an editable face name field." - (let ((buttons (widget-get widget :buttons)) - (symbol (widget-get widget :value))) - ;; Sample. - (push (widget-create-child-and-convert widget 'item - :format "(%{%t%})" - :sample-face symbol - :tag "sample") - buttons) - (insert " ") - ;; Update buttons. - (widget-put widget :buttons buttons)) - - (let ((size (widget-get widget :size)) - (value (widget-get widget :value)) - (from (point)) - ;; This is changed to a real overlay in `widget-setup'. We - ;; need the end points to behave differently until - ;; `widget-setup' is called. - (overlay (cons (make-marker) (make-marker)))) - (widget-put widget :field-overlay overlay) - (insert value) - (and size - (< (length value) size) - (insert-char ?\ (- size (length value)))) - (unless (memq widget widget-field-list) - (setq widget-field-new (cons widget widget-field-new))) - (move-marker (cdr overlay) (point)) - (set-marker-insertion-type (cdr overlay) nil) - (when (null size) - (insert ?\n)) - (move-marker (car overlay) from) - (set-marker-insertion-type (car overlay) t))) + (widget-put widget + :error (format "Invalid face: %S" + (widget-value widget))) + widget))) + +(defun widget-face-sample-face-get (widget) + (let ((value (widget-value widget))) + (if (facep value) + value + 'default))) + +(defun widget-face-notify (widget child &optional event) + "Update the sample, and notify the parent." + (overlay-put (widget-get widget :sample-overlay) + 'face (widget-apply widget :sample-face-get)) + (widget-default-notify widget child event)) ;;; The `hook' Widget.
--- a/lisp/dired.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/dired.el Fri Apr 08 16:25:22 2005 +0000 @@ -1937,10 +1937,11 @@ "Copy names of marked (or next ARG) files into the kill ring. The names are separated by a space. With a zero prefix arg, use the absolute file name of each marked file. -With \\[universal-argument], use the file name sans directory of each marked file. +With \\[universal-argument], use the file name relative to the Dired buffer's +`default-directory'. (This still may contain slashes if in a subdirectory.) -If on a subdir headerline, use subdirname instead; prefix arg is ignored -in this case. +If on a subdir headerline, use absolute subdirname instead; +prefix arg and marked files are ignored in this case. You can then feed the file name(s) to other commands with \\[yank]." (interactive "P") @@ -1950,10 +1951,11 @@ (if arg (cond ((zerop (prefix-numeric-value arg)) (dired-get-marked-files)) - ((integerp arg) - (dired-get-marked-files 'no-dir arg)) - (t ; else a raw arg - (dired-get-marked-files t))) + ((consp arg) + (dired-get-marked-files t)) + (t + (dired-get-marked-files + 'no-dir (prefix-numeric-value arg)))) (dired-get-marked-files 'no-dir)) " ")))) (if (eq last-command 'kill-region)
--- a/lisp/ediff-init.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/ediff-init.el Fri Apr 08 16:25:22 2005 +0000 @@ -1,6 +1,7 @@ ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff -;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 04 Free Software Foundation, Inc. +;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +;; 2004, 2005 Free Software Foundation, Inc. ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> @@ -43,7 +44,7 @@ ;; end pacifier ;; Is it XEmacs? -(defconst ediff-xemacs-p (string-match "XEmacs" emacs-version)) +(defconst ediff-xemacs-p (featurep 'xemacs)) ;; Is it Emacs? (defconst ediff-emacs-p (not ediff-xemacs-p)) @@ -53,7 +54,7 @@ ;; compiler at hand. ;; Suggested by rms. (defmacro ediff-cond-compile-for-xemacs-or-emacs (xemacs-form emacs-form) - (if (string-match "XEmacs" emacs-version) + (if (featurep 'xemacs) xemacs-form emacs-form)) (defvar ediff-force-faces nil @@ -1145,9 +1146,9 @@ (defface ediff-even-diff-face-B (if ediff-emacs-p - `((((class color) (min-colors 16)) + `((((class color) (min-colors 16)) (:foreground "White" :background "Grey")) - (((class color)) + (((class color)) (:foreground "blue3" :background "Grey" :weight bold)) (t (:italic t :stipple ,stipple-pixmap))) `((((type tty)) (:foreground "blue3" :background "Grey" :weight bold))
--- a/lisp/emacs-lisp/copyright.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/emacs-lisp/copyright.el Fri Apr 08 16:25:22 2005 +0000 @@ -112,7 +112,7 @@ (concat "Add " copyright-current-year " to copyright? ")))) (if replace - (replace-match copyright-current-year t t nil 1) + (replace-match copyright-current-year t t nil 2) (let ((size (save-excursion (skip-chars-backward "0-9")))) (if (and (eq (% (- (string-to-number copyright-current-year) (string-to-number (buffer-substring
--- a/lisp/emacs-lisp/easy-mmode.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/emacs-lisp/easy-mmode.el Fri Apr 08 16:25:22 2005 +0000 @@ -94,8 +94,11 @@ These following keyword arguments are supported (other keywords will be passed to `defcustom' if the minor mode is global): :group GROUP Custom group name to use in all generated `defcustom' forms. + Defaults to MODE without the possible trailing \"-mode\". + (This default may not be a valid customization group defined + with `defgroup'. Make sure it is.) :global GLOBAL If non-nil specifies that the minor mode is not meant to be - buffer-local, so don't make the variable MODE buffer-local. + buffer-local, so don't make the variable MODE buffer-local. By default, the mode is buffer-local. :init-value VAL Same as the INIT-VALUE argument. :lighter SPEC Same as the LIGHTER argument. @@ -153,10 +156,9 @@ (unless group ;; We might as well provide a best-guess default group. (setq group - `(:group (or (custom-current-group) - ',(intern (replace-regexp-in-string - "-mode\\'" "" mode-name)))))) - + `(:group ',(intern (replace-regexp-in-string + "-mode\\'" "" mode-name))))) + `(progn ;; Define the variable to enable or disable the mode. ,(if (not globalp) @@ -220,8 +222,8 @@ ;; Return the new setting. ,mode) - ;; Autoloading an easy-mmode-define-minor-mode autoloads - ;; everything up-to-here. + ;; Autoloading a define-minor-mode autoloads everything + ;; up-to-here. :autoload-end ;; The toggle's hook. @@ -280,9 +282,8 @@ (unless group ;; We might as well provide a best-guess default group. (setq group - `(:group (or (custom-current-group) - ',(intern (replace-regexp-in-string - "-mode\\'" "" (symbol-name mode))))))) + `(:group ',(intern (replace-regexp-in-string + "-mode\\'" "" (symbol-name mode)))))) `(progn ;; The actual global minor-mode
--- a/lisp/fast-lock.el Mon Apr 04 16:43:15 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,863 +0,0 @@ -;;; fast-lock.el --- automagic text properties caching for fast Font Lock mode - -;; Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - -;; Author: Simon Marshall <simon@gnu.org> -;; Maintainer: FSF -;; Keywords: faces files -;; Version: 3.14 - -;; 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, 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 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: - -;; Fast Lock mode is a Font Lock support mode. -;; It makes visiting a file in Font Lock mode faster by restoring its face text -;; properties from automatically saved associated Font Lock cache files. -;; -;; See caveats and feedback below. -;; See also the lazy-lock package. (But don't use the two at the same time!) - -;; Installation: -;; -;; Put in your ~/.emacs: -;; -;; (setq font-lock-support-mode 'fast-lock-mode) -;; -;; Start up a new Emacs and use font-lock as usual (except that you can use the -;; so-called "gaudier" fontification regexps on big files without frustration). -;; -;; When you visit a file (which has `font-lock-mode' enabled) that has a -;; corresponding Font Lock cache file associated with it, the Font Lock cache -;; will be loaded from that file instead of being generated by Font Lock code. - -;; Caveats: -;; -;; A cache will be saved when visiting a compressed file using crypt++, but not -;; be read. This is a "feature"/"consequence"/"bug" of crypt++. -;; -;; Version control packages are likely to stamp all over file modification -;; times. Therefore the act of checking out may invalidate a cache. - -;; History: -;; -;; 0.02--1.00: -;; - Changed name from turbo-prop to fast-lock. Automagic for font-lock only -;; - Made `fast-lock-mode' a minor mode, like G. Dinesh Dutt's fss-mode -;; 1.00--1.01: -;; - Turn on `fast-lock-mode' only if `buffer-file-name' or `interactive-p' -;; - Made `fast-lock-file-name' use `buffer-name' if `buffer-file-name' is nil -;; - Moved save-all conditions to `fast-lock-save-cache' -;; - Added `fast-lock-save-text-properties' to `kill-buffer-hook' -;; 1.01--2.00: complete rewrite---not worth the space to document -;; - Changed structure of text properties cache and threw out file mod checks -;; 2.00--2.01: -;; - Made `condition-case' forms understand `quit'. -;; - Made `fast-lock' require `font-lock' -;; - Made `fast-lock-cache-name' chase links (from Ben Liblit) -;; 2.01--3.00: -;; - Changed structure of cache to include `font-lock-keywords' (from rms) -;; - Changed `fast-lock-cache-mechanisms' to `fast-lock-cache-directories' -;; - Removed `fast-lock-read-others' -;; - Made `fast-lock-read-cache' ignore cache owner -;; - Made `fast-lock-save-cache-external' create cache directory -;; - Made `fast-lock-save-cache-external' save `font-lock-keywords' -;; - Made `fast-lock-cache-data' check `font-lock-keywords' -;; 3.00--3.01: incorporated port of 2.00 to Lucid, made by Barry Warsaw -;; - Package now provides itself -;; - Lucid: Use `font-lock-any-extents-p' for `font-lock-any-properties-p' -;; - Lucid: Use `list-faces' for `face-list' -;; - Lucid: Added `set-text-properties' -;; - Lucid: Made `turn-on-fast-lock' pass 1 not t to `fast-lock-mode' -;; - Removed test for `fast-lock-mode' from `fast-lock-read-cache' -;; - Lucid: Added Lucid-specific `fast-lock-get-face-properties' -;; 3.01--3.02: now works with Lucid Emacs, thanks to Barry Warsaw -;; - Made `fast-lock-cache-name' map ":" to ";" for OS/2 (from Serganova Vera) -;; - Made `fast-lock-cache-name' use abbreviated file name (from Barry Warsaw) -;; - Lucid: Separated handlers for `error' and `quit' for `condition-case' -;; 3.02--3.03: -;; - Changed `fast-lock-save-cache-external' to `fast-lock-save-cache-data' -;; - Lucid: Added Lucid-specific `fast-lock-set-face-properties' -;; 3.03--3.04: -;; - Corrected `subrp' test of Lucid code -;; - Replaced `font-lock-any-properties-p' with `text-property-not-all' -;; - Lucid: Made `fast-lock-set-face-properties' put `text-prop' on extents -;; - Made `fast-lock-cache-directories' a regexp alist (from Colin Rafferty) -;; - Made `fast-lock-cache-directory' to return a usable cache file directory -;; 3.04--3.05: -;; - Lucid: Fix for XEmacs 19.11 `text-property-not-all' -;; - Replaced `subrp' test of Lucid code with `emacs-version' `string-match' -;; - Made `byte-compile-warnings' omit `unresolved' on compilation -;; - Made `fast-lock-save-cache-data' use a buffer (from Rick Sladkey) -;; - Reverted to old `fast-lock-get-face-properties' (from Rick Sladkey) -;; 3.05--3.06: incorporated hack of 3.03, made by Jonathan Stigelman (Stig) -;; - Reverted to 3.04 version of `fast-lock-get-face-properties' -;; - XEmacs: Removed `list-faces' `defalias' -;; - Made `fast-lock-mode' and `turn-on-fast-lock' succeed `autoload' cookies -;; - Added `fast-lock-submit-bug-report' -;; - Renamed `fast-lock-save-size' to `fast-lock-minimum-size' -;; - Made `fast-lock-save-cache' output a message if no save ever attempted -;; - Made `fast-lock-save-cache-data' output a message if save attempted -;; - Made `fast-lock-cache-data' output a message if load attempted -;; - Made `fast-lock-save-cache-data' do `condition-case' not `unwind-protect' -;; - Made `fast-lock-save-cache' and `fast-lock-read-cache' return nothing -;; - Made `fast-lock-save-cache' check `buffer-modified-p' (Stig) -;; - Added `fast-lock-save-events' -;; - Added `fast-lock-after-save-hook' to `after-save-hook' (Stig) -;; - Added `fast-lock-kill-buffer-hook' to `kill-buffer-hook' -;; - Changed `fast-lock-save-caches' to `fast-lock-kill-emacs-hook' -;; - Added `fast-lock-kill-emacs-hook' to `kill-emacs-hook' -;; - Made `fast-lock-save-cache' check `verify-visited-file-modtime' (Stig) -;; - Made `visited-file-modtime' be the basis of the timestamp (Stig) -;; - Made `fast-lock-save-cache-1' and `fast-lock-cache-data' use/reformat it -;; - Added `fast-lock-cache-filename' to keep track of the cache file name -;; - Added `fast-lock-after-fontify-buffer' -;; - Added `fast-lock-save-faces' list of faces to save (idea from Stig/Tibor) -;; - Made `fast-lock-get-face-properties' functions use it -;; - XEmacs: Made `fast-lock-set-face-properties' do extents the Font Lock way -;; - XEmacs: Removed fix for `text-property-not-all' (19.11 support dropped) -;; - Made `fast-lock-mode' ensure `font-lock-mode' is on -;; - Made `fast-lock-save-cache' do `cdr-safe' not `cdr' (from Dave Foster) -;; - Made `fast-lock-save-cache' do `set-buffer' first (from Dave Foster) -;; - Made `fast-lock-save-cache' loop until saved or quit (from Georg Nikodym) -;; - Made `fast-lock-cache-data' check `buffer-modified-p' -;; - Made `fast-lock-cache-data' do `font-lock-compile-keywords' if necessary -;; - XEmacs: Made `font-lock-compile-keywords' `defalias' -;; 3.06--3.07: -;; - XEmacs: Add `fast-lock-after-fontify-buffer' to the Font Lock hook -;; - Made `fast-lock-cache-name' explain the use of `directory-abbrev-alist' -;; - Made `fast-lock-mode' use `buffer-file-truename' not `buffer-file-name' -;; 3.07--3.08: -;; - Made `fast-lock-read-cache' set `fast-lock-cache-filename' -;; 3.08--3.09: -;; - Made `fast-lock-save-cache' cope if `fast-lock-minimum-size' is an a list -;; - Made `fast-lock-mode' respect the value of `font-lock-inhibit-thing-lock' -;; - Added `fast-lock-after-unfontify-buffer' -;; 3.09--3.10: -;; - Rewrite for Common Lisp macros -;; - Made fast-lock.el barf on a crap 8+3 pseudo-OS (Eli Zaretskii help) -;; - XEmacs: Made `add-minor-mode' succeed `autoload' cookie -;; - XEmacs: Made `fast-lock-save-faces' default to `font-lock-face-list' -;; - Made `fast-lock-save-cache' use `font-lock-value-in-major-mode' -;; - Wrap with `save-buffer-state' (Ray Van Tassle report) -;; - Made `fast-lock-mode' wrap `font-lock-support-mode' -;; 3.10--3.11: -;; - Made `fast-lock-get-face-properties' cope with face lists -;; - Added `fast-lock-verbose' -;; - XEmacs: Add `font-lock-value-in-major-mode' if necessary -;; - Removed `fast-lock-submit-bug-report' and bade farewell -;; 3.11--3.12: -;; - Added Custom support (Hrvoje Niksic help) -;; - Made `save-buffer-state' wrap `inhibit-point-motion-hooks' -;; - Made `fast-lock-cache-data' simplify calls of `font-lock-compile-keywords' -;; 3.12--3.13: -;; - Removed `byte-*' variables from `eval-when-compile' (Erik Naggum hint) -;; - Changed structure of cache to include `font-lock-syntactic-keywords' -;; - Made `fast-lock-save-cache-1' save syntactic fontification data -;; - Made `fast-lock-cache-data' take syntactic fontification data -;; - Added `fast-lock-get-syntactic-properties' -;; - Renamed `fast-lock-set-face-properties' to `fast-lock-add-properties' -;; - Made `fast-lock-add-properties' add syntactic and face fontification data -;; 3.13--3.14: -;; - Made `fast-lock-cache-name' cope with `windowsnt' (Geoff Voelker fix) -;; - Made `fast-lock-verbose' use `other' widget (Andreas Schwab fix) -;; - Used `with-temp-message' where possible to make messages temporary. - -;;; Code: - -(require 'font-lock) - -;; Make sure fast-lock.el is supported. -(if (and (eq system-type 'ms-dos) (not (msdos-long-file-names))) - (error "`fast-lock' was written for long file name systems")) - -(eval-when-compile - ;; - ;; We don't do this at the top-level as we only use non-autoloaded macros. - (require 'cl) - ;; - ;; We use this to preserve or protect things when modifying text properties. - (defmacro save-buffer-state (varlist &rest body) - "Bind variables according to VARLIST and eval BODY restoring buffer state." - `(let* (,@(append varlist - '((modified (buffer-modified-p)) (buffer-undo-list t) - (inhibit-read-only t) (inhibit-point-motion-hooks t) - before-change-functions after-change-functions - deactivate-mark buffer-file-name buffer-file-truename))) - ,@body - (when (and (not modified) (buffer-modified-p)) - (set-buffer-modified-p nil)))) - (put 'save-buffer-state 'lisp-indent-function 1) - ;; - ;; We use this to verify that a face should be saved. - (defmacro fast-lock-save-facep (face) - "Return non-nil if FACE is one of `fast-lock-save-faces'." - `(or (null fast-lock-save-faces) - (if (symbolp ,face) - (memq ,face fast-lock-save-faces) - (let ((faces ,face)) - (while (unless (memq (car faces) fast-lock-save-faces) - (setq faces (cdr faces)))) - faces)))) - ;; - ;; We use this for compatibility with a future Emacs. - (or (fboundp 'with-temp-message) - (defmacro with-temp-message (message &rest body) - `(let ((temp-message ,message) current-message) - (unwind-protect - (progn - (when temp-message - (setq current-message (current-message)) - (message temp-message)) - ,@body) - (when temp-message - (message current-message)))))) - ;; - ;; We use this for compatibility with a future Emacs. - (or (fboundp 'defcustom) - (defmacro defcustom (symbol value doc &rest args) - `(defvar ,symbol ,value ,doc)))) - -;(defun fast-lock-submit-bug-report () -; "Submit via mail a bug report on fast-lock.el." -; (interactive) -; (let ((reporter-prompt-for-summary-p t)) -; (reporter-submit-bug-report "simon@gnu.org" "fast-lock 3.14" -; '(fast-lock-cache-directories fast-lock-minimum-size -; fast-lock-save-others fast-lock-save-events fast-lock-save-faces -; fast-lock-verbose) -; nil nil -; (concat "Hi Si., -; -;I want to report a bug. I've read the `Bugs' section of `Info' on Emacs, so I -;know how to make a clear and unambiguous report. To reproduce the bug: -; -;Start a fresh editor via `" invocation-name " -no-init-file -no-site-file'. -;In the `*scratch*' buffer, evaluate:")))) - -(defvar fast-lock-mode nil) ; Whether we are turned on. -(defvar fast-lock-cache-timestamp nil) ; For saving/reading. -(defvar fast-lock-cache-filename nil) ; For deleting. - -;; User Variables: - -(defcustom fast-lock-minimum-size 25600 - "*Minimum size of a buffer for cached fontification. -Only buffers more than this can have associated Font Lock cache files saved. -If nil, means cache files are never created. -If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE), -where MAJOR-MODE is a symbol or t (meaning the default). For example: - ((c-mode . 25600) (c++-mode . 25600) (rmail-mode . 1048576)) -means that the minimum size is 25K for buffers in C or C++ modes, one megabyte -for buffers in Rmail mode, and size is irrelevant otherwise." - :type '(choice (const :tag "none" nil) - (integer :tag "size") - (repeat :menu-tag "mode specific" :tag "mode specific" - :value ((t . nil)) - (cons :tag "Instance" - (radio :tag "Mode" - (const :tag "all" t) - (symbol :tag "name")) - (radio :tag "Size" - (const :tag "none" nil) - (integer :tag "size"))))) - :group 'fast-lock) - -(defcustom fast-lock-cache-directories '("." "~/.emacs-flc") -; - `internal', keep each file's Font Lock cache file in the same file. -; - `external', keep each file's Font Lock cache file in the same directory. - "*Directories in which Font Lock cache files are saved and read. -Each item should be either DIR or a cons pair of the form (REGEXP . DIR) where -DIR is a directory name (relative or absolute) and REGEXP is a regexp. - -An attempt will be made to save or read Font Lock cache files using these items -until one succeeds (i.e., until a readable or writable one is found). If an -item contains REGEXP, DIR is used only if the buffer file name matches REGEXP. -For example: - - (let ((home (expand-file-name (abbreviate-file-name (file-truename \"~/\"))))) - (list (cons (concat \"^\" (regexp-quote home)) \".\") \"~/.emacs-flc\")) - => - ((\"^/your/true/home/directory/\" . \".\") \"~/.emacs-flc\") - -would cause a file's current directory to be used if the file is under your -home directory hierarchy, or otherwise the absolute directory `~/.emacs-flc'." - :type '(repeat (radio (directory :tag "directory") - (cons :tag "Matching" - (regexp :tag "regexp") - (directory :tag "directory")))) - :group 'fast-lock) - -(defcustom fast-lock-save-events '(kill-buffer kill-emacs) - "*Events under which caches will be saved. -Valid events are `save-buffer', `kill-buffer' and `kill-emacs'. -If concurrent editing sessions use the same associated cache file for a file's -buffer, then you should add `save-buffer' to this list." - :type '(set (const :tag "buffer saving" save-buffer) - (const :tag "buffer killing" kill-buffer) - (const :tag "emacs killing" kill-emacs)) - :group 'fast-lock) - -(defcustom fast-lock-save-others t - "*If non-nil, save Font Lock cache files irrespective of file owner. -If nil, means only buffer files known to be owned by you can have associated -Font Lock cache files saved. Ownership may be unknown for networked files." - :type 'boolean - :group 'fast-lock) - -(defcustom fast-lock-verbose font-lock-verbose - "*If non-nil, means show status messages for cache processing. -If a number, only buffers greater than this size have processing messages." - :type '(choice (const :tag "never" nil) - (other :tag "always" t) - (integer :tag "size")) - :group 'fast-lock) - -(defvar fast-lock-save-faces - (when (save-match-data (string-match "XEmacs" (emacs-version))) - ;; XEmacs uses extents for everything, so we have to pick the right ones. - font-lock-face-list) - "Faces that will be saved in a Font Lock cache file. -If nil, means information for all faces will be saved.") - -;; User Functions: - -;;;###autoload -(defun fast-lock-mode (&optional arg) - "Toggle Fast Lock mode. -With arg, turn Fast Lock mode on if and only if arg is positive and the buffer -is associated with a file. Enable it automatically in your `~/.emacs' by: - - (setq font-lock-support-mode 'fast-lock-mode) - -If Fast Lock mode is enabled, and the current buffer does not contain any text -properties, any associated Font Lock cache is used if its timestamp matches the -buffer's file, and its `font-lock-keywords' match those that you are using. - -Font Lock caches may be saved: -- When you save the file's buffer. -- When you kill an unmodified file's buffer. -- When you exit Emacs, for all unmodified or saved buffers. -Depending on the value of `fast-lock-save-events'. -See also the commands `fast-lock-read-cache' and `fast-lock-save-cache'. - -Use \\[font-lock-fontify-buffer] to fontify the buffer if the cache is bad. - -Various methods of control are provided for the Font Lock cache. In general, -see variable `fast-lock-cache-directories' and function `fast-lock-cache-name'. -For saving, see variables `fast-lock-minimum-size', `fast-lock-save-events', -`fast-lock-save-others' and `fast-lock-save-faces'." - (interactive "P") - ;; Only turn on if we are visiting a file. We could use `buffer-file-name', - ;; but many packages temporarily wrap that to nil when doing their own thing. - (set (make-local-variable 'fast-lock-mode) - (and buffer-file-truename - (not (memq 'fast-lock-mode font-lock-inhibit-thing-lock)) - (if arg (> (prefix-numeric-value arg) 0) (not fast-lock-mode)))) - (if (and fast-lock-mode (not font-lock-mode)) - ;; Turned on `fast-lock-mode' rather than `font-lock-mode'. - (let ((font-lock-support-mode 'fast-lock-mode)) - (font-lock-mode t)) - ;; Let's get down to business. - (set (make-local-variable 'fast-lock-cache-timestamp) nil) - (set (make-local-variable 'fast-lock-cache-filename) nil) - (when (and fast-lock-mode (not font-lock-fontified)) - (fast-lock-read-cache)))) - -(defun fast-lock-read-cache () - "Read the Font Lock cache for the current buffer. - -The following criteria must be met for a Font Lock cache file to be read: -- Fast Lock mode must be turned on in the buffer. -- The buffer must not be modified. -- The buffer's `font-lock-keywords' must match the cache's. -- The buffer file's timestamp must match the cache's. -- Criteria imposed by `fast-lock-cache-directories'. - -See `fast-lock-mode'." - (interactive) - (let ((directories fast-lock-cache-directories) - (modified (buffer-modified-p)) (inhibit-read-only t) - (fontified font-lock-fontified)) - (set (make-local-variable 'font-lock-fontified) nil) - ;; Keep trying directories until fontification is turned off. - (while (and directories (not font-lock-fontified)) - (let ((directory (fast-lock-cache-directory (car directories) nil))) - (condition-case nil - (when directory - (setq fast-lock-cache-filename (fast-lock-cache-name directory)) - (when (file-readable-p fast-lock-cache-filename) - (load fast-lock-cache-filename t t t))) - (error nil) (quit nil)) - (setq directories (cdr directories)))) - ;; Unset `fast-lock-cache-filename', and restore `font-lock-fontified', if - ;; we don't use a cache. (Note that `fast-lock-cache-data' sets the value - ;; of `fast-lock-cache-timestamp'.) - (set-buffer-modified-p modified) - (unless font-lock-fontified - (setq fast-lock-cache-filename nil font-lock-fontified fontified)))) - -(defun fast-lock-save-cache (&optional buffer) - "Save the Font Lock cache of BUFFER or the current buffer. - -The following criteria must be met for a Font Lock cache file to be saved: -- Fast Lock mode must be turned on in the buffer. -- The event must be one of `fast-lock-save-events'. -- The buffer must be at least `fast-lock-minimum-size' bytes long. -- The buffer file must be owned by you, or `fast-lock-save-others' must be t. -- The buffer must contain at least one `face' text property. -- The buffer must not be modified. -- The buffer file's timestamp must be the same as the file's on disk. -- The on disk file's timestamp must be different than the buffer's cache. -- Criteria imposed by `fast-lock-cache-directories'. - -See `fast-lock-mode'." - (interactive) - (save-excursion - (when buffer - (set-buffer buffer)) - (let ((min-size (font-lock-value-in-major-mode fast-lock-minimum-size)) - (file-timestamp (visited-file-modtime)) (saved nil)) - (when (and fast-lock-mode - ;; - ;; "Only save if the buffer matches the file, the file has - ;; changed, and it was changed by the current emacs session." - ;; - ;; Only save if the buffer is not modified, - ;; (i.e., so we don't save for something not on disk) - (not (buffer-modified-p)) - ;; and the file's timestamp is the same as the buffer's, - ;; (i.e., someone else hasn't written the file in the meantime) - (verify-visited-file-modtime (current-buffer)) - ;; and the file's timestamp is different from the cache's. - ;; (i.e., a save has occurred since the cache was read) - (not (equal fast-lock-cache-timestamp file-timestamp)) - ;; - ;; Only save if user's restrictions are satisfied. - (and min-size (>= (buffer-size) min-size)) - (or fast-lock-save-others - (eq (user-uid) (nth 2 (file-attributes buffer-file-name)))) - ;; - ;; Only save if there are `face' properties to save. - (text-property-not-all (point-min) (point-max) 'face nil)) - ;; - ;; Try each directory until we manage to save or the user quits. - (let ((directories fast-lock-cache-directories)) - (while (and directories (memq saved '(nil error))) - (let* ((dir (fast-lock-cache-directory (car directories) t)) - (file (and dir (fast-lock-cache-name dir)))) - (when (and file (file-writable-p file)) - (setq saved (fast-lock-save-cache-1 file file-timestamp))) - (setq directories (cdr directories))))))))) - -;;;###autoload -(defun turn-on-fast-lock () - "Unconditionally turn on Fast Lock mode." - (fast-lock-mode t)) - -;;; API Functions: - -(defun fast-lock-after-fontify-buffer () - ;; Delete the Font Lock cache file used to restore fontification, if any. - (when fast-lock-cache-filename - (if (file-writable-p fast-lock-cache-filename) - (delete-file fast-lock-cache-filename) - (message "File %s font lock cache cannot be deleted" (buffer-name)))) - ;; Flag so that a cache will be saved later even if the file is never saved. - (setq fast-lock-cache-timestamp nil)) - -(defalias 'fast-lock-after-unfontify-buffer - 'ignore) - -;; Miscellaneous Functions: - -(defun fast-lock-save-cache-after-save-file () - ;; Do `fast-lock-save-cache' if `save-buffer' is on `fast-lock-save-events'. - (when (memq 'save-buffer fast-lock-save-events) - (fast-lock-save-cache))) - -(defun fast-lock-save-cache-before-kill-buffer () - ;; Do `fast-lock-save-cache' if `kill-buffer' is on `fast-lock-save-events'. - (when (memq 'kill-buffer fast-lock-save-events) - (fast-lock-save-cache))) - -(defun fast-lock-save-caches-before-kill-emacs () - ;; Do `fast-lock-save-cache's if `kill-emacs' is on `fast-lock-save-events'. - (when (memq 'kill-emacs fast-lock-save-events) - (mapcar 'fast-lock-save-cache (buffer-list)))) - -(defun fast-lock-cache-directory (directory create) - "Return usable directory based on DIRECTORY. -Returns nil if the directory does not exist, or, if CREATE non-nil, cannot be -created. DIRECTORY may be a string or a cons pair of the form (REGEXP . DIR). -See `fast-lock-cache-directories'." - (let ((dir - (cond ((not buffer-file-name) - ;; Should never be nil, but `crypt++' screws it up. - nil) - ((stringp directory) - ;; Just a directory. - directory) - (t - ;; A directory iff the file name matches the regexp. - (let ((bufile (expand-file-name buffer-file-truename)) - (case-fold-search nil)) - (when (save-match-data (string-match (car directory) bufile)) - (cdr directory))))))) - (cond ((not dir) - nil) - ((file-accessible-directory-p dir) - dir) - (create - (condition-case nil - (progn (make-directory dir t) dir) - (error nil)))))) - -;; If you are wondering why we only hash if the directory is not ".", rather -;; than if `file-name-absolute-p', it is because if we just appended ".flc" for -;; relative cache directories (that are not ".") then it is possible that more -;; than one file would have the same cache name in that directory, if the luser -;; made a link from one relative cache directory to another. (Phew!) -(defun fast-lock-cache-name (directory) - "Return full cache file name using caching DIRECTORY. -If DIRECTORY is `.', the file name is the buffer file name appended with `.flc'. -Otherwise, the file name is constructed from DIRECTORY and the buffer's true -abbreviated file name, with all `/' characters in the name replaced with `#' -characters, and appended with `.flc'. - -If the same file has different cache file names when edited on different -machines, e.g., on one machine the cache file name has the prefix `#home', -perhaps due to automount, try putting in your `~/.emacs' something like: - - (setq directory-abbrev-alist (cons '(\"^/home/\" . \"/\") directory-abbrev-alist)) - -Emacs automagically removes the common `/tmp_mnt' automount prefix by default. - -See `fast-lock-cache-directory'." - (if (string-equal directory ".") - (concat buffer-file-name ".flc") - (let* ((bufile (expand-file-name buffer-file-truename)) - (chars-alist - (if (memq system-type '(emx windows-nt cygwin)) - '((?/ . (?#)) (?# . (?# ?#)) (?: . (?\;)) (?\; . (?\; ?\;))) - '((?/ . (?#)) (?# . (?# ?#))))) - (mapchars - (function (lambda (c) (or (cdr (assq c chars-alist)) (list c)))))) - (concat - (file-name-as-directory (expand-file-name directory)) - (mapconcat 'char-to-string (apply 'append (mapcar mapchars bufile)) "") - ".flc")))) - -;; Font Lock Cache Processing Functions: - -;; The version 3 format of the cache is: -;; -;; (fast-lock-cache-data VERSION TIMESTAMP -;; font-lock-syntactic-keywords SYNTACTIC-PROPERTIES -;; font-lock-keywords FACE-PROPERTIES) - -(defun fast-lock-save-cache-1 (file timestamp) - ;; Save the FILE with the TIMESTAMP plus fontification data. - ;; Returns non-nil if a save was attempted to a writable cache file. - (let ((tpbuf (generate-new-buffer " *fast-lock*")) - (verbose (if (numberp fast-lock-verbose) - (> (buffer-size) fast-lock-verbose) - fast-lock-verbose)) - (saved t)) - (with-temp-message - (when verbose - (format "Saving %s font lock cache..." (buffer-name))) - (condition-case nil - (save-excursion - (print (list 'fast-lock-cache-data 3 - (list 'quote timestamp) - (list 'quote font-lock-syntactic-keywords) - (list 'quote (fast-lock-get-syntactic-properties)) - (list 'quote font-lock-keywords) - (list 'quote (fast-lock-get-face-properties))) - tpbuf) - (set-buffer tpbuf) - (write-region (point-min) (point-max) file nil 'quietly) - (setq fast-lock-cache-timestamp timestamp - fast-lock-cache-filename file)) - (error (setq saved 'error)) (quit (setq saved 'quit))) - (kill-buffer tpbuf)) - (cond ((eq saved 'quit) - (message "Saving %s font lock cache...quit" (buffer-name))) - ((eq saved 'error) - (message "Saving %s font lock cache...failed" (buffer-name)))) - ;; We return non-nil regardless of whether a failure occurred. - saved)) - -(defun fast-lock-cache-data (version timestamp - syntactic-keywords syntactic-properties - keywords face-properties - &rest ignored) - ;; Find value of syntactic keywords in case it is a symbol. - (setq font-lock-syntactic-keywords (font-lock-eval-keywords - font-lock-syntactic-keywords)) - ;; Compile all keywords in case some are and some aren't. - (when font-lock-syntactic-keywords - (setq font-lock-syntactic-keywords (font-lock-compile-keywords - font-lock-syntactic-keywords))) - (when syntactic-keywords - (setq syntactic-keywords (font-lock-compile-keywords syntactic-keywords))) - (setq font-lock-keywords (font-lock-compile-keywords font-lock-keywords) - keywords (font-lock-compile-keywords keywords)) - ;; Use the Font Lock cache SYNTACTIC-PROPERTIES and FACE-PROPERTIES if we're - ;; using cache VERSION format 3, the current buffer's file timestamp matches - ;; the TIMESTAMP, the current buffer's `font-lock-syntactic-keywords' are the - ;; same as SYNTACTIC-KEYWORDS, and the current buffer's `font-lock-keywords' - ;; are the same as KEYWORDS. - (let ((buf-timestamp (visited-file-modtime)) - (verbose (if (numberp fast-lock-verbose) - (> (buffer-size) fast-lock-verbose) - fast-lock-verbose)) - (loaded t)) - (if (or (/= version 3) - (buffer-modified-p) - (not (equal timestamp buf-timestamp)) - (not (equal syntactic-keywords font-lock-syntactic-keywords)) - (not (equal keywords font-lock-keywords))) - (setq loaded nil) - (with-temp-message - (when verbose - (format "Loading %s font lock cache..." (buffer-name))) - (condition-case nil - (fast-lock-add-properties syntactic-properties face-properties) - (error (setq loaded 'error)) (quit (setq loaded 'quit)))) - (cond ((eq loaded 'quit) - (message "Loading %s font lock cache...quit" (buffer-name))) - ((eq loaded 'error) - (message "Loading %s font lock cache...failed" (buffer-name))))) - (setq font-lock-fontified (eq loaded t) - fast-lock-cache-timestamp (and (eq loaded t) timestamp)))) - -;; Text Properties Processing Functions: - -;; This is fast, but fails if adjacent characters have different `face' text -;; properties. Maybe that's why I dropped it in the first place? -;(defun fast-lock-get-face-properties () -; "Return a list of `face' text properties in the current buffer. -;Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) -;where VALUE is a `face' property value and STARTx and ENDx are positions." -; (save-restriction -; (widen) -; (let ((start (text-property-not-all (point-min) (point-max) 'face nil)) -; (limit (point-max)) end properties value cell) -; (while start -; (setq end (next-single-property-change start 'face nil limit) -; value (get-text-property start 'face)) -; ;; Make, or add to existing, list of regions with same `face'. -; (if (setq cell (assq value properties)) -; (setcdr cell (cons start (cons end (cdr cell)))) -; (setq properties (cons (list value start end) properties))) -; (setq start (next-single-property-change end 'face))) -; properties))) - -;; This is slow, but copes if adjacent characters have different `face' text -;; properties, but fails if they are lists. -;(defun fast-lock-get-face-properties () -; "Return a list of `face' text properties in the current buffer. -;Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) -;where VALUE is a `face' property value and STARTx and ENDx are positions. -;Only those `face' VALUEs in `fast-lock-save-faces' are returned." -; (save-restriction -; (widen) -; (let ((faces (or fast-lock-save-faces (face-list))) (limit (point-max)) -; properties regions face start end) -; (while faces -; (setq face (car faces) faces (cdr faces) regions () end (point-min)) -; ;; Make a list of start/end regions with `face' property face. -; (while (setq start (text-property-any end limit 'face face)) -; (setq end (or (text-property-not-all start limit 'face face) limit) -; regions (cons start (cons end regions)))) -; ;; Add `face' face's regions, if any, to properties. -; (when regions -; (push (cons face regions) properties))) -; properties))) - -(defun fast-lock-get-face-properties () - "Return a list of `face' text properties in the current buffer. -Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) -where VALUE is a `face' property value and STARTx and ENDx are positions." - (save-restriction - (widen) - (let ((start (text-property-not-all (point-min) (point-max) 'face nil)) - end properties value cell) - (while start - (setq end (next-single-property-change start 'face nil (point-max)) - value (get-text-property start 'face)) - ;; Make, or add to existing, list of regions with same `face'. - (cond ((setq cell (assoc value properties)) - (setcdr cell (cons start (cons end (cdr cell))))) - ((fast-lock-save-facep value) - (push (list value start end) properties))) - (setq start (text-property-not-all end (point-max) 'face nil))) - properties))) - -(defun fast-lock-get-syntactic-properties () - "Return a list of `syntax-table' text properties in the current buffer. -See `fast-lock-get-face-properties'." - (save-restriction - (widen) - (let ((start (text-property-not-all (point-min) (point-max) 'syntax-table - nil)) - end properties value cell) - (while start - (setq end (next-single-property-change start 'syntax-table nil - (point-max)) - value (get-text-property start 'syntax-table)) - ;; Make, or add to existing, list of regions with same `syntax-table'. - (if (setq cell (assoc value properties)) - (setcdr cell (cons start (cons end (cdr cell)))) - (push (list value start end) properties)) - (setq start (text-property-not-all end (point-max) 'syntax-table nil))) - properties))) - -(defun fast-lock-add-properties (syntactic-properties face-properties) - "Add `syntax-table' and `face' text properties to the current buffer. -Any existing `syntax-table' and `face' text properties are removed first. -See `fast-lock-get-face-properties'." - (save-buffer-state (plist regions) - (save-restriction - (widen) - (font-lock-unfontify-region (point-min) (point-max)) - ;; - ;; Set the `syntax-table' property for each start/end region. - (while syntactic-properties - (setq plist (list 'syntax-table (car (car syntactic-properties))) - regions (cdr (car syntactic-properties)) - syntactic-properties (cdr syntactic-properties)) - (while regions - (add-text-properties (nth 0 regions) (nth 1 regions) plist) - (setq regions (nthcdr 2 regions)))) - ;; - ;; Set the `face' property for each start/end region. - (while face-properties - (setq plist (list 'face (car (car face-properties))) - regions (cdr (car face-properties)) - face-properties (cdr face-properties)) - (while regions - (add-text-properties (nth 0 regions) (nth 1 regions) plist) - (setq regions (nthcdr 2 regions))))))) - -;; Functions for XEmacs: - -(when (save-match-data (string-match "XEmacs" (emacs-version))) - ;; - ;; It would be better to use XEmacs' `map-extents' over extents with a - ;; `font-lock' property, but `face' properties are on different extents. - (defun fast-lock-get-face-properties () - "Return a list of `face' text properties in the current buffer. -Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) -where VALUE is a `face' property value and STARTx and ENDx are positions. -Only those `face' VALUEs in `fast-lock-save-faces' are returned." - (save-restriction - (widen) - (let ((properties ()) cell) - (map-extents - (function (lambda (extent ignore) - (let ((value (extent-face extent))) - ;; We're only interested if it's one of `fast-lock-save-faces'. - (when (and value (fast-lock-save-facep value)) - (let ((start (extent-start-position extent)) - (end (extent-end-position extent))) - ;; Make or add to existing list of regions with the same - ;; `face' property value. - (if (setq cell (assoc value properties)) - (setcdr cell (cons start (cons end (cdr cell)))) - (push (list value start end) properties)))) - ;; Return nil to keep `map-extents' going. - nil)))) - properties))) - ;; - ;; XEmacs does not support the `syntax-table' text property. - (defalias 'fast-lock-get-syntactic-properties - 'ignore) - ;; - ;; Make extents just like XEmacs' font-lock.el does. - (defun fast-lock-add-properties (syntactic-properties face-properties) - "Set `face' text properties in the current buffer. -Any existing `face' text properties are removed first. -See `fast-lock-get-face-properties'." - (save-restriction - (widen) - (font-lock-unfontify-region (point-min) (point-max)) - ;; Set the `face' property, etc., for each start/end region. - (while face-properties - (let ((face (car (car face-properties))) - (regions (cdr (car face-properties)))) - (while regions - (font-lock-set-face (nth 0 regions) (nth 1 regions) face) - (setq regions (nthcdr 2 regions))) - (setq face-properties (cdr face-properties)))) - ;; XEmacs does not support the `syntax-table' text property. - )) - ;; - ;; XEmacs 19.12 font-lock.el's `font-lock-fontify-buffer' runs a hook. - (add-hook 'font-lock-after-fontify-buffer-hook - 'fast-lock-after-fontify-buffer)) - -(unless (boundp 'font-lock-syntactic-keywords) - (defvar font-lock-syntactic-keywords nil)) - -(unless (boundp 'font-lock-inhibit-thing-lock) - (defvar font-lock-inhibit-thing-lock nil)) - -(unless (fboundp 'font-lock-compile-keywords) - (defalias 'font-lock-compile-keywords 'identity)) - -(unless (fboundp 'font-lock-eval-keywords) - (defun font-lock-eval-keywords (keywords) - (if (symbolp keywords) - (font-lock-eval-keywords (if (fboundp keywords) - (funcall keywords) - (eval keywords))) - keywords))) - -(unless (fboundp 'font-lock-value-in-major-mode) - (defun font-lock-value-in-major-mode (alist) - (if (consp alist) - (cdr (or (assq major-mode alist) (assq t alist))) - alist))) - -(unless (fboundp 'current-message) - (defun current-message () - "")) - -;; Install ourselves: - -(add-hook 'after-save-hook 'fast-lock-save-cache-after-save-file) -(add-hook 'kill-buffer-hook 'fast-lock-save-cache-before-kill-buffer) -(add-hook 'kill-emacs-hook 'fast-lock-save-caches-before-kill-emacs) - -;;;###autoload -(when (fboundp 'add-minor-mode) - (defvar fast-lock-mode nil) - (add-minor-mode 'fast-lock-mode nil)) -;;;###dont-autoload -(unless (assq 'fast-lock-mode minor-mode-alist) - (setq minor-mode-alist (append minor-mode-alist '((fast-lock-mode nil))))) - -;; Provide ourselves: - -(provide 'fast-lock) - -;;; arch-tag: 638c431e-8cae-4538-80a1-963ff97d233e -;;; fast-lock.el ends here
--- a/lisp/ffap.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/ffap.el Fri Apr 08 16:25:22 2005 +0000 @@ -217,10 +217,13 @@ "*A regexp matching filename wildcard characters, or nil. If `find-file-at-point' gets a filename matching this pattern, -it passes it on to `find-file' with non-nil WILDCARDS argument, -which expands wildcards and visits multiple files. To visit -a file whose name contains wildcard characters you can suppress -wildcard expansion by setting `find-file-wildcards'. +and `ffap-pass-wildcards-to-dired' is nil, it passes it on to +`find-file' with non-nil WILDCARDS argument, which expands +wildcards and visits multiple files. To visit a file whose name +contains wildcard characters you can suppress wildcard expansion +by setting `find-file-wildcards'. If `find-file-at-point' gets a +filename matching this pattern and `ffap-pass-wildcards-to-dired' +is non-nil, it passes it on to `dired'. If `dired-at-point' gets a filename matching this pattern, it passes it on to `dired'." @@ -230,6 +233,11 @@ ) :group 'ffap) +(defcustom ffap-pass-wildcards-to-dired nil + "*If non-nil, pass filenames matching `ffap-dired-wildcards' to dired." + :type 'boolean + :group 'ffap) + (defcustom ffap-newfile-prompt nil ;; Suggestion from RHOGEE, 11 Jul 1994. Disabled, I think this is ;; better handled by `find-file-not-found-hooks'. @@ -1386,6 +1394,10 @@ ((ffap-url-p filename) (let (current-prefix-arg) ; w3 2.3.25 bug, reported by KPC (funcall ffap-url-fetcher filename))) + ((and ffap-pass-wildcards-to-dired + ffap-dired-wildcards + (string-match ffap-dired-wildcards filename)) + (funcall ffap-directory-finder filename)) ((and ffap-dired-wildcards (string-match ffap-dired-wildcards filename) find-file-wildcards
--- a/lisp/generic-x.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/generic-x.el Fri Apr 08 16:25:22 2005 +0000 @@ -1616,7 +1616,7 @@ (((class color) (background dark)) (:background "red")) (t (:weight bold))) "Font Lock mode face used to highlight TABs." - :group 'show-tabs) + :group 'generic-x) (defface show-tabs-space-face '((((class grayscale) (background light)) (:background "DimGray" :weight bold)) @@ -1625,7 +1625,7 @@ (((class color) (background dark)) (:background "yellow")) (t (:weight bold))) "Font Lock mode face used to highlight spaces." - :group 'show-tabs) + :group 'generic-x) (define-generic-mode show-tabs-generic-mode nil ;; no comment char
--- a/lisp/generic.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/generic.el Fri Apr 08 16:25:22 2005 +0000 @@ -219,12 +219,14 @@ The optional CUSTOM-KEYWORD-ARGS are pairs of keywords and values. They will be passed to the generated `defcustom' form of -the mode hook variable MODE-hook. You can specify keyword -arguments without specifying a docstring. +the mode hook variable MODE-hook. Defaults to MODE without the +possible trailing \"-mode\". (This default may not be a valid +customization group defined with `defgroup'. Make sure it is.) +You can specify keyword arguments without specifying a docstring. See the file generic-x.el for some examples of `define-generic-mode'." (declare (debug (sexp def-form def-form def-form form def-form - &optional stringp)) + [&optional stringp] &rest [keywordp form])) (indent 1)) ;; Backward compatibility. @@ -237,21 +239,20 @@ (push docstring custom-keyword-args) (setq docstring nil)) - (let* ((mode-name (symbol-name mode)) + (let* ((name (symbol-name mode)) (pretty-name (capitalize (replace-regexp-in-string - "-mode\\'" "" mode-name))) - (mode-hook (intern (concat mode-name "-hook")))) + "-mode\\'" "" name))) + (mode-hook (intern (concat name "-hook")))) (unless (plist-get custom-keyword-args :group) (setq custom-keyword-args (plist-put custom-keyword-args - :group `(or (custom-current-group) - ',(intern (replace-regexp-in-string - "-mode\\'" "" mode-name)))))) + :group `',(intern (replace-regexp-in-string + "-mode\\'" "" name))))) `(progn ;; Add a new entry. - (add-to-list 'generic-mode-list ,mode-name) + (add-to-list 'generic-mode-list ,name) ;; Add it to auto-mode-alist (dolist (re ,auto-mode-list) @@ -274,10 +275,10 @@ (defun generic-mode-internal (mode comment-list keyword-list font-lock-list function-list) "Go into the generic mode MODE." - (let* ((mode-name (symbol-name mode)) + (let* ((name (symbol-name mode)) (pretty-name (capitalize (replace-regexp-in-string - "-mode\\'" "" mode-name))) - (mode-hook (intern (concat mode-name "-hook")))) + "-mode\\'" "" name))) + (mode-hook (intern (concat name "-hook")))) (kill-all-local-variables)
--- a/lisp/gnus/ChangeLog Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/gnus/ChangeLog Fri Apr 08 16:25:22 2005 +0000 @@ -1,7 +1,22 @@ +2005-04-04 Reiner Steib <Reiner.Steib@gmx.de> + + * message.el (message-make-date): Add defvars in order to silence + the byte compiler inside the defun. + + * nnimap.el (nnimap-date-days-ago): Ditto. + + * gnus-demon.el (parse-time-string): Added autoload. + + * gnus-delay.el (parse-time-string): Added autoload. + + * gnus-art.el (parse-time-string): Added autoload. + + * nnultimate.el (parse-time): Require for `parse-time-string'. + 2005-04-03 Katsumi Yamaoka <yamaoka@jpl.org> - * gnus-sum.el (gnus-summary-make-menu-bar): Fix an - "unrecognised menu descriptor" error. + * gnus-sum.el (gnus-summary-make-menu-bar): Avoid the + "Unrecognized menu descriptor" error in XEmacs. 2005-03-25 Katsumi Yamaoka <yamaoka@jpl.org>
--- a/lisp/gnus/gnus-art.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/gnus/gnus-art.el Fri Apr 08 16:25:22 2005 +0000 @@ -46,6 +46,7 @@ (autoload 'gnus-msg-mail "gnus-msg" nil t) (autoload 'gnus-button-mailto "gnus-msg") (autoload 'gnus-button-reply "gnus-msg" nil t) +(autoload 'parse-time-string "parse-time" nil nil) (defgroup gnus-article nil "Article display."
--- a/lisp/gnus/gnus-delay.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/gnus/gnus-delay.el Fri Apr 08 16:25:22 2005 +0000 @@ -37,6 +37,7 @@ (require 'nndraft) (require 'gnus-draft) +(autoload 'parse-time-string "parse-time" nil nil) ;;;###autoload (defgroup gnus-delay nil
--- a/lisp/gnus/gnus-demon.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/gnus/gnus-demon.el Fri Apr 08 16:25:22 2005 +0000 @@ -40,6 +40,8 @@ (require 'itimer) (require 'timer))) +(autoload 'parse-time-string "parse-time" nil nil) + (defgroup gnus-demon nil "Demonic behaviour." :group 'gnus)
--- a/lisp/gnus/message.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/gnus/message.el Fri Apr 08 16:25:22 2005 +0000 @@ -4568,6 +4568,8 @@ "Make a valid data header. If NOW, use that time instead." (require 'parse-time) + (defvar parse-time-weekdays) + (defvar parse-time-months) (let* ((now (or now (current-time))) (zone (nth 8 (decode-time now))) (sign "+"))
--- a/lisp/gnus/nnimap.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/gnus/nnimap.el Fri Apr 08 16:25:22 2005 +0000 @@ -1388,6 +1388,8 @@ (defun nnimap-date-days-ago (daysago) "Return date, in format \"3-Aug-1998\", for DAYSAGO days ago." + (require 'parse-time) + (defvar parse-time-months) (let* ((time (nnimap-time-substract (current-time) (days-to-time daysago))) (date (format-time-string (format "%%d-%s-%%Y"
--- a/lisp/gnus/nnultimate.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/gnus/nnultimate.el Fri Apr 08 16:25:22 2005 +0000 @@ -39,6 +39,7 @@ (require 'mm-util) (require 'mm-url) (require 'nnweb) +(require 'parse-time) (autoload 'w3-parse-buffer "w3-parse") (nnoo-declare nnultimate)
--- a/lisp/ielm.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/ielm.el Fri Apr 08 16:25:22 2005 +0000 @@ -65,7 +65,7 @@ \(add-hook 'ielm-mode-hook '(lambda () - (define-key ielm-map \"\C-w\" 'comint-kill-region) + (define-key ielm-map \"\\C-w\" 'comint-kill-region) (define-key ielm-map [C-S-backspace] 'comint-kill-whole-line)))
--- a/lisp/info.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/info.el Fri Apr 08 16:25:22 2005 +0000 @@ -3240,6 +3240,7 @@ (setq line-move-ignore-invisible t) (make-local-variable 'desktop-save-buffer) (setq desktop-save-buffer 'Info-desktop-buffer-misc-data) + (add-hook 'kill-buffer-hook 'Info-kill-buffer nil t) (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t) (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) (add-hook 'isearch-mode-hook 'Info-isearch-start nil t) @@ -3254,6 +3255,13 @@ (Info-set-mode-line) (run-hooks 'Info-mode-hook)) +;; When an Info buffer is killed, make sure the associated tags buffer +;; is killed too. +(defun Info-kill-buffer () + (and (eq major-mode 'Info-mode) + Info-tag-table-buffer + (kill-buffer Info-tag-table-buffer))) + (defun Info-clone-buffer-hook () (when (bufferp Info-tag-table-buffer) (setq Info-tag-table-buffer @@ -3887,16 +3895,6 @@ (set-buffer-modified-p nil)))) - -;; When an Info buffer is killed, make sure the associated tags buffer -;; is killed too. -(defun Info-kill-buffer () - (and (eq major-mode 'Info-mode) - Info-tag-table-buffer - (kill-buffer Info-tag-table-buffer))) - -(add-hook 'kill-buffer-hook 'Info-kill-buffer) - ;;; Speedbar support: ;; These functions permit speedbar to display the "tags" in the ;; current info node.
--- a/lisp/lazy-lock.el Mon Apr 04 16:43:15 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1054 +0,0 @@ -;;; lazy-lock.el --- lazy demand-driven fontification for fast Font Lock mode - -;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 2001 -;; Free Software Foundation, Inc. - -;; Author: Simon Marshall <simon@gnu.org> -;; Maintainer: FSF -;; Keywords: faces files -;; Version: 2.11 - -;; 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, 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 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: - -;; Purpose: -;; -;; Lazy Lock mode is a Font Lock support mode. -;; It makes visiting buffers in Font Lock mode faster by making fontification -;; be demand-driven, deferred and stealthy, so that fontification only occurs -;; when, and where, necessary. -;; -;; See caveats and feedback below. -;; See also the fast-lock package. (But don't use them at the same time!) - -;; Installation: -;; -;; Put in your ~/.emacs: -;; -;; (setq font-lock-support-mode 'lazy-lock-mode) -;; -;; Start up a new Emacs and use font-lock as usual (except that you can use the -;; so-called "gaudier" fontification regexps on big files without frustration). -;; -;; In a buffer (which has `font-lock-mode' enabled) which is at least -;; `lazy-lock-minimum-size' characters long, buffer fontification will not -;; occur and only the visible portion of the buffer will be fontified. Motion -;; around the buffer will fontify those visible portions not previously -;; fontified. If stealth fontification is enabled, buffer fontification will -;; occur in invisible parts of the buffer after `lazy-lock-stealth-time' -;; seconds of idle time. If on-the-fly fontification is deferred, on-the-fly -;; fontification will occur after `lazy-lock-defer-time' seconds of idle time. - -;; User-visible differences with version 1: -;; -;; - Version 2 can defer on-the-fly fontification. Therefore you need not, and -;; should not, use defer-lock.el with this version of lazy-lock.el. -;; -;; A number of variables have changed meaning: -;; -;; - A value of nil for the variable `lazy-lock-minimum-size' means never turn -;; on demand-driven fontification. In version 1 this meant always turn on -;; demand-driven fontification. If you really want demand-driven fontification -;; regardless of buffer size, set this variable to 0. -;; -;; - The variable `lazy-lock-stealth-lines' cannot have a nil value. In -;; version 1 this meant use `window-height' as the maximum number of lines to -;; fontify as a stealth chunk. This makes no sense; stealth fontification is -;; of a buffer, not a window. - -;; Implementation differences with version 1: -;; -;; - Version 1 of lazy-lock.el is a bit of a hack. Version 1 demand-driven -;; fontification, the core feature of lazy-lock.el, is implemented by placing a -;; function on `post-command-hook'. This function fontifies where necessary, -;; i.e., where a window scroll has occurred. However, there are a number of -;; problems with using `post-command-hook': -;; -;; (a) As the name suggests, `post-command-hook' is run after every command, -;; i.e., frequently and regardless of whether scrolling has occurred. -;; (b) Scrolling can occur during a command, when `post-command-hook' is not -;; run, i.e., it is not necessarily run after scrolling has occurred. -;; (c) When `post-command-hook' is run, there is nothing to suggest where -;; scrolling might have occurred, i.e., which windows have scrolled. -;; -;; Thus lazy-lock.el's function is called almost as often as possible, usually -;; when it need not be called, yet it is not always called when it is needed. -;; Also, lazy-lock.el's function must check each window to see if a scroll has -;; occurred there. Worse still, lazy-lock.el's function must fontify a region -;; twice as large as necessary to make sure the window is completely fontified. -;; Basically, `post-command-hook' is completely inappropriate for lazy-lock.el. -;; -;; Ideally, we want to attach lazy-lock.el's function to a hook that is run -;; only when scrolling occurs, e.g., `window-start' has changed, and tells us -;; as much information as we need, i.e., the window and its new buffer region. -;; Richard Stallman implemented a `window-scroll-functions' for Emacs 19.30. -;; Functions on it are run when `window-start' has changed, and are supplied -;; with the window and the window's new `window-start' position. (It would be -;; better if it also supplied the window's new `window-end' position, but that -;; is calculated as part of the redisplay process, and the functions on -;; `window-scroll-functions' are run before redisplay has finished.) Thus, the -;; hook deals with the above problems (a), (b) and (c). -;; -;; If only life was that easy. Version 2 demand-driven fontification is mostly -;; implemented by placing a function on `window-scroll-functions'. However, -;; not all scrolling occurs when `window-start' has changed. A change in -;; window size, e.g., via C-x 1, or a significant deletion, e.g., of a number -;; of lines, causes text previously invisible (i.e., after `window-end') to -;; become visible without changing `window-start'. Arguably, these events are -;; not scrolling events, but fontification must occur for lazy-lock.el to work. -;; Hooks `window-size-change-functions' and `redisplay-end-trigger-functions' -;; were added for these circumstances. -;; -;; (Ben Wing thinks these hooks are "horribly horribly kludgy", and implemented -;; a `pre-idle-hook', a `mother-of-all-post-command-hooks', for XEmacs 19.14. -;; He then hacked up a version 1 lazy-lock.el to use `pre-idle-hook' rather -;; than `post-command-hook'. Whereas functions on `post-command-hook' are -;; called almost as often as possible, functions on `pre-idle-hook' really are -;; called as often as possible, even when the mouse moves and, on some systems, -;; while XEmacs is idle. Thus, the hook deals with the above problem (b), but -;; unfortunately it makes (a) worse and does not address (c) at all. -;; -;; I freely admit that `redisplay-end-trigger-functions' and, to a much lesser -;; extent, `window-size-change-functions' are not pretty. However, I feel that -;; a `window-scroll-functions' feature is cleaner than a `pre-idle-hook', and -;; the result is faster and smaller, less intrusive and more targeted, code. -;; Since `pre-idle-hook' is pretty much like `post-command-hook', there is no -;; point in making this version of lazy-lock.el work with it. Anyway, that's -;; Lit 30 of my humble opinion. -;; -;; - Version 1 stealth fontification is also implemented by placing a function -;; on `post-command-hook'. This function waits for a given amount of time, -;; and, if Emacs remains idle, fontifies where necessary. Again, there are a -;; number of problems with using `post-command-hook': -;; -;; (a) Functions on `post-command-hook' are run sequentially, so this function -;; can interfere with other functions on the hook, and vice versa. -;; (b) This function waits for a given amount of time, so it can interfere with -;; various features that are dealt with by Emacs after a command, e.g., -;; region highlighting, asynchronous updating and keystroke echoing. -;; (c) Fontification may be required during a command, when `post-command-hook' -;; is not run. (Version 2 deferred fontification only.) -;; -;; Again, `post-command-hook' is completely inappropriate for lazy-lock.el. -;; Richard Stallman and Morten Welinder implemented internal Timers and Idle -;; Timers for Emacs 19.31. Functions can be run independently at given times -;; or after given amounts of idle time. Thus, the feature deals with the above -;; problems (a), (b) and (c). Version 2 deferral and stealth are implemented -;; by functions on Idle Timers. (A function on XEmacs' `pre-idle-hook' is -;; similar to an Emacs Idle Timer function with a fixed zero second timeout.) - -;; - Version 1 has the following problems (relative to version 2): -;; -;; (a) It is slow when it does its job. -;; (b) It does not always do its job when it should. -;; (c) It slows all interaction (when it doesn't need to do its job). -;; (d) It interferes with other package functions on `post-command-hook'. -;; (e) It interferes with Emacs things within the read-eval loop. -;; -;; Ben's hacked-up lazy-lock.el 1.14 almost solved (b) but made (c) worse. -;; -;; - Version 2 has the following additional features (relative to version 1): -;; -;; (a) It can defer fontification (both on-the-fly and on-scrolling). -;; (b) It can fontify contextually (syntactically true on-the-fly). - -;; Caveats: -;; -;; Lazy Lock mode does not work efficiently with Outline mode. -;; This is because when in Outline mode, although text may be not visible to -;; you in the window, the text is visible to Emacs Lisp code (not surprisingly) -;; and Lazy Lock fontifies it mercilessly. Maybe it will be fixed one day. -;; -;; Because buffer text is not necessarily fontified, other packages that expect -;; buffer text to be fontified in Font Lock mode either might not work as -;; expected, or might not display buffer text as expected. An example of the -;; latter is `occur', which copies lines of buffer text into another buffer. -;; -;; In Emacs 19.30, Lazy Lock mode does not ensure that an existing buffer is -;; fontified if it is made visible via a minibuffer-less command that replaces -;; an existing window's buffer (e.g., via the Buffers menu). Upgrade! -;; -;; In Emacs 19.30, Lazy Lock mode does not work well with Transient Mark mode -;; or modes based on Comint mode (e.g., Shell mode), and also interferes with -;; the echoing of keystrokes in the minibuffer. This is because of the way -;; deferral and stealth have to be implemented for Emacs 19.30. Upgrade! -;; -;; Currently XEmacs does not have the features to support this version of -;; lazy-lock.el. Maybe it will one day. - -;; History: -;; -;; 1.15--2.00: -;; - Rewrite for Emacs 19.30 and the features rms added to support lazy-lock.el -;; so that it could work correctly and efficiently. -;; - Many thanks to those who reported bugs, fixed bugs, made suggestions or -;; otherwise contributed in the version 1 cycle; Jari Aalto, Kevin Broadey, -;; Ulrik Dickow, Bill Dubuque, Bob Glickstein, Boris Goldowsky, -;; Jonas Jarnestrom, David Karr, Michael Kifer, Erik Naggum, Rick Sladkey, -;; Jim Thompson, Ben Wing, Ilya Zakharevich, and Richard Stallman. -;; 2.00--2.01: -;; - Made `lazy-lock-fontify-after-command' always `sit-for' and so redisplay -;; - Use `buffer-name' not `buffer-live-p' (Bill Dubuque hint) -;; - Made `lazy-lock-install' do `add-to-list' not `setq' of `current-buffer' -;; - Made `lazy-lock-fontify-after-install' loop over buffer list -;; - Made `lazy-lock-arrange-before-change' to arrange `window-end' triggering -;; - Made `lazy-lock-let-buffer-state' wrap both `befter-change-functions' -;; - Made `lazy-lock-fontify-region' do `condition-case' (Hyman Rosen report) -;; 2.01--2.02: -;; - Use `buffer-live-p' as `buffer-name' can barf (Richard Stanton report) -;; - Made `lazy-lock-install' set `font-lock-fontified' (Kevin Davidson report) -;; - Made `lazy-lock-install' add hooks only if needed -;; - Made `lazy-lock-unstall' add `font-lock-after-change-function' if needed -;; 2.02--2.03: -;; - Made `lazy-lock-fontify-region' do `condition-case' for `quit' too -;; - Made `lazy-lock-mode' respect the value of `font-lock-inhibit-thing-lock' -;; - Added `lazy-lock-after-unfontify-buffer' -;; - Removed `lazy-lock-fontify-after-install' hack -;; - Made `lazy-lock-fontify-after-scroll' not `set-buffer' to `window-buffer' -;; - Made `lazy-lock-fontify-after-trigger' not `set-buffer' to `window-buffer' -;; - Made `lazy-lock-fontify-after-idle' be interruptible (Scott Burson hint) -;; 2.03--2.04: -;; - Rewrite for Emacs 19.31 idle timers -;; - Renamed `buffer-windows' to `get-buffer-window-list' -;; - Removed `buffer-live-p' -;; - Made `lazy-lock-defer-after-change' always save `current-buffer' -;; - Made `lazy-lock-fontify-after-defer' just process buffers -;; - Made `lazy-lock-install-hooks' add hooks correctly (Kevin Broadey report) -;; - Made `lazy-lock-install' cope if `lazy-lock-defer-time' is a list -;; 2.04--2.05: -;; - Rewrite for Common Lisp macros -;; - Added `do-while' macro -;; - Renamed `lazy-lock-let-buffer-state' macro to `save-buffer-state' -;; - Returned `lazy-lock-fontify-after-install' hack (Darren Hall hint) -;; - Added `lazy-lock-defer-on-scrolling' functionality (Scott Byer hint) -;; - Made `lazy-lock-mode' wrap `font-lock-support-mode' -;; 2.05--2.06: -;; - Made `lazy-lock-fontify-after-defer' swap correctly (Scott Byer report) -;; 2.06--2.07: -;; - Added `lazy-lock-stealth-load' functionality (Rob Hooft hint) -;; - Made `lazy-lock-unstall' call `lazy-lock-fontify-region' if needed -;; - Made `lazy-lock-mode' call `lazy-lock-unstall' only if needed -;; - Made `lazy-lock-defer-after-scroll' do `set-window-redisplay-end-trigger' -;; - Added `lazy-lock-defer-contextually' functionality -;; - Added `lazy-lock-defer-on-the-fly' from `lazy-lock-defer-time' -;; - Renamed `lazy-lock-defer-driven' to `lazy-lock-defer-on-scrolling' -;; - Removed `lazy-lock-submit-bug-report' and bade farewell -;; 2.07--2.08: -;; - Made `lazy-lock-fontify-conservatively' fontify around `window-point' -;; - Made `save-buffer-state' wrap `inhibit-point-motion-hooks' -;; - Added Custom support -;; 2.08--2.09: -;; - Removed `byte-*' variables from `eval-when-compile' (Erik Naggum hint) -;; - Made various wrapping `inhibit-point-motion-hooks' (Vinicius Latorre hint) -;; - Made `lazy-lock-fontify-after-idle' wrap `minibuffer-auto-raise' -;; - Made `lazy-lock-fontify-after-defer' paranoid about deferred buffers -;; 2.09--2.10: -;; - Use `window-end' UPDATE arg for Emacs 20.4 and later. -;; - Made deferral `widen' before unfontifying (Dan Nicolaescu report) -;; - Use `lazy-lock-fontify-after-visage' for hideshow.el (Dan Nicolaescu hint) -;; - Use `other' widget where possible (Andreas Schwab fix) -;; 2.10--2.11: -;; - Used `with-temp-message' where possible to make messages temporary. - -;;; Code: - -(require 'font-lock) - -(eval-when-compile - ;; We don't do this at the top-level as we only use non-autoloaded macros. - (require 'cl) - ;; - ;; We use this to preserve or protect things when modifying text properties. - (defmacro save-buffer-state (varlist &rest body) - "Bind variables according to VARLIST and eval BODY restoring buffer state." - `(let* (,@(append varlist - '((modified (buffer-modified-p)) - (buffer-undo-list t) - (inhibit-read-only t) - (inhibit-point-motion-hooks t) - (inhibit-modification-hooks t) - deactivate-mark - buffer-file-name - buffer-file-truename))) - ,@body - (when (and (not modified) (buffer-modified-p)) - (restore-buffer-modified-p nil)))) - (put 'save-buffer-state 'lisp-indent-function 1) - ;; - ;; We use this for clarity and speed. Naughty but nice. - (defmacro do-while (test &rest body) - "(do-while TEST BODY...): eval BODY... and repeat if TEST yields non-nil. -The order of execution is thus BODY, TEST, BODY, TEST and so on -until TEST returns nil." - `(while (progn ,@body ,test))) - (put 'do-while 'lisp-indent-function (get 'while 'lisp-indent-function))) - -(defvar lazy-lock-mode nil) ; Whether we are turned on. -(defvar lazy-lock-buffers nil) ; For deferral. -(defvar lazy-lock-timers (cons nil nil)) ; For deferral and stealth. - -;; User Variables: - -(defcustom lazy-lock-minimum-size 25600 - "*Minimum size of a buffer for demand-driven fontification. -On-demand fontification occurs if the buffer size is greater than this value. -If nil, means demand-driven fontification is never performed. -If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE), -where MAJOR-MODE is a symbol or t (meaning the default). For example: - ((c-mode . 25600) (c++-mode . 25600) (rmail-mode . 1048576)) -means that the minimum size is 25K for buffers in C or C++ modes, one megabyte -for buffers in Rmail mode, and size is irrelevant otherwise. - -The value of this variable is used when Lazy Lock mode is turned on." - :type '(choice (const :tag "none" nil) - (integer :tag "size") - (repeat :menu-tag "mode specific" :tag "mode specific" - :value ((t . nil)) - (cons :tag "Instance" - (radio :tag "Mode" - (const :tag "all" t) - (symbol :tag "name")) - (radio :tag "Size" - (const :tag "none" nil) - (integer :tag "size"))))) - :group 'lazy-lock) - -(defcustom lazy-lock-defer-on-the-fly t - "*If non-nil, means fontification after a change should be deferred. -If nil, means on-the-fly fontification is performed. This means when changes -occur in the buffer, those areas are immediately fontified. -If a list, it should be a list of `major-mode' symbol names for which deferred -fontification should occur. The sense of the list is negated if it begins with -`not'. For example: - (c-mode c++-mode) -means that on-the-fly fontification is deferred for buffers in C and C++ modes -only, and deferral does not occur otherwise. - -The value of this variable is used when Lazy Lock mode is turned on." - :type '(choice (const :tag "never" nil) - (const :tag "always" t) - (set :menu-tag "mode specific" :tag "modes" - :value (not) - (const :tag "Except" not) - (repeat :inline t (symbol :tag "mode")))) - :group 'lazy-lock) - -(defcustom lazy-lock-defer-on-scrolling nil - "*If non-nil, means fontification after a scroll should be deferred. -If nil, means demand-driven fontification is performed. This means when -scrolling into unfontified areas of the buffer, those areas are immediately -fontified. Thus scrolling never presents unfontified areas. However, since -fontification occurs during scrolling, scrolling may be slow. -If t, means defer-driven fontification is performed. This means fontification -of those areas is deferred. Thus scrolling may present momentarily unfontified -areas. However, since fontification does not occur during scrolling, scrolling -will be faster than demand-driven fontification. -If any other value, e.g., `eventually', means demand-driven fontification is -performed until the buffer is fontified, then buffer fontification becomes -defer-driven. Thus scrolling never presents unfontified areas until the buffer -is first fontified, after which subsequent scrolling may present future buffer -insertions momentarily unfontified. However, since fontification does not -occur during scrolling after the buffer is first fontified, scrolling will -become faster. (But, since contextual changes continually occur, such a value -makes little sense if `lazy-lock-defer-contextually' is non-nil.) - -The value of this variable is used when Lazy Lock mode is turned on." - :type '(choice (const :tag "never" nil) - (const :tag "always" t) - (other :tag "eventually" eventually)) - :group 'lazy-lock) - -(defcustom lazy-lock-defer-contextually 'syntax-driven - "*If non-nil, means deferred fontification should be syntactically true. -If nil, means deferred fontification occurs only on those lines modified. This -means where modification on a line causes syntactic change on subsequent lines, -those subsequent lines are not refontified to reflect their new context. -If t, means deferred fontification occurs on those lines modified and all -subsequent lines. This means those subsequent lines are refontified to reflect -their new syntactic context, either immediately or when scrolling into them. -If any other value, e.g., `syntax-driven', means deferred syntactically true -fontification occurs only if syntactic fontification is performed using the -buffer mode's syntax table, i.e., only if `font-lock-keywords-only' is nil. - -The value of this variable is used when Lazy Lock mode is turned on." - :type '(choice (const :tag "never" nil) - (const :tag "always" t) - (other :tag "syntax-driven" syntax-driven)) - :group 'lazy-lock) - -(defcustom lazy-lock-defer-time - (if (featurep 'lisp-float-type) (/ (float 1) (float 4)) 1) - "*Time in seconds to delay before beginning deferred fontification. -Deferred fontification occurs if there is no input within this time. -If nil, means fontification is never deferred, regardless of the values of the -variables `lazy-lock-defer-on-the-fly', `lazy-lock-defer-on-scrolling' and -`lazy-lock-defer-contextually'. - -The value of this variable is used when Lazy Lock mode is turned on." - :type '(choice (const :tag "never" nil) - (number :tag "seconds")) - :group 'lazy-lock) - -(defcustom lazy-lock-stealth-time 30 - "*Time in seconds to delay before beginning stealth fontification. -Stealth fontification occurs if there is no input within this time. -If nil, means stealth fontification is never performed. - -The value of this variable is used when Lazy Lock mode is turned on." - :type '(choice (const :tag "never" nil) - (number :tag "seconds")) - :group 'lazy-lock) - -(defcustom lazy-lock-stealth-lines (if font-lock-maximum-decoration 100 250) - "*Maximum size of a chunk of stealth fontification. -Each iteration of stealth fontification can fontify this number of lines. -To speed up input response during stealth fontification, at the cost of stealth -taking longer to fontify, you could reduce the value of this variable." - :type '(integer :tag "lines") - :group 'lazy-lock) - -(defcustom lazy-lock-stealth-load - (if (condition-case nil (load-average) (error)) 200) - "*Load in percentage above which stealth fontification is suspended. -Stealth fontification pauses when the system short-term load average (as -returned by the function `load-average' if supported) goes above this level, -thus reducing the demand that stealth fontification makes on the system. -If nil, means stealth fontification is never suspended. -To reduce machine load during stealth fontification, at the cost of stealth -taking longer to fontify, you could reduce the value of this variable. -See also `lazy-lock-stealth-nice'." - :type (if (condition-case nil (load-average) (error)) - '(choice (const :tag "never" nil) - (integer :tag "load")) - '(const :format "%t: unsupported\n" nil)) - :group 'lazy-lock) - -(defcustom lazy-lock-stealth-nice - (if (featurep 'lisp-float-type) (/ (float 1) (float 8)) 1) - "*Time in seconds to pause between chunks of stealth fontification. -Each iteration of stealth fontification is separated by this amount of time, -thus reducing the demand that stealth fontification makes on the system. -If nil, means stealth fontification is never paused. -To reduce machine load during stealth fontification, at the cost of stealth -taking longer to fontify, you could increase the value of this variable. -See also `lazy-lock-stealth-load'." - :type '(choice (const :tag "never" nil) - (number :tag "seconds")) - :group 'lazy-lock) - -(defcustom lazy-lock-stealth-verbose - (if (featurep 'lisp-float-type) - (and (not lazy-lock-defer-contextually) (not (null font-lock-verbose)))) - "*If non-nil, means stealth fontification should show status messages." - :type 'boolean - :group 'lazy-lock) - -;; User Functions: - -;;;###autoload -(defun lazy-lock-mode (&optional arg) - "Toggle Lazy Lock mode. -With arg, turn Lazy Lock mode on if and only if arg is positive. Enable it -automatically in your `~/.emacs' by: - - (setq font-lock-support-mode 'lazy-lock-mode) - -For a newer font-lock support mode with similar functionality, see -`jit-lock-mode'. Eventually, Lazy Lock mode will be deprecated in -JIT Lock's favor. - -When Lazy Lock mode is enabled, fontification can be lazy in a number of ways: - -- Demand-driven buffer fontification if `lazy-lock-minimum-size' is non-nil. - This means initial fontification does not occur if the buffer is greater than - `lazy-lock-minimum-size' characters in length. Instead, fontification occurs - when necessary, such as when scrolling through the buffer would otherwise - reveal unfontified areas. This is useful if buffer fontification is too slow - for large buffers. - -- Deferred scroll fontification if `lazy-lock-defer-on-scrolling' is non-nil. - This means demand-driven fontification does not occur as you scroll. - Instead, fontification is deferred until after `lazy-lock-defer-time' seconds - of Emacs idle time, while Emacs remains idle. This is useful if - fontification is too slow to keep up with scrolling. - -- Deferred on-the-fly fontification if `lazy-lock-defer-on-the-fly' is non-nil. - This means on-the-fly fontification does not occur as you type. Instead, - fontification is deferred until after `lazy-lock-defer-time' seconds of Emacs - idle time, while Emacs remains idle. This is useful if fontification is too - slow to keep up with your typing. - -- Deferred context fontification if `lazy-lock-defer-contextually' is non-nil. - This means fontification updates the buffer corresponding to true syntactic - context, after `lazy-lock-defer-time' seconds of Emacs idle time, while Emacs - remains idle. Otherwise, fontification occurs on modified lines only, and - subsequent lines can remain fontified corresponding to previous syntactic - contexts. This is useful where strings or comments span lines. - -- Stealthy buffer fontification if `lazy-lock-stealth-time' is non-nil. - This means remaining unfontified areas of buffers are fontified if Emacs has - been idle for `lazy-lock-stealth-time' seconds, while Emacs remains idle. - This is useful if any buffer has any deferred fontification. - -Basic Font Lock mode on-the-fly fontification behaviour fontifies modified -lines only. Thus, if `lazy-lock-defer-contextually' is non-nil, Lazy Lock mode -on-the-fly fontification may fontify differently, albeit correctly. In any -event, to refontify some lines you can use \\[font-lock-fontify-block]. - -Stealth fontification only occurs while the system remains unloaded. -If the system load rises above `lazy-lock-stealth-load' percent, stealth -fontification is suspended. Stealth fontification intensity is controlled via -the variable `lazy-lock-stealth-nice' and `lazy-lock-stealth-lines', and -verbosity is controlled via the variable `lazy-lock-stealth-verbose'." - (interactive "P") - (let* ((was-on lazy-lock-mode) - (now-on (unless (memq 'lazy-lock-mode font-lock-inhibit-thing-lock) - (if arg (> (prefix-numeric-value arg) 0) (not was-on))))) - (cond ((and now-on (not font-lock-mode)) - ;; Turned on `lazy-lock-mode' rather than `font-lock-mode'. - (let ((font-lock-support-mode 'lazy-lock-mode)) - (font-lock-mode t))) - (now-on - ;; Turn ourselves on. - (set (make-local-variable 'lazy-lock-mode) t) - (lazy-lock-install)) - (was-on - ;; Turn ourselves off. - (set (make-local-variable 'lazy-lock-mode) nil) - (lazy-lock-unstall))))) - -;;;###autoload -(defun turn-on-lazy-lock () - "Unconditionally turn on Lazy Lock mode." - (lazy-lock-mode t)) - -(defun lazy-lock-install () - (let ((min-size (font-lock-value-in-major-mode lazy-lock-minimum-size)) - (defer-change (and lazy-lock-defer-time lazy-lock-defer-on-the-fly)) - (defer-scroll (and lazy-lock-defer-time lazy-lock-defer-on-scrolling)) - (defer-context (and lazy-lock-defer-time lazy-lock-defer-contextually - (or (eq lazy-lock-defer-contextually t) - (null font-lock-keywords-only))))) - ;; - ;; Tell Font Lock whether Lazy Lock will do fontification. - (make-local-variable 'font-lock-fontified) - (setq font-lock-fontified (and min-size (>= (buffer-size) min-size))) - ;; - ;; Add the text properties and fontify. - (if (not font-lock-fontified) - (lazy-lock-after-fontify-buffer) - ;; Make sure we fontify in any existing windows showing the buffer. - (let ((windows (get-buffer-window-list (current-buffer) 'nomini t))) - (lazy-lock-after-unfontify-buffer) - (while windows - (lazy-lock-fontify-conservatively (car windows)) - (setq windows (cdr windows))))) - ;; - ;; Add the fontification hooks. - (lazy-lock-install-hooks - font-lock-fontified - (cond ((eq (car-safe defer-change) 'not) - (not (memq major-mode (cdr defer-change)))) - ((listp defer-change) - (memq major-mode defer-change)) - (t - defer-change)) - (eq defer-scroll t) - defer-context) - ;; - ;; Add the fontification timers. - (lazy-lock-install-timers - (if (or defer-change defer-scroll defer-context) lazy-lock-defer-time) - lazy-lock-stealth-time))) - -(defun lazy-lock-install-hooks (fontifying - defer-change defer-scroll defer-context) - ;; - ;; Add hook if lazy-lock.el is fontifying on scrolling or is deferring. - (when (or fontifying defer-change defer-scroll defer-context) - (add-hook 'window-scroll-functions (if defer-scroll - 'lazy-lock-defer-after-scroll - 'lazy-lock-fontify-after-scroll) - nil t)) - ;; - ;; Add hook if lazy-lock.el is fontifying and is not deferring changes. - (when (and fontifying (not defer-change) (not defer-context)) - (add-hook 'before-change-functions 'lazy-lock-arrange-before-change nil t)) - ;; - ;; Replace Font Lock mode hook. - (remove-hook 'after-change-functions 'font-lock-after-change-function t) - (add-hook 'after-change-functions - (cond ((and defer-change defer-context) - 'lazy-lock-defer-rest-after-change) - (defer-change - 'lazy-lock-defer-line-after-change) - (defer-context - 'lazy-lock-fontify-rest-after-change) - (t - 'lazy-lock-fontify-line-after-change)) - nil t) - ;; - ;; Add package-specific hook. - (add-hook 'outline-view-change-hook 'lazy-lock-fontify-after-visage nil t) - (add-hook 'hs-hide-hook 'lazy-lock-fontify-after-visage nil t)) - -(defun lazy-lock-install-timers (dtime stime) - ;; Schedule or re-schedule the deferral and stealth timers. - ;; The layout of `lazy-lock-timers' is: - ;; ((DEFER-TIME . DEFER-TIMER) (STEALTH-TIME . STEALTH-TIMER) - ;; If an idle timeout has changed, cancel the existing idle timer (if there - ;; is one) and schedule a new one (if the new idle timeout is non-nil). - (unless (eq dtime (car (car lazy-lock-timers))) - (let ((defer (car lazy-lock-timers))) - (when (cdr defer) - (cancel-timer (cdr defer))) - (setcar lazy-lock-timers (cons dtime (and dtime - (run-with-idle-timer dtime t 'lazy-lock-fontify-after-defer)))))) - (unless (eq stime (car (cdr lazy-lock-timers))) - (let ((stealth (cdr lazy-lock-timers))) - (when (cdr stealth) - (cancel-timer (cdr stealth))) - (setcdr lazy-lock-timers (cons stime (and stime - (run-with-idle-timer stime t 'lazy-lock-fontify-after-idle))))))) - -(defun lazy-lock-unstall () - ;; - ;; If Font Lock mode is still enabled, make sure that the buffer is - ;; fontified, and reinstall its hook. We must do this first. - (when font-lock-mode - (when (lazy-lock-unfontified-p) - (let ((verbose (if (numberp font-lock-verbose) - (> (buffer-size) font-lock-verbose) - font-lock-verbose))) - (with-temp-message - (when verbose - (format "Fontifying %s..." (buffer-name))) - ;; Make sure we fontify etc. in the whole buffer. - (save-restriction - (widen) - (lazy-lock-fontify-region (point-min) (point-max)))))) - (add-hook 'after-change-functions 'font-lock-after-change-function nil t)) - ;; - ;; Remove the text properties. - (lazy-lock-after-unfontify-buffer) - ;; - ;; Remove the fontification hooks. - (remove-hook 'window-scroll-functions 'lazy-lock-fontify-after-scroll t) - (remove-hook 'window-scroll-functions 'lazy-lock-defer-after-scroll t) - (remove-hook 'before-change-functions 'lazy-lock-arrange-before-change t) - (remove-hook 'after-change-functions 'lazy-lock-fontify-line-after-change t) - (remove-hook 'after-change-functions 'lazy-lock-fontify-rest-after-change t) - (remove-hook 'after-change-functions 'lazy-lock-defer-line-after-change t) - (remove-hook 'after-change-functions 'lazy-lock-defer-rest-after-change t) - (remove-hook 'outline-view-change-hook 'lazy-lock-fontify-after-visage t) - (remove-hook 'hs-hide-hook 'lazy-lock-fontify-after-visage t)) - -;; Hook functions. - -;; Lazy Lock mode intervenes when (1) a previously invisible buffer region -;; becomes visible, i.e., for demand- or defer-driven on-the-scroll -;; fontification, (2) a buffer modification occurs, i.e., for defer-driven -;; on-the-fly fontification, (3) Emacs becomes idle, i.e., for fontification of -;; deferred fontification and stealth fontification, and (4) other special -;; occasions. - -;; 1. There are three ways whereby this can happen. -;; -;; (a) Scrolling the window, either explicitly (e.g., `scroll-up') or -;; implicitly (e.g., `search-forward'). Here, `window-start' changes. -;; Fontification occurs by adding `lazy-lock-fontify-after-scroll' (for -;; demand-driven fontification) or `lazy-lock-defer-after-scroll' (for -;; defer-driven fontification) to the hook `window-scroll-functions'. - -(defun lazy-lock-fontify-after-scroll (window window-start) - ;; Called from `window-scroll-functions'. - ;; Fontify WINDOW from WINDOW-START following the scroll. - (let ((inhibit-point-motion-hooks t)) - (lazy-lock-fontify-region window-start (window-end window t))) - ;; A prior deletion that did not cause scrolling, followed by a scroll, would - ;; result in an unnecessary trigger after this if we did not cancel it now. - (set-window-redisplay-end-trigger window nil)) - -(defun lazy-lock-defer-after-scroll (window window-start) - ;; Called from `window-scroll-functions'. - ;; Defer fontification following the scroll. Save the current buffer so that - ;; we subsequently fontify in all windows showing the buffer. - (unless (memq (current-buffer) lazy-lock-buffers) - (push (current-buffer) lazy-lock-buffers)) - ;; A prior deletion that did not cause scrolling, followed by a scroll, would - ;; result in an unnecessary trigger after this if we did not cancel it now. - (set-window-redisplay-end-trigger window nil)) - -;; (b) Resizing the window, either explicitly (e.g., `enlarge-window') or -;; implicitly (e.g., `delete-other-windows'). Here, `window-end' changes. -;; Fontification occurs by adding `lazy-lock-fontify-after-resize' to the -;; hook `window-size-change-functions'. - -(defun lazy-lock-fontify-after-resize (frame) - ;; Called from `window-size-change-functions'. - ;; Fontify windows in FRAME following the resize. We cannot use - ;; `window-start' or `window-end' so we fontify conservatively. - (save-excursion - (save-selected-window - (select-frame frame) - (walk-windows (function (lambda (window) - (set-buffer (window-buffer window)) - (when lazy-lock-mode - (lazy-lock-fontify-conservatively window)) - (set-window-redisplay-end-trigger window nil))) - 'nomini frame)))) - -;; (c) Deletion in the buffer. Here, a `window-end' marker can become visible. -;; Fontification occurs by adding `lazy-lock-arrange-before-change' to -;; `before-change-functions' and `lazy-lock-fontify-after-trigger' to the -;; hook `redisplay-end-trigger-functions'. Before every deletion, the -;; marker `window-redisplay-end-trigger' position is set to the soon-to-be -;; changed `window-end' position. If the marker becomes visible, -;; `lazy-lock-fontify-after-trigger' gets called. Ouch. Note that we only -;; have to deal with this eventuality if there is no on-the-fly deferral. - -(defun lazy-lock-arrange-before-change (beg end) - ;; Called from `before-change-functions'. - ;; Arrange that if text becomes visible it will be fontified (if a deletion - ;; is pending, text might become visible at the bottom). - (unless (eq beg end) - (let ((windows (get-buffer-window-list (current-buffer) 'nomini t)) window) - (while windows - (setq window (car windows)) - (unless (markerp (window-redisplay-end-trigger window)) - (set-window-redisplay-end-trigger window (make-marker))) - (set-marker (window-redisplay-end-trigger window) (window-end window)) - (setq windows (cdr windows)))))) - -(defun lazy-lock-fontify-after-trigger (window trigger-point) - ;; Called from `redisplay-end-trigger-functions'. - ;; Fontify WINDOW from TRIGGER-POINT following the redisplay. - ;; We could probably just use `lazy-lock-fontify-after-scroll' without loss: - ;; (inline (lazy-lock-fontify-after-scroll window (window-start window))) - (let ((inhibit-point-motion-hooks t)) - (lazy-lock-fontify-region trigger-point (window-end window t)))) - -;; 2. Modified text must be marked as unfontified so it can be identified and -;; fontified later when Emacs is idle. Deferral occurs by adding one of -;; `lazy-lock-fontify-*-after-change' (for on-the-fly fontification) or -;; `lazy-lock-defer-*-after-change' (for deferred fontification) to the -;; hook `after-change-functions'. - -(defalias 'lazy-lock-fontify-line-after-change - ;; Called from `after-change-functions'. - ;; Fontify the current change. - 'font-lock-after-change-function) - -(defun lazy-lock-fontify-rest-after-change (beg end old-len) - ;; Called from `after-change-functions'. - ;; Fontify the current change and defer fontification of the rest of the - ;; buffer. Save the current buffer so that we subsequently fontify in all - ;; windows showing the buffer. - (lazy-lock-fontify-line-after-change beg end old-len) - (save-buffer-state nil - (unless (memq (current-buffer) lazy-lock-buffers) - (push (current-buffer) lazy-lock-buffers)) - (save-restriction - (widen) - (remove-text-properties end (point-max) '(lazy-lock nil))))) - -(defun lazy-lock-defer-line-after-change (beg end old-len) - ;; Called from `after-change-functions'. - ;; Defer fontification of the current change. Save the current buffer so - ;; that we subsequently fontify in all windows showing the buffer. - (save-buffer-state nil - (unless (memq (current-buffer) lazy-lock-buffers) - (push (current-buffer) lazy-lock-buffers)) - (remove-text-properties (max (1- beg) (point-min)) - (min (1+ end) (point-max)) - '(lazy-lock nil)))) - -(defun lazy-lock-defer-rest-after-change (beg end old-len) - ;; Called from `after-change-functions'. - ;; Defer fontification of the rest of the buffer. Save the current buffer so - ;; that we subsequently fontify in all windows showing the buffer. - (save-buffer-state nil - (unless (memq (current-buffer) lazy-lock-buffers) - (push (current-buffer) lazy-lock-buffers)) - (save-restriction - (widen) - (remove-text-properties (max (1- beg) (point-min)) - (point-max) - '(lazy-lock nil))))) - -;; 3. Deferred fontification and stealth fontification are done from these two -;; functions. They are set up as Idle Timers. - -(defun lazy-lock-fontify-after-defer () - ;; Called from `timer-idle-list'. - ;; Fontify all windows where deferral has occurred for its buffer. - (save-excursion - (while (and lazy-lock-buffers (not (input-pending-p))) - (let ((buffer (car lazy-lock-buffers)) windows) - ;; Paranoia: check that the buffer is still live and Lazy Lock mode on. - (when (buffer-live-p buffer) - (set-buffer buffer) - (when lazy-lock-mode - (setq windows (get-buffer-window-list buffer 'nomini t)) - (while windows - (lazy-lock-fontify-window (car windows)) - (setq windows (cdr windows))))) - (setq lazy-lock-buffers (cdr lazy-lock-buffers))))) - ;; Add hook if fontification should now be defer-driven in this buffer. - (when (and lazy-lock-mode lazy-lock-defer-on-scrolling - (memq 'lazy-lock-fontify-after-scroll window-scroll-functions) - (not (or (input-pending-p) (lazy-lock-unfontified-p)))) - (remove-hook 'window-scroll-functions 'lazy-lock-fontify-after-scroll t) - (add-hook 'window-scroll-functions 'lazy-lock-defer-after-scroll nil t))) - -(defun lazy-lock-fontify-after-idle () - ;; Called from `timer-idle-list'. - ;; Fontify all buffers that need it, stealthily while idle. - (unless (or executing-kbd-macro (window-minibuffer-p (selected-window))) - ;; Loop over all buffers, fontify stealthily for each if necessary. - (let ((buffers (buffer-list)) (continue t) - message message-log-max minibuffer-auto-raise) - (save-excursion - (do-while (and buffers continue) - (set-buffer (car buffers)) - (if (not (and lazy-lock-mode (lazy-lock-unfontified-p))) - (setq continue (not (input-pending-p))) - ;; Fontify regions in this buffer while there is no input. - (with-temp-message - (when lazy-lock-stealth-verbose - "Fontifying stealthily...") - (do-while (and (lazy-lock-unfontified-p) continue) - (if (and lazy-lock-stealth-load - (> (car (load-average)) lazy-lock-stealth-load)) - ;; Wait a while before continuing with the loop. - (progn - (when message - (message "Fontifying stealthily...suspended") - (setq message nil)) - (setq continue (sit-for (or lazy-lock-stealth-time 30)))) - ;; Fontify a chunk. - (when lazy-lock-stealth-verbose - (if message - (message "Fontifying stealthily... %2d%% of %s" - (lazy-lock-percent-fontified) (buffer-name)) - (message "Fontifying stealthily...") - (setq message t))) - ;; Current buffer may have changed during `sit-for'. - (set-buffer (car buffers)) - (lazy-lock-fontify-chunk) - (setq continue (sit-for (or lazy-lock-stealth-nice 0))))))) - (setq buffers (cdr buffers))))))) - -;; 4. Special circumstances. - -(defun lazy-lock-fontify-after-visage () - ;; Called from `outline-view-change-hook' and `hs-hide-hook'. - ;; Fontify windows showing the current buffer, as its visibility has changed. - ;; This is a conspiracy hack between lazy-lock.el, outline.el and - ;; hideshow.el. - (let ((windows (get-buffer-window-list (current-buffer) 'nomini t))) - (while windows - (lazy-lock-fontify-conservatively (car windows)) - (setq windows (cdr windows))))) - -(defun lazy-lock-after-fontify-buffer () - ;; Called from `font-lock-after-fontify-buffer'. - ;; Mark the current buffer as fontified. - ;; This is a conspiracy hack between lazy-lock.el and font-lock.el. - (save-buffer-state nil - (add-text-properties (point-min) (point-max) '(lazy-lock t)))) - -(defun lazy-lock-after-unfontify-buffer () - ;; Called from `font-lock-after-unfontify-buffer'. - ;; Mark the current buffer as unfontified. - ;; This is a conspiracy hack between lazy-lock.el and font-lock.el. - (save-buffer-state nil - (remove-text-properties (point-min) (point-max) '(lazy-lock nil)))) - -;; Fontification functions. - -;; If packages want to ensure that some region of the buffer is fontified, they -;; should use this function. For an example, see ps-print.el. -(defun lazy-lock-fontify-region (beg end) - ;; Fontify between BEG and END, where necessary, in the current buffer. - (save-restriction - (widen) - (when (setq beg (text-property-any beg end 'lazy-lock nil)) - (save-excursion - (save-match-data - (save-buffer-state - ;; Ensure syntactic fontification is always correct. - (font-lock-beginning-of-syntax-function next) - ;; Find successive unfontified regions between BEG and END. - (condition-case data - (do-while beg - (setq next (or (text-property-any beg end 'lazy-lock t) end)) - ;; Make sure the region end points are at beginning of line. - (goto-char beg) - (unless (bolp) - (beginning-of-line) - (setq beg (point))) - (goto-char next) - (unless (bolp) - (forward-line) - (setq next (point))) - ;; Fontify the region, then flag it as fontified. - (font-lock-fontify-region beg next) - (add-text-properties beg next '(lazy-lock t)) - (setq beg (text-property-any next end 'lazy-lock nil))) - ((error quit) (message "Fontifying region...%s" data))))))))) - -(defun lazy-lock-fontify-chunk () - ;; Fontify the nearest chunk, for stealth, in the current buffer. - (let ((inhibit-point-motion-hooks t)) - (save-excursion - (save-restriction - (widen) - ;; Move to end of line in case the character at point is not fontified. - (end-of-line) - ;; Find where the previous (next) unfontified regions end (begin). - (let ((prev (previous-single-property-change (point) 'lazy-lock)) - (next (text-property-any (point) (point-max) 'lazy-lock nil))) - ;; Fontify from the nearest unfontified position. - (if (or (null prev) (and next (< (- next (point)) (- (point) prev)))) - ;; The next, or neither, region is the nearest not fontified. - (lazy-lock-fontify-region - (progn (goto-char (or next (point-min))) - (beginning-of-line) - (point)) - (progn (goto-char (or next (point-min))) - (forward-line lazy-lock-stealth-lines) - (point))) - ;; The previous region is the nearest not fontified. - (lazy-lock-fontify-region - (progn (goto-char prev) - (forward-line (- lazy-lock-stealth-lines)) - (point)) - (progn (goto-char prev) - (forward-line) - (point))))))))) - -(defun lazy-lock-fontify-window (window) - ;; Fontify in WINDOW between `window-start' and `window-end'. - ;; We can only do this when we can use `window-start' and `window-end'. - (with-current-buffer (window-buffer window) - (lazy-lock-fontify-region (window-start window) (window-end window)))) - -(defun lazy-lock-fontify-conservatively (window) - ;; Fontify in WINDOW conservatively around point. - ;; Where we cannot use `window-start' and `window-end' we do `window-height' - ;; lines around point. That way we guarantee to have done enough. - (with-current-buffer (window-buffer window) - (let ((inhibit-point-motion-hooks t)) - (lazy-lock-fontify-region - (save-excursion - (goto-char (window-point window)) - (vertical-motion (- (window-height window)) window) (point)) - (save-excursion - (goto-char (window-point window)) - (vertical-motion (window-height window) window) (point)))))) - -(defun lazy-lock-unfontified-p () - ;; Return non-nil if there is anywhere still to be fontified. - (save-restriction - (widen) - (text-property-any (point-min) (point-max) 'lazy-lock nil))) - -(defun lazy-lock-percent-fontified () - ;; Return the percentage (of characters) of the buffer that are fontified. - (save-restriction - (widen) - (let ((beg (point-min)) (size 0) next) - ;; Find where the next fontified region begins. - (while (setq beg (text-property-any beg (point-max) 'lazy-lock t)) - (setq next (or (text-property-any beg (point-max) 'lazy-lock nil) - (point-max))) - (incf size (- next beg)) - (setq beg next)) - ;; Float because using integer multiplication will frequently overflow. - (truncate (* (/ (float size) (point-max)) 100))))) - -;; Version dependent workarounds and fixes. - -(when (consp lazy-lock-defer-time) - ;; - ;; In 2.06.04 and below, `lazy-lock-defer-time' could specify modes and time. - (with-output-to-temp-buffer "*Help*" - (princ "The value of the variable `lazy-lock-defer-time' was\n ") - (princ lazy-lock-defer-time) - (princ "\n") - (princ "This variable cannot now be a list of modes and time,\n") - (princ "so instead use ") - (princ (substitute-command-keys "\\[customize-option]")) - (princ " to modify the variables, or put the forms:\n") - (princ " (setq lazy-lock-defer-time ") - (princ (cdr lazy-lock-defer-time)) - (princ ")\n") - (princ " (setq lazy-lock-defer-on-the-fly '") - (princ (car lazy-lock-defer-time)) - (princ ")\n") - (princ "in your ~/.emacs. ") - (princ "The above forms have been evaluated for this editor session,\n") - (princ "but you should use ") - (princ (substitute-command-keys "\\[customize-option]")) - (princ " or change your ~/.emacs now.")) - (setq lazy-lock-defer-on-the-fly (car lazy-lock-defer-time) - lazy-lock-defer-time (cdr lazy-lock-defer-time))) - -(when (boundp 'lazy-lock-defer-driven) - ;; - ;; In 2.06.04 and below, `lazy-lock-defer-driven' was the variable name. - (with-output-to-temp-buffer "*Help*" - (princ "The value of the variable `lazy-lock-defer-driven' is set to ") - (if (memq lazy-lock-defer-driven '(nil t)) - (princ lazy-lock-defer-driven) - (princ "`") - (princ lazy-lock-defer-driven) - (princ "'")) - (princ ".\n") - (princ "This variable is now called `lazy-lock-defer-on-scrolling',\n") - (princ "so instead use ") - (princ (substitute-command-keys "\\[customize-option]")) - (princ " to modify the variable, or put the form:\n") - (princ " (setq lazy-lock-defer-on-scrolling ") - (unless (memq lazy-lock-defer-driven '(nil t)) - (princ "'")) - (princ lazy-lock-defer-driven) - (princ ")\n") - (princ "in your ~/.emacs. ") - (princ "The above form has been evaluated for this editor session,\n") - (princ "but you should use ") - (princ (substitute-command-keys "\\[customize-option]")) - (princ " or change your ~/.emacs now.")) - (setq lazy-lock-defer-on-scrolling lazy-lock-defer-driven)) - -;; Install ourselves: - -(add-hook 'window-size-change-functions 'lazy-lock-fontify-after-resize) -(add-hook 'redisplay-end-trigger-functions 'lazy-lock-fontify-after-trigger) - -(unless (assq 'lazy-lock-mode minor-mode-alist) - (setq minor-mode-alist (append minor-mode-alist '((lazy-lock-mode nil))))) - -;; Provide ourselves: - -(provide 'lazy-lock) - -;;; arch-tag: c1776846-f046-4a45-9684-54b951b12fc9 -;;; lazy-lock.el ends here
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lisp/obsolete/fast-lock.el Fri Apr 08 16:25:22 2005 +0000 @@ -0,0 +1,863 @@ +;;; fast-lock.el --- automagic text properties caching for fast Font Lock mode + +;; Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + +;; Author: Simon Marshall <simon@gnu.org> +;; Maintainer: FSF +;; Keywords: faces files +;; Version: 3.14 + +;; 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, 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 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: + +;; Fast Lock mode is a Font Lock support mode. +;; It makes visiting a file in Font Lock mode faster by restoring its face text +;; properties from automatically saved associated Font Lock cache files. +;; +;; See caveats and feedback below. +;; See also the lazy-lock package. (But don't use the two at the same time!) + +;; Installation: +;; +;; Put in your ~/.emacs: +;; +;; (setq font-lock-support-mode 'fast-lock-mode) +;; +;; Start up a new Emacs and use font-lock as usual (except that you can use the +;; so-called "gaudier" fontification regexps on big files without frustration). +;; +;; When you visit a file (which has `font-lock-mode' enabled) that has a +;; corresponding Font Lock cache file associated with it, the Font Lock cache +;; will be loaded from that file instead of being generated by Font Lock code. + +;; Caveats: +;; +;; A cache will be saved when visiting a compressed file using crypt++, but not +;; be read. This is a "feature"/"consequence"/"bug" of crypt++. +;; +;; Version control packages are likely to stamp all over file modification +;; times. Therefore the act of checking out may invalidate a cache. + +;; History: +;; +;; 0.02--1.00: +;; - Changed name from turbo-prop to fast-lock. Automagic for font-lock only +;; - Made `fast-lock-mode' a minor mode, like G. Dinesh Dutt's fss-mode +;; 1.00--1.01: +;; - Turn on `fast-lock-mode' only if `buffer-file-name' or `interactive-p' +;; - Made `fast-lock-file-name' use `buffer-name' if `buffer-file-name' is nil +;; - Moved save-all conditions to `fast-lock-save-cache' +;; - Added `fast-lock-save-text-properties' to `kill-buffer-hook' +;; 1.01--2.00: complete rewrite---not worth the space to document +;; - Changed structure of text properties cache and threw out file mod checks +;; 2.00--2.01: +;; - Made `condition-case' forms understand `quit'. +;; - Made `fast-lock' require `font-lock' +;; - Made `fast-lock-cache-name' chase links (from Ben Liblit) +;; 2.01--3.00: +;; - Changed structure of cache to include `font-lock-keywords' (from rms) +;; - Changed `fast-lock-cache-mechanisms' to `fast-lock-cache-directories' +;; - Removed `fast-lock-read-others' +;; - Made `fast-lock-read-cache' ignore cache owner +;; - Made `fast-lock-save-cache-external' create cache directory +;; - Made `fast-lock-save-cache-external' save `font-lock-keywords' +;; - Made `fast-lock-cache-data' check `font-lock-keywords' +;; 3.00--3.01: incorporated port of 2.00 to Lucid, made by Barry Warsaw +;; - Package now provides itself +;; - Lucid: Use `font-lock-any-extents-p' for `font-lock-any-properties-p' +;; - Lucid: Use `list-faces' for `face-list' +;; - Lucid: Added `set-text-properties' +;; - Lucid: Made `turn-on-fast-lock' pass 1 not t to `fast-lock-mode' +;; - Removed test for `fast-lock-mode' from `fast-lock-read-cache' +;; - Lucid: Added Lucid-specific `fast-lock-get-face-properties' +;; 3.01--3.02: now works with Lucid Emacs, thanks to Barry Warsaw +;; - Made `fast-lock-cache-name' map ":" to ";" for OS/2 (from Serganova Vera) +;; - Made `fast-lock-cache-name' use abbreviated file name (from Barry Warsaw) +;; - Lucid: Separated handlers for `error' and `quit' for `condition-case' +;; 3.02--3.03: +;; - Changed `fast-lock-save-cache-external' to `fast-lock-save-cache-data' +;; - Lucid: Added Lucid-specific `fast-lock-set-face-properties' +;; 3.03--3.04: +;; - Corrected `subrp' test of Lucid code +;; - Replaced `font-lock-any-properties-p' with `text-property-not-all' +;; - Lucid: Made `fast-lock-set-face-properties' put `text-prop' on extents +;; - Made `fast-lock-cache-directories' a regexp alist (from Colin Rafferty) +;; - Made `fast-lock-cache-directory' to return a usable cache file directory +;; 3.04--3.05: +;; - Lucid: Fix for XEmacs 19.11 `text-property-not-all' +;; - Replaced `subrp' test of Lucid code with `emacs-version' `string-match' +;; - Made `byte-compile-warnings' omit `unresolved' on compilation +;; - Made `fast-lock-save-cache-data' use a buffer (from Rick Sladkey) +;; - Reverted to old `fast-lock-get-face-properties' (from Rick Sladkey) +;; 3.05--3.06: incorporated hack of 3.03, made by Jonathan Stigelman (Stig) +;; - Reverted to 3.04 version of `fast-lock-get-face-properties' +;; - XEmacs: Removed `list-faces' `defalias' +;; - Made `fast-lock-mode' and `turn-on-fast-lock' succeed `autoload' cookies +;; - Added `fast-lock-submit-bug-report' +;; - Renamed `fast-lock-save-size' to `fast-lock-minimum-size' +;; - Made `fast-lock-save-cache' output a message if no save ever attempted +;; - Made `fast-lock-save-cache-data' output a message if save attempted +;; - Made `fast-lock-cache-data' output a message if load attempted +;; - Made `fast-lock-save-cache-data' do `condition-case' not `unwind-protect' +;; - Made `fast-lock-save-cache' and `fast-lock-read-cache' return nothing +;; - Made `fast-lock-save-cache' check `buffer-modified-p' (Stig) +;; - Added `fast-lock-save-events' +;; - Added `fast-lock-after-save-hook' to `after-save-hook' (Stig) +;; - Added `fast-lock-kill-buffer-hook' to `kill-buffer-hook' +;; - Changed `fast-lock-save-caches' to `fast-lock-kill-emacs-hook' +;; - Added `fast-lock-kill-emacs-hook' to `kill-emacs-hook' +;; - Made `fast-lock-save-cache' check `verify-visited-file-modtime' (Stig) +;; - Made `visited-file-modtime' be the basis of the timestamp (Stig) +;; - Made `fast-lock-save-cache-1' and `fast-lock-cache-data' use/reformat it +;; - Added `fast-lock-cache-filename' to keep track of the cache file name +;; - Added `fast-lock-after-fontify-buffer' +;; - Added `fast-lock-save-faces' list of faces to save (idea from Stig/Tibor) +;; - Made `fast-lock-get-face-properties' functions use it +;; - XEmacs: Made `fast-lock-set-face-properties' do extents the Font Lock way +;; - XEmacs: Removed fix for `text-property-not-all' (19.11 support dropped) +;; - Made `fast-lock-mode' ensure `font-lock-mode' is on +;; - Made `fast-lock-save-cache' do `cdr-safe' not `cdr' (from Dave Foster) +;; - Made `fast-lock-save-cache' do `set-buffer' first (from Dave Foster) +;; - Made `fast-lock-save-cache' loop until saved or quit (from Georg Nikodym) +;; - Made `fast-lock-cache-data' check `buffer-modified-p' +;; - Made `fast-lock-cache-data' do `font-lock-compile-keywords' if necessary +;; - XEmacs: Made `font-lock-compile-keywords' `defalias' +;; 3.06--3.07: +;; - XEmacs: Add `fast-lock-after-fontify-buffer' to the Font Lock hook +;; - Made `fast-lock-cache-name' explain the use of `directory-abbrev-alist' +;; - Made `fast-lock-mode' use `buffer-file-truename' not `buffer-file-name' +;; 3.07--3.08: +;; - Made `fast-lock-read-cache' set `fast-lock-cache-filename' +;; 3.08--3.09: +;; - Made `fast-lock-save-cache' cope if `fast-lock-minimum-size' is an a list +;; - Made `fast-lock-mode' respect the value of `font-lock-inhibit-thing-lock' +;; - Added `fast-lock-after-unfontify-buffer' +;; 3.09--3.10: +;; - Rewrite for Common Lisp macros +;; - Made fast-lock.el barf on a crap 8+3 pseudo-OS (Eli Zaretskii help) +;; - XEmacs: Made `add-minor-mode' succeed `autoload' cookie +;; - XEmacs: Made `fast-lock-save-faces' default to `font-lock-face-list' +;; - Made `fast-lock-save-cache' use `font-lock-value-in-major-mode' +;; - Wrap with `save-buffer-state' (Ray Van Tassle report) +;; - Made `fast-lock-mode' wrap `font-lock-support-mode' +;; 3.10--3.11: +;; - Made `fast-lock-get-face-properties' cope with face lists +;; - Added `fast-lock-verbose' +;; - XEmacs: Add `font-lock-value-in-major-mode' if necessary +;; - Removed `fast-lock-submit-bug-report' and bade farewell +;; 3.11--3.12: +;; - Added Custom support (Hrvoje Niksic help) +;; - Made `save-buffer-state' wrap `inhibit-point-motion-hooks' +;; - Made `fast-lock-cache-data' simplify calls of `font-lock-compile-keywords' +;; 3.12--3.13: +;; - Removed `byte-*' variables from `eval-when-compile' (Erik Naggum hint) +;; - Changed structure of cache to include `font-lock-syntactic-keywords' +;; - Made `fast-lock-save-cache-1' save syntactic fontification data +;; - Made `fast-lock-cache-data' take syntactic fontification data +;; - Added `fast-lock-get-syntactic-properties' +;; - Renamed `fast-lock-set-face-properties' to `fast-lock-add-properties' +;; - Made `fast-lock-add-properties' add syntactic and face fontification data +;; 3.13--3.14: +;; - Made `fast-lock-cache-name' cope with `windowsnt' (Geoff Voelker fix) +;; - Made `fast-lock-verbose' use `other' widget (Andreas Schwab fix) +;; - Used `with-temp-message' where possible to make messages temporary. + +;;; Code: + +(require 'font-lock) + +;; Make sure fast-lock.el is supported. +(if (and (eq system-type 'ms-dos) (not (msdos-long-file-names))) + (error "`fast-lock' was written for long file name systems")) + +(eval-when-compile + ;; + ;; We don't do this at the top-level as we only use non-autoloaded macros. + (require 'cl) + ;; + ;; We use this to preserve or protect things when modifying text properties. + (defmacro save-buffer-state (varlist &rest body) + "Bind variables according to VARLIST and eval BODY restoring buffer state." + `(let* (,@(append varlist + '((modified (buffer-modified-p)) (buffer-undo-list t) + (inhibit-read-only t) (inhibit-point-motion-hooks t) + before-change-functions after-change-functions + deactivate-mark buffer-file-name buffer-file-truename))) + ,@body + (when (and (not modified) (buffer-modified-p)) + (set-buffer-modified-p nil)))) + (put 'save-buffer-state 'lisp-indent-function 1) + ;; + ;; We use this to verify that a face should be saved. + (defmacro fast-lock-save-facep (face) + "Return non-nil if FACE is one of `fast-lock-save-faces'." + `(or (null fast-lock-save-faces) + (if (symbolp ,face) + (memq ,face fast-lock-save-faces) + (let ((faces ,face)) + (while (unless (memq (car faces) fast-lock-save-faces) + (setq faces (cdr faces)))) + faces)))) + ;; + ;; We use this for compatibility with a future Emacs. + (or (fboundp 'with-temp-message) + (defmacro with-temp-message (message &rest body) + `(let ((temp-message ,message) current-message) + (unwind-protect + (progn + (when temp-message + (setq current-message (current-message)) + (message temp-message)) + ,@body) + (when temp-message + (message current-message)))))) + ;; + ;; We use this for compatibility with a future Emacs. + (or (fboundp 'defcustom) + (defmacro defcustom (symbol value doc &rest args) + `(defvar ,symbol ,value ,doc)))) + +;(defun fast-lock-submit-bug-report () +; "Submit via mail a bug report on fast-lock.el." +; (interactive) +; (let ((reporter-prompt-for-summary-p t)) +; (reporter-submit-bug-report "simon@gnu.org" "fast-lock 3.14" +; '(fast-lock-cache-directories fast-lock-minimum-size +; fast-lock-save-others fast-lock-save-events fast-lock-save-faces +; fast-lock-verbose) +; nil nil +; (concat "Hi Si., +; +;I want to report a bug. I've read the `Bugs' section of `Info' on Emacs, so I +;know how to make a clear and unambiguous report. To reproduce the bug: +; +;Start a fresh editor via `" invocation-name " -no-init-file -no-site-file'. +;In the `*scratch*' buffer, evaluate:")))) + +(defvar fast-lock-mode nil) ; Whether we are turned on. +(defvar fast-lock-cache-timestamp nil) ; For saving/reading. +(defvar fast-lock-cache-filename nil) ; For deleting. + +;; User Variables: + +(defcustom fast-lock-minimum-size 25600 + "*Minimum size of a buffer for cached fontification. +Only buffers more than this can have associated Font Lock cache files saved. +If nil, means cache files are never created. +If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE), +where MAJOR-MODE is a symbol or t (meaning the default). For example: + ((c-mode . 25600) (c++-mode . 25600) (rmail-mode . 1048576)) +means that the minimum size is 25K for buffers in C or C++ modes, one megabyte +for buffers in Rmail mode, and size is irrelevant otherwise." + :type '(choice (const :tag "none" nil) + (integer :tag "size") + (repeat :menu-tag "mode specific" :tag "mode specific" + :value ((t . nil)) + (cons :tag "Instance" + (radio :tag "Mode" + (const :tag "all" t) + (symbol :tag "name")) + (radio :tag "Size" + (const :tag "none" nil) + (integer :tag "size"))))) + :group 'fast-lock) + +(defcustom fast-lock-cache-directories '("." "~/.emacs-flc") +; - `internal', keep each file's Font Lock cache file in the same file. +; - `external', keep each file's Font Lock cache file in the same directory. + "*Directories in which Font Lock cache files are saved and read. +Each item should be either DIR or a cons pair of the form (REGEXP . DIR) where +DIR is a directory name (relative or absolute) and REGEXP is a regexp. + +An attempt will be made to save or read Font Lock cache files using these items +until one succeeds (i.e., until a readable or writable one is found). If an +item contains REGEXP, DIR is used only if the buffer file name matches REGEXP. +For example: + + (let ((home (expand-file-name (abbreviate-file-name (file-truename \"~/\"))))) + (list (cons (concat \"^\" (regexp-quote home)) \".\") \"~/.emacs-flc\")) + => + ((\"^/your/true/home/directory/\" . \".\") \"~/.emacs-flc\") + +would cause a file's current directory to be used if the file is under your +home directory hierarchy, or otherwise the absolute directory `~/.emacs-flc'." + :type '(repeat (radio (directory :tag "directory") + (cons :tag "Matching" + (regexp :tag "regexp") + (directory :tag "directory")))) + :group 'fast-lock) + +(defcustom fast-lock-save-events '(kill-buffer kill-emacs) + "*Events under which caches will be saved. +Valid events are `save-buffer', `kill-buffer' and `kill-emacs'. +If concurrent editing sessions use the same associated cache file for a file's +buffer, then you should add `save-buffer' to this list." + :type '(set (const :tag "buffer saving" save-buffer) + (const :tag "buffer killing" kill-buffer) + (const :tag "emacs killing" kill-emacs)) + :group 'fast-lock) + +(defcustom fast-lock-save-others t + "*If non-nil, save Font Lock cache files irrespective of file owner. +If nil, means only buffer files known to be owned by you can have associated +Font Lock cache files saved. Ownership may be unknown for networked files." + :type 'boolean + :group 'fast-lock) + +(defcustom fast-lock-verbose font-lock-verbose + "*If non-nil, means show status messages for cache processing. +If a number, only buffers greater than this size have processing messages." + :type '(choice (const :tag "never" nil) + (other :tag "always" t) + (integer :tag "size")) + :group 'fast-lock) + +(defvar fast-lock-save-faces + (when (save-match-data (string-match "XEmacs" (emacs-version))) + ;; XEmacs uses extents for everything, so we have to pick the right ones. + font-lock-face-list) + "Faces that will be saved in a Font Lock cache file. +If nil, means information for all faces will be saved.") + +;; User Functions: + +;;;###autoload +(defun fast-lock-mode (&optional arg) + "Toggle Fast Lock mode. +With arg, turn Fast Lock mode on if and only if arg is positive and the buffer +is associated with a file. Enable it automatically in your `~/.emacs' by: + + (setq font-lock-support-mode 'fast-lock-mode) + +If Fast Lock mode is enabled, and the current buffer does not contain any text +properties, any associated Font Lock cache is used if its timestamp matches the +buffer's file, and its `font-lock-keywords' match those that you are using. + +Font Lock caches may be saved: +- When you save the file's buffer. +- When you kill an unmodified file's buffer. +- When you exit Emacs, for all unmodified or saved buffers. +Depending on the value of `fast-lock-save-events'. +See also the commands `fast-lock-read-cache' and `fast-lock-save-cache'. + +Use \\[font-lock-fontify-buffer] to fontify the buffer if the cache is bad. + +Various methods of control are provided for the Font Lock cache. In general, +see variable `fast-lock-cache-directories' and function `fast-lock-cache-name'. +For saving, see variables `fast-lock-minimum-size', `fast-lock-save-events', +`fast-lock-save-others' and `fast-lock-save-faces'." + (interactive "P") + ;; Only turn on if we are visiting a file. We could use `buffer-file-name', + ;; but many packages temporarily wrap that to nil when doing their own thing. + (set (make-local-variable 'fast-lock-mode) + (and buffer-file-truename + (not (memq 'fast-lock-mode font-lock-inhibit-thing-lock)) + (if arg (> (prefix-numeric-value arg) 0) (not fast-lock-mode)))) + (if (and fast-lock-mode (not font-lock-mode)) + ;; Turned on `fast-lock-mode' rather than `font-lock-mode'. + (let ((font-lock-support-mode 'fast-lock-mode)) + (font-lock-mode t)) + ;; Let's get down to business. + (set (make-local-variable 'fast-lock-cache-timestamp) nil) + (set (make-local-variable 'fast-lock-cache-filename) nil) + (when (and fast-lock-mode (not font-lock-fontified)) + (fast-lock-read-cache)))) + +(defun fast-lock-read-cache () + "Read the Font Lock cache for the current buffer. + +The following criteria must be met for a Font Lock cache file to be read: +- Fast Lock mode must be turned on in the buffer. +- The buffer must not be modified. +- The buffer's `font-lock-keywords' must match the cache's. +- The buffer file's timestamp must match the cache's. +- Criteria imposed by `fast-lock-cache-directories'. + +See `fast-lock-mode'." + (interactive) + (let ((directories fast-lock-cache-directories) + (modified (buffer-modified-p)) (inhibit-read-only t) + (fontified font-lock-fontified)) + (set (make-local-variable 'font-lock-fontified) nil) + ;; Keep trying directories until fontification is turned off. + (while (and directories (not font-lock-fontified)) + (let ((directory (fast-lock-cache-directory (car directories) nil))) + (condition-case nil + (when directory + (setq fast-lock-cache-filename (fast-lock-cache-name directory)) + (when (file-readable-p fast-lock-cache-filename) + (load fast-lock-cache-filename t t t))) + (error nil) (quit nil)) + (setq directories (cdr directories)))) + ;; Unset `fast-lock-cache-filename', and restore `font-lock-fontified', if + ;; we don't use a cache. (Note that `fast-lock-cache-data' sets the value + ;; of `fast-lock-cache-timestamp'.) + (set-buffer-modified-p modified) + (unless font-lock-fontified + (setq fast-lock-cache-filename nil font-lock-fontified fontified)))) + +(defun fast-lock-save-cache (&optional buffer) + "Save the Font Lock cache of BUFFER or the current buffer. + +The following criteria must be met for a Font Lock cache file to be saved: +- Fast Lock mode must be turned on in the buffer. +- The event must be one of `fast-lock-save-events'. +- The buffer must be at least `fast-lock-minimum-size' bytes long. +- The buffer file must be owned by you, or `fast-lock-save-others' must be t. +- The buffer must contain at least one `face' text property. +- The buffer must not be modified. +- The buffer file's timestamp must be the same as the file's on disk. +- The on disk file's timestamp must be different than the buffer's cache. +- Criteria imposed by `fast-lock-cache-directories'. + +See `fast-lock-mode'." + (interactive) + (save-excursion + (when buffer + (set-buffer buffer)) + (let ((min-size (font-lock-value-in-major-mode fast-lock-minimum-size)) + (file-timestamp (visited-file-modtime)) (saved nil)) + (when (and fast-lock-mode + ;; + ;; "Only save if the buffer matches the file, the file has + ;; changed, and it was changed by the current emacs session." + ;; + ;; Only save if the buffer is not modified, + ;; (i.e., so we don't save for something not on disk) + (not (buffer-modified-p)) + ;; and the file's timestamp is the same as the buffer's, + ;; (i.e., someone else hasn't written the file in the meantime) + (verify-visited-file-modtime (current-buffer)) + ;; and the file's timestamp is different from the cache's. + ;; (i.e., a save has occurred since the cache was read) + (not (equal fast-lock-cache-timestamp file-timestamp)) + ;; + ;; Only save if user's restrictions are satisfied. + (and min-size (>= (buffer-size) min-size)) + (or fast-lock-save-others + (eq (user-uid) (nth 2 (file-attributes buffer-file-name)))) + ;; + ;; Only save if there are `face' properties to save. + (text-property-not-all (point-min) (point-max) 'face nil)) + ;; + ;; Try each directory until we manage to save or the user quits. + (let ((directories fast-lock-cache-directories)) + (while (and directories (memq saved '(nil error))) + (let* ((dir (fast-lock-cache-directory (car directories) t)) + (file (and dir (fast-lock-cache-name dir)))) + (when (and file (file-writable-p file)) + (setq saved (fast-lock-save-cache-1 file file-timestamp))) + (setq directories (cdr directories))))))))) + +;;;###autoload +(defun turn-on-fast-lock () + "Unconditionally turn on Fast Lock mode." + (fast-lock-mode t)) + +;;; API Functions: + +(defun fast-lock-after-fontify-buffer () + ;; Delete the Font Lock cache file used to restore fontification, if any. + (when fast-lock-cache-filename + (if (file-writable-p fast-lock-cache-filename) + (delete-file fast-lock-cache-filename) + (message "File %s font lock cache cannot be deleted" (buffer-name)))) + ;; Flag so that a cache will be saved later even if the file is never saved. + (setq fast-lock-cache-timestamp nil)) + +(defalias 'fast-lock-after-unfontify-buffer + 'ignore) + +;; Miscellaneous Functions: + +(defun fast-lock-save-cache-after-save-file () + ;; Do `fast-lock-save-cache' if `save-buffer' is on `fast-lock-save-events'. + (when (memq 'save-buffer fast-lock-save-events) + (fast-lock-save-cache))) + +(defun fast-lock-save-cache-before-kill-buffer () + ;; Do `fast-lock-save-cache' if `kill-buffer' is on `fast-lock-save-events'. + (when (memq 'kill-buffer fast-lock-save-events) + (fast-lock-save-cache))) + +(defun fast-lock-save-caches-before-kill-emacs () + ;; Do `fast-lock-save-cache's if `kill-emacs' is on `fast-lock-save-events'. + (when (memq 'kill-emacs fast-lock-save-events) + (mapcar 'fast-lock-save-cache (buffer-list)))) + +(defun fast-lock-cache-directory (directory create) + "Return usable directory based on DIRECTORY. +Returns nil if the directory does not exist, or, if CREATE non-nil, cannot be +created. DIRECTORY may be a string or a cons pair of the form (REGEXP . DIR). +See `fast-lock-cache-directories'." + (let ((dir + (cond ((not buffer-file-name) + ;; Should never be nil, but `crypt++' screws it up. + nil) + ((stringp directory) + ;; Just a directory. + directory) + (t + ;; A directory iff the file name matches the regexp. + (let ((bufile (expand-file-name buffer-file-truename)) + (case-fold-search nil)) + (when (save-match-data (string-match (car directory) bufile)) + (cdr directory))))))) + (cond ((not dir) + nil) + ((file-accessible-directory-p dir) + dir) + (create + (condition-case nil + (progn (make-directory dir t) dir) + (error nil)))))) + +;; If you are wondering why we only hash if the directory is not ".", rather +;; than if `file-name-absolute-p', it is because if we just appended ".flc" for +;; relative cache directories (that are not ".") then it is possible that more +;; than one file would have the same cache name in that directory, if the luser +;; made a link from one relative cache directory to another. (Phew!) +(defun fast-lock-cache-name (directory) + "Return full cache file name using caching DIRECTORY. +If DIRECTORY is `.', the file name is the buffer file name appended with `.flc'. +Otherwise, the file name is constructed from DIRECTORY and the buffer's true +abbreviated file name, with all `/' characters in the name replaced with `#' +characters, and appended with `.flc'. + +If the same file has different cache file names when edited on different +machines, e.g., on one machine the cache file name has the prefix `#home', +perhaps due to automount, try putting in your `~/.emacs' something like: + + (setq directory-abbrev-alist (cons '(\"^/home/\" . \"/\") directory-abbrev-alist)) + +Emacs automagically removes the common `/tmp_mnt' automount prefix by default. + +See `fast-lock-cache-directory'." + (if (string-equal directory ".") + (concat buffer-file-name ".flc") + (let* ((bufile (expand-file-name buffer-file-truename)) + (chars-alist + (if (memq system-type '(emx windows-nt cygwin)) + '((?/ . (?#)) (?# . (?# ?#)) (?: . (?\;)) (?\; . (?\; ?\;))) + '((?/ . (?#)) (?# . (?# ?#))))) + (mapchars + (function (lambda (c) (or (cdr (assq c chars-alist)) (list c)))))) + (concat + (file-name-as-directory (expand-file-name directory)) + (mapconcat 'char-to-string (apply 'append (mapcar mapchars bufile)) "") + ".flc")))) + +;; Font Lock Cache Processing Functions: + +;; The version 3 format of the cache is: +;; +;; (fast-lock-cache-data VERSION TIMESTAMP +;; font-lock-syntactic-keywords SYNTACTIC-PROPERTIES +;; font-lock-keywords FACE-PROPERTIES) + +(defun fast-lock-save-cache-1 (file timestamp) + ;; Save the FILE with the TIMESTAMP plus fontification data. + ;; Returns non-nil if a save was attempted to a writable cache file. + (let ((tpbuf (generate-new-buffer " *fast-lock*")) + (verbose (if (numberp fast-lock-verbose) + (> (buffer-size) fast-lock-verbose) + fast-lock-verbose)) + (saved t)) + (with-temp-message + (when verbose + (format "Saving %s font lock cache..." (buffer-name))) + (condition-case nil + (save-excursion + (print (list 'fast-lock-cache-data 3 + (list 'quote timestamp) + (list 'quote font-lock-syntactic-keywords) + (list 'quote (fast-lock-get-syntactic-properties)) + (list 'quote font-lock-keywords) + (list 'quote (fast-lock-get-face-properties))) + tpbuf) + (set-buffer tpbuf) + (write-region (point-min) (point-max) file nil 'quietly) + (setq fast-lock-cache-timestamp timestamp + fast-lock-cache-filename file)) + (error (setq saved 'error)) (quit (setq saved 'quit))) + (kill-buffer tpbuf)) + (cond ((eq saved 'quit) + (message "Saving %s font lock cache...quit" (buffer-name))) + ((eq saved 'error) + (message "Saving %s font lock cache...failed" (buffer-name)))) + ;; We return non-nil regardless of whether a failure occurred. + saved)) + +(defun fast-lock-cache-data (version timestamp + syntactic-keywords syntactic-properties + keywords face-properties + &rest ignored) + ;; Find value of syntactic keywords in case it is a symbol. + (setq font-lock-syntactic-keywords (font-lock-eval-keywords + font-lock-syntactic-keywords)) + ;; Compile all keywords in case some are and some aren't. + (when font-lock-syntactic-keywords + (setq font-lock-syntactic-keywords (font-lock-compile-keywords + font-lock-syntactic-keywords))) + (when syntactic-keywords + (setq syntactic-keywords (font-lock-compile-keywords syntactic-keywords))) + (setq font-lock-keywords (font-lock-compile-keywords font-lock-keywords) + keywords (font-lock-compile-keywords keywords)) + ;; Use the Font Lock cache SYNTACTIC-PROPERTIES and FACE-PROPERTIES if we're + ;; using cache VERSION format 3, the current buffer's file timestamp matches + ;; the TIMESTAMP, the current buffer's `font-lock-syntactic-keywords' are the + ;; same as SYNTACTIC-KEYWORDS, and the current buffer's `font-lock-keywords' + ;; are the same as KEYWORDS. + (let ((buf-timestamp (visited-file-modtime)) + (verbose (if (numberp fast-lock-verbose) + (> (buffer-size) fast-lock-verbose) + fast-lock-verbose)) + (loaded t)) + (if (or (/= version 3) + (buffer-modified-p) + (not (equal timestamp buf-timestamp)) + (not (equal syntactic-keywords font-lock-syntactic-keywords)) + (not (equal keywords font-lock-keywords))) + (setq loaded nil) + (with-temp-message + (when verbose + (format "Loading %s font lock cache..." (buffer-name))) + (condition-case nil + (fast-lock-add-properties syntactic-properties face-properties) + (error (setq loaded 'error)) (quit (setq loaded 'quit)))) + (cond ((eq loaded 'quit) + (message "Loading %s font lock cache...quit" (buffer-name))) + ((eq loaded 'error) + (message "Loading %s font lock cache...failed" (buffer-name))))) + (setq font-lock-fontified (eq loaded t) + fast-lock-cache-timestamp (and (eq loaded t) timestamp)))) + +;; Text Properties Processing Functions: + +;; This is fast, but fails if adjacent characters have different `face' text +;; properties. Maybe that's why I dropped it in the first place? +;(defun fast-lock-get-face-properties () +; "Return a list of `face' text properties in the current buffer. +;Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) +;where VALUE is a `face' property value and STARTx and ENDx are positions." +; (save-restriction +; (widen) +; (let ((start (text-property-not-all (point-min) (point-max) 'face nil)) +; (limit (point-max)) end properties value cell) +; (while start +; (setq end (next-single-property-change start 'face nil limit) +; value (get-text-property start 'face)) +; ;; Make, or add to existing, list of regions with same `face'. +; (if (setq cell (assq value properties)) +; (setcdr cell (cons start (cons end (cdr cell)))) +; (setq properties (cons (list value start end) properties))) +; (setq start (next-single-property-change end 'face))) +; properties))) + +;; This is slow, but copes if adjacent characters have different `face' text +;; properties, but fails if they are lists. +;(defun fast-lock-get-face-properties () +; "Return a list of `face' text properties in the current buffer. +;Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) +;where VALUE is a `face' property value and STARTx and ENDx are positions. +;Only those `face' VALUEs in `fast-lock-save-faces' are returned." +; (save-restriction +; (widen) +; (let ((faces (or fast-lock-save-faces (face-list))) (limit (point-max)) +; properties regions face start end) +; (while faces +; (setq face (car faces) faces (cdr faces) regions () end (point-min)) +; ;; Make a list of start/end regions with `face' property face. +; (while (setq start (text-property-any end limit 'face face)) +; (setq end (or (text-property-not-all start limit 'face face) limit) +; regions (cons start (cons end regions)))) +; ;; Add `face' face's regions, if any, to properties. +; (when regions +; (push (cons face regions) properties))) +; properties))) + +(defun fast-lock-get-face-properties () + "Return a list of `face' text properties in the current buffer. +Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) +where VALUE is a `face' property value and STARTx and ENDx are positions." + (save-restriction + (widen) + (let ((start (text-property-not-all (point-min) (point-max) 'face nil)) + end properties value cell) + (while start + (setq end (next-single-property-change start 'face nil (point-max)) + value (get-text-property start 'face)) + ;; Make, or add to existing, list of regions with same `face'. + (cond ((setq cell (assoc value properties)) + (setcdr cell (cons start (cons end (cdr cell))))) + ((fast-lock-save-facep value) + (push (list value start end) properties))) + (setq start (text-property-not-all end (point-max) 'face nil))) + properties))) + +(defun fast-lock-get-syntactic-properties () + "Return a list of `syntax-table' text properties in the current buffer. +See `fast-lock-get-face-properties'." + (save-restriction + (widen) + (let ((start (text-property-not-all (point-min) (point-max) 'syntax-table + nil)) + end properties value cell) + (while start + (setq end (next-single-property-change start 'syntax-table nil + (point-max)) + value (get-text-property start 'syntax-table)) + ;; Make, or add to existing, list of regions with same `syntax-table'. + (if (setq cell (assoc value properties)) + (setcdr cell (cons start (cons end (cdr cell)))) + (push (list value start end) properties)) + (setq start (text-property-not-all end (point-max) 'syntax-table nil))) + properties))) + +(defun fast-lock-add-properties (syntactic-properties face-properties) + "Add `syntax-table' and `face' text properties to the current buffer. +Any existing `syntax-table' and `face' text properties are removed first. +See `fast-lock-get-face-properties'." + (save-buffer-state (plist regions) + (save-restriction + (widen) + (font-lock-unfontify-region (point-min) (point-max)) + ;; + ;; Set the `syntax-table' property for each start/end region. + (while syntactic-properties + (setq plist (list 'syntax-table (car (car syntactic-properties))) + regions (cdr (car syntactic-properties)) + syntactic-properties (cdr syntactic-properties)) + (while regions + (add-text-properties (nth 0 regions) (nth 1 regions) plist) + (setq regions (nthcdr 2 regions)))) + ;; + ;; Set the `face' property for each start/end region. + (while face-properties + (setq plist (list 'face (car (car face-properties))) + regions (cdr (car face-properties)) + face-properties (cdr face-properties)) + (while regions + (add-text-properties (nth 0 regions) (nth 1 regions) plist) + (setq regions (nthcdr 2 regions))))))) + +;; Functions for XEmacs: + +(when (save-match-data (string-match "XEmacs" (emacs-version))) + ;; + ;; It would be better to use XEmacs' `map-extents' over extents with a + ;; `font-lock' property, but `face' properties are on different extents. + (defun fast-lock-get-face-properties () + "Return a list of `face' text properties in the current buffer. +Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) +where VALUE is a `face' property value and STARTx and ENDx are positions. +Only those `face' VALUEs in `fast-lock-save-faces' are returned." + (save-restriction + (widen) + (let ((properties ()) cell) + (map-extents + (function (lambda (extent ignore) + (let ((value (extent-face extent))) + ;; We're only interested if it's one of `fast-lock-save-faces'. + (when (and value (fast-lock-save-facep value)) + (let ((start (extent-start-position extent)) + (end (extent-end-position extent))) + ;; Make or add to existing list of regions with the same + ;; `face' property value. + (if (setq cell (assoc value properties)) + (setcdr cell (cons start (cons end (cdr cell)))) + (push (list value start end) properties)))) + ;; Return nil to keep `map-extents' going. + nil)))) + properties))) + ;; + ;; XEmacs does not support the `syntax-table' text property. + (defalias 'fast-lock-get-syntactic-properties + 'ignore) + ;; + ;; Make extents just like XEmacs' font-lock.el does. + (defun fast-lock-add-properties (syntactic-properties face-properties) + "Set `face' text properties in the current buffer. +Any existing `face' text properties are removed first. +See `fast-lock-get-face-properties'." + (save-restriction + (widen) + (font-lock-unfontify-region (point-min) (point-max)) + ;; Set the `face' property, etc., for each start/end region. + (while face-properties + (let ((face (car (car face-properties))) + (regions (cdr (car face-properties)))) + (while regions + (font-lock-set-face (nth 0 regions) (nth 1 regions) face) + (setq regions (nthcdr 2 regions))) + (setq face-properties (cdr face-properties)))) + ;; XEmacs does not support the `syntax-table' text property. + )) + ;; + ;; XEmacs 19.12 font-lock.el's `font-lock-fontify-buffer' runs a hook. + (add-hook 'font-lock-after-fontify-buffer-hook + 'fast-lock-after-fontify-buffer)) + +(unless (boundp 'font-lock-syntactic-keywords) + (defvar font-lock-syntactic-keywords nil)) + +(unless (boundp 'font-lock-inhibit-thing-lock) + (defvar font-lock-inhibit-thing-lock nil)) + +(unless (fboundp 'font-lock-compile-keywords) + (defalias 'font-lock-compile-keywords 'identity)) + +(unless (fboundp 'font-lock-eval-keywords) + (defun font-lock-eval-keywords (keywords) + (if (symbolp keywords) + (font-lock-eval-keywords (if (fboundp keywords) + (funcall keywords) + (eval keywords))) + keywords))) + +(unless (fboundp 'font-lock-value-in-major-mode) + (defun font-lock-value-in-major-mode (alist) + (if (consp alist) + (cdr (or (assq major-mode alist) (assq t alist))) + alist))) + +(unless (fboundp 'current-message) + (defun current-message () + "")) + +;; Install ourselves: + +(add-hook 'after-save-hook 'fast-lock-save-cache-after-save-file) +(add-hook 'kill-buffer-hook 'fast-lock-save-cache-before-kill-buffer) +(add-hook 'kill-emacs-hook 'fast-lock-save-caches-before-kill-emacs) + +;;;###autoload +(when (fboundp 'add-minor-mode) + (defvar fast-lock-mode nil) + (add-minor-mode 'fast-lock-mode nil)) +;;;###dont-autoload +(unless (assq 'fast-lock-mode minor-mode-alist) + (setq minor-mode-alist (append minor-mode-alist '((fast-lock-mode nil))))) + +;; Provide ourselves: + +(provide 'fast-lock) + +;;; arch-tag: 638c431e-8cae-4538-80a1-963ff97d233e +;;; fast-lock.el ends here
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lisp/obsolete/lazy-lock.el Fri Apr 08 16:25:22 2005 +0000 @@ -0,0 +1,1054 @@ +;;; lazy-lock.el --- lazy demand-driven fontification for fast Font Lock mode + +;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 2001 +;; Free Software Foundation, Inc. + +;; Author: Simon Marshall <simon@gnu.org> +;; Maintainer: FSF +;; Keywords: faces files +;; Version: 2.11 + +;; 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, 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 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: + +;; Purpose: +;; +;; Lazy Lock mode is a Font Lock support mode. +;; It makes visiting buffers in Font Lock mode faster by making fontification +;; be demand-driven, deferred and stealthy, so that fontification only occurs +;; when, and where, necessary. +;; +;; See caveats and feedback below. +;; See also the fast-lock package. (But don't use them at the same time!) + +;; Installation: +;; +;; Put in your ~/.emacs: +;; +;; (setq font-lock-support-mode 'lazy-lock-mode) +;; +;; Start up a new Emacs and use font-lock as usual (except that you can use the +;; so-called "gaudier" fontification regexps on big files without frustration). +;; +;; In a buffer (which has `font-lock-mode' enabled) which is at least +;; `lazy-lock-minimum-size' characters long, buffer fontification will not +;; occur and only the visible portion of the buffer will be fontified. Motion +;; around the buffer will fontify those visible portions not previously +;; fontified. If stealth fontification is enabled, buffer fontification will +;; occur in invisible parts of the buffer after `lazy-lock-stealth-time' +;; seconds of idle time. If on-the-fly fontification is deferred, on-the-fly +;; fontification will occur after `lazy-lock-defer-time' seconds of idle time. + +;; User-visible differences with version 1: +;; +;; - Version 2 can defer on-the-fly fontification. Therefore you need not, and +;; should not, use defer-lock.el with this version of lazy-lock.el. +;; +;; A number of variables have changed meaning: +;; +;; - A value of nil for the variable `lazy-lock-minimum-size' means never turn +;; on demand-driven fontification. In version 1 this meant always turn on +;; demand-driven fontification. If you really want demand-driven fontification +;; regardless of buffer size, set this variable to 0. +;; +;; - The variable `lazy-lock-stealth-lines' cannot have a nil value. In +;; version 1 this meant use `window-height' as the maximum number of lines to +;; fontify as a stealth chunk. This makes no sense; stealth fontification is +;; of a buffer, not a window. + +;; Implementation differences with version 1: +;; +;; - Version 1 of lazy-lock.el is a bit of a hack. Version 1 demand-driven +;; fontification, the core feature of lazy-lock.el, is implemented by placing a +;; function on `post-command-hook'. This function fontifies where necessary, +;; i.e., where a window scroll has occurred. However, there are a number of +;; problems with using `post-command-hook': +;; +;; (a) As the name suggests, `post-command-hook' is run after every command, +;; i.e., frequently and regardless of whether scrolling has occurred. +;; (b) Scrolling can occur during a command, when `post-command-hook' is not +;; run, i.e., it is not necessarily run after scrolling has occurred. +;; (c) When `post-command-hook' is run, there is nothing to suggest where +;; scrolling might have occurred, i.e., which windows have scrolled. +;; +;; Thus lazy-lock.el's function is called almost as often as possible, usually +;; when it need not be called, yet it is not always called when it is needed. +;; Also, lazy-lock.el's function must check each window to see if a scroll has +;; occurred there. Worse still, lazy-lock.el's function must fontify a region +;; twice as large as necessary to make sure the window is completely fontified. +;; Basically, `post-command-hook' is completely inappropriate for lazy-lock.el. +;; +;; Ideally, we want to attach lazy-lock.el's function to a hook that is run +;; only when scrolling occurs, e.g., `window-start' has changed, and tells us +;; as much information as we need, i.e., the window and its new buffer region. +;; Richard Stallman implemented a `window-scroll-functions' for Emacs 19.30. +;; Functions on it are run when `window-start' has changed, and are supplied +;; with the window and the window's new `window-start' position. (It would be +;; better if it also supplied the window's new `window-end' position, but that +;; is calculated as part of the redisplay process, and the functions on +;; `window-scroll-functions' are run before redisplay has finished.) Thus, the +;; hook deals with the above problems (a), (b) and (c). +;; +;; If only life was that easy. Version 2 demand-driven fontification is mostly +;; implemented by placing a function on `window-scroll-functions'. However, +;; not all scrolling occurs when `window-start' has changed. A change in +;; window size, e.g., via C-x 1, or a significant deletion, e.g., of a number +;; of lines, causes text previously invisible (i.e., after `window-end') to +;; become visible without changing `window-start'. Arguably, these events are +;; not scrolling events, but fontification must occur for lazy-lock.el to work. +;; Hooks `window-size-change-functions' and `redisplay-end-trigger-functions' +;; were added for these circumstances. +;; +;; (Ben Wing thinks these hooks are "horribly horribly kludgy", and implemented +;; a `pre-idle-hook', a `mother-of-all-post-command-hooks', for XEmacs 19.14. +;; He then hacked up a version 1 lazy-lock.el to use `pre-idle-hook' rather +;; than `post-command-hook'. Whereas functions on `post-command-hook' are +;; called almost as often as possible, functions on `pre-idle-hook' really are +;; called as often as possible, even when the mouse moves and, on some systems, +;; while XEmacs is idle. Thus, the hook deals with the above problem (b), but +;; unfortunately it makes (a) worse and does not address (c) at all. +;; +;; I freely admit that `redisplay-end-trigger-functions' and, to a much lesser +;; extent, `window-size-change-functions' are not pretty. However, I feel that +;; a `window-scroll-functions' feature is cleaner than a `pre-idle-hook', and +;; the result is faster and smaller, less intrusive and more targeted, code. +;; Since `pre-idle-hook' is pretty much like `post-command-hook', there is no +;; point in making this version of lazy-lock.el work with it. Anyway, that's +;; Lit 30 of my humble opinion. +;; +;; - Version 1 stealth fontification is also implemented by placing a function +;; on `post-command-hook'. This function waits for a given amount of time, +;; and, if Emacs remains idle, fontifies where necessary. Again, there are a +;; number of problems with using `post-command-hook': +;; +;; (a) Functions on `post-command-hook' are run sequentially, so this function +;; can interfere with other functions on the hook, and vice versa. +;; (b) This function waits for a given amount of time, so it can interfere with +;; various features that are dealt with by Emacs after a command, e.g., +;; region highlighting, asynchronous updating and keystroke echoing. +;; (c) Fontification may be required during a command, when `post-command-hook' +;; is not run. (Version 2 deferred fontification only.) +;; +;; Again, `post-command-hook' is completely inappropriate for lazy-lock.el. +;; Richard Stallman and Morten Welinder implemented internal Timers and Idle +;; Timers for Emacs 19.31. Functions can be run independently at given times +;; or after given amounts of idle time. Thus, the feature deals with the above +;; problems (a), (b) and (c). Version 2 deferral and stealth are implemented +;; by functions on Idle Timers. (A function on XEmacs' `pre-idle-hook' is +;; similar to an Emacs Idle Timer function with a fixed zero second timeout.) + +;; - Version 1 has the following problems (relative to version 2): +;; +;; (a) It is slow when it does its job. +;; (b) It does not always do its job when it should. +;; (c) It slows all interaction (when it doesn't need to do its job). +;; (d) It interferes with other package functions on `post-command-hook'. +;; (e) It interferes with Emacs things within the read-eval loop. +;; +;; Ben's hacked-up lazy-lock.el 1.14 almost solved (b) but made (c) worse. +;; +;; - Version 2 has the following additional features (relative to version 1): +;; +;; (a) It can defer fontification (both on-the-fly and on-scrolling). +;; (b) It can fontify contextually (syntactically true on-the-fly). + +;; Caveats: +;; +;; Lazy Lock mode does not work efficiently with Outline mode. +;; This is because when in Outline mode, although text may be not visible to +;; you in the window, the text is visible to Emacs Lisp code (not surprisingly) +;; and Lazy Lock fontifies it mercilessly. Maybe it will be fixed one day. +;; +;; Because buffer text is not necessarily fontified, other packages that expect +;; buffer text to be fontified in Font Lock mode either might not work as +;; expected, or might not display buffer text as expected. An example of the +;; latter is `occur', which copies lines of buffer text into another buffer. +;; +;; In Emacs 19.30, Lazy Lock mode does not ensure that an existing buffer is +;; fontified if it is made visible via a minibuffer-less command that replaces +;; an existing window's buffer (e.g., via the Buffers menu). Upgrade! +;; +;; In Emacs 19.30, Lazy Lock mode does not work well with Transient Mark mode +;; or modes based on Comint mode (e.g., Shell mode), and also interferes with +;; the echoing of keystrokes in the minibuffer. This is because of the way +;; deferral and stealth have to be implemented for Emacs 19.30. Upgrade! +;; +;; Currently XEmacs does not have the features to support this version of +;; lazy-lock.el. Maybe it will one day. + +;; History: +;; +;; 1.15--2.00: +;; - Rewrite for Emacs 19.30 and the features rms added to support lazy-lock.el +;; so that it could work correctly and efficiently. +;; - Many thanks to those who reported bugs, fixed bugs, made suggestions or +;; otherwise contributed in the version 1 cycle; Jari Aalto, Kevin Broadey, +;; Ulrik Dickow, Bill Dubuque, Bob Glickstein, Boris Goldowsky, +;; Jonas Jarnestrom, David Karr, Michael Kifer, Erik Naggum, Rick Sladkey, +;; Jim Thompson, Ben Wing, Ilya Zakharevich, and Richard Stallman. +;; 2.00--2.01: +;; - Made `lazy-lock-fontify-after-command' always `sit-for' and so redisplay +;; - Use `buffer-name' not `buffer-live-p' (Bill Dubuque hint) +;; - Made `lazy-lock-install' do `add-to-list' not `setq' of `current-buffer' +;; - Made `lazy-lock-fontify-after-install' loop over buffer list +;; - Made `lazy-lock-arrange-before-change' to arrange `window-end' triggering +;; - Made `lazy-lock-let-buffer-state' wrap both `befter-change-functions' +;; - Made `lazy-lock-fontify-region' do `condition-case' (Hyman Rosen report) +;; 2.01--2.02: +;; - Use `buffer-live-p' as `buffer-name' can barf (Richard Stanton report) +;; - Made `lazy-lock-install' set `font-lock-fontified' (Kevin Davidson report) +;; - Made `lazy-lock-install' add hooks only if needed +;; - Made `lazy-lock-unstall' add `font-lock-after-change-function' if needed +;; 2.02--2.03: +;; - Made `lazy-lock-fontify-region' do `condition-case' for `quit' too +;; - Made `lazy-lock-mode' respect the value of `font-lock-inhibit-thing-lock' +;; - Added `lazy-lock-after-unfontify-buffer' +;; - Removed `lazy-lock-fontify-after-install' hack +;; - Made `lazy-lock-fontify-after-scroll' not `set-buffer' to `window-buffer' +;; - Made `lazy-lock-fontify-after-trigger' not `set-buffer' to `window-buffer' +;; - Made `lazy-lock-fontify-after-idle' be interruptible (Scott Burson hint) +;; 2.03--2.04: +;; - Rewrite for Emacs 19.31 idle timers +;; - Renamed `buffer-windows' to `get-buffer-window-list' +;; - Removed `buffer-live-p' +;; - Made `lazy-lock-defer-after-change' always save `current-buffer' +;; - Made `lazy-lock-fontify-after-defer' just process buffers +;; - Made `lazy-lock-install-hooks' add hooks correctly (Kevin Broadey report) +;; - Made `lazy-lock-install' cope if `lazy-lock-defer-time' is a list +;; 2.04--2.05: +;; - Rewrite for Common Lisp macros +;; - Added `do-while' macro +;; - Renamed `lazy-lock-let-buffer-state' macro to `save-buffer-state' +;; - Returned `lazy-lock-fontify-after-install' hack (Darren Hall hint) +;; - Added `lazy-lock-defer-on-scrolling' functionality (Scott Byer hint) +;; - Made `lazy-lock-mode' wrap `font-lock-support-mode' +;; 2.05--2.06: +;; - Made `lazy-lock-fontify-after-defer' swap correctly (Scott Byer report) +;; 2.06--2.07: +;; - Added `lazy-lock-stealth-load' functionality (Rob Hooft hint) +;; - Made `lazy-lock-unstall' call `lazy-lock-fontify-region' if needed +;; - Made `lazy-lock-mode' call `lazy-lock-unstall' only if needed +;; - Made `lazy-lock-defer-after-scroll' do `set-window-redisplay-end-trigger' +;; - Added `lazy-lock-defer-contextually' functionality +;; - Added `lazy-lock-defer-on-the-fly' from `lazy-lock-defer-time' +;; - Renamed `lazy-lock-defer-driven' to `lazy-lock-defer-on-scrolling' +;; - Removed `lazy-lock-submit-bug-report' and bade farewell +;; 2.07--2.08: +;; - Made `lazy-lock-fontify-conservatively' fontify around `window-point' +;; - Made `save-buffer-state' wrap `inhibit-point-motion-hooks' +;; - Added Custom support +;; 2.08--2.09: +;; - Removed `byte-*' variables from `eval-when-compile' (Erik Naggum hint) +;; - Made various wrapping `inhibit-point-motion-hooks' (Vinicius Latorre hint) +;; - Made `lazy-lock-fontify-after-idle' wrap `minibuffer-auto-raise' +;; - Made `lazy-lock-fontify-after-defer' paranoid about deferred buffers +;; 2.09--2.10: +;; - Use `window-end' UPDATE arg for Emacs 20.4 and later. +;; - Made deferral `widen' before unfontifying (Dan Nicolaescu report) +;; - Use `lazy-lock-fontify-after-visage' for hideshow.el (Dan Nicolaescu hint) +;; - Use `other' widget where possible (Andreas Schwab fix) +;; 2.10--2.11: +;; - Used `with-temp-message' where possible to make messages temporary. + +;;; Code: + +(require 'font-lock) + +(eval-when-compile + ;; We don't do this at the top-level as we only use non-autoloaded macros. + (require 'cl) + ;; + ;; We use this to preserve or protect things when modifying text properties. + (defmacro save-buffer-state (varlist &rest body) + "Bind variables according to VARLIST and eval BODY restoring buffer state." + `(let* (,@(append varlist + '((modified (buffer-modified-p)) + (buffer-undo-list t) + (inhibit-read-only t) + (inhibit-point-motion-hooks t) + (inhibit-modification-hooks t) + deactivate-mark + buffer-file-name + buffer-file-truename))) + ,@body + (when (and (not modified) (buffer-modified-p)) + (restore-buffer-modified-p nil)))) + (put 'save-buffer-state 'lisp-indent-function 1) + ;; + ;; We use this for clarity and speed. Naughty but nice. + (defmacro do-while (test &rest body) + "(do-while TEST BODY...): eval BODY... and repeat if TEST yields non-nil. +The order of execution is thus BODY, TEST, BODY, TEST and so on +until TEST returns nil." + `(while (progn ,@body ,test))) + (put 'do-while 'lisp-indent-function (get 'while 'lisp-indent-function))) + +(defvar lazy-lock-mode nil) ; Whether we are turned on. +(defvar lazy-lock-buffers nil) ; For deferral. +(defvar lazy-lock-timers (cons nil nil)) ; For deferral and stealth. + +;; User Variables: + +(defcustom lazy-lock-minimum-size 25600 + "*Minimum size of a buffer for demand-driven fontification. +On-demand fontification occurs if the buffer size is greater than this value. +If nil, means demand-driven fontification is never performed. +If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE), +where MAJOR-MODE is a symbol or t (meaning the default). For example: + ((c-mode . 25600) (c++-mode . 25600) (rmail-mode . 1048576)) +means that the minimum size is 25K for buffers in C or C++ modes, one megabyte +for buffers in Rmail mode, and size is irrelevant otherwise. + +The value of this variable is used when Lazy Lock mode is turned on." + :type '(choice (const :tag "none" nil) + (integer :tag "size") + (repeat :menu-tag "mode specific" :tag "mode specific" + :value ((t . nil)) + (cons :tag "Instance" + (radio :tag "Mode" + (const :tag "all" t) + (symbol :tag "name")) + (radio :tag "Size" + (const :tag "none" nil) + (integer :tag "size"))))) + :group 'lazy-lock) + +(defcustom lazy-lock-defer-on-the-fly t + "*If non-nil, means fontification after a change should be deferred. +If nil, means on-the-fly fontification is performed. This means when changes +occur in the buffer, those areas are immediately fontified. +If a list, it should be a list of `major-mode' symbol names for which deferred +fontification should occur. The sense of the list is negated if it begins with +`not'. For example: + (c-mode c++-mode) +means that on-the-fly fontification is deferred for buffers in C and C++ modes +only, and deferral does not occur otherwise. + +The value of this variable is used when Lazy Lock mode is turned on." + :type '(choice (const :tag "never" nil) + (const :tag "always" t) + (set :menu-tag "mode specific" :tag "modes" + :value (not) + (const :tag "Except" not) + (repeat :inline t (symbol :tag "mode")))) + :group 'lazy-lock) + +(defcustom lazy-lock-defer-on-scrolling nil + "*If non-nil, means fontification after a scroll should be deferred. +If nil, means demand-driven fontification is performed. This means when +scrolling into unfontified areas of the buffer, those areas are immediately +fontified. Thus scrolling never presents unfontified areas. However, since +fontification occurs during scrolling, scrolling may be slow. +If t, means defer-driven fontification is performed. This means fontification +of those areas is deferred. Thus scrolling may present momentarily unfontified +areas. However, since fontification does not occur during scrolling, scrolling +will be faster than demand-driven fontification. +If any other value, e.g., `eventually', means demand-driven fontification is +performed until the buffer is fontified, then buffer fontification becomes +defer-driven. Thus scrolling never presents unfontified areas until the buffer +is first fontified, after which subsequent scrolling may present future buffer +insertions momentarily unfontified. However, since fontification does not +occur during scrolling after the buffer is first fontified, scrolling will +become faster. (But, since contextual changes continually occur, such a value +makes little sense if `lazy-lock-defer-contextually' is non-nil.) + +The value of this variable is used when Lazy Lock mode is turned on." + :type '(choice (const :tag "never" nil) + (const :tag "always" t) + (other :tag "eventually" eventually)) + :group 'lazy-lock) + +(defcustom lazy-lock-defer-contextually 'syntax-driven + "*If non-nil, means deferred fontification should be syntactically true. +If nil, means deferred fontification occurs only on those lines modified. This +means where modification on a line causes syntactic change on subsequent lines, +those subsequent lines are not refontified to reflect their new context. +If t, means deferred fontification occurs on those lines modified and all +subsequent lines. This means those subsequent lines are refontified to reflect +their new syntactic context, either immediately or when scrolling into them. +If any other value, e.g., `syntax-driven', means deferred syntactically true +fontification occurs only if syntactic fontification is performed using the +buffer mode's syntax table, i.e., only if `font-lock-keywords-only' is nil. + +The value of this variable is used when Lazy Lock mode is turned on." + :type '(choice (const :tag "never" nil) + (const :tag "always" t) + (other :tag "syntax-driven" syntax-driven)) + :group 'lazy-lock) + +(defcustom lazy-lock-defer-time + (if (featurep 'lisp-float-type) (/ (float 1) (float 4)) 1) + "*Time in seconds to delay before beginning deferred fontification. +Deferred fontification occurs if there is no input within this time. +If nil, means fontification is never deferred, regardless of the values of the +variables `lazy-lock-defer-on-the-fly', `lazy-lock-defer-on-scrolling' and +`lazy-lock-defer-contextually'. + +The value of this variable is used when Lazy Lock mode is turned on." + :type '(choice (const :tag "never" nil) + (number :tag "seconds")) + :group 'lazy-lock) + +(defcustom lazy-lock-stealth-time 30 + "*Time in seconds to delay before beginning stealth fontification. +Stealth fontification occurs if there is no input within this time. +If nil, means stealth fontification is never performed. + +The value of this variable is used when Lazy Lock mode is turned on." + :type '(choice (const :tag "never" nil) + (number :tag "seconds")) + :group 'lazy-lock) + +(defcustom lazy-lock-stealth-lines (if font-lock-maximum-decoration 100 250) + "*Maximum size of a chunk of stealth fontification. +Each iteration of stealth fontification can fontify this number of lines. +To speed up input response during stealth fontification, at the cost of stealth +taking longer to fontify, you could reduce the value of this variable." + :type '(integer :tag "lines") + :group 'lazy-lock) + +(defcustom lazy-lock-stealth-load + (if (condition-case nil (load-average) (error)) 200) + "*Load in percentage above which stealth fontification is suspended. +Stealth fontification pauses when the system short-term load average (as +returned by the function `load-average' if supported) goes above this level, +thus reducing the demand that stealth fontification makes on the system. +If nil, means stealth fontification is never suspended. +To reduce machine load during stealth fontification, at the cost of stealth +taking longer to fontify, you could reduce the value of this variable. +See also `lazy-lock-stealth-nice'." + :type (if (condition-case nil (load-average) (error)) + '(choice (const :tag "never" nil) + (integer :tag "load")) + '(const :format "%t: unsupported\n" nil)) + :group 'lazy-lock) + +(defcustom lazy-lock-stealth-nice + (if (featurep 'lisp-float-type) (/ (float 1) (float 8)) 1) + "*Time in seconds to pause between chunks of stealth fontification. +Each iteration of stealth fontification is separated by this amount of time, +thus reducing the demand that stealth fontification makes on the system. +If nil, means stealth fontification is never paused. +To reduce machine load during stealth fontification, at the cost of stealth +taking longer to fontify, you could increase the value of this variable. +See also `lazy-lock-stealth-load'." + :type '(choice (const :tag "never" nil) + (number :tag "seconds")) + :group 'lazy-lock) + +(defcustom lazy-lock-stealth-verbose + (if (featurep 'lisp-float-type) + (and (not lazy-lock-defer-contextually) (not (null font-lock-verbose)))) + "*If non-nil, means stealth fontification should show status messages." + :type 'boolean + :group 'lazy-lock) + +;; User Functions: + +;;;###autoload +(defun lazy-lock-mode (&optional arg) + "Toggle Lazy Lock mode. +With arg, turn Lazy Lock mode on if and only if arg is positive. Enable it +automatically in your `~/.emacs' by: + + (setq font-lock-support-mode 'lazy-lock-mode) + +For a newer font-lock support mode with similar functionality, see +`jit-lock-mode'. Eventually, Lazy Lock mode will be deprecated in +JIT Lock's favor. + +When Lazy Lock mode is enabled, fontification can be lazy in a number of ways: + +- Demand-driven buffer fontification if `lazy-lock-minimum-size' is non-nil. + This means initial fontification does not occur if the buffer is greater than + `lazy-lock-minimum-size' characters in length. Instead, fontification occurs + when necessary, such as when scrolling through the buffer would otherwise + reveal unfontified areas. This is useful if buffer fontification is too slow + for large buffers. + +- Deferred scroll fontification if `lazy-lock-defer-on-scrolling' is non-nil. + This means demand-driven fontification does not occur as you scroll. + Instead, fontification is deferred until after `lazy-lock-defer-time' seconds + of Emacs idle time, while Emacs remains idle. This is useful if + fontification is too slow to keep up with scrolling. + +- Deferred on-the-fly fontification if `lazy-lock-defer-on-the-fly' is non-nil. + This means on-the-fly fontification does not occur as you type. Instead, + fontification is deferred until after `lazy-lock-defer-time' seconds of Emacs + idle time, while Emacs remains idle. This is useful if fontification is too + slow to keep up with your typing. + +- Deferred context fontification if `lazy-lock-defer-contextually' is non-nil. + This means fontification updates the buffer corresponding to true syntactic + context, after `lazy-lock-defer-time' seconds of Emacs idle time, while Emacs + remains idle. Otherwise, fontification occurs on modified lines only, and + subsequent lines can remain fontified corresponding to previous syntactic + contexts. This is useful where strings or comments span lines. + +- Stealthy buffer fontification if `lazy-lock-stealth-time' is non-nil. + This means remaining unfontified areas of buffers are fontified if Emacs has + been idle for `lazy-lock-stealth-time' seconds, while Emacs remains idle. + This is useful if any buffer has any deferred fontification. + +Basic Font Lock mode on-the-fly fontification behaviour fontifies modified +lines only. Thus, if `lazy-lock-defer-contextually' is non-nil, Lazy Lock mode +on-the-fly fontification may fontify differently, albeit correctly. In any +event, to refontify some lines you can use \\[font-lock-fontify-block]. + +Stealth fontification only occurs while the system remains unloaded. +If the system load rises above `lazy-lock-stealth-load' percent, stealth +fontification is suspended. Stealth fontification intensity is controlled via +the variable `lazy-lock-stealth-nice' and `lazy-lock-stealth-lines', and +verbosity is controlled via the variable `lazy-lock-stealth-verbose'." + (interactive "P") + (let* ((was-on lazy-lock-mode) + (now-on (unless (memq 'lazy-lock-mode font-lock-inhibit-thing-lock) + (if arg (> (prefix-numeric-value arg) 0) (not was-on))))) + (cond ((and now-on (not font-lock-mode)) + ;; Turned on `lazy-lock-mode' rather than `font-lock-mode'. + (let ((font-lock-support-mode 'lazy-lock-mode)) + (font-lock-mode t))) + (now-on + ;; Turn ourselves on. + (set (make-local-variable 'lazy-lock-mode) t) + (lazy-lock-install)) + (was-on + ;; Turn ourselves off. + (set (make-local-variable 'lazy-lock-mode) nil) + (lazy-lock-unstall))))) + +;;;###autoload +(defun turn-on-lazy-lock () + "Unconditionally turn on Lazy Lock mode." + (lazy-lock-mode t)) + +(defun lazy-lock-install () + (let ((min-size (font-lock-value-in-major-mode lazy-lock-minimum-size)) + (defer-change (and lazy-lock-defer-time lazy-lock-defer-on-the-fly)) + (defer-scroll (and lazy-lock-defer-time lazy-lock-defer-on-scrolling)) + (defer-context (and lazy-lock-defer-time lazy-lock-defer-contextually + (or (eq lazy-lock-defer-contextually t) + (null font-lock-keywords-only))))) + ;; + ;; Tell Font Lock whether Lazy Lock will do fontification. + (make-local-variable 'font-lock-fontified) + (setq font-lock-fontified (and min-size (>= (buffer-size) min-size))) + ;; + ;; Add the text properties and fontify. + (if (not font-lock-fontified) + (lazy-lock-after-fontify-buffer) + ;; Make sure we fontify in any existing windows showing the buffer. + (let ((windows (get-buffer-window-list (current-buffer) 'nomini t))) + (lazy-lock-after-unfontify-buffer) + (while windows + (lazy-lock-fontify-conservatively (car windows)) + (setq windows (cdr windows))))) + ;; + ;; Add the fontification hooks. + (lazy-lock-install-hooks + font-lock-fontified + (cond ((eq (car-safe defer-change) 'not) + (not (memq major-mode (cdr defer-change)))) + ((listp defer-change) + (memq major-mode defer-change)) + (t + defer-change)) + (eq defer-scroll t) + defer-context) + ;; + ;; Add the fontification timers. + (lazy-lock-install-timers + (if (or defer-change defer-scroll defer-context) lazy-lock-defer-time) + lazy-lock-stealth-time))) + +(defun lazy-lock-install-hooks (fontifying + defer-change defer-scroll defer-context) + ;; + ;; Add hook if lazy-lock.el is fontifying on scrolling or is deferring. + (when (or fontifying defer-change defer-scroll defer-context) + (add-hook 'window-scroll-functions (if defer-scroll + 'lazy-lock-defer-after-scroll + 'lazy-lock-fontify-after-scroll) + nil t)) + ;; + ;; Add hook if lazy-lock.el is fontifying and is not deferring changes. + (when (and fontifying (not defer-change) (not defer-context)) + (add-hook 'before-change-functions 'lazy-lock-arrange-before-change nil t)) + ;; + ;; Replace Font Lock mode hook. + (remove-hook 'after-change-functions 'font-lock-after-change-function t) + (add-hook 'after-change-functions + (cond ((and defer-change defer-context) + 'lazy-lock-defer-rest-after-change) + (defer-change + 'lazy-lock-defer-line-after-change) + (defer-context + 'lazy-lock-fontify-rest-after-change) + (t + 'lazy-lock-fontify-line-after-change)) + nil t) + ;; + ;; Add package-specific hook. + (add-hook 'outline-view-change-hook 'lazy-lock-fontify-after-visage nil t) + (add-hook 'hs-hide-hook 'lazy-lock-fontify-after-visage nil t)) + +(defun lazy-lock-install-timers (dtime stime) + ;; Schedule or re-schedule the deferral and stealth timers. + ;; The layout of `lazy-lock-timers' is: + ;; ((DEFER-TIME . DEFER-TIMER) (STEALTH-TIME . STEALTH-TIMER) + ;; If an idle timeout has changed, cancel the existing idle timer (if there + ;; is one) and schedule a new one (if the new idle timeout is non-nil). + (unless (eq dtime (car (car lazy-lock-timers))) + (let ((defer (car lazy-lock-timers))) + (when (cdr defer) + (cancel-timer (cdr defer))) + (setcar lazy-lock-timers (cons dtime (and dtime + (run-with-idle-timer dtime t 'lazy-lock-fontify-after-defer)))))) + (unless (eq stime (car (cdr lazy-lock-timers))) + (let ((stealth (cdr lazy-lock-timers))) + (when (cdr stealth) + (cancel-timer (cdr stealth))) + (setcdr lazy-lock-timers (cons stime (and stime + (run-with-idle-timer stime t 'lazy-lock-fontify-after-idle))))))) + +(defun lazy-lock-unstall () + ;; + ;; If Font Lock mode is still enabled, make sure that the buffer is + ;; fontified, and reinstall its hook. We must do this first. + (when font-lock-mode + (when (lazy-lock-unfontified-p) + (let ((verbose (if (numberp font-lock-verbose) + (> (buffer-size) font-lock-verbose) + font-lock-verbose))) + (with-temp-message + (when verbose + (format "Fontifying %s..." (buffer-name))) + ;; Make sure we fontify etc. in the whole buffer. + (save-restriction + (widen) + (lazy-lock-fontify-region (point-min) (point-max)))))) + (add-hook 'after-change-functions 'font-lock-after-change-function nil t)) + ;; + ;; Remove the text properties. + (lazy-lock-after-unfontify-buffer) + ;; + ;; Remove the fontification hooks. + (remove-hook 'window-scroll-functions 'lazy-lock-fontify-after-scroll t) + (remove-hook 'window-scroll-functions 'lazy-lock-defer-after-scroll t) + (remove-hook 'before-change-functions 'lazy-lock-arrange-before-change t) + (remove-hook 'after-change-functions 'lazy-lock-fontify-line-after-change t) + (remove-hook 'after-change-functions 'lazy-lock-fontify-rest-after-change t) + (remove-hook 'after-change-functions 'lazy-lock-defer-line-after-change t) + (remove-hook 'after-change-functions 'lazy-lock-defer-rest-after-change t) + (remove-hook 'outline-view-change-hook 'lazy-lock-fontify-after-visage t) + (remove-hook 'hs-hide-hook 'lazy-lock-fontify-after-visage t)) + +;; Hook functions. + +;; Lazy Lock mode intervenes when (1) a previously invisible buffer region +;; becomes visible, i.e., for demand- or defer-driven on-the-scroll +;; fontification, (2) a buffer modification occurs, i.e., for defer-driven +;; on-the-fly fontification, (3) Emacs becomes idle, i.e., for fontification of +;; deferred fontification and stealth fontification, and (4) other special +;; occasions. + +;; 1. There are three ways whereby this can happen. +;; +;; (a) Scrolling the window, either explicitly (e.g., `scroll-up') or +;; implicitly (e.g., `search-forward'). Here, `window-start' changes. +;; Fontification occurs by adding `lazy-lock-fontify-after-scroll' (for +;; demand-driven fontification) or `lazy-lock-defer-after-scroll' (for +;; defer-driven fontification) to the hook `window-scroll-functions'. + +(defun lazy-lock-fontify-after-scroll (window window-start) + ;; Called from `window-scroll-functions'. + ;; Fontify WINDOW from WINDOW-START following the scroll. + (let ((inhibit-point-motion-hooks t)) + (lazy-lock-fontify-region window-start (window-end window t))) + ;; A prior deletion that did not cause scrolling, followed by a scroll, would + ;; result in an unnecessary trigger after this if we did not cancel it now. + (set-window-redisplay-end-trigger window nil)) + +(defun lazy-lock-defer-after-scroll (window window-start) + ;; Called from `window-scroll-functions'. + ;; Defer fontification following the scroll. Save the current buffer so that + ;; we subsequently fontify in all windows showing the buffer. + (unless (memq (current-buffer) lazy-lock-buffers) + (push (current-buffer) lazy-lock-buffers)) + ;; A prior deletion that did not cause scrolling, followed by a scroll, would + ;; result in an unnecessary trigger after this if we did not cancel it now. + (set-window-redisplay-end-trigger window nil)) + +;; (b) Resizing the window, either explicitly (e.g., `enlarge-window') or +;; implicitly (e.g., `delete-other-windows'). Here, `window-end' changes. +;; Fontification occurs by adding `lazy-lock-fontify-after-resize' to the +;; hook `window-size-change-functions'. + +(defun lazy-lock-fontify-after-resize (frame) + ;; Called from `window-size-change-functions'. + ;; Fontify windows in FRAME following the resize. We cannot use + ;; `window-start' or `window-end' so we fontify conservatively. + (save-excursion + (save-selected-window + (select-frame frame) + (walk-windows (function (lambda (window) + (set-buffer (window-buffer window)) + (when lazy-lock-mode + (lazy-lock-fontify-conservatively window)) + (set-window-redisplay-end-trigger window nil))) + 'nomini frame)))) + +;; (c) Deletion in the buffer. Here, a `window-end' marker can become visible. +;; Fontification occurs by adding `lazy-lock-arrange-before-change' to +;; `before-change-functions' and `lazy-lock-fontify-after-trigger' to the +;; hook `redisplay-end-trigger-functions'. Before every deletion, the +;; marker `window-redisplay-end-trigger' position is set to the soon-to-be +;; changed `window-end' position. If the marker becomes visible, +;; `lazy-lock-fontify-after-trigger' gets called. Ouch. Note that we only +;; have to deal with this eventuality if there is no on-the-fly deferral. + +(defun lazy-lock-arrange-before-change (beg end) + ;; Called from `before-change-functions'. + ;; Arrange that if text becomes visible it will be fontified (if a deletion + ;; is pending, text might become visible at the bottom). + (unless (eq beg end) + (let ((windows (get-buffer-window-list (current-buffer) 'nomini t)) window) + (while windows + (setq window (car windows)) + (unless (markerp (window-redisplay-end-trigger window)) + (set-window-redisplay-end-trigger window (make-marker))) + (set-marker (window-redisplay-end-trigger window) (window-end window)) + (setq windows (cdr windows)))))) + +(defun lazy-lock-fontify-after-trigger (window trigger-point) + ;; Called from `redisplay-end-trigger-functions'. + ;; Fontify WINDOW from TRIGGER-POINT following the redisplay. + ;; We could probably just use `lazy-lock-fontify-after-scroll' without loss: + ;; (inline (lazy-lock-fontify-after-scroll window (window-start window))) + (let ((inhibit-point-motion-hooks t)) + (lazy-lock-fontify-region trigger-point (window-end window t)))) + +;; 2. Modified text must be marked as unfontified so it can be identified and +;; fontified later when Emacs is idle. Deferral occurs by adding one of +;; `lazy-lock-fontify-*-after-change' (for on-the-fly fontification) or +;; `lazy-lock-defer-*-after-change' (for deferred fontification) to the +;; hook `after-change-functions'. + +(defalias 'lazy-lock-fontify-line-after-change + ;; Called from `after-change-functions'. + ;; Fontify the current change. + 'font-lock-after-change-function) + +(defun lazy-lock-fontify-rest-after-change (beg end old-len) + ;; Called from `after-change-functions'. + ;; Fontify the current change and defer fontification of the rest of the + ;; buffer. Save the current buffer so that we subsequently fontify in all + ;; windows showing the buffer. + (lazy-lock-fontify-line-after-change beg end old-len) + (save-buffer-state nil + (unless (memq (current-buffer) lazy-lock-buffers) + (push (current-buffer) lazy-lock-buffers)) + (save-restriction + (widen) + (remove-text-properties end (point-max) '(lazy-lock nil))))) + +(defun lazy-lock-defer-line-after-change (beg end old-len) + ;; Called from `after-change-functions'. + ;; Defer fontification of the current change. Save the current buffer so + ;; that we subsequently fontify in all windows showing the buffer. + (save-buffer-state nil + (unless (memq (current-buffer) lazy-lock-buffers) + (push (current-buffer) lazy-lock-buffers)) + (remove-text-properties (max (1- beg) (point-min)) + (min (1+ end) (point-max)) + '(lazy-lock nil)))) + +(defun lazy-lock-defer-rest-after-change (beg end old-len) + ;; Called from `after-change-functions'. + ;; Defer fontification of the rest of the buffer. Save the current buffer so + ;; that we subsequently fontify in all windows showing the buffer. + (save-buffer-state nil + (unless (memq (current-buffer) lazy-lock-buffers) + (push (current-buffer) lazy-lock-buffers)) + (save-restriction + (widen) + (remove-text-properties (max (1- beg) (point-min)) + (point-max) + '(lazy-lock nil))))) + +;; 3. Deferred fontification and stealth fontification are done from these two +;; functions. They are set up as Idle Timers. + +(defun lazy-lock-fontify-after-defer () + ;; Called from `timer-idle-list'. + ;; Fontify all windows where deferral has occurred for its buffer. + (save-excursion + (while (and lazy-lock-buffers (not (input-pending-p))) + (let ((buffer (car lazy-lock-buffers)) windows) + ;; Paranoia: check that the buffer is still live and Lazy Lock mode on. + (when (buffer-live-p buffer) + (set-buffer buffer) + (when lazy-lock-mode + (setq windows (get-buffer-window-list buffer 'nomini t)) + (while windows + (lazy-lock-fontify-window (car windows)) + (setq windows (cdr windows))))) + (setq lazy-lock-buffers (cdr lazy-lock-buffers))))) + ;; Add hook if fontification should now be defer-driven in this buffer. + (when (and lazy-lock-mode lazy-lock-defer-on-scrolling + (memq 'lazy-lock-fontify-after-scroll window-scroll-functions) + (not (or (input-pending-p) (lazy-lock-unfontified-p)))) + (remove-hook 'window-scroll-functions 'lazy-lock-fontify-after-scroll t) + (add-hook 'window-scroll-functions 'lazy-lock-defer-after-scroll nil t))) + +(defun lazy-lock-fontify-after-idle () + ;; Called from `timer-idle-list'. + ;; Fontify all buffers that need it, stealthily while idle. + (unless (or executing-kbd-macro (window-minibuffer-p (selected-window))) + ;; Loop over all buffers, fontify stealthily for each if necessary. + (let ((buffers (buffer-list)) (continue t) + message message-log-max minibuffer-auto-raise) + (save-excursion + (do-while (and buffers continue) + (set-buffer (car buffers)) + (if (not (and lazy-lock-mode (lazy-lock-unfontified-p))) + (setq continue (not (input-pending-p))) + ;; Fontify regions in this buffer while there is no input. + (with-temp-message + (when lazy-lock-stealth-verbose + "Fontifying stealthily...") + (do-while (and (lazy-lock-unfontified-p) continue) + (if (and lazy-lock-stealth-load + (> (car (load-average)) lazy-lock-stealth-load)) + ;; Wait a while before continuing with the loop. + (progn + (when message + (message "Fontifying stealthily...suspended") + (setq message nil)) + (setq continue (sit-for (or lazy-lock-stealth-time 30)))) + ;; Fontify a chunk. + (when lazy-lock-stealth-verbose + (if message + (message "Fontifying stealthily... %2d%% of %s" + (lazy-lock-percent-fontified) (buffer-name)) + (message "Fontifying stealthily...") + (setq message t))) + ;; Current buffer may have changed during `sit-for'. + (set-buffer (car buffers)) + (lazy-lock-fontify-chunk) + (setq continue (sit-for (or lazy-lock-stealth-nice 0))))))) + (setq buffers (cdr buffers))))))) + +;; 4. Special circumstances. + +(defun lazy-lock-fontify-after-visage () + ;; Called from `outline-view-change-hook' and `hs-hide-hook'. + ;; Fontify windows showing the current buffer, as its visibility has changed. + ;; This is a conspiracy hack between lazy-lock.el, outline.el and + ;; hideshow.el. + (let ((windows (get-buffer-window-list (current-buffer) 'nomini t))) + (while windows + (lazy-lock-fontify-conservatively (car windows)) + (setq windows (cdr windows))))) + +(defun lazy-lock-after-fontify-buffer () + ;; Called from `font-lock-after-fontify-buffer'. + ;; Mark the current buffer as fontified. + ;; This is a conspiracy hack between lazy-lock.el and font-lock.el. + (save-buffer-state nil + (add-text-properties (point-min) (point-max) '(lazy-lock t)))) + +(defun lazy-lock-after-unfontify-buffer () + ;; Called from `font-lock-after-unfontify-buffer'. + ;; Mark the current buffer as unfontified. + ;; This is a conspiracy hack between lazy-lock.el and font-lock.el. + (save-buffer-state nil + (remove-text-properties (point-min) (point-max) '(lazy-lock nil)))) + +;; Fontification functions. + +;; If packages want to ensure that some region of the buffer is fontified, they +;; should use this function. For an example, see ps-print.el. +(defun lazy-lock-fontify-region (beg end) + ;; Fontify between BEG and END, where necessary, in the current buffer. + (save-restriction + (widen) + (when (setq beg (text-property-any beg end 'lazy-lock nil)) + (save-excursion + (save-match-data + (save-buffer-state + ;; Ensure syntactic fontification is always correct. + (font-lock-beginning-of-syntax-function next) + ;; Find successive unfontified regions between BEG and END. + (condition-case data + (do-while beg + (setq next (or (text-property-any beg end 'lazy-lock t) end)) + ;; Make sure the region end points are at beginning of line. + (goto-char beg) + (unless (bolp) + (beginning-of-line) + (setq beg (point))) + (goto-char next) + (unless (bolp) + (forward-line) + (setq next (point))) + ;; Fontify the region, then flag it as fontified. + (font-lock-fontify-region beg next) + (add-text-properties beg next '(lazy-lock t)) + (setq beg (text-property-any next end 'lazy-lock nil))) + ((error quit) (message "Fontifying region...%s" data))))))))) + +(defun lazy-lock-fontify-chunk () + ;; Fontify the nearest chunk, for stealth, in the current buffer. + (let ((inhibit-point-motion-hooks t)) + (save-excursion + (save-restriction + (widen) + ;; Move to end of line in case the character at point is not fontified. + (end-of-line) + ;; Find where the previous (next) unfontified regions end (begin). + (let ((prev (previous-single-property-change (point) 'lazy-lock)) + (next (text-property-any (point) (point-max) 'lazy-lock nil))) + ;; Fontify from the nearest unfontified position. + (if (or (null prev) (and next (< (- next (point)) (- (point) prev)))) + ;; The next, or neither, region is the nearest not fontified. + (lazy-lock-fontify-region + (progn (goto-char (or next (point-min))) + (beginning-of-line) + (point)) + (progn (goto-char (or next (point-min))) + (forward-line lazy-lock-stealth-lines) + (point))) + ;; The previous region is the nearest not fontified. + (lazy-lock-fontify-region + (progn (goto-char prev) + (forward-line (- lazy-lock-stealth-lines)) + (point)) + (progn (goto-char prev) + (forward-line) + (point))))))))) + +(defun lazy-lock-fontify-window (window) + ;; Fontify in WINDOW between `window-start' and `window-end'. + ;; We can only do this when we can use `window-start' and `window-end'. + (with-current-buffer (window-buffer window) + (lazy-lock-fontify-region (window-start window) (window-end window)))) + +(defun lazy-lock-fontify-conservatively (window) + ;; Fontify in WINDOW conservatively around point. + ;; Where we cannot use `window-start' and `window-end' we do `window-height' + ;; lines around point. That way we guarantee to have done enough. + (with-current-buffer (window-buffer window) + (let ((inhibit-point-motion-hooks t)) + (lazy-lock-fontify-region + (save-excursion + (goto-char (window-point window)) + (vertical-motion (- (window-height window)) window) (point)) + (save-excursion + (goto-char (window-point window)) + (vertical-motion (window-height window) window) (point)))))) + +(defun lazy-lock-unfontified-p () + ;; Return non-nil if there is anywhere still to be fontified. + (save-restriction + (widen) + (text-property-any (point-min) (point-max) 'lazy-lock nil))) + +(defun lazy-lock-percent-fontified () + ;; Return the percentage (of characters) of the buffer that are fontified. + (save-restriction + (widen) + (let ((beg (point-min)) (size 0) next) + ;; Find where the next fontified region begins. + (while (setq beg (text-property-any beg (point-max) 'lazy-lock t)) + (setq next (or (text-property-any beg (point-max) 'lazy-lock nil) + (point-max))) + (incf size (- next beg)) + (setq beg next)) + ;; Float because using integer multiplication will frequently overflow. + (truncate (* (/ (float size) (point-max)) 100))))) + +;; Version dependent workarounds and fixes. + +(when (consp lazy-lock-defer-time) + ;; + ;; In 2.06.04 and below, `lazy-lock-defer-time' could specify modes and time. + (with-output-to-temp-buffer "*Help*" + (princ "The value of the variable `lazy-lock-defer-time' was\n ") + (princ lazy-lock-defer-time) + (princ "\n") + (princ "This variable cannot now be a list of modes and time,\n") + (princ "so instead use ") + (princ (substitute-command-keys "\\[customize-option]")) + (princ " to modify the variables, or put the forms:\n") + (princ " (setq lazy-lock-defer-time ") + (princ (cdr lazy-lock-defer-time)) + (princ ")\n") + (princ " (setq lazy-lock-defer-on-the-fly '") + (princ (car lazy-lock-defer-time)) + (princ ")\n") + (princ "in your ~/.emacs. ") + (princ "The above forms have been evaluated for this editor session,\n") + (princ "but you should use ") + (princ (substitute-command-keys "\\[customize-option]")) + (princ " or change your ~/.emacs now.")) + (setq lazy-lock-defer-on-the-fly (car lazy-lock-defer-time) + lazy-lock-defer-time (cdr lazy-lock-defer-time))) + +(when (boundp 'lazy-lock-defer-driven) + ;; + ;; In 2.06.04 and below, `lazy-lock-defer-driven' was the variable name. + (with-output-to-temp-buffer "*Help*" + (princ "The value of the variable `lazy-lock-defer-driven' is set to ") + (if (memq lazy-lock-defer-driven '(nil t)) + (princ lazy-lock-defer-driven) + (princ "`") + (princ lazy-lock-defer-driven) + (princ "'")) + (princ ".\n") + (princ "This variable is now called `lazy-lock-defer-on-scrolling',\n") + (princ "so instead use ") + (princ (substitute-command-keys "\\[customize-option]")) + (princ " to modify the variable, or put the form:\n") + (princ " (setq lazy-lock-defer-on-scrolling ") + (unless (memq lazy-lock-defer-driven '(nil t)) + (princ "'")) + (princ lazy-lock-defer-driven) + (princ ")\n") + (princ "in your ~/.emacs. ") + (princ "The above form has been evaluated for this editor session,\n") + (princ "but you should use ") + (princ (substitute-command-keys "\\[customize-option]")) + (princ " or change your ~/.emacs now.")) + (setq lazy-lock-defer-on-scrolling lazy-lock-defer-driven)) + +;; Install ourselves: + +(add-hook 'window-size-change-functions 'lazy-lock-fontify-after-resize) +(add-hook 'redisplay-end-trigger-functions 'lazy-lock-fontify-after-trigger) + +(unless (assq 'lazy-lock-mode minor-mode-alist) + (setq minor-mode-alist (append minor-mode-alist '((lazy-lock-mode nil))))) + +;; Provide ourselves: + +(provide 'lazy-lock) + +;;; arch-tag: c1776846-f046-4a45-9684-54b951b12fc9 +;;; lazy-lock.el ends here
--- a/lisp/progmodes/compile.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/progmodes/compile.el Fri Apr 08 16:25:22 2005 +0000 @@ -1233,6 +1233,10 @@ (make-local-variable 'compilation-messages-start) (make-local-variable 'compilation-error-screen-columns) (make-local-variable 'overlay-arrow-position) + (set (make-local-variable 'overlay-arrow-string) "=>") + (setq next-error-overlay-arrow-position nil) + (add-hook 'kill-buffer-hook + (lambda () (setq next-error-overlay-arrow-position nil)) nil t) ;; Note that compilation-next-error-function is for interfacing ;; with the next-error function in simple.el, and it's only ;; coincidentally named similarly to compilation-next-error. @@ -1641,8 +1645,9 @@ (numberp next-error-highlight))) (delete-overlay compilation-highlight-overlay)))))) (when (and (eq next-error-highlight 'fringe-arrow)) - (set (make-local-variable 'overlay-arrow-position) - (copy-marker (line-beginning-position)))))) + (setq next-error-overlay-arrow-position + (copy-marker (line-beginning-position)))))) + (defun compilation-find-file (marker filename dir &rest formats) "Find a buffer for file FILENAME.
--- a/lisp/progmodes/sh-script.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/progmodes/sh-script.el Fri Apr 08 16:25:22 2005 +0000 @@ -574,7 +574,7 @@ ;; but it *did* have an asterisk in the docstring! (defcustom sh-builtins '((bash sh-append posix - "." "alias" "bg" "bind" "builtin" "compgen" "complete" + "." "alias" "bg" "bind" "builtin" "caller" "compgen" "complete" "declare" "dirs" "disown" "enable" "fc" "fg" "help" "history" "jobs" "kill" "let" "local" "popd" "printf" "pushd" "shopt" "source" "suspend" "typeset" "unalias") @@ -791,6 +791,10 @@ :group 'sh-indentation) (defvar sh-heredoc-face 'sh-heredoc-face) +(defface sh-escaped-newline '((t :inherit font-lock-string-face)) + "Face used for (non-escaped) backslash at end of a line in Shell-script mode." + :group 'sh-script + :version "22.1") (defvar sh-font-lock-keywords '((csh sh-append shell @@ -815,7 +819,7 @@ ;; The next entry is only used for defining the others (shell sh-append executable-font-lock-keywords ;; Using font-lock-string-face here confuses sh-get-indent-info. - ("\\\\$" 0 font-lock-warning-face) + ("\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\\\)$" 3 'sh-escaped-newline) ("\\\\[^A-Za-z0-9]" 0 font-lock-string-face) ("\\${?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\|[$*_]\\)" 1 font-lock-variable-name-face))
--- a/lisp/progmodes/tcl.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/progmodes/tcl.el Fri Apr 08 16:25:22 2005 +0000 @@ -42,6 +42,7 @@ ;; * tcl-typeword-list is similar, but uses font-lock-type-face. ;; * tcl-keyword-list is a list of keywords. I've generally used this ;; for flow-control words. Eg I add "unwind_protect" to this list. +;; * tcl-builtin-list lists commands to be given font-lock-builtin-face. ;; * tcl-type-alist can be used to minimally customize indentation ;; according to context. @@ -193,6 +194,11 @@ quoted for Tcl." :type 'string) +(defface tcl-escaped-newline '((t :inherit font-lock-string-face)) + "Face used for (non-escaped) backslash at end of a line in Tcl mode." + :group 'tcl + :version "22.1") + ;; ;; Keymaps, abbrevs, syntax tables. ;; @@ -372,6 +378,21 @@ Default list includes some TclX keywords. Call `tcl-set-font-lock-keywords' after changing this list.") +(defvar tcl-builtin-list + '("after" "append" "array" "bgerror" "binary" "catch" "cd" "clock" + "close" "concat" "console" "dde" "encoding" "eof" "exec" "expr" + "fblocked" "fconfigure" "fcopy" "file" "fileevent" "flush" + "format" "gets" "glob" "history" "incr" "info" "interp" "join" + "lappend" "lindex" "linsert" "list" "llength" "load" "lrange" + "lreplace" "lsort" "namespace" "open" "package" "pid" "puts" "pwd" + "read" "regexp" "registry" "regsub" "rename" "scan" "seek" "set" + "socket" "source" "split" "string" "subst" "tell" "time" "trace" + "unknown" "unset" "vwait") + "List of Tcl commands. Used only for highlighting. +Call `tcl-set-font-lock-keywords' after changing this list. +This list excludes those commands already found in `tcl-proc-list' and +`tcl-keyword-list'.") + (defvar tcl-font-lock-keywords nil "Keywords to highlight for Tcl. See variable `font-lock-keywords'. This variable is generally set from `tcl-proc-regexp', @@ -467,11 +488,30 @@ "\\(\\s-\\|$\\)") 2 'font-lock-type-face) + (list (concat "\\_<" (regexp-opt tcl-builtin-list t) "\\_>") + 1 'font-lock-builtin-face) + + ;; When variable names are enclosed in {} braces, any + ;; character can be used. Otherwise just letters, digits, + ;; underscores. Variable names can be prefixed with any + ;; number of "namespace::" qualifiers. A leading "::" refers + ;; to the global namespace. + '("\\${\\([^}]+\\)}" 1 font-lock-variable-name-face) + '("\\$\\(\\(?:::\\)?\\(?:[[:alnum:]_]+::\\)*[[:alnum:]_]+\\)" + 1 font-lock-variable-name-face) + '("\\(?:\\s-\\|^\\|\\[\\)set\\s-+{\\([^}]+\\)}" + 1 font-lock-variable-name-face keep) + '("\\(?:\\s-\\|^\\|\\[\\)set\\s-+\\(\\(?:::\\)?\ +\\(?:[[:alnum:]_]+::\\)*[[:alnum:]_]+\\)" + 1 font-lock-variable-name-face keep) + + '("\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\\\)$" 3 'tcl-escaped-newline) + ;; Keywords. Only recognized if surrounded by whitespace. ;; FIXME consider using "not word or symbol", not ;; "whitespace". (cons (concat "\\_<" (regexp-opt tcl-keyword-list t) "\\_>") - 2)))) + 1)))) (if tcl-proc-regexp () @@ -542,8 +582,8 @@ (set (make-local-variable 'font-lock-defaults) '(tcl-font-lock-keywords nil nil nil beginning-of-defun - (font-lock-syntactic-keywords . tcl-font-lock-syntactic-keywords) - (parse-sexp-lookup-properties . t))) + (font-lock-syntactic-keywords . tcl-font-lock-syntactic-keywords) + (parse-sexp-lookup-properties . t))) (set (make-local-variable 'imenu-generic-expression) tcl-imenu-generic-expression)
--- a/lisp/simple.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/simple.el Fri Apr 08 16:25:22 2005 +0000 @@ -114,6 +114,10 @@ (defvar next-error-highlight-timer nil) +(defvar next-error-overlay-arrow-position nil) +(put 'next-error-overlay-arrow-position 'overlay-arrow-string "=>") +(add-to-list 'overlay-arrow-variable-list 'next-error-overlay-arrow-position) + (defvar next-error-last-buffer nil "The most recent next-error buffer. A buffer becomes most recent when its compilation, grep, or
--- a/lisp/startup.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/startup.el Fri Apr 08 16:25:22 2005 +0000 @@ -662,7 +662,7 @@ (while (and (not done) args) (let* ((longopts '(("--no-init-file") ("--no-site-file") ("--user") ("--debug-init") ("--iconic") ("--icon-type") - ("--no-blinking-cursor"))) + ("--no-blinking-cursor") ("--bare-bones"))) (argi (pop args)) (orig-argi argi) argval) @@ -682,7 +682,7 @@ (setq argval nil argi orig-argi))))) (cond - ((equal argi "-Q") + ((member argi '("-Q" "-bare-bones")) (setq init-file-user nil site-run-file nil no-blinking-cursor t @@ -1485,9 +1485,16 @@ nil t)) (error nil)) (kill-buffer buffer))))) - ;; Stop any "Loading image..." message hiding echo-area-message. - (use-fancy-splash-screens-p) - (display-startup-echo-area-message)) + ;; display-splash-screen at the end of command-line-1 calls + ;; use-fancy-splash-screens-p. This can cause image.el to be + ;; loaded, putting "Loading image... done" in the echo area. + ;; This hides startup-echo-area-message. So + ;; use-fancy-splash-screens-p is called here simply to get the + ;; loading of image.el (if needed) out of the way before + ;; display-startup-echo-area-message runs. + (progn + (use-fancy-splash-screens-p) + (display-startup-echo-area-message))) ;; Delay 2 seconds after an init file error message ;; was displayed, so user can read it.
--- a/lisp/term/mac-win.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/term/mac-win.el Fri Apr 08 16:25:22 2005 +0000 @@ -1577,7 +1577,10 @@ (new-fontset font (x-complement-fontset-spec xlfd-fields nil)) ;; Create a fontset from FONT. The fontset name is ;; generated from FONT. - (create-fontset-from-ascii-font font resolved-name "startup")))) + (if (and (string= "mac" (aref xlfd-fields xlfd-regexp-registry-subnum)) + (string= "roman" (aref xlfd-fields xlfd-regexp-encoding-subnum))) + (create-fontset-from-mac-roman-font font resolved-name "startup") + (create-fontset-from-ascii-font font resolved-name "startup"))))) ;; Apply a geometry resource to the initial frame. Put it at the end ;; of the alist, so that anything specified on the command line takes
--- a/lisp/term/xterm.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/term/xterm.el Fri Apr 08 16:25:22 2005 +0000 @@ -109,15 +109,15 @@ ("red" 1 (205 0 0)) ; red3 ("green" 2 ( 0 205 0)) ; green3 ("yellow" 3 (205 205 0)) ; yellow3 - ("blue" 4 ( 0 0 205)) ; blue3 + ("blue" 4 ( 0 0 238)) ; blue2 ("magenta" 5 (205 0 205)) ; magenta3 ("cyan" 6 ( 0 205 205)) ; cyan3 ("white" 7 (229 229 229)) ; gray90 - ("brightblack" 8 ( 77 77 77)) ; gray30 + ("brightblack" 8 (127 127 127)) ; gray50 ("brightred" 9 (255 0 0)) ; red ("brightgreen" 10 ( 0 255 0)) ; green ("brightyellow" 11 (255 255 0)) ; yellow - ("brightblue" 12 ( 0 0 255)) ; blue + ("brightblue" 12 (92 92 255)) ; rgb:5c/5c/ff ("brightmagenta" 13 (255 0 255)) ; magenta ("brightcyan" 14 ( 0 255 255)) ; cyan ("brightwhite" 15 (255 255 255))) ; white
--- a/lisp/textmodes/org.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/textmodes/org.el Fri Apr 08 16:25:22 2005 +0000 @@ -279,7 +279,7 @@ :group 'org-startup :type 'boolean) -(defcustom org-insert-mode-line-in-empty-file t +(defcustom org-insert-mode-line-in-empty-file nil "Non-nil means insert the first line setting Org-mode in empty files. When the function `org-mode' is called interactively in an empty, this normally means that the file name does not automatically trigger Org-mode. @@ -3477,7 +3477,7 @@ (defun org-diary-default-entry () "Add a dummy entry to the diary. Needed to avoid empty dates which mess up holiday display." - (add-to-diary-list original-date "Org-mode dummy" "")) + (add-to-diary-list original-date "Org-mode dummy" "" nil)) (defun org-add-file (&optional file) "Add current file to the list of files in variable `org-agenda-files'.
--- a/lisp/textmodes/tex-mode.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/textmodes/tex-mode.el Fri Apr 08 16:25:22 2005 +0000 @@ -573,7 +573,7 @@ 2 '(tex-font-lock-append-prop 'italic) 'append) ;; This is separate from the previous one because of cases like ;; {\em foo {\bf bar} bla} where both match. - (list (concat "\\\\\\(bf\\)\\>" args) + (list (concat "\\\\\\(bf\\(series\\)?\\)\\>" args) 2 '(tex-font-lock-append-prop 'bold) 'append))))) "Gaudy expressions to highlight in TeX modes.")
--- a/lisp/wdired.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/wdired.el Fri Apr 08 16:25:22 2005 +0000 @@ -1,10 +1,10 @@ ;;; wdired.el --- Rename files editing their names in dired buffers -;; Copyright (C) 2001, 2004 Free Software Foundation, Inc. +;; Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc. ;; Filename: wdired.el -;; Author: Juan León Lahoz García <juan-leon.lahoz@tecsidel.es> -;; Version: 1.91 +;; Author: Juan León Lahoz García <juanleon1@gmail.com> +;; Version: 2.0 ;; Keywords: dired, environment, files, renaming ;; This file is part of GNU Emacs. @@ -156,9 +156,8 @@ ;;; Code: +(defvar dired-backup-overwrite) ; Only in emacs 20.x this is a custom var (eval-when-compile - (require 'advice) - (defvar dired-backup-overwrite) ; Only in emacs 20.x this is a custom var (set (make-local-variable 'byte-compile-dynamic) t)) (eval-and-compile @@ -199,19 +198,6 @@ (other :tag "As in dired mode" t)) :group 'wdired) -(defcustom wdired-advise-functions t - "*If t some editing commands are advised when wdired is loaded. -The advice only has effect in wdired mode. These commands are -`query-replace' `query-replace-regexp' `replace-string', and the -advice makes them to ignore read-only regions, so no attempts to -modify these regions are done by them, and so they don't end -prematurely. - -Setting this to nil does not unadvise the functions, if they are -already advised, but new Emacs will not advise them." - :type 'boolean - :group 'wdired) - (defcustom wdired-allow-to-redirect-links t "*If non-nil, the target of the symbolic links can be changed also. In systems without symbolic links support, this variable has no effect @@ -309,6 +295,7 @@ (interactive) (set (make-local-variable 'wdired-old-content) (buffer-substring (point-min) (point-max))) + (set (make-local-variable 'query-replace-skip-read-only) t) (use-local-map wdired-mode-map) (force-mode-line-update) (setq buffer-read-only nil) @@ -664,64 +651,6 @@ (interactive "p") (wdired-xcase-word 'capitalize-word arg)) -;; The following code is related to advice some interactive functions -;; to make some editing commands in wdired mode not to fail trying to -;; change read-only text. Notice that some advises advice and unadvise -;; them-self to another functions: search-forward and -;; re-search-forward. This is to keep these functions advised only -;; when is necessary. Since they are built-in commands used heavily in -;; lots of places, to have it permanently advised would cause some -;; performance loss. - - -(defun wdired-add-skip-in-replace (command) - "Advice COMMAND to skip matches while they have read-only properties. -This is useful to avoid \"read-only\" errors in search and replace -commands. This advice only has effect in wdired mode." - (eval - `(defadvice ,command (around wdired-discard-read-only activate) - ,(format "Make %s to work better with wdired,\n%s." command - "skipping read-only matches when invoked without argument") - ad-do-it - (if (eq major-mode 'wdired-mode) - (while (and ad-return-value - (text-property-any - (max 1 (1- (match-beginning 0))) (match-end 0) - 'read-only t)) - ad-do-it)) - ad-return-value))) - - -(defun wdired-add-replace-advice (command) - "Advice COMMAND to skip matches while they have read-only properties. -This is useful to avoid \"read-only\" errors in search and replace -commands. This advice only has effect in wdired mode." - (eval - `(defadvice ,command (around wdired-grok-read-only activate) - ,(format "Make %s to work better with wdired,\n%s." command - "skipping read-only matches when invoked without argument") - (if (eq major-mode 'wdired-mode) - (progn - (wdired-add-skip-in-replace 'search-forward) - (wdired-add-skip-in-replace 're-search-forward) - (unwind-protect - ad-do-it - (progn - (ad-remove-advice 'search-forward - 'around 'wdired-discard-read-only) - (ad-remove-advice 're-search-forward - 'around 'wdired-discard-read-only) - (ad-update 'search-forward) - (ad-update 're-search-forward)))) - ad-do-it) - ad-return-value))) - - -(if wdired-advise-functions - (progn - (mapcar 'wdired-add-replace-advice - '(query-replace query-replace-regexp replace-string)))) - ;; The following code deals with changing the access bits (or ;; permissions) of the files.
--- a/lisp/wid-edit.el Mon Apr 04 16:43:15 2005 +0000 +++ b/lisp/wid-edit.el Fri Apr 08 16:25:22 2005 +0000 @@ -1185,9 +1185,17 @@ ;; or if a special `boundary' field has been added after the widget ;; field. (if (overlayp overlay) - (if (and (not (eq (get-char-property (overlay-end overlay) - 'field - (widget-field-buffer widget)) + (if (and (not (eq (with-current-buffer + (widget-field-buffer widget) + (save-restriction + ;; `widget-narrow-to-field' can be + ;; active when this function is called + ;; from an change-functions hook. So + ;; temporarily remove field narrowing + ;; before to call `get-char-property'. + (widen) + (get-char-property (overlay-end overlay) + 'field))) 'boundary)) (or widget-field-add-space (null (widget-get widget :size))))
--- a/lispref/ChangeLog Mon Apr 04 16:43:15 2005 +0000 +++ b/lispref/ChangeLog Fri Apr 08 16:25:22 2005 +0000 @@ -1,3 +1,8 @@ +2005-04-05 Lute Kamstra <lute@gnu.org> + + * modes.texi (Defining Minor Modes): Document :group keyword + argument and its default value. + 2005-04-03 Lute Kamstra <lute@gnu.org> * hooks.texi (Standard Hooks): Add some hooks. Add cross
--- a/lispref/modes.texi Mon Apr 04 16:43:15 2005 +0000 +++ b/lispref/modes.texi Fri Apr 08 16:25:22 2005 +0000 @@ -1127,6 +1127,12 @@ corresponding values. A few keywords have special meanings: @table @code +@item :group @var{group} +Custom group name to use in all generated @code{defcustom} forms. +Defaults to @var{mode} without the possible trailing @samp{-mode}. Be +aware that this default may not be a valid customization group defined +with @code{defgroup}. Please make sure it is. + @item :global @var{global} If non-@code{nil} specifies that the minor mode should be global. By default, minor modes are buffer-local.
--- a/mac/ChangeLog Mon Apr 04 16:43:15 2005 +0000 +++ b/mac/ChangeLog Fri Apr 08 16:25:22 2005 +0000 @@ -1,3 +1,11 @@ +2005-04-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings + (CFBundleShortVersionString, CFBundleGetInfoString): Fix version + number and copyright. + + * Emacs.r (DITL, vers): Likewise. + 2005-03-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> * Emacs.app/Contents/Info.plist (CFBundleIdentifier): Change to
--- a/mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings Mon Apr 04 16:43:15 2005 +0000 +++ b/mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings Fri Apr 08 16:25:22 2005 +0000 @@ -1,5 +1,5 @@ /* Localized versions of Info.plist keys */ CFBundleName = "Emacs"; -CFBundleShortVersionString = "Emacs version 21"; -CFBundleGetInfoString = "Emacs version 21, Copyright 2002 FSF."; +CFBundleShortVersionString = "22.0.50"; +CFBundleGetInfoString = "22.0.50, Copyright (C) 2005 Free Software Foundation, Inc.";
--- a/mac/src/Emacs.r Mon Apr 04 16:43:15 2005 +0000 +++ b/mac/src/Emacs.r Fri Apr 08 16:25:22 2005 +0000 @@ -141,7 +141,7 @@ {10, 60, 72, 278}, StaticText { disabled, - "GNU Emacs 21 for Mac OS" + "GNU Emacs 22 for Mac OS" } } }; @@ -215,14 +215,14 @@ }; resource 'vers' (1) { - 0x1, - 0x0, - development, - 0x0, - 0, - "d6", - "GNU Emacs 21.1 for Mac OS\n\0xa9 2" - "000 Free Software Foundation" + 0x22, /* Major revision in BCD */ + 0x0, /* Minor revision in BCD */ + development, /* development, alpha, beta, or final (release) */ + 50, /* Non-final release # */ + 0, /* Region code */ + "22.0.50", /* Short version number */ + "22.0.50, Copyright \0xa9 2005 " + "Free Software Foundation, Inc." /* Long version number */ }; data 'EMAx' (0, "Owner resource") {
--- a/man/ChangeLog Mon Apr 04 16:43:15 2005 +0000 +++ b/man/ChangeLog Fri Apr 08 16:25:22 2005 +0000 @@ -1,3 +1,19 @@ +2005-04-06 Kim F. Storm <storm@cua.dk> + + * cmdargs.texi (Initial Options): Add --bare-bones alias for -Q. + +2005-04-04 Luc Teirlinck <teirllm@auburn.edu> + + * dired.texi (Dired Visiting): `dired-view-command-alist' has been + deleted. + (Marks vs Flags): Add some convenient key bindings. + (Hiding Subdirectories): Delete redundant and inaccurate sentence. + (Misc Dired Features): Correct and expand description of `w' command. + + * frames.texi (XTerm Mouse): Delete apparently false info. + The GNU/Linux console currently does not appear to support + `xterm-mouse-mode'. + 2005-04-04 Jay Belanger <belanger@truman.edu> * calc.texi: Change Calc version number.
--- a/man/cmdargs.texi Mon Apr 04 16:43:15 2005 +0000 +++ b/man/cmdargs.texi Fri Apr 08 16:25:22 2005 +0000 @@ -268,6 +268,8 @@ @item -Q @opindex -Q +@itemx --bare-bones +@opindex --bare-bones Start emacs with minimum customizations and window decorations. This is like using @samp{-q} and @samp{--no-site-file}, but in addition it also disables the menu-bar, the tool-bar, the scroll-bars,
--- a/man/dired.texi Mon Apr 04 16:43:15 2005 +0000 +++ b/man/dired.texi Fri Apr 08 16:25:22 2005 +0000 @@ -289,15 +289,11 @@ @item v @kindex v @r{(Dired)} @findex dired-view-file -View the file described on the current line, using either an external -viewing program or @kbd{M-x view-file} (@code{dired-view-file}). - -@vindex dired-view-command-alist -External viewers are used for certain file types under the control of -@code{dired-view-command-alist}. Viewing a file with @code{view-file} -is like visiting it, but is slanted toward moving around in the file +View the file described on the current line, using @kbd{M-x view-file} +(@code{dired-view-file}). Viewing a file with @code{view-file} is +like visiting it, but is slanted toward moving around in the file conveniently and does not allow changing the file. @xref{Misc File -Ops,View File, Miscellaneous File Operations}. +Ops, View File, Miscellaneous File Operations}. @item ^ @kindex ^ @r{(Dired)} @@ -376,13 +372,17 @@ (@code{dired-unmark-backward}). @item * ! +@itemx U @kindex * ! @r{(Dired)} +@kindex U @r{(Dired)} @findex dired-unmark-all-marks Remove all marks from all the files in this Dired buffer (@code{dired-unmark-all-marks}). @item * ? @var{markchar} +@itemx M-@key{DEL} @kindex * ? @r{(Dired)} +@kindex M-DEL @r{(Dired)} @findex dired-unmark-all-files Remove all marks that use the character @var{markchar} (@code{dired-unmark-all-files}). The argument is a single @@ -396,17 +396,23 @@ files without asking about them. @item * C-n +@itemx M-@} @findex dired-next-marked-file @kindex * C-n @r{(Dired)} +@kindex M-@} @r{(Dired)} Move down to the next marked file (@code{dired-next-marked-file}) A file is ``marked'' if it has any kind of mark. @item * C-p +@itemx M-@{ @findex dired-prev-marked-file @kindex * C-p @r{(Dired)} +@kindex M-@{ @r{(Dired)} Move up to the previous marked file (@code{dired-prev-marked-file}) -@item * t +@item t +@itemx * t +@kindex t @r{(Dired)} @kindex * t @r{(Dired)} @findex dired-toggle-marks @cindex toggling marks (in Dired) @@ -968,9 +974,6 @@ can use hiding to temporarily exclude subdirectories from operations without having to remove the markers. - The subdirectory hiding commands toggle; that is, they hide what was -visible, and show what was hidden. - @node Dired Updating @section Updating the Dired Buffer @cindex updating Dired buffer @@ -1145,18 +1148,18 @@ @findex dired-copy-filename-as-kill The @kbd{w} command (@code{dired-copy-filename-as-kill}) puts the names of the marked (or next @var{n}) files into the kill ring, as if -you had killed them with @kbd{C-w}. +you had killed them with @kbd{C-w}. The names are separated by a space. The main purpose of this command is so that you can yank the file names into arguments for other Emacs commands. It also displays what was pushed onto the kill ring, so you can use it to display the list of currently marked files in the echo area. With a zero prefix -argument @var{n}=0, this uses the absolute file name of each marked -file. With just @kbd{C-u} as the prefix argument, it uses the -relative file name of each marked file. As a special case, if no -prefix argument is given and point is on a directory headerline, -@kbd{w} gives you the name of that directory without looking for -marked files. +argument, this uses the absolute file name of each marked file. With +just @kbd{C-u} as the prefix argument, it uses file names relative to +the Dired buffer's default directory. (This can still contain slashes +if in a subdirectory.) As a special case, if point is on a directory +headerline, @kbd{w} gives you the absolute name of that directory. +Any prefix argument or marked files are ignored in this case. On the X window system, Emacs supports the ``drag and drop'' protocol. You can drag a file object from another program, and drop
--- a/man/frames.texi Mon Apr 04 16:43:15 2005 +0000 +++ b/man/frames.texi Fri Apr 08 16:25:22 2005 +0000 @@ -1058,9 +1058,7 @@ you can use @kbd{M-x xterm-mouse-mode} to enable simple use of the mouse---only single clicks are supported. The normal @code{xterm} mouse functionality is still available by holding down the @kbd{SHIFT} key -when you press the mouse button. The Linux console supports this -mode if it has support for the mouse enabled, e.g.@: using the -@command{gpm} daemon. +when you press the mouse button. @ignore arch-tag: 7dcf3a31-a43b-45d4-a900-445b10d77e49
--- a/src/ChangeLog Mon Apr 04 16:43:15 2005 +0000 +++ b/src/ChangeLog Fri Apr 08 16:25:22 2005 +0000 @@ -1,3 +1,19 @@ +2005-04-08 Kim F. Storm <storm@cua.dk> + + * xdisp.c (syms_of_xdisp): Init overlay-arrow-string to "=>". + +2005-04-06 Kim F. Storm <storm@cua.dk> + + * emacs.c (standard_args): Add -Q, --bare-bones, -bare-bones. + +2005-04-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * mac.c (cfdate_to_lisp): Add `const' for variable `epoch_gdate'. + (Fmac_get_preference): Doc fix. + + * macfns.c (Fx_create_frame, x_create_tip_frame): Add + "fontset-mac" to fallback font/fontsets. + 2005-04-04 Kim F. Storm <storm@cua.dk> * alloc.c (Fgarbage_collect): Call CHECK_CONS_LIST before and after gc. @@ -2865,7 +2881,7 @@ * xfns.c (xic_create_xfontset): Initialize missing_list to NULL. -2004-10-21 K,Aa(Broly L$,1 q(Brentey <lorentey@elte.hu> +2004-10-21 K,Ba(Broly L,Bu(Brentey <lorentey@elte.hu> * xterm.h (x_output): New member `xic_base_fontname'. (FRAME_XIC_BASE_FONTNAME): New macro. @@ -4146,7 +4162,7 @@ * keyboard.c (cmd_error): Don't call any_kboard_state if inside a recursive edit level. -2004-06-13 Lorentey K,Aa(Broly <lorentey@elte.hu> +2004-06-13 K,Ba(Broly L,Bu(Brentey <lorentey@elte.hu> * keyboard.c (command_loop): Call any_kboard_state before command_loop_2 when at top level.
--- a/src/ChangeLog.6 Mon Apr 04 16:43:15 2005 +0000 +++ b/src/ChangeLog.6 Fri Apr 08 16:25:22 2005 +0000 @@ -4817,7 +4817,7 @@ (Fmemory_use_counts): New function. (syms_of_alloc): defsubr it. -1995-07-28 Gvran Uddeborg <uddeborg@carmen.se> +1995-07-28 Göran Uddeborg <uddeborg@carmen.se> * s/isc4-1.h: ISC 4.1 has termios.
--- a/src/emacs.c Mon Apr 04 16:43:15 2005 +0000 +++ b/src/emacs.c Fri Apr 08 16:25:22 2005 +0000 @@ -1806,6 +1806,8 @@ { "-d", "--display", 60, 1 }, { "-display", 0, 60, 1 }, /* Now for the options handled in startup.el. */ + { "-Q", "--bare-bones", 55, 0 }, + { "-bare-bones", 0, 55, 0 }, { "-q", "--no-init-file", 50, 0 }, { "-no-init-file", 0, 50, 0 }, { "-no-site-file", "--no-site-file", 40, 0 },
--- a/src/mac.c Mon Apr 04 16:43:15 2005 +0000 +++ b/src/mac.c Fri Apr 08 16:25:22 2005 +0000 @@ -364,13 +364,13 @@ /* CFDate to a list of three integers as in a return value of - `current-time'xo. */ + `current-time'. */ Lisp_Object cfdate_to_lisp (date) CFDateRef date; { - static CFGregorianDate epoch_gdate = {1970, 1, 1, 0, 0, 0.0}; + static const CFGregorianDate epoch_gdate = {1970, 1, 1, 0, 0, 0.0}; static CFAbsoluteTime epoch = 0.0, sec; int high, low; @@ -668,7 +668,7 @@ return Qnil; result = Fcons (component, result); - while (binding = parse_binding (p)) + while ((binding = parse_binding (p)) != '\0') { if (binding == '*') result = Fcons (LOOSE_BINDING, result); @@ -3662,7 +3662,7 @@ CFDate List of three integers date (cf. `current-time') CFData Unibyte string data - CFArray Array array + CFArray Vector array CFDictionary Alist or hash table dictionary (depending on HASH-BOUND) @@ -4174,26 +4174,13 @@ staticpro (&QCLIPBOARD); #if TARGET_API_MAC_CARBON - Qstring = intern ("string"); - staticpro (&Qstring); - - Qnumber = intern ("number"); - staticpro (&Qnumber); - - Qboolean = intern ("boolean"); - staticpro (&Qboolean); - - Qdate = intern ("date"); - staticpro (&Qdate); - - Qdata = intern ("data"); - staticpro (&Qdata); - - Qarray = intern ("array"); - staticpro (&Qarray); - - Qdictionary = intern ("dictionary"); - staticpro (&Qdictionary); + Qstring = intern ("string"); staticpro (&Qstring); + Qnumber = intern ("number"); staticpro (&Qnumber); + Qboolean = intern ("boolean"); staticpro (&Qboolean); + Qdate = intern ("date"); staticpro (&Qdate); + Qdata = intern ("data"); staticpro (&Qdata); + Qarray = intern ("array"); staticpro (&Qarray); + Qdictionary = intern ("dictionary"); staticpro (&Qdictionary); Qxml = intern ("xml"); staticpro (&Qxml);
--- a/src/macfns.c Mon Apr 04 16:43:15 2005 +0000 +++ b/src/macfns.c Fri Apr 08 16:25:22 2005 +0000 @@ -2632,6 +2632,8 @@ font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1"); /* If those didn't work, look for something which will at least work. */ if (! STRINGP (font)) + font = x_new_fontset (f, "fontset-mac"); + if (! STRINGP (font)) font = x_new_font (f, "-*-monaco-*-12-*-mac-roman"); if (! STRINGP (font)) font = x_new_font (f, "-*-courier-*-10-*-mac-roman"); @@ -3732,6 +3734,8 @@ font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1"); /* If those didn't work, look for something which will at least work. */ if (! STRINGP (font)) + font = x_new_fontset (f, "fontset-mac"); + if (! STRINGP (font)) font = x_new_font (f, "-*-monaco-*-12-*-mac-roman"); if (! STRINGP (font)) font = x_new_font (f, "-*-courier-*-10-*-mac-roman");
--- a/src/xdisp.c Mon Apr 04 16:43:15 2005 +0000 +++ b/src/xdisp.c Fri Apr 08 16:25:22 2005 +0000 @@ -22612,7 +22612,7 @@ DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string, doc: /* String to display as an arrow in non-window frames. See also `overlay-arrow-position'. */); - Voverlay_arrow_string = Qnil; + Voverlay_arrow_string = build_string ("=>"); DEFVAR_LISP ("overlay-arrow-variable-list", &Voverlay_arrow_variable_list, doc: /* List of variables (symbols) which hold markers for overlay arrows.