aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKaroly Lorentey2006-01-03 02:15:28 +0000
committerKaroly Lorentey2006-01-03 02:15:28 +0000
commitb58cb6144c59dfa3a44b9b383cf354bc2c9bebdf (patch)
tree87bc562249d9e597e12406e1d9b1c7dfb0f937e5 /lisp
parentb3e6f69c10973ff7b040ced07a3a084960619681 (diff)
parent55262b16df717fe533ea4ad23dac3f02398c9055 (diff)
downloademacs-b58cb6144c59dfa3a44b9b383cf354bc2c9bebdf.tar.gz
emacs-b58cb6144c59dfa3a44b9b383cf354bc2c9bebdf.zip
Merged from miles@gnu.org--gnu-2005 (patch 682)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-682 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-490
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog171
-rw-r--r--lisp/Makefile.in3
-rw-r--r--lisp/cus-edit.el234
-rw-r--r--lisp/cus-start.el2
-rw-r--r--lisp/cus-theme.el22
-rw-r--r--lisp/custom.el103
-rw-r--r--lisp/font-lock.el7
-rw-r--r--lisp/jit-lock.el4
-rw-r--r--lisp/locate.el4
-rw-r--r--lisp/makefile.w32-in3
-rw-r--r--lisp/mh-e/ChangeLog63
-rw-r--r--lisp/mh-e/mh-customize.el493
-rw-r--r--lisp/mh-e/mh-e.el106
-rw-r--r--lisp/mh-e/mh-init.el7
-rw-r--r--lisp/mh-e/mh-mime.el11
-rw-r--r--lisp/mh-e/mh-utils.el70
-rw-r--r--lisp/mouse.el21
-rw-r--r--lisp/net/goto-addr.el5
-rw-r--r--lisp/net/webjump.el224
-rw-r--r--lisp/paren.el8
-rw-r--r--lisp/progmodes/cc-defs.el8
-rw-r--r--lisp/progmodes/delphi.el2
-rw-r--r--lisp/progmodes/flymake.el286
-rw-r--r--lisp/progmodes/glasses.el2
-rw-r--r--lisp/progmodes/gud.el11
-rw-r--r--lisp/subr.el14
-rw-r--r--lisp/textmodes/bibtex.el1116
-rw-r--r--lisp/textmodes/fill.el5
-rw-r--r--lisp/url/ChangeLog8
-rw-r--r--lisp/url/url-cache.el3
-rw-r--r--lisp/url/url-handlers.el3
-rw-r--r--lisp/url/url.el4
-rw-r--r--lisp/xt-mouse.el3
33 files changed, 1702 insertions, 1324 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 288e4d7ed44..1050d3deb84 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,171 @@
12006-01-01 Richard M. Stallman <rms@gnu.org>
2
3 * cus-edit.el (Custom-set, Custom-save): Ask for confirmation.
4 (Custom-reset-current, Custom-reset-saved): Likewise.
5 (Custom-reset-standard): Show message if aborted.
6 (custom-mode): Doc fix, describing those commands.
7
8 * mouse.el (mouse-drag-region-1): When following link via mouse-2,
9 put on event-kind property.
10
112005-12-31 Chong Yidong <cyd@stupidchicken.com>
12
13 * custom.el (provide-theme): Ban `user' theme name.
14 (custom-enabling-themes): New variable.
15 (enable-theme): Don't enable user if custom-enabling-themes is t.
16 (custom-enabled-themes): Make it a defcustom.
17 (custom-theme-recalc-face): No-op if face is undefined.
18
19 * cus-edit.el (custom-button-mouse): New variable.
20 (custom-button-mouse): New face.
21 (custom-raised-buttons, custom-mode): Use it.
22
23 * cus-theme.el (custom-new-theme-mode): Use custom-button-mouse.
24
252005-12-31 Eli Zaretskii <eliz@gnu.org>
26
27 * progmodes/gud.el (gud-display-line): Support hl-line in the
28 source buffer.
29
302005-12-31 Lennart Borgman <lennart.borgman.073@student.lu.se> (tiny change)
31
32 * mouse.el (mouse-drag-window-above): Verify that the found window
33 overlaps with the given window in the horizontal dimension.
34
352005-12-31 Eli Zaretskii <eliz@gnu.org>
36
37 * Makefile.in (cvs-update): New target.
38
39 * makefile.w32-in (cvs-update): Ditto.
40
412005-12-30 Chong Yidong <cyd@stupidchicken.com>
42
43 * cus-theme.el (custom-new-theme-mode): Use cus-edit faces.
44 (custom-new-theme-mode-map): New variable.
45
462005-12-30 Richard M. Stallman <rms@gnu.org>
47
48 * custom.el (custom-load-themes): Function deleted.
49
50 * cus-edit.el (custom-save-loaded-themes): Function deleted.
51 (custom-save-variables): Don't delete or add custom-load-themes call.
52
532005-12-30 Stefan Monnier <monnier@iro.umontreal.ca>
54
55 * cus-start.el: Add `visible-cursor'.
56
57 * progmodes/flymake.el (flymake-copy-buffer-to-temp-buffer): Simplify.
58 (flymake-parse-output-and-residual): Remove `source-buffer' argument.
59 (flymake-process-filter): Switch to buffer before calling it instead.
60 (flymake-post-syntax-check, flymake-highlight-err-lines)
61 (flymake-delete-own-overlays, flymake-parse-err-lines)
62 (flymake-start-syntax-check, flymake-start-syntax-check-process)
63 (flymake-count-lines, flymake-parse-residual):
64 Remove constant buffer argument.
65 (flymake-start-syntax-check-for-current-buffer): Remove.
66 Update callers to use flymake-start-syntax-check instead.
67 (flymake-display-err-menu-for-current-line):
68 Remove unused var `mouse-pos'.
69 (flymake-restore-formatting): Comment out unused function.
70 (flymake-report-status, flymake-report-fatal-status): Remove buffer
71 argument, use current-buffer instead. Update callers.
72
732005-12-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
74
75 * textmodes/bibtex.el (bibtex-mode): Make completion-ignore-case
76 buffer-local because choose-completion-delete-max-match requires
77 that we set completion-ignore-case (i.e., binding via let is not
78 sufficient).
79 (bibtex-complete): Always set completion-ignore-case and
80 choose-completion-string-functions. The latter is needed because
81 choose-completion-string-functions keeps its value if we quit the
82 *Completions* buffer without requesting a completion.
83
842005-12-30 Andreas Schwab <schwab@suse.de>
85
86 * progmodes/cc-defs.el: Ignore errors from font-lock-compile-keywords.
87
882005-12-30 Eli Zaretskii <eliz@gnu.org>
89
90 * jit-lock.el (jit-lock-chunk-size): Doc fix.
91
922005-12-30 Juri Linkov <juri@jurta.org>
93
94 * locate.el (locate-fcodes-file, locate-header-face)
95 * progmodes/delphi.el (delphi-other-face)
96 * progmodes/glasses.el (glasses-face): Add tag "None" to const nil.
97
98 * paren.el (show-paren-match, show-paren-mismatch): Use existing
99 group `paren-showing-faces'.
100
101 * net/goto-addr.el (goto-address-highlight-keymap): Fix docstring.
102 (goto-address): Fix docstring.
103
104 * net/webjump.el (webjump-sample-sites): Update URLs.
105
106 * textmodes/fill.el (fill-single-word-nobreak-p): Use `sentence-end'.
107
108 * subr.el (cancel-change-group): Add listp around pending-undo-list.
109
1102005-12-29 Stefan Monnier <monnier@iro.umontreal.ca>
111
112 * font-lock.el (font-lock-compile-keywords): Signal an error when
113 font-lock-set-defaults hasn't been called.
114
1152005-12-29 Luc Teirlinck <teirllm@auburn.edu>
116
117 * subr.el (noreturn, 1value): Doc fixes.
118
1192005-12-29 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
120
121 * textmodes/bibtex.el (bibtex-text-in-field-bounds): Handle case
122 that assoc-string returns nil.
123
1242005-12-29 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
125
126 * textmodes/bibtex.el (bibtex-entry-type-whitespace)
127 (bibtex-entry-type-str, bibtex-empty-field-re)
128 (bibtex-search-backward-string, bibtex-preamble-prefix)
129 (bibtex-search-entry, bibtex-enclosing-entry-maybe-empty-head): Remove.
130 (bibtex-any-valid-entry-type): New variable.
131 (bibtex-parse-field-name): Simplify.
132 (bibtex-parse-string, bibtex-search-forward-string): New arg empty-key.
133 (bibtex-preamble-prefix): Include left delimiter.
134 (bibtex-search-forward-field, bibtex-search-backward-field):
135 Allow unbounded search past entry boundaries (required by bibtex-pop).
136 (bibtex-text-in-field-bounds): Use push.
137 (bibtex-text-in-field): Do not use bibtex-narrow-to-entry.
138 (bibtex-parse-preamble, bibtex-valid-entry)
139 (bibtex-beginning-first-field): New functions.
140 (bibtex-skip-to-valid-entry): Use bibtex-valid-entry. Fix regexp.
141 (bibtex-map-entries): Fix docstring.
142 (bibtex-flash-head): New arg prompt. Simplify.
143 (bibtex-enclosing-field): Include code of bibtex-inside-field.
144 (bibtex-insert-kill): Simplify. Always insert text past the
145 current field or entry.
146 (bibtex-format-entry): Use bibtex-parse-field.
147 (bibtex-pop): Use bibtex-beginning-of-entry and
148 bibtex-end-of-entry to initiate the search. Insert empty field if
149 we found ourselves.
150 (bibtex-print-help-message): New args field and comma.
151 Handle entry keys.
152 (bibtex-make-field): Use bibtex-beginning-of-entry.
153 (bibtex-end-of-entry): Use bibtex-valid-entry. Recognize any
154 invalid entry.
155 (bibtex-validate): Use bibtex-valid-entry and bibtex-parse-string.
156 Handle preambles. Simplify code for thorough test.
157 (bibtex-next-field, bibtex-find-text, bibtex-find-text-internal):
158 New arg comma. Handle entry heads.
159 (bibtex-remove-OPT-or-ALT, bibtex-remove-delimiters)
160 (bibtex-kill-field, bibtex-copy-field-as-kil, bibtex-empty-field):
161 New arg comma.
162 (bibtex-kill-entry): Use bibtex-any-entry-maybe-empty-head.
163 (bibtex-fill-field): Simplify.
164 (bibtex-fill-entry): Use bibtex-beginning-first-field and
165 bibtex-parse-field.
166 (bibtex-convert-alien): Do not wait before calling bibtex-validate.
167 (bibtex-complete): Use bibtex-parse-preamble.
168
12005-12-29 Nick Roberts <nickrob@snap.net.nz> 1692005-12-29 Nick Roberts <nickrob@snap.net.nz>
2 170
3 * progmodes/gdb-ui.el (gdb-tooltip-print, gdb-tooltip-print-1): 171 * progmodes/gdb-ui.el (gdb-tooltip-print, gdb-tooltip-print-1):
@@ -11,8 +179,7 @@
11 179
122005-12-28 Bill Wohler <wohler@newt.com> 1802005-12-28 Bill Wohler <wohler@newt.com>
13 181
14 * simple.el (mh-e-user-agent): Move to mh-e/mh-comp.el and 182 * simple.el (mh-e-user-agent): Move to mh-e/mh-comp.el and autoload.
15 autoload.
16 183
172005-12-28 Stefan Monnier <monnier@iro.umontreal.ca> 1842005-12-28 Stefan Monnier <monnier@iro.umontreal.ca>
18 185
diff --git a/lisp/Makefile.in b/lisp/Makefile.in
index eaac8d08324..9a4497679ef 100644
--- a/lisp/Makefile.in
+++ b/lisp/Makefile.in
@@ -119,6 +119,9 @@ update-subdirs: doit
119 119
120updates: update-subdirs autoloads mh-autoloads finder-data custom-deps 120updates: update-subdirs autoloads mh-autoloads finder-data custom-deps
121 121
122# This is useful after "cvs up".
123cvs-update: recompile autoloads finder-data custom-deps
124
122# Update the AUTHORS file. 125# Update the AUTHORS file.
123 126
124update-authors: 127update-authors:
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 54d0fa23e52..4c92034eaad 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -746,22 +746,26 @@ groups after non-groups, if nil do not order groups at all."
746(defun Custom-set () 746(defun Custom-set ()
747 "Set changes in all modified options." 747 "Set changes in all modified options."
748 (interactive) 748 (interactive)
749 (let ((children custom-options)) 749 (if (y-or-n-p "Set all values according to this buffer? ")
750 (mapc (lambda (child) 750 (let ((children custom-options))
751 (when (eq (widget-get child :custom-state) 'modified) 751 (mapc (lambda (child)
752 (widget-apply child :custom-set))) 752 (when (eq (widget-get child :custom-state) 'modified)
753 children))) 753 (widget-apply child :custom-set)))
754 children))
755 (message "Aborted")))
754 756
755(defun Custom-save () 757(defun Custom-save ()
756 "Set all modified group members and save them." 758 "Set all modified group members and save them."
757 (interactive) 759 (interactive)
758 (let ((children custom-options)) 760 (if (yes-or-no-p "Save all settings in this buffer? ")
759 (mapc (lambda (child) 761 (let ((children custom-options))
760 (when (memq (widget-get child :custom-state) 762 (mapc (lambda (child)
761 '(modified set changed rogue)) 763 (when (memq (widget-get child :custom-state)
762 (widget-apply child :custom-save))) 764 '(modified set changed rogue))
763 children)) 765 (widget-apply child :custom-save)))
764 (custom-save-all)) 766 children)
767 (custom-save-all))
768 (message "Aborted")))
765 769
766(defvar custom-reset-menu 770(defvar custom-reset-menu
767 '(("Current" . Custom-reset-current) 771 '(("Current" . Custom-reset-current)
@@ -784,22 +788,26 @@ when the action is chosen.")
784(defun Custom-reset-current (&rest ignore) 788(defun Custom-reset-current (&rest ignore)
785 "Reset all modified group members to their current value." 789 "Reset all modified group members to their current value."
786 (interactive) 790 (interactive)
787 (let ((children custom-options)) 791 (if (y-or-n-p "Update buffer text to show all current settings? ")
788 (mapc (lambda (widget) 792 (let ((children custom-options))
789 (if (memq (widget-get widget :custom-state) 793 (mapc (lambda (widget)
790 '(modified changed)) 794 (if (memq (widget-get widget :custom-state)
791 (widget-apply widget :custom-reset-current))) 795 '(modified changed))
792 children))) 796 (widget-apply widget :custom-reset-current)))
797 children))
798 (message "Aborted")))
793 799
794(defun Custom-reset-saved (&rest ignore) 800(defun Custom-reset-saved (&rest ignore)
795 "Reset all modified or set group members to their saved value." 801 "Reset all modified or set group members to their saved value."
796 (interactive) 802 (interactive)
797 (let ((children custom-options)) 803 (if (y-or-n-p "Update buffer text to show all saved settings? ")
798 (mapc (lambda (widget) 804 (let ((children custom-options))
799 (if (memq (widget-get widget :custom-state) 805 (mapc (lambda (widget)
800 '(modified set changed rogue)) 806 (if (memq (widget-get widget :custom-state)
801 (widget-apply widget :custom-reset-saved))) 807 '(modified set changed rogue))
802 children))) 808 (widget-apply widget :custom-reset-saved)))
809 children))
810 (message "Aborted")))
803 811
804(defun Custom-reset-standard (&rest ignore) 812(defun Custom-reset-standard (&rest ignore)
805 "Erase all customization (either current or saved) for the group members. 813 "Erase all customization (either current or saved) for the group members.
@@ -808,18 +816,19 @@ This operation eliminates any saved values for the group members,
808making them as if they had never been customized at all." 816making them as if they had never been customized at all."
809 (interactive) 817 (interactive)
810 (let ((children custom-options)) 818 (let ((children custom-options))
811 (when (or (and (= 1 (length children)) 819 (if (or (and (= 1 (length children))
812 (memq (widget-type (car children)) 820 (memq (widget-type (car children))
813 '(custom-variable custom-face))) 821 '(custom-variable custom-face)))
814 (yes-or-no-p "Really erase all customizations in this buffer? ")) 822 (yes-or-no-p "Really erase all customizations in this buffer? "))
815 (mapc (lambda (widget) 823 (mapc (lambda (widget)
816 (and (if (widget-get widget :custom-standard-value) 824 (and (if (widget-get widget :custom-standard-value)
817 (widget-apply widget :custom-standard-value) 825 (widget-apply widget :custom-standard-value)
818 t) 826 t)
819 (memq (widget-get widget :custom-state) 827 (memq (widget-get widget :custom-state)
820 '(modified set changed saved rogue)) 828 '(modified set changed saved rogue))
821 (widget-apply widget :custom-reset-standard))) 829 (widget-apply widget :custom-reset-standard)))
822 children)))) 830 children)
831 (message "Aborted"))))
823 832
824;;; The Customize Commands 833;;; The Customize Commands
825 834
@@ -1405,6 +1414,9 @@ This button will have a menu with all three reset operations."
1405(defvar custom-button nil 1414(defvar custom-button nil
1406 "Face used for buttons in customization buffers.") 1415 "Face used for buttons in customization buffers.")
1407 1416
1417(defvar custom-button-mouse nil
1418 "Mouse face used for buttons in customization buffers.")
1419
1408(defvar custom-button-pressed nil 1420(defvar custom-button-pressed nil
1409 "Face used for pressed buttons in customization buffers.") 1421 "Face used for pressed buttons in customization buffers.")
1410 1422
@@ -1419,6 +1431,8 @@ Otherwise use brackets."
1419 (custom-set-default variable value) 1431 (custom-set-default variable value)
1420 (setq custom-button 1432 (setq custom-button
1421 (if value 'custom-button 'custom-button-unraised)) 1433 (if value 'custom-button 'custom-button-unraised))
1434 (setq custom-button-mouse
1435 (if value 'custom-button-mouse 'highlight))
1422 (setq custom-button-pressed 1436 (setq custom-button-pressed
1423 (if value 1437 (if value
1424 'custom-button-pressed 1438 'custom-button-pressed
@@ -1960,6 +1974,16 @@ and `face'."
1960;; backward-compatibility alias 1974;; backward-compatibility alias
1961(put 'custom-button-face 'face-alias 'custom-button) 1975(put 'custom-button-face 'face-alias 'custom-button)
1962 1976
1977(defface custom-button-mouse
1978 '((((type x w32 mac) (class color))
1979 (:box (:line-width 2 :style released-button)
1980 :background "grey90" :foreground "black"))
1981 (t
1982 nil))
1983 "Mouse face for custom buffer buttons if `custom-raised-buttons' is non-nil."
1984 :version "22.1"
1985 :group 'custom-faces)
1986
1963(defface custom-button-unraised 1987(defface custom-button-unraised
1964 '((((min-colors 88) 1988 '((((min-colors 88)
1965 (class color) (background light)) :foreground "blue1" :underline t) 1989 (class color) (background light)) :foreground "blue1" :underline t)
@@ -1975,6 +1999,9 @@ and `face'."
1975(setq custom-button 1999(setq custom-button
1976 (if custom-raised-buttons 'custom-button 'custom-button-unraised)) 2000 (if custom-raised-buttons 'custom-button 'custom-button-unraised))
1977 2001
2002(setq custom-button-mouse
2003 (if custom-raised-buttons 'custom-button-mouse 'highlight))
2004
1978(defface custom-button-pressed 2005(defface custom-button-pressed
1979 '((((type x w32 mac) (class color)) 2006 '((((type x w32 mac) (class color))
1980 (:box (:line-width 2 :style pressed-button) 2007 (:box (:line-width 2 :style pressed-button)
@@ -4024,6 +4051,33 @@ if only the first line of the docstring is shown."))
4024 (save-buffer)) 4051 (save-buffer))
4025 (unless old-buffer 4052 (unless old-buffer
4026 (kill-buffer (current-buffer)))))) 4053 (kill-buffer (current-buffer))))))
4054
4055;;;###autoload
4056(defun customize-save-customized ()
4057 "Save all user options which have been set in this session."
4058 (interactive)
4059 (mapatoms (lambda (symbol)
4060 (let ((face (get symbol 'customized-face))
4061 (value (get symbol 'customized-value))
4062 (face-comment (get symbol 'customized-face-comment))
4063 (variable-comment
4064 (get symbol 'customized-variable-comment)))
4065 (when face
4066 (put symbol 'saved-face face)
4067 (custom-push-theme 'theme-face symbol 'user 'set value)
4068 (put symbol 'customized-face nil))
4069 (when value
4070 (put symbol 'saved-value value)
4071 (custom-push-theme 'theme-value symbol 'user 'set value)
4072 (put symbol 'customized-value nil))
4073 (when variable-comment
4074 (put symbol 'saved-variable-comment variable-comment)
4075 (put symbol 'customized-variable-comment nil))
4076 (when face-comment
4077 (put symbol 'saved-face-comment face-comment)
4078 (put symbol 'customized-face-comment nil)))))
4079 ;; We really should update all custom buffers here.
4080 (custom-save-all))
4027 4081
4028;; Editing the custom file contents in a buffer. 4082;; Editing the custom file contents in a buffer.
4029 4083
@@ -4069,10 +4123,8 @@ This function does not save the buffer."
4069(defun custom-save-variables () 4123(defun custom-save-variables ()
4070 "Save all customized variables in `custom-file'." 4124 "Save all customized variables in `custom-file'."
4071 (save-excursion 4125 (save-excursion
4072 (custom-save-delete 'custom-load-themes)
4073 (custom-save-delete 'custom-reset-variables) 4126 (custom-save-delete 'custom-reset-variables)
4074 (custom-save-delete 'custom-set-variables) 4127 (custom-save-delete 'custom-set-variables)
4075 (custom-save-loaded-themes)
4076 (custom-save-resets 'theme-value 'custom-reset-variables nil) 4128 (custom-save-resets 'theme-value 'custom-reset-variables nil)
4077 (let ((standard-output (current-buffer)) 4129 (let ((standard-output (current-buffer))
4078 (saved-list (make-list 1 0)) 4130 (saved-list (make-list 1 0))
@@ -4131,6 +4183,33 @@ This function does not save the buffer."
4131 (unless (looking-at "\n") 4183 (unless (looking-at "\n")
4132 (princ "\n"))))) 4184 (princ "\n")))))
4133 4185
4186(defun custom-save-resets (property setter special)
4187 (let (started-writing ignored-special)
4188 ;; (custom-save-delete setter) Done by caller
4189 (let ((standard-output (current-buffer))
4190 (mapper `(lambda (object)
4191 (let ((spec (car-safe (get object (quote ,property)))))
4192 (when (and (not (memq object ignored-special))
4193 (eq (nth 0 spec) 'user)
4194 (eq (nth 1 spec) 'reset))
4195 ;; Do not write reset statements unless necessary.
4196 (unless started-writing
4197 (setq started-writing t)
4198 (unless (bolp)
4199 (princ "\n"))
4200 (princ "(")
4201 (princ (quote ,setter))
4202 (princ "\n '(")
4203 (prin1 object)
4204 (princ " ")
4205 (prin1 (nth 3 spec))
4206 (princ ")")))))))
4207 (mapc mapper special)
4208 (setq ignored-special special)
4209 (mapatoms mapper)
4210 (when started-writing
4211 (princ ")\n")))))
4212
4134(defun custom-save-faces () 4213(defun custom-save-faces ()
4135 "Save all customized faces in `custom-file'." 4214 "Save all customized faces in `custom-file'."
4136 (save-excursion 4215 (save-excursion
@@ -4187,71 +4266,6 @@ This function does not save the buffer."
4187 (princ ")") 4266 (princ ")")
4188 (unless (looking-at "\n") 4267 (unless (looking-at "\n")
4189 (princ "\n"))))) 4268 (princ "\n")))))
4190
4191(defun custom-save-resets (property setter special)
4192 (let (started-writing ignored-special)
4193 ;; (custom-save-delete setter) Done by caller
4194 (let ((standard-output (current-buffer))
4195 (mapper `(lambda (object)
4196 (let ((spec (car-safe (get object (quote ,property)))))
4197 (when (and (not (memq object ignored-special))
4198 (eq (nth 0 spec) 'user)
4199 (eq (nth 1 spec) 'reset))
4200 ;; Do not write reset statements unless necessary.
4201 (unless started-writing
4202 (setq started-writing t)
4203 (unless (bolp)
4204 (princ "\n"))
4205 (princ "(")
4206 (princ (quote ,setter))
4207 (princ "\n '(")
4208 (prin1 object)
4209 (princ " ")
4210 (prin1 (nth 3 spec))
4211 (princ ")")))))))
4212 (mapc mapper special)
4213 (setq ignored-special special)
4214 (mapatoms mapper)
4215 (when started-writing
4216 (princ ")\n")))))
4217
4218(defun custom-save-loaded-themes ()
4219 (let ((themes (reverse (get 'user 'theme-loads-themes)))
4220 (standard-output (current-buffer)))
4221 (when themes
4222 (unless (bolp) (princ "\n"))
4223 (princ "(custom-load-themes")
4224 (mapc (lambda (theme)
4225 (princ "\n '")
4226 (prin1 theme)) themes)
4227 (princ " )\n"))))
4228
4229;;;###autoload
4230(defun customize-save-customized ()
4231 "Save all user options which have been set in this session."
4232 (interactive)
4233 (mapatoms (lambda (symbol)
4234 (let ((face (get symbol 'customized-face))
4235 (value (get symbol 'customized-value))
4236 (face-comment (get symbol 'customized-face-comment))
4237 (variable-comment
4238 (get symbol 'customized-variable-comment)))
4239 (when face
4240 (put symbol 'saved-face face)
4241 (custom-push-theme 'theme-face symbol 'user 'set value)
4242 (put symbol 'customized-face nil))
4243 (when value
4244 (put symbol 'saved-value value)
4245 (custom-push-theme 'theme-value symbol 'user 'set value)
4246 (put symbol 'customized-value nil))
4247 (when variable-comment
4248 (put symbol 'saved-variable-comment variable-comment)
4249 (put symbol 'customized-variable-comment nil))
4250 (when face-comment
4251 (put symbol 'saved-face-comment face-comment)
4252 (put symbol 'customized-face-comment nil)))))
4253 ;; We really should update all custom buffers here.
4254 (custom-save-all))
4255 4269
4256;;; The Customize Menu. 4270;;; The Customize Menu.
4257 4271
@@ -4400,11 +4414,12 @@ Complete content of editable text field. \\[widget-complete]
4400\\<custom-mode-map>\ 4414\\<custom-mode-map>\
4401Invoke button under the mouse pointer. \\[Custom-move-and-invoke] 4415Invoke button under the mouse pointer. \\[Custom-move-and-invoke]
4402Invoke button under point. \\[widget-button-press] 4416Invoke button under point. \\[widget-button-press]
4403Set all modifications. \\[Custom-set] 4417Set all options from current text. \\[Custom-set]
4404Make all modifications default. \\[Custom-save] 4418Make values in current text permanent. \\[Custom-save]
4405Reset all modified options. \\[Custom-reset-current] 4419Make text match actual option values. \\[Custom-reset-current]
4406Reset all modified or set options. \\[Custom-reset-saved] 4420Reset options to permanent settings. \\[Custom-reset-saved]
4407Reset all options. \\[Custom-reset-standard] 4421Erase customizations; set options
4422 and buffer text to the standard values. \\[Custom-reset-standard]
4408 4423
4409Entry to this mode calls the value of `custom-mode-hook' 4424Entry to this mode calls the value of `custom-mode-hook'
4410if that value is non-nil." 4425if that value is non-nil."
@@ -4420,8 +4435,7 @@ if that value is non-nil."
4420 (make-local-variable 'widget-button-face) 4435 (make-local-variable 'widget-button-face)
4421 (setq widget-button-face custom-button) 4436 (setq widget-button-face custom-button)
4422 (set (make-local-variable 'widget-button-pressed-face) custom-button-pressed) 4437 (set (make-local-variable 'widget-button-pressed-face) custom-button-pressed)
4423 (if custom-raised-buttons 4438 (set (make-local-variable 'widget-mouse-face) custom-button-mouse)
4424 (set (make-local-variable 'widget-mouse-face) custom-button))
4425 4439
4426 ;; When possible, use relief for buttons, not bracketing. This test 4440 ;; When possible, use relief for buttons, not bracketing. This test
4427 ;; may not be optimal. 4441 ;; may not be optimal.
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index a851d32d296..30af30045f8 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -274,6 +274,8 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
274 (words-include-escapes editing-basics boolean) 274 (words-include-escapes editing-basics boolean)
275 (open-paren-in-column-0-is-defun-start editing-basics boolean 275 (open-paren-in-column-0-is-defun-start editing-basics boolean
276 "21.1") 276 "21.1")
277 ;; term.c
278 (visible-cursor cursor boolean "22.1")
277 ;; undo.c 279 ;; undo.c
278 (undo-limit undo integer) 280 (undo-limit undo integer)
279 (undo-strong-limit undo integer) 281 (undo-strong-limit undo integer)
diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el
index 43cf96e34fa..d7102fc11f7 100644
--- a/lisp/cus-theme.el
+++ b/lisp/cus-theme.el
@@ -31,11 +31,31 @@
31(eval-when-compile 31(eval-when-compile
32 (require 'wid-edit)) 32 (require 'wid-edit))
33 33
34(defvar custom-new-theme-mode-map
35 (let ((map (make-keymap)))
36 (set-keymap-parent map widget-keymap)
37 (suppress-keymap map)
38 (define-key map "n" 'widget-forward)
39 (define-key map "p" 'widget-backward)
40 (define-key map [mouse-1] 'widget-move-and-invoke)
41 map)
42 "Keymap for `custom-new-theme-mode'.")
43
34(define-derived-mode custom-new-theme-mode nil "New-Theme" 44(define-derived-mode custom-new-theme-mode nil "New-Theme"
35 "Major mode for the buffer created by `customize-create-theme'. 45 "Major mode for the buffer created by `customize-create-theme'.
36Do not call this mode function yourself. It is only meant for internal 46Do not call this mode function yourself. It is only meant for internal
37use by `customize-create-theme'." 47use by `customize-create-theme'."
38 (set-keymap-parent custom-new-theme-mode-map widget-keymap)) 48 (use-local-map custom-new-theme-mode-map)
49 (define-key custom-new-theme-mode-map [mouse-1] 'widget-move-and-invoke)
50 (set (make-local-variable 'widget-documentation-face) 'custom-documentation)
51 (set (make-local-variable 'widget-button-face) custom-button)
52 (set (make-local-variable 'widget-button-pressed-face) custom-button-pressed)
53 (set (make-local-variable 'widget-mouse-face) custom-button-mouse)
54 (when custom-raised-buttons
55 (set (make-local-variable 'widget-push-button-prefix) "")
56 (set (make-local-variable 'widget-push-button-suffix) "")
57 (set (make-local-variable 'widget-link-prefix) "")
58 (set (make-local-variable 'widget-link-suffix) "")))
39(put 'custom-new-theme-mode 'mode-class 'special) 59(put 'custom-new-theme-mode 'mode-class 'special)
40 60
41(defvar custom-theme-name) 61(defvar custom-theme-name)
diff --git a/lisp/custom.el b/lisp/custom.el
index df2488bda40..18d79a6af23 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -648,8 +648,7 @@ The user has not customized the variable; had he done that, the
648list would contain an entry for the `user' theme, too. 648list would contain an entry for the `user' theme, too.
649 649
650See `custom-known-themes' for a list of known themes." 650See `custom-known-themes' for a list of known themes."
651 (unless (or (eq prop 'theme-value) 651 (unless (memq prop '(theme-value theme-face))
652 (eq prop 'theme-face))
653 (error "Unknown theme property")) 652 (error "Unknown theme property"))
654 (let* ((old (get symbol prop)) 653 (let* ((old (get symbol prop))
655 (setting (assq theme old)) 654 (setting (assq theme old))
@@ -1048,21 +1047,15 @@ into this directory."
1048 "Return non-nil if THEME has been loaded." 1047 "Return non-nil if THEME has been loaded."
1049 (memq theme custom-loaded-themes)) 1048 (memq theme custom-loaded-themes))
1050 1049
1051(defvar custom-enabled-themes '(user)
1052 "Custom themes currently enabled, highest precedence first.
1053The first one is always `user'.")
1054
1055(defun custom-theme-enabled-p (theme)
1056 "Return non-nil if THEME is enabled."
1057 (memq theme custom-enabled-themes))
1058
1059(defun provide-theme (theme) 1050(defun provide-theme (theme)
1060 "Indicate that this file provides THEME. 1051 "Indicate that this file provides THEME, and mark it as enabled.
1061Add THEME to `custom-loaded-themes', and `provide' whatever 1052Add THEME to `custom-loaded-themes' and `custom-enabled-themes',
1062feature name is stored in THEME's property `theme-feature'. 1053and `provide' the feature name stored in THEME's property `theme-feature'.
1063 1054
1064Usually the `theme-feature' property contains a symbol created 1055Usually the `theme-feature' property contains a symbol created
1065by `custom-make-theme-feature'." 1056by `custom-make-theme-feature'."
1057 (if (eq theme 'user)
1058 (error "Custom theme cannot be named `user'"))
1066 (custom-check-theme theme) 1059 (custom-check-theme theme)
1067 (provide (get theme 'theme-feature)) 1060 (provide (get theme 'theme-feature))
1068 (push theme custom-loaded-themes) 1061 (push theme custom-loaded-themes)
@@ -1120,15 +1113,11 @@ All the themes loaded for BY-THEME are recorded in BY-THEME's property
1120 (load-theme theme))) 1113 (load-theme theme)))
1121 (push theme themes-loaded)) 1114 (push theme themes-loaded))
1122 (put by-theme 'theme-loads-themes themes-loaded))) 1115 (put by-theme 'theme-loads-themes themes-loaded)))
1123
1124(defun custom-load-themes (&rest body)
1125 "Load themes for the USER theme as specified by BODY.
1126
1127See `custom-theme-load-themes' for more information on BODY."
1128 (apply 'custom-theme-load-themes 'user body))
1129 1116
1130;;; Enabling and disabling loaded themes. 1117;;; Enabling and disabling loaded themes.
1131 1118
1119(defvar custom-enabling-themes nil)
1120
1132(defun enable-theme (theme) 1121(defun enable-theme (theme)
1133 "Reenable all variable and face settings defined by THEME. 1122 "Reenable all variable and face settings defined by THEME.
1134The newly enabled theme gets the highest precedence (after `user'). 1123The newly enabled theme gets the highest precedence (after `user').
@@ -1137,9 +1126,9 @@ If it is already enabled, just give it highest precedence (after `user').
1137This signals an error if THEME does not specify any theme 1126This signals an error if THEME does not specify any theme
1138settings. Theme settings are set using `load-theme'." 1127settings. Theme settings are set using `load-theme'."
1139 (interactive "SEnable Custom theme: ") 1128 (interactive "SEnable Custom theme: ")
1129 (unless (or (eq theme 'user) (memq theme custom-loaded-themes))
1130 (error "Theme %s not defined" (symbol-name theme)))
1140 (let ((settings (get theme 'theme-settings))) 1131 (let ((settings (get theme 'theme-settings)))
1141 (if (and (not (eq theme 'user)) (null settings))
1142 (error "No theme settings defined in %s." (symbol-name theme)))
1143 (dolist (s settings) 1132 (dolist (s settings)
1144 (let* ((prop (car s)) 1133 (let* ((prop (car s))
1145 (symbol (cadr s)) 1134 (symbol (cadr s))
@@ -1147,29 +1136,58 @@ settings. Theme settings are set using `load-theme'."
1147 (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list))) 1136 (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list)))
1148 (if (eq prop 'theme-value) 1137 (if (eq prop 'theme-value)
1149 (custom-theme-recalc-variable symbol) 1138 (custom-theme-recalc-variable symbol)
1150 (if (facep symbol) 1139 (custom-theme-recalc-face symbol)))))
1151 (custom-theme-recalc-face symbol))))))
1152 (setq custom-enabled-themes
1153 (cons theme (delq theme custom-enabled-themes)))
1154 ;; `user' must always be the highest-precedence enabled theme.
1155 (unless (eq theme 'user) 1140 (unless (eq theme 'user)
1156 (enable-theme 'user))) 1141 (setq custom-enabled-themes
1142 (cons theme (delq theme custom-enabled-themes)))
1143 (unless custom-enabling-themes
1144 (enable-theme 'user))))
1145
1146(defcustom custom-enabled-themes nil
1147 "List of enabled Custom Themes, highest precedence first.
1148
1149This does not include the `user' theme, which is set by Customize,
1150and always takes precedence over other Custom Themes."
1151 :group 'customize
1152 :type '(repeat symbol)
1153 :set (lambda (symbol themes)
1154 ;; Avoid an infinite loop when custom-enabled-themes is
1155 ;; defined in a theme (e.g. `user'). Enabling the theme sets
1156 ;; custom-enabled-themes, which enables the theme...
1157 (unless custom-enabling-themes
1158 (let ((custom-enabling-themes t))
1159 (setq themes (delq 'user (delete-dups themes)))
1160 (if (boundp symbol)
1161 (dolist (theme (symbol-value symbol))
1162 (if (not (memq theme themes))
1163 (disable-theme theme))))
1164 (dolist (theme (reverse themes))
1165 (if (or (custom-theme-loaded-p theme) (eq theme 'user))
1166 (enable-theme theme)
1167 (load-theme theme)))
1168 (enable-theme 'user)
1169 (custom-set-default symbol themes)))))
1170
1171(defun custom-theme-enabled-p (theme)
1172 "Return non-nil if THEME is enabled."
1173 (memq theme custom-enabled-themes))
1157 1174
1158(defun disable-theme (theme) 1175(defun disable-theme (theme)
1159 "Disable all variable and face settings defined by THEME. 1176 "Disable all variable and face settings defined by THEME.
1160See `custom-known-themes' for a list of known themes." 1177See `custom-enabled-themes' for a list of enabled themes."
1161 (interactive "SDisable Custom theme: ") 1178 (interactive "SDisable Custom theme: ")
1162 (let ((settings (get theme 'theme-settings))) 1179 (when (memq theme custom-enabled-themes)
1163 (dolist (s settings) 1180 (let ((settings (get theme 'theme-settings)))
1164 (let* ((prop (car s)) 1181 (dolist (s settings)
1165 (symbol (cadr s)) 1182 (let* ((prop (car s))
1166 (spec-list (get symbol prop))) 1183 (symbol (cadr s))
1167 (put symbol prop (assq-delete-all theme spec-list)) 1184 (spec-list (get symbol prop)))
1168 (if (eq prop 'theme-value) 1185 (put symbol prop (assq-delete-all theme spec-list))
1169 (custom-theme-recalc-variable symbol) 1186 (if (eq prop 'theme-value)
1170 (custom-theme-recalc-face symbol))))) 1187 (custom-theme-recalc-variable symbol)
1171 (setq custom-enabled-themes 1188 (custom-theme-recalc-face symbol)))))
1172 (delq theme custom-enabled-themes))) 1189 (setq custom-enabled-themes
1190 (delq theme custom-enabled-themes))))
1173 1191
1174(defun custom-theme-value (theme setting-list) 1192(defun custom-theme-value (theme setting-list)
1175 "Determine the value specified for THEME according to SETTING-LIST. 1193 "Determine the value specified for THEME according to SETTING-LIST.
@@ -1217,9 +1235,10 @@ This function returns nil if no custom theme specifies a value for VARIABLE."
1217 1235
1218(defun custom-theme-recalc-face (face) 1236(defun custom-theme-recalc-face (face)
1219 "Set FACE according to currently enabled custom themes." 1237 "Set FACE according to currently enabled custom themes."
1220 (let ((theme-faces (reverse (get face 'theme-face)))) 1238 (if (facep face)
1221 (dolist (spec theme-faces) 1239 (let ((theme-faces (reverse (get face 'theme-face))))
1222 (face-spec-set face (car (cddr spec)))))) 1240 (dolist (spec theme-faces)
1241 (face-spec-set face (car (cddr spec)))))))
1223 1242
1224(defun custom-theme-reset-variables (theme &rest args) 1243(defun custom-theme-reset-variables (theme &rest args)
1225 "Reset the specs in THEME of some variables to their values in other themes. 1244 "Reset the specs in THEME of some variables to their values in other themes.
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index de366997a93..7819a0e81cc 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1507,6 +1507,13 @@ Here each COMPILED is of the form (MATCHER HIGHLIGHT ...) as shown in the
1507`font-lock-keywords' doc string. 1507`font-lock-keywords' doc string.
1508If REGEXP is non-nil, it means these keywords are used for 1508If REGEXP is non-nil, it means these keywords are used for
1509`font-lock-keywords' rather than for `font-lock-syntactic-keywords'." 1509`font-lock-keywords' rather than for `font-lock-syntactic-keywords'."
1510 (if (not font-lock-set-defaults)
1511 ;; This should never happen. But some external packages sometimes
1512 ;; call font-lock in unexpected and incorrect ways. It's important to
1513 ;; stop processing at this point, otherwise we may end up changing the
1514 ;; global value of font-lock-keywords and break highlighting in many
1515 ;; other buffers.
1516 (error "Font-lock trying to use keywords before setting them up"))
1510 (if (eq (car-safe keywords) t) 1517 (if (eq (car-safe keywords) t)
1511 keywords 1518 keywords
1512 (setq keywords 1519 (setq keywords
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el
index eb5ace956eb..16db1e25a9a 100644
--- a/lisp/jit-lock.el
+++ b/lisp/jit-lock.el
@@ -65,7 +65,9 @@ Preserves the `buffer-modified-p' state of the current buffer."
65 :group 'font-lock) 65 :group 'font-lock)
66 66
67(defcustom jit-lock-chunk-size 500 67(defcustom jit-lock-chunk-size 500
68 "*Jit-lock chunks of this many characters, or smaller." 68 "*Jit-lock fontifies chunks of at most this many characters at a time.
69
70This variable controls both display-time and stealth fontification."
69 :type 'integer 71 :type 'integer
70 :group 'jit-lock) 72 :group 'jit-lock)
71 73
diff --git a/lisp/locate.el b/lisp/locate.el
index 563300f6c03..9676c84f80c 100644
--- a/lisp/locate.el
+++ b/lisp/locate.el
@@ -144,12 +144,12 @@
144 144
145(defcustom locate-fcodes-file nil 145(defcustom locate-fcodes-file nil
146 "*File name for the database of file names." 146 "*File name for the database of file names."
147 :type '(choice file (const nil)) 147 :type '(choice (const :tag "None" nil) file)
148 :group 'locate) 148 :group 'locate)
149 149
150(defcustom locate-header-face nil 150(defcustom locate-header-face nil
151 "*Face used to highlight the locate header." 151 "*Face used to highlight the locate header."
152 :type '(choice face (const nil)) 152 :type '(choice (const :tag "None" nil) face)
153 :group 'locate) 153 :group 'locate)
154 154
155;;;###autoload 155;;;###autoload
diff --git a/lisp/makefile.w32-in b/lisp/makefile.w32-in
index 24acf0009c4..f9c33dbed79 100644
--- a/lisp/makefile.w32-in
+++ b/lisp/makefile.w32-in
@@ -183,6 +183,9 @@ update-subdirs-SH: doit
183 183
184updates: update-subdirs autoloads mh-autoloads finder-data custom-deps 184updates: update-subdirs autoloads mh-autoloads finder-data custom-deps
185 185
186# This is useful after "cvs up".
187cvs-update: recompile autoloads finder-data custom-deps
188
186# Update the AUTHORS file. 189# Update the AUTHORS file.
187 190
188update-authors: 191update-authors:
diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog
index 74fd15a2c19..4f3d56f98c9 100644
--- a/lisp/mh-e/ChangeLog
+++ b/lisp/mh-e/ChangeLog
@@ -1,3 +1,66 @@
12006-01-01 Bill Wohler <wohler@newt.com>
2
3 * mh-customize.el: Sync docstrings with manual for faces and sort
4 them alphabetically.
5 (mh-faces): Move below mh-hooks.
6 (mh-folder-faces, mh-index-faces, mh-letter-faces)
7 (mh-show-faces, mh-speed-faces): Delete. Organize faces like
8 hooks.
9 (mh-speed-update-interval): Fix group (mh-speedbar, not mh-speed).
10 (facemenu-unlisted-faces): Might as well ignore all MH-E faces.
11 (mh-folder-body-face, mh-folder-cur-msg-face)
12 (mh-folder-cur-msg-number-face, mh-folder-date-face)
13 (mh-folder-followup-face, mh-folder-msg-number-face)
14 (mh-folder-deleted-face, mh-folder-refiled-face)
15 (mh-folder-subject-face, mh-folder-address-face)
16 (mh-folder-scan-format-face, mh-folder-to-face)
17 (mh-index-folder-face, mh-show-cc-face, mh-show-date-face)
18 (mh-show-header-face, mh-show-pgg-good-face)
19 (mh-show-pgg-unknown-face, mh-show-pgg-bad-face)
20 (mh-show-to-face, mh-show-from-face, mh-show-subject-face):
21 Delete.
22 (mh-folder-cur-msg): Unused. Delete.
23 (mh-folder-address): Use defface; inherit from mh-folder-subject.
24 (mh-folder-body, mh-folder-cur-msg-number, mh-folder-date):
25 Inherit from mh-folder-msg-number.
26 (mh-folder-deleted): Use defface. Inherit from
27 mh-folder-msg-number.
28 (mh-folder-sent-to-me-hint): New face. Inherit from
29 mh-folder-date.
30 (mh-folder-sent-to-me-sender): Rename from mh-folder-scan-format.
31 Use defface. Inherit from mh-folder-followup.
32 (mh-show-xface): Inherit from mh-show-from and highlight.
33 (bw-face-generation, bw-toggle-faces)
34 (bw-new-face-to-old, bw-old-face-to-new): New (tempoarary)
35 variables, functions for toggling between old and new faces.
36
37 * mh-e.el (font-lock-auto-fontify, font-lock-defaults): Hide in
38 eval-when-compile. We should probably do this throughout.
39 (mh-scan-good-msg-regexp, mh-scan-deleted-msg-regexp)
40 (mh-scan-refiled-msg-regexp, mh-scan-cur-msg-number-regexp)
41 (mh-scan-date-regexp, mh-scan-rcpt-regexp, mh-scan-body-regexp)
42 (mh-scan-subject-regexp): Sync docstrings with manual
43 (mh-scan-format-regexp): Rename to
44 mh-scan-sent-to-me-sender-regexp. Drop date parenthesized
45 expression. Make expression more like the others (anchored at the
46 beginning of line). Sync docstrings with manual.
47 (mh-folder-font-lock-keywords): Use faces directly rather than
48 -face variables. Use mh-scan-sent-to-me-sender-regexp instead of
49 mh-scan-format-regexp, and within that expression, use faces
50 mh-folder-sent-to-me-hint and mh-folder-sent-to-me-sender instead
51 of mh-folder-date-face and mh-folder-scan-format-face which were
52 misleading.
53
54 * mh-mime.el (mh-mime-security-button-face): Use faces directly
55 rather than -face variables.
56
57 * mh-utils.el (mh-show-font-lock-keywords): Use faces directly
58 rather than -face variables.
59 (mh-face-foreground-compat, mh-face-background-compat): New macros.
60 (mh-face-display-function): Use mh-face-foreground-compat and
61 mh-face-background-compat to use inherited attributes of
62 mh-show-xface on Emacs 22 while still working on Emacs 21.
63
12005-12-28 Bill Wohler <wohler@newt.com> 642005-12-28 Bill Wohler <wohler@newt.com>
2 65
3 * mh-comp.el (mh-e-user-agent): Move here from simple.el. Use 66 * mh-comp.el (mh-e-user-agent): Move here from simple.el. Use
diff --git a/lisp/mh-e/mh-customize.el b/lisp/mh-e/mh-customize.el
index f5556bda2ba..edd6ee41b01 100644
--- a/lisp/mh-e/mh-customize.el
+++ b/lisp/mh-e/mh-customize.el
@@ -204,57 +204,18 @@ and GNU mailutils."
204 :prefix "mh-" 204 :prefix "mh-"
205 :group 'mh-e) 205 :group 'mh-e)
206 206
207(defgroup mh-faces nil
208 "Faces used in MH-E."
209 :link '(custom-manual "(mh-e)Top")
210 :prefix "mh-"
211 :group 'faces
212 :group 'mh-e)
213
214(defgroup mh-hooks nil 207(defgroup mh-hooks nil
215 "MH-E hooks." 208 "MH-E hooks."
216 :link '(custom-manual "(mh-e)Top") 209 :link '(custom-manual "(mh-e)Top")
217 :prefix "mh-" 210 :prefix "mh-"
218 :group 'mh-e) 211 :group 'mh-e)
219 212
220 213(defgroup mh-faces nil
221 214 "Faces used in MH-E."
222;;; Faces 215 :link '(custom-manual "(mh-e)Top")
223
224(defgroup mh-folder-faces nil
225 "Faces used in scan listing."
226 :link '(custom-manual "(mh-e)Folders")
227 :prefix "mh-"
228 :group 'mh-faces
229 :group 'mh-folder)
230
231(defgroup mh-index-faces nil
232 "Faces used in searching."
233 :link '(custom-manual "(mh-e)Searching")
234 :prefix "mh-"
235 :group 'mh-faces
236 :group 'mh-index)
237
238(defgroup mh-letter-faces nil
239 "Faces used in message drafts."
240 :link '(custom-manual "(mh-e)Editing Drafts")
241 :prefix "mh-"
242 :group 'mh-faces
243 :group 'mh-letter)
244
245(defgroup mh-show-faces nil
246 "Faces used in message display."
247 :link '(custom-manual "(mh-e)Reading Mail")
248 :prefix "mh-"
249 :group 'mh-faces
250 :group 'mh-show)
251
252(defgroup mh-speed-faces nil
253 "Faces used in speedbar."
254 :link '(custom-manual "(mh-e)Speedbar")
255 :prefix "mh-" 216 :prefix "mh-"
256 :group 'mh-faces 217 :group 'faces
257 :group 'mh-speed) 218 :group 'mh-e)
258 219
259 220
260 221
@@ -1883,13 +1844,13 @@ lines you'd like to see."
1883 1844
1884 1845
1885 1846
1886;;; The Speedbar (:group 'mh-speed) 1847;;; The Speedbar (:group 'mh-speedbar)
1887 1848
1888(defcustom mh-speed-update-interval 60 1849(defcustom mh-speed-update-interval 60
1889 "Time between speedbar updates in seconds. 1850 "Time between speedbar updates in seconds.
1890Set to 0 to disable automatic update." 1851Set to 0 to disable automatic update."
1891 :type 'integer 1852 :type 'integer
1892 :group 'mh-speed) 1853 :group 'mh-speedbar)
1893 1854
1894 1855
1895 1856
@@ -2526,81 +2487,42 @@ sequence."
2526 2487
2527 2488
2528 2489
2529;;; Faces (:group 'mh-*-faces + group where faces described) 2490;;; Faces (:group 'mh-faces + group where faces described)
2530 2491
2531 2492(if (boundp 'facemenu-unlisted-faces)
2493 (add-to-list 'facemenu-unlisted-faces "^mh-"))
2532 2494
2533;;; Faces Used in Scan Listing (:group 'mh-folder-faces) 2495(defface mh-folder-address '((t (:inherit mh-folder-subject)))
2496 "Recipient face."
2497 :group 'mh-faces
2498 :group 'mh-folder)
2534 2499
2535(defvar mh-folder-body-face 'mh-folder-body
2536 "Face used to highlight body text in MH-Folder buffers.")
2537(defface mh-folder-body 2500(defface mh-folder-body
2538 (mh-defface-compat 2501 '((((class color))
2539 '((((class color) (min-colors 88) (background light)) 2502 (:inherit mh-folder-msg-number))
2540 (:foreground "RosyBrown")) 2503 (t
2541 (((class color) (min-colors 88) (background dark)) 2504 (:inherit mh-folder-msg-number :italic t)))
2542 (:foreground "LightSalmon")) 2505 "Body text face."
2543 (((class color)) 2506 :group 'mh-faces
2544 (:foreground "green")) 2507 :group 'mh-folder)
2545 (((class grayscale) (background light))
2546 (:foreground "DimGray" :italic t))
2547 (((class grayscale) (background dark))
2548 (:foreground "LightGray" :italic t))
2549 (t
2550 (:italic t))))
2551 "Face used to highlight body text in MH-Folder buffers."
2552 :group 'mh-folder-faces)
2553
2554(defvar mh-folder-cur-msg-face 'mh-folder-cur-msg
2555 "Face used for the current message line in MH-Folder buffers.")
2556(defface mh-folder-cur-msg
2557 (mh-defface-compat
2558 '((((class color) (min-colors 88) (background light))
2559 (:background "LightGreen") ;Use this for solid background colour
2560 ;; (:underline t) ;Use this for underlining
2561 )
2562 (((class color) (min-colors 88) (background dark))
2563 (:background "DarkOliveGreen4"))
2564 (((class color))
2565 (:background "LightGreen"))
2566 (t
2567 (:underline t))))
2568 "Face used for the current message line in MH-Folder buffers."
2569 :group 'mh-folder-faces)
2570 2508
2571(defvar mh-folder-cur-msg-number-face 'mh-folder-cur-msg-number
2572 "Face used to highlight the current message in MH-Folder buffers.")
2573(defface mh-folder-cur-msg-number 2509(defface mh-folder-cur-msg-number
2574 (mh-defface-compat 2510 '((t
2575 '((((class color) (min-colors 88) (background light)) 2511 (:inherit mh-folder-msg-number :bold t)))
2576 (:foreground "Purple")) 2512 "Current message number face."
2577 (((class color) (min-colors 88) (background dark)) 2513 :group 'mh-faces
2578 (:foreground "Cyan")) 2514 :group 'mh-folder)
2579 (((class color))
2580 (:foreground "cyan" :weight bold))
2581 (((class grayscale) (background light))
2582 (:foreground "LightGray" :bold t))
2583 (((class grayscale) (background dark))
2584 (:foreground "DimGray" :bold t))
2585 (t
2586 (:bold t))))
2587 "Face used to highlight the current message in MH-Folder buffers."
2588 :group 'mh-folder-faces)
2589 2515
2590(defvar mh-folder-date-face 'mh-folder-date 2516(defface mh-folder-date '((t (:inherit mh-folder-msg-number)))
2591 "Face used to highlight the date in MH-Folder buffers.") 2517 "Date face."
2592(defface mh-folder-date 2518 :group 'mh-faces
2593 '((((class color) (background light)) 2519 :group 'mh-folder)
2594 (:foreground "snow4")) 2520
2595 (((class color) (background dark)) 2521(defface mh-folder-deleted '((t (:inherit mh-folder-msg-number)))
2596 (:foreground "snow3")) 2522 "Deleted message face."
2597 (t 2523 :group 'mh-faces
2598 (:bold t))) 2524 :group 'mh-folder)
2599 "Face used to highlight the date in MH-Folder buffers."
2600 :group 'mh-folder-faces)
2601 2525
2602(defvar mh-folder-followup-face 'mh-folder-followup
2603 "Face used to highlight Re: subject text in MH-Folder buffers.")
2604(defface mh-folder-followup 2526(defface mh-folder-followup
2605 '((((class color) (background light)) 2527 '((((class color) (background light))
2606 (:foreground "blue3")) 2528 (:foreground "blue3"))
@@ -2608,27 +2530,19 @@ sequence."
2608 (:foreground "LightGoldenRod")) 2530 (:foreground "LightGoldenRod"))
2609 (t 2531 (t
2610 (:bold t))) 2532 (:bold t)))
2611 "Face used to highlight Re: subject text in MH-Folder buffers." 2533 "\"Re:\" face."
2612 :group 'mh-folder-faces) 2534 :group 'mh-faces
2535 :group 'mh-folder)
2613 2536
2614(defvar mh-folder-msg-number-face 'mh-folder-msg-number
2615 "Face used to highlight the message number in MH-Folder buffers.")
2616(defface mh-folder-msg-number 2537(defface mh-folder-msg-number
2617 '((((class color) (background light)) 2538 '((((class color) (background light))
2618 (:foreground "snow4")) 2539 (:foreground "snow4"))
2619 (((class color) (background dark)) 2540 (((class color) (background dark))
2620 (:foreground "snow3")) 2541 (:foreground "snow3")))
2621 (t 2542 "Message number face."
2622 (:bold t))) 2543 :group 'mh-faces
2623 "Face used to highlight the message number in MH-Folder buffers." 2544 :group 'mh-folder)
2624 :group 'mh-folder-faces)
2625
2626(defvar mh-folder-deleted-face 'mh-folder-deleted
2627 "Face used to highlight deleted messages in MH-Folder buffers.")
2628(copy-face 'mh-folder-msg-number 'mh-folder-deleted)
2629 2545
2630(defvar mh-folder-refiled-face 'mh-folder-refiled
2631 "Face used to highlight refiled messages in MH-Folder buffers.")
2632(defface mh-folder-refiled 2546(defface mh-folder-refiled
2633 (mh-defface-compat 2547 (mh-defface-compat
2634 '((((class color) (min-colors 88) (background light)) 2548 '((((class color) (min-colors 88) (background light))
@@ -2643,13 +2557,26 @@ sequence."
2643 (:foreground "DimGray" :bold t :italic t)) 2557 (:foreground "DimGray" :bold t :italic t))
2644 (t 2558 (t
2645 (:bold t :italic t)))) 2559 (:bold t :italic t))))
2646 "Face used to highlight refiled messages in MH-Folder buffers." 2560 "Refiled message face."
2647 :group 'mh-folder-faces) 2561 :group 'mh-faces
2562 :group 'mh-folder)
2563
2564(defface mh-folder-sent-to-me-hint '((t (:inherit mh-folder-date)))
2565 "Fontification hint face in messages sent directly to us.
2566The detection of messages sent to us is governed by the scan
2567format `mh-scan-format-nmh' and the regular expression
2568`mh-scan-sent-to-me-sender-regexp'."
2569 :group 'mh-faces
2570 :group 'mh-folder)
2571
2572(defface mh-folder-sent-to-me-sender '((t (:inherit mh-folder-followup)))
2573 "Sender face in messages sent directly to us.
2574The detection of messages sent to us is governed by the scan
2575format `mh-scan-format-nmh' and the regular expression
2576`mh-scan-sent-to-me-sender-regexp'."
2577 :group 'mh-faces
2578 :group 'mh-folder)
2648 2579
2649(defvar mh-folder-subject-face 'mh-folder-subject
2650 "Face used to highlight subject text in MH-Folder buffers.")
2651(if (boundp 'facemenu-unlisted-faces)
2652 (add-to-list 'facemenu-unlisted-faces "^mh-folder"))
2653(defface mh-folder-subject 2580(defface mh-folder-subject
2654 '((((class color) (background light)) 2581 '((((class color) (background light))
2655 (:foreground "blue4")) 2582 (:foreground "blue4"))
@@ -2657,8 +2584,9 @@ sequence."
2657 (:foreground "yellow")) 2584 (:foreground "yellow"))
2658 (t 2585 (t
2659 (:bold t))) 2586 (:bold t)))
2660 "Face used to highlight subject text in MH-Folder buffers." 2587 "Subject face."
2661 :group 'mh-folder-faces) 2588 :group 'mh-faces
2589 :group 'mh-folder)
2662 2590
2663(defface mh-folder-tick 2591(defface mh-folder-tick
2664 '((((class color) (background dark)) 2592 '((((class color) (background dark))
@@ -2667,19 +2595,10 @@ sequence."
2667 (:background "#dddf7e")) 2595 (:background "#dddf7e"))
2668 (t 2596 (t
2669 (:underline t))) 2597 (:underline t)))
2670 "Face used to show ticked messages." 2598 "Ticked message face."
2671 :group 'mh-folder-faces) 2599 :group 'mh-faces
2672 2600 :group 'mh-folder)
2673(defvar mh-folder-address-face 'mh-folder-address
2674 "Face used to highlight the address in MH-Folder buffers.")
2675(copy-face 'mh-folder-subject 'mh-folder-address)
2676
2677(defvar mh-folder-scan-format-face 'mh-folder-scan-format
2678 "Face used to highlight `mh-scan-format-regexp' matches in MH-Folder buffers.")
2679(copy-face 'mh-folder-followup 'mh-folder-scan-format)
2680 2601
2681(defvar mh-folder-to-face 'mh-folder-to
2682 "Face used to highlight the To: string in MH-Folder buffers.")
2683(defface mh-folder-to 2602(defface mh-folder-to
2684 (mh-defface-compat 2603 (mh-defface-compat
2685 '((((class color) (min-colors 88) (background light)) 2604 '((((class color) (min-colors 88) (background light))
@@ -2694,15 +2613,10 @@ sequence."
2694 (:foreground "LightGray" :italic t)) 2613 (:foreground "LightGray" :italic t))
2695 (t 2614 (t
2696 (:italic t)))) 2615 (:italic t))))
2697 "Face used to highlight the To: string in MH-Folder buffers." 2616 "\"To:\" face."
2698 :group 'mh-folder-faces) 2617 :group 'mh-faces
2699 2618 :group 'mh-folder)
2700
2701
2702;;; Faces Used in Searching (:group 'mh-index-faces)
2703 2619
2704(defvar mh-index-folder-face 'mh-index-folder
2705 "Face used to highlight folders in MH-Index buffers.")
2706(defface mh-index-folder 2620(defface mh-index-folder
2707 '((((class color) (background light)) 2621 '((((class color) (background light))
2708 (:foreground "dark green" :bold t)) 2622 (:foreground "dark green" :bold t))
@@ -2710,12 +2624,9 @@ sequence."
2710 (:foreground "indian red" :bold t)) 2624 (:foreground "indian red" :bold t))
2711 (t 2625 (t
2712 (:bold t))) 2626 (:bold t)))
2713 "Face used to highlight folders in MH-Index buffers." 2627 "Folder heading face in MH-Folder buffers created by searches."
2714 :group 'mh-index-faces) 2628 :group 'mh-faces
2715 2629 :group 'mh-index)
2716
2717
2718;;; Faces Used in Message Drafts (:group 'mh-letter-faces)
2719 2630
2720(defface mh-letter-header-field 2631(defface mh-letter-header-field
2721 '((((class color) (background light)) 2632 '((((class color) (background light))
@@ -2724,15 +2635,10 @@ sequence."
2724 (:background "gray10")) 2635 (:background "gray10"))
2725 (t 2636 (t
2726 (:bold t))) 2637 (:bold t)))
2727 "Face used to display header fields in draft buffers." 2638 "Editable header field value face in draft buffers."
2728 :group 'mh-letter-faces) 2639 :group 'mh-faces
2729 2640 :group 'mh-letter)
2730
2731
2732;;; Faces Used in Message Display (:group 'mh-show-faces)
2733 2641
2734(defvar mh-show-cc-face 'mh-show-cc
2735 "Face used to highlight cc: header fields.")
2736(defface mh-show-cc 2642(defface mh-show-cc
2737 (mh-defface-compat 2643 (mh-defface-compat
2738 '((((class color) (min-colors 88) (background light)) 2644 '((((class color) (min-colors 88) (background light))
@@ -2747,11 +2653,10 @@ sequence."
2747 (:foreground "DimGray" :bold t :italic t)) 2653 (:foreground "DimGray" :bold t :italic t))
2748 (t 2654 (t
2749 (:bold t :italic t)))) 2655 (:bold t :italic t))))
2750 "Face used to highlight cc: header fields." 2656 "Face used to highlight \"cc:\" header fields."
2751 :group 'mh-show-faces) 2657 :group 'mh-faces
2658 :group 'mh-show)
2752 2659
2753(defvar mh-show-date-face 'mh-show-date
2754 "Face used to highlight the Date: header field.")
2755(defface mh-show-date 2660(defface mh-show-date
2756 (mh-defface-compat 2661 (mh-defface-compat
2757 '((((class color) (min-colors 88) (background light)) 2662 '((((class color) (min-colors 88) (background light))
@@ -2766,11 +2671,21 @@ sequence."
2766 (:foreground "DimGray" :bold t)) 2671 (:foreground "DimGray" :bold t))
2767 (t 2672 (t
2768 (:bold t :underline t)))) 2673 (:bold t :underline t))))
2769 "Face used to highlight the Date: header field." 2674 "Face used to highlight \"Date:\" header fields."
2770 :group 'mh-show-faces) 2675 :group 'mh-faces
2676 :group 'mh-show)
2677
2678(defface mh-show-from
2679 '((((class color) (background light))
2680 (:foreground "red3"))
2681 (((class color) (background dark))
2682 (:foreground "cyan"))
2683 (t
2684 (:bold t)))
2685 "Face used to highlight \"From:\" header fields."
2686 :group 'mh-faces
2687 :group 'mh-show)
2771 2688
2772(defvar mh-show-header-face 'mh-show-header
2773 "Face used to deemphasize unspecified header fields.")
2774(defface mh-show-header 2689(defface mh-show-header
2775 (mh-defface-compat 2690 (mh-defface-compat
2776 '((((class color) (min-colors 88) (background light)) 2691 '((((class color) (min-colors 88) (background light))
@@ -2785,46 +2700,35 @@ sequence."
2785 (:foreground "LightGray" :italic t)) 2700 (:foreground "LightGray" :italic t))
2786 (t 2701 (t
2787 (:italic t)))) 2702 (:italic t))))
2788 "Face used to deemphasize unspecified header fields." 2703 "Face used to deemphasize less interesting header fields."
2789 :group 'mh-show-faces) 2704 :group 'mh-faces
2705 :group 'mh-show)
2790 2706
2791(defvar mh-show-pgg-good-face 'mh-show-pgg-good 2707(defface mh-show-pgg-bad '((t (:bold t :foreground "DeepPink1")))
2792 "Face used to highlight a good PGG signature.") 2708 "Bad PGG signature face."
2793(defface mh-show-pgg-good 2709 :group 'mh-faces
2794 '((t 2710 :group 'mh-show)
2795 (:bold t :foreground "LimeGreen")))
2796 "Face used to highlight a good PGG signature."
2797 :group 'mh-show-faces)
2798
2799(defvar mh-show-pgg-unknown-face 'mh-show-pgg-unknown
2800 "Face used to highlight a PGG signature whose status is unknown.
2801This face is also used for a signature when the signer is
2802untrusted.")
2803(defface mh-show-pgg-unknown
2804 '((t
2805 (:bold t :foreground "DarkGoldenrod2")))
2806 "Face used to highlight a PGG signature whose status is unknown.
2807This face is also used for a signature when the signer is untrusted."
2808 :group 'mh-show-faces)
2809
2810(defvar mh-show-pgg-bad-face 'mh-show-pgg-bad
2811 "Face used to highlight a bad PGG signature.")
2812(defface mh-show-pgg-bad
2813 '((t
2814 (:bold t :foreground "DeepPink1")))
2815 "Face used to highlight a bad PGG signature."
2816 :group 'mh-show-faces)
2817 2711
2818(defface mh-show-signature 2712(defface mh-show-pgg-good '((t (:bold t :foreground "LimeGreen")))
2819 '((t 2713 "Good PGG signature face."
2820 (:italic t))) 2714 :group 'mh-faces
2821 "Face used to highlight the message signature." 2715 :group 'mh-show)
2822 :group 'mh-show-faces) 2716
2717(defface mh-show-pgg-unknown '((t (:bold t :foreground "DarkGoldenrod2")))
2718 "Unknown or untrusted PGG signature face."
2719 :group 'mh-faces
2720 :group 'mh-show)
2721
2722(defface mh-show-signature '((t (:italic t)))
2723 "Signature face."
2724 :group 'mh-faces
2725 :group 'mh-show)
2726
2727(defface mh-show-subject '((t (:inherit mh-folder-subject)))
2728 "Face used to highlight \"Subject:\" header fields."
2729 :group 'mh-faces
2730 :group 'mh-show)
2823 2731
2824(defvar mh-show-to-face 'mh-show-to
2825 "Face used to highlight the To: header field.")
2826(if (boundp 'facemenu-unlisted-faces)
2827 (add-to-list 'facemenu-unlisted-faces "^mh-show"))
2828(defface mh-show-to 2732(defface mh-show-to
2829 '((((class color) (background light)) 2733 '((((class color) (background light))
2830 (:foreground "SaddleBrown")) 2734 (:foreground "SaddleBrown"))
@@ -2835,43 +2739,31 @@ This face is also used for a signature when the signer is untrusted."
2835 (((class grayscale) (background dark)) 2739 (((class grayscale) (background dark))
2836 (:foreground "LightGray" :underline t)) 2740 (:foreground "LightGray" :underline t))
2837 (t (:underline t))) 2741 (t (:underline t)))
2838 "Face used to highlight the To: header field." 2742 "Face used to highlight \"To:\" header fields."
2839 :group 'mh-show-faces) 2743 :group 'mh-faces
2840 2744 :group 'mh-show)
2841(defvar mh-show-from-face 'mh-show-from
2842 "Face used to highlight the From: header field.")
2843(defface mh-show-from
2844 '((((class color) (background light))
2845 (:foreground "red3"))
2846 (((class color) (background dark))
2847 (:foreground "cyan"))
2848 (t
2849 (:bold t)))
2850 "Face used to highlight the From: header field."
2851 :group 'mh-show-faces)
2852
2853(defface mh-show-xface
2854 '((t
2855 (:foreground "black" :background "white")))
2856 "Face used to display the X-Face image.
2857The background and foreground is used in the image."
2858 :group 'mh-show-faces)
2859
2860(defvar mh-show-subject-face 'mh-show-subject
2861 "Face used to highlight the Subject: header field.")
2862(copy-face 'mh-folder-subject 'mh-show-subject)
2863
2864
2865 2745
2866;;; Faces Used in Speedbar (:group 'mh-speed-faces) 2746(defface mh-show-xface '((t (:inherit (mh-show-from highlight))))
2747 "X-Face image face.
2748The background and foreground are used in the image."
2749 :group 'mh-faces
2750 :group 'mh-show)
2867 2751
2868(defface mh-speedbar-folder 2752(defface mh-speedbar-folder
2869 '((((class color) (background light)) 2753 '((((class color) (background light))
2870 (:foreground "blue4")) 2754 (:foreground "blue4"))
2871 (((class color) (background dark)) 2755 (((class color) (background dark))
2872 (:foreground "light blue"))) 2756 (:foreground "light blue")))
2873 "Face used for folders in the speedbar buffer." 2757 "Basic folder face."
2874 :group 'mh-speed-faces) 2758 :group 'mh-faces
2759 :group 'mh-speedbar)
2760
2761(defface mh-speedbar-folder-with-unseen-messages
2762 '((t
2763 (:inherit mh-speedbar-folder :bold t)))
2764 "Folder face when folder contains unread messages."
2765 :group 'mh-faces
2766 :group 'mh-speedbar)
2875 2767
2876(defface mh-speedbar-selected-folder 2768(defface mh-speedbar-selected-folder
2877 '((((class color) (background light)) 2769 '((((class color) (background light))
@@ -2880,20 +2772,111 @@ The background and foreground is used in the image."
2880 (:foreground "red1" :underline t)) 2772 (:foreground "red1" :underline t))
2881 (t 2773 (t
2882 (:underline t))) 2774 (:underline t)))
2883 "Face used for the current folder." 2775 "Selected folder face."
2884 :group 'mh-speed-faces) 2776 :group 'mh-faces
2885 2777 :group 'mh-speedbar)
2886(defface mh-speedbar-folder-with-unseen-messages
2887 '((t
2888 (:inherit mh-speedbar-folder :bold t)))
2889 "Face used for folders in the speedbar buffer which have unread messages."
2890 :group 'mh-speed-faces)
2891 2778
2892(defface mh-speedbar-selected-folder-with-unseen-messages 2779(defface mh-speedbar-selected-folder-with-unseen-messages
2893 '((t 2780 '((t
2894 (:inherit mh-speedbar-selected-folder :bold t))) 2781 (:inherit mh-speedbar-selected-folder :bold t)))
2895 "Face used for the current folder when it has unread messages." 2782 "Selected folder face when folder contains unread messages."
2896 :group 'mh-speed-faces) 2783 :group 'mh-faces
2784 :group 'mh-speedbar)
2785
2786;;; XXX Temporary function for comparing old and new faces. Delete
2787;;; when everybody is happy.
2788(defvar bw-face-generation 'new)
2789
2790(defun bw-toggle-faces ()
2791 "Toggle between old and new faces."
2792 (interactive)
2793 (cond ((eq bw-face-generation 'new)
2794 (message "Going from new to old...")
2795 (bw-new-face-to-old)
2796 (message "Going from new to old...done")
2797 (setq bw-face-generation 'old))
2798 ((eq bw-face-generation 'old)
2799 (message "Going from old to new...")
2800 (bw-old-face-to-new)
2801 (message "Going from old to new...done")
2802 (setq bw-face-generation 'new))))
2803
2804(defun bw-new-face-to-old ()
2805 "Sets old faces."
2806 (face-spec-set 'mh-folder-body
2807 (mh-defface-compat
2808 '((((class color) (min-colors 88) (background light))
2809 (:foreground "RosyBrown"))
2810 (((class color) (min-colors 88) (background dark))
2811 (:foreground "LightSalmon"))
2812 (((class color))
2813 (:foreground "green"))
2814 (((class grayscale) (background light))
2815 (:foreground "DimGray" :italic t))
2816 (((class grayscale) (background dark))
2817 (:foreground "LightGray" :italic t))
2818 (t
2819 (:italic t)))))
2820
2821 (face-spec-set 'mh-folder-msg-number
2822 '((((class color) (background light))
2823 (:foreground "snow4"))
2824 (((class color) (background dark))
2825 (:foreground "snow3"))
2826 (t
2827 (:bold t))))
2828
2829 (face-spec-set 'mh-folder-cur-msg-number
2830 (mh-defface-compat
2831 '((((class color) (min-colors 88) (background light))
2832 (:foreground "Purple"))
2833 (((class color) (min-colors 88) (background dark))
2834 (:foreground "Cyan"))
2835 (((class color))
2836 (:foreground "cyan" :weight bold))
2837 (((class grayscale) (background light))
2838 (:foreground "LightGray" :bold t))
2839 (((class grayscale) (background dark))
2840 (:foreground "DimGray" :bold t))
2841 (t
2842 (:bold t)))))
2843
2844 (face-spec-set 'mh-folder-date
2845 '((((class color) (background light))
2846 (:foreground "snow4"))
2847 (((class color) (background dark))
2848 (:foreground "snow3"))
2849 (t
2850 (:bold t))))
2851
2852 (face-spec-set 'mh-folder-msg-number
2853 '((((class color) (background light))
2854 (:foreground "snow4"))
2855 (((class color) (background dark))
2856 (:foreground "snow3"))
2857 (t
2858 (:bold t)))))
2859
2860(defun bw-old-face-to-new ()
2861 "Sets new faces."
2862 (face-spec-set 'mh-folder-body
2863 '((((class color))
2864 (:inherit mh-folder-msg-number))
2865 (t
2866 (:inherit mh-folder-msg-number :italic t))))
2867
2868 (face-spec-set 'mh-folder-cur-msg-number
2869 '((t
2870 (:inherit mh-folder-msg-number :bold t))))
2871
2872 (face-spec-set 'mh-folder-date '((t (:inherit mh-folder-msg-number))))
2873
2874 (face-spec-set 'mh-folder-msg-number
2875 '((((class color) (background light))
2876 (:foreground "snow4"))
2877 (((class color) (background dark))
2878 (:foreground "snow3")))))
2879
2897 2880
2898;; Local Variables: 2881;; Local Variables:
2899;; indent-tabs-mode: nil 2882;; indent-tabs-mode: nil
diff --git a/lisp/mh-e/mh-e.el b/lisp/mh-e/mh-e.el
index 30034008cec..1deb465c1fe 100644
--- a/lisp/mh-e/mh-e.el
+++ b/lisp/mh-e/mh-e.el
@@ -95,8 +95,9 @@
95(require 'easymenu) 95(require 'easymenu)
96 96
97;; Shush the byte-compiler 97;; Shush the byte-compiler
98(defvar font-lock-auto-fontify) 98(eval-when-compile
99(defvar font-lock-defaults) 99 (defvar font-lock-auto-fontify)
100 (defvar font-lock-defaults))
100 101
101(defconst mh-version "7.85+cvs" "Version number of MH-E.") 102(defconst mh-version "7.85+cvs" "Version number of MH-E.")
102 103
@@ -194,7 +195,8 @@ matches the message number as in the default of
194 \"^\\\\( *[0-9]+\\\\)[^D^0-9]\". 195 \"^\\\\( *[0-9]+\\\\)[^D^0-9]\".
195 196
196This expression includes the leading space within the parenthesis 197This expression includes the leading space within the parenthesis
197since it looks better to highlight it as well. This regular 198since it looks better to highlight it as well. The highlighting
199is done with the face `mh-folder-msg-number'. This regular
198expression should be correct as it is needed by non-fontification 200expression should be correct as it is needed by non-fontification
199functions.") 201functions.")
200 202
@@ -209,7 +211,8 @@ matches the message number as in the default of
209 \"^\\\\( *[0-9]+\\\\)D\". 211 \"^\\\\( *[0-9]+\\\\)D\".
210 212
211This expression includes the leading space within the parenthesis 213This expression includes the leading space within the parenthesis
212since it looks better to highlight it as well. This regular 214since it looks better to highlight it as well. The highlighting
215is done with the face `mh-folder-deleted'. This regular
213expression should be correct as it is needed by non-fontification 216expression should be correct as it is needed by non-fontification
214functions. See also `mh-note-deleted'.") 217functions. See also `mh-note-deleted'.")
215 218
@@ -224,7 +227,8 @@ matches the message number as in the default of
224 \"^\\\\( *[0-9]+\\\\)\\\\^\". 227 \"^\\\\( *[0-9]+\\\\)\\\\^\".
225 228
226This expression includes the leading space within the parenthesis 229This expression includes the leading space within the parenthesis
227since it looks better to highlight it as well. This regular 230since it looks better to highlight it as well. The highlighting
231is done with the face `mh-folder-refiled'. This regular
228expression should be correct as it is needed by non-fontification 232expression should be correct as it is needed by non-fontification
229functions. See also `mh-note-refiled'.") 233functions. See also `mh-note-refiled'.")
230 234
@@ -246,9 +250,10 @@ matches the message number as in the default of
246 250
247This expression includes the leading space and current message 251This expression includes the leading space and current message
248marker \"+\" within the parenthesis since it looks better to 252marker \"+\" within the parenthesis since it looks better to
249highlight these items as well. This regular expression should be 253highlight these items as well. The highlighting is done with the
250correct as it is needed by non-fontification functions. See also 254face `mh-folder-cur-msg-number'. This regular expression should
251`mh-note-cur'.") 255be correct as it is needed by non-fontification functions. See
256also `mh-note-cur'.")
252 257
253(defvar mh-scan-date-regexp "\\([0-9][0-9]/[0-9][0-9]\\)" 258(defvar mh-scan-date-regexp "\\([0-9][0-9]/[0-9][0-9]\\)"
254 "This regular expression matches a valid date. 259 "This regular expression matches a valid date.
@@ -258,8 +263,8 @@ Note that the default setting of `mh-folder-font-lock-keywords'
258expects this expression to contain only one parenthesized 263expects this expression to contain only one parenthesized
259expression which matches the date field as in the default of 264expression which matches the date field as in the default of
260\"\\\\([0-9][0-9]/[0-9][0-9]\\\\)\"}. If this regular expression 265\"\\\\([0-9][0-9]/[0-9][0-9]\\\\)\"}. If this regular expression
261is not correct, the date will not be highlighted. See also 266is not correct, the date will not be highlighted with the face
262`mh-scan-format-regexp'.") 267`mh-folder-date'.")
263 268
264(defvar mh-scan-rcpt-regexp "\\(To:\\)\\(..............\\)" 269(defvar mh-scan-rcpt-regexp "\\(To:\\)\\(..............\\)"
265 "This regular expression specifies the recipient in messages you sent. 270 "This regular expression specifies the recipient in messages you sent.
@@ -270,8 +275,9 @@ The first is expected to match the \"To:\" that the default scan
270format file generates. The second is expected to match the 275format file generates. The second is expected to match the
271recipient's name as in the default of 276recipient's name as in the default of
272\"\\\\(To:\\\\)\\\\(..............\\\\)\". If this regular 277\"\\\\(To:\\\\)\\\\(..............\\\\)\". If this regular
273expression is not correct, the recipient will not be 278expression is not correct, the \"To:\" string will not be
274highlighted.") 279highlighted with the face `mh-folder-to' and the recipient will
280not be highlighted with the face `mh-folder-address'")
275 281
276(defvar mh-scan-body-regexp "\\(<<\\([^\n]+\\)?\\)" 282(defvar mh-scan-body-regexp "\\(<<\\([^\n]+\\)?\\)"
277 "This regular expression matches the message body fragment. 283 "This regular expression matches the message body fragment.
@@ -280,7 +286,8 @@ Note that the default setting of `mh-folder-font-lock-keywords'
280expects this expression to contain at least one parenthesized 286expects this expression to contain at least one parenthesized
281expression which matches the body text as in the default of 287expression which matches the body text as in the default of
282\"\\\\(<<\\\\([^\\n]+\\\\)?\\\\)\". If this regular expression is 288\"\\\\(<<\\\\([^\\n]+\\\\)?\\\\)\". If this regular expression is
283not correct, the body fragment will not be highlighted.") 289not correct, the body fragment will not be highlighted with the
290face `mh-folder-body'.")
284 291
285(defvar mh-scan-subject-regexp 292(defvar mh-scan-subject-regexp
286 "^ *[0-9]+........[ ]*...................\\([Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-*\\)*\\([^<\n]*\\)" 293 "^ *[0-9]+........[ ]*...................\\([Rr][Ee]\\(\\[[0-9]+\\]\\)?:\\s-*\\)*\\([^<\n]*\\)"
@@ -289,12 +296,13 @@ not correct, the body fragment will not be highlighted.")
289It must match from the beginning of the line. Note that the 296It must match from the beginning of the line. Note that the
290default setting of `mh-folder-font-lock-keywords' expects this 297default setting of `mh-folder-font-lock-keywords' expects this
291expression to contain at least three parenthesized expressions. 298expression to contain at least three parenthesized expressions.
292The first is expected to match the \"Re:\" string, if any. The 299The first is expected to match the \"Re:\" string, if any, and is
293second matches an optional bracketed number after \"Re:\", such as 300highlighted with the face `mh-folder-followup'. The second
294in \"Re[2]:\" (and is thus a sub-expression of the first 301matches an optional bracketed number after \"Re:\", such as in
295expression) and the third is expected to match the subject line 302\"Re[2]:\" (and is thus a sub-expression of the first expression)
296itself as in the default of (broken on multiple lines for 303and the third is expected to match the subject line itself which
297readability): 304is highlighted with the face `mh-folder-subject'. For example,
305the default (broken on multiple lines for readability) is
298 306
299 ^ *[0-9]+........[ ]*................... 307 ^ *[0-9]+........[ ]*...................
300 \\\\([Rr][Ee]\\\\(\\\\\\=[[0-9]+\\\\]\\\\)?:\\\\s-*\\\\)* 308 \\\\([Rr][Ee]\\\\(\\\\\\=[[0-9]+\\\\]\\\\)?:\\\\s-*\\\\)*
@@ -303,22 +311,22 @@ readability):
303This regular expression should be correct as it is needed by 311This regular expression should be correct as it is needed by
304non-fontification functions.") 312non-fontification functions.")
305 313
306(defvar mh-scan-format-regexp 314(defvar mh-scan-sent-to-me-sender-regexp
307 (concat "\\([bct]\\)" mh-scan-date-regexp " *\\(..................\\)") 315 "^ *[0-9]+.\\([bct]\\).....[ ]*\\(..................\\)"
308 "This regular expression matches the output of scan. 316 "This regular expression matches messages sent to us.
309 317
310Note that the default setting of `mh-folder-font-lock-keywords' 318Note that the default setting of `mh-folder-font-lock-keywords'
311expects this expression to contain at least three parenthesized 319expects this expression to contain at least two parenthesized
312expressions. The first should match the fontification hint (see 320expressions. The first should match the fontification hint (see
313`mh-scan-format-nmh'), the second is found in 321`mh-scan-format-nmh') and the second should match the user name
314`mh-scan-date-regexp', and the third should match the user name
315as in the default of 322as in the default of
316 323
317 \"(concat \"\\\\([bct]\\\\)\" mh-scan-date-regexp 324 ^ *[0-9]+.\\\\([bct]\\\\).....[ ]*\\\\(..................\\\\)
318 \"*\\\\(..................\\\\)\")\".
319 325
320If this regular expression is not correct, the notation hints and 326If this regular expression is not correct, the notation hints
321the sender will not be highlighted.") 327will not be highlighted with the face
328`mh-mh-folder-sent-to-me-hint' and the sender will not be
329highlighted with the face `mh-folder-sent-to-me-sender'.")
322 330
323 331
324 332
@@ -326,31 +334,37 @@ the sender will not be highlighted.")
326 (list 334 (list
327 ;; Folders when displaying index buffer 335 ;; Folders when displaying index buffer
328 (list "^\\+.*" 336 (list "^\\+.*"
329 '(0 mh-index-folder-face)) 337 '(0 'mh-index-folder))
330 ;; Marked for deletion 338 ;; Marked for deletion
331 (list (concat mh-scan-deleted-msg-regexp ".*") 339 (list (concat mh-scan-deleted-msg-regexp ".*")
332 '(0 mh-folder-deleted-face)) 340 '(0 'mh-folder-deleted))
333 ;; Marked for refile 341 ;; Marked for refile
334 (list (concat mh-scan-refiled-msg-regexp ".*") 342 (list (concat mh-scan-refiled-msg-regexp ".*")
335 '(0 mh-folder-refiled-face)) 343 '(0 'mh-folder-refiled))
336 ;;after subj 344 ;; After subject
337 (list mh-scan-body-regexp '(1 mh-folder-body-face nil t)) 345 (list mh-scan-body-regexp
346 '(1 'mh-folder-body nil t))
347 ;; Subject
338 '(mh-folder-font-lock-subject 348 '(mh-folder-font-lock-subject
339 (1 mh-folder-followup-face append t) 349 (1 'mh-folder-followup append t)
340 (2 mh-folder-subject-face append t)) 350 (2 'mh-folder-subject append t))
341 ;;current msg 351 ;; Current message number
342 (list mh-scan-cur-msg-number-regexp 352 (list mh-scan-cur-msg-number-regexp
343 '(1 mh-folder-cur-msg-number-face)) 353 '(1 'mh-folder-cur-msg-number))
354 ;; Message number
344 (list mh-scan-good-msg-regexp 355 (list mh-scan-good-msg-regexp
345 '(1 mh-folder-msg-number-face)) ;; Msg number 356 '(1 'mh-folder-msg-number))
346 (list mh-scan-date-regexp '(1 mh-folder-date-face)) ;; Date 357 ;; Date
358 (list mh-scan-date-regexp
359 '(1 'mh-folder-date))
360 ;; Messages from me (To:)
347 (list mh-scan-rcpt-regexp 361 (list mh-scan-rcpt-regexp
348 '(1 mh-folder-to-face) ;; To: 362 '(1 'mh-folder-to)
349 '(2 mh-folder-address-face)) ;; address 363 '(2 'mh-folder-address))
350 ;; scan font-lock name 364 ;; Messages to me
351 (list mh-scan-format-regexp 365 (list mh-scan-sent-to-me-sender-regexp
352 '(1 mh-folder-date-face) 366 '(1 'mh-folder-sent-to-me-hint)
353 '(3 mh-folder-scan-format-face))) 367 '(2 'mh-folder-sent-to-me-sender)))
354 "Keywords (regular expressions) used to fontify the MH-Folder buffer.") 368 "Keywords (regular expressions) used to fontify the MH-Folder buffer.")
355 369
356(defvar mh-scan-cmd-note-width 1 370(defvar mh-scan-cmd-note-width 1
diff --git a/lisp/mh-e/mh-init.el b/lisp/mh-e/mh-init.el
index 6b8feda8ccc..2818674afae 100644
--- a/lisp/mh-e/mh-init.el
+++ b/lisp/mh-e/mh-init.el
@@ -1,6 +1,6 @@
1;;; mh-init.el --- MH-E initialization 1;;; mh-init.el --- MH-E initialization
2 2
3;; Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. 3;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
4 4
5;; Author: Peter S. Galbraith <psg@debian.org> 5;; Author: Peter S. Galbraith <psg@debian.org>
6;; Maintainer: Bill Wohler <wohler@newt.com> 6;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -334,7 +334,7 @@ there. Otherwise, the images directory is added to the
334 334
335(defun mh-defface-compat (spec) 335(defun mh-defface-compat (spec)
336 "Convert SPEC for defface if necessary to run on older platforms. 336 "Convert SPEC for defface if necessary to run on older platforms.
337See `defface' for the spec definition. 337Modifies SPEC in place and returns it. See `defface' for the spec definition.
338 338
339When `mh-min-colors-defined-flag' is nil, this function finds a 339When `mh-min-colors-defined-flag' is nil, this function finds a
340display with a single \"class\" requirement with a \"color\" 340display with a single \"class\" requirement with a \"color\"
@@ -351,7 +351,8 @@ requirements."
351 (loop for entry in spec do 351 (loop for entry in spec do
352 (when (not (eq (car entry) t)) 352 (when (not (eq (car entry) t))
353 (if (assoc 'min-colors (car entry)) 353 (if (assoc 'min-colors (car entry))
354 (delq (assoc 'min-colors (car entry)) (car entry))))))) 354 (delq (assoc 'min-colors (car entry)) (car entry))))))
355 spec)
355 356
356(provide 'mh-init) 357(provide 'mh-init)
357 358
diff --git a/lisp/mh-e/mh-mime.el b/lisp/mh-e/mh-mime.el
index 4338a94381b..c028890f6a1 100644
--- a/lisp/mh-e/mh-mime.el
+++ b/lisp/mh-e/mh-mime.el
@@ -1407,14 +1407,15 @@ Parameter EL is unused."
1407(defun mh-mime-security-button-face (info) 1407(defun mh-mime-security-button-face (info)
1408 "Return the button face to use for encrypted/signed mail based on INFO." 1408 "Return the button face to use for encrypted/signed mail based on INFO."
1409 (cond ((string-match "OK" info) ;Decrypted mail 1409 (cond ((string-match "OK" info) ;Decrypted mail
1410 mh-show-pgg-good-face) 1410 'mh-show-pgg-good)
1411 ((string-match "Failed" info) ;Decryption failed or signature invalid 1411 ((string-match "Failed" info) ;Decryption failed or signature invalid
1412 mh-show-pgg-bad-face) 1412 'mh-show-pgg-bad)
1413 ((string-match "Undecided" info);Unprocessed mail 1413 ((string-match "Undecided" info);Unprocessed mail
1414 mh-show-pgg-unknown-face) 1414 'mh-show-pgg-unknown)
1415 ((string-match "Untrusted" info);Key not trusted 1415 ((string-match "Untrusted" info);Key not trusted
1416 mh-show-pgg-unknown-face) 1416 'mh-show-pgg-unknown)
1417 (t mh-show-pgg-good-face))) 1417 (t
1418 'mh-show-pgg-good)))
1418 1419
1419(defun mh-mime-security-press-button (handle) 1420(defun mh-mime-security-press-button (handle)
1420 "Callback from security button for part HANDLE." 1421 "Callback from security button for part HANDLE."
diff --git a/lisp/mh-e/mh-utils.el b/lisp/mh-e/mh-utils.el
index b5d97a2be05..e008c93916e 100644
--- a/lisp/mh-e/mh-utils.el
+++ b/lisp/mh-e/mh-utils.el
@@ -402,18 +402,30 @@ Argument LIMIT limits search."
402(eval-and-compile 402(eval-and-compile
403 ;; Otherwise byte-compilation fails on `mh-show-font-lock-keywords-with-cite' 403 ;; Otherwise byte-compilation fails on `mh-show-font-lock-keywords-with-cite'
404 (defvar mh-show-font-lock-keywords 404 (defvar mh-show-font-lock-keywords
405 '(("^\\(From:\\|Sender:\\)\\(.*\\)" (1 'default) (2 mh-show-from-face)) 405 '(("^\\(From:\\|Sender:\\)\\(.*\\)"
406 (mh-header-to-font-lock (0 'default) (1 mh-show-to-face)) 406 (1 'default)
407 (mh-header-cc-font-lock (0 'default) (1 mh-show-cc-face)) 407 (2 'mh-show-from))
408 (mh-header-to-font-lock
409 (0 'default)
410 (1 'mh-show-to))
411 (mh-header-cc-font-lock
412 (0 'default)
413 (1 'mh-show-cc))
408 ("^\\(Reply-To:\\|Return-Path:\\)\\(.*\\)$" 414 ("^\\(Reply-To:\\|Return-Path:\\)\\(.*\\)$"
409 (1 'default) (2 mh-show-from-face)) 415 (1 'default)
410 (mh-header-subject-font-lock (0 'default) (1 mh-show-subject-face)) 416 (2 'mh-show-from))
417 (mh-header-subject-font-lock
418 (0 'default)
419 (1 'mh-show-subject))
411 ("^\\(Apparently-To:\\|Newsgroups:\\)\\(.*\\)" 420 ("^\\(Apparently-To:\\|Newsgroups:\\)\\(.*\\)"
412 (1 'default) (2 mh-show-cc-face)) 421 (1 'default)
422 (2 'mh-show-cc))
413 ("^\\(In-reply-to\\|Date\\):\\(.*\\)$" 423 ("^\\(In-reply-to\\|Date\\):\\(.*\\)$"
414 (1 'default) (2 mh-show-date-face)) 424 (1 'default)
415 (mh-letter-header-font-lock (0 mh-show-header-face append t))) 425 (2 'mh-show-date))
416 "Additional expressions to highlight in MH-show mode.")) 426 (mh-letter-header-font-lock
427 (0 'mh-show-header append t)))
428 "Additional expressions to highlight in MH-Show buffers."))
417 429
418(defvar mh-show-font-lock-keywords-with-cite 430(defvar mh-show-font-lock-keywords-with-cite
419 (eval-when-compile 431 (eval-when-compile
@@ -432,11 +444,13 @@ Argument LIMIT limits search."
432 (beginning-of-line) (end-of-line) 444 (beginning-of-line) (end-of-line)
433 (2 font-lock-constant-face nil t) 445 (2 font-lock-constant-face nil t)
434 (4 font-lock-comment-face nil t))))))) 446 (4 font-lock-comment-face nil t)))))))
435 "Additional expressions to highlight in MH-show mode.") 447 "Additional expressions to highlight in MH-Show buffers.")
436 448
437(defvar mh-letter-font-lock-keywords 449(defvar mh-letter-font-lock-keywords
438 `(,@mh-show-font-lock-keywords-with-cite 450 `(,@mh-show-font-lock-keywords-with-cite
439 (mh-font-lock-field-data (1 'mh-letter-header-field prepend t)))) 451 (mh-font-lock-field-data
452 (1 'mh-letter-header-field prepend t)))
453 "Additional expressions to highlight in MH-Letter buffers.")
440 454
441(defun mh-show-font-lock-fontify-region (beg end loudly) 455(defun mh-show-font-lock-fontify-region (beg end loudly)
442 "Limit font-lock in `mh-show-mode' to the header. 456 "Limit font-lock in `mh-show-mode' to the header.
@@ -1229,6 +1243,32 @@ See also `mh-folder-mode'.
1229 1243
1230(mh-do-in-xemacs (defvar default-enable-multibyte-characters)) 1244(mh-do-in-xemacs (defvar default-enable-multibyte-characters))
1231 1245
1246(defmacro mh-face-foreground-compat (face &optional frame inherit)
1247 "Return the foreground color name of FACE, or nil if unspecified.
1248See documentation for `face-foreground' for a description of the
1249arguments FACE, FRAME, and INHERIT.
1250
1251Calls `face-foreground' correctly in older environments. Versions
1252of Emacs prior to version 22 lacked an INHERIT argument which
1253when t tells `face-foreground' to consider an inherited value for
1254the foreground if the face does not define one itself."
1255 (if (>= emacs-major-version 22)
1256 `(face-foreground ,face ,frame ,inherit)
1257 `(face-foreground ,face ,frame)))
1258
1259(defmacro mh-face-background-compat (face &optional frame inherit)
1260 "Return the background color name of face, or nil if unspecified.
1261See documentation for `back-foreground' for a description of the
1262arguments FACE, FRAME, and INHERIT.
1263
1264Calls `face-background' correctly in older environments. Versions
1265of Emacs prior to version 22 lacked an INHERIT argument which
1266when t tells `face-background' to consider an inherited value for
1267the background if the face does not define one itself."
1268 (if (>= emacs-major-version 22)
1269 `(face-background ,face ,frame ,inherit)
1270 `(face-background ,face ,frame)))
1271
1232(defun mh-face-display-function () 1272(defun mh-face-display-function ()
1233 "Display a Face, X-Face, or X-Image-URL header field. 1273 "Display a Face, X-Face, or X-Image-URL header field.
1234If more than one of these are present, then the first one found 1274If more than one of these are present, then the first one found
@@ -1259,9 +1299,11 @@ in this order is used."
1259 (mh-funcall-if-exists 1299 (mh-funcall-if-exists
1260 insert-image (create-image 1300 insert-image (create-image
1261 raw type t 1301 raw type t
1262 :foreground (face-foreground 'mh-show-xface) 1302 :foreground
1263 :background (face-background 'mh-show-xface)) 1303 (mh-face-foreground-compat 'mh-show-xface nil t)
1264 " "))) 1304 :background
1305 (mh-face-background-compat 'mh-show-xface nil t))
1306 " ")))
1265 ;; XEmacs 1307 ;; XEmacs
1266 (mh-do-in-xemacs 1308 (mh-do-in-xemacs
1267 (cond 1309 (cond
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 186fa438b35..ef655ba836f 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -355,14 +355,21 @@ This command must be bound to a mouse click."
355(defun mouse-drag-window-above (window) 355(defun mouse-drag-window-above (window)
356 "Return the (or a) window directly above WINDOW. 356 "Return the (or a) window directly above WINDOW.
357That means one whose bottom edge is at the same height as WINDOW's top edge." 357That means one whose bottom edge is at the same height as WINDOW's top edge."
358 (let ((top (nth 1 (window-edges window))) 358 (let ((start-top (nth 1 (window-edges window)))
359 (start-left (nth 0 (window-edges window)))
360 (start-right (nth 2 (window-edges window)))
359 (start-window window) 361 (start-window window)
360 above-window) 362 above-window)
361 (setq window (previous-window window 0)) 363 (setq window (previous-window window 0))
362 (while (and (not above-window) (not (eq window start-window))) 364 (while (and (not above-window) (not (eq window start-window)))
363 (if (= (+ (window-height window) (nth 1 (window-edges window))) 365 (let ((left (nth 0 (window-edges window)))
364 top) 366 (right (nth 2 (window-edges window))))
365 (setq above-window window)) 367 (when (and (= (+ (window-height window) (nth 1 (window-edges window)))
368 start-top)
369 (or (and (<= left start-left) (<= start-right right))
370 (and (<= start-left left) (<= left start-right))
371 (and (<= start-left right) (<= right start-right))))
372 (setq above-window window)))
366 (setq window (previous-window window))) 373 (setq window (previous-window window)))
367 above-window)) 374 above-window))
368 375
@@ -1025,7 +1032,11 @@ at the same position."
1025 (select-window original-window) 1032 (select-window original-window)
1026 (if (or (vectorp on-link) (stringp on-link)) 1033 (if (or (vectorp on-link) (stringp on-link))
1027 (setq event (aref on-link 0)) 1034 (setq event (aref on-link 0))
1028 (setcar event 'mouse-2))) 1035 (setcar event 'mouse-2)
1036 ;; If this mouse click has never been done by
1037 ;; the user, it doesn't have the necessary
1038 ;; property to be interpreted correctly.
1039 (put 'mouse-2 'event-kind 'mouse-click)))
1029 (push event unread-command-events)))) 1040 (push event unread-command-events))))
1030 1041
1031 ;; Case where the end-event is not a cons cell (it's just a boring 1042 ;; Case where the end-event is not a cons cell (it's just a boring
diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index 9925227619f..e1ae498923b 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -129,7 +129,7 @@ A value of t means there is no limit--fontify regardless of the size."
129 'goto-address-at-point) 129 'goto-address-at-point)
130 (define-key m (kbd "C-c RET") 'goto-address-at-point) 130 (define-key m (kbd "C-c RET") 'goto-address-at-point)
131 m) 131 m)
132 "keymap to hold goto-addr's mouse key defs under highlighted URLs.") 132 "Keymap to hold goto-addr's mouse key defs under highlighted URLs.")
133 133
134(defcustom goto-address-url-face 'bold 134(defcustom goto-address-url-face 'bold
135 "Face to use for URLs." 135 "Face to use for URLs."
@@ -242,7 +242,8 @@ address. If no e-mail address found, return nil."
242 "Sets up goto-address functionality in the current buffer. 242 "Sets up goto-address functionality in the current buffer.
243Allows user to use mouse/keyboard command to click to go to a URL 243Allows user to use mouse/keyboard command to click to go to a URL
244or to send e-mail. 244or to send e-mail.
245By default, goto-address binds to mouse-2 and C-c RET. 245By default, goto-address binds `goto-address-at-point' to mouse-2 and C-c RET
246only on URLs and e-mail addresses.
246 247
247Also fontifies the buffer appropriately (see `goto-address-fontify-p' and 248Also fontifies the buffer appropriately (see `goto-address-fontify-p' and
248`goto-address-highlight-p' for more information)." 249`goto-address-highlight-p' for more information)."
diff --git a/lisp/net/webjump.el b/lisp/net/webjump.el
index fc7b23ae1ba..4a3baea4f41 100644
--- a/lisp/net/webjump.el
+++ b/lisp/net/webjump.el
@@ -72,104 +72,184 @@
72 72
73(defvar webjump-sample-sites 73(defvar webjump-sample-sites
74 '( 74 '(
75
76 ;; FSF, not including Emacs-specific. 75 ;; FSF, not including Emacs-specific.
77 ("GNU Project FTP Archive" . 76 ("GNU Project FTP Archive" .
77 ;; GNU FTP Mirror List from http://www.gnu.org/order/ftp.html
78 [mirrors "ftp://ftp.gnu.org/pub/gnu/" 78 [mirrors "ftp://ftp.gnu.org/pub/gnu/"
79 ;; ASIA: 79 ;; United States
80 "ftp://ftp.cs.titech.ac.jp" 80 "ftp://mirrors.kernel.org/gnu"
81 "ftp://tron.um.u-tokyo.ac.jp/pub/GNU/prep" 81 "ftp://gatekeeper.dec.com/pub/GNU/"
82 "ftp://cair-archive.kaist.ac.kr/pub/gnu" 82 "ftp://ftp.keystealth.org/pub/gnu/"
83 "ftp://ftp.nectec.or.th/pub/mirrors/gnu" 83 "ftp://mirrors.usc.edu/pub/gnu/"
84 ;; AUSTRALIA: 84 "ftp://cudlug.cudenver.edu/pub/mirrors/ftp.gnu.org/"
85 "ftp://archie.au/gnu" 85 "ftp://ftp.cise.ufl.edu/pub/mirrors/GNU/"
86 "ftp://archie.oz/gnu" 86 "ftp://uiarchive.cso.uiuc.edu/pub/ftp/ftp.gnu.org/gnu/"
87 "ftp://archie.oz.au/gnu" 87 "ftp://gnu.cs.lewisu.edu/gnu/"
88 ;; AFRICA: 88 "ftp://ftp.in-span.net/pub/mirrors/ftp.gnu.org/"
89 "ftp://ftp.sun.ac.za/pub/gnu" 89 "ftp://gnu.ms.uky.edu/pub/mirrors/gnu/"
90 ;; MIDDLE-EAST: 90 "ftp://ftp.algx.net/pub/gnu/"
91 "ftp://ftp.technion.ac.il/pub/unsupported/gnu" 91 "ftp://aeneas.mit.edu/pub/gnu/"
92 ;; EUROPE: 92 "ftp://ftp.egr.msu.edu/pub/gnu/"
93 "ftp://irisa.irisa.fr/pub/gnu" 93 "ftp://ftp.wayne.edu/pub/gnu/"
94 "ftp://ftp.univ-lyon1.fr/pub/gnu" 94 "ftp://wuarchive.wustl.edu/mirrors/gnu/"
95 "ftp://ftp.mcc.ac.uk" 95 "ftp://gnu.teleglobe.net/ftp.gnu.org/"
96 "ftp://unix.hensa.ac.uk/mirrors/uunet/systems/gnu" 96 "ftp://ftp.cs.columbia.edu/archives/gnu/prep/"
97 "ftp://src.doc.ic.ac.uk/gnu" 97 "ftp://ftp.ece.cornell.edu/pub/mirrors/gnu/"
98 "ftp://ftp.ieunet.ie/pub/gnu" 98 "ftp://ftp.ibiblio.org/pub/mirrors/gnu/"
99 "ftp://ftp.eunet.ch" 99 "ftp://ftp.cis.ohio-state.edu/mirror/gnu/"
100 "ftp://nic.switch.ch/mirror/gnu" 100 "ftp://ftp.club.cc.cmu.edu/gnu/"
101 "ftp://ftp.informatik.rwth-aachen.de/pub/gnu" 101 "ftp://ftp.sunsite.utk.edu/pub/gnu/ftp/"
102 "ftp://ftp.informatik.tu-muenchen.de" 102 "ftp://thales.memphis.edu/pub/gnu/"
103 "ftp://gnu.wwc.edu"
104 "ftp://ftp.twtelecom.net/pub/GNU/"
105 ;; Africa
106 "ftp://ftp.sun.ac.za/mirrorsites/ftp.gnu.org"
107 ;; The Americas
108 "ftp://ftp.unicamp.br/pub/gnu/"
109 "ftp://master.softaplic.com.br/pub/gnu/"
110 "ftp://ftp.matrix.com.br/pub/gnu/"
111 "ftp://ftp.pucpr.br/gnu"
112 "ftp://ftp.linorg.usp.br/gnu"
113 "ftp://ftp.cs.ubc.ca/mirror2/gnu/"
114 "ftp://cs.ubishops.ca/pub/ftp.gnu.org/"
115 "ftp://ftp.inf.utfsm.cl/pub/gnu/"
116 "ftp://sunsite.ulatina.ac.cr/Mirrors/GNU/"
117 "ftp://www.gnu.unam.mx/pub/gnu/software/"
118 "ftp://gnu.cem.itesm.mx/pub/mirrors/gnu.org/"
119 "ftp://ftp.azc.uam.mx/mirrors/gnu/"
120 ;; Australia
121 "ftp://mirror.aarnet.edu.au/pub/gnu/"
122 "ftp://gnu.mirror.pacific.net.au/gnu/"
123 ;; Asia
124 "ftp://ftp.cs.cuhk.edu.hk/pub/gnu/gnu/"
125 "ftp://sunsite.ust.hk/pub/gnu/"
126 "ftp://ftp.gnupilgrims.org/pub/gnu"
127 "ftp://www.imtech.res.in/mirror/gnuftp/"
128 "ftp://kambing.vlsm.org/gnu"
129 "ftp://ftp.cs.huji.ac.il/mirror/GNU/"
130 "ftp://tron.um.u-tokyo.ac.jp/pub/GNU/"
131 "ftp://core.ring.gr.jp/pub/GNU/"
132 "ftp://ftp.ring.gr.jp/pub/GNU/"
133 "ftp://mirrors.hbi.co.jp/gnu/"
134 "ftp://ftp.cs.titech.ac.jp/pub/gnu/"
135 "ftp://ftpmirror.hanyang.ac.kr/GNU/"
136 "ftp://ftp.linux.sarang.net/mirror/gnu/gnu/"
137 "ftp://ftp.xgate.co.kr/pub/mirror/gnu/"
138 "ftp://ftp://gnu.xinicks.com/"
139 "ftp://ftp.isu.net.sa/pub/gnu/"
140 "ftp://ftp.nctu.edu.tw/UNIX/gnu/"
141 "ftp://coda.nctu.edu.tw/UNIX/gnu/"
142 "ftp://ftp1.sinica.edu.tw/pub3/GNU/gnu/"
143 "ftp://gnu.cdpa.nsysu.edu.tw/gnu"
144 "ftp://ftp.nectec.or.th/pub/mirrors/gnu/"
145 ;; Europe
146 "ftp://ftp.gnu.vbs.at/"
147 "ftp://ftp.univie.ac.at/packages/gnu/"
148 "ftp://gd.tuwien.ac.at/gnu/gnusrc/"
149 "ftp://ftp.belnet.be/mirror/ftp.gnu.org/"
150 "ftp://gnu.blic.net/pub/gnu/"
151 "ftp://ftp.fi.muni.cz/pub/gnu/"
152 "ftp://ftp.dkuug.dk/pub/gnu/"
153 "ftp://sunsite.dk/mirrors/gnu"
154 "ftp://ftp.funet.fi/pub/gnu/prep/"
155 "ftp://ftp.irisa.fr/pub/gnu/"
156 "ftp://ftp.cs.univ-paris8.fr/mirrors/ftp.gnu.org/"
157 "ftp://ftp.cs.tu-berlin.de/pub/gnu/"
158 "ftp://ftp.leo.org/pub/comp/os/unix/gnu/"
159 "ftp://ftp.informatik.rwth-aachen.de/pub/gnu/"
160 "ftp://ftp.de.uu.net/pub/gnu/"
161 "ftp://ftp.freenet.de/pub/ftp.gnu.org/gnu/"
162 "ftp://ftp.cs.uni-bonn.de/pub/gnu/"
163 "ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/ftp.gnu.org/"
164 "ftp://ftp.stw-bonn.de/pub/mirror/ftp.gnu.org/"
165 "ftp://ftp.math.uni-bremen.de/pub/gnu"
166 "ftp://ftp.forthnet.gr/pub/gnu/"
167 "ftp://ftp.ntua.gr/pub/gnu/"
168 "ftp://ftp.duth.gr/pub/gnu/"
169 "ftp://ftp.physics.auth.gr/pub/gnu/"
170 "ftp://ftp.esat.net/pub/gnu/"
171 "ftp://ftp.heanet.ie/mirrors/ftp.gnu.org"
172 "ftp://ftp.lugroma2.org/pub/gnu/"
173 "ftp://ftp.gnu.inetcosmos.org/pub/gnu/"
174 "ftp://ftp.digitaltrust.it/pub/gnu"
175 "ftp://ftp://rm.mirror.garr.it/mirrors/gnuftp"
176 "ftp://ftp.nluug.nl/pub/gnu/"
177 "ftp://ftp.mirror.nl/pub/mirror/gnu/"
178 "ftp://ftp.nl.uu.net/pub/gnu/"
179 "ftp://mirror.widexs.nl/pub/gnu/"
180 "ftp://ftp.easynet.nl/mirror/GNU/"
103 "ftp://ftp.win.tue.nl/pub/gnu" 181 "ftp://ftp.win.tue.nl/pub/gnu"
104 "ftp://ftp.nl.net" 182 "ftp://gnu.mirror.vuurwerk.net/pub/GNU/"
105 "ftp://ftp.etsimo.uniovi.es/pub/gnu" 183 "ftp://gnu.kookel.org/pub/ftp.gnu.org/"
106 "ftp://ftp.funet.fi/pub/gnu" 184 "ftp://ftp.uninett.no/pub/gnu/"
107 "ftp://ftp.denet.dk" 185 "ftp://ftp.task.gda.pl/pub/gnu/"
108 "ftp://ftp.stacken.kth.se" 186 "ftp://sunsite.icm.edu.pl/pub/gnu/"
109 "ftp://isy.liu.se" 187 "ftp://ftp.man.poznan.pl/pub/gnu"
110 "ftp://ftp.luth.se/pub/unix/gnu" 188 "ftp://ftp.ist.utl.pt/pub/GNU/gnu/"
111 "ftp://ftp.sunet.se/pub/gnu" 189 "ftp://ftp.telepac.pt/pub/gnu/"
112 "ftp://archive.eu.net" 190 "ftp://ftp.timisoara.roedu.net/mirrors/ftp.gnu.org/pub/gnu"
113 ;; SOUTH AMERICA: 191 "ftp://ftp.chg.ru/pub/gnu/"
114 "ftp://ftp.inf.utfsm.cl/pub/gnu" 192 "ftp://gnuftp.axitel.ru/"
115 "ftp://ftp.unicamp.br/pub/gnu" 193 "ftp://ftp.arnes.si/software/gnu/"
116 ;; WESTERN CANADA: 194 "ftp://ftp.etsimo.uniovi.es/pub/gnu/"
117 "ftp://ftp.cs.ubc.ca/mirror2/gnu" 195 "ftp://ftp.rediris.es/pub/gnu/"
118 ;; USA: 196 "ftp://ftp.chl.chalmers.se/pub/gnu/"
119 "ftp://wuarchive.wustl.edu/systems/gnu" 197 "ftp://ftp.isy.liu.se/pub/gnu/"
120 "ftp://labrea.stanford.edu" 198 "ftp://ftp.luth.se/pub/unix/gnu/"
121 "ftp://ftp.digex.net/pub/gnu" 199 "ftp://ftp.stacken.kth.se/pub/gnu/"
122 "ftp://ftp.kpc.com/pub/mirror/gnu" 200 "ftp://ftp.sunet.se/pub/gnu/"
123 "ftp://f.ms.uky.edu/pub3/gnu" 201 "ftp://sunsite.cnlab-switch.ch/mirror/gnu/"
124 "ftp://jaguar.utah.edu/gnustuff" 202 "ftp://ftp.ulak.net.tr/gnu/"
125 "ftp://ftp.hawaii.edu/mirrors/gnu" 203 "ftp://ftp.gnu.org.ua"
126 "ftp://uiarchive.cso.uiuc.edu/pub/gnu" 204 "ftp://ftp.mcc.ac.uk/pub/gnu/"
127 "ftp://ftp.cs.columbia.edu/archives/gnu/prep" 205 "ftp://ftp.mirror.ac.uk/sites/ftp.gnu.org/gnu/"
128 "ftp://gatekeeper.dec.com/pub/GNU" 206 "ftp://ftp.warwick.ac.uk/pub/gnu/"
129 "ftp://ftp.uu.net/systems/gnu"]) 207 "ftp://ftp.hands.com/ftp.gnu.org/"
208 "ftp://gnu.teleglobe.net/ftp.gnu.org/"])
130 ("GNU Project Home Page" . "www.gnu.org") 209 ("GNU Project Home Page" . "www.gnu.org")
131 210
132 ;; Emacs. 211 ;; Emacs.
133 ("Emacs Lisp Archive" . 212 ("Emacs Home Page" .
134 "ftp://ftp.emacs.org/pub/") 213 "www.gnu.org/software/emacs/emacs.html")
214 ("Savannah Emacs page" .
215 "savannah.gnu.org/projects/emacs")
216 ("Emacs Lisp List" .
217 "www.damtp.cam.ac.uk/user/eglen/emacs/ell.html")
218 ("Emacs Wiki" .
219 [simple-query "www.emacswiki.org"
220 "www.emacswiki.org/cgi-bin/wiki/" ""])
135 221
136 ;; Internet search engines. 222 ;; Internet search engines.
137 ("AltaVista" . 223 ("Google" .
138 [simple-query 224 [simple-query "www.google.com"
139 "www.altavista.digital.com" 225 "www.google.com/search?q=" ""])
140 "www.altavista.digital.com/cgi-bin/query?pg=aq&what=web&fmt=.&q=" 226 ("Google Groups" .
141 "&r=&d0=&d1="]) 227 [simple-query "groups.google.com"
142 ("Archie" . 228 "groups.google.com/groups?q=" ""])
143 [simple-query "hoohoo.ncsa.uiuc.edu/cgi-bin/AA.pl"
144 "hoohoo.ncsa.uiuc.edu/cgi-bin/AA.pl?query=" ""])
145 ("Lycos" .
146 [simple-query "www.lycos.com"
147 "www.lycos.com/cgi-bin/pursuit?cat=lycos&query=" ""])
148 ("Yahoo" . 229 ("Yahoo" .
149 [simple-query "www.yahoo.com" "search.yahoo.com/bin/search?p=" ""]) 230 [simple-query "www.yahoo.com" "search.yahoo.com/search?p=" ""])
231 ("Yahoo: Reference" . "www.yahoo.com/Reference/")
150 232
151 ;; Misc. general interest. 233 ;; Misc. general interest.
152 ("Interactive Weather Information Network" . webjump-to-iwin) 234 ("Interactive Weather Information Network" . webjump-to-iwin)
153 ("Usenet FAQs" . 235 ("Usenet FAQs" .
154 [simple-query "www.cis.ohio-state.edu/hypertext/faq/usenet/FAQ-List.html" 236 "www.faqs.org/faqs/")
155 "www.cis.ohio-state.edu/htbin/search-usenet-faqs/form?find="
156 ""])
157 ("RTFM Usenet FAQs by Group" . 237 ("RTFM Usenet FAQs by Group" .
158 "ftp://rtfm.mit.edu/pub/usenet-by-group/") 238 "ftp://rtfm.mit.edu/pub/usenet-by-group/")
159 ("RTFM Usenet FAQs by Hierachy" . 239 ("RTFM Usenet FAQs by Hierachy" .
160 "ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/") 240 "ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/")
161 ("X Consortium Archive" . "ftp.x.org") 241 ("X Consortium Archive" . "ftp.x.org")
162 ("Yahoo: Reference" . "www.yahoo.com/Reference/")
163 242
164 ;; Computer social issues, privacy, professionalism. 243 ;; Computer social issues, privacy, professionalism.
165 ("Association for Computing Machinery" . "www.acm.org") 244 ("Association for Computing Machinery" . "www.acm.org")
166 ("Computer Professionals for Social Responsibility" . "www.cpsr.org/dox/") 245 ("Computer Professionals for Social Responsibility" . "www.cpsr.org")
167 ("Electronic Frontier Foundation" . "www.eff.org") 246 ("Electronic Frontier Foundation" . "www.eff.org")
168 ("IEEE Computer Society" . "www.computer.org") 247 ("IEEE Computer Society" . "www.computer.org")
169 ("Risks Digest" . webjump-to-risks) 248 ("Risks Digest" . webjump-to-risks)
170 249
171 ;; Fun. 250 ;; More.
172 ("Bastard Operator from Hell" . "www.replay.com/bofh/") 251 ("Supplemental Web site list for webjump" .
252 "www.neilvandyke.org/webjump/")
173 253
174 ) 254 )
175 "Sample hotlist for WebJump. See the documentation for the `webjump' 255 "Sample hotlist for WebJump. See the documentation for the `webjump'
diff --git a/lisp/paren.el b/lisp/paren.el
index f5327c3b344..8b5a134d2d4 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -72,8 +72,8 @@ otherwise)."
72 :group 'paren-showing 72 :group 'paren-showing
73 :version "20.3") 73 :version "20.3")
74 74
75(defgroup paren-showing-faces () 75(defgroup paren-showing-faces nil
76 "Group for faces of Show Paren mode" 76 "Group for faces of Show Paren mode."
77 :group 'paren-showing 77 :group 'paren-showing
78 :group 'faces 78 :group 'faces
79 :version "22.1") 79 :version "22.1")
@@ -88,7 +88,7 @@ otherwise)."
88 (t 88 (t
89 :background "gray")) 89 :background "gray"))
90 "Show Paren mode face used for a matching paren." 90 "Show Paren mode face used for a matching paren."
91 :group 'show-paren-faces) 91 :group 'paren-showing-faces)
92;; backward-compatibility alias 92;; backward-compatibility alias
93(put 'show-paren-match-face 'face-alias 'show-paren-match) 93(put 'show-paren-match-face 'face-alias 'show-paren-match)
94 94
@@ -96,7 +96,7 @@ otherwise)."
96 '((((class color)) (:foreground "white" :background "purple")) 96 '((((class color)) (:foreground "white" :background "purple"))
97 (t (:inverse-video t))) 97 (t (:inverse-video t)))
98 "Show Paren mode face used for a mismatching paren." 98 "Show Paren mode face used for a mismatching paren."
99 :group 'show-paren-faces) 99 :group 'paren-showing-faces)
100;; backward-compatibility alias 100;; backward-compatibility alias
101(put 'show-paren-mismatch-face 'face-alias 'show-paren-mismatch) 101(put 'show-paren-mismatch-face 'face-alias 'show-paren-mismatch)
102 102
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index b237dd9a598..9de0a24f09e 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -72,7 +72,9 @@
72(eval-after-load "font-lock" 72(eval-after-load "font-lock"
73 '(if (and (not (featurep 'cc-fix)) ; only load the file once. 73 '(if (and (not (featurep 'cc-fix)) ; only load the file once.
74 (let (font-lock-keywords) 74 (let (font-lock-keywords)
75 (font-lock-compile-keywords '("\\<\\>")) 75 (condition-case nil
76 (font-lock-compile-keywords '("\\<\\>"))
77 (error nil))
76 font-lock-keywords)) ; did the previous call foul this up? 78 font-lock-keywords)) ; did the previous call foul this up?
77 (load "cc-fix"))) 79 (load "cc-fix")))
78 80
@@ -83,7 +85,9 @@
83 (progn 85 (progn
84 (require 'font-lock) 86 (require 'font-lock)
85 (let (font-lock-keywords) 87 (let (font-lock-keywords)
86 (font-lock-compile-keywords '("\\<\\>")) 88 (condition-case nil
89 (font-lock-compile-keywords '("\\<\\>"))
90 (error nil))
87 font-lock-keywords))) 91 font-lock-keywords)))
88 (cc-load "cc-fix"))) 92 (cc-load "cc-fix")))
89 93
diff --git a/lisp/progmodes/delphi.el b/lisp/progmodes/delphi.el
index cdc557c7274..4c271113b72 100644
--- a/lisp/progmodes/delphi.el
+++ b/lisp/progmodes/delphi.el
@@ -177,7 +177,7 @@ differs from the default."
177 177
178(defcustom delphi-other-face nil 178(defcustom delphi-other-face nil
179 "*Face used to color everything else." 179 "*Face used to color everything else."
180 :type '(choice face (const nil)) 180 :type '(choice (const :tag "None" nil) face)
181 :group 'delphi) 181 :group 'delphi)
182 182
183(defconst delphi-directives 183(defconst delphi-directives
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 9ceee6f6920..6f5d0855e19 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -516,15 +516,11 @@ instead of reading master file from disk."
516 516
517(defun flymake-copy-buffer-to-temp-buffer (buffer) 517(defun flymake-copy-buffer-to-temp-buffer (buffer)
518 "Copy contents of BUFFER into newly created temp buffer." 518 "Copy contents of BUFFER into newly created temp buffer."
519 (let ((contents nil) 519 (with-current-buffer
520 (temp-buffer nil)) 520 (get-buffer-create (generate-new-buffer-name
521 (with-current-buffer buffer 521 (concat "flymake:" (buffer-name buffer))))
522 (setq contents (buffer-string)) 522 (insert-buffer-substring buffer)
523 523 (current-buffer)))
524 (setq temp-buffer (get-buffer-create (generate-new-buffer-name (concat "flymake:" (buffer-name buffer)))))
525 (set-buffer temp-buffer)
526 (insert contents))
527 temp-buffer))
528 524
529(defun flymake-check-include (source-file-name inc-path inc-name include-dirs) 525(defun flymake-check-include (source-file-name inc-path inc-name include-dirs)
530 "Check if SOURCE-FILE-NAME can be found in include path. 526 "Check if SOURCE-FILE-NAME can be found in include path.
@@ -613,7 +609,8 @@ It's flymake process filter."
613 609
614 (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid) 610 (flymake-log 3 "received %d byte(s) of output from process %d" (length output) pid)
615 (when source-buffer 611 (when source-buffer
616 (flymake-parse-output-and-residual source-buffer output)))) 612 (with-current-buffer source-buffer
613 (flymake-parse-output-and-residual output)))))
617 614
618(defun flymake-process-sentinel (process event) 615(defun flymake-process-sentinel (process event)
619 "Sentinel for syntax check buffers." 616 "Sentinel for syntax check buffers."
@@ -636,8 +633,8 @@ It's flymake process filter."
636 (when source-buffer 633 (when source-buffer
637 (with-current-buffer source-buffer 634 (with-current-buffer source-buffer
638 635
639 (flymake-parse-residual source-buffer) 636 (flymake-parse-residual)
640 (flymake-post-syntax-check source-buffer exit-status command) 637 (flymake-post-syntax-check exit-status command)
641 (setq flymake-is-running nil)))) 638 (setq flymake-is-running nil))))
642 (error 639 (error
643 (let ((err-str (format "Error in process sentinel for buffer %s: %s" 640 (let ((err-str (format "Error in process sentinel for buffer %s: %s"
@@ -646,60 +643,51 @@ It's flymake process filter."
646 (with-current-buffer source-buffer 643 (with-current-buffer source-buffer
647 (setq flymake-is-running nil)))))))) 644 (setq flymake-is-running nil))))))))
648 645
649(defun flymake-post-syntax-check (source-buffer exit-status command) 646(defun flymake-post-syntax-check (exit-status command)
650 (with-current-buffer source-buffer 647 (setq flymake-err-info flymake-new-err-info)
651 (setq flymake-err-info flymake-new-err-info) 648 (setq flymake-new-err-info nil)
652 (setq flymake-new-err-info nil) 649 (setq flymake-err-info
653 (setq flymake-err-info 650 (flymake-fix-line-numbers
654 (flymake-fix-line-numbers 651 flymake-err-info 1 (flymake-count-lines)))
655 flymake-err-info 1 (flymake-count-lines source-buffer)))) 652 (flymake-delete-own-overlays)
656 (flymake-delete-own-overlays source-buffer) 653 (flymake-highlight-err-lines flymake-err-info)
657 (flymake-highlight-err-lines
658 source-buffer (with-current-buffer source-buffer flymake-err-info))
659 (let (err-count warn-count) 654 (let (err-count warn-count)
660 (with-current-buffer source-buffer 655 (setq err-count (flymake-get-err-count flymake-err-info "e"))
661 (setq err-count (flymake-get-err-count flymake-err-info "e")) 656 (setq warn-count (flymake-get-err-count flymake-err-info "w"))
662 (setq warn-count (flymake-get-err-count flymake-err-info "w")) 657 (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)"
663 (flymake-log 2 "%s: %d error(s), %d warning(s) in %.2f second(s)" 658 (buffer-name) err-count warn-count
664 (buffer-name source-buffer) err-count warn-count
665 (- (flymake-float-time) flymake-check-start-time)) 659 (- (flymake-float-time) flymake-check-start-time))
666 (setq flymake-check-start-time nil)) 660 (setq flymake-check-start-time nil)
667 661
668 (if (and (equal 0 err-count) (equal 0 warn-count)) 662 (if (and (equal 0 err-count) (equal 0 warn-count))
669 (if (equal 0 exit-status) 663 (if (equal 0 exit-status)
670 (flymake-report-status source-buffer "" "") ; PASSED 664 (flymake-report-status "" "") ; PASSED
671 (if (not (with-current-buffer source-buffer 665 (if (not flymake-check-was-interrupted)
672 flymake-check-was-interrupted)) 666 (flymake-report-fatal-status "CFGERR"
673 (flymake-report-fatal-status (current-buffer) "CFGERR"
674 (format "Configuration error has occured while running %s" command)) 667 (format "Configuration error has occured while running %s" command))
675 (flymake-report-status source-buffer nil ""))) ; "STOPPED" 668 (flymake-report-status nil ""))) ; "STOPPED"
676 (flymake-report-status source-buffer (format "%d/%d" err-count warn-count) "")))) 669 (flymake-report-status (format "%d/%d" err-count warn-count) ""))))
677 670
678(defun flymake-parse-output-and-residual (source-buffer output) 671(defun flymake-parse-output-and-residual (output)
679 "Split OUTPUT into lines, merge in residual if necessary." 672 "Split OUTPUT into lines, merge in residual if necessary."
680 (with-current-buffer source-buffer 673 (let* ((buffer-residual flymake-output-residual)
681 (let* ((buffer-residual flymake-output-residual) 674 (total-output (if buffer-residual (concat buffer-residual output) output))
682 (total-output (if buffer-residual (concat buffer-residual output) output)) 675 (lines-and-residual (flymake-split-output total-output))
683 (lines-and-residual (flymake-split-output total-output)) 676 (lines (nth 0 lines-and-residual))
684 (lines (nth 0 lines-and-residual)) 677 (new-residual (nth 1 lines-and-residual)))
685 (new-residual (nth 1 lines-and-residual))) 678 (setq flymake-output-residual new-residual)
686 (with-current-buffer source-buffer 679 (setq flymake-new-err-info
687 (setq flymake-output-residual new-residual) 680 (flymake-parse-err-lines
688 (setq flymake-new-err-info 681 flymake-new-err-info lines))))
689 (flymake-parse-err-lines 682
690 flymake-new-err-info 683(defun flymake-parse-residual ()
691 source-buffer lines))))))
692
693(defun flymake-parse-residual (source-buffer)
694 "Parse residual if it's non empty." 684 "Parse residual if it's non empty."
695 (with-current-buffer source-buffer 685 (when flymake-output-residual
696 (when flymake-output-residual 686 (setq flymake-new-err-info
697 (setq flymake-new-err-info 687 (flymake-parse-err-lines
698 (flymake-parse-err-lines 688 flymake-new-err-info
699 flymake-new-err-info 689 (list flymake-output-residual)))
700 source-buffer 690 (setq flymake-output-residual nil)))
701 (list flymake-output-residual)))
702 (setq flymake-output-residual nil))))
703 691
704(defvar flymake-err-info nil 692(defvar flymake-err-info nil
705 "Sorted list of line numbers and lists of err info in the form (file, err-text).") 693 "Sorted list of line numbers and lists of err info in the form (file, err-text).")
@@ -803,16 +791,11 @@ line number outside the file being compiled."
803 (setq count (1- count)))) 791 (setq count (1- count))))
804 err-info-list) 792 err-info-list)
805 793
806(defun flymake-highlight-err-lines (buffer err-info-list) 794(defun flymake-highlight-err-lines (err-info-list)
807 "Highlight error lines in BUFFER using info from ERR-INFO-LIST." 795 "Highlight error lines in BUFFER using info from ERR-INFO-LIST."
808 (with-current-buffer buffer 796 (save-excursion
809 (save-excursion 797 (dolist (err err-info-list)
810 (let* ((idx 0) 798 (flymake-highlight-line (car err) (nth 1 err)))))
811 (count (length err-info-list)))
812 (while (< idx count)
813 (flymake-highlight-line (car (nth idx err-info-list))
814 (nth 1 (nth idx err-info-list)))
815 (setq idx (1+ idx)))))))
816 799
817(defun flymake-overlay-p (ov) 800(defun flymake-overlay-p (ov)
818 "Determine whether overlay OV was created by flymake." 801 "Determine whether overlay OV was created by flymake."
@@ -831,16 +814,13 @@ line number outside the file being compiled."
831 ov) 814 ov)
832 (flymake-log 3 "created an overlay at (%d-%d)" beg end))) 815 (flymake-log 3 "created an overlay at (%d-%d)" beg end)))
833 816
834(defun flymake-delete-own-overlays (buffer) 817(defun flymake-delete-own-overlays ()
835 "Delete all flymake overlays in BUFFER." 818 "Delete all flymake overlays in BUFFER."
836 (with-current-buffer buffer 819 (dolist (ol (overlays-in (point-min) (point-max)))
837 (let ((ov (overlays-in (point-min) (point-max)))) 820 (when (flymake-overlay-p ol)
838 (while (consp ov) 821 (delete-overlay ol)
839 (when (flymake-overlay-p (car ov)) 822 ;;+(flymake-log 3 "deleted overlay %s" ol)
840 (delete-overlay (car ov)) 823 )))
841 ;;+(flymake-log 3 "deleted overlay %s" ov)
842 )
843 (setq ov (cdr ov))))))
844 824
845(defun flymake-region-has-flymake-overlays (beg end) 825(defun flymake-region-has-flymake-overlays (beg end)
846 "Check if region specified by BEG and END has overlay. 826 "Check if region specified by BEG and END has overlay.
@@ -905,19 +885,19 @@ Perhaps use text from LINE-ERR-INFO-LIST to enhance highlighting."
905 885
906 (flymake-make-overlay beg end tooltip-text face nil))) 886 (flymake-make-overlay beg end tooltip-text face nil)))
907 887
908(defun flymake-parse-err-lines (err-info-list source-buffer lines) 888(defun flymake-parse-err-lines (err-info-list lines)
909 "Parse err LINES, store info in ERR-INFO-LIST." 889 "Parse err LINES, store info in ERR-INFO-LIST."
910 (let* ((count (length lines)) 890 (let* ((count (length lines))
911 (idx 0) 891 (idx 0)
912 (line-err-info nil) 892 (line-err-info nil)
913 (real-file-name nil) 893 (real-file-name nil)
914 (source-file-name (buffer-file-name source-buffer)) 894 (source-file-name buffer-file-name)
915 (get-real-file-name-f (flymake-get-real-file-name-function source-file-name))) 895 (get-real-file-name-f (flymake-get-real-file-name-function source-file-name)))
916 896
917 (while (< idx count) 897 (while (< idx count)
918 (setq line-err-info (flymake-parse-line (nth idx lines))) 898 (setq line-err-info (flymake-parse-line (nth idx lines)))
919 (when line-err-info 899 (when line-err-info
920 (setq real-file-name (funcall get-real-file-name-f source-buffer (flymake-ler-get-file line-err-info))) 900 (setq real-file-name (funcall get-real-file-name-f (current-buffer) (flymake-ler-get-file line-err-info)))
921 (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name)) 901 (setq line-err-info (flymake-ler-set-full-file line-err-info real-file-name))
922 902
923 (if (flymake-same-files real-file-name source-file-name) 903 (if (flymake-same-files real-file-name source-file-name)
@@ -1147,9 +1127,9 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1147 (let* ((include-dirs (append '(".") (flymake-get-project-include-dirs base-dir) (flymake-get-system-include-dirs)))) 1127 (let* ((include-dirs (append '(".") (flymake-get-project-include-dirs base-dir) (flymake-get-system-include-dirs))))
1148 include-dirs)) 1128 include-dirs))
1149 1129
1150(defun flymake-restore-formatting (source-buffer) 1130;; (defun flymake-restore-formatting ()
1151 "Remove any formatting made by flymake." 1131;; "Remove any formatting made by flymake."
1152 ) 1132;; )
1153 1133
1154(defun flymake-get-program-dir (buffer) 1134(defun flymake-get-program-dir (buffer)
1155 "Get dir to start program in." 1135 "Get dir to start program in."
@@ -1176,38 +1156,36 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1176 :group 'flymake 1156 :group 'flymake
1177 :type 'boolean) 1157 :type 'boolean)
1178 1158
1179(defun flymake-start-syntax-check (buffer) 1159(defun flymake-start-syntax-check ()
1180 "Start syntax checking for buffer BUFFER." 1160 "Start syntax checking for current buffer."
1181 (unless (bufferp buffer) 1161 (interactive)
1182 (error "Expected a buffer")) 1162 (flymake-log 3 "flymake is running: %s" flymake-is-running)
1183 (with-current-buffer buffer 1163 (when (and (not flymake-is-running)
1184 (flymake-log 3 "flymake is running: %s" flymake-is-running) 1164 (flymake-can-syntax-check-file buffer-file-name))
1185 (when (and (not flymake-is-running) 1165 (when (or (not flymake-compilation-prevents-syntax-check)
1186 (flymake-can-syntax-check-file (buffer-file-name buffer))) 1166 (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP")
1187 (when (or (not flymake-compilation-prevents-syntax-check) 1167 (flymake-clear-buildfile-cache)
1188 (not (flymake-compilation-is-running))) ;+ (flymake-rep-ort-status buffer "COMP") 1168 (flymake-clear-project-include-dirs-cache)
1189 (flymake-clear-buildfile-cache) 1169
1190 (flymake-clear-project-include-dirs-cache) 1170 (setq flymake-check-was-interrupted nil)
1191 1171 (setq flymake-buffer-data (flymake-makehash 'equal))
1192 (setq flymake-check-was-interrupted nil) 1172
1193 (setq flymake-buffer-data (flymake-makehash 'equal)) 1173 (let* ((source-file-name buffer-file-name)
1194 1174 (init-f (flymake-get-init-function source-file-name))
1195 (let* ((source-file-name (buffer-file-name buffer)) 1175 (cleanup-f (flymake-get-cleanup-function source-file-name))
1196 (init-f (flymake-get-init-function source-file-name)) 1176 (cmd-and-args (funcall init-f (current-buffer)))
1197 (cleanup-f (flymake-get-cleanup-function source-file-name)) 1177 (cmd (nth 0 cmd-and-args))
1198 (cmd-and-args (funcall init-f buffer)) 1178 (args (nth 1 cmd-and-args))
1199 (cmd (nth 0 cmd-and-args)) 1179 (dir (nth 2 cmd-and-args)))
1200 (args (nth 1 cmd-and-args)) 1180 (if (not cmd-and-args)
1201 (dir (nth 2 cmd-and-args))) 1181 (progn
1202 (if (not cmd-and-args) 1182 (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name)
1203 (progn 1183 (funcall cleanup-f (current-buffer)))
1204 (flymake-log 0 "init function %s for %s failed, cleaning up" init-f source-file-name) 1184 (progn
1205 (funcall cleanup-f buffer)) 1185 (setq flymake-last-change-time nil)
1206 (progn 1186 (flymake-start-syntax-check-process cmd args dir)))))))
1207 (setq flymake-last-change-time nil) 1187
1208 (flymake-start-syntax-check-process buffer cmd args dir)))))))) 1188(defun flymake-start-syntax-check-process (cmd args dir)
1209
1210(defun flymake-start-syntax-check-process (buffer cmd args dir)
1211 "Start syntax check process." 1189 "Start syntax check process."
1212 (let* ((process nil)) 1190 (let* ((process nil))
1213 (condition-case err 1191 (condition-case err
@@ -1219,25 +1197,24 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1219 (set-process-sentinel process 'flymake-process-sentinel) 1197 (set-process-sentinel process 'flymake-process-sentinel)
1220 (set-process-filter process 'flymake-process-filter) 1198 (set-process-filter process 'flymake-process-filter)
1221 1199
1222 (flymake-reg-names (process-id process) (buffer-name buffer)) 1200 (flymake-reg-names (process-id process) (buffer-name))
1223 1201
1224 (with-current-buffer buffer 1202 (setq flymake-is-running t)
1225 (setq flymake-is-running t) 1203 (setq flymake-last-change-time nil)
1226 (setq flymake-last-change-time nil) 1204 (setq flymake-check-start-time (flymake-float-time))
1227 (setq flymake-check-start-time (flymake-float-time)))
1228 1205
1229 (flymake-report-status buffer nil "*") 1206 (flymake-report-status nil "*")
1230 (flymake-log 2 "started process %d, command=%s, dir=%s" 1207 (flymake-log 2 "started process %d, command=%s, dir=%s"
1231 (process-id process) (process-command process) default-directory) 1208 (process-id process) (process-command process) default-directory)
1232 process) 1209 process)
1233 (error 1210 (error
1234 (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s" 1211 (let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s"
1235 cmd args (error-message-string err))) 1212 cmd args (error-message-string err)))
1236 (source-file-name (buffer-file-name buffer)) 1213 (source-file-name buffer-file-name)
1237 (cleanup-f (flymake-get-cleanup-function source-file-name))) 1214 (cleanup-f (flymake-get-cleanup-function source-file-name)))
1238 (flymake-log 0 err-str) 1215 (flymake-log 0 err-str)
1239 (funcall cleanup-f buffer) 1216 (funcall cleanup-f (current-buffer))
1240 (flymake-report-fatal-status buffer "PROCERR" err-str)))))) 1217 (flymake-report-fatal-status "PROCERR" err-str))))))
1241 1218
1242(defun flymake-kill-process (pid &optional rest) 1219(defun flymake-kill-process (pid &optional rest)
1243 "Kill process PID." 1220 "Kill process PID."
@@ -1304,12 +1281,7 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1304 1281
1305 (setq flymake-last-change-time nil) 1282 (setq flymake-last-change-time nil)
1306 (flymake-log 3 "starting syntax check as more than 1 second passed since last change") 1283 (flymake-log 3 "starting syntax check as more than 1 second passed since last change")
1307 (flymake-start-syntax-check buffer))))) 1284 (flymake-start-syntax-check)))))
1308
1309(defun flymake-start-syntax-check-for-current-buffer ()
1310 "Run `flymake-start-syntax-check' for current buffer if it isn't already running."
1311 (interactive)
1312 (flymake-start-syntax-check (current-buffer)))
1313 1285
1314(defun flymake-current-line-no () 1286(defun flymake-current-line-no ()
1315 "Return number of current line in current buffer." 1287 "Return number of current line in current buffer."
@@ -1318,10 +1290,9 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1318 (end (if (= (point) (point-max)) (point) (1+ (point))))) 1290 (end (if (= (point) (point-max)) (point) (1+ (point)))))
1319 (count-lines beg end))) 1291 (count-lines beg end)))
1320 1292
1321(defun flymake-count-lines (buffer) 1293(defun flymake-count-lines ()
1322 "Return number of lines in buffer BUFFER." 1294 "Return number of lines in buffer BUFFER."
1323 (with-current-buffer buffer 1295 (count-lines (point-min) (point-max)))
1324 (count-lines (point-min) (point-max))))
1325 1296
1326(defun flymake-get-point-pixel-pos () 1297(defun flymake-get-point-pixel-pos ()
1327 "Return point position in pixels: (x, y)." 1298 "Return point position in pixels: (x, y)."
@@ -1346,7 +1317,6 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1346 (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))) 1317 (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
1347 (menu-data (flymake-make-err-menu-data line-no line-err-info-list)) 1318 (menu-data (flymake-make-err-menu-data line-no line-err-info-list))
1348 (choice nil) 1319 (choice nil)
1349 (mouse-pos (flymake-get-point-pixel-pos))
1350 (menu-pos (list (flymake-get-point-pixel-pos) (selected-window)))) 1320 (menu-pos (list (flymake-get-point-pixel-pos) (selected-window))))
1351 (if menu-data 1321 (if menu-data
1352 (progn 1322 (progn
@@ -1402,20 +1372,18 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1402 1372
1403(make-variable-buffer-local 'flymake-mode-line-status) 1373(make-variable-buffer-local 'flymake-mode-line-status)
1404 1374
1405(defun flymake-report-status (buffer e-w &optional status) 1375(defun flymake-report-status (e-w &optional status)
1406 "Show status in mode line." 1376 "Show status in mode line."
1407 (when (bufferp buffer) 1377 (when e-w
1408 (with-current-buffer buffer 1378 (setq flymake-mode-line-e-w e-w))
1409 (when e-w 1379 (when status
1410 (setq flymake-mode-line-e-w e-w)) 1380 (setq flymake-mode-line-status status))
1411 (when status 1381 (let* ((mode-line " Flymake"))
1412 (setq flymake-mode-line-status status)) 1382 (when (> (length flymake-mode-line-e-w) 0)
1413 (let* ((mode-line " Flymake")) 1383 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
1414 (when (> (length flymake-mode-line-e-w) 0) 1384 (setq mode-line (concat mode-line flymake-mode-line-status))
1415 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w))) 1385 (setq flymake-mode-line mode-line)
1416 (setq mode-line (concat mode-line flymake-mode-line-status)) 1386 (force-mode-line-update)))
1417 (setq flymake-mode-line mode-line)
1418 (force-mode-line-update)))))
1419 1387
1420(defun flymake-display-warning (warning) 1388(defun flymake-display-warning (warning)
1421 "Display a warning to user." 1389 "Display a warning to user."
@@ -1426,15 +1394,14 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'."
1426 :group 'flymake 1394 :group 'flymake
1427 :type 'boolean) 1395 :type 'boolean)
1428 1396
1429(defun flymake-report-fatal-status (buffer status warning) 1397(defun flymake-report-fatal-status (status warning)
1430 "Display a warning and switch flymake mode off." 1398 "Display a warning and switch flymake mode off."
1431 (when flymake-gui-warnings-enabled 1399 (when flymake-gui-warnings-enabled
1432 (flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning)) 1400 (flymake-display-warning (format "Flymake: %s. Flymake will be switched OFF" warning))
1433 ) 1401 )
1434 (with-current-buffer buffer 1402 (flymake-mode 0)
1435 (flymake-mode 0) 1403 (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s"
1436 (flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status %s, warning %s" 1404 (buffer-name) status warning))
1437 (buffer-name buffer) status warning)))
1438 1405
1439(defcustom flymake-start-syntax-check-on-find-file t 1406(defcustom flymake-start-syntax-check-on-find-file t
1440 "Start syntax check on find file." 1407 "Start syntax check on find file."
@@ -1458,13 +1425,13 @@ With arg, turn Flymake mode on if and only if arg is positive."
1458 (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t) 1425 (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
1459 ;;+(add-hook 'find-file-hook 'flymake-find-file-hook) 1426 ;;+(add-hook 'find-file-hook 'flymake-find-file-hook)
1460 1427
1461 (flymake-report-status (current-buffer) "" "") 1428 (flymake-report-status "" "")
1462 1429
1463 (setq flymake-timer 1430 (setq flymake-timer
1464 (run-at-time nil 1 'flymake-on-timer-event (current-buffer))) 1431 (run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
1465 1432
1466 (when flymake-start-syntax-check-on-find-file 1433 (when flymake-start-syntax-check-on-find-file
1467 (flymake-start-syntax-check-for-current-buffer)))) 1434 (flymake-start-syntax-check))))
1468 1435
1469 ;; Turning the mode OFF. 1436 ;; Turning the mode OFF.
1470 (t 1437 (t
@@ -1473,7 +1440,7 @@ With arg, turn Flymake mode on if and only if arg is positive."
1473 (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t) 1440 (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t)
1474 ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t) 1441 ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t)
1475 1442
1476 (flymake-delete-own-overlays (current-buffer)) 1443 (flymake-delete-own-overlays)
1477 1444
1478 (when flymake-timer 1445 (when flymake-timer
1479 (cancel-timer flymake-timer) 1446 (cancel-timer flymake-timer)
@@ -1504,14 +1471,14 @@ With arg, turn Flymake mode on if and only if arg is positive."
1504 (let((new-text (buffer-substring start stop))) 1471 (let((new-text (buffer-substring start stop)))
1505 (when (and flymake-start-syntax-check-on-newline (equal new-text "\n")) 1472 (when (and flymake-start-syntax-check-on-newline (equal new-text "\n"))
1506 (flymake-log 3 "starting syntax check as new-line has been seen") 1473 (flymake-log 3 "starting syntax check as new-line has been seen")
1507 (flymake-start-syntax-check-for-current-buffer)) 1474 (flymake-start-syntax-check))
1508 (setq flymake-last-change-time (flymake-float-time)))) 1475 (setq flymake-last-change-time (flymake-float-time))))
1509 1476
1510(defun flymake-after-save-hook () 1477(defun flymake-after-save-hook ()
1511 (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved? 1478 (if (local-variable-p 'flymake-mode (current-buffer)) ; (???) other way to determine whether flymake is active in buffer being saved?
1512 (progn 1479 (progn
1513 (flymake-log 3 "starting syntax check as buffer was saved") 1480 (flymake-log 3 "starting syntax check as buffer was saved")
1514 (flymake-start-syntax-check-for-current-buffer)))) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???) 1481 (flymake-start-syntax-check)))) ; no more mode 3. cannot start check if mode 3 (to temp copies) is active - (???)
1515 1482
1516(defun flymake-kill-buffer-hook () 1483(defun flymake-kill-buffer-hook ()
1517 (when flymake-timer 1484 (when flymake-timer
@@ -1521,7 +1488,7 @@ With arg, turn Flymake mode on if and only if arg is positive."
1521(defun flymake-find-file-hook () 1488(defun flymake-find-file-hook ()
1522 ;;+(when flymake-start-syntax-check-on-find-file 1489 ;;+(when flymake-start-syntax-check-on-find-file
1523 ;;+ (flymake-log 3 "starting syntax check on file open") 1490 ;;+ (flymake-log 3 "starting syntax check on file open")
1524 ;;+ (flymake-start-syntax-check-for-current-buffer) 1491 ;;+ (flymake-start-syntax-check)
1525 ;;+) 1492 ;;+)
1526 (when (and (not (local-variable-p 'flymake-mode (current-buffer))) 1493 (when (and (not (local-variable-p 'flymake-mode (current-buffer)))
1527 (flymake-can-syntax-check-file buffer-file-name)) 1494 (flymake-can-syntax-check-file buffer-file-name))
@@ -1728,7 +1695,8 @@ Return full-name. Names are real, not patched."
1728 (if (not buildfile-dir) 1695 (if (not buildfile-dir)
1729 (progn 1696 (progn
1730 (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name) 1697 (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
1731 (flymake-report-fatal-status buffer "NOMK" (format "No buildfile (%s) found for %s" buildfile-name source-file-name)) 1698 (with-current-buffer buffer
1699 (flymake-report-fatal-status "NOMK" (format "No buildfile (%s) found for %s" buildfile-name source-file-name)))
1732 ) 1700 )
1733 (progn 1701 (progn
1734 (flymake-set-buffer-value buffer "base-dir" buildfile-dir))) 1702 (flymake-set-buffer-value buffer "base-dir" buildfile-dir)))
@@ -1748,7 +1716,9 @@ Return full-name. Names are real, not patched."
1748 (if (not master-and-temp-master) 1716 (if (not master-and-temp-master)
1749 (progn 1717 (progn
1750 (flymake-log 1 "cannot find master file for %s" source-file-name) 1718 (flymake-log 1 "cannot find master file for %s" source-file-name)
1751 (flymake-report-status buffer "!" "") ; NOMASTER 1719 (when (bufferp buffer)
1720 (with-current-buffer buffer
1721 (flymake-report-status "!" ""))) ; NOMASTER
1752 ) 1722 )
1753 (progn 1723 (progn
1754 (setq master-file-name (nth 0 master-and-temp-master)) 1724 (setq master-file-name (nth 0 master-and-temp-master))
diff --git a/lisp/progmodes/glasses.el b/lisp/progmodes/glasses.el
index 18f744e81c8..d19f636ff93 100644
--- a/lisp/progmodes/glasses.el
+++ b/lisp/progmodes/glasses.el
@@ -82,7 +82,7 @@ For example, you can set `glasses-separator' to an empty string and
82`glasses-face' to `bold'. Then unreadable identifiers will have no separators, 82`glasses-face' to `bold'. Then unreadable identifiers will have no separators,
83but will have their capitals in bold." 83but will have their capitals in bold."
84 :group 'glasses 84 :group 'glasses
85 :type '(choice face (const nil)) 85 :type '(choice (const :tag "None" nil) face)
86 :set 'glasses-custom-set 86 :set 'glasses-custom-set
87 :initialize 'custom-initialize-default) 87 :initialize 'custom-initialize-default)
88 88
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index a9ccdf38442..e99262dd670 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -2735,6 +2735,7 @@ Obeying it means displaying in another window the specified file and line."
2735 (window (and buffer (or (get-buffer-window buffer) 2735 (window (and buffer (or (get-buffer-window buffer)
2736 (display-buffer buffer)))) 2736 (display-buffer buffer))))
2737 (pos)) 2737 (pos))
2738 (message "%s %s" (current-buffer) buffer)
2738 (if buffer 2739 (if buffer
2739 (progn 2740 (progn
2740 (with-current-buffer buffer 2741 (with-current-buffer buffer
@@ -2750,7 +2751,15 @@ Obeying it means displaying in another window the specified file and line."
2750 (setq pos (point)) 2751 (setq pos (point))
2751 (or gud-overlay-arrow-position 2752 (or gud-overlay-arrow-position
2752 (setq gud-overlay-arrow-position (make-marker))) 2753 (setq gud-overlay-arrow-position (make-marker)))
2753 (set-marker gud-overlay-arrow-position (point) (current-buffer))) 2754 (set-marker gud-overlay-arrow-position (point) (current-buffer))
2755 ;; If they turned on hl-line, move the hl-line highlight to
2756 ;; the arrow's line.
2757 (when (featurep 'hl-line)
2758 (cond
2759 (global-hl-line-mode
2760 (global-hl-line-highlight))
2761 ((and hl-line-mode hl-line-sticky-flag)
2762 (hl-line-highlight)))))
2754 (cond ((or (< pos (point-min)) (> pos (point-max))) 2763 (cond ((or (< pos (point-min)) (> pos (point-max)))
2755 (widen) 2764 (widen)
2756 (goto-char pos)))) 2765 (goto-char pos))))
diff --git a/lisp/subr.el b/lisp/subr.el
index c03fa3be5a0..a3e696d0e95 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -42,17 +42,15 @@ Each element of this list holds the arguments to one call to `defcustom'.")
42(defalias 'not 'null) 42(defalias 'not 'null)
43 43
44(defmacro noreturn (form) 44(defmacro noreturn (form)
45 "Evaluates FORM, with the expectation that the evaluation will signal an error 45 "Evaluate FORM, expecting it not to return.
46instead of returning to its caller. If FORM does return, an error is 46If FORM does return, signal an error."
47signaled."
48 `(prog1 ,form 47 `(prog1 ,form
49 (error "Form marked with `noreturn' did return"))) 48 (error "Form marked with `noreturn' did return")))
50 49
51(defmacro 1value (form) 50(defmacro 1value (form)
52 "Evaluates FORM, with the expectation that the same value will be returned 51 "Evaluate FORM, expecting a constant return value.
53from all evaluations of FORM. This is the global do-nothing 52This is the global do-nothing version. There is also `testcover-1value'
54version of `1value'. There is also `testcover-1value' that 53that complains if FORM ever does return differing values."
55complains if FORM ever does return differing values."
56 form) 54 form)
57 55
58(defmacro lambda (&rest cdr) 56(defmacro lambda (&rest cdr)
@@ -1686,7 +1684,7 @@ This finishes the change group by reverting all of its changes."
1686 (when (and (consp elt) (not (eq elt (last pending-undo-list)))) 1684 (when (and (consp elt) (not (eq elt (last pending-undo-list))))
1687 (error "Undoing to some unrelated state")) 1685 (error "Undoing to some unrelated state"))
1688 ;; Undo it all. 1686 ;; Undo it all.
1689 (while pending-undo-list (undo-more 1)) 1687 (while (listp pending-undo-list) (undo-more 1))
1690 ;; Reset the modified cons cell ELT to its original content. 1688 ;; Reset the modified cons cell ELT to its original content.
1691 (when (consp elt) 1689 (when (consp elt)
1692 (setcar elt old-car) 1690 (setcar elt old-car)
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 161b5fbc126..10b2ca206e9 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -853,7 +853,7 @@ The following is a complex example, see http://link.aps.org/linkfaq.html.
853 :group 'bibtex 853 :group 'bibtex
854 :type 'boolean) 854 :type 'boolean)
855 855
856;; `bibtex-font-lock-keywords' is a user option as well, but since the 856;; `bibtex-font-lock-keywords' is a user option, too. But since the
857;; patterns used to define this variable are defined in a later 857;; patterns used to define this variable are defined in a later
858;; section of this file, it is defined later. 858;; section of this file, it is defined later.
859 859
@@ -1091,7 +1091,7 @@ The CDRs of the elements are t for header keys and nil for crossref keys.")
1091 "Regexp matching the name of a BibTeX field.") 1091 "Regexp matching the name of a BibTeX field.")
1092 1092
1093(defconst bibtex-name-part 1093(defconst bibtex-name-part
1094 (concat ",[ \t\n]*\\(" bibtex-field-name "\\)[ \t\n]*=") 1094 (concat ",[ \t\n]*\\(" bibtex-field-name "\\)")
1095 "Regexp matching the name part of a BibTeX field.") 1095 "Regexp matching the name part of a BibTeX field.")
1096 1096
1097(defconst bibtex-reference-key "[][[:alnum:].:;?!`'/*@+|()<>&_^$-]+" 1097(defconst bibtex-reference-key "[][[:alnum:].:;?!`'/*@+|()<>&_^$-]+"
@@ -1105,16 +1105,6 @@ The CDRs of the elements are t for header keys and nil for crossref keys.")
1105 (regexp-opt (mapcar 'car bibtex-entry-field-alist)) "\\)") 1105 (regexp-opt (mapcar 'car bibtex-entry-field-alist)) "\\)")
1106 "Regexp matching the name of a BibTeX entry.") 1106 "Regexp matching the name of a BibTeX entry.")
1107 1107
1108(defvar bibtex-entry-type-whitespace
1109 (concat "[ \t]*" bibtex-entry-type)
1110 "Regexp matching the name of a BibTeX entry preceded by whitespace.")
1111
1112(defvar bibtex-entry-type-str
1113 (concat "@[ \t]*\\(?:"
1114 (regexp-opt (append '("String")
1115 (mapcar 'car bibtex-entry-field-alist))) "\\)")
1116 "Regexp matching the name of a BibTeX entry (including @String).")
1117
1118(defvar bibtex-entry-head 1108(defvar bibtex-entry-head
1119 (concat "^[ \t]*\\(" 1109 (concat "^[ \t]*\\("
1120 bibtex-entry-type 1110 bibtex-entry-type
@@ -1132,15 +1122,18 @@ The CDRs of the elements are t for header keys and nil for crossref keys.")
1132 bibtex-reference-key "\\)?") 1122 bibtex-reference-key "\\)?")
1133 "Regexp matching the header line of any BibTeX entry (possibly without key).") 1123 "Regexp matching the header line of any BibTeX entry (possibly without key).")
1134 1124
1125(defvar bibtex-any-valid-entry-type
1126 (concat "^[ \t]*@[ \t]*\\(?:"
1127 (regexp-opt (append '("String" "Preamble")
1128 (mapcar 'car bibtex-entry-field-alist))) "\\)")
1129 "Regexp matching any valid BibTeX entry (including String and Preamble).")
1130
1135(defconst bibtex-type-in-head 1 1131(defconst bibtex-type-in-head 1
1136 "Regexp subexpression number of the type part in `bibtex-entry-head'.") 1132 "Regexp subexpression number of the type part in `bibtex-entry-head'.")
1137 1133
1138(defconst bibtex-key-in-head 2 1134(defconst bibtex-key-in-head 2
1139 "Regexp subexpression number of the key part in `bibtex-entry-head'.") 1135 "Regexp subexpression number of the key part in `bibtex-entry-head'.")
1140 1136
1141(defconst bibtex-empty-field-re "\\`\\(\"\"\\|{}\\)\\'"
1142 "Regexp matching the text part (as a string) of an empty field.")
1143
1144(defconst bibtex-string-type "^[ \t]*\\(@[ \t]*String\\)[ \t]*[({][ \t\n]*" 1137(defconst bibtex-string-type "^[ \t]*\\(@[ \t]*String\\)[ \t]*[({][ \t\n]*"
1145 "Regexp matching the name of a BibTeX String entry.") 1138 "Regexp matching the name of a BibTeX String entry.")
1146 1139
@@ -1148,8 +1141,9 @@ The CDRs of the elements are t for header keys and nil for crossref keys.")
1148 (concat bibtex-string-type "\\(" bibtex-reference-key "\\)?") 1141 (concat bibtex-string-type "\\(" bibtex-reference-key "\\)?")
1149 "Regexp matching the header line of a BibTeX String entry.") 1142 "Regexp matching the header line of a BibTeX String entry.")
1150 1143
1151(defconst bibtex-preamble-prefix "[ \t]*@[ \t]*Preamble[ \t]*" 1144(defconst bibtex-preamble-prefix
1152 "Regexp matching the prefix part of a preamble.") 1145 "[ \t]*\\(@[ \t]*Preamble\\)[ \t]*[({][ \t\n]*"
1146 "Regexp matching the prefix part of a BibTeX Preamble entry.")
1153 1147
1154(defconst bibtex-font-lock-syntactic-keywords 1148(defconst bibtex-font-lock-syntactic-keywords
1155 `((,(concat "^[ \t]*\\(" (substring bibtex-comment-start 0 1) "\\)" 1149 `((,(concat "^[ \t]*\\(" (substring bibtex-comment-start 0 1) "\\)"
@@ -1229,12 +1223,9 @@ very first character of the match, the actual starting position of the name
1229part and end position of the match. Move point to end of field name. 1223part and end position of the match. Move point to end of field name.
1230If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceding 1224If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceding
1231BibTeX field as necessary." 1225BibTeX field as necessary."
1232 (cond ((looking-at ",[ \t\n]*") 1226 (cond ((looking-at bibtex-name-part)
1233 (let ((start (point))) 1227 (goto-char (match-end 0))
1234 (goto-char (match-end 0)) 1228 (list (match-beginning 0) (match-beginning 1) (match-end 0)))
1235 (when (looking-at bibtex-field-name)
1236 (goto-char (match-end 0))
1237 (list start (match-beginning 0) (match-end 0)))))
1238 ;; Maybe add a missing comma. 1229 ;; Maybe add a missing comma.
1239 ((and bibtex-autoadd-commas 1230 ((and bibtex-autoadd-commas
1240 (looking-at (concat "[ \t\n]*\\(?:" bibtex-field-name 1231 (looking-at (concat "[ \t\n]*\\(?:" bibtex-field-name
@@ -1334,60 +1325,71 @@ the boundaries of the name and text parts of the field. Do not move point."
1334 "Search forward to find a BibTeX field of name NAME. 1325 "Search forward to find a BibTeX field of name NAME.
1335If a syntactically correct field is found, return a pair containing 1326If a syntactically correct field is found, return a pair containing
1336the boundaries of the name and text parts of the field. The search 1327the boundaries of the name and text parts of the field. The search
1337is limited by optional arg BOUND or if nil by the end of the current 1328is limited by optional arg BOUND. If BOUND is t the search is limited
1338entry. Do not move point." 1329by the end of the current entry. Do not move point."
1339 (save-match-data 1330 (save-match-data
1340 (save-excursion 1331 (save-excursion
1341 (if bound 1332 (if (eq bound t)
1342 ;; If the search is bounded we need not worry we could overshoot. 1333 (let ((regexp (concat bibtex-name-part "[ \t\n]*=\\|"
1343 ;; This is indeed the case when `bibtex-search-forward-field' is 1334 bibtex-any-entry-maybe-empty-head))
1344 ;; called many times. So we optimize this part of this function. 1335 (case-fold-search t) bounds)
1345 (let ((name-part (concat ",[ \t\n]*\\(" name "\\)[ \t\n]*=[ \t\n]*")) 1336 (catch 'done
1346 (case-fold-search t) left right) 1337 (if (looking-at "[ \t]*@") (goto-char (match-end 0)))
1347 (while (and (not right) 1338 (while (and (not bounds)
1348 (re-search-forward name-part bound t)) 1339 (re-search-forward regexp nil t))
1349 (setq left (list (match-beginning 0) (match-beginning 1) 1340 (if (match-beginning 2)
1350 (match-end 1)) 1341 ;; We found a new entry
1351 ;; Don't worry that the field text could be past bound. 1342 (throw 'done nil)
1352 right (bibtex-parse-field-text))) 1343 ;; We found a field
1353 (if right (cons left right))) 1344 (goto-char (match-beginning 0))
1354 (let ((regexp (concat bibtex-name-part "\\|" 1345 (setq bounds (bibtex-parse-field))))
1355 bibtex-any-entry-maybe-empty-head)) 1346 ;; Step through all fields so that we cannot overshoot.
1356 (case-fold-search t) bounds) 1347 (while bounds
1357 (catch 'done 1348 (goto-char (bibtex-start-of-name-in-field bounds))
1358 (if (looking-at "[ \t]*@") (goto-char (match-end 0))) 1349 (if (looking-at name) (throw 'done bounds))
1359 (while (and (not bounds) 1350 (goto-char (bibtex-end-of-field bounds))
1360 (re-search-forward regexp nil t)) 1351 (setq bounds (bibtex-parse-field)))))
1361 (if (match-beginning 2) 1352 ;; Bounded search or bound is nil (i.e. we cannot overshoot).
1362 ;; We found a new entry 1353 ;; Indeed, the search is bounded when `bibtex-search-forward-field'
1363 (throw 'done nil) 1354 ;; is called many times. So we optimize this part of this function.
1364 ;; We found a field 1355 (let ((name-part (concat ",[ \t\n]*\\(" name "\\)[ \t\n]*=[ \t\n]*"))
1365 (goto-char (match-beginning 0)) 1356 (case-fold-search t) left right)
1366 (setq bounds (bibtex-parse-field)))) 1357 (while (and (not right)
1367 ;; Step through all fields so that we cannot overshoot. 1358 (re-search-forward name-part bound t))
1368 (while bounds 1359 (setq left (list (match-beginning 0) (match-beginning 1)
1369 (goto-char (bibtex-start-of-name-in-field bounds)) 1360 (match-end 1))
1370 (if (looking-at name) (throw 'done bounds)) 1361 ;; Don't worry that the field text could be past bound.
1371 (goto-char (bibtex-end-of-field bounds)) 1362 right (bibtex-parse-field-text)))
1372 (setq bounds (bibtex-parse-field))))))))) 1363 (if right (cons left right)))))))
1373 1364
1374(defun bibtex-search-backward-field (name &optional bound) 1365(defun bibtex-search-backward-field (name &optional bound)
1375 "Search backward to find a BibTeX field of name NAME. 1366 "Search backward to find a BibTeX field of name NAME.
1376If a syntactically correct field is found, return a pair containing 1367If a syntactically correct field is found, return a pair containing
1377the boundaries of the name and text parts of the field. The search 1368the boundaries of the name and text parts of the field. The search
1378is limited by the optional arg BOUND. If BOUND is nil the search is 1369is limited by the optional arg BOUND. If BOUND is t the search is
1379limited by the beginning of the current entry. Do not move point." 1370limited by the beginning of the current entry. Do not move point."
1380 (save-match-data 1371 (save-match-data
1381 (save-excursion 1372 (if (eq bound t)
1382 (let ((name-part (concat ",[ \t\n]*\\(?:" name "\\)[ \t\n]*=")) 1373 (setq bound (save-excursion (bibtex-beginning-of-entry))))
1383 (case-fold-search t) 1374 (let ((name-part (concat ",[ \t\n]*\\(" name "\\)[ \t\n]*=[ \t\n]*"))
1384 bounds) 1375 (case-fold-search t) left right)
1385 (unless bound (setq bound (save-excursion (bibtex-beginning-of-entry)))) 1376 (save-excursion
1386 (while (and (not bounds) 1377 ;; the parsing functions are not designed for parsing backwards :-(
1387 (search-backward "," bound t) 1378 (when (search-backward "," bound t)
1388 (looking-at name-part)) 1379 (or (save-excursion
1389 (setq bounds (bibtex-parse-field))) 1380 (when (looking-at name-part)
1390 bounds)))) 1381 (setq left (list (match-beginning 0) (match-beginning 1)
1382 (match-end 1)))
1383 (goto-char (match-end 0))
1384 (setq right (bibtex-parse-field-text))))
1385 (while (and (not right)
1386 (re-search-backward name-part bound t))
1387 (setq left (list (match-beginning 0) (match-beginning 1)
1388 (match-end 1)))
1389 (save-excursion
1390 (goto-char (match-end 0))
1391 (setq right (bibtex-parse-field-text)))))
1392 (if right (cons left right)))))))
1391 1393
1392(defun bibtex-name-in-field (bounds &optional remove-opt-alt) 1394(defun bibtex-name-in-field (bounds &optional remove-opt-alt)
1393 "Get content of name in BibTeX field defined via BOUNDS. 1395 "Get content of name in BibTeX field defined via BOUNDS.
@@ -1407,25 +1409,22 @@ by removing field delimiters and concatenating the resulting string.
1407If `bibtex-expand-strings' is non-nil, also expand BibTeX strings." 1409If `bibtex-expand-strings' is non-nil, also expand BibTeX strings."
1408 (if content 1410 (if content
1409 (save-excursion 1411 (save-excursion
1412 (goto-char (bibtex-start-of-text-in-field bounds))
1410 (let ((epoint (bibtex-end-of-text-in-field bounds)) 1413 (let ((epoint (bibtex-end-of-text-in-field bounds))
1411 content opoint temp) 1414 content opoint)
1412 (goto-char (bibtex-start-of-text-in-field bounds))
1413 (while (< (setq opoint (point)) epoint) 1415 (while (< (setq opoint (point)) epoint)
1414 (cond ((looking-at bibtex-field-const) 1416 (if (looking-at bibtex-field-const)
1415 (let ((mtch (match-string-no-properties 0))) 1417 (let ((mtch (match-string-no-properties 0)))
1416 (goto-char (match-end 0)) 1418 (push (or (if bibtex-expand-strings
1417 (setq temp (if bibtex-expand-strings 1419 (cdr (assoc-string mtch (bibtex-strings) t)))
1418 (cdr (assoc-string mtch (bibtex-strings) t))) 1420 mtch) content)
1419 content (concat content (or temp mtch))))) 1421 (goto-char (match-end 0)))
1420 1422 (let ((bounds (bibtex-parse-field-string)))
1421 ((setq temp (bibtex-parse-field-string)) 1423 (push (buffer-substring-no-properties
1422 (setq content (concat content (buffer-substring-no-properties 1424 (1+ (car bounds)) (1- (cdr bounds))) content)
1423 (1+ (car temp)) 1425 (goto-char (cdr bounds))))
1424 (1- (cdr temp)))))
1425 (goto-char (cdr temp)))
1426 (t (error "Malformed text field")))
1427 (re-search-forward "\\=[ \t\n]*#[ \t\n]*" nil t)) 1426 (re-search-forward "\\=[ \t\n]*#[ \t\n]*" nil t))
1428 content)) 1427 (apply 'concat (nreverse content))))
1429 (buffer-substring-no-properties (bibtex-start-of-text-in-field bounds) 1428 (buffer-substring-no-properties (bibtex-start-of-text-in-field bounds)
1430 (bibtex-end-of-text-in-field bounds)))) 1429 (bibtex-end-of-text-in-field bounds))))
1431 1430
@@ -1434,19 +1433,15 @@ If `bibtex-expand-strings' is non-nil, also expand BibTeX strings."
1434Return nil if not found. 1433Return nil if not found.
1435If optional arg FOLLOW-CROSSREF is non-nil, follow crossref." 1434If optional arg FOLLOW-CROSSREF is non-nil, follow crossref."
1436 (save-excursion 1435 (save-excursion
1437 (save-restriction 1436 (let* ((end (if follow-crossref (bibtex-end-of-entry) t))
1438 ;; We want to jump back and forth while searching FIELD 1437 (beg (bibtex-beginning-of-entry)) ; move point
1439 (bibtex-narrow-to-entry) 1438 (bounds (bibtex-search-forward-field field end)))
1440 (goto-char (point-min)) 1439 (cond (bounds (bibtex-text-in-field-bounds bounds t))
1441 (let ((bounds (bibtex-search-forward-field field (point-max))) 1440 ((and follow-crossref
1442 crossref-field) 1441 (progn (goto-char beg)
1443 (cond (bounds (bibtex-text-in-field-bounds bounds t)) 1442 (setq bounds (bibtex-search-forward-field
1444 ((and follow-crossref 1443 "\\(OPT\\)?crossref" end))))
1445 (progn (goto-char (point-min)) 1444 (let ((crossref-field (bibtex-text-in-field-bounds bounds t)))
1446 (setq bounds (bibtex-search-forward-field
1447 "\\(OPT\\)?crossref" (point-max)))))
1448 (setq crossref-field (bibtex-text-in-field-bounds bounds t))
1449 (widen)
1450 (if (bibtex-find-crossref crossref-field) 1445 (if (bibtex-find-crossref crossref-field)
1451 ;; Do not pass FOLLOW-CROSSREF because we want 1446 ;; Do not pass FOLLOW-CROSSREF because we want
1452 ;; to follow crossrefs only one level of recursion. 1447 ;; to follow crossrefs only one level of recursion.
@@ -1487,42 +1482,28 @@ character of the string entry. Move point past BibTeX string entry."
1487 (nth 1 bounds) 1482 (nth 1 bounds)
1488 (match-end 0)))))) 1483 (match-end 0))))))
1489 1484
1490(defun bibtex-parse-string () 1485(defun bibtex-parse-string (&optional empty-key)
1491 "Parse a BibTeX string entry beginning at the position of point. 1486 "Parse a BibTeX string entry beginning at the position of point.
1492If a syntactically correct entry is found, return a cons pair containing 1487If a syntactically correct entry is found, return a cons pair containing
1493the boundaries of the reference key and text parts of the entry. 1488the boundaries of the reference key and text parts of the entry.
1494Do not move point." 1489If EMPTY-KEY is non-nil, key may be empty. Do not move point."
1495 (bibtex-parse-association 'bibtex-parse-string-prefix 1490 (let ((bibtex-string-empty-key empty-key))
1496 'bibtex-parse-string-postfix)) 1491 (bibtex-parse-association 'bibtex-parse-string-prefix
1492 'bibtex-parse-string-postfix)))
1497 1493
1498(defun bibtex-search-forward-string () 1494(defun bibtex-search-forward-string (&optional empty-key)
1499 "Search forward to find a BibTeX string entry. 1495 "Search forward to find a BibTeX string entry.
1500If a syntactically correct entry is found, a pair containing the boundaries of 1496If a syntactically correct entry is found, a pair containing the boundaries of
1501the reference key and text parts of the string is returned. Do not move point." 1497the reference key and text parts of the string is returned.
1498If EMPTY-KEY is non-nil, key may be empty. Do not move point."
1502 (save-excursion 1499 (save-excursion
1503 (save-match-data 1500 (save-match-data
1504 (let ((case-fold-search t) 1501 (let ((case-fold-search t) bounds)
1505 boundaries) 1502 (while (and (not bounds)
1506 (while (and (not boundaries)
1507 (search-forward-regexp bibtex-string-type nil t)) 1503 (search-forward-regexp bibtex-string-type nil t))
1508 (goto-char (match-beginning 0)) 1504 (save-excursion (goto-char (match-beginning 0))
1509 (unless (setq boundaries (bibtex-parse-string)) 1505 (setq bounds (bibtex-parse-string empty-key))))
1510 (forward-char 1))) 1506 bounds))))
1511 boundaries))))
1512
1513(defun bibtex-search-backward-string ()
1514 "Search backward to find a BibTeX string entry.
1515If a syntactically correct entry is found, a pair containing the boundaries of
1516the reference key and text parts of the field is returned. Do not move point."
1517 (save-excursion
1518 (save-match-data
1519 (let ((case-fold-search t)
1520 boundaries)
1521 (while (and (not boundaries)
1522 (search-backward-regexp bibtex-string-type nil t))
1523 (goto-char (match-beginning 0))
1524 (setq boundaries (bibtex-parse-string)))
1525 boundaries))))
1526 1507
1527(defun bibtex-reference-key-in-string (bounds) 1508(defun bibtex-reference-key-in-string (bounds)
1528 "Return the key part of a BibTeX string defined via BOUNDS" 1509 "Return the key part of a BibTeX string defined via BOUNDS"
@@ -1554,14 +1535,15 @@ If `bibtex-expand-strings' is non-nil, also expand BibTeX strings."
1554 (or (match-string-no-properties bibtex-key-in-head) 1535 (or (match-string-no-properties bibtex-key-in-head)
1555 empty)) 1536 empty))
1556 1537
1557(defun bibtex-preamble-prefix (&optional delim) 1538(defun bibtex-parse-preamble ()
1558 "Parse the prefix part of a BibTeX Preamble. 1539 "Parse BibTeX preamble.
1559Point must be at beginning of prefix part. If prefix is found move point 1540Point must be at beginning of preamble. Do not move point."
1560to its end and return position of point. If optional arg DELIM is non-nil,
1561move past the opening delimiter. If no preamble is found return nil."
1562 (let ((case-fold-search t)) 1541 (let ((case-fold-search t))
1563 (re-search-forward (concat "\\=" bibtex-preamble-prefix 1542 (when (looking-at bibtex-preamble-prefix)
1564 (if delim "[({][ \t\n]*")) nil t))) 1543 (let ((start (match-beginning 0)) (pref-start (match-beginning 1))
1544 (bounds (save-excursion (goto-char (match-end 0))
1545 (bibtex-parse-string-postfix))))
1546 (if bounds (cons (list start pref-start) bounds))))))
1565 1547
1566;; Helper Functions 1548;; Helper Functions
1567 1549
@@ -1579,6 +1561,35 @@ move past the opening delimiter. If no preamble is found return nil."
1579 (+ (count-lines 1 (point)) 1561 (+ (count-lines 1 (point))
1580 (if (bolp) 1 0))) 1562 (if (bolp) 1 0)))
1581 1563
1564(defun bibtex-valid-entry (&optional empty-key)
1565 "Parse a valid BibTeX entry (maybe without key if EMPTY-KEY is t).
1566A valid entry is a syntactical correct one with type contained in
1567`bibtex-entry-field-alist'. Ignore @String and @Preamble entries.
1568Return a cons pair with buffer positions of beginning and end of entry
1569if a valid entry is found, nil otherwise. Do not move point.
1570After a call to this function `match-data' corresponds to the header
1571of the entry, see regexp `bibtex-entry-head'."
1572 (let ((case-fold-search t) end)
1573 (if (looking-at (if empty-key bibtex-entry-maybe-empty-head
1574 bibtex-entry-head))
1575 (save-excursion
1576 (save-match-data
1577 (goto-char (match-end 0))
1578 (let ((entry-closer
1579 (if (save-excursion
1580 (goto-char (match-end bibtex-type-in-head))
1581 (looking-at "[ \t]*("))
1582 ",?[ \t\n]*)" ;; entry opened with `('
1583 ",?[ \t\n]*}")) ;; entry opened with `{'
1584 bounds)
1585 (skip-chars-forward " \t\n")
1586 ;; loop over all BibTeX fields
1587 (while (setq bounds (bibtex-parse-field))
1588 (goto-char (bibtex-end-of-field bounds)))
1589 ;; This matches the infix* part.
1590 (if (looking-at entry-closer) (setq end (match-end 0)))))
1591 (if end (cons (match-beginning 0) end))))))
1592
1582(defun bibtex-skip-to-valid-entry (&optional backward) 1593(defun bibtex-skip-to-valid-entry (&optional backward)
1583 "Move point to beginning of the next valid BibTeX entry. 1594 "Move point to beginning of the next valid BibTeX entry.
1584Do not move if we are already at beginning of a valid BibTeX entry. 1595Do not move if we are already at beginning of a valid BibTeX entry.
@@ -1590,32 +1601,27 @@ entry. Return buffer position of beginning and end of entry if a valid
1590entry is found, nil otherwise." 1601entry is found, nil otherwise."
1591 (interactive "P") 1602 (interactive "P")
1592 (let ((case-fold-search t) 1603 (let ((case-fold-search t)
1593 found) 1604 found bounds)
1594 (beginning-of-line) 1605 (beginning-of-line)
1595 ;; Loop till we look at a valid entry. 1606 ;; Loop till we look at a valid entry.
1596 (while (not (or found (if backward (bobp) (eobp)))) 1607 (while (not (or found (if backward (bobp) (eobp))))
1597 (let ((pnt (point)) 1608 (cond ((setq found (or (bibtex-valid-entry)
1598 bounds) 1609 (and (not bibtex-sort-ignore-string-entries)
1599 (cond ((or (and (looking-at bibtex-entry-type-whitespace) 1610 (setq bounds (bibtex-parse-string))
1600 (setq found (bibtex-search-entry nil nil t)) 1611 (cons (bibtex-start-of-field bounds)
1601 (equal (match-beginning 0) pnt)) 1612 (bibtex-end-of-string bounds))))))
1602 (and (not bibtex-sort-ignore-string-entries) 1613 (backward (re-search-backward "^[ \t]*@" nil 'move))
1603 (setq bounds (bibtex-parse-string)) 1614 (t (if (re-search-forward "\n\\([ \t]*@\\)" nil 'move)
1604 (setq found (cons (bibtex-start-of-field bounds) 1615 (goto-char (match-beginning 1))))))
1605 (bibtex-end-of-string bounds)))))
1606 (goto-char pnt))
1607 (backward (re-search-backward "^[ \t]*@" nil 'move))
1608 (t (re-search-forward "\\=[ \t]*@" nil t) ;; don't be stuck
1609 (if (re-search-forward "^[ \t]*@" nil 'move)
1610 (goto-char (match-beginning 0)))))))
1611 found)) 1616 found))
1612 1617
1613(defun bibtex-map-entries (fun) 1618(defun bibtex-map-entries (fun)
1614 "Call FUN for each BibTeX entry in buffer (possibly narrowed). 1619 "Call FUN for each BibTeX entry in buffer (possibly narrowed).
1615FUN is called with three arguments, the key of the entry and the buffer 1620FUN is called with three arguments, the key of the entry and the buffer
1616positions (marker) of beginning and end of entry. Point is inside the entry. 1621positions of beginning and end of entry. Also, point is at beginning of
1617If `bibtex-sort-ignore-string-entries' is non-nil, FUN is not called for 1622entry and `match-data' corresponds to the header of the entry,
1618@String entries." 1623see regexp `bibtex-entry-head'. If `bibtex-sort-ignore-string-entries'
1624is non-nil, FUN is not called for @String entries."
1619 (let ((case-fold-search t) 1625 (let ((case-fold-search t)
1620 found) 1626 found)
1621 (save-excursion 1627 (save-excursion
@@ -1673,75 +1679,19 @@ If FLAG is nil, a message is echoed if point was incremented at least
1673 "}" 1679 "}"
1674 ")")) 1680 ")"))
1675 1681
1676(defun bibtex-search-entry (empty-head &optional bound noerror backward) 1682(defun bibtex-flash-head (prompt)
1677 "Search for a BibTeX entry (maybe without reference key if EMPTY-HEAD is t).
1678BOUND and NOERROR are exactly as in `re-search-forward'. If BACKWARD
1679is non-nil, search in reverse direction. Move point past the closing
1680delimiter (at the beginning of entry if BACKWARD is non-nil).
1681Return a cons pair with buffer positions of beginning and end of entry.
1682After a call to this function `match-data' corresponds to the head part
1683of the entry, see regexp `bibtex-entry-head'.
1684Ignore @String and @Preamble entries."
1685 (let ((pnt (point))
1686 (entry-head-re (if empty-head
1687 bibtex-entry-maybe-empty-head
1688 bibtex-entry-head)))
1689 (if backward
1690 (let (found)
1691 (while (and (not found)
1692 (re-search-backward entry-head-re bound noerror))
1693 (setq found (bibtex-search-entry empty-head pnt t)))
1694 (cond (found
1695 (goto-char (match-beginning 0))
1696 found)
1697 ((not noerror) ;; yell
1698 (error "Backward search of BibTeX entry failed"))
1699 (t (if (eq noerror t) (goto-char pnt)) ;; don't move
1700 nil)))
1701 (let (found)
1702 (unless bound (setq bound (point-max)))
1703 (while (and (not found)
1704 (re-search-forward entry-head-re bound noerror))
1705 (save-match-data
1706 (let ((entry-closer
1707 (if (save-excursion
1708 (goto-char (match-end bibtex-type-in-head))
1709 (looking-at "[ \t]*("))
1710 ",?[ \t\n]*)" ;; entry opened with `('
1711 ",?[ \t\n]*}")) ;; entry opened with `{'
1712 bounds)
1713 (skip-chars-forward " \t\n" bound)
1714 ;; loop over all BibTeX fields
1715 (while (and (setq bounds (bibtex-parse-field))
1716 (<= (bibtex-end-of-field bounds) bound))
1717 (goto-char (bibtex-end-of-field bounds)))
1718 ;; This matches the infix* part.
1719 (when (and (looking-at entry-closer)
1720 (<= (match-end 0) bound))
1721 (goto-char (match-end 0))
1722 (setq found t)))))
1723 (cond (found
1724 (cons (match-beginning 0) (point)))
1725 ((not noerror) ;; yell
1726 (error "Search of BibTeX entry failed"))
1727 (t (if (eq noerror t) (goto-char pnt)) ;; don't move
1728 nil))))))
1729
1730(defun bibtex-flash-head ()
1731 "Flash at BibTeX entry head before point, if exists." 1683 "Flash at BibTeX entry head before point, if exists."
1732 (let ((case-fold-search t) 1684 (let ((case-fold-search t)
1733 (pnt (point)) 1685 (pnt (point)))
1734 flash)
1735 (save-excursion 1686 (save-excursion
1736 (bibtex-beginning-of-entry) 1687 (bibtex-beginning-of-entry)
1737 (when (and (looking-at bibtex-any-entry-maybe-empty-head) 1688 (when (and (looking-at bibtex-any-entry-maybe-empty-head)
1738 (< (point) pnt)) 1689 (< (point) pnt))
1739 (goto-char (match-beginning bibtex-type-in-head)) 1690 (goto-char (match-beginning bibtex-type-in-head))
1740 (setq flash (match-end bibtex-key-in-head))
1741 (if (pos-visible-in-window-p (point)) 1691 (if (pos-visible-in-window-p (point))
1742 (sit-for 1) 1692 (sit-for 1)
1743 (message "From: %s" 1693 (message "%s%s" prompt (buffer-substring-no-properties
1744 (buffer-substring (point) flash))))))) 1694 (point) (match-end bibtex-key-in-head))))))))
1745 1695
1746(defun bibtex-make-optional-field (field) 1696(defun bibtex-make-optional-field (field)
1747 "Make an optional field named FIELD in current BibTeX entry." 1697 "Make an optional field named FIELD in current BibTeX entry."
@@ -1772,66 +1722,55 @@ are ignored. Return point"
1772 (bibtex-skip-to-valid-entry) 1722 (bibtex-skip-to-valid-entry)
1773 (point)) 1723 (point))
1774 1724
1775(defun bibtex-inside-field () 1725(defun bibtex-enclosing-field (&optional comma noerr)
1776 "Try to avoid point being at end of a BibTeX field."
1777 (end-of-line)
1778 (skip-chars-backward " \t")
1779 (if (= (preceding-char) ?,)
1780 (forward-char -2))
1781 (if (or (= (preceding-char) ?})
1782 (= (preceding-char) ?\"))
1783 (forward-char -1)))
1784
1785(defun bibtex-enclosing-field (&optional noerr)
1786 "Search for BibTeX field enclosing point. 1726 "Search for BibTeX field enclosing point.
1727For `bibtex-mode''s internal algorithms, a field begins at the comma
1728following the preceding field. Usually, this is not what the user expects.
1729Thus if COMMA is non-nil, the \"current field\" includes the terminating comma.
1787Unless NOERR is non-nil, signal an error if no enclosing field is found. 1730Unless NOERR is non-nil, signal an error if no enclosing field is found.
1788On success return bounds, nil otherwise. Do not move point." 1731On success return bounds, nil otherwise. Do not move point."
1789 (let ((bounds (bibtex-search-backward-field bibtex-field-name))) 1732 (save-excursion
1790 (if (and bounds 1733 (when comma
1791 (<= (bibtex-start-of-field bounds) (point)) 1734 (end-of-line)
1792 (>= (bibtex-end-of-field bounds) (point))) 1735 (skip-chars-backward " \t")
1793 bounds 1736 (if (= (preceding-char) ?,) (forward-char -1)))
1794 (unless noerr 1737
1795 (error "Can't find enclosing BibTeX field"))))) 1738 (let ((bounds (bibtex-search-backward-field bibtex-field-name t)))
1796 1739 (cond ((and bounds
1797(defun bibtex-enclosing-entry-maybe-empty-head () 1740 (<= (bibtex-start-of-field bounds) (point))
1798 "Search for BibTeX entry enclosing point. Move point to end of entry. 1741 (>= (bibtex-end-of-field bounds) (point)))
1799Beginning (but not end) of entry is given by (`match-beginning' 0)." 1742 bounds)
1800 (let ((case-fold-search t) 1743 ((not noerr)
1801 (old-point (point))) 1744 (error "Can't find enclosing BibTeX field"))))))
1802 (unless (re-search-backward bibtex-entry-maybe-empty-head nil t) 1745
1803 (goto-char old-point) 1746(defun bibtex-beginning-first-field (&optional beg)
1804 (error "Can't find beginning of enclosing BibTeX entry")) 1747 "Move point to beginning of first field.
1805 (goto-char (match-beginning bibtex-type-in-head)) 1748Optional arg BEG is beginning of entry."
1806 (unless (bibtex-search-entry t nil t) 1749 (if beg (goto-char beg) (bibtex-beginning-of-entry))
1807 (goto-char old-point) 1750 (looking-at bibtex-any-entry-maybe-empty-head)
1808 (error "Can't find end of enclosing BibTeX entry")))) 1751 (goto-char (match-end 0)))
1809 1752
1810(defun bibtex-insert-kill (n) 1753(defun bibtex-insert-kill (n &optional comma)
1811 "Reinsert the Nth stretch of killed BibTeX text." 1754 "Reinsert the Nth stretch of killed BibTeX text (field or entry).
1812 (if (not bibtex-last-kill-command) 1755Optional arg COMMA is as in `bibtex-enclosing-field'."
1813 (error "BibTeX kill ring is empty") 1756 (unless bibtex-last-kill-command (error "BibTeX kill ring is empty"))
1814 (let* ((kr (if (eq bibtex-last-kill-command 'field) 1757 (let ((fun (lambda (kryp kr) ;; adapted from `current-kill'
1815 'bibtex-field-kill-ring 1758 (car (set kryp (nthcdr (mod (- n (length (eval kryp)))
1816 'bibtex-entry-kill-ring)) 1759 (length kr)) kr))))))
1817 (kryp (if (eq bibtex-last-kill-command 'field) 1760 (if (eq bibtex-last-kill-command 'field)
1818 'bibtex-field-kill-ring-yank-pointer 1761 (progn
1819 'bibtex-entry-kill-ring-yank-pointer)) 1762 ;; insert past the current field
1820 (current (car (set kryp (nthcdr (mod (- n (length (eval kryp))) 1763 (goto-char (bibtex-end-of-field (bibtex-enclosing-field comma)))
1821 (length (eval kr))) 1764 (set-mark (point))
1822 (eval kr)))))) 1765 (message "Mark set")
1823 (if (eq bibtex-last-kill-command 'field) 1766 (bibtex-make-field (funcall fun 'bibtex-field-kill-ring-yank-pointer
1824 (progn 1767 bibtex-field-kill-ring) t))
1825 (bibtex-find-text) 1768 ;; insert past the current entry
1826 (if (looking-at "[}\"]") 1769 (bibtex-skip-to-valid-entry)
1827 (forward-char)) 1770 (set-mark (point))
1828 (set-mark (point)) 1771 (message "Mark set")
1829 (message "Mark set") 1772 (insert (funcall fun 'bibtex-entry-kill-ring-yank-pointer
1830 (bibtex-make-field current t)) 1773 bibtex-entry-kill-ring)))))
1831 (unless (eobp) (bibtex-beginning-of-entry))
1832 (set-mark (point))
1833 (message "Mark set")
1834 (insert current)))))
1835 1774
1836(defun bibtex-format-entry () 1775(defun bibtex-format-entry ()
1837 "Helper function for `bibtex-clean-entry'. 1776 "Helper function for `bibtex-clean-entry'.
@@ -1900,9 +1839,8 @@ Formats current entry according to variable `bibtex-entry-format'."
1900 (error "All alternatives are empty")) 1839 (error "All alternatives are empty"))
1901 1840
1902 ;; process all fields 1841 ;; process all fields
1903 (goto-char (point-min)) 1842 (bibtex-beginning-first-field (point-min))
1904 (while (setq bounds (bibtex-search-forward-field 1843 (while (setq bounds (bibtex-parse-field))
1905 bibtex-field-name (point-max)))
1906 (let* ((beg-field (copy-marker (bibtex-start-of-field bounds))) 1844 (let* ((beg-field (copy-marker (bibtex-start-of-field bounds)))
1907 (end-field (copy-marker (bibtex-end-of-field bounds) t)) 1845 (end-field (copy-marker (bibtex-end-of-field bounds) t))
1908 (beg-name (copy-marker (bibtex-start-of-name-in-field bounds))) 1846 (beg-name (copy-marker (bibtex-start-of-name-in-field bounds)))
@@ -2040,10 +1978,6 @@ Formats current entry according to variable `bibtex-entry-format'."
2040 (error "Alternative fields `%s' are defined %s times" 1978 (error "Alternative fields `%s' are defined %s times"
2041 altlist found)))))) 1979 altlist found))))))
2042 1980
2043 ;; update point
2044 (if (looking-at (bibtex-field-right-delimiter))
2045 (forward-char))
2046
2047 ;; update comma after last field 1981 ;; update comma after last field
2048 (if (memq 'last-comma format) 1982 (if (memq 'last-comma format)
2049 (cond ((and bibtex-comma-after-last-field 1983 (cond ((and bibtex-comma-after-last-field
@@ -2536,6 +2470,7 @@ already set."
2536 "Complete word fragment before point to longest prefix of COMPLETIONS. 2470 "Complete word fragment before point to longest prefix of COMPLETIONS.
2537COMPLETIONS is an alist of strings. If point is not after the part 2471COMPLETIONS is an alist of strings. If point is not after the part
2538of a word, all strings are listed. Return completion." 2472of a word, all strings are listed. Return completion."
2473 ;; Return value is used by cleanup functions.
2539 (let* ((case-fold-search t) 2474 (let* ((case-fold-search t)
2540 (beg (save-excursion 2475 (beg (save-excursion
2541 (re-search-backward "[ \t{\"]") 2476 (re-search-backward "[ \t{\"]")
@@ -2558,13 +2493,13 @@ of a word, all strings are listed. Return completion."
2558 (display-completion-list (all-completions part-of-word completions) 2493 (display-completion-list (all-completions part-of-word completions)
2559 part-of-word)) 2494 part-of-word))
2560 (message "Making completion list...done") 2495 (message "Making completion list...done")
2561 ;; return value is handled by choose-completion-string-functions
2562 nil)))) 2496 nil))))
2563 2497
2564(defun bibtex-complete-string-cleanup (str compl) 2498(defun bibtex-complete-string-cleanup (str compl)
2565 "Cleanup after inserting string STR. 2499 "Cleanup after inserting string STR.
2566Remove enclosing field delimiters for STR. Display message with 2500Remove enclosing field delimiters for STR. Display message with
2567expansion of STR using expansion list COMPL." 2501expansion of STR using expansion list COMPL."
2502 ;; point is at position inside field where completion was requested
2568 (save-excursion 2503 (save-excursion
2569 (let ((abbr (cdr (if (stringp str) 2504 (let ((abbr (cdr (if (stringp str)
2570 (assoc-string str compl t))))) 2505 (assoc-string str compl t)))))
@@ -2624,50 +2559,52 @@ Used as default value of `bibtex-summary-function'."
2624(defun bibtex-pop (arg direction) 2559(defun bibtex-pop (arg direction)
2625 "Fill current field from the ARGth same field's text in DIRECTION. 2560 "Fill current field from the ARGth same field's text in DIRECTION.
2626Generic function used by `bibtex-pop-previous' and `bibtex-pop-next'." 2561Generic function used by `bibtex-pop-previous' and `bibtex-pop-next'."
2627 (bibtex-find-text) 2562 ;; parse current field
2628 (save-excursion 2563 (let* ((bounds (bibtex-enclosing-field t))
2629 ;; parse current field 2564 (start-old-field (bibtex-start-of-field bounds))
2630 (bibtex-inside-field) 2565 (start-old-text (bibtex-start-of-text-in-field bounds))
2631 (let* ((case-fold-search t) 2566 (end-old-text (bibtex-end-of-text-in-field bounds))
2632 (bounds (bibtex-enclosing-field)) 2567 (field-name (bibtex-name-in-field bounds t))
2633 (start-old-text (bibtex-start-of-text-in-field bounds)) 2568 failure)
2634 (stop-old-text (bibtex-end-of-text-in-field bounds)) 2569 (save-excursion
2635 (field-name (bibtex-name-in-field bounds t)))
2636 ;; if executed several times in a row, start each search where 2570 ;; if executed several times in a row, start each search where
2637 ;; the last one was finished 2571 ;; the last one was finished
2638 (unless (eq last-command 'bibtex-pop) 2572 (cond ((eq last-command 'bibtex-pop)
2639 (bibtex-enclosing-entry-maybe-empty-head) 2573 (goto-char (if (eq direction 'previous)
2640 (setq bibtex-pop-previous-search-point (match-beginning 0) 2574 bibtex-pop-previous-search-point
2641 bibtex-pop-next-search-point (point))) 2575 bibtex-pop-next-search-point)))
2642 (if (eq direction 'previous) 2576 ((eq direction 'previous)
2643 (goto-char bibtex-pop-previous-search-point) 2577 (bibtex-beginning-of-entry))
2644 (goto-char bibtex-pop-next-search-point)) 2578 (t (bibtex-end-of-entry)))
2645 ;; Now search for arg'th previous/next similar field 2579 ;; Search for arg'th previous/next similar field
2646 (let (bounds failure new-text) 2580 (while (and (not failure)
2647 (while (and (not failure) 2581 (>= (setq arg (1- arg)) 0))
2648 (> arg 0)) 2582 ;; The search of BibTeX fields is not bounded by entry boundaries
2649 (cond ((eq direction 'previous) 2583 (if (eq direction 'previous)
2650 (if (setq bounds (bibtex-search-backward-field field-name)) 2584 (if (setq bounds (bibtex-search-backward-field field-name))
2651 (goto-char (bibtex-start-of-field bounds)) 2585 (goto-char (bibtex-start-of-field bounds))
2652 (setq failure t))) 2586 (setq failure t))
2653 ((eq direction 'next) 2587 (if (setq bounds (bibtex-search-forward-field field-name))
2654 (if (setq bounds (bibtex-search-forward-field field-name)) 2588 (goto-char (bibtex-end-of-field bounds))
2655 (goto-char (bibtex-end-of-field bounds)) 2589 (setq failure t))))
2656 (setq failure t)))) 2590 (if failure
2657 (setq arg (- arg 1))) 2591 (error "No %s matching BibTeX field"
2658 (if failure 2592 (if (eq direction 'previous) "previous" "next"))
2659 (error "No %s matching BibTeX field" 2593 ;; Found a matching field. Remember boundaries.
2660 (if (eq direction 'previous) "previous" "next")) 2594 (let ((new-text (bibtex-text-in-field-bounds bounds))
2661 ;; Found a matching field. Remember boundaries. 2595 (nbeg (copy-marker (bibtex-start-of-field bounds)))
2662 (setq bibtex-pop-previous-search-point (bibtex-start-of-field bounds) 2596 (nend (copy-marker (bibtex-end-of-field bounds))))
2663 bibtex-pop-next-search-point (bibtex-end-of-field bounds) 2597 (bibtex-flash-head "From: ")
2664 new-text (bibtex-text-in-field-bounds bounds))
2665 (bibtex-flash-head)
2666 ;; Go back to where we started, delete old text, and pop new. 2598 ;; Go back to where we started, delete old text, and pop new.
2667 (goto-char stop-old-text) 2599 (goto-char end-old-text)
2668 (delete-region start-old-text stop-old-text) 2600 (delete-region start-old-text end-old-text)
2669 (insert new-text))))) 2601 (if (= nbeg start-old-field)
2670 (bibtex-find-text) 2602 (insert (bibtex-field-left-delimiter)
2603 (bibtex-field-right-delimiter))
2604 (insert new-text))
2605 (setq bibtex-pop-previous-search-point (marker-position nbeg)
2606 bibtex-pop-next-search-point (marker-position nend))))))
2607 (bibtex-find-text nil nil nil t)
2671 (setq this-command 'bibtex-pop)) 2608 (setq this-command 'bibtex-pop))
2672 2609
2673(defun bibtex-beginning-of-field () 2610(defun bibtex-beginning-of-field ()
@@ -2846,6 +2783,7 @@ if that value is non-nil.
2846 (list (list nil bibtex-entry-head bibtex-key-in-head)) 2783 (list (list nil bibtex-entry-head bibtex-key-in-head))
2847 imenu-case-fold-search t) 2784 imenu-case-fold-search t)
2848 (make-local-variable 'choose-completion-string-functions) 2785 (make-local-variable 'choose-completion-string-functions)
2786 (make-local-variable 'completion-ignore-case)
2849 ;; XEmacs needs easy-menu-add, Emacs does not care 2787 ;; XEmacs needs easy-menu-add, Emacs does not care
2850 (easy-menu-add bibtex-edit-menu) 2788 (easy-menu-add bibtex-edit-menu)
2851 (easy-menu-add bibtex-entry-menu) 2789 (easy-menu-add bibtex-entry-menu)
@@ -2861,7 +2799,7 @@ and `bibtex-user-optional-fields'."
2861 (let ((e (assoc-string entry-type bibtex-entry-field-alist t)) 2799 (let ((e (assoc-string entry-type bibtex-entry-field-alist t))
2862 required optional) 2800 required optional)
2863 (unless e 2801 (unless e
2864 (error "BibTeX entry type %s not defined" entry-type)) 2802 (error "Fields for BibTeX entry type %s not defined" entry-type))
2865 (if (and (member-ignore-case entry-type bibtex-include-OPTcrossref) 2803 (if (and (member-ignore-case entry-type bibtex-include-OPTcrossref)
2866 (nth 2 e)) 2804 (nth 2 e))
2867 (setq required (nth 0 (nth 2 e)) 2805 (setq required (nth 0 (nth 2 e))
@@ -2918,10 +2856,11 @@ according to `bibtex-field-list', but are not yet present."
2918 (save-excursion 2856 (save-excursion
2919 (bibtex-beginning-of-entry) 2857 (bibtex-beginning-of-entry)
2920 ;; For inserting new fields, we use the fact that 2858 ;; For inserting new fields, we use the fact that
2921 ;; bibtex-parse-entry moves point to the end of the last field. 2859 ;; `bibtex-parse-entry' moves point to the end of the last field.
2922 (let* ((fields-alist (bibtex-parse-entry)) 2860 (let* ((fields-alist (bibtex-parse-entry))
2923 (field-list (bibtex-field-list 2861 (field-list (bibtex-field-list
2924 (cdr (assoc "=type=" fields-alist))))) 2862 (cdr (assoc "=type=" fields-alist)))))
2863 (skip-chars-backward " \t\n")
2925 (dolist (field (car field-list)) 2864 (dolist (field (car field-list))
2926 (unless (assoc-string (car field) fields-alist t) 2865 (unless (assoc-string (car field) fields-alist t)
2927 (bibtex-make-field field))) 2866 (bibtex-make-field field)))
@@ -2964,6 +2903,7 @@ entry (for example, the year parts of the keys)."
2964 (key (bibtex-key-in-head)) 2903 (key (bibtex-key-in-head))
2965 (key-end (match-end bibtex-key-in-head)) 2904 (key-end (match-end bibtex-key-in-head))
2966 (case-fold-search t) 2905 (case-fold-search t)
2906 (bibtex-sort-ignore-string-entries t)
2967 tmp other-key other bounds) 2907 tmp other-key other bounds)
2968 ;; The fields we want to change start right after the key. 2908 ;; The fields we want to change start right after the key.
2969 (goto-char key-end) 2909 (goto-char key-end)
@@ -3016,28 +2956,28 @@ entry (for example, the year parts of the keys)."
3016 (while (re-search-backward (regexp-quote other-suffix) key-end 'move) 2956 (while (re-search-backward (regexp-quote other-suffix) key-end 'move)
3017 (replace-match suffix))))))) 2957 (replace-match suffix)))))))
3018 2958
3019(defun bibtex-print-help-message () 2959(defun bibtex-print-help-message (&optional field comma)
3020 "Print helpful information about current field in current BibTeX entry." 2960 "Print helpful information about current FIELD in current BibTeX entry.
3021 (interactive) 2961Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
3022 (let* ((case-fold-search t) 2962interactive calls."
3023 (type (save-excursion 2963 (interactive (list nil t))
3024 (bibtex-beginning-of-entry) 2964 (unless field (setq field (car (bibtex-find-text-internal nil nil comma))))
3025 (looking-at bibtex-any-entry-maybe-empty-head) 2965 (if (string-match "@" field)
3026 (bibtex-type-in-head))) 2966 (cond ((bibtex-string= field "@string")
3027 comment field-list) 2967 (message "String definition"))
3028 (cond ((bibtex-string= type "string") 2968 ((bibtex-string= field "@preamble")
3029 (message "String definition")) 2969 (message "Preamble definition"))
3030 ((bibtex-string= type "preamble") 2970 (t (message "Entry key")))
3031 (message "Preamble definition")) 2971 (let* ((case-fold-search t)
3032 (t 2972 (type (save-excursion
3033 (setq field-list (bibtex-field-list type) 2973 (bibtex-beginning-of-entry)
3034 comment 2974 (looking-at bibtex-entry-maybe-empty-head)
3035 (assoc-string (bibtex-name-in-field (bibtex-enclosing-field) t) 2975 (bibtex-type-in-head)))
3036 (append (car field-list) (cdr field-list)) 2976 (field-list (bibtex-field-list type))
3037 t)) 2977 (comment (assoc-string field (append (car field-list)
3038 (if comment 2978 (cdr field-list)) t)))
3039 (message "%s" (nth 1 comment)) 2979 (if comment (message "%s" (nth 1 comment))
3040 (message "No comment available")))))) 2980 (message "No comment available")))))
3041 2981
3042(defun bibtex-make-field (field &optional move interactive) 2982(defun bibtex-make-field (field &optional move interactive)
3043 "Make a field named FIELD in current BibTeX entry. 2983 "Make a field named FIELD in current BibTeX entry.
@@ -3052,7 +2992,8 @@ MOVE and INTERACTIVE are t when called interactively."
3052 (list (let ((completion-ignore-case t) 2992 (list (let ((completion-ignore-case t)
3053 (field-list (bibtex-field-list 2993 (field-list (bibtex-field-list
3054 (save-excursion 2994 (save-excursion
3055 (bibtex-enclosing-entry-maybe-empty-head) 2995 (bibtex-beginning-of-entry)
2996 (looking-at bibtex-any-entry-maybe-empty-head)
3056 (bibtex-type-in-head))))) 2997 (bibtex-type-in-head)))))
3057 (completing-read "BibTeX field name: " 2998 (completing-read "BibTeX field name: "
3058 (append (car field-list) (cdr field-list)) 2999 (append (car field-list) (cdr field-list))
@@ -3081,8 +3022,9 @@ MOVE and INTERACTIVE are t when called interactively."
3081 (t (concat (bibtex-field-left-delimiter) 3022 (t (concat (bibtex-field-left-delimiter)
3082 (bibtex-field-right-delimiter)))))) 3023 (bibtex-field-right-delimiter))))))
3083 (when interactive 3024 (when interactive
3084 (forward-char -1) 3025 ;; (bibtex-find-text nil nil bibtex-help-message)
3085 (bibtex-print-help-message))) 3026 (if (memq (preceding-char) '(?} ?\")) (forward-char -1))
3027 (if bibtex-help-message (bibtex-print-help-message (car field)))))
3086 3028
3087(defun bibtex-beginning-of-entry () 3029(defun bibtex-beginning-of-entry ()
3088 "Move to beginning of BibTeX entry (beginning of line). 3030 "Move to beginning of BibTeX entry (beginning of line).
@@ -3103,28 +3045,19 @@ of the previous entry. Do not move if ahead of first entry.
3103Return the new location of point." 3045Return the new location of point."
3104 (interactive) 3046 (interactive)
3105 (let ((case-fold-search t) 3047 (let ((case-fold-search t)
3106 (org (point)) 3048 (pnt (point))
3107 (pnt (bibtex-beginning-of-entry)) 3049 (_ (bibtex-beginning-of-entry))
3108 err bounds) 3050 (bounds (bibtex-valid-entry t)))
3109 (cond ((looking-at bibtex-entry-type-whitespace) 3051 (cond (bounds (goto-char (cdr bounds))) ; regular entry
3110 (bibtex-search-entry t nil t) 3052 ;; @String or @Preamble
3111 (unless (equal (match-beginning 0) pnt) 3053 ((setq bounds (or (bibtex-parse-string t) (bibtex-parse-preamble)))
3112 (setq err t)))
3113 ;; @String
3114 ((setq bounds (bibtex-parse-string))
3115 (goto-char (bibtex-end-of-string bounds))) 3054 (goto-char (bibtex-end-of-string bounds)))
3116 ;; @Preamble 3055 ((looking-at bibtex-any-valid-entry-type)
3117 ((bibtex-preamble-prefix t) 3056 ;; Parsing of entry failed
3118 (unless (bibtex-parse-string-postfix) ;; @String postfix OK 3057 (error "Syntactically incorrect BibTeX entry starts here."))
3119 (setq err t))) 3058 (t (if (interactive-p) (message "Not on a known BibTeX entry."))
3120 (t 3059 (goto-char pnt)))
3121 (if (interactive-p) 3060 (point)))
3122 (message "Not on a known BibTeX entry."))
3123 (goto-char org)))
3124 (when err
3125 (goto-char pnt)
3126 (error "Syntactically incorrect BibTeX entry starts here")))
3127 (point))
3128 3061
3129(defun bibtex-goto-line (arg) 3062(defun bibtex-goto-line (arg)
3130 "Goto line ARG, counting from beginning of (narrowed) buffer." 3063 "Goto line ARG, counting from beginning of (narrowed) buffer."
@@ -3188,7 +3121,7 @@ If mark is active count entries in region, if not in whole buffer."
3188 (interactive) 3121 (interactive)
3189 (let ((bounds (save-excursion 3122 (let ((bounds (save-excursion
3190 (bibtex-beginning-of-entry) 3123 (bibtex-beginning-of-entry)
3191 (bibtex-search-forward-field "abstract")))) 3124 (bibtex-search-forward-field "abstract" t))))
3192 (if bounds 3125 (if bounds
3193 (ispell-region (bibtex-start-of-text-in-field bounds) 3126 (ispell-region (bibtex-start-of-text-in-field bounds)
3194 (bibtex-end-of-text-in-field bounds)) 3127 (bibtex-end-of-text-in-field bounds))
@@ -3216,7 +3149,7 @@ of the head of the entry found. Return nil if no entry found."
3216 ;; Don't search CROSSREF-KEY if we don't need it. 3149 ;; Don't search CROSSREF-KEY if we don't need it.
3217 (if (eq bibtex-maintain-sorted-entries 'crossref) 3150 (if (eq bibtex-maintain-sorted-entries 'crossref)
3218 (let ((bounds (bibtex-search-forward-field 3151 (let ((bounds (bibtex-search-forward-field
3219 "\\(OPT\\)?crossref"))) 3152 "\\(OPT\\)?crossref" t)))
3220 (list key 3153 (list key
3221 (if bounds (bibtex-text-in-field-bounds bounds t)) 3154 (if bounds (bibtex-text-in-field-bounds bounds t))
3222 entry-name)) 3155 entry-name))
@@ -3283,7 +3216,7 @@ entry and SPLIT is t."
3283 (let ((crossref-key 3216 (let ((crossref-key
3284 (save-excursion 3217 (save-excursion
3285 (bibtex-beginning-of-entry) 3218 (bibtex-beginning-of-entry)
3286 (let ((bounds (bibtex-search-forward-field "crossref"))) 3219 (let ((bounds (bibtex-search-forward-field "crossref" t)))
3287 (if bounds 3220 (if bounds
3288 (bibtex-text-in-field-bounds bounds t)))))) 3221 (bibtex-text-in-field-bounds bounds t))))))
3289 (list (bibtex-read-key "Find crossref key: " crossref-key t) 3222 (list (bibtex-read-key "Find crossref key: " crossref-key t)
@@ -3429,40 +3362,38 @@ Return t if test was successful, nil otherwise."
3429 error-list syntax-error) 3362 error-list syntax-error)
3430 (save-excursion 3363 (save-excursion
3431 (save-restriction 3364 (save-restriction
3432 (if mark-active 3365 (if mark-active (narrow-to-region (region-beginning) (region-end)))
3433 (narrow-to-region (region-beginning) (region-end)))
3434 3366
3435 ;; looking if entries fit syntactical structure 3367 ;; Check syntactical structure of entries
3436 (goto-char (point-min)) 3368 (goto-char (point-min))
3437 (bibtex-progress-message "Checking syntactical structure") 3369 (bibtex-progress-message "Checking syntactical structure")
3438 (let (bibtex-sort-ignore-string-entries) 3370 (let (bounds end)
3439 (while (re-search-forward "^[ \t]*@" nil t) 3371 (while (setq end (re-search-forward "^[ \t]*@" nil t))
3440 (bibtex-progress-message) 3372 (bibtex-progress-message)
3441 (forward-char -1) 3373 (goto-char (match-beginning 0))
3442 (let ((pnt (point))) 3374 (cond ((setq bounds (bibtex-valid-entry))
3443 (if (not (looking-at bibtex-entry-type-str)) 3375 (goto-char (cdr bounds)))
3444 (forward-char) 3376 ((setq bounds (or (bibtex-parse-string)
3445 (bibtex-skip-to-valid-entry) 3377 (bibtex-parse-preamble)))
3446 (if (equal (point) pnt) 3378 (goto-char (bibtex-end-of-string bounds)))
3447 (forward-char) 3379 ((looking-at bibtex-any-valid-entry-type)
3448 (goto-char pnt) 3380 (push (cons (bibtex-current-line)
3449 (push (cons (bibtex-current-line) 3381 "Syntax error (check esp. commas, braces, and quotes)")
3450 "Syntax error (check esp. commas, braces, and quotes)") 3382 error-list)
3451 error-list) 3383 (goto-char (match-end 0)))
3452 (forward-char)))))) 3384 (t (goto-char end)))))
3453 (bibtex-progress-message 'done) 3385 (bibtex-progress-message 'done)
3454 3386
3455 (if error-list 3387 (if error-list
3456 ;; proceed only if there were no syntax errors. 3388 ;; Continue only if there were no syntax errors.
3457 (setq syntax-error t) 3389 (setq syntax-error t)
3458 3390
3459 ;; looking for duplicate keys and correct sort order 3391 ;; Check for duplicate keys and correct sort order
3460 (let (previous current key-list) 3392 (let (previous current key-list)
3461 (bibtex-progress-message "Checking for duplicate keys") 3393 (bibtex-progress-message "Checking for duplicate keys")
3462 (bibtex-map-entries 3394 (bibtex-map-entries
3463 (lambda (key beg end) 3395 (lambda (key beg end)
3464 (bibtex-progress-message) 3396 (bibtex-progress-message)
3465 (goto-char beg)
3466 (setq current (bibtex-entry-index)) 3397 (setq current (bibtex-entry-index))
3467 (cond ((not previous)) 3398 (cond ((not previous))
3468 ((member key key-list) 3399 ((member key key-list)
@@ -3498,18 +3429,13 @@ Return t if test was successful, nil otherwise."
3498 (bibtex-map-entries 3429 (bibtex-map-entries
3499 (lambda (key beg end) 3430 (lambda (key beg end)
3500 (bibtex-progress-message) 3431 (bibtex-progress-message)
3501 (let* ((entry-list (progn 3432 (let* ((entry-list (assoc-string (bibtex-type-in-head)
3502 (goto-char beg) 3433 bibtex-entry-field-alist t))
3503 (bibtex-search-entry nil end)
3504 (assoc-string (bibtex-type-in-head)
3505 bibtex-entry-field-alist t)))
3506 (req (copy-sequence (elt (elt entry-list 1) 0))) 3434 (req (copy-sequence (elt (elt entry-list 1) 0)))
3507 (creq (copy-sequence (elt (elt entry-list 2) 0))) 3435 (creq (copy-sequence (elt (elt entry-list 2) 0)))
3508 crossref-there bounds alt-there field) 3436 crossref-there bounds alt-there field)
3509 (goto-char beg) 3437 (bibtex-beginning-first-field beg)
3510 (while (setq bounds (bibtex-search-forward-field 3438 (while (setq bounds (bibtex-parse-field))
3511 bibtex-field-name end))
3512 (goto-char (bibtex-start-of-text-in-field bounds))
3513 (let ((field-name (bibtex-name-in-field bounds))) 3439 (let ((field-name (bibtex-name-in-field bounds)))
3514 (if (and (bibtex-string= field-name "month") 3440 (if (and (bibtex-string= field-name "month")
3515 ;; Check only abbreviated month fields. 3441 ;; Check only abbreviated month fields.
@@ -3521,18 +3447,19 @@ Return t if test was successful, nil otherwise."
3521 (push (cons (bibtex-current-line) 3447 (push (cons (bibtex-current-line)
3522 "Questionable month field") 3448 "Questionable month field")
3523 error-list)) 3449 error-list))
3524 (setq field (assoc-string field-name req t)) 3450 (setq field (assoc-string field-name req t)
3451 req (delete field req)
3452 creq (delete (assoc-string field-name creq t) creq))
3525 (if (nth 3 field) 3453 (if (nth 3 field)
3526 (if alt-there (push (cons (bibtex-current-line) 3454 (if alt-there
3527 "More than one non-empty alternative") 3455 (push (cons (bibtex-current-line)
3528 error-list) 3456 "More than one non-empty alternative")
3457 error-list)
3529 (setq alt-there t))) 3458 (setq alt-there t)))
3530 (setq req (delete field req)
3531 creq (delete (assoc-string field-name creq t) creq))
3532 (if (bibtex-string= field-name "crossref") 3459 (if (bibtex-string= field-name "crossref")
3533 (setq crossref-there t)))) 3460 (setq crossref-there t)))
3534 (if crossref-there 3461 (goto-char (bibtex-end-of-field bounds)))
3535 (setq req creq)) 3462 (if crossref-there (setq req creq))
3536 (let (alt) 3463 (let (alt)
3537 (dolist (field req) 3464 (dolist (field req)
3538 (if (nth 3 field) 3465 (if (nth 3 field)
@@ -3573,11 +3500,10 @@ Return t if test was successful, nil otherwise."
3573 (toggle-read-only 1) 3500 (toggle-read-only 1)
3574 (goto-line 3)) ; first error message 3501 (goto-line 3)) ; first error message
3575 (display-buffer err-buf) 3502 (display-buffer err-buf)
3576 ;; return nil 3503 nil) ; return `nil' (i.e., buffer is invalid)
3577 nil)
3578 (message "%s is syntactically correct" 3504 (message "%s is syntactically correct"
3579 (if mark-active "Region" "Buffer")) 3505 (if mark-active "Region" "Buffer"))
3580 t))) 3506 t))) ; return `t' (i.e., buffer is valid)
3581 3507
3582(defun bibtex-validate-globally (&optional strings) 3508(defun bibtex-validate-globally (&optional strings)
3583 "Check for duplicate keys in `bibtex-files'. 3509 "Check for duplicate keys in `bibtex-files'.
@@ -3631,37 +3557,41 @@ Return t if test was successful, nil otherwise."
3631 (toggle-read-only 1) 3557 (toggle-read-only 1)
3632 (goto-line 3)) ; first error message 3558 (goto-line 3)) ; first error message
3633 (display-buffer err-buf) 3559 (display-buffer err-buf)
3634 ;; return nil 3560 nil) ; return `nil' (i.e., buffer is invalid)
3635 nil)
3636 (message "No duplicate keys.") 3561 (message "No duplicate keys.")
3637 t))) 3562 t))) ; return `t' (i.e., buffer is valid)
3638 3563
3639(defun bibtex-next-field (begin) 3564(defun bibtex-next-field (begin &optional comma)
3640 "Move point to end of text of next BibTeX field. 3565 "Move point to end of text of next BibTeX field or entry head.
3641With prefix BEGIN non-nil, move point to its beginning." 3566With prefix BEGIN non-nil, move point to its beginning. Optional arg COMMA
3642 (interactive "P") 3567is as in `bibtex-enclosing-field'. It is t for interactive calls."
3643 (bibtex-inside-field) 3568 (interactive (list current-prefix-arg t))
3644 (let ((start (point))) 3569 (let ((bounds (bibtex-find-text-internal t nil comma))
3645 (condition-case () 3570 end-of-entry)
3646 (let ((bounds (bibtex-enclosing-field))) 3571 (if (not bounds)
3647 (goto-char (bibtex-end-of-field bounds)) 3572 (setq end-of-entry t)
3648 (forward-char 2)) 3573 (goto-char (nth 3 bounds))
3649 (error 3574 (if (assoc-string (car bounds) '("@String" "@Preamble") t)
3650 (goto-char start) 3575 (setq end-of-entry t)
3651 (end-of-line) 3576 ;; BibTeX key or field
3652 (forward-char)))) 3577 (if (looking-at ",[ \t\n]*") (goto-char (match-end 0)))
3653 (bibtex-find-text begin nil bibtex-help-message)) 3578 ;; end of entry
3654 3579 (if (looking-at "[)}][ \t\n]*") (setq end-of-entry t))))
3655(defun bibtex-find-text (&optional begin noerror help) 3580 (if (and end-of-entry
3656 "Move point to end of text of current BibTeX field. 3581 (re-search-forward bibtex-any-entry-maybe-empty-head nil t))
3582 (goto-char (match-beginning 0)))
3583 (bibtex-find-text begin nil bibtex-help-message)))
3584
3585(defun bibtex-find-text (&optional begin noerror help comma)
3586 "Move point to end of text of current BibTeX field or entry head.
3657With optional prefix BEGIN non-nil, move point to its beginning. 3587With optional prefix BEGIN non-nil, move point to its beginning.
3658Unless NOERROR is non-nil, an error is signaled if point is not 3588Unless NOERROR is non-nil, an error is signaled if point is not
3659on a BibTeX field. If optional arg HELP is non-nil print help message. 3589on a BibTeX field. If optional arg HELP is non-nil print help message.
3660When called interactively, the value of HELP is `bibtex-help-message'." 3590When called interactively, the value of HELP is `bibtex-help-message'.
3661 (interactive (list current-prefix-arg nil bibtex-help-message)) 3591Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
3662 (let ((pnt (point)) 3592interactive calls."
3663 (bounds (bibtex-find-text-internal))) 3593 (interactive (list current-prefix-arg nil bibtex-help-message t))
3664 (beginning-of-line) 3594 (let ((bounds (bibtex-find-text-internal t nil comma)))
3665 (cond (bounds 3595 (cond (bounds
3666 (if begin 3596 (if begin
3667 (progn (goto-char (nth 1 bounds)) 3597 (progn (goto-char (nth 1 bounds))
@@ -3670,72 +3600,88 @@ When called interactively, the value of HELP is `bibtex-help-message'."
3670 (goto-char (nth 2 bounds)) 3600 (goto-char (nth 2 bounds))
3671 (if (memq (preceding-char) '(?} ?\")) 3601 (if (memq (preceding-char) '(?} ?\"))
3672 (forward-char -1))) 3602 (forward-char -1)))
3673 (if help (bibtex-print-help-message))) 3603 (if help (bibtex-print-help-message (car bounds))))
3674 ((looking-at bibtex-entry-maybe-empty-head) 3604 ((not noerror) (error "Not on BibTeX field")))))
3675 (goto-char (if begin
3676 (match-beginning bibtex-key-in-head)
3677 (match-end 0))))
3678 (t
3679 (goto-char pnt)
3680 (unless noerror (error "Not on BibTeX field"))))))
3681 3605
3682(defun bibtex-find-text-internal (&optional noerror subfield) 3606(defun bibtex-find-text-internal (&optional noerror subfield comma)
3683 "Find text part of current BibTeX field, @String or @Preamble. 3607 "Find text part of current BibTeX field or entry head.
3684Return list (NAME START END) with field name, start and end of text 3608Return list (NAME START-TEXT END-TEXT END) with field or entry name,
3685or nil if not found. 3609start and end of text and end of field or entry head, or nil if not found.
3686If optional arg NOERROR is non-nil, an error message is suppressed if text 3610If optional arg NOERROR is non-nil, an error message is suppressed if text
3687is not found. If optional arg SUBFIELD is non-nil START and END correspond 3611is not found. If optional arg SUBFIELD is non-nil START-TEXT and END-TEXT
3688to the current subfield delimited by #." 3612correspond to the current subfield delimited by #.
3613Optional arg COMMA is as in `bibtex-enclosing-field'."
3689 (save-excursion 3614 (save-excursion
3690 (let ((pnt (point)) 3615 (let ((pnt (point))
3691 (_ (bibtex-inside-field)) 3616 (bounds (bibtex-enclosing-field comma t))
3692 (bounds (bibtex-enclosing-field t))
3693 (case-fold-search t) 3617 (case-fold-search t)
3694 (bibtex-string-empty-key t) 3618 name start-text end-text end failure done no-sub)
3695 name start end)
3696 (bibtex-beginning-of-entry) 3619 (bibtex-beginning-of-entry)
3697 (cond (bounds 3620 (cond (bounds
3698 (setq name (bibtex-name-in-field bounds t) 3621 (setq name (bibtex-name-in-field bounds t)
3699 start (bibtex-start-of-text-in-field bounds) 3622 start-text (bibtex-start-of-text-in-field bounds)
3700 end (bibtex-end-of-text-in-field bounds))) 3623 end-text (bibtex-end-of-text-in-field bounds)
3624 end (bibtex-end-of-field bounds)))
3701 ;; @String 3625 ;; @String
3702 ((setq bounds (bibtex-parse-string)) 3626 ((setq bounds (bibtex-parse-string t))
3703 (setq name "@String" ;; not a field name! 3627 (if (<= pnt (bibtex-end-of-string bounds))
3704 start (bibtex-start-of-text-in-string bounds) 3628 (setq name "@String" ;; not a field name!
3705 end (bibtex-end-of-text-in-string bounds))) 3629 start-text (bibtex-start-of-text-in-string bounds)
3630 end-text (bibtex-end-of-text-in-string bounds)
3631 end (bibtex-end-of-string bounds))
3632 (setq failure t)))
3706 ;; @Preamble 3633 ;; @Preamble
3707 ((and (bibtex-preamble-prefix t) 3634 ((setq bounds (bibtex-parse-preamble))
3708 (setq bounds (bibtex-parse-field-text))) 3635 (if (<= pnt (bibtex-end-of-string bounds))
3709 (setq name "@Preamble" ;; not a field name! 3636 (setq name "@Preamble" ;; not a field name!
3710 start (car bounds) 3637 start-text (bibtex-start-of-text-in-string bounds)
3711 end (nth 1 bounds))) 3638 end-text (bibtex-end-of-text-in-string bounds)
3712 (t (unless noerror (error "Not on BibTeX field")))) 3639 end (bibtex-end-of-string bounds))
3713 (when (and start end subfield) 3640 (setq failure t)))
3714 (goto-char start) 3641 ;; BibTeX head
3715 (let (done) 3642 ((looking-at bibtex-entry-maybe-empty-head)
3643 (goto-char (match-end 0))
3644 (if comma (save-match-data
3645 (re-search-forward "\\=[ \t\n]*," nil t)))
3646 (if (<= pnt (point))
3647 (setq name (match-string-no-properties bibtex-type-in-head)
3648 start-text (or (match-beginning bibtex-key-in-head)
3649 (match-end 0))
3650 end-text (or (match-end bibtex-key-in-head)
3651 (match-end 0))
3652 end end-text
3653 no-sub t) ;; subfields do not make sense
3654 (setq failure t)))
3655 (t (setq failure t)))
3656 (when (and subfield (not failure))
3657 (setq failure no-sub)
3658 (unless failure
3659 (goto-char start-text)
3716 (while (not done) 3660 (while (not done)
3717 (if (or (prog1 (looking-at bibtex-field-const) 3661 (if (or (prog1 (looking-at bibtex-field-const)
3718 (setq end (match-end 0))) 3662 (setq end-text (match-end 0)))
3719 (prog1 (setq bounds (bibtex-parse-field-string)) 3663 (prog1 (setq bounds (bibtex-parse-field-string))
3720 (setq end (cdr bounds)))) 3664 (setq end-text (cdr bounds))))
3721 (progn 3665 (progn
3722 (if (and (<= start pnt) (<= pnt end)) 3666 (if (and (<= start-text pnt) (<= pnt end-text))
3723 (setq done t) 3667 (setq done t)
3724 (goto-char end)) 3668 (goto-char end-text))
3725 (if (looking-at "[ \t\n]*#[ \t\n]*") 3669 (if (looking-at "[ \t\n]*#[ \t\n]*")
3726 (setq start (goto-char (match-end 0))))) 3670 (setq start-text (goto-char (match-end 0)))))
3727 (unless noerror (error "Not on text part of BibTeX field")) 3671 (setq done t failure t)))))
3728 (setq done t start nil end nil))))) 3672 (cond ((not failure)
3729 (if (and start end) 3673 (list name start-text end-text end))
3730 (list name start end))))) 3674 ((and no-sub (not noerror))
3731 3675 (error "Not on text part of BibTeX field"))
3732(defun bibtex-remove-OPT-or-ALT () 3676 ((not noerror) (error "Not on BibTeX field"))))))
3677
3678(defun bibtex-remove-OPT-or-ALT (&optional comma)
3733 "Remove the string starting optional/alternative fields. 3679 "Remove the string starting optional/alternative fields.
3734Align text and go thereafter to end of text." 3680Align text and go thereafter to end of text. Optional arg COMMA
3735 (interactive) 3681is as in `bibtex-enclosing-field'. It is t for interactive calls."
3736 (bibtex-inside-field) 3682 (interactive (list t))
3737 (let ((case-fold-search t) 3683 (let ((case-fold-search t)
3738 (bounds (bibtex-enclosing-field))) 3684 (bounds (bibtex-enclosing-field comma)))
3739 (save-excursion 3685 (save-excursion
3740 (goto-char (bibtex-start-of-name-in-field bounds)) 3686 (goto-char (bibtex-start-of-name-in-field bounds))
3741 (when (looking-at "OPT\\|ALT") 3687 (when (looking-at "OPT\\|ALT")
@@ -3751,14 +3697,14 @@ Align text and go thereafter to end of text."
3751 (delete-horizontal-space) 3697 (delete-horizontal-space)
3752 (if bibtex-align-at-equal-sign 3698 (if bibtex-align-at-equal-sign
3753 (insert " ") 3699 (insert " ")
3754 (indent-to-column bibtex-text-indentation)))) 3700 (indent-to-column bibtex-text-indentation))))))
3755 (bibtex-inside-field))) 3701
3756 3702(defun bibtex-remove-delimiters (&optional comma)
3757(defun bibtex-remove-delimiters () 3703 "Remove \"\" or {} around current BibTeX field text.
3758 "Remove \"\" or {} around current BibTeX field text." 3704Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
3759 (interactive) 3705interactive calls."
3760 ;; `bibtex-find-text-internal' issues an error message if bounds is nil. 3706 (interactive (list t))
3761 (let* ((bounds (bibtex-find-text-internal nil t)) 3707 (let* ((bounds (bibtex-find-text-internal nil t comma))
3762 (start (nth 1 bounds)) 3708 (start (nth 1 bounds))
3763 (end (nth 2 bounds))) 3709 (end (nth 2 bounds)))
3764 (if (memq (char-before end) '(?\} ?\")) 3710 (if (memq (char-before end) '(?\} ?\"))
@@ -3766,15 +3712,15 @@ Align text and go thereafter to end of text."
3766 (if (memq (char-after start) '(?\{ ?\")) 3712 (if (memq (char-after start) '(?\{ ?\"))
3767 (delete-region start (1+ start))))) 3713 (delete-region start (1+ start)))))
3768 3714
3769(defun bibtex-kill-field (&optional copy-only) 3715(defun bibtex-kill-field (&optional copy-only comma)
3770 "Kill the entire enclosing BibTeX field. 3716 "Kill the entire enclosing BibTeX field.
3771With prefix arg COPY-ONLY, copy the current field to `bibtex-field-kill-ring', 3717With prefix arg COPY-ONLY, copy the current field to `bibtex-field-kill-ring',
3772but do not actually kill it." 3718but do not actually kill it. Optional arg COMMA is as in
3773 (interactive "P") 3719`bibtex-enclosing-field'. It is t for interactive calls."
3720 (interactive (list current-prefix-arg t))
3774 (save-excursion 3721 (save-excursion
3775 (bibtex-inside-field)
3776 (let* ((case-fold-search t) 3722 (let* ((case-fold-search t)
3777 (bounds (bibtex-enclosing-field)) 3723 (bounds (bibtex-enclosing-field comma))
3778 (end (bibtex-end-of-field bounds)) 3724 (end (bibtex-end-of-field bounds))
3779 (beg (bibtex-start-of-field bounds))) 3725 (beg (bibtex-start-of-field bounds)))
3780 (goto-char end) 3726 (goto-char end)
@@ -3791,10 +3737,12 @@ but do not actually kill it."
3791 (delete-region beg end)))) 3737 (delete-region beg end))))
3792 (setq bibtex-last-kill-command 'field)) 3738 (setq bibtex-last-kill-command 'field))
3793 3739
3794(defun bibtex-copy-field-as-kill () 3740(defun bibtex-copy-field-as-kill (&optional comma)
3795 "Copy the BibTeX field at point to the kill ring." 3741 "Copy the BibTeX field at point to the kill ring.
3796 (interactive) 3742Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
3797 (bibtex-kill-field t)) 3743interactive calls."
3744 (interactive (list t))
3745 (bibtex-kill-field t comma))
3798 3746
3799(defun bibtex-kill-entry (&optional copy-only) 3747(defun bibtex-kill-entry (&optional copy-only)
3800 "Kill the entire enclosing BibTeX entry. 3748 "Kill the entire enclosing BibTeX entry.
@@ -3806,7 +3754,7 @@ but do not actually kill it."
3806 (beg (bibtex-beginning-of-entry)) 3754 (beg (bibtex-beginning-of-entry))
3807 (end (progn (bibtex-end-of-entry) 3755 (end (progn (bibtex-end-of-entry)
3808 (if (re-search-forward 3756 (if (re-search-forward
3809 bibtex-entry-maybe-empty-head nil 'move) 3757 bibtex-any-entry-maybe-empty-head nil 'move)
3810 (goto-char (match-beginning 0))) 3758 (goto-char (match-beginning 0)))
3811 (point)))) 3759 (point))))
3812 (push (buffer-substring-no-properties beg end) 3760 (push (buffer-substring-no-properties beg end)
@@ -3831,13 +3779,13 @@ More precisely, reinsert the field or entry killed or yanked most recently.
3831With argument N, reinsert the Nth most recently killed BibTeX item. 3779With argument N, reinsert the Nth most recently killed BibTeX item.
3832See also the command \\[bibtex-yank-pop]." 3780See also the command \\[bibtex-yank-pop]."
3833 (interactive "*p") 3781 (interactive "*p")
3834 (bibtex-insert-kill (1- n)) 3782 (bibtex-insert-kill (1- n) t)
3835 (setq this-command 'bibtex-yank)) 3783 (setq this-command 'bibtex-yank))
3836 3784
3837(defun bibtex-yank-pop (n) 3785(defun bibtex-yank-pop (n)
3838 "Replace just-yanked killed BibTeX item with a different item. 3786 "Replace just-yanked killed BibTeX item with a different item.
3839This command is allowed only immediately after a `bibtex-yank' or a 3787This command is allowed only immediately after a `bibtex-yank' or a
3840`bibtex-yank-pop'. At such a time, the region contains a reinserted 3788`bibtex-yank-pop'. In this case, the region contains a reinserted
3841previously killed BibTeX item. `bibtex-yank-pop' deletes that item 3789previously killed BibTeX item. `bibtex-yank-pop' deletes that item
3842and inserts in its place a different killed BibTeX item. 3790and inserts in its place a different killed BibTeX item.
3843 3791
@@ -3853,13 +3801,14 @@ comes the newest one."
3853 (setq this-command 'bibtex-yank) 3801 (setq this-command 'bibtex-yank)
3854 (let ((inhibit-read-only t)) 3802 (let ((inhibit-read-only t))
3855 (delete-region (point) (mark t)) 3803 (delete-region (point) (mark t))
3856 (bibtex-insert-kill n))) 3804 (bibtex-insert-kill n t)))
3857 3805
3858(defun bibtex-empty-field () 3806(defun bibtex-empty-field (&optional comma)
3859 "Delete the text part of the current field, replace with empty text." 3807 "Delete the text part of the current field, replace with empty text.
3860 (interactive) 3808Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
3861 (bibtex-inside-field) 3809interactive calls."
3862 (let ((bounds (bibtex-enclosing-field))) 3810 (interactive (list t))
3811 (let ((bounds (bibtex-enclosing-field comma)))
3863 (goto-char (bibtex-start-of-text-in-field bounds)) 3812 (goto-char (bibtex-start-of-text-in-field bounds))
3864 (delete-region (point) (bibtex-end-of-text-in-field bounds)) 3813 (delete-region (point) (bibtex-end-of-text-in-field bounds))
3865 (insert (bibtex-field-left-delimiter) 3814 (insert (bibtex-field-left-delimiter)
@@ -3960,7 +3909,7 @@ At end of the cleaning process, the functions in
3960 (if (and (listp bibtex-strings) 3909 (if (and (listp bibtex-strings)
3961 (not (assoc key bibtex-strings))) 3910 (not (assoc key bibtex-strings)))
3962 (push (cons key (bibtex-text-in-string 3911 (push (cons key (bibtex-text-in-string
3963 (save-excursion (bibtex-parse-string)) t)) 3912 (bibtex-parse-string) t))
3964 bibtex-strings))) 3913 bibtex-strings)))
3965 ;; We have a normal entry. 3914 ;; We have a normal entry.
3966 ((listp bibtex-reference-keys) 3915 ((listp bibtex-reference-keys)
@@ -3988,28 +3937,27 @@ At end of the cleaning process, the functions in
3988If JUSTIFY is non-nil justify as well. 3937If JUSTIFY is non-nil justify as well.
3989If optional arg MOVE is non-nil move point to end of field." 3938If optional arg MOVE is non-nil move point to end of field."
3990 (let ((end-field (copy-marker (bibtex-end-of-field bounds)))) 3939 (let ((end-field (copy-marker (bibtex-end-of-field bounds))))
3991 (goto-char (bibtex-start-of-field bounds)) 3940 (if (not justify)
3992 (if justify 3941 (goto-char (bibtex-start-of-text-in-field bounds))
3993 (progn 3942 (goto-char (bibtex-start-of-field bounds))
3994 (forward-char) 3943 (forward-char) ;; leading comma
3995 (bibtex-delete-whitespace) 3944 (bibtex-delete-whitespace)
3996 (open-line 1) 3945 (open-line 1)
3997 (forward-char) 3946 (forward-char)
3998 (indent-to-column (+ bibtex-entry-offset 3947 (indent-to-column (+ bibtex-entry-offset
3999 bibtex-field-indentation)) 3948 bibtex-field-indentation))
4000 (re-search-forward "[ \t\n]*=" end-field) 3949 (re-search-forward "[ \t\n]*=" end-field)
4001 (replace-match "=") 3950 (replace-match "=")
4002 (forward-char -1) 3951 (forward-char -1)
4003 (if bibtex-align-at-equal-sign 3952 (if bibtex-align-at-equal-sign
4004 (indent-to-column 3953 (indent-to-column
4005 (+ bibtex-entry-offset (- bibtex-text-indentation 2))) 3954 (+ bibtex-entry-offset (- bibtex-text-indentation 2)))
4006 (insert " ")) 3955 (insert " "))
4007 (forward-char) 3956 (forward-char)
4008 (bibtex-delete-whitespace) 3957 (bibtex-delete-whitespace)
4009 (if bibtex-align-at-equal-sign 3958 (if bibtex-align-at-equal-sign
4010 (insert " ") 3959 (insert " ")
4011 (indent-to-column bibtex-text-indentation))) 3960 (indent-to-column bibtex-text-indentation)))
4012 (re-search-forward "[ \t\n]*=[ \t\n]*" end-field))
4013 ;; Paragraphs within fields are not preserved. Bother? 3961 ;; Paragraphs within fields are not preserved. Bother?
4014 (fill-region-as-paragraph (line-beginning-position) end-field 3962 (fill-region-as-paragraph (line-beginning-position) end-field
4015 default-justification nil (point)) 3963 default-justification nil (point))
@@ -4017,14 +3965,13 @@ If optional arg MOVE is non-nil move point to end of field."
4017 3965
4018(defun bibtex-fill-field (&optional justify) 3966(defun bibtex-fill-field (&optional justify)
4019 "Like \\[fill-paragraph], but fill current BibTeX field. 3967 "Like \\[fill-paragraph], but fill current BibTeX field.
4020Optional prefix arg JUSTIFY non-nil means justify as well. 3968If optional prefix JUSTIFY is non-nil justify as well.
4021In BibTeX mode this function is bound to `fill-paragraph-function'." 3969In BibTeX mode this function is bound to `fill-paragraph-function'."
4022 (interactive "*P") 3970 (interactive "*P")
4023 (let ((pnt (copy-marker (point))) 3971 (let ((pnt (copy-marker (point)))
4024 (bounds (bibtex-enclosing-field))) 3972 (bounds (bibtex-enclosing-field t)))
4025 (when bounds 3973 (bibtex-fill-field-bounds bounds justify)
4026 (bibtex-fill-field-bounds bounds justify) 3974 (goto-char pnt)))
4027 (goto-char pnt))))
4028 3975
4029(defun bibtex-fill-entry () 3976(defun bibtex-fill-entry ()
4030 "Fill current BibTeX entry. 3977 "Fill current BibTeX entry.
@@ -4035,14 +3982,16 @@ If `bibtex-align-at-equal-sign' is non-nil, align equal signs, too."
4035 (interactive "*") 3982 (interactive "*")
4036 (let ((pnt (copy-marker (point))) 3983 (let ((pnt (copy-marker (point)))
4037 (end (copy-marker (bibtex-end-of-entry))) 3984 (end (copy-marker (bibtex-end-of-entry)))
3985 (beg (bibtex-beginning-of-entry)) ; move point
4038 bounds) 3986 bounds)
4039 (bibtex-beginning-of-entry)
4040 (bibtex-delete-whitespace) 3987 (bibtex-delete-whitespace)
4041 (indent-to-column bibtex-entry-offset) 3988 (indent-to-column bibtex-entry-offset)
4042 (while (setq bounds (bibtex-search-forward-field bibtex-field-name end)) 3989 (bibtex-beginning-first-field beg)
3990 (while (setq bounds (bibtex-parse-field))
4043 (bibtex-fill-field-bounds bounds t t)) 3991 (bibtex-fill-field-bounds bounds t t))
4044 (if (looking-at ",") 3992 (if (looking-at ",")
4045 (forward-char)) 3993 (forward-char))
3994 (skip-chars-backward " \t\n")
4046 (bibtex-delete-whitespace) 3995 (bibtex-delete-whitespace)
4047 (open-line 1) 3996 (open-line 1)
4048 (forward-char) 3997 (forward-char)
@@ -4115,8 +4064,7 @@ If mark is active reformat entries in region, if not in whole buffer."
4115 bibtex-autokey-edit-before-use) 4064 bibtex-autokey-edit-before-use)
4116 4065
4117 (save-restriction 4066 (save-restriction
4118 (narrow-to-region (if mark-active (region-beginning) (point-min)) 4067 (if mark-active (narrow-to-region (region-beginning) (region-end)))
4119 (if mark-active (region-end) (point-max)))
4120 (if (memq 'realign bibtex-entry-format) 4068 (if (memq 'realign bibtex-entry-format)
4121 (bibtex-realign)) 4069 (bibtex-realign))
4122 (bibtex-progress-message "Formatting" 1) 4070 (bibtex-progress-message "Formatting" 1)
@@ -4143,12 +4091,10 @@ entries from minibuffer."
4143 (message "Starting to validate buffer...") 4091 (message "Starting to validate buffer...")
4144 (sit-for 1 nil t) 4092 (sit-for 1 nil t)
4145 (bibtex-realign) 4093 (bibtex-realign)
4146 (message
4147 "If errors occur, correct them and call `bibtex-convert-alien' again")
4148 (sit-for 5 nil t)
4149 (deactivate-mark) ; So bibtex-validate works on the whole buffer. 4094 (deactivate-mark) ; So bibtex-validate works on the whole buffer.
4150 (when (let (bibtex-maintain-sorted-entries) 4095 (if (not (let (bibtex-maintain-sorted-entries)
4151 (bibtex-validate)) 4096 (bibtex-validate)))
4097 (message "Correct errors and call `bibtex-convert-alien' again")
4152 (message "Starting to reformat entries...") 4098 (message "Starting to reformat entries...")
4153 (sit-for 2 nil t) 4099 (sit-for 2 nil t)
4154 (bibtex-reformat read-options) 4100 (bibtex-reformat read-options)
@@ -4166,10 +4112,9 @@ An error is signaled if point is outside key or BibTeX field."
4166 (interactive) 4112 (interactive)
4167 (let ((pnt (point)) 4113 (let ((pnt (point))
4168 (case-fold-search t) 4114 (case-fold-search t)
4169 (bibtex-string-empty-key t)
4170 bounds name compl) 4115 bounds name compl)
4171 (save-excursion 4116 (save-excursion
4172 (if (and (setq bounds (bibtex-enclosing-field t)) 4117 (if (and (setq bounds (bibtex-enclosing-field nil t))
4173 (>= pnt (bibtex-start-of-text-in-field bounds)) 4118 (>= pnt (bibtex-start-of-text-in-field bounds))
4174 (<= pnt (bibtex-end-of-text-in-field bounds))) 4119 (<= pnt (bibtex-end-of-text-in-field bounds)))
4175 (setq name (bibtex-name-in-field bounds t) 4120 (setq name (bibtex-name-in-field bounds t)
@@ -4182,7 +4127,7 @@ An error is signaled if point is outside key or BibTeX field."
4182 ;; point is in other field 4127 ;; point is in other field
4183 (t (bibtex-strings)))) 4128 (t (bibtex-strings))))
4184 (bibtex-beginning-of-entry) 4129 (bibtex-beginning-of-entry)
4185 (cond ((setq bounds (bibtex-parse-string)) 4130 (cond ((setq bounds (bibtex-parse-string t))
4186 ;; point is inside a @String key 4131 ;; point is inside a @String key
4187 (cond ((and (>= pnt (nth 1 (car bounds))) 4132 (cond ((and (>= pnt (nth 1 (car bounds)))
4188 (<= pnt (nth 2 (car bounds)))) 4133 (<= pnt (nth 2 (car bounds))))
@@ -4192,11 +4137,10 @@ An error is signaled if point is outside key or BibTeX field."
4192 (<= pnt (bibtex-end-of-text-in-string bounds))) 4137 (<= pnt (bibtex-end-of-text-in-string bounds)))
4193 (setq compl (bibtex-strings))))) 4138 (setq compl (bibtex-strings)))))
4194 ;; point is inside a @Preamble field 4139 ;; point is inside a @Preamble field
4195 ((and (bibtex-preamble-prefix t) 4140 ((setq bounds (bibtex-parse-preamble))
4196 (setq bounds (bibtex-parse-field-text)) 4141 (if (and (>= pnt (bibtex-start-of-text-in-string bounds))
4197 (>= pnt (car bounds)) 4142 (<= pnt (bibtex-end-of-text-in-string bounds)))
4198 (<= pnt (nth 1 bounds))) 4143 (setq compl (bibtex-strings))))
4199 (setq compl (bibtex-strings)))
4200 ((and (looking-at bibtex-entry-maybe-empty-head) 4144 ((and (looking-at bibtex-entry-maybe-empty-head)
4201 ;; point is inside a key 4145 ;; point is inside a key
4202 (or (and (match-beginning bibtex-key-in-head) 4146 (or (and (match-beginning bibtex-key-in-head)
@@ -4209,41 +4153,53 @@ An error is signaled if point is outside key or BibTeX field."
4209 4153
4210 (cond ((eq compl 'key) 4154 (cond ((eq compl 'key)
4211 ;; key completion: no cleanup needed 4155 ;; key completion: no cleanup needed
4212 (let (completion-ignore-case) 4156 (setq choose-completion-string-functions nil
4213 (bibtex-complete-internal (bibtex-global-key-alist)))) 4157 completion-ignore-case nil)
4158 (bibtex-complete-internal (bibtex-global-key-alist)))
4214 4159
4215 ((eq compl 'crossref-key) 4160 ((eq compl 'crossref-key)
4216 ;; crossref key completion 4161 ;; crossref key completion
4217 (let (completion-ignore-case) 4162 ;;
4218 (setq choose-completion-string-functions 4163 ;; If we quit the *Completions* buffer without requesting
4219 (lambda (choice buffer mini-p base-size) 4164 ;; a completion, `choose-completion-string-functions' is still
4220 (let ((choose-completion-string-functions nil)) 4165 ;; non-nil. Therefore, `choose-completion-string-functions' is
4221 (choose-completion-string choice buffer base-size)) 4166 ;; always set (either to non-nil or nil) when a new completion
4222 (bibtex-complete-crossref-cleanup choice) 4167 ;; is requested.
4223 ;; return t (needed by choose-completion-string-functions) 4168 ;; Also, `choose-completion-delete-max-match' requires
4224 t)) 4169 ;; that we set `completion-ignore-case' (i.e., binding via `let'
4225 (bibtex-complete-crossref-cleanup (bibtex-complete-internal 4170 ;; is not sufficient).
4226 (bibtex-global-key-alist))))) 4171 (setq completion-ignore-case nil
4172 choose-completion-string-functions
4173 (lambda (choice buffer mini-p base-size)
4174 (setq choose-completion-string-functions nil)
4175 (choose-completion-string choice buffer base-size)
4176 (bibtex-complete-crossref-cleanup choice)
4177 t)) ; needed by choose-completion-string-functions
4178
4179 (bibtex-complete-crossref-cleanup (bibtex-complete-internal
4180 (bibtex-global-key-alist))))
4227 4181
4228 ((eq compl 'string) 4182 ((eq compl 'string)
4229 ;; string key completion: no cleanup needed 4183 ;; string key completion: no cleanup needed
4230 (let ((completion-ignore-case t)) 4184 (setq choose-completion-string-functions nil
4231 (bibtex-complete-internal bibtex-strings))) 4185 completion-ignore-case t)
4186 (bibtex-complete-internal bibtex-strings))
4232 4187
4233 (compl 4188 (compl
4234 ;; string completion 4189 ;; string completion
4235 (let ((completion-ignore-case t)) 4190 (setq completion-ignore-case t
4236 (setq choose-completion-string-functions 4191 choose-completion-string-functions
4237 `(lambda (choice buffer mini-p base-size) 4192 `(lambda (choice buffer mini-p base-size)
4238 (let ((choose-completion-string-functions nil)) 4193 (setq choose-completion-string-functions nil)
4239 (choose-completion-string choice buffer base-size)) 4194 (choose-completion-string choice buffer base-size)
4240 (bibtex-complete-string-cleanup choice ',compl) 4195 (bibtex-complete-string-cleanup choice ',compl)
4241 ;; return t (needed by choose-completion-string-functions) 4196 t)) ; needed by choose-completion-string-functions
4242 t)) 4197 (bibtex-complete-string-cleanup (bibtex-complete-internal compl)
4243 (bibtex-complete-string-cleanup (bibtex-complete-internal compl) 4198 compl))
4244 compl))) 4199
4245 4200 (t (setq choose-completion-string-functions nil
4246 (t (error "Point outside key or BibTeX field"))))) 4201 completion-ignore-case nil) ; default
4202 (error "Point outside key or BibTeX field")))))
4247 4203
4248(defun bibtex-Article () 4204(defun bibtex-Article ()
4249 "Insert a new BibTeX @Article entry; see also `bibtex-entry'." 4205 "Insert a new BibTeX @Article entry; see also `bibtex-entry'."
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index ce95c6f026f..48defb7d786 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -291,12 +291,13 @@ act as a paragraph-separator."
291 291
292(defun fill-single-word-nobreak-p () 292(defun fill-single-word-nobreak-p ()
293 "Don't break a line after the first or before the last word of a sentence." 293 "Don't break a line after the first or before the last word of a sentence."
294 (or (looking-at "[ \t]*\\sw+[ \t]*[.?!:][ \t]*$") 294 (or (looking-at (concat "[ \t]*\\sw+" "\\(?:" (sentence-end) "\\)"))
295 (save-excursion 295 (save-excursion
296 (skip-chars-backward " \t") 296 (skip-chars-backward " \t")
297 (and (/= (skip-syntax-backward "w") 0) 297 (and (/= (skip-syntax-backward "w") 0)
298 (/= (skip-chars-backward " \t") 0) 298 (/= (skip-chars-backward " \t") 0)
299 (/= (skip-chars-backward ".?!:") 0))))) 299 (/= (skip-chars-backward ".?!:") 0)
300 (looking-at (sentence-end))))))
300 301
301(defun fill-french-nobreak-p () 302(defun fill-french-nobreak-p ()
302 "Return nil if French style allows breaking the line at point. 303 "Return nil if French style allows breaking the line at point.
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index ac6afe45608..cc2d1eace59 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,11 @@
12006-01-02 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * url-handlers.el (url-retrieve-synchronously): Don't autoload.
4
5 * url.el (url-retrieve, url-retrieve-synchronously): Autoload.
6
7 * url-cache.el: Require `url'.
8
12005-12-27 Stefan Monnier <monnier@iro.umontreal.ca> 92005-12-27 Stefan Monnier <monnier@iro.umontreal.ca>
2 10
3 * url-cache.el (url-store-in-cache): Use save-current-buffer. 11 * url-cache.el (url-store-in-cache): Use save-current-buffer.
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index b8c2b063adc..5113ad0d7d9 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -1,7 +1,7 @@
1;;; url-cache.el --- Uniform Resource Locator retrieval tool 1;;; url-cache.el --- Uniform Resource Locator retrieval tool
2 2
3;; Copyright (C) 1996, 1997, 1998, 1999, 2004, 3;; Copyright (C) 1996, 1997, 1998, 1999, 2004,
4;; 2005 Free Software Foundation, Inc. 4;; 2005, 2006 Free Software Foundation, Inc.
5 5
6;; Keywords: comm, data, processes, hypermedia 6;; Keywords: comm, data, processes, hypermedia
7 7
@@ -26,6 +26,7 @@
26 26
27(require 'url-parse) 27(require 'url-parse)
28(require 'url-util) 28(require 'url-util)
29(require 'url) ;E.g. for url-configuration-directory.
29 30
30(defcustom url-cache-directory 31(defcustom url-cache-directory
31 (expand-file-name "cache" url-configuration-directory) 32 (expand-file-name "cache" url-configuration-directory)
diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el
index 1c9d1d9c0b1..0338eefd268 100644
--- a/lisp/url/url-handlers.el
+++ b/lisp/url/url-handlers.el
@@ -1,7 +1,7 @@
1;;; url-handlers.el --- file-name-handler stuff for URL loading 1;;; url-handlers.el --- file-name-handler stuff for URL loading
2 2
3;; Copyright (C) 1996, 1997, 1998, 1999, 2004, 3;; Copyright (C) 1996, 1997, 1998, 1999, 2004,
4;; 2005 Free Software Foundation, Inc. 4;; 2005, 2006 Free Software Foundation, Inc.
5 5
6;; Keywords: comm, data, processes, hypermedia 6;; Keywords: comm, data, processes, hypermedia
7 7
@@ -37,7 +37,6 @@
37;; after mm-dissect-buffer and defined in the same file. 37;; after mm-dissect-buffer and defined in the same file.
38;; The following are autoloaded instead of `require'd to avoid eagerly 38;; The following are autoloaded instead of `require'd to avoid eagerly
39;; loading all of URL when turning on url-handler-mode in the .emacs. 39;; loading all of URL when turning on url-handler-mode in the .emacs.
40(autoload 'url-retrieve-synchronously "url" "Retrieve url synchronously.")
41(autoload 'url-expand-file-name "url-expand" "Convert url to a fully specified url, and canonicalize it.") 40(autoload 'url-expand-file-name "url-expand" "Convert url to a fully specified url, and canonicalize it.")
42(autoload 'mm-dissect-buffer "mm-decode" "Dissect the current buffer and return a list of MIME handles.") 41(autoload 'mm-dissect-buffer "mm-decode" "Dissect the current buffer and return a list of MIME handles.")
43(autoload 'url-scheme-get-property "url-methods" "Get property of a URL SCHEME.") 42(autoload 'url-scheme-get-property "url-methods" "Get property of a URL SCHEME.")
diff --git a/lisp/url/url.el b/lisp/url/url.el
index 6d6540ac82a..f9d06010171 100644
--- a/lisp/url/url.el
+++ b/lisp/url/url.el
@@ -1,7 +1,7 @@
1;;; url.el --- Uniform Resource Locator retrieval tool 1;;; url.el --- Uniform Resource Locator retrieval tool
2 2
3;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004, 3;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004,
4;; 2005 Free Software Foundation, Inc. 4;; 2005, 2006 Free Software Foundation, Inc.
5 5
6;; Author: Bill Perry <wmperry@gnu.org> 6;; Author: Bill Perry <wmperry@gnu.org>
7;; Keywords: comm, data, processes, hypermedia 7;; Keywords: comm, data, processes, hypermedia
@@ -114,6 +114,7 @@ Emacs."
114;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 114;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
115;;; Retrieval functions 115;;; Retrieval functions
116;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 116;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
117;;;###autoload
117(defun url-retrieve (url callback &optional cbargs) 118(defun url-retrieve (url callback &optional cbargs)
118 "Retrieve URL asynchronously and call CALLBACK with CBARGS when finished. 119 "Retrieve URL asynchronously and call CALLBACK with CBARGS when finished.
119URL is either a string or a parsed URL. 120URL is either a string or a parsed URL.
@@ -155,6 +156,7 @@ already completed."
155 (url-history-update-url url (current-time))) 156 (url-history-update-url url (current-time)))
156 buffer)) 157 buffer))
157 158
159;;;###autoload
158(defun url-retrieve-synchronously (url) 160(defun url-retrieve-synchronously (url)
159 "Retrieve URL synchronously. 161 "Retrieve URL synchronously.
160Return the buffer containing the data, or nil if there are no data 162Return the buffer containing the data, or nil if there are no data
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 075ea879270..0036712fec4 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -39,9 +39,6 @@
39 39
40;;; Todo: 40;;; Todo:
41 41
42;; The xterm mouse escape codes are supposedly also supported by the
43;; Linux console, but I have not been able to verify this.
44
45;; Support multi-click -- somehow. 42;; Support multi-click -- somehow.
46 43
47;;; Code: 44;;; Code: