aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMiles Bader2005-01-16 03:40:12 +0000
committerMiles Bader2005-01-16 03:40:12 +0000
commit54c4c5465ff6dcf158fc47b5894a688ec356f900 (patch)
tree7fd504f98080bd7c498874d3662ef67086a09b66 /lisp
parentd570d39f949427c4a5041375529c3748d72c6e3c (diff)
parent42187e99f8adc31d93d027b9017160731aab8972 (diff)
downloademacs-54c4c5465ff6dcf158fc47b5894a688ec356f900.tar.gz
emacs-54c4c5465ff6dcf158fc47b5894a688ec356f900.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-2
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-83 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-84 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-3 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-4 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-5 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-6 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-11 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-12 Remove "-face" suffix from lazy-highlight face name * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-13 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-16 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-17 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-18 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-21 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-22 <no summary provided> * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-23 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-39 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-40 Fix regressions from latest reftex update * miles@gnu.org--gnu-2005/gnus--rel--5.10--base-0 tag of miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-82 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-1 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-2 Merge from miles@gnu.org--gnu-2004 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-3 Merge from emacs--cvs-trunk--0
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog559
-rw-r--r--lisp/add-log.el4
-rw-r--r--lisp/battery.el17
-rw-r--r--lisp/calc/calc-embed.el6
-rw-r--r--lisp/calc/calc-ext.el78
-rw-r--r--lisp/calc/calc-help.el18
-rw-r--r--lisp/calc/calc-mode.el11
-rw-r--r--lisp/calc/calc-prog.el51
-rw-r--r--lisp/calc/calc-sel.el3
-rw-r--r--lisp/calc/calc-units.el2
-rw-r--r--lisp/calc/calc-yank.el23
-rw-r--r--lisp/calc/calc.el370
-rw-r--r--lisp/cus-edit.el73
-rw-r--r--lisp/cus-face.el1
-rw-r--r--lisp/custom.el44
-rw-r--r--lisp/desktop.el127
-rw-r--r--lisp/ebuff-menu.el4
-rw-r--r--lisp/electric.el20
-rw-r--r--lisp/emacs-lisp/autoload.el4
-rw-r--r--lisp/emacs-lisp/elint.el2
-rw-r--r--lisp/emacs-lisp/find-func.el189
-rw-r--r--lisp/emacs-lisp/lisp-mnt.el7
-rw-r--r--lisp/emacs-lisp/lisp-mode.el3
-rw-r--r--lisp/emacs-lisp/re-builder.el8
-rw-r--r--lisp/facemenu.el113
-rw-r--r--lisp/files.el197
-rw-r--r--lisp/gnus/ChangeLog5
-rw-r--r--lisp/gnus/spam.el14
-rw-r--r--lisp/help-fns.el21
-rw-r--r--lisp/help-macro.el2
-rw-r--r--lisp/imenu.el18
-rw-r--r--lisp/info-look.el11
-rw-r--r--lisp/info.el57
-rw-r--r--lisp/isearch.el240
-rw-r--r--lisp/loadhist.el21
-rw-r--r--lisp/mail/mailabbrev.el24
-rw-r--r--lisp/mail/rmail.el305
-rw-r--r--lisp/man.el87
-rw-r--r--lisp/mouse.el64
-rw-r--r--lisp/progmodes/ebrowse.el18
-rw-r--r--lisp/progmodes/hideshow.el3
-rw-r--r--lisp/progmodes/perl-mode.el8
-rw-r--r--lisp/progmodes/sh-script.el82
-rw-r--r--lisp/replace.el53
-rw-r--r--lisp/simple.el28
-rw-r--r--lisp/startup.el6
-rw-r--r--lisp/textmodes/ispell.el51
-rw-r--r--lisp/textmodes/org.el599
-rw-r--r--lisp/textmodes/reftex-auc.el4
-rw-r--r--lisp/textmodes/reftex-cite.el147
-rw-r--r--lisp/textmodes/reftex-dcr.el4
-rw-r--r--lisp/textmodes/reftex-global.el4
-rw-r--r--lisp/textmodes/reftex-index.el45
-rw-r--r--lisp/textmodes/reftex-parse.el4
-rw-r--r--lisp/textmodes/reftex-ref.el97
-rw-r--r--lisp/textmodes/reftex-sel.el18
-rw-r--r--lisp/textmodes/reftex-toc.el5
-rw-r--r--lisp/textmodes/reftex-vars.el108
-rw-r--r--lisp/textmodes/reftex.el19
-rw-r--r--lisp/textmodes/sgml-mode.el52
-rw-r--r--lisp/toolbar/README2
-rw-r--r--lisp/toolbar/back_arrow.pbmbin0 -> 185 bytes
-rw-r--r--lisp/toolbar/back_arrow.xpm57
-rw-r--r--lisp/toolbar/fwd_arrow.pbmbin0 -> 185 bytes
-rw-r--r--lisp/toolbar/fwd_arrow.xpm70
-rw-r--r--lisp/toolbar/lc-back_arrow.xpm33
-rw-r--r--lisp/toolbar/lc-fwd_arrow.xpm32
-rw-r--r--lisp/type-break.el30
-rw-r--r--lisp/uniquify.el18
-rw-r--r--lisp/url/ChangeLog10
-rw-r--r--lisp/url/url-http.el4
-rw-r--r--lisp/url/url.el42
-rw-r--r--lisp/vc-arch.el6
-rw-r--r--lisp/vc-cvs.el4
-rw-r--r--lisp/vc-mcvs.el4
-rw-r--r--lisp/vc-svn.el9
-rw-r--r--lisp/vc.el22
-rw-r--r--lisp/woman.el3
-rw-r--r--lisp/xt-mouse.el52
79 files changed, 3326 insertions, 1230 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1df649e2d5b..fa3006178b1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,13 +1,558 @@
12005-01-01 Jay Belanger <belanger@truman.edu> 12005-01-15 Richard M. Stallman <rms@gnu.org>
2
3 * emacs-lisp/lisp-mnt.el (lm-with-file): Use Lisp mode in temp buffer.
4 In non-temp buffer, switch syntax table temporarily.
5
6 * emacs-lisp/lisp-mode.el (indent-pp-sexp): Doc fix.
7
8 * replace.el (occur-accumulate-lines, occur-engine): Avoid warnings.
9
10 * tar-mode.el (tar-extract): Bind buffer-undo-list to t.
11
12 * imenu.el (imenu--split-menu): Copy menulist before sorting.
13 (imenu--generic-function): Use START, not BEG, as pos of definition.
14
15 * simple.el (just-one-space): Argument specifies number of spaces.
16
17 * simple.el (eval-expression-print-format): Avoid warning
18 about edebug-active.
19
202005-01-15 "James R. Van Zandt" <jrvz@comcast.net> (Tiny change)
21
22 * progmodes/sh-script.el: Code copied from make-mode.el
23 with small changes,
24 (sh-mode-map): Bind C-c C-\.
25 (sh-backslash-column, sh-backslash-align): New variables.
26 (sh-backslash-region, sh-append-backslash): New functions.
27
282005-01-15 Sergey Poznyakoff <gray@Mirddin.farlep.net>
29
30 * mail/rmail.el: Updated to work with movemail from GNU Mailutils
31 (rmail-pop-password, rmail-pop-password-required): Moved to
32 rmail-obsolete group.
33 (rmail-set-pop-password): Renamed to rmail-set-remote-password.
34 All callers updated.
35 (rmail-get-pop-password): Renamed to rmail-get-remote-password.
36 Take an argument specifying whether it is POP or IMAP mailbox we
37 are using. All callers updated.
38 (rmail-pop-password-error): Renamed to
39 rmail-remote-password-error. Added mailutils-specific error
40 message.
41 (rmail-movemail-search-path)
42 (rmail-movemail-variant-in-use): New variables.
43 (rmail-remote-password, rmail-remote-password-required): New
44 customization variables.
45 (rmail-probe,rmail-autodetect, rmail-movemail-variant-p): New
46 functions.
47 (rmail-parse-url): New function.
48 (rmail-get-new-mail, rmail-insert-inbox-text): Updated for use
49 with GNU mailutils movemail.
50
512005-01-15 Kevin Ryde <user42@zip.com.au>
52
53 * info-look.el (c-mode/symbol): Add ^` to prefix, and change
54 suffix to space, $ or '$, to correctly position point when going
55 to @table style constants like DBL_MAX.
56
572005-01-15 Jorgen Schaefer <forcer@forcix.cx> (tiny change)
58
59 * type-break.el (type-break-mode, type-break-file-time)
60 (type-break-file-keystroke-count, type-break-choose-file): Don't
61 store data in or load data from the file if type-break-file-name
62 is nil.
63 (type-break-file-name): Doc update as per the above.
64
652005-01-15 Stephen Eglen <S.J.Eglen@damtp.cam.ac.uk> (tiny change)
66
67 * woman.el (woman-dired-define-key-maybe): If KEY is undefined,
68 lookup-key might return nil; handle that.
69
702005-01-15 Alan Mackenzie <acm@muc.de>
71
72 * ebrowse.el (ebrowse-class-in-tree): Return the tail of the tree
73 rather than the element found, thus enabling the tree to be
74 setcar'd.
2 75
3 * calc-yank.el (calc-edit-mode): Change default header. 762005-01-14 Carsten Dominik <dominik@science.uva.nl>
4 77
5 * calc-store.el (calc-edit-variable): Change title to match new 78 * textmodes/org.el (org-show-following-heading): New option.
6 header. 79 (org-show-hierarchy-above): Use `org-show-following-heading'.
80 (org-cycle): Documentation fix.
81
82 * textmodes/org.el (orgtbl-optimized): New option
83 (orgtbl-mode): New command, a minor mode.
84 (orgtbl-mode-map): New variable.
85 (turn-on-orgtbl, orgtbl-mode, orgtbl-make-binding)
86 (orgtbl-error, orgtbl-self-insert-command)
87 (orgtbl-delete-backward-char, orgtbl-delete-char): New functions.
88
89 * textmodes/org.el (org-mode): `org-table-may-need-update' is now
90 a local variable in each org-mode buffer.
91
92 * textmodes/org.el (org-set-regexps-and-options): Renamed from
93 `org-set-regexps'. Added checking for STARTUP keyword.
94 (org-get-current-options): Added STARTUP options.
95 (org-table-insert-row): Mode mode intelligent about when
96 realignment is needed.
97 (org-self-insert-command, org-delete-backward-char,
98 org-delete-char): New commands.
99 (org-enable-table-editor): new default value `optimized'.
100 (org-table-blank-field): Support blanking regions if active.
101
102
1032005-01-14 Carsten Dominik <dominik@science.uva.nl>
104
105 * textmodes/reftex-cite.el (reftex-bib-sort-year): Catch the case
106 if the year is not given.
107
108 * textmodes/reftex-ref.el (reftex-replace-prefix-escapes): Added
109 new escapes %m and %M, fixed bug with %F by adding
110 save-match-data.
111 (reftex-reference): Removed ?. from list of spaces.
112 (reftex-label-info): Added automatic label prefix recognition
113
114 * textmodes/reftex-index.el (reftex-index-next-phrase): Added
115 slave parameter to call of `reftex-index-this-phrase'
116 (reftex-index-this-phrase): New optional argument
117 (reftex-index-region-phrases): Added slave parameter to call of
118 `reftex-index-this-phrase'
119 (reftex-display-index): New argument redo
120 (reftex-index-rescan): Added 'redo to arguments of
121 `reftex-display-index'
122 (reftex-index-Rescan, reftex-index-revert)
123 (reftex-index-switch-index-tag): Added 'redo to arguments of
124 `reftex-display-index'
125 (reftex-index-make-phrase-regexp): Fixed bug with case-sensitive
126 indexing. Fixed bug with matching is there is a quote before or
127 after the word.
128
129 * textmodes/reftex-cite.el (reftex-all-used-citation-keys): Fix
130 bug when collecting citation keys in lines with comments.
131 (reftex-citation): Prefix argument no longer rescans the document,
132 but forces prompting for optional arguments of cite macros.
133 (reftex-do-citation): Prompting for optional arguments
134 implemented.
135
136 * textmodes/reftex-vars.el (reftex-cite-format-builtin): Added
137 optional arguments to most cite commands.
138 (reftex-cite-cleanup-optional-args): New option
139 (reftex-cite-prompt-optional-args): New option.
140 (reftex-trust-label-prefix): New option
141
142 * textmodes/reftex-toc.el (reftex-toc-find-section): Added
143 push-mark before changing the position in the buffer.
144
145 * textmodes/reftex.el (reftex-prefix-to-typekey-alist): New
146 variable
147 (reftex-compile-variables): Compute reftex-prefix-to-typekey-alist
148
1492005-01-14 Nick Roberts <nickrob@snap.net.nz>
150
151 * xt-mouse.el (xterm-mouse-event): Compute window co-ordinates
152 more carefully.
153
1542005-01-13 Stefan Monnier <monnier@iro.umontreal.ca>
155
156 * textmodes/sgml-mode.el (sgml-fill-nobreak): New fun.
157 (sgml-mode): Use it.
158 (sgml-get-context): Better keep track of implicitly closed tags.
159
1602005-01-13 Kenichi Handa <handa@m17n.org>
161
162 * textmodes/ispell.el: These changes are to fix misalignment error
163 caused by equivalent characters of different Emacs charsets.
164 (ispell-unified-chars-table): New variable.
165 (ispell-get-decoded-string): New function.
166 (ispell-get-casechars, ispell-get-not-casechars)
167 (ispell-get-otherchars): Call ispell-get-decoded-string.
168
1692005-01-12 Johan Bockg,Ae(Brd <bojohan@users.sourceforge.net>
170
171 * custom.el (custom-declare-variable): Just put symbol instead
172 of (defvar . symbol) in `current-load-list'.
173
1742005-01-12 Reiner Steib <Reiner.Steib@gmx.de>
175
176 * emacs-lisp/elint.el: Fixed typo in Commentary section.
177
1782005-01-12 Jay Belanger <belanger@truman.edu>
179
180 * calc/calc-help.el (calc-describe-key): Use temporary info buffer
181 to create a Calc summary.
182
1832005-01-12 Kim F. Storm <storm@cua.dk>
184
185 * mouse.el (mouse-on-link-p): Change functionality and doc
186 string to comply with latest description in lisp ref.
187
1882005-01-12 Nick Roberts <nickrob@snap.net.nz>
189
190 * xt-mouse.el (xterm-mouse-translate, xterm-mouse-event):
191 Enable mouse clicks on mode-line, header-line and margin.
192 (event-type): Give mouse event symbols an 'event-kind property
193 with value 'mouse-click.
194
1952005-01-12 Juri Linkov <juri@jurta.org>
196
197 * facemenu.el (list-colors-display): Add new arg buffer-name.
198 Use it. Fix docstring. Replace code for identifying duplicate
199 colors by the name with call to `list-colors-duplicates' which
200 identifies duplicate colors by the value unless the color
201 is one of special Windows colors. Set truncate-lines to t.
202 Print sorted duplicate color names on each line. Indent to 22
203 \(the longest color name in rgb.txt) instead of 20. Optimize.
204 (list-colors-duplicates): New function.
205 (facemenu-color-name-equal): Delete function.
206
207 * facemenu.el (list-colors-print): New function created from code
208 in list-colors-display. Print #RRGGBB at the window right edge.
209 (list-colors-display): When temp-buffer-show-function is not
210 defined, call list-colors-print from temp-buffer-show-hook
211 to get the right value of window-width in list-colors-print
212 after the buffer is displayed.
213
214 * simple.el (pop-mark): Move deactivate-mark out of conditional
215 part to deactivate the active mark regardless of the state of the
216 mark ring.
217
218 * desktop.el (desktop-save): Add `mode: emacs-lisp' to the local
219 variables line in desktop files.
220
2212005-01-12 Juri Linkov <juri@jurta.org>
222
223 * isearch.el (search-highlight, isearch, isearch-lazy-highlight):
224 Bring together isearch highlight related options.
225 (lazy-highlight): Replace group `replace' by `matching'.
226 (lazy-highlight-cleanup, lazy-highlight-initial-delay)
227 (lazy-highlight-interval, lazy-highlight-max-at-a-time)
228 (lazy-highlight): Add aliases to old names isearch-lazy-highlight-...
229 and declare them obsolete.
230 (lazy-highlight-face): Rename from isearch-lazy-highlight-face.
231 (isearch-faces): Remove defgroup.
232 (isearch-overlay, isearch-highlight, isearch-dehighlight):
233 Move isearch highlighting code closer to lazy highlighting code.
234
235 * replace.el (query-replace-lazy-highlight): Add lazy-highlight group.
236 (query-replace-highlight, query-replace-lazy-highlight)
237 (query-replace): Move definitions to the beginning of the file.
238
2392005-01-11 Juri Linkov <juri@jurta.org>
240
241 * toolbar/back_arrow.xpm, toolbar/back_arrow.pbm,
242 * toolbar/lc-back_arrow.xpm, toolbar/lc-fwd_arrow.xpm,
243 * toolbar/fwd_arrow.xpm, toolbar/fwd_arrow.pbm: New icons.
244
245 * info.el (Info-history-forward): New variable.
246 (Info-select-node): Reset Info-history-forward to nil.
247 (Info-last): Turn into defalias.
248 (Info-history-back): Rename from Info-last.
249 Add current node to Info-history-forward.
250 (Info-history-forward): New fun.
251 (Info-mode-map): Replace Info-last by Info-history-back.
252 Bind Info-history-forward to "r".
253 (Info-mode-menu): Replace Info-last by Info-history-back.
254 Fix menu item text. Add menu item for Info-history-forward.
255 (info-tool-bar-map): Replace Info-last by Info-history-back.
256 Replace its icon "undo" by "back_arrow". Add icon "fwd_arrow"
257 for Info-history-forward.
258 (Info-mode): Replace Info-last by Info-history-back in docstring.
259 Add local variable Info-history-forward.
260 (Info-goto-emacs-command-node): Replace Info-last by Info-history-back.
261
2622005-01-11 Stefan Monnier <monnier@iro.umontreal.ca>
263
264 * mouse.el (mouse-drag-mode-line-1, mouse-drag-vertical-line)
265 (mouse-drag-region, mouse-drag-region-1, mouse-drag-secondary):
266 Ignore select-window events rather than fiddle with
267 mouse-autoselect-window.
268
2692005-01-11 Matthew Mundell <matt@mundell.ukfsn.org>
270
271 * type-break.el (type-break-mode): Fix previous change.
272
2732005-01-10 Jay Belanger <belanger@truman.edu>
274
275 * calc/calc-ext.el (calc-reset): Reset when inside embedded
276 calculator; only reset when point is inside a calculator.
277 Don't adjust the window height if the window takes up the whole height
278 of the frame.
279
2802005-01-10 Thien-Thi Nguyen <ttn@gnu.org>
281
282 * ebuff-menu.el (Electric-buffer-menu-mode):
283 Preserve value of buffer-local var header-line-format.
284
2852005-01-09 Jay Belanger <belanger@truman.edu>
286
287 * calc/calc.el (calc-mode-var-list-restore-saved-values):
288 Make sure settings file exists before accessing it.
289
290 * calc/calc-embed.el (calc-embedded-subst):
291 Replace math-multi-subst-rec, which is only supposed to be called
292 by math-multi-subst, by math-multi-subst.
293
2942005-01-09 Andre Spiegel <spiegel@gnu.org>
295
296 * vc.el (vc-allow-async-revert): New user option.
297 (vc-disable-async-diff): New internal variable.
298 (vc-revert-buffer): Use them to disable asynchronous diff.
299
300 * vc-cvs.el, vc-arch.el, vc-svn.el, vc-mcvs.el (vc-cvs-diff)
301 (vc-arch-diff, vc-svn-diff, vc-mcvs-diff): Don't diff
302 asynchronously if vc-disable-async-diff is t.
303
3042005-01-09 Jay Belanger <belanger@truman.edu>
305
306 * calc/calc.el (defcalcmodevar): New macro.
307 (calc-mode-var-list-restore-default-values)
308 (calc-mode-var-list-restore-saved-values): New functions.
309 (calc-mode-var-list): Use defcalcmodevar to define it.
310 (calc-always-load-extensions, calc-line-numbering)
311 (calc-line-breaking, calc-display-just, calc-display-origin)
312 (calc-number-radix, calc-leading-zeros, calc-group-digits)
313 (calc-group-char, calc-point-char, calc-frac-format)
314 (calc-prefer-frac, calc-hms-format, calc-date-format)
315 (calc-float-format, calc-full-float-format, calc-complex-format)
316 (calc-complex-mode, calc-infinite-mode, calc-display-strings)
317 (calc-matrix-just, calc-break-vectors, calc-full-vectors)
318 (calc-full-trail-vectors, calc-vector-commas, calc-vector-brackets)
319 (calc-matrix-brackets, calc-language, calc-language-option)
320 (calc-left-label, calc-right-label, calc-word-size)
321 (calc-previous-modulo, calc-simplify-mode, calc-auto-recompute)
322 (calc-display-raw, calc-internal-prec, calc-angle-mode)
323 (calc-algebraic-mode, calc-incomplete-algebraic-mode)
324 (calc-symbolic-mode, calc-matrix-mode, calc-shift-prefix)
325 (calc-window-height, calc-display-trail, calc-show-selections)
326 (calc-use-selections, calc-assoc-selections)
327 (calc-display-working-message, calc-auto-why, calc-timing)
328 (calc-mode-save-mode, calc-standard-date-formats, calc-autorange-units)
329 (calc-was-keypad-mode, calc-full-mode, calc-user-parse-tables)
330 (calc-gnuplot-default-device, calc-gnuplot-default-output)
331 (calc-gnuplot-print-device, calc-gnuplot-print-output)
332 (calc-gnuplot-geometry, calc-graph-default-resolution)
333 (calc-graph-default-resolution-3d, calc-invocation-macro)
334 (calc-show-banner): Use defcalcmodevar to declare them and set
335 their default values.
336
337 * calc/calc-ext.el (calc-reset): Restore saved values of variables
338 instead of default values (but restore default values if there is
339 an argument of 0).
340
3412005-01-09 David Kastrup <dak@gnu.org>
342
343 * desktop.el (desktop-restore-eager): Fix typo in type.
344
3452005-01-08 Richard M. Stallman <rms@gnu.org>
346
347 * cus-edit.el (customize): Delete :link.
348
3492005-01-08 Jay Belanger <belanger@truman.edu>
350
351 * calc/calc.el (calc-mode): Remove the extension from the
352 `calc-settings-file' file name when loading it.
353
3542005-01-08 Kim F. Storm <storm@cua.dk>
355
356 * info.el (Info-mode-map, Info-next-link-keymap)
357 (Info-prev-link-keymap, Info-up-link-keymap):
358 Map follow-link to mouse-face.
359 (Info-fontify-node): Add "mouse-2: " prefix to tooltip.
360
3612005-01-08 Jay Belanger <belanger@truman.edu>
362
363 * calc/calc.el (calc-settings-file): Change default value.
364 Suggested by cgw in a comment in calc-mode.el.
365
366 * calc/calc-mode.el (calc-settings-file-name):
367 Compare calc-settings-file to user-init-file instead of ~/.emacs.
368 Replace ~/.emacs in a prompt by calc-settings-file.
369
3702005-01-07 Lars Hansen <larsh@math.ku.dk>
371
372 * desktop.el (desktop-restore-eager, desktop-lazy-verbose)
373 (desktop-lazy-idle-delay): New customizable variables.
374 (desktop-buffer-args-list): New variable.
375 (desktop-append-buffer-args): New function.
376 (desktop-save): Call desktop-append-buffer-args for some buffers.
377 (desktop-lazy-create-buffer): New function.
378 (desktop-idle-create-buffers): New function.
379 (desktop-read): Add message about buffers to restore lazily.
380 (desktop-lazy-abort): New command.
381 (desktop-clear): Call desktop-lazy-abort.
382 (desktop-lazy-complete): New command.
7 383
8 * calc/calc-prog.el (calc-edit-user-syntax): Change title to edit 3842005-01-06 Richard M. Stallman <rms@gnu.org>
385
386 * emacs-lisp/find-func.el (find-face-definition):
387 Rename from find-face.
388
3892005-01-06 Kim F. Storm <storm@cua.dk>
390
391 * simple.el (completion-list-mode-map): Map follow-link to mouse-face.
392
393 * man.el (Man-xref-man-page, Man-xref-header-file)
394 (Man-xref-normal-file): Add follow-link property.
395
3962005-01-06 Jay Belanger <belanger@truman.edu>
397
398 * calc/calc-units.el: Make sure the proper macro definitions are
399 available when compiling.
400
4012005-01-06 Juri Linkov <juri@jurta.org>
402
403 * isearch.el (isearch-lazy-highlight-update):
404 Rename `isearch-lazy-highlight-interval' to `lazy-highlight-interval'.
405
4062005-01-06 Miles Bader <miles@gnu.org>
407
408 * isearch.el (lazy-highlight): Rename from `lazy-highlight-face'.
409 (isearch-lazy-highlight-face): Use new name.
410
4112005-01-05 Stefan Monnier <monnier@iro.umontreal.ca>
412
413 * uniquify.el (uniquify-rationalize-file-buffer-names):
414 Re-add an interactive spec.
415 (uniquify-rationalize-file-buffer-names): Fix corner case when renaming
416 to the same name.
417
418 * isearch.el (isearch-dehighlight): Remove unused arg `totally'.
419 (isearch-update, isearch-done): Adjust calls accordingly.
420
4212005-01-05 Richard M. Stallman <rms@gnu.org>
422
423 * custom.el (custom-set-variables, custom-theme-set-variables):
424 Clarify documentation.
425
426 * emacs-lisp/find-func.el (find-variable)
427 (find-variable-other-window, find-variable-other-frame):
428 Fix the TYPE args to find-function-read and find-function-do-it.
429 (find-function): Doc fix.
430 (find-function-at-point): Replace function-at-point alias.
431
4322005-01-04 Richard M. Stallman <rms@gnu.org>
433
434 * cus-face.el (custom-declare-face):
435 Record defface in current-load-list.
436
437 * help-fns.el (variable-at-point): New arg ANY-SYMBOL.
438
439 * emacs-lisp/find-func.el: Doc fixes.
440 (find-face-regexp): New variable.
441 (find-function-regexp-alist): New variable.
442 (find-function-C-source): Third arg is now TYPE.
443 (find-function-search-for-symbol): Handle general TYPE.
444 (find-function-read, find-function-do-it): Handle general TYPE.
445 (find-definition-noselect, find-face): New functions.
446 (function-at-point): Alias deleted.
447
4482005-01-04 Stefan Monnier <monnier@iro.umontreal.ca>
449
450 * battery.el (display-battery-mode): Rename from display-battery.
451 Handle the case where it gets turned off.
452
4532005-01-04 Richard M. Stallman <rms@gnu.org>
454
455 * cus-edit.el (customize): Make :link point to user doc.
456
457 * man.el (Man-fontify-manpage): Turn off undo generation.
458
459 * add-log.el (change-log-font-lock-keywords): Don't match just "From".
460
4612005-01-04 Andreas Schwab <schwab@suse.de>
462
463 * files.el (insert-directory): Only look for error lines in
464 inserted text. Don't move too far after processing --dired markers.
465
4662005-01-04 Richard M. Stallman <rms@gnu.org>
467
468 * mail/mailabbrev.el (sendmail-pre-abbrev-expand-hook):
469 Don't expand if the character is @, period, dash, etc.
470 (define-mail-abbrev): Quote names that contain problem characters.
471
4722005-01-04 Thien-Thi Nguyen <ttn@gnu.org>
473
474 * progmodes/hideshow.el: No longer require `cl'; `dolist' is standard.
475
4762005-01-03 Richard M. Stallman <rms@gnu.org>
477
478 * replace.el (replace-dehighlight): Use lazy-highlight-cleanup.
479 (query-replace-highlight, query-replace-lazy-highlight)
480 (query-replace): Definitions moved up. Doc fix.
481
4822005-01-03 Richard M. Stallman <rms@gnu.org>
483
484 * isearch.el (lazy-highlight): Group renamed from isearch-lazy-...
485 (lazy-highlight-cleanup, lazy-highlight-initial-delay)
486 (lazy-highlight-interval, lazy-highlight-max-at-a-time)
487 (lazy-highlight-face): Rename from isearch-lazy-...
488 Change all references to them.
489
4902005-01-03 Luc Teirlinck <teirllm@auburn.edu>
491
492 * cus-edit.el (custom-file): Doc fix for defcustom.
493 (custom-file): The function no longer sets the variable
494 `custom-file' to its return value.
495
496 * startup.el (command-line): No longer load `custom-file'.
497
4982005-01-03 Stefan Monnier <monnier@iro.umontreal.ca>
499
500 * emacs-lisp/find-func.el (find-variable-regexp): Avoid defface.
501
502 * progmodes/perl-mode.el (perl-nochange, perl-calculate-indent):
503 Don't confuse module-prefixed identifiers for labels.
504 Reported by Juan-Leon Lahoz Garcia <juanleon1@gmail.com>.
505
5062005-01-02 Richard M. Stallman <rms@gnu.org>
507
508 * files.el (basic-save-buffer-1): Fix previous change.
509
510 * loadhist.el (file-loadhist-lookup): New function.
511 (file-provides, file-requires): Use it.
512
513 * electric.el (Electric-pop-up-window): Use fit-window-to-buffer
514 instead of calculating the right size.
515
5162005-01-02 Karl Chen <quarl@cs.berkeley.edu> (tiny change)
517
518 * vc-svn.el (vc-svn-diff): Stay local if possible.
519
5202005-01-02 Stefan <monnier@iro.umontreal.ca>
521
522 * vc-arch.el (vc-arch-workfile-version): Handle the empty-branch case.
523
524 * files.el (hack-local-variables): Fix last change.
525
5262005-01-02 Jay Belanger <belanger@truman.edu>
527
528 * calc/calc-yank.el (calc-edit-top): New variable.
529 (calc-edit-mode): Set calc-edit-top to be the beginning of the edited
530 object. Change header properties.
531 (calc-edit-finish, calc-edit-finish-stack-object)
532 (calc-edit-show-buffer): Use calc-edit-top to find the beginning of the
533 edited object.
534 * calc/calc-sel.el (calc-finish-selection-edit): Use calc-edit-top
535 for the beginning of the edited object.
536 * calc/calc-embed.el (calc-embedded-finish-edit): Use calc-edit-top
537 for the beginning of the edited object.
538 * calc/calc-prog.el (calc-edit-macro-finish-edit)
539 (calc-finish-formula-edit, calc-macro-repeats)
540 (calc-edit-macro-adjust-buffer, calc-edit-format-macro-buffer)
541 (calc-edit-macro-pre-finish-edit): Use calc-edit-top for the
542 beginning of the edited object.
543 (calc-user-define-edit): Change the header for editing macros.
544 Remove unnecessary variable.
545
5462005-01-01 Jay Belanger <belanger@truman.edu>
547
548 * calc/calc-yank.el (calc-edit-mode): Change default header.
549 (calc-edit-finish, calc-show-edit-buffer): Adjust to handle new header.
550 * calc/calc-store.el (calc-edit-variable): Change title to match new
551 header.
552 * calc/calc-prog.el (calc-edit-user-syntax): Change title in edit
9 mode to match new header. 553 mode to match new header.
10 (calc-user-define-edit): Change titles to include names of commands. 554 (calc-user-define-edit): Change titles to include names of commands.
555 (calc-finish-formula-edit): Adjust to handle new header.
11 (calc-finish-macro-edit): Remove. 556 (calc-finish-macro-edit): Remove.
12 (calc-edit-macro-repeats, calc-edit-macro-adjust-buffer) 557 (calc-edit-macro-repeats, calc-edit-macro-adjust-buffer)
13 (calc-edit-macro-command, calc-edit-macro-command-type) 558 (calc-edit-macro-command, calc-edit-macro-command-type)
@@ -2944,7 +3489,7 @@
2944 * menu-bar.el (menu-bar-files-menu): Make "Open File..." call 3489 * menu-bar.el (menu-bar-files-menu): Make "Open File..." call
2945 find-file-existing. Add "New File..." that calls find-file. 3490 find-file-existing. Add "New File..." that calls find-file.
2946 3491
2947 * diropen.pbm diropen.xpm: New files. 3492 * diropen.pbm, diropen.xpm: New files.
2948 3493
2949 * toolbar/tool-bar.el (tool-bar-setup): Tool bar item dired uses 3494 * toolbar/tool-bar.el (tool-bar-setup): Tool bar item dired uses
2950 icon diropen. New tool bar item find-file-existing uses icon open. 3495 icon diropen. New tool bar item find-file-existing uses icon open.
@@ -4044,7 +4589,7 @@
4044 (dired-move-to-end-of-filename): Make the " -> " search more specific. 4589 (dired-move-to-end-of-filename): Make the " -> " search more specific.
4045 (dired-buffers-for-dir): Remove unused var `pattern'. 4590 (dired-buffers-for-dir): Remove unused var `pattern'.
4046 4591
40472004-09-28 Matthew Mundell <matt@mundell.ukfsn.org> (tiny change) 45922004-09-28 Matthew Mundell <matt@mundell.ukfsn.org>
4048 4593
4049 * calendar/diary-lib.el (list-diary-entries): Save diary buffer 4594 * calendar/diary-lib.el (list-diary-entries): Save diary buffer
4050 from diary display excursion. Store diary buffer's point for 4595 from diary display excursion. Store diary buffer's point for
diff --git a/lisp/add-log.el b/lisp/add-log.el
index 14a32e580c8..50be95d265a 100644
--- a/lisp/add-log.el
+++ b/lisp/add-log.el
@@ -248,7 +248,9 @@ Note: The search is conducted only within 10%, at the beginning of the file."
248 ("<\\([^>\n]+\\)>\\(:\\| (\\)" (1 'change-log-function-face)) 248 ("<\\([^>\n]+\\)>\\(:\\| (\\)" (1 'change-log-function-face))
249 ;; 249 ;;
250 ;; Acknowledgements. 250 ;; Acknowledgements.
251 ("\\(^\t\\| \\)\\(From\\|Patch\\(es\\)? by\\|Report\\(ed by\\| from\\)\\|Suggest\\(ed by\\|ion from\\)\\)" 251 ;; Don't include plain "From" because that is vague;
252 ;; we want to encourage people to say something more specific.
253 ("\\(^\t\\| \\)\\(Patch\\(es\\)? by\\|Report\\(ed by\\| from\\)\\|Suggest\\(ed by\\|ion from\\)\\)"
252 2 'change-log-acknowledgement-face)) 254 2 'change-log-acknowledgement-face))
253 "Additional expressions to highlight in Change Log mode.") 255 "Additional expressions to highlight in Change Log mode.")
254 256
diff --git a/lisp/battery.el b/lisp/battery.el
index b8790450735..69bd68bb0b9 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -1,6 +1,6 @@
1;;; battery.el --- display battery status information 1;;; battery.el --- display battery status information
2 2
3;; Copyright (C) 1997, 1998, 2000, 2001, 2003, 2004 3;; Copyright (C) 1997, 1998, 2000, 2001, 2003, 2004, 2005
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org> 6;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
@@ -108,20 +108,23 @@ The text being displayed in the echo area is controlled by the variables
108 "Battery status not available"))) 108 "Battery status not available")))
109 109
110;;;###autoload 110;;;###autoload
111(defun display-battery () 111(define-minor-mode display-battery-mode
112 "Display battery status information in the mode line. 112 "Display battery status information in the mode line.
113The text being displayed in the mode line is controlled by the variables 113The text being displayed in the mode line is controlled by the variables
114`battery-mode-line-format' and `battery-status-function'. 114`battery-mode-line-format' and `battery-status-function'.
115The mode line will be updated automatically every `battery-update-interval' 115The mode line will be updated automatically every `battery-update-interval'
116seconds." 116seconds."
117 (interactive) 117 :global t
118 (setq battery-mode-line-string "") 118 (setq battery-mode-line-string "")
119 (or global-mode-string (setq global-mode-string '(""))) 119 (or global-mode-string (setq global-mode-string '("")))
120 (add-to-list 'global-mode-string 'battery-mode-line-string t)
121 (and battery-update-timer (cancel-timer battery-update-timer)) 120 (and battery-update-timer (cancel-timer battery-update-timer))
122 (setq battery-update-timer (run-at-time nil battery-update-interval 121 (if (not display-battery-mode)
123 'battery-update-handler)) 122 (setq global-mode-string
124 (battery-update)) 123 (delq 'battery-mode-line-string global-mode-string))
124 (add-to-list 'global-mode-string 'battery-mode-line-string t)
125 (setq battery-update-timer (run-at-time nil battery-update-interval
126 'battery-update-handler))
127 (battery-update)))
125 128
126(defun battery-update-handler () 129(defun battery-update-handler ()
127 (battery-update) 130 (battery-update)
diff --git a/lisp/calc/calc-embed.el b/lisp/calc/calc-embed.el
index 067d233bf4a..db1acfcb145 100644
--- a/lisp/calc/calc-embed.el
+++ b/lisp/calc/calc-embed.el
@@ -308,10 +308,10 @@ This is not required to be present for user-written mode annotations.")
308 (calc-show-edit-buffer)) 308 (calc-show-edit-buffer))
309 309
310(defvar calc-original-buffer) 310(defvar calc-original-buffer)
311 311(defvar calc-edit-top)
312(defun calc-embedded-finish-edit (info) 312(defun calc-embedded-finish-edit (info)
313 (let ((buf (current-buffer)) 313 (let ((buf (current-buffer))
314 (str (buffer-substring (point) (point-max))) 314 (str (buffer-substring calc-edit-top (point-max)))
315 (start (point)) 315 (start (point))
316 pos) 316 pos)
317 (switch-to-buffer calc-original-buffer) 317 (switch-to-buffer calc-original-buffer)
@@ -885,7 +885,7 @@ The command \\[yank] can retrieve it from there."
885 (list 'calcFunc-assign 885 (list 'calcFunc-assign
886 (nth 1 x) 886 (nth 1 x)
887 (calc-embedded-subst (nth 2 x))) 887 (calc-embedded-subst (nth 2 x)))
888 (calc-normalize (math-evaluate-expr-rec (math-multi-subst-rec x)))))) 888 (calc-normalize (math-evaluate-expr-rec (math-multi-subst x nil nil))))))
889 889
890(defun calc-embedded-eval-get-var (var base) 890(defun calc-embedded-eval-get-var (var base)
891 (let ((entry base) 891 (let ((entry base)
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el
index 89588b4ea74..280c3ca634b 100644
--- a/lisp/calc/calc-ext.el
+++ b/lisp/calc/calc-ext.el
@@ -1240,36 +1240,54 @@ calc-kill calc-kill-region calc-yank))))
1240 1240
1241(defun calc-reset (arg) 1241(defun calc-reset (arg)
1242 (interactive "P") 1242 (interactive "P")
1243 (save-excursion 1243 (setq arg (if arg (prefix-numeric-value arg) nil))
1244 (or (eq major-mode 'calc-mode) 1244 (cond
1245 (calc-create-buffer)) 1245 ((and
1246 (if calc-embedded-info 1246 calc-embedded-info
1247 (calc-embedded nil)) 1247 (equal (aref calc-embedded-info 0) (current-buffer))
1248 (or arg 1248 (<= (point) (aref calc-embedded-info 5))
1249 (setq calc-stack nil)) 1249 (>= (point) (aref calc-embedded-info 4)))
1250 (setq calc-undo-list nil 1250 (let ((cbuf (aref calc-embedded-info 1))
1251 calc-redo-list nil) 1251 (calc-embedded-quiet t))
1252 (let (calc-stack calc-user-parse-tables calc-standard-date-formats 1252 (save-window-excursion
1253 calc-invocation-macro) 1253 (calc-embedded nil)
1254 (mapcar (function (lambda (v) (set v nil))) calc-local-var-list) 1254 (set-buffer cbuf)
1255 (mapcar (function (lambda (v) (set (car v) (nth 1 v)))) 1255 (calc-reset arg))
1256 calc-mode-var-list)) 1256 (calc-embedded nil)))
1257 (calc-set-language nil nil t) 1257 ((eq major-mode 'calc-mode)
1258 (calc-mode) 1258 (save-excursion
1259 (calc-flush-caches t) 1259 (unless (and arg (> (abs arg) 0))
1260 (run-hooks 'calc-reset-hook)) 1260 (setq calc-stack nil))
1261 (calc-wrapper 1261 (setq calc-undo-list nil
1262 (let ((win (get-buffer-window (current-buffer)))) 1262 calc-redo-list nil)
1263 (calc-realign 0) 1263 (let (calc-stack calc-user-parse-tables calc-standard-date-formats
1264 (if win 1264 calc-invocation-macro)
1265 (let ((height (- (window-height win) 2))) 1265 (mapcar (function (lambda (v) (set v nil))) calc-local-var-list)
1266 (set-window-point win (point)) 1266 (if (and arg (<= arg 0))
1267 (or (= height calc-window-height) 1267 (calc-mode-var-list-restore-default-values)
1268 (let ((swin (selected-window))) 1268 (calc-mode-var-list-restore-saved-values)))
1269 (select-window win) 1269 (calc-set-language nil nil t)
1270 (enlarge-window (- calc-window-height height)) 1270 (calc-mode)
1271 (select-window swin))))))) 1271 (calc-flush-caches t)
1272 (message "(Calculator reset)")) 1272 (run-hooks 'calc-reset-hook))
1273 (calc-wrapper
1274 (let ((win (get-buffer-window (current-buffer))))
1275 (calc-realign 0)
1276 ;; Adjust the window height if the window is visible, but doesn't
1277 ;; take up the whole height of the frame.
1278 (if (and
1279 win
1280 (< (window-height win) (1- (frame-height))))
1281 (let ((height (- (window-height win) 2)))
1282 (set-window-point win (point))
1283 (or (= height calc-window-height)
1284 (let ((swin (selected-window)))
1285 (select-window win)
1286 (enlarge-window (- calc-window-height height))
1287 (select-window swin)))))))
1288 (message "(Calculator reset)"))
1289 (t
1290 (message "(Not inside a Calc buffer)"))))
1273 1291
1274;; What a pain; scroll-left behaves differently when called non-interactively. 1292;; What a pain; scroll-left behaves differently when called non-interactively.
1275(defun calc-scroll-left (n) 1293(defun calc-scroll-left (n)
diff --git a/lisp/calc/calc-help.el b/lisp/calc/calc-help.el
index 087c42d295c..eb0cba79cd8 100644
--- a/lisp/calc/calc-help.el
+++ b/lisp/calc/calc-help.el
@@ -178,15 +178,15 @@ C-w Describe how there is no warranty for Calc."
178 (if (= (buffer-size) 0) 178 (if (= (buffer-size) 0)
179 (progn 179 (progn
180 (message "Reading Calc summary from manual...") 180 (message "Reading Calc summary from manual...")
181 (save-window-excursion 181 (require 'info nil t)
182 (save-excursion 182 (with-temp-buffer
183 (calc-info-goto-node "Summary") 183 (Info-mode)
184 (goto-char (point-min)) 184 (Info-goto-node "(Calc)Summary")
185 (forward-line 1) 185 (goto-char (point-min))
186 (copy-to-buffer "*Calc Summary*" 186 (forward-line 1)
187 (point) (point-max)) 187 (copy-to-buffer "*Calc Summary*"
188 (if Info-history 188 (point) (point-max)))
189 (Info-last)))))) 189 (setq buffer-read-only t)))
190 (goto-char (point-min)) 190 (goto-char (point-min))
191 (setq case-fold-search nil) 191 (setq case-fold-search nil)
192 (re-search-forward "^\\(.*\\)\\[\\.\\. a b") 192 (re-search-forward "^\\(.*\\)\\[\\.\\. a b")
diff --git a/lisp/calc/calc-mode.el b/lisp/calc/calc-mode.el
index dfc488d49dd..389b52385b6 100644
--- a/lisp/calc/calc-mode.el
+++ b/lisp/calc/calc-mode.el
@@ -309,25 +309,22 @@
309(defun calc-settings-file-name (name &optional arg) 309(defun calc-settings-file-name (name &optional arg)
310 (interactive 310 (interactive
311 (list (read-file-name (format "Settings file name (normally %s): " 311 (list (read-file-name (format "Settings file name (normally %s): "
312 (abbreviate-file-name (or user-init-file 312 (abbreviate-file-name calc-settings-file)))
313 "~/.emacs"))))
314 current-prefix-arg)) 313 current-prefix-arg))
315 (calc-wrapper 314 (calc-wrapper
316 (setq arg (if arg (prefix-numeric-value arg) 0)) 315 (setq arg (if arg (prefix-numeric-value arg) 0))
317 (if (equal name "") 316 (if (string-equal (file-name-nondirectory name) "")
318 (message "Calc settings file is \"%s\"" calc-settings-file) 317 (message "Calc settings file is \"%s\"" calc-settings-file)
319 (if (< (math-abs arg) 2) 318 (if (< (math-abs arg) 2)
320 (let ((list calc-mode-var-list)) 319 (let ((list calc-mode-var-list))
321 (while list 320 (while list
322 (set (car (car list)) (nth 1 (car list))) 321 (set (car (car list)) (nth 1 (car list)))
323 (setq list (cdr list))))) 322 (setq list (cdr list)))))
324 ;; FIXME: we should use ~/.calc or so in order to avoid
325 ;; reexecuting ~/.emacs (it's not always idempotent) -cgw 2001.11.12
326 (setq calc-settings-file name) 323 (setq calc-settings-file name)
327 (or (and 324 (or (and
328 calc-settings-file 325 calc-settings-file
329 (string-match "\\.emacs" calc-settings-file) 326 (equal user-init-file calc-settings-file)
330 (> arg 0)) 327 (> arg 0))
331 (< arg 0) 328 (< arg 0)
332 (load name t) 329 (load name t)
333 (message "New file"))))) 330 (message "New file")))))
diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el
index b171010e220..b4901b5f8a0 100644
--- a/lisp/calc/calc-prog.el
+++ b/lisp/calc/calc-prog.el
@@ -684,21 +684,16 @@
684 (eq (car-safe (nth 3 cmd)) 'calc-execute-kbd-macro))) 684 (eq (car-safe (nth 3 cmd)) 'calc-execute-kbd-macro)))
685 (let* ((mac (elt (nth 1 (nth 3 cmd)) 1)) 685 (let* ((mac (elt (nth 1 (nth 3 cmd)) 1))
686 (str (edmacro-format-keys mac t)) 686 (str (edmacro-format-keys mac t))
687 (macbeg)
688 (kys (nth 3 (nth 3 cmd)))) 687 (kys (nth 3 (nth 3 cmd))))
689 (calc-edit-mode 688 (calc-edit-mode
690 (list 'calc-edit-macro-finish-edit cmdname kys) 689 (list 'calc-edit-macro-finish-edit cmdname kys)
691 t (format "Editing keyboard macro (%s, bound to %s).\n" 690 t (format (concat
692 cmdname kys)) 691 "Editing keyboard macro (%s, bound to %s).\n"
693 (goto-char (point-max)) 692 "Original keys: %s \n")
694 (insert "Original keys: " (elt (nth 1 (nth 3 cmd)) 0) "\n" ) 693 cmdname kys (elt (nth 1 (nth 3 cmd)) 0)))
695 (setq macbeg (point))
696 (insert str "\n") 694 (insert str "\n")
697 (calc-edit-format-macro-buffer) 695 (calc-edit-format-macro-buffer)
698 (calc-show-edit-buffer) 696 (calc-show-edit-buffer)))
699 (goto-char (point-min))
700 (search-forward "Original")
701 (forward-line 2)))
702 (t (let* ((func (calc-stack-command-p cmd)) 697 (t (let* ((func (calc-stack-command-p cmd))
703 (defn (and func 698 (defn (and func
704 (symbolp func) 699 (symbolp func)
@@ -714,18 +709,16 @@
714 nil 709 nil
715 (format "Editing formula (%s, %s, bound to %s).\n" 710 (format "Editing formula (%s, %s, bound to %s).\n"
716 intcmd algcmd kys)) 711 intcmd algcmd kys))
717 (insert (math-showing-full-precision 712 (insert (math-showing-full-precision
718 (math-format-nice-expr defn (frame-width))) 713 (math-format-nice-expr defn (frame-width)))
719 "\n")) 714 "\n"))
720 (calc-show-edit-buffer) 715 (calc-show-edit-buffer))
721 (goto-char (point-min))
722 (forward-line 2))
723 (error "That command's definition cannot be edited"))))))) 716 (error "That command's definition cannot be edited")))))))
724 717
725;; Formatting the macro buffer 718;; Formatting the macro buffer
726 719
727(defun calc-edit-macro-repeats () 720(defun calc-edit-macro-repeats ()
728 (goto-char (point-min)) 721 (goto-char calc-edit-top)
729 (while 722 (while
730 (re-search-forward "^\\([0-9]+\\)\\*" nil t) 723 (re-search-forward "^\\([0-9]+\\)\\*" nil t)
731 (setq num (string-to-int (match-string 1))) 724 (setq num (string-to-int (match-string 1)))
@@ -738,10 +731,10 @@
738 731
739(defun calc-edit-macro-adjust-buffer () 732(defun calc-edit-macro-adjust-buffer ()
740 (calc-edit-macro-repeats) 733 (calc-edit-macro-repeats)
741 (goto-char (point-min)) 734 (goto-char calc-edit-top)
742 (while (re-search-forward "^RET$" nil t) 735 (while (re-search-forward "^RET$" nil t)
743 (delete-char 1)) 736 (delete-char 1))
744 (goto-char (point-min)) 737 (goto-char calc-edit-top)
745 (while (and (re-search-forward "^$" nil t) 738 (while (and (re-search-forward "^$" nil t)
746 (not (= (point) (point-max)))) 739 (not (= (point) (point-max))))
747 (delete-char 1))) 740 (delete-char 1)))
@@ -869,11 +862,7 @@
869(defun calc-edit-format-macro-buffer () 862(defun calc-edit-format-macro-buffer ()
870 "Rewrite the Calc macro editing buffer." 863 "Rewrite the Calc macro editing buffer."
871 (calc-edit-macro-adjust-buffer) 864 (calc-edit-macro-adjust-buffer)
872 (goto-char (point-min)) 865 (goto-char calc-edit-top)
873 (search-forward "Original keys:")
874 (forward-line 1)
875 (insert "\n")
876 (skip-chars-forward " \t\n")
877 (let ((type (calc-edit-macro-command-type))) 866 (let ((type (calc-edit-macro-command-type)))
878 (while (not (string-equal type "")) 867 (while (not (string-equal type ""))
879 (cond 868 (cond
@@ -913,27 +902,25 @@
913 (calc-edit-macro-combine-var-name)) 902 (calc-edit-macro-combine-var-name))
914 (t (forward-line 1))) 903 (t (forward-line 1)))
915 (setq type (calc-edit-macro-command-type)))) 904 (setq type (calc-edit-macro-command-type))))
916 (goto-char (point-min))) 905 (goto-char calc-edit-top))
917 906
918;; Finish editing the macro 907;; Finish editing the macro
919 908
920(defun calc-edit-macro-pre-finish-edit () 909(defun calc-edit-macro-pre-finish-edit ()
921 (goto-char (point-min)) 910 (goto-char calc-edit-top)
922 (while (re-search-forward "\\(^\\| \\)RET\\($\\|\t\\| \\)" nil t) 911 (while (re-search-forward "\\(^\\| \\)RET\\($\\|\t\\| \\)" nil t)
923 (search-backward "RET") 912 (search-backward "RET")
924 (delete-char 3) 913 (delete-char 3)
925 (insert "<return>"))) 914 (insert "<return>")))
926 915
916(defvar calc-edit-top)
927(defun calc-edit-macro-finish-edit (cmdname key) 917(defun calc-edit-macro-finish-edit (cmdname key)
928 "Finish editing a Calc macro. 918 "Finish editing a Calc macro.
929Redefine the corresponding command." 919Redefine the corresponding command."
930 (interactive) 920 (interactive)
931 (let ((cmd (intern cmdname))) 921 (let ((cmd (intern cmdname)))
932 (calc-edit-macro-pre-finish-edit) 922 (calc-edit-macro-pre-finish-edit)
933 (goto-char (point-max)) 923 (let* ((str (buffer-substring calc-edit-top (point-max)))
934 (re-search-backward "^Original keys:")
935 (forward-line 1)
936 (let* ((str (buffer-substring (point) (point-max)))
937 (mac (edmacro-parse-keys str t))) 924 (mac (edmacro-parse-keys str t)))
938 (if (= (length mac) 0) 925 (if (= (length mac) 0)
939 (fmakunbound cmd) 926 (fmakunbound cmd)
@@ -946,10 +933,8 @@ Redefine the corresponding command."
946 'arg key))))))) 933 'arg key)))))))
947 934
948(defun calc-finish-formula-edit (func) 935(defun calc-finish-formula-edit (func)
949 (goto-char (point-min))
950 (forward-line 2)
951 (let ((buf (current-buffer)) 936 (let ((buf (current-buffer))
952 (str (buffer-substring (point) (point-max))) 937 (str (buffer-substring calc-edit-top (point-max)))
953 (start (point)) 938 (start (point))
954 (body (calc-valid-formula-func func))) 939 (body (calc-valid-formula-func func)))
955 (set-buffer calc-original-buffer) 940 (set-buffer calc-original-buffer)
diff --git a/lisp/calc/calc-sel.el b/lisp/calc/calc-sel.el
index 7b45814f1e7..4ae0df5d3ba 100644
--- a/lisp/calc/calc-sel.el
+++ b/lisp/calc/calc-sel.el
@@ -677,10 +677,11 @@
677;; The variable calc-edit-disp-trail is local to calc-edit-finish, 677;; The variable calc-edit-disp-trail is local to calc-edit-finish,
678;; in calc-yank.el. 678;; in calc-yank.el.
679(defvar calc-edit-disp-trail) 679(defvar calc-edit-disp-trail)
680(defvar calc-edit-top)
680 681
681(defun calc-finish-selection-edit (num sel reselect) 682(defun calc-finish-selection-edit (num sel reselect)
682 (let ((buf (current-buffer)) 683 (let ((buf (current-buffer))
683 (str (buffer-substring (point) (point-max))) 684 (str (buffer-substring calc-edit-top (point-max)))
684 (start (point))) 685 (start (point)))
685 (switch-to-buffer calc-original-buffer) 686 (switch-to-buffer calc-original-buffer)
686 (let ((val (math-read-expr str))) 687 (let ((val (math-read-expr str)))
diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el
index d473b02c0a6..e8a3abfe958 100644
--- a/lisp/calc/calc-units.el
+++ b/lisp/calc/calc-units.el
@@ -30,6 +30,8 @@
30 30
31(require 'calc-ext) 31(require 'calc-ext)
32(require 'calc-macs) 32(require 'calc-macs)
33(eval-when-compile
34 (require 'calc-alg))
33 35
34;;; Units operations. 36;;; Units operations.
35 37
diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el
index 4c7d41e0f76..53d5946e073 100644
--- a/lisp/calc/calc-yank.el
+++ b/lisp/calc/calc-yank.el
@@ -430,6 +430,7 @@
430(defvar calc-edit-handler) 430(defvar calc-edit-handler)
431(defvar calc-restore-trail) 431(defvar calc-restore-trail)
432(defvar calc-allow-ret) 432(defvar calc-allow-ret)
433(defvar calc-edit-top)
433 434
434(defun calc-edit-mode (&optional handler allow-ret title) 435(defun calc-edit-mode (&optional handler allow-ret title)
435 "Calculator editing mode. Press RET, LFD, or C-c C-c to finish. 436 "Calculator editing mode. Press RET, LFD, or C-c C-c to finish.
@@ -464,10 +465,15 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
464 (let ((calc-edit-handler nil)) 465 (let ((calc-edit-handler nil))
465 (calc-edit-finish t)) 466 (calc-edit-finish t))
466 (message "(Cancelled)")) t t) 467 (message "(Cancelled)")) t t)
467 (insert (or title title "Calc Edit Mode. ") 468 (insert (propertize
468 "Press `C-c C-c'" 469 (concat
469 (if allow-ret "" " or RET") 470 (or title title "Calc Edit Mode. ")
470 " to finish, `C-x k RET' to cancel.\n"))) 471 "Press `C-c C-c'"
472 (if allow-ret "" " or RET")
473 " to finish, `C-x k RET' to cancel.\n\n")
474 'font-lock-face 'italic 'read-only t 'rear-nonsticky t 'front-sticky t))
475 (make-local-variable 'calc-edit-top)
476 (setq calc-edit-top (point))))
471(put 'calc-edit-mode 'mode-class 'special) 477(put 'calc-edit-mode 'mode-class 'special)
472 478
473(defun calc-show-edit-buffer () 479(defun calc-show-edit-buffer ()
@@ -484,8 +490,7 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
484 (if win 490 (if win
485 (delete-window win)))) 491 (delete-window win))))
486 (set-buffer-modified-p nil) 492 (set-buffer-modified-p nil)
487 (goto-char (point-min)) 493 (goto-char calc-edit-top)))
488 (forward-line 1)))
489 494
490(defun calc-edit-return () 495(defun calc-edit-return ()
491 (interactive) 496 (interactive)
@@ -519,9 +524,7 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
519 (set-buffer original) 524 (set-buffer original)
520 (not (eq major-mode 'calc-mode)))) 525 (not (eq major-mode 'calc-mode))))
521 (error "Original calculator buffer has been corrupted"))) 526 (error "Original calculator buffer has been corrupted")))
522 (goto-char (point-min)) 527 (goto-char calc-edit-top)
523 (when (looking-at "Calc Edit\\|Editing ")
524 (forward-line 1))
525 (if (buffer-modified-p) 528 (if (buffer-modified-p)
526 (eval calc-edit-handler)) 529 (eval calc-edit-handler))
527 (if one-window 530 (if one-window
@@ -546,7 +549,7 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
546 549
547(defun calc-finish-stack-edit (num) 550(defun calc-finish-stack-edit (num)
548 (let ((buf (current-buffer)) 551 (let ((buf (current-buffer))
549 (str (buffer-substring (point) (point-max))) 552 (str (buffer-substring calc-edit-top (point-max)))
550 (start (point)) 553 (start (point))
551 pos) 554 pos)
552 (if (and (integerp num) (> num 1)) 555 (if (and (integerp num) (> num 1))
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index f93c2e899b5..a578a8666b8 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -206,8 +206,8 @@
206(require 'calc-macs) 206(require 'calc-macs)
207 207
208;;;###autoload 208;;;###autoload
209(defvar calc-settings-file user-init-file 209(defvar calc-settings-file (convert-standard-filename "~/.calc.el")
210 "*File in which to record permanent settings; default is `user-init-file'.") 210 "*File in which to record permanent settings.")
211 211
212(defvar calc-bug-address "belanger@truman.edu" 212(defvar calc-bug-address "belanger@truman.edu"
213 "Address of the author of Calc, for use by `report-calc-bug'.") 213 "Address of the author of Calc, for use by `report-calc-bug'.")
@@ -241,128 +241,102 @@ scientific notation in calc-mode.")
241(defvar calc-loaded-settings-file nil 241(defvar calc-loaded-settings-file nil
242 "t if `calc-settings-file' has been loaded yet.") 242 "t if `calc-settings-file' has been loaded yet.")
243 243
244(defvar calc-always-load-extensions) 244
245(defvar calc-line-numbering) 245(defvar calc-mode-var-list '()
246(defvar calc-line-breaking) 246 "List of variables used in customizing GNU Calc.")
247(defvar calc-display-just) 247
248(defvar calc-display-origin) 248(defmacro defcalcmodevar (var defval &optional doc)
249(defvar calc-number-radix) 249 `(progn
250(defvar calc-leading-zeros) 250 (defvar ,var ,defval ,doc)
251(defvar calc-group-digits) 251 (add-to-list 'calc-mode-var-list (list (quote ,var) ,defval))))
252(defvar calc-group-char) 252
253(defvar calc-point-char) 253(defun calc-mode-var-list-restore-default-values ()
254(defvar calc-frac-format) 254 (mapcar (function (lambda (v) (set (car v) (nth 1 v))))
255(defvar calc-prefer-frac) 255 calc-mode-var-list))
256(defvar calc-hms-format) 256
257(defvar calc-date-format) 257(defun calc-mode-var-list-restore-saved-values ()
258(defvar calc-float-format) 258 (let ((newvarlist '()))
259(defvar calc-full-float-format) 259 (save-excursion
260(defvar calc-complex-format) 260 (let (pos
261(defvar calc-complex-mode) 261 (file (substitute-in-file-name calc-settings-file)))
262(defvar calc-infinite-mode) 262 (when (and
263(defvar calc-display-strings) 263 (file-regular-p file)
264(defvar calc-matrix-just) 264 (set-buffer (find-file-noselect file))
265(defvar calc-break-vectors) 265 (goto-char (point-min))
266(defvar calc-full-vectors) 266 (search-forward ";;; Mode settings stored by Calc" nil t)
267(defvar calc-full-trail-vectors) 267 (progn
268(defvar calc-vector-commas) 268 (forward-line 1)
269(defvar calc-vector-brackets) 269 (setq pos (point))
270(defvar calc-matrix-brackets) 270 (search-forward "\n;;; End of mode settings" nil t)))
271(defvar calc-language) 271 (beginning-of-line)
272(defvar calc-language-option) 272 (calc-mode-var-list-restore-default-values)
273(defvar calc-left-label) 273 (eval-region pos (point))
274(defvar calc-right-label) 274 (let ((varlist calc-mode-var-list))
275(defvar calc-word-size) 275 (while varlist
276(defvar calc-previous-modulo) 276 (let ((var (car varlist)))
277(defvar calc-simplify-mode) 277 (setq newvarlist
278(defvar calc-auto-recompute) 278 (cons (list (car var) (symbol-value (car var)))
279(defvar calc-display-raw) 279 newvarlist)))
280(defvar calc-internal-prec) 280 (setq varlist (cdr varlist)))))))
281(defvar calc-angle-mode) 281 (if newvarlist
282(defvar calc-algebraic-mode) 282 (mapcar (function (lambda (v) (set (car v) (nth 1 v))))
283(defvar calc-incomplete-algebraic-mode) 283 newvarlist)
284(defvar calc-symbolic-mode) 284 (calc-mode-var-list-restore-default-values))))
285(defvar calc-matrix-mode) 285
286(defvar calc-shift-prefix) 286(defcalcmodevar calc-always-load-extensions nil
287(defvar calc-window-height) 287 "If non-nil, load the calc-ext module automatically when calc is loaded.")
288(defvar calc-display-trail) 288
289(defvar calc-show-selections) 289(defcalcmodevar calc-line-numbering t
290(defvar calc-use-selections) 290 "If non-nil, display line numbers in Calculator stack.")
291(defvar calc-assoc-selections) 291
292(defvar calc-display-working-message) 292(defcalcmodevar calc-line-breaking t
293(defvar calc-auto-why) 293 "If non-nil, break long values across multiple lines in Calculator stack.")
294(defvar calc-timing) 294
295(defvar calc-mode-save-mode) 295(defcalcmodevar calc-display-just nil
296(defvar calc-standard-date-formats) 296 "If nil, stack display is left-justified.
297(defvar calc-autorange-units)
298(defvar calc-was-keypad-mode)
299(defvar calc-full-mode)
300(defvar calc-user-parse-tables)
301(defvar calc-gnuplot-default-device)
302(defvar calc-gnuplot-default-output)
303(defvar calc-gnuplot-print-device)
304(defvar calc-gnuplot-print-output)
305(defvar calc-gnuplot-geometry)
306(defvar calc-graph-default-resolution)
307(defvar calc-graph-default-resolution-3d)
308(defvar calc-invocation-macro)
309(defvar calc-show-banner)
310
311(defconst calc-mode-var-list '(
312 (calc-always-load-extensions nil
313 "If non-nil, load the calc-ext module automatically when calc is loaded.")
314
315 (calc-line-numbering t
316 "If non-nil, display line numbers in Calculator stack.")
317
318 (calc-line-breaking t
319 "If non-nil, break long values across multiple lines in Calculator stack.")
320
321 (calc-display-just nil
322 "If nil, stack display is left-justified.
323If `right', stack display is right-justified. 297If `right', stack display is right-justified.
324If `center', stack display is centered.") 298If `center', stack display is centered.")
325 299
326 (calc-display-origin nil 300(defcalcmodevar calc-display-origin nil
327 "Horizontal origin of displayed stack entries. 301 "Horizontal origin of displayed stack entries.
328In left-justified mode, this is effectively indentation. (Default 0). 302In left-justified mode, this is effectively indentation. (Default 0).
329In right-justified mode, this is effectively window width. 303In right-justified mode, this is effectively window width.
330In centered mode, center of stack entry is placed here.") 304In centered mode, center of stack entry is placed here.")
331 305
332 (calc-number-radix 10 306(defcalcmodevar calc-number-radix 10
333 "Radix for entry and display of numbers in calc-mode, 2-36.") 307 "Radix for entry and display of numbers in calc-mode, 2-36.")
334 308
335 (calc-leading-zeros nil 309(defcalcmodevar calc-leading-zeros nil
336 "If non-nil, leading zeros are provided to pad integers to calc-word-size.") 310 "If non-nil, leading zeros are provided to pad integers to calc-word-size.")
337 311
338 (calc-group-digits nil 312(defcalcmodevar calc-group-digits nil
339 "If non-nil, group digits in large displayed integers by inserting spaces. 313 "If non-nil, group digits in large displayed integers by inserting spaces.
340If an integer, group that many digits at a time. 314If an integer, group that many digits at a time.
341If t, use 4 for binary and hex, 3 otherwise.") 315If t, use 4 for binary and hex, 3 otherwise.")
342 316
343 (calc-group-char "," 317(defcalcmodevar calc-group-char ","
344 "The character (in the form of a string) to be used for grouping digits. 318 "The character (in the form of a string) to be used for grouping digits.
345This is used only when calc-group-digits mode is on.") 319This is used only when calc-group-digits mode is on.")
346 320
347 (calc-point-char "." 321(defcalcmodevar calc-point-char "."
348 "The character (in the form of a string) to be used as a decimal point.") 322 "The character (in the form of a string) to be used as a decimal point.")
349 323
350 (calc-frac-format (":" nil) 324(defcalcmodevar calc-frac-format '(":" nil)
351 "Format of displayed fractions; a string of one or two of \":\" or \"/\".") 325 "Format of displayed fractions; a string of one or two of \":\" or \"/\".")
352 326
353 (calc-prefer-frac nil 327(defcalcmodevar calc-prefer-frac nil
354 "If non-nil, prefer fractional over floating-point results.") 328 "If non-nil, prefer fractional over floating-point results.")
355 329
356 (calc-hms-format "%s@ %s' %s\"" 330(defcalcmodevar calc-hms-format "%s@ %s' %s\""
357 "Format of displayed hours-minutes-seconds angles, a format string. 331 "Format of displayed hours-minutes-seconds angles, a format string.
358String must contain three %s marks for hours, minutes, seconds respectively.") 332String must contain three %s marks for hours, minutes, seconds respectively.")
359 333
360 (calc-date-format ((H ":" mm C SS pp " ") 334(defcalcmodevar calc-date-format '((H ":" mm C SS pp " ")
361 Www " " Mmm " " D ", " YYYY) 335 Www " " Mmm " " D ", " YYYY)
362 "Format of displayed date forms.") 336 "Format of displayed date forms.")
363 337
364 (calc-float-format (float 0) 338(defcalcmodevar calc-float-format '(float 0)
365 "Format to use for display of floating-point numbers in calc-mode. 339 "Format to use for display of floating-point numbers in calc-mode.
366Must be a list of one of the following forms: 340Must be a list of one of the following forms:
367 (float 0) Floating point format, display full precision. 341 (float 0) Floating point format, display full precision.
368 (float N) N > 0: Floating point format, at most N significant figures. 342 (float N) N > 0: Floating point format, at most N significant figures.
@@ -375,54 +349,54 @@ Must be a list of one of the following forms:
375 (eng N) N > 0: Engineering notation, N significant figures. 349 (eng N) N > 0: Engineering notation, N significant figures.
376 (eng -N) -N < 0: Engineering notation, calc-internal-prec - N figs.") 350 (eng -N) -N < 0: Engineering notation, calc-internal-prec - N figs.")
377 351
378 (calc-full-float-format (float 0) 352(defcalcmodevar calc-full-float-format '(float 0)
379 "Format to use when full precision must be displayed.") 353 "Format to use when full precision must be displayed.")
380 354
381 (calc-complex-format nil 355(defcalcmodevar calc-complex-format nil
382 "Format to use for display of complex numbers in calc-mode. Must be one of: 356 "Format to use for display of complex numbers in calc-mode. Must be one of:
383 nil Use (x, y) form. 357 nil Use (x, y) form.
384 i Use x + yi form. 358 i Use x + yi form.
385 j Use x + yj form.") 359 j Use x + yj form.")
386 360
387 (calc-complex-mode cplx 361(defcalcmodevar calc-complex-mode 'cplx
388 "Preferred form, either `cplx' or `polar', for complex numbers.") 362 "Preferred form, either `cplx' or `polar', for complex numbers.")
389 363
390 (calc-infinite-mode nil 364(defcalcmodevar calc-infinite-mode nil
391 "If nil, 1 / 0 is left unsimplified. 365 "If nil, 1 / 0 is left unsimplified.
392If 0, 1 / 0 is changed to inf (zeros are considered positive). 366If 0, 1 / 0 is changed to inf (zeros are considered positive).
393Otherwise, 1 / 0 is changed to uinf (undirected infinity).") 367Otherwise, 1 / 0 is changed to uinf (undirected infinity).")
394 368
395 (calc-display-strings nil 369(defcalcmodevar calc-display-strings nil
396 "If non-nil, display vectors of byte-sized integers as strings.") 370 "If non-nil, display vectors of byte-sized integers as strings.")
397 371
398 (calc-matrix-just center 372(defcalcmodevar calc-matrix-just 'center
399 "If nil, vector elements are left-justified. 373 "If nil, vector elements are left-justified.
400If `right', vector elements are right-justified. 374If `right', vector elements are right-justified.
401If `center', vector elements are centered.") 375If `center', vector elements are centered.")
402 376
403 (calc-break-vectors nil 377(defcalcmodevar calc-break-vectors nil
404 "If non-nil, display vectors one element per line.") 378 "If non-nil, display vectors one element per line.")
405 379
406 (calc-full-vectors t 380(defcalcmodevar calc-full-vectors t
407 "If non-nil, display long vectors in full. If nil, use abbreviated form.") 381 "If non-nil, display long vectors in full. If nil, use abbreviated form.")
408 382
409 (calc-full-trail-vectors t 383(defcalcmodevar calc-full-trail-vectors t
410 "If non-nil, display long vectors in full in the trail.") 384 "If non-nil, display long vectors in full in the trail.")
411 385
412 (calc-vector-commas "," 386(defcalcmodevar calc-vector-commas ","
413 "If non-nil, separate elements of displayed vectors with this string.") 387 "If non-nil, separate elements of displayed vectors with this string.")
414 388
415 (calc-vector-brackets "[]" 389(defcalcmodevar calc-vector-brackets "[]"
416 "If non-nil, surround displayed vectors with these characters.") 390 "If non-nil, surround displayed vectors with these characters.")
417 391
418 (calc-matrix-brackets (R O) 392(defcalcmodevar calc-matrix-brackets '(R O)
419 "A list of code-letter symbols that control \"big\" matrix display. 393 "A list of code-letter symbols that control \"big\" matrix display.
420If `R' is present, display inner brackets for matrices. 394If `R' is present, display inner brackets for matrices.
421If `O' is present, display outer brackets for matrices (above/below). 395If `O' is present, display outer brackets for matrices (above/below).
422If `C' is present, display outer brackets for matrices (centered).") 396If `C' is present, display outer brackets for matrices (centered).")
423 397
424 (calc-language nil 398(defcalcmodevar calc-language nil
425 "Language or format for entry and display of stack values. Must be one of: 399 "Language or format for entry and display of stack values. Must be one of:
426 nil Use standard Calc notation. 400 nil Use standard Calc notation.
427 flat Use standard Calc notation, one-line format. 401 flat Use standard Calc notation, one-line format.
428 big Display formulas in 2-d notation (enter w/std notation). 402 big Display formulas in 2-d notation (enter w/std notation).
@@ -435,23 +409,23 @@ If `C' is present, display outer brackets for matrices (centered).")
435 math Use Mathematica(tm) notation. 409 math Use Mathematica(tm) notation.
436 maple Use Maple notation.") 410 maple Use Maple notation.")
437 411
438 (calc-language-option nil 412(defcalcmodevar calc-language-option nil
439 "Numeric prefix argument for the command that set `calc-language'.") 413 "Numeric prefix argument for the command that set `calc-language'.")
440 414
441 (calc-left-label "" 415(defcalcmodevar calc-left-label ""
442 "Label to display at left of formula.") 416 "Label to display at left of formula.")
443 417
444 (calc-right-label "" 418(defcalcmodevar calc-right-label ""
445 "Label to display at right of formula.") 419 "Label to display at right of formula.")
446 420
447 (calc-word-size 32 421(defcalcmodevar calc-word-size 32
448 "Minimum number of bits per word, if any, for binary operations in calc-mode.") 422 "Minimum number of bits per word, if any, for binary operations in calc-mode.")
449 423
450 (calc-previous-modulo nil 424(defcalcmodevar calc-previous-modulo nil
451 "Most recently used value of M in a modulo form.") 425 "Most recently used value of M in a modulo form.")
452 426
453 (calc-simplify-mode nil 427(defcalcmodevar calc-simplify-mode nil
454 "Type of simplification applied to results. 428 "Type of simplification applied to results.
455If `none', results are not simplified when pushed on the stack. 429If `none', results are not simplified when pushed on the stack.
456If `num', functions are simplified only when args are constant. 430If `num', functions are simplified only when args are constant.
457If nil, only fast simplifications are applied. 431If nil, only fast simplifications are applied.
@@ -460,69 +434,69 @@ If `alg', `math-simplify' is applied.
460If `ext', `math-simplify-extended' is applied. 434If `ext', `math-simplify-extended' is applied.
461If `units', `math-simplify-units' is applied.") 435If `units', `math-simplify-units' is applied.")
462 436
463 (calc-auto-recompute t 437(defcalcmodevar calc-auto-recompute t
464 "If non-nil, recompute evalto's automatically when necessary.") 438 "If non-nil, recompute evalto's automatically when necessary.")
465 439
466 (calc-display-raw nil 440(defcalcmodevar calc-display-raw nil
467 "If non-nil, display shows unformatted Lisp exprs. (For debugging)") 441 "If non-nil, display shows unformatted Lisp exprs.(defcalcmodevar For debugging)")
468 442
469 (calc-internal-prec 12 443(defcalcmodevar calc-internal-prec 12
470 "Number of digits of internal precision for calc-mode calculations.") 444 "Number of digits of internal precision for calc-mode calculations.")
471 445
472 (calc-angle-mode deg 446(defcalcmodevar calc-angle-mode 'deg
473 "If deg, angles are in degrees; if rad, angles are in radians. 447 "If deg, angles are in degrees; if rad, angles are in radians.
474If hms, angles are in degrees-minutes-seconds.") 448If hms, angles are in degrees-minutes-seconds.")
475 449
476 (calc-algebraic-mode nil 450(defcalcmodevar calc-algebraic-mode nil
477 "If non-nil, numeric entry accepts whole algebraic expressions. 451 "If non-nil, numeric entry accepts whole algebraic expressions.
478If nil, algebraic expressions must be preceded by \"'\".") 452If nil, algebraic expressions must be preceded by \"'\".")
479 453
480 (calc-incomplete-algebraic-mode nil 454(defcalcmodevar calc-incomplete-algebraic-mode nil
481 "Like calc-algebraic-mode except only affects ( and [ keys.") 455 "Like calc-algebraic-mode except only affects ( and [ keys.")
482 456
483 (calc-symbolic-mode nil 457(defcalcmodevar calc-symbolic-mode nil
484 "If non-nil, inexact numeric computations like sqrt(2) are postponed. 458 "If non-nil, inexact numeric computations like sqrt(2) are postponed.
485If nil, computations on numbers always yield numbers where possible.") 459If nil, computations on numbers always yield numbers where possible.")
486 460
487 (calc-matrix-mode nil 461(defcalcmodevar calc-matrix-mode nil
488 "If `matrix', variables are assumed to be matrix-valued. 462 "If `matrix', variables are assumed to be matrix-valued.
489If a number, variables are assumed to be NxN matrices. 463If a number, variables are assumed to be NxN matrices.
490If `scalar', variables are assumed to be scalar-valued. 464If `scalar', variables are assumed to be scalar-valued.
491If nil, symbolic math routines make no assumptions about variables.") 465If nil, symbolic math routines make no assumptions about variables.")
492 466
493 (calc-shift-prefix nil 467(defcalcmodevar calc-shift-prefix nil
494 "If non-nil, shifted letter keys are prefix keys rather than normal meanings.") 468 "If non-nil, shifted letter keys are prefix keys rather than normal meanings.")
495 469
496 (calc-window-height 7 470(defcalcmodevar calc-window-height 7
497 "Initial height of Calculator window.") 471 "Initial height of Calculator window.")
498 472
499 (calc-display-trail t 473(defcalcmodevar calc-display-trail t
500 "If non-nil, M-x calc creates a window to display Calculator trail.") 474 "If non-nil, M-x calc creates a window to display Calculator trail.")
501 475
502 (calc-show-selections t 476(defcalcmodevar calc-show-selections t
503 "If non-nil, selected sub-formulas are shown by obscuring rest of formula. 477 "If non-nil, selected sub-formulas are shown by obscuring rest of formula.
504If nil, selected sub-formulas are highlighted by obscuring the sub-formulas.") 478If nil, selected sub-formulas are highlighted by obscuring the sub-formulas.")
505 479
506 (calc-use-selections t 480(defcalcmodevar calc-use-selections t
507 "If non-nil, commands operate only on selected portions of formulas. 481 "If non-nil, commands operate only on selected portions of formulas.
508If nil, selections displayed but ignored.") 482If nil, selections displayed but ignored.")
509 483
510 (calc-assoc-selections t 484(defcalcmodevar calc-assoc-selections t
511 "If non-nil, selection hides deep structure of associative formulas.") 485 "If non-nil, selection hides deep structure of associative formulas.")
512 486
513 (calc-display-working-message lots 487(defcalcmodevar calc-display-working-message 'lots
514 "If non-nil, display \"Working...\" for potentially slow Calculator commands.") 488 "If non-nil, display \"Working...\" for potentially slow Calculator commands.")
515 489
516 (calc-auto-why maybe 490(defcalcmodevar calc-auto-why 'maybe
517 "If non-nil, automatically execute a \"why\" command to explain odd results.") 491 "If non-nil, automatically execute a \"why\" command to explain odd results.")
518 492
519 (calc-timing nil 493(defcalcmodevar calc-timing nil
520 "If non-nil, display timing information on each slow command.") 494 "If non-nil, display timing information on each slow command.")
521 495
522 (calc-mode-save-mode local) 496(defcalcmodevar calc-mode-save-mode 'local)
523 497
524 (calc-standard-date-formats 498(defcalcmodevar calc-standard-date-formats
525 ("N" 499 '("N"
526 "<H:mm:SSpp >Www Mmm D, YYYY" 500 "<H:mm:SSpp >Www Mmm D, YYYY"
527 "D Mmm YYYY<, h:mm:SS>" 501 "D Mmm YYYY<, h:mm:SS>"
528 "Www Mmm BD< hh:mm:ss> YYYY" 502 "Www Mmm BD< hh:mm:ss> YYYY"
@@ -533,40 +507,32 @@ If nil, selections displayed but ignored.")
533 "j<, h:mm:SS>" 507 "j<, h:mm:SS>"
534 "YYddd< hh:mm:ss>")) 508 "YYddd< hh:mm:ss>"))
535 509
536 (calc-autorange-units nil) 510(defcalcmodevar calc-autorange-units nil)
537 511
538 (calc-was-keypad-mode nil) 512(defcalcmodevar calc-was-keypad-mode nil)
539 513
540 (calc-full-mode nil) 514(defcalcmodevar calc-full-mode nil)
541 515
542 (calc-user-parse-tables nil) 516(defcalcmodevar calc-user-parse-tables nil)
543 517
544 (calc-gnuplot-default-device "default") 518(defcalcmodevar calc-gnuplot-default-device "default")
545 519
546 (calc-gnuplot-default-output "STDOUT") 520(defcalcmodevar calc-gnuplot-default-output "STDOUT")
547 521
548 (calc-gnuplot-print-device "postscript") 522(defcalcmodevar calc-gnuplot-print-device "postscript")
549 523
550 (calc-gnuplot-print-output "auto") 524(defcalcmodevar calc-gnuplot-print-output "auto")
551 525
552 (calc-gnuplot-geometry nil) 526(defcalcmodevar calc-gnuplot-geometry nil)
553 527
554 (calc-graph-default-resolution 15) 528(defcalcmodevar calc-graph-default-resolution 15)
555 529
556 (calc-graph-default-resolution-3d 5) 530(defcalcmodevar calc-graph-default-resolution-3d 5)
557 531
558 (calc-invocation-macro nil) 532(defcalcmodevar calc-invocation-macro nil)
559
560 (calc-show-banner t
561 "*If non-nil, show a friendly greeting above the stack."))
562 "List of variables (and default values) used in customizing GNU Calc.")
563 533
564(mapcar (function (lambda (v) 534(defcalcmodevar calc-show-banner t
565 (or (boundp (car v)) 535 "*If non-nil, show a friendly greeting above the stack.")
566 (set (car v) (nth 1 v)))
567 (if (nth 2 v)
568 (put (car v) 'variable-documentation (nth 2 v)))))
569 calc-mode-var-list)
570 536
571(defconst calc-local-var-list '(calc-stack 537(defconst calc-local-var-list '(calc-stack
572 calc-stack-top 538 calc-stack-top
@@ -1028,7 +994,7 @@ Notations: 3.14e6 3.14 * 10^6
1028 (equal calc-settings-file user-init-file) 994 (equal calc-settings-file user-init-file)
1029 (progn 995 (progn
1030 (setq calc-loaded-settings-file t) 996 (setq calc-loaded-settings-file t)
1031 (load calc-settings-file t))) ; t = missing-ok 997 (load (file-name-sans-extension calc-settings-file) t))) ; t = missing-ok
1032 (let ((p command-line-args)) 998 (let ((p command-line-args))
1033 (while p 999 (while p
1034 (and (equal (car p) "-f") 1000 (and (equal (car p) "-f")
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 5f3ffc6f8bf..8a60163181a 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -243,7 +243,6 @@
243 243
244(defgroup customize '((widgets custom-group)) 244(defgroup customize '((widgets custom-group))
245 "Customization of the Customization support." 245 "Customization of the Customization support."
246 :link '(custom-manual "(elisp)Customization")
247 :prefix "custom-" 246 :prefix "custom-"
248 :group 'help) 247 :group 'help)
249 248
@@ -3699,35 +3698,57 @@ The default is nil, which means to use your init file
3699as specified by `user-init-file'. If the value is not nil, 3698as specified by `user-init-file'. If the value is not nil,
3700it should be an absolute file name. 3699it should be an absolute file name.
3701 3700
3702To make this feature work, you'll need to put something in your 3701You can set this option through Custom, if you carefully read the
3703init file to specify the value of `custom-file'. Just 3702last paragraph below. However, usually it is simpler to write
3704customizing the variable won't suffice, because Emacs won't know 3703something like the following in your init file:
3705which file to load unless the init file sets `custom-file'. 3704
3706 3705\(setq custom-file \"~/.emacs-custom.el\")
3707When you change this variable, look in the previous custom file 3706\(load custom-file)
3708\(usually your init file) for the forms `(custom-set-variables ...)' 3707
3709and `(custom-set-faces ...)', and copy them (whichever ones you find) 3708Note that both lines are necessary: the first line tells Custom to
3710to the new custom file. This will preserve your existing customizations." 3709save all customizations in this file, but does not load it.
3711 :type '(choice (const :tag "Your Emacs init file" nil) file) 3710
3711When you change this variable outside Custom, look in the
3712previous custom file \(usually your init file) for the
3713forms `(custom-set-variables ...)' and `(custom-set-faces ...)',
3714and copy them (whichever ones you find) to the new custom file.
3715This will preserve your existing customizations.
3716
3717If you save this option using Custom, Custom will write all
3718currently saved customizations, including the new one for this
3719option itself, into the file you specify, overwriting any
3720`custom-set-variables' and `custom-set-faces' forms already
3721present in that file. It will not delete any customizations from
3722the old custom file. You should do that manually if that is what you
3723want. You also have to put something like `\(load \"CUSTOM-FILE\")
3724in your init file, where CUSTOM-FILE is the actual name of the
3725file. Otherwise, Emacs will not load the file when it starts up,
3726and hence will not set `custom-file' to that file either."
3727 :type '(choice (const :tag "Your Emacs init file" nil)
3728 (file :format "%t:%v%d"
3729 :doc
3730 "Please read entire docstring below before setting \
3731this through Custom.
3732Click om \"More\" \(or position point there and press RETURN)
3733if only the first line of the docstring is shown."))
3712 :group 'customize) 3734 :group 'customize)
3713 3735
3714(defun custom-file () 3736(defun custom-file ()
3715 "Return the file name for saving customizations." 3737 "Return the file name for saving customizations."
3716 (setq custom-file 3738 (or custom-file
3717 (or custom-file 3739 (let ((user-init-file user-init-file)
3718 (let ((user-init-file user-init-file) 3740 (default-init-file
3719 (default-init-file 3741 (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))
3720 (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs"))) 3742 (when (null user-init-file)
3721 (when (null user-init-file) 3743 (if (or (file-exists-p default-init-file)
3722 (if (or (file-exists-p default-init-file) 3744 (and (eq system-type 'windows-nt)
3723 (and (eq system-type 'windows-nt) 3745 (file-exists-p "~/_emacs")))
3724 (file-exists-p "~/_emacs"))) 3746 ;; Started with -q, i.e. the file containing
3725 ;; Started with -q, i.e. the file containing 3747 ;; Custom settings hasn't been read. Saving
3726 ;; Custom settings hasn't been read. Saving 3748 ;; settings there would overwrite other settings.
3727 ;; settings there would overwrite other settings. 3749 (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
3728 (error "Saving settings from \"emacs -q\" would overwrite existing customizations")) 3750 (setq user-init-file default-init-file))
3729 (setq user-init-file default-init-file)) 3751 user-init-file)))
3730 user-init-file))))
3731 3752
3732(defun custom-save-delete (symbol) 3753(defun custom-save-delete (symbol)
3733 "Visit `custom-file' and delete all calls to SYMBOL from it. 3754 "Visit `custom-file' and delete all calls to SYMBOL from it.
diff --git a/lisp/cus-face.el b/lisp/cus-face.el
index 0f3f6018cfc..33c8c995a4c 100644
--- a/lisp/cus-face.el
+++ b/lisp/cus-face.el
@@ -50,6 +50,7 @@
50 (make-face-x-resource-internal face)))) 50 (make-face-x-resource-internal face))))
51 ;; Don't record SPEC until we see it causes no errors. 51 ;; Don't record SPEC until we see it causes no errors.
52 (put face 'face-defface-spec spec) 52 (put face 'face-defface-spec spec)
53 (push (cons 'defface face) current-load-list)
53 (when (and doc (null (face-documentation face))) 54 (when (and doc (null (face-documentation face)))
54 (set-face-documentation face (purecopy doc))) 55 (set-face-documentation face (purecopy doc)))
55 (custom-handle-all-keywords face args 'custom-face) 56 (custom-handle-all-keywords face args 'custom-face)
diff --git a/lisp/custom.el b/lisp/custom.el
index 2ddd7ceb943..e7aba88f72a 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -168,7 +168,7 @@ set to nil, as the value is no longer rogue."
168 ;; Do the actual initialization. 168 ;; Do the actual initialization.
169 (unless custom-dont-initialize 169 (unless custom-dont-initialize
170 (funcall initialize symbol default))) 170 (funcall initialize symbol default)))
171 (push (cons 'defvar symbol) current-load-list) 171 (push symbol current-load-list)
172 (run-hooks 'custom-define-hook) 172 (run-hooks 'custom-define-hook)
173 symbol) 173 symbol)
174 174
@@ -710,44 +710,46 @@ in every Customization buffer.")
710(put 'custom-local-buffer 'permanent-local t) 710(put 'custom-local-buffer 'permanent-local t)
711 711
712(defun custom-set-variables (&rest args) 712(defun custom-set-variables (&rest args)
713 "Initialize variables according to user preferences. 713 "Install user customizations of variable values specified in ARGS.
714The settings are registered as theme `user'. 714These settings are registered as theme `user'.
715The arguments should each be a list of the form: 715The arguments should each be a list of the form:
716 716
717 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]]) 717 (SYMBOL EXP [NOW [REQUEST [COMMENT]]])
718 718
719The unevaluated VALUE is stored as the saved value for SYMBOL. 719This stores EXP (without evaluating it) as the saved value for SYMBOL.
720If NOW is present and non-nil, VALUE is also evaluated and bound as 720If NOW is present and non-nil, then also evaluate EXP and set
721the default value for the SYMBOL. 721the default value for the SYMBOL to the value of EXP.
722 722
723REQUEST is a list of features we must 'require for SYMBOL. 723REQUEST is a list of features we must require in order to
724handle SYMBOL properly.
724COMMENT is a comment string about SYMBOL." 725COMMENT is a comment string about SYMBOL."
725 (apply 'custom-theme-set-variables 'user args)) 726 (apply 'custom-theme-set-variables 'user args))
726 727
727(defun custom-theme-set-variables (theme &rest args) 728(defun custom-theme-set-variables (theme &rest args)
728 "Initialize variables according to settings specified by args. 729 "Initialize variables for theme THEME according to settings in ARGS.
729Records the settings as belonging to THEME. 730Each of the arguments in ARGS should be a list of this form:
730 731
731The arguments should be a list where each entry has the form: 732 (SYMBOL EXP [NOW [REQUEST [COMMENT]]])
732 733
733 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]]) 734This stores EXP (without evaluating it) as the saved value for SYMBOL.
735If NOW is present and non-nil, then also evaluate EXP and set
736the default value for the SYMBOL to the value of EXP.
734 737
735The unevaluated VALUE is stored as the saved value for SYMBOL. 738REQUEST is a list of features we must require in order to
736If NOW is present and non-nil, VALUE is also evaluated and bound as 739handle SYMBOL properly.
737the default value for the SYMBOL.
738REQUEST is a list of features we must 'require for SYMBOL.
739COMMENT is a comment string about SYMBOL. 740COMMENT is a comment string about SYMBOL.
740 741
741Several properties of THEME and SYMBOL are used in the process: 742Several properties of THEME and SYMBOL are used in the process:
742 743
743If THEME property `theme-immediate' is non-nil, this is equivalent of 744If THEME's property `theme-immediate' is non-nil, this is equivalent of
744providing the NOW argument to all symbols in the argument list: SYMBOL 745providing the NOW argument to all symbols in the argument list:
745is bound to the evaluated VALUE. The only difference is SYMBOL property 746evaluate each EXP and set the corresponding SYMBOL. However,
747there's a difference in the handling of SYMBOL's property
746`force-value': if NOW is non-nil, SYMBOL's property `force-value' is set to 748`force-value': if NOW is non-nil, SYMBOL's property `force-value' is set to
747the symbol `rogue', else if THEME's property `theme-immediate' is non-nil, 749the symbol `rogue', else if THEME's property `theme-immediate' is non-nil,
748FACE's property `force-face' is set to the symbol `immediate'. 750SYMBOL's property `force-value' is set to the symbol `immediate'.
749 751
750VALUE itself is saved unevaluated as SYMBOL property `saved-value' and 752EXP itself is saved unevaluated as SYMBOL property `saved-value' and
751in SYMBOL's list property `theme-value' \(using `custom-push-theme')." 753in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
752 (custom-check-theme theme) 754 (custom-check-theme theme)
753 (let ((immediate (get theme 'theme-immediate))) 755 (let ((immediate (get theme 'theme-immediate)))
diff --git a/lisp/desktop.el b/lisp/desktop.el
index 50ee9d03b7e..163122a2d14 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -1,6 +1,6 @@
1;;; desktop.el --- save partial status of Emacs when killed 1;;; desktop.el --- save partial status of Emacs when killed
2 2
3;; Copyright (C) 1993, 1994, 1995, 1997, 2000, 2001 3;; Copyright (C) 1993, 1994, 1995, 1997, 2000, 2001, 2005
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Author: Morten Welinder <terra@diku.dk> 6;; Author: Morten Welinder <terra@diku.dk>
@@ -198,7 +198,7 @@ Feature: Saving `kill-ring' implies saving `kill-ring-yank-pointer'."
198 search-ring-yank-pointer 198 search-ring-yank-pointer
199 regexp-search-ring 199 regexp-search-ring
200 regexp-search-ring-yank-pointer) 200 regexp-search-ring-yank-pointer)
201 "List of global variables to clear by `desktop-clear'. 201 "List of global variables that `desktop-clear' will clear.
202An element may be variable name (a symbol) or a cons cell of the form 202An element may be variable name (a symbol) or a cons cell of the form
203\(VAR . FORM). Symbols are set to nil and for cons cells VAR is set 203\(VAR . FORM). Symbols are set to nil and for cons cells VAR is set
204to the value obtained by evaluateing FORM." 204to the value obtained by evaluateing FORM."
@@ -267,6 +267,27 @@ Possible values are:
267 :group 'desktop 267 :group 'desktop
268 :version "21.4") 268 :version "21.4")
269 269
270(defcustom desktop-restore-eager t
271 "Number of buffers to restore immediately.
272Remaining buffers are restored lazily (when Emacs is idle).
273If value is t, all buffers are restored immediately."
274 :type '(choice (const t) integer)
275 :group 'desktop
276 :version "21.4")
277
278(defcustom desktop-lazy-verbose t
279 "Verbose reporting of lazily created buffers."
280 :type 'boolean
281 :group 'desktop
282 :version "21.4")
283
284(defcustom desktop-lazy-idle-delay 5
285 "Idle delay before starting to create buffers.
286See `desktop-restore-eager'."
287 :type 'integer
288 :group 'desktop
289 :version "21.4")
290
270;;;###autoload 291;;;###autoload
271(defvar desktop-save-buffer nil 292(defvar desktop-save-buffer nil
272 "When non-nil, save buffer status in desktop file. 293 "When non-nil, save buffer status in desktop file.
@@ -365,6 +386,7 @@ This kills all buffers except for internal ones and those matching
365`desktop-clear-preserve-buffers'. Furthermore, it clears the 386`desktop-clear-preserve-buffers'. Furthermore, it clears the
366variables listed in `desktop-globals-to-clear'." 387variables listed in `desktop-globals-to-clear'."
367 (interactive) 388 (interactive)
389 (desktop-lazy-abort)
368 (dolist (var desktop-globals-to-clear) 390 (dolist (var desktop-globals-to-clear)
369 (if (symbolp var) 391 (if (symbolp var)
370 (eval `(setq-default ,var nil)) 392 (eval `(setq-default ,var nil))
@@ -625,12 +647,13 @@ See also `desktop-base-file-name'."
625 (setq locals (cdr locals))) 647 (setq locals (cdr locals)))
626 ll))) 648 ll)))
627 (buffer-list))) 649 (buffer-list)))
650 (eager desktop-restore-eager)
628 (buf (get-buffer-create "*desktop*"))) 651 (buf (get-buffer-create "*desktop*")))
629 (set-buffer buf) 652 (set-buffer buf)
630 (erase-buffer) 653 (erase-buffer)
631 654
632 (insert 655 (insert
633 ";; -*- coding: utf-8-emacs; -*-\n" 656 ";; -*- mode: emacs-lisp; coding: utf-8-emacs; -*-\n"
634 desktop-header 657 desktop-header
635 ";; Created " (current-time-string) "\n" 658 ";; Created " (current-time-string) "\n"
636 ";; Desktop file format version " desktop-file-version "\n" 659 ";; Desktop file format version " desktop-file-version "\n"
@@ -645,14 +668,21 @@ See also `desktop-base-file-name'."
645 668
646 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n") 669 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n")
647 (mapc #'(lambda (l) 670 (mapc #'(lambda (l)
648 (if (apply 'desktop-save-buffer-p l) 671 (when (apply 'desktop-save-buffer-p l)
649 (progn 672 (insert "("
650 (insert "(desktop-create-buffer " desktop-file-version) 673 (if (or (not (integerp eager))
651 (mapc #'(lambda (e) 674 (unless (zerop eager)
652 (insert "\n " (desktop-value-to-string e))) 675 (setq eager (1- eager))
653 l) 676 t))
654 (insert ")\n\n")))) 677 "desktop-create-buffer"
655 info) 678 "desktop-append-buffer-args")
679 " "
680 desktop-file-version)
681 (mapc #'(lambda (e)
682 (insert "\n " (desktop-value-to-string e)))
683 l)
684 (insert ")\n\n")))
685 info)
656 (setq default-directory dirname) 686 (setq default-directory dirname)
657 (when (file-exists-p filename) (delete-file filename)) 687 (when (file-exists-p filename) (delete-file filename))
658 (let ((coding-system-for-write 'utf-8-emacs)) 688 (let ((coding-system-for-write 'utf-8-emacs))
@@ -670,6 +700,11 @@ This function also sets `desktop-dirname' to nil."
670 (when (file-exists-p filename) 700 (when (file-exists-p filename)
671 (delete-file filename))))) 701 (delete-file filename)))))
672 702
703(defvar desktop-buffer-args-list nil
704 "List of args for `desktop-create-buffer'.")
705
706(defvar desktop-lazy-timer nil)
707
673;; ---------------------------------------------------------------------------- 708;; ----------------------------------------------------------------------------
674;;;###autoload 709;;;###autoload
675(defun desktop-read (&optional dirname) 710(defun desktop-read (&optional dirname)
@@ -706,6 +741,7 @@ It returns t if a desktop file was loaded, nil otherwise."
706 (let ((desktop-first-buffer nil) 741 (let ((desktop-first-buffer nil)
707 (desktop-buffer-ok-count 0) 742 (desktop-buffer-ok-count 0)
708 (desktop-buffer-fail-count 0)) 743 (desktop-buffer-fail-count 0))
744 (setq desktop-lazy-timer nil)
709 ;; Evaluate desktop buffer. 745 ;; Evaluate desktop buffer.
710 (load (expand-file-name desktop-base-file-name desktop-dirname) t t t) 746 (load (expand-file-name desktop-base-file-name desktop-dirname) t t t)
711 ;; `desktop-create-buffer' puts buffers at end of the buffer list. 747 ;; `desktop-create-buffer' puts buffers at end of the buffer list.
@@ -717,11 +753,15 @@ It returns t if a desktop file was loaded, nil otherwise."
717 (run-hooks 'desktop-delay-hook) 753 (run-hooks 'desktop-delay-hook)
718 (setq desktop-delay-hook nil) 754 (setq desktop-delay-hook nil)
719 (run-hooks 'desktop-after-read-hook) 755 (run-hooks 'desktop-after-read-hook)
720 (message "Desktop: %d buffer%s restored%s." 756 (message "Desktop: %d buffer%s restored%s%s."
721 desktop-buffer-ok-count 757 desktop-buffer-ok-count
722 (if (= 1 desktop-buffer-ok-count) "" "s") 758 (if (= 1 desktop-buffer-ok-count) "" "s")
723 (if (< 0 desktop-buffer-fail-count) 759 (if (< 0 desktop-buffer-fail-count)
724 (format ", %d failed to restore" desktop-buffer-fail-count) 760 (format ", %d failed to restore" desktop-buffer-fail-count)
761 "")
762 (if desktop-buffer-args-list
763 (format ", %d to restore lazily"
764 (length desktop-buffer-args-list))
725 "")) 765 ""))
726 t) 766 t)
727 ;; No desktop file found. 767 ;; No desktop file found.
@@ -917,6 +957,69 @@ directory DIRNAME."
917 (cons 'case-replace cr) 957 (cons 'case-replace cr)
918 (cons 'overwrite-mode (car mim))))) 958 (cons 'overwrite-mode (car mim)))))
919 959
960(defun desktop-append-buffer-args (&rest args)
961 "Append ARGS at end of `desktop-buffer-args-list'
962ARGS must be an argument list for `desktop-create-buffer'."
963 (setq desktop-buffer-args-list (nconc desktop-buffer-args-list (list args)))
964 (unless desktop-lazy-timer
965 (setq desktop-lazy-timer
966 (run-with-idle-timer desktop-lazy-idle-delay t 'desktop-idle-create-buffers))))
967
968(defun desktop-lazy-create-buffer ()
969 "Pop args from `desktop-buffer-args-list', create buffer and bury it."
970 (when desktop-buffer-args-list
971 (let* ((remaining (length desktop-buffer-args-list))
972 (args (pop desktop-buffer-args-list))
973 (buffer-name (nth 2 args))
974 (msg (format "Desktop lazily opening %s (%s remaining)..."
975 buffer-name remaining)))
976 (when desktop-lazy-verbose
977 (message msg))
978 (let ((desktop-first-buffer nil)
979 (desktop-buffer-ok-count 0)
980 (desktop-buffer-fail-count 0))
981 (apply 'desktop-create-buffer args)
982 (run-hooks 'desktop-delay-hook)
983 (setq desktop-delay-hook nil)
984 (bury-buffer (get-buffer buffer-name))
985 (when desktop-lazy-verbose
986 (message "%s%s" msg (if (> desktop-buffer-ok-count 0) "done" "failed")))))))
987
988(defun desktop-idle-create-buffers ()
989 "Create buffers until the user does something, then stop.
990If there are no buffers left to create, kill the timer."
991 (let ((repeat 1))
992 (while (and repeat desktop-buffer-args-list)
993 (save-window-excursion
994 (desktop-lazy-create-buffer))
995 (setq repeat (sit-for 0.2))
996 (unless desktop-buffer-args-list
997 (cancel-timer desktop-lazy-timer)
998 (setq desktop-lazy-timer nil)
999 (message "Lazy desktop load complete")
1000 (sit-for 3)
1001 (message "")))))
1002
1003(defun desktop-lazy-complete ()
1004 "Run the desktop load to completion."
1005 (interactive)
1006 (let ((desktop-lazy-verbose t))
1007 (while desktop-buffer-args-list
1008 (save-window-excursion
1009 (desktop-lazy-create-buffer)))
1010 (message "Lazy desktop load complete")))
1011
1012(defun desktop-lazy-abort ()
1013 "Abort lazy loading of the desktop."
1014 (interactive)
1015 (when desktop-lazy-timer
1016 (cancel-timer desktop-lazy-timer)
1017 (setq desktop-lazy-timer nil))
1018 (when desktop-buffer-args-list
1019 (setq desktop-buffer-args-list nil)
1020 (when (interactive-p)
1021 (message "Lazy desktop load aborted"))))
1022
920;; ---------------------------------------------------------------------------- 1023;; ----------------------------------------------------------------------------
921;; When `desktop-save-mode' is non-nil and "--no-desktop" is not specified on the 1024;; When `desktop-save-mode' is non-nil and "--no-desktop" is not specified on the
922;; command line, we do the rest of what it takes to use desktop, but do it 1025;; command line, we do the rest of what it takes to use desktop, but do it
diff --git a/lisp/ebuff-menu.el b/lisp/ebuff-menu.el
index 2bfbace4c4b..bfac2afe6e9 100644
--- a/lisp/ebuff-menu.el
+++ b/lisp/ebuff-menu.el
@@ -149,7 +149,9 @@ Letters do not insert themselves; instead, they are commands.
149 149
150Entry to this mode via command `electric-buffer-list' calls the value of 150Entry to this mode via command `electric-buffer-list' calls the value of
151`electric-buffer-menu-mode-hook'." 151`electric-buffer-menu-mode-hook'."
152 (kill-all-local-variables) 152 (let ((saved header-line-format))
153 (kill-all-local-variables)
154 (setq header-line-format saved))
153 (use-local-map electric-buffer-menu-mode-map) 155 (use-local-map electric-buffer-menu-mode-map)
154 (setq mode-name "Electric Buffer Menu") 156 (setq mode-name "Electric Buffer Menu")
155 (setq mode-line-buffer-identification "Electric Buffer List") 157 (setq mode-line-buffer-identification "Electric Buffer List")
diff --git a/lisp/electric.el b/lisp/electric.el
index 3d2bf140c8c..18a4d8388c5 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -144,31 +144,17 @@
144 (buf (get-buffer buffer)) 144 (buf (get-buffer buffer))
145 (one-window (one-window-p t)) 145 (one-window (one-window-p t))
146 (pop-up-windows t) 146 (pop-up-windows t)
147 (pop-up-frames nil) 147 (pop-up-frames nil))
148 (target-height)
149 (lines))
150 (if (not buf) 148 (if (not buf)
151 (error "Buffer %s does not exist" buffer) 149 (error "Buffer %s does not exist" buffer)
152 (with-current-buffer buf
153 (setq lines (count-lines (point-min) (point-max)))
154 (setq target-height
155 (min (max (if max-height (min max-height (1+ lines)) (1+ lines))
156 window-min-height)
157 (save-window-excursion
158 (delete-other-windows)
159 (1- (window-height (selected-window)))))))
160 (cond ((and (eq (window-buffer win) buf)) 150 (cond ((and (eq (window-buffer win) buf))
161 (select-window win)) 151 (select-window win))
162 (one-window 152 (one-window
163 (pop-to-buffer buffer) 153 (pop-to-buffer buffer)
164 (setq win (selected-window)) 154 (setq win (selected-window)))
165 (enlarge-window (- target-height (window-height win))))
166 (t 155 (t
167 (switch-to-buffer buf))) 156 (switch-to-buffer buf)))
168 (if (and (not max-height) 157 (fit-window-to-buffer win max-height)
169 (> target-height (window-height (selected-window))))
170 (progn (goto-char (window-start win))
171 (enlarge-window (- target-height (window-height win)))))
172 (goto-char (point-min)) 158 (goto-char (point-min))
173 win))) 159 win)))
174 160
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 196786e9179..0a75a43827e 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -135,7 +135,7 @@ or macro definition or a defcustom)."
135 135
136 136
137(defun autoload-trim-file-name (file) 137(defun autoload-trim-file-name (file)
138 ;; Returns a relative pathname of FILE 138 ;; Returns a relative file path for FILE
139 ;; starting from the directory that loaddefs.el is in. 139 ;; starting from the directory that loaddefs.el is in.
140 ;; That is normally a directory in load-path, 140 ;; That is normally a directory in load-path,
141 ;; which means Emacs will be able to find FILE when it looks. 141 ;; which means Emacs will be able to find FILE when it looks.
@@ -273,7 +273,7 @@ are used."
273 output-end) 273 output-end)
274 274
275 ;; If the autoload section we create here uses an absolute 275 ;; If the autoload section we create here uses an absolute
276 ;; pathname for FILE in its header, and then Emacs is installed 276 ;; file name for FILE in its header, and then Emacs is installed
277 ;; under a different path on another system, 277 ;; under a different path on another system,
278 ;; `update-autoloads-here' won't be able to find the files to be 278 ;; `update-autoloads-here' won't be able to find the files to be
279 ;; autoloaded. So, if FILE is in the same directory or a 279 ;; autoloaded. So, if FILE is in the same directory or a
diff --git a/lisp/emacs-lisp/elint.el b/lisp/emacs-lisp/elint.el
index 9454bfc9da3..d4967a7cd06 100644
--- a/lisp/emacs-lisp/elint.el
+++ b/lisp/emacs-lisp/elint.el
@@ -29,7 +29,7 @@
29;; mispellings and undefined variables, although it can also catch 29;; mispellings and undefined variables, although it can also catch
30;; function calls with the wrong number of arguments. 30;; function calls with the wrong number of arguments.
31 31
32;; Before using, call `elint-initialize' to set up som argument 32;; Before using, call `elint-initialize' to set up some argument
33;; data. This takes a while. Then call elint-current-buffer or 33;; data. This takes a while. Then call elint-current-buffer or
34;; elint-defun to lint a buffer or a defun. 34;; elint-defun to lint a buffer or a defun.
35 35
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index a70adb4d423..7e2ac5aa883 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -1,6 +1,6 @@
1;;; find-func.el --- find the definition of the Emacs Lisp function near point 1;;; find-func.el --- find the definition of the Emacs Lisp function near point
2 2
3;; Copyright (C) 1997, 1999, 2001, 2004 Free Software Foundation, Inc. 3;; Copyright (C) 1997, 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
4 4
5;; Author: Jens Petersen <petersen@kurims.kyoto-u.ac.jp> 5;; Author: Jens Petersen <petersen@kurims.kyoto-u.ac.jp>
6;; Maintainer: petersen@kurims.kyoto-u.ac.jp 6;; Maintainer: petersen@kurims.kyoto-u.ac.jp
@@ -76,16 +76,37 @@ Please send improvements and fixes to the maintainer."
76 :version "21.1") 76 :version "21.1")
77 77
78(defcustom find-variable-regexp 78(defcustom find-variable-regexp
79 (concat"^\\s-*(def[^umag]\\(\\w\\|\\s_\\)+\\*?" find-function-space-re "%s\\(\\s-\\|$\\)") 79 (concat"^\\s-*(def[^fumag]\\(\\w\\|\\s_\\)+\\*?" find-function-space-re "%s\\(\\s-\\|$\\)")
80 "The regexp used by `find-variable' to search for a variable definition. 80 "The regexp used by `find-variable' to search for a variable definition.
81It should match right up to the variable name. The default value 81Note it must contain a `%s' at the place where `format'
82avoids `defun', `defmacro', `defalias', `defadvice', `defgroup'. 82should insert the variable name. The default value
83avoids `defun', `defmacro', `defalias', `defadvice', `defgroup', `defface'.
83 84
84Please send improvements and fixes to the maintainer." 85Please send improvements and fixes to the maintainer."
85 :type 'regexp 86 :type 'regexp
86 :group 'find-function 87 :group 'find-function
87 :version "21.1") 88 :version "21.1")
88 89
90(defcustom find-face-regexp
91 (concat"^\\s-*(defface" find-function-space-re "%s\\(\\s-\\|$\\)")
92 "The regexp used by `find-face' to search for a face definition.
93Note it must contain a `%s' at the place where `format'
94should insert the face name.
95
96Please send improvements and fixes to the maintainer."
97 :type 'regexp
98 :group 'find-function
99 :version "21.4")
100
101(defvar find-function-regexp-alist
102 '((nil . find-function-regexp)
103 (defvar . find-variable-regexp)
104 (defface . find-face-regexp))
105 "Alist mapping definition types into regexp variables.
106Each regexp variable's value should actually be a format string
107to be used to substitute the desired symbol name into the regexp.")
108(put 'find-function-regexp-alist 'risky-local-variable t)
109
89(defcustom find-function-source-path nil 110(defcustom find-function-source-path nil
90 "The default list of directories where `find-function' searches. 111 "The default list of directories where `find-function' searches.
91 112
@@ -136,9 +157,9 @@ See the functions `find-function' and `find-variable'."
136If nil, do not try to find the source code of functions and variables 157If nil, do not try to find the source code of functions and variables
137defined in C.") 158defined in C.")
138 159
139(defun find-function-C-source (fun-or-var file variable-p) 160(defun find-function-C-source (fun-or-var file type)
140 "Find the source location where SUBR-OR-VAR is defined in FILE. 161 "Find the source location where SUBR-OR-VAR is defined in FILE.
141VARIABLE-P should be non-nil for a variable or nil for a subroutine." 162TYPE should be nil to find a function, or `defvar' to find a variable."
142 (unless find-function-C-source-directory 163 (unless find-function-C-source-directory
143 (setq find-function-C-source-directory 164 (setq find-function-C-source-directory
144 (read-directory-name "Emacs C source dir: " nil nil t))) 165 (read-directory-name "Emacs C source dir: " nil nil t)))
@@ -146,12 +167,12 @@ VARIABLE-P should be non-nil for a variable or nil for a subroutine."
146 (unless (file-readable-p file) 167 (unless (file-readable-p file)
147 (error "The C source file %s is not available" 168 (error "The C source file %s is not available"
148 (file-name-nondirectory file))) 169 (file-name-nondirectory file)))
149 (unless variable-p 170 (unless type
150 (setq fun-or-var (indirect-function fun-or-var))) 171 (setq fun-or-var (indirect-function fun-or-var)))
151 (with-current-buffer (find-file-noselect file) 172 (with-current-buffer (find-file-noselect file)
152 (goto-char (point-min)) 173 (goto-char (point-min))
153 (unless (re-search-forward 174 (unless (re-search-forward
154 (if variable-p 175 (if type
155 (concat "DEFVAR[A-Z_]*[ \t\n]*([ \t\n]*\"" 176 (concat "DEFVAR[A-Z_]*[ \t\n]*([ \t\n]*\""
156 (regexp-quote (symbol-name fun-or-var)) 177 (regexp-quote (symbol-name fun-or-var))
157 "\"") 178 "\"")
@@ -175,10 +196,12 @@ VARIABLE-P should be non-nil for a variable or nil for a subroutine."
175 (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf))))) 196 (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
176 197
177;;;###autoload 198;;;###autoload
178(defun find-function-search-for-symbol (symbol variable-p library) 199(defun find-function-search-for-symbol (symbol type library)
179 "Search for SYMBOL. 200 "Search for SYMBOL's definition of type TYPE in LIBRARY.
180If VARIABLE-P is nil, `find-function-regexp' is used, otherwise 201If TYPE is nil, look for a function definition.
181`find-variable-regexp' is used. The search is done in library LIBRARY." 202Otherwise, TYPE specifies the kind of definition,
203and it is interpreted via `find-function-regexp-alist'.
204The search is done in the source for library LIBRARY."
182 (if (null library) 205 (if (null library)
183 (error "Don't know where `%s' is defined" symbol)) 206 (error "Don't know where `%s' is defined" symbol))
184 ;; Some functions are defined as part of the construct 207 ;; Some functions are defined as part of the construct
@@ -186,14 +209,13 @@ If VARIABLE-P is nil, `find-function-regexp' is used, otherwise
186 (while (and (symbolp symbol) (get symbol 'definition-name)) 209 (while (and (symbolp symbol) (get symbol 'definition-name))
187 (setq symbol (get symbol 'definition-name))) 210 (setq symbol (get symbol 'definition-name)))
188 (if (string-match "\\`src/\\(.*\\.c\\)\\'" library) 211 (if (string-match "\\`src/\\(.*\\.c\\)\\'" library)
189 (find-function-C-source symbol (match-string 1 library) variable-p) 212 (find-function-C-source symbol (match-string 1 library) type)
190 (if (string-match "\\.el\\(c\\)\\'" library) 213 (if (string-match "\\.el\\(c\\)\\'" library)
191 (setq library (substring library 0 (match-beginning 1)))) 214 (setq library (substring library 0 (match-beginning 1))))
192 (let* ((filename (find-library-name library))) 215 (let* ((filename (find-library-name library))
216 (regexp-symbol (cdr (assq type find-function-regexp-alist))))
193 (with-current-buffer (find-file-noselect filename) 217 (with-current-buffer (find-file-noselect filename)
194 (let ((regexp (format (if variable-p 218 (let ((regexp (format (symbol-value regexp-symbol)
195 find-variable-regexp
196 find-function-regexp)
197 (regexp-quote (symbol-name symbol)))) 219 (regexp-quote (symbol-name symbol))))
198 (case-fold-search)) 220 (case-fold-search))
199 (with-syntax-table emacs-lisp-mode-syntax-table 221 (with-syntax-table emacs-lisp-mode-syntax-table
@@ -245,55 +267,53 @@ in `load-path'."
245 ((symbol-file function 'defun))))) 267 ((symbol-file function 'defun)))))
246 (find-function-search-for-symbol function nil library)))) 268 (find-function-search-for-symbol function nil library))))
247 269
248(defalias 'function-at-point 'function-called-at-point) 270(defun find-function-read (&optional type)
249
250(defun find-function-read (&optional variable-p)
251 "Read and return an interned symbol, defaulting to the one near point. 271 "Read and return an interned symbol, defaulting to the one near point.
252 272
253If the optional VARIABLE-P is nil, then a function is gotten 273If TYPE is nil, insist on a symbol with a function definition.
254defaulting to the value of the function `function-at-point', otherwise 274Otherwise TYPE should be `defvar' or `defface'.
255a variable is asked for, with the default coming from 275If TYPE is nil, defaults using `function-called-at-point',
256`variable-at-point'." 276otherwise uses `variable-at-point'."
257 (let ((symb (funcall (if variable-p 277 (let ((symb (if (null type)
258 'variable-at-point 278 (function-called-at-point)
259 'function-at-point))) 279 (if (eq type 'defvar)
280 (variable-at-point)
281 (variable-at-point t))))
282 (predicate (cdr (assq type '((nil . fboundp) (defvar . boundp)
283 (defface . facep)))))
284 (prompt (cdr (assq type '((nil . "function") (defvar . "variable")
285 (defface . "face")))))
260 (enable-recursive-minibuffers t) 286 (enable-recursive-minibuffers t)
261 val) 287 val)
262 (if (equal symb 0) 288 (if (equal symb 0)
263 (setq symb nil)) 289 (setq symb nil))
264 (setq val (if variable-p 290 (setq val (completing-read
265 (completing-read 291 (concat "Find "
266 (concat "Find variable" 292 prompt
267 (if symb 293 (if symb
268 (format " (default %s)" symb)) 294 (format " (default %s)" symb))
269 ": ") 295 ": ")
270 obarray 'boundp t nil) 296 obarray predicate t nil))
271 (completing-read
272 (concat "Find function"
273 (if symb
274 (format " (default %s)" symb))
275 ": ")
276 obarray 'fboundp t nil)))
277 (list (if (equal val "") 297 (list (if (equal val "")
278 symb 298 symb
279 (intern val))))) 299 (intern val)))))
280 300
281(defun find-function-do-it (symbol variable-p switch-fn) 301(defun find-function-do-it (symbol type switch-fn)
282 "Find Emacs Lisp SYMBOL in a buffer and display it. 302 "Find Emacs Lisp SYMBOL in a buffer and display it.
283If VARIABLE-P is nil, a function definition is searched for, otherwise 303TYPE is nil to search for a function definition,
284a variable definition is searched for. The start of a definition is 304or else `defvar' or `defface'.
285centered according to the variable `find-function-recenter-line'. 305
286See also `find-function-after-hook' It is displayed with function SWITCH-FN. 306The variable `find-function-recenter-line' controls how
307to recenter the display. SWITCH-FN is the function to call
308to display and select the buffer.
309See also `find-function-after-hook'.
287 310
288Point is saved in the buffer if it is one of the current buffers." 311Set mark before moving, if the buffer already existed."
289 (let* ((orig-point (point)) 312 (let* ((orig-point (point))
290 (orig-buf (window-buffer)) 313 (orig-buf (window-buffer))
291 (orig-buffers (buffer-list)) 314 (orig-buffers (buffer-list))
292 (buffer-point (save-excursion 315 (buffer-point (save-excursion
293 (funcall (if variable-p 316 (find-definition-noselect symbol type)))
294 'find-variable-noselect
295 'find-function-noselect)
296 symbol)))
297 (new-buf (car buffer-point)) 317 (new-buf (car buffer-point))
298 (new-point (cdr buffer-point))) 318 (new-point (cdr buffer-point)))
299 (when buffer-point 319 (when buffer-point
@@ -309,9 +329,9 @@ Point is saved in the buffer if it is one of the current buffers."
309 "Find the definition of the FUNCTION near point. 329 "Find the definition of the FUNCTION near point.
310 330
311Finds the Emacs Lisp library containing the definition of the function 331Finds the Emacs Lisp library containing the definition of the function
312near point (selected by `function-at-point') in a buffer and 332near point (selected by `function-called-at-point') in a buffer and
313places point before the definition. Point is saved in the buffer if 333places point before the definition.
314it is one of the current buffers. 334Set mark before moving, if the buffer already existed.
315 335
316The library where FUNCTION is defined is searched for in 336The library where FUNCTION is defined is searched for in
317`find-function-source-path', if non nil, otherwise in `load-path'. 337`find-function-source-path', if non nil, otherwise in `load-path'.
@@ -340,15 +360,15 @@ See `find-function' for more details."
340 "Return a pair `(BUFFER . POINT)' pointing to the definition of SYMBOL. 360 "Return a pair `(BUFFER . POINT)' pointing to the definition of SYMBOL.
341 361
342Finds the Emacs Lisp library containing the definition of SYMBOL 362Finds the Emacs Lisp library containing the definition of SYMBOL
343in a buffer and the point of the definition. The buffer is 363in a buffer, and the point of the definition. It does not switch
344not selected. 364to the buffer or display it.
345 365
346The library where VARIABLE is defined is searched for in FILE or 366The library where VARIABLE is defined is searched for in FILE or
347`find-function-source-path', if non nil, otherwise in `load-path'." 367`find-function-source-path', if non nil, otherwise in `load-path'."
348 (if (not variable) 368 (if (not variable)
349 (error "You didn't specify a variable")) 369 (error "You didn't specify a variable"))
350 (let ((library (or file (symbol-file variable 'defvar)))) 370 (let ((library (or file (symbol-file variable 'defvar))))
351 (find-function-search-for-symbol variable 'variable library))) 371 (find-function-search-for-symbol variable 'defvar library)))
352 372
353;;;###autoload 373;;;###autoload
354(defun find-variable (variable) 374(defun find-variable (variable)
@@ -356,35 +376,70 @@ The library where VARIABLE is defined is searched for in FILE or
356 376
357Finds the Emacs Lisp library containing the definition of the variable 377Finds the Emacs Lisp library containing the definition of the variable
358near point (selected by `variable-at-point') in a buffer and 378near point (selected by `variable-at-point') in a buffer and
359places point before the definition. Point is saved in the buffer if 379places point before the definition.
360it is one of the current buffers. 380
381Set mark before moving, if the buffer already existed.
361 382
362The library where VARIABLE is defined is searched for in 383The library where VARIABLE is defined is searched for in
363`find-function-source-path', if non nil, otherwise in `load-path'. 384`find-function-source-path', if non nil, otherwise in `load-path'.
364See also `find-function-recenter-line' and `find-function-after-hook'." 385See also `find-function-recenter-line' and `find-function-after-hook'."
365 (interactive (find-function-read 'variable)) 386 (interactive (find-function-read 'defvar))
366 (find-function-do-it variable t 'switch-to-buffer)) 387 (find-function-do-it variable 'defvar 'switch-to-buffer))
367 388
368;;;###autoload 389;;;###autoload
369(defun find-variable-other-window (variable) 390(defun find-variable-other-window (variable)
370 "Find, in another window, the definition of VARIABLE near point. 391 "Find, in another window, the definition of VARIABLE near point.
371 392
372See `find-variable' for more details." 393See `find-variable' for more details."
373 (interactive (find-function-read 'variable)) 394 (interactive (find-function-read 'defvar))
374 (find-function-do-it variable t 'switch-to-buffer-other-window)) 395 (find-function-do-it variable 'defvar 'switch-to-buffer-other-window))
375 396
376;;;###autoload 397;;;###autoload
377(defun find-variable-other-frame (variable) 398(defun find-variable-other-frame (variable)
378 "Find, in annother frame, the definition of VARIABLE near point. 399 "Find, in annother frame, the definition of VARIABLE near point.
379 400
380See `find-variable' for more details." 401See `find-variable' for more details."
381 (interactive (find-function-read 'variable)) 402 (interactive (find-function-read 'defvar))
382 (find-function-do-it variable t 'switch-to-buffer-other-frame)) 403 (find-function-do-it variable 'defvar 'switch-to-buffer-other-frame))
404
405;;;###autoload
406(defun find-definition-noselect (symbol type &optional file)
407 "Return a pair `(BUFFER . POINT)' pointing to the definition of SYMBOL.
408TYPE says what type of definition: nil for a function,
409`defvar' or `defface' for a variable or face. This functoin
410does not switch to the buffer or display it.
411
412The library where SYMBOL is defined is searched for in FILE or
413`find-function-source-path', if non nil, otherwise in `load-path'."
414 (if (not symbol)
415 (error "You didn't specify a symbol"))
416 (if (null type)
417 (find-function-noselect symbol)
418 (let ((library (or file (symbol-file symbol type))))
419 (find-function-search-for-symbol symbol type library))))
420
421;; For symmetry, this should be called find-face; but some programs
422;; assume that, if that name is defined, it means something else.
423;;;###autoload
424(defun find-face-definition (face)
425 "Find the definition of FACE. FACE defaults to the name near point.
426
427Finds the Emacs Lisp library containing the definition of the face
428near point (selected by `variable-at-point') in a buffer and
429places point before the definition.
430
431Set mark before moving, if the buffer already existed.
432
433The library where FACE is defined is searched for in
434`find-function-source-path', if non nil, otherwise in `load-path'.
435See also `find-function-recenter-line' and `find-function-after-hook'."
436 (interactive (find-function-read 'defface))
437 (find-function-do-it face 'defface 'switch-to-buffer))
383 438
384;;;###autoload 439;;;###autoload
385(defun find-function-on-key (key) 440(defun find-function-on-key (key)
386 "Find the function that KEY invokes. KEY is a string. 441 "Find the function that KEY invokes. KEY is a string.
387Point is saved if FUNCTION is in the current buffer." 442Set mark before moving, if the buffer already existed."
388 (interactive "kFind function on key: ") 443 (interactive "kFind function on key: ")
389 (let (defn) 444 (let (defn)
390 (save-excursion 445 (save-excursion
@@ -412,7 +467,7 @@ Point is saved if FUNCTION is in the current buffer."
412(defun find-function-at-point () 467(defun find-function-at-point ()
413 "Find directly the function at point in the other window." 468 "Find directly the function at point in the other window."
414 (interactive) 469 (interactive)
415 (let ((symb (function-at-point))) 470 (let ((symb (function-called-at-point)))
416 (when symb 471 (when symb
417 (find-function-other-window symb)))) 472 (find-function-other-window symb))))
418 473
@@ -437,5 +492,5 @@ Point is saved if FUNCTION is in the current buffer."
437 492
438(provide 'find-func) 493(provide 'find-func)
439 494
440;;; arch-tag: 43ecd81c-74dc-4d9a-8f63-a61e55670d64 495;; arch-tag: 43ecd81c-74dc-4d9a-8f63-a61e55670d64
441;;; find-func.el ends here 496;;; find-func.el ends here
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el
index 671f3c8ce2a..701da1c4dec 100644
--- a/lisp/emacs-lisp/lisp-mnt.el
+++ b/lisp/emacs-lisp/lisp-mnt.el
@@ -304,9 +304,14 @@ If FILE is nil, execute BODY in the current buffer."
304 (if ,filesym 304 (if ,filesym
305 (with-temp-buffer 305 (with-temp-buffer
306 (insert-file-contents ,filesym) 306 (insert-file-contents ,filesym)
307 (lisp-mode)
307 ,@body) 308 ,@body)
308 (save-excursion 309 (save-excursion
309 ,@body))))) 310 ;; Switching major modes is too drastic, so just switch
311 ;; temporarily to the Lisp mode syntax table.
312 (with-syntax-table lisp-mode-syntax-table
313 ,@body))))))
314
310(put 'lm-with-file 'lisp-indent-function 1) 315(put 'lm-with-file 'lisp-indent-function 1)
311(put 'lm-with-file 'edebug-form-spec t) 316(put 'lm-with-file 'edebug-form-spec t)
312 317
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index f4364c38e8d..f181f3683f0 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1125,7 +1125,8 @@ ENDPOS is encountered."
1125 (set-marker endmark nil)))) 1125 (set-marker endmark nil))))
1126 1126
1127(defun indent-pp-sexp (&optional arg) 1127(defun indent-pp-sexp (&optional arg)
1128 "Indent each line of the list or, with prefix ARG, pretty-printify the list." 1128 "Indent each line of the list starting just after point, or prettyprint it.
1129A prefix argument specifies pretty-printing."
1129 (interactive "P") 1130 (interactive "P")
1130 (if arg 1131 (if arg
1131 (save-excursion 1132 (save-excursion
diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el
index 77a12167c30..019a45213c8 100644
--- a/lisp/emacs-lisp/re-builder.el
+++ b/lisp/emacs-lisp/re-builder.el
@@ -1,6 +1,6 @@
1;;; re-builder.el --- building Regexps with visual feedback 1;;; re-builder.el --- building Regexps with visual feedback
2 2
3;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. 3;; Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
4 4
5;; Author: Detlev Zundel <dzu@gnu.org> 5;; Author: Detlev Zundel <dzu@gnu.org>
6;; Keywords: matching, lisp, tools 6;; Keywords: matching, lisp, tools
@@ -61,12 +61,12 @@
61;; even the auto updates go all the way. Forcing an update overrides 61;; even the auto updates go all the way. Forcing an update overrides
62;; this limit allowing an easy way to see all matches. 62;; this limit allowing an easy way to see all matches.
63 63
64;; Currently `re-builder' understands four different forms of input, 64;; Currently `re-builder' understands five different forms of input,
65;; namely `read', `string', `sregex' and `lisp-re' syntax. Read 65;; namely `read', `string', `rx', `sregex' and `lisp-re' syntax. Read
66;; syntax and string syntax are both delimited by `"'s and behave 66;; syntax and string syntax are both delimited by `"'s and behave
67;; according to their name. With the `string' syntax there's no need 67;; according to their name. With the `string' syntax there's no need
68;; to escape the backslashes and double quotes simplifying the editing 68;; to escape the backslashes and double quotes simplifying the editing
69;; somewhat. The other two allow editing of symbolic regular 69;; somewhat. The other three allow editing of symbolic regular
70;; expressions supported by the packages of the same name. (`lisp-re' 70;; expressions supported by the packages of the same name. (`lisp-re'
71;; is a package by me and its support may go away as it is nearly the 71;; is a package by me and its support may go away as it is nearly the
72;; same as the `sregex' package in Emacs) 72;; same as the `sregex' package in Emacs)
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index c6cce457fe6..127b8fe608b 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -471,50 +471,81 @@ These special properties include `invisible', `intangible' and `read-only'."
471 col))) 471 col)))
472 472
473;;;###autoload 473;;;###autoload
474(defun list-colors-display (&optional list) 474(defun list-colors-display (&optional list buffer-name)
475 "Display names of defined colors, and show what they look like. 475 "Display names of defined colors, and show what they look like.
476If the optional argument LIST is non-nil, it should be a list of 476If the optional argument LIST is non-nil, it should be a list of
477colors to display. Otherwise, this command computes a list 477colors to display. Otherwise, this command computes a list of
478of colors that the current display can handle." 478colors that the current display can handle. If the optional
479argument BUFFER-NAME is nil, it defaults to *Colors*."
479 (interactive) 480 (interactive)
480 (when (and (null list) (> (display-color-cells) 0)) 481 (when (and (null list) (> (display-color-cells) 0))
481 (setq list (defined-colors)) 482 (setq list (list-colors-duplicates (defined-colors)))
482 ;; Delete duplicate colors.
483
484 ;; Identify duplicate colors by the name rather than the color
485 ;; value. For example, on MS-Windows, logical colors are added to
486 ;; the list that might have the same value but have different
487 ;; names and meanings. For example, `SystemMenuText' (the color
488 ;; w32 uses for the text in menu entries) and `SystemWindowText'
489 ;; (the default color w32 uses for the text in windows and
490 ;; dialogs) may be the same display color and be adjacent in the
491 ;; list. Detecting duplicates by name insures that both of these
492 ;; colors remain despite identical color values.
493 (let ((l list))
494 (while (cdr l)
495 (if (facemenu-color-name-equal (car l) (car (cdr l)))
496 (setcdr l (cdr (cdr l)))
497 (setq l (cdr l)))))
498 (when (memq (display-visual-class) '(gray-scale pseudo-color direct-color)) 483 (when (memq (display-visual-class) '(gray-scale pseudo-color direct-color))
499 ;; Don't show more than what the display can handle. 484 ;; Don't show more than what the display can handle.
500 (let ((lc (nthcdr (1- (display-color-cells)) list))) 485 (let ((lc (nthcdr (1- (display-color-cells)) list)))
501 (if lc 486 (if lc
502 (setcdr lc nil))))) 487 (setcdr lc nil)))))
503 (with-output-to-temp-buffer "*Colors*" 488 (with-output-to-temp-buffer (or buffer-name "*Colors*")
504 (save-excursion 489 (save-excursion
505 (set-buffer standard-output) 490 (set-buffer standard-output)
506 (let (s) 491 (setq truncate-lines t)
507 (while list 492 (if temp-buffer-show-function
508 (setq s (point)) 493 (list-colors-print list)
509 (insert (car list)) 494 ;; Call list-colors-print from temp-buffer-show-hook
510 (indent-to 20) 495 ;; to get the right value of window-width in list-colors-print
511 (put-text-property s (point) 'face 496 ;; after the buffer is displayed.
512 (cons 'background-color (car list))) 497 (add-hook 'temp-buffer-show-hook
513 (setq s (point)) 498 (lambda () (list-colors-print list)) nil t)))))
514 (insert " " (car list) "\n") 499
515 (put-text-property s (point) 'face 500(defun list-colors-print (list)
516 (cons 'foreground-color (car list))) 501 (dolist (color list)
517 (setq list (cdr list))))))) 502 (if (consp color)
503 (if (cdr color)
504 (setq color (sort color (lambda (a b)
505 (string< (downcase a)
506 (downcase b))))))
507 (setq color (list color)))
508 (put-text-property
509 (prog1 (point)
510 (insert (car color))
511 (indent-to 22))
512 (point)
513 'face (cons 'background-color (car color)))
514 (put-text-property
515 (prog1 (point)
516 (insert " " (if (cdr color)
517 (mapconcat 'identity (cdr color) ", ")
518 (car color)))
519 (indent-to (max (- (window-width) 8) 44))
520 (insert (apply 'format " #%02x%02x%02x"
521 (mapcar (lambda (c) (lsh c -8))
522 (color-values (car color)))))
523
524 (insert "\n"))
525 (point)
526 'face (cons 'foreground-color (car color))))
527 (goto-char (point-min)))
528
529(defun list-colors-duplicates (&optional list)
530 "Return a list of colors with grouped duplicate colors.
531If a color has no duplicates, then the element of the returned list
532has the form '(COLOR-NAME). The element of the returned list with
533duplicate colors has the form '(COLOR-NAME DUPLICATE-COLOR-NAME ...).
534This function uses the predicate `facemenu-color-equal' to compare
535color names. If the optional argument LIST is non-nil, it should
536be a list of colors to display. Otherwise, this function uses
537a list of colors that the current display can handle."
538 (let* ((list (mapcar 'list (or list (defined-colors))))
539 (l list))
540 (while (cdr l)
541 (if (and (facemenu-color-equal (car (car l)) (car (car (cdr l))))
542 (not (and (boundp 'w32-default-color-map)
543 (not (assoc (car (car l)) w32-default-color-map)))))
544 (progn
545 (setcdr (car l) (cons (car (car (cdr l))) (cdr (car l))))
546 (setcdr l (cdr (cdr l))))
547 (setq l (cdr l))))
548 list))
518 549
519(defun facemenu-color-equal (a b) 550(defun facemenu-color-equal (a b)
520 "Return t if colors A and B are the same color. 551 "Return t if colors A and B are the same color.
@@ -525,22 +556,6 @@ determine the correct answer."
525 (cond ((equal a b) t) 556 (cond ((equal a b) t)
526 ((equal (color-values a) (color-values b))))) 557 ((equal (color-values a) (color-values b)))))
527 558
528(defun facemenu-color-name-equal (a b)
529 "Return t if colors A and B are the same color.
530A and B should be strings naming colors. These names are
531downcased, stripped of spaces and the string `grey' is turned
532into `gray'. This accommodates alternative spellings of colors
533found commonly in the list. It returns nil if the colors differ."
534 (progn
535 (setq a (replace-regexp-in-string "grey" "gray"
536 (replace-regexp-in-string " " ""
537 (downcase a)))
538 b (replace-regexp-in-string "grey" "gray"
539 (replace-regexp-in-string " " ""
540 (downcase b))))
541
542 (equal a b)))
543
544(defun facemenu-add-face (face &optional start end) 559(defun facemenu-add-face (face &optional start end)
545 "Add FACE to text between START and END. 560 "Add FACE to text between START and END.
546If START is nil or START to END is empty, add FACE to next typed character 561If START is nil or START to END is empty, add FACE to next typed character
diff --git a/lisp/files.el b/lisp/files.el
index cfee975066d..cdaa7a5adb8 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1856,8 +1856,14 @@ mode function to use. FUNCTION will be called, unless it is nil.
1856 1856
1857If the element has the form (REGEXP FUNCTION NON-NIL), then after 1857If the element has the form (REGEXP FUNCTION NON-NIL), then after
1858calling FUNCTION (if it's not nil), we delete the suffix that matched 1858calling FUNCTION (if it's not nil), we delete the suffix that matched
1859REGEXP and search the list again for another match.") 1859REGEXP and search the list again for another match.
1860 1860
1861If the file name matches `inhibit-first-line-modes-regexps',
1862then `auto-mode-alist' is not processed.
1863
1864See also `interpreter-mode-alist', which detects executable script modes
1865based on the interpreters they specify to run,
1866and `magic-mode-alist', which determines modes based on file contents.")
1861 1867
1862(defvar interpreter-mode-alist 1868(defvar interpreter-mode-alist
1863 ;; Note: The entries for the modes defined in cc-mode.el (awk-mode 1869 ;; Note: The entries for the modes defined in cc-mode.el (awk-mode
@@ -1902,11 +1908,13 @@ REGEXP and search the list again for another match.")
1902 ("guile" . scheme-mode) 1908 ("guile" . scheme-mode)
1903 ("clisp" . lisp-mode))) 1909 ("clisp" . lisp-mode)))
1904 "Alist mapping interpreter names to major modes. 1910 "Alist mapping interpreter names to major modes.
1905This alist applies to files whose first line starts with `#!'. 1911This is used for files whose first lines match `auto-mode-interpreter-regexp'.
1906Each element looks like (INTERPRETER . MODE). 1912Each element looks like (INTERPRETER . MODE).
1907The car of each element is compared with 1913The car of each element is compared with
1908the name of the interpreter specified in the first line. 1914the name of the interpreter specified in the first line.
1909If it matches, mode MODE is selected.") 1915If it matches, mode MODE is selected.
1916
1917See also `auto-mode-alist'.")
1910 1918
1911(defvar inhibit-first-line-modes-regexps '("\\.tar\\'" "\\.tgz\\'") 1919(defvar inhibit-first-line-modes-regexps '("\\.tar\\'" "\\.tgz\\'")
1912 "List of regexps; if one matches a file name, don't look for `-*-'.") 1920 "List of regexps; if one matches a file name, don't look for `-*-'.")
@@ -1935,12 +1943,14 @@ with that interpreter in `interpreter-mode-alist'.")
1935 (concat "\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<" 1943 (concat "\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<"
1936 comment-re "*" 1944 comment-re "*"
1937 "\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\s *" comment-re "*\\)?" 1945 "\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\s *" comment-re "*\\)?"
1938 "[Hh][Tt][Mm][Ll]")) . html-mode) 1946 "[Hh][Tt][Mm][Ll]"))
1947 . html-mode)
1939 ;; These two must come after html, because they are more general: 1948 ;; These two must come after html, because they are more general:
1940 ("<\\?xml " . xml-mode) 1949 ("<\\?xml " . xml-mode)
1941 (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)") 1950 (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
1942 (comment-re (concat "\\(?:!--" incomment-re "*-->\\s *<\\)"))) 1951 (comment-re (concat "\\(?:!--" incomment-re "*-->\\s *<\\)")))
1943 (concat "\\s *<" comment-re "*!DOCTYPE ")) . sgml-mode) 1952 (concat "\\s *<" comment-re "*!DOCTYPE "))
1953 . sgml-mode)
1944 ("%![^V]" . ps-mode) 1954 ("%![^V]" . ps-mode)
1945 ("# xmcd " . conf-unix-mode)) 1955 ("# xmcd " . conf-unix-mode))
1946 "Alist of buffer beginnings vs. corresponding major mode functions. 1956 "Alist of buffer beginnings vs. corresponding major mode functions.
@@ -2202,86 +2212,86 @@ is specified, returning t if it is specified."
2202 (save-excursion 2212 (save-excursion
2203 (goto-char (point-max)) 2213 (goto-char (point-max))
2204 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) 2214 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move)
2205 (if (let ((case-fold-search t)) 2215 (when (let ((case-fold-search t))
2206 (and (search-forward "Local Variables:" nil t) 2216 (and (search-forward "Local Variables:" nil t)
2207 (or (eq enable-local-variables t) 2217 (or (eq enable-local-variables t)
2208 mode-only 2218 mode-only
2209 (and enable-local-variables 2219 (and enable-local-variables
2210 (save-window-excursion 2220 (save-window-excursion
2211 (switch-to-buffer (current-buffer)) 2221 (switch-to-buffer (current-buffer))
2212 (save-excursion 2222 (save-excursion
2213 (beginning-of-line) 2223 (beginning-of-line)
2214 (set-window-start (selected-window) (point))) 2224 (set-window-start (selected-window) (point)))
2215 (y-or-n-p (format "Set local variables as specified at end of %s? " 2225 (y-or-n-p (format "Set local variables as specified at end of %s? "
2216 (if buffer-file-name 2226 (if buffer-file-name
2217 (file-name-nondirectory 2227 (file-name-nondirectory
2218 buffer-file-name) 2228 buffer-file-name)
2219 (concat "buffer " 2229 (concat "buffer "
2220 (buffer-name)))))))))) 2230 (buffer-name))))))))))
2221 (skip-chars-forward " \t") 2231 (skip-chars-forward " \t")
2222 (let ((enable-local-eval enable-local-eval) 2232 (let ((enable-local-eval enable-local-eval)
2223 ;; suffix is what comes after "local variables:" in its line. 2233 ;; suffix is what comes after "local variables:" in its line.
2224 (suffix 2234 (suffix
2225 (concat 2235 (concat
2226 (regexp-quote (buffer-substring (point) (line-end-position))) 2236 (regexp-quote (buffer-substring (point) (line-end-position)))
2227 "$")) 2237 "$"))
2228 ;; prefix is what comes before "local variables:" in its line. 2238 ;; prefix is what comes before "local variables:" in its line.
2229 (prefix 2239 (prefix
2230 (concat "^" (regexp-quote 2240 (concat "^" (regexp-quote
2231 (buffer-substring (line-beginning-position) 2241 (buffer-substring (line-beginning-position)
2232 (match-beginning 0))))) 2242 (match-beginning 0)))))
2233 beg) 2243 beg)
2234 2244
2235 (forward-line 1) 2245 (forward-line 1)
2236 (let ((startpos (point)) 2246 (let ((startpos (point))
2237 endpos 2247 endpos
2238 (thisbuf (current-buffer))) 2248 (thisbuf (current-buffer)))
2239 (save-excursion 2249 (save-excursion
2240 (if (not (re-search-forward 2250 (if (not (re-search-forward
2241 (concat prefix "[ \t]*End:[ \t]*" suffix) 2251 (concat prefix "[ \t]*End:[ \t]*" suffix)
2242 nil t)) 2252 nil t))
2243 (error "Local variables list is not properly terminated")) 2253 (error "Local variables list is not properly terminated"))
2244 (beginning-of-line) 2254 (beginning-of-line)
2245 (setq endpos (point))) 2255 (setq endpos (point)))
2246 2256
2247 (with-temp-buffer 2257 (with-temp-buffer
2248 (insert-buffer-substring thisbuf startpos endpos) 2258 (insert-buffer-substring thisbuf startpos endpos)
2249 (goto-char (point-min)) 2259 (goto-char (point-min))
2250 (subst-char-in-region (point) (point-max) ?\^m ?\n) 2260 (subst-char-in-region (point) (point-max) ?\^m ?\n)
2251 (while (not (eobp)) 2261 (while (not (eobp))
2252 ;; Discard the prefix. 2262 ;; Discard the prefix.
2253 (if (looking-at prefix) 2263 (if (looking-at prefix)
2254 (delete-region (point) (match-end 0)) 2264 (delete-region (point) (match-end 0))
2255 (error "Local variables entry is missing the prefix")) 2265 (error "Local variables entry is missing the prefix"))
2256 (end-of-line) 2266 (end-of-line)
2257 ;; Discard the suffix. 2267 ;; Discard the suffix.
2258 (if (looking-back suffix) 2268 (if (looking-back suffix)
2259 (delete-region (match-beginning 0) (point)) 2269 (delete-region (match-beginning 0) (point))
2260 (error "Local variables entry is missing the suffix")) 2270 (error "Local variables entry is missing the suffix"))
2261 (forward-line 1)) 2271 (forward-line 1))
2262 (goto-char (point-min)) 2272 (goto-char (point-min))
2263 2273
2264 (while (not (eobp)) 2274 (while (not (eobp))
2265 ;; Find the variable name; strip whitespace. 2275 ;; Find the variable name; strip whitespace.
2266 (skip-chars-forward " \t") 2276 (skip-chars-forward " \t")
2267 (setq beg (point)) 2277 (setq beg (point))
2268 (skip-chars-forward "^:\n") 2278 (skip-chars-forward "^:\n")
2269 (if (eolp) (error "Missing colon in local variables entry")) 2279 (if (eolp) (error "Missing colon in local variables entry"))
2270 (skip-chars-backward " \t") 2280 (skip-chars-backward " \t")
2271 (let* ((str (buffer-substring beg (point))) 2281 (let* ((str (buffer-substring beg (point)))
2272 (var (read str)) 2282 (var (read str))
2273 val) 2283 val)
2274 ;; Read the variable value. 2284 ;; Read the variable value.
2275 (skip-chars-forward "^:") 2285 (skip-chars-forward "^:")
2276 (forward-char 1) 2286 (forward-char 1)
2277 (setq val (read (current-buffer))) 2287 (setq val (read (current-buffer)))
2278 (if mode-only 2288 (if mode-only
2279 (if (eq var 'mode) 2289 (if (eq var 'mode)
2280 (setq mode-specified t)) 2290 (setq mode-specified t))
2281 ;; Set the variable. "Variables" mode and eval are funny. 2291 ;; Set the variable. "Variables" mode and eval are funny.
2282 (with-current-buffer thisbuf 2292 (with-current-buffer thisbuf
2283 (hack-one-local-variable var val)))) 2293 (hack-one-local-variable var val))))
2284 (forward-line 1))))))) 2294 (forward-line 1)))))))
2285 (unless mode-only 2295 (unless mode-only
2286 (run-hooks 'hack-local-variables-hook)) 2296 (run-hooks 'hack-local-variables-hook))
2287 mode-specified)) 2297 mode-specified))
@@ -3264,11 +3274,12 @@ Before and after saving the buffer, this function runs
3264;; but inhibited if one of write-file-functions returns non-nil. 3274;; but inhibited if one of write-file-functions returns non-nil.
3265;; It returns a value (MODES . BACKUPNAME), like backup-buffer. 3275;; It returns a value (MODES . BACKUPNAME), like backup-buffer.
3266(defun basic-save-buffer-1 () 3276(defun basic-save-buffer-1 ()
3267 (if save-buffer-coding-system 3277 (prog1
3268 (let ((coding-system-for-write save-buffer-coding-system)) 3278 (if save-buffer-coding-system
3279 (let ((coding-system-for-write save-buffer-coding-system))
3280 (basic-save-buffer-2))
3269 (basic-save-buffer-2)) 3281 (basic-save-buffer-2))
3270 (basic-save-buffer-2)) 3282 (setq buffer-file-coding-system-explicit last-coding-system-used)))
3271 (setq buffer-file-coding-system-explicit last-coding-system-used))
3272 3283
3273;; This returns a value (MODES . BACKUPNAME), like backup-buffer. 3284;; This returns a value (MODES . BACKUPNAME), like backup-buffer.
3274(defun basic-save-buffer-2 () 3285(defun basic-save-buffer-2 ()
@@ -4549,7 +4560,7 @@ normally equivalent short `-D' option is just passed on to
4549 error-lines) 4560 error-lines)
4550 ;; Find all the lines that are error messages, 4561 ;; Find all the lines that are error messages,
4551 ;; and record the bounds of each one. 4562 ;; and record the bounds of each one.
4552 (goto-char (point-min)) 4563 (goto-char beg)
4553 (while (< (point) linebeg) 4564 (while (< (point) linebeg)
4554 (or (eql (following-char) ?\s) 4565 (or (eql (following-char) ?\s)
4555 (push (list (point) (line-end-position)) error-lines)) 4566 (push (list (point) (line-end-position)) error-lines))
@@ -4575,11 +4586,9 @@ normally equivalent short `-D' option is just passed on to
4575 (end-of-line)))) 4586 (end-of-line))))
4576 (goto-char end) 4587 (goto-char end)
4577 (beginning-of-line) 4588 (beginning-of-line)
4578 (delete-region (point) (progn (forward-line 2) (point)))) 4589 (delete-region (point) (progn (forward-line 1) (point))))
4579 (forward-line 1)
4580 (if (looking-at "//DIRED-OPTIONS//") 4590 (if (looking-at "//DIRED-OPTIONS//")
4581 (delete-region (point) (progn (forward-line 1) (point))) 4591 (delete-region (point) (progn (forward-line 1) (point))))))
4582 (forward-line 1))))
4583 4592
4584 ;; Now decode what read if necessary. 4593 ;; Now decode what read if necessary.
4585 (let ((coding (or coding-system-for-read 4594 (let ((coding (or coding-system-for-read
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 46a1449ce79..4eee8bcbbfc 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,8 @@
12005-01-05 Reiner Steib <Reiner.Steib@gmx.de>
2
3 * spam.el (spam-face): New face. Don't use `gnus-splash-face'
4 which is unreadable in some setups.
5
12004-12-27 Simon Josefsson <jas@extundo.com> 62004-12-27 Simon Josefsson <jas@extundo.com>
2 7
3 * mm-bodies.el (mm-body-encoding): Don't permit 7-bit to be used 8 * mm-bodies.el (mm-body-encoding): Don't permit 7-bit to be used
diff --git a/lisp/gnus/spam.el b/lisp/gnus/spam.el
index a0b28340717..9a55ba9f318 100644
--- a/lisp/gnus/spam.el
+++ b/lisp/gnus/spam.el
@@ -298,7 +298,19 @@ All unmarked article in such group receive the spam mark on group entry."
298 :type '(radio (const nil) regexp) 298 :type '(radio (const nil) regexp)
299 :group 'spam) 299 :group 'spam)
300 300
301(defcustom spam-face 'gnus-splash-face 301(defface spam-face
302 '((((class color) (type tty) (background dark))
303 (:foreground "gray80" :background "gray50"))
304 (((class color) (type tty) (background light))
305 (:foreground "gray50" :background "gray80"))
306 (((class color) (background dark))
307 (:foreground "ivory2"))
308 (((class color) (background light))
309 (:foreground "ivory4"))
310 (t :inverse-video t))
311 "Face for spam-marked articles.")
312
313(defcustom spam-face 'spam-face
302 "Face for spam-marked articles." 314 "Face for spam-marked articles."
303 :type 'face 315 :type 'face
304 :group 'spam) 316 :group 'spam)
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 522c1e2c19d..9acadaa2fa6 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -216,6 +216,14 @@ ARGLIST can also be t or a string of the form \"(FUN ARG1 ARG2 ...)\"."
216 (intern (upcase name)))))) 216 (intern (upcase name))))))
217 arglist))) 217 arglist)))
218 218
219;;; Could be this, if we make symbol-file do the work below.
220;;; (defun help-C-file-name (subr-or-var kind)
221;;; "Return the name of the C file where SUBR-OR-VAR is defined.
222;;; KIND should be `var' for a variable or `subr' for a subroutine."
223;;; (symbol-file (if (symbolp subr-or-var) subr-or-var
224;;; (subr-name subr-or-var))
225;;; (if (eq kind 'var) 'defvar 'defun)))
226
219(defun help-C-file-name (subr-or-var kind) 227(defun help-C-file-name (subr-or-var kind)
220 "Return the name of the C file where SUBR-OR-VAR is defined. 228 "Return the name of the C file where SUBR-OR-VAR is defined.
221KIND should be `var' for a variable or `subr' for a subroutine." 229KIND should be `var' for a variable or `subr' for a subroutine."
@@ -231,8 +239,8 @@ KIND should be `var' for a variable or `subr' for a subroutine."
231 (let ((file (catch 'loop 239 (let ((file (catch 'loop
232 (while t 240 (while t
233 (let ((pnt (search-forward (concat "" name "\n")))) 241 (let ((pnt (search-forward (concat "" name "\n"))))
234 (re-search-backward "S\\(.*\\)") 242 (re-search-backward "S\\(.*\\)")
235 (let ((file (match-string 1))) 243 (let ((file (match-string 1)))
236 (if (member file build-files) 244 (if (member file build-files)
237 (throw 'loop file) 245 (throw 'loop file)
238 (goto-char pnt)))))))) 246 (goto-char pnt))))))))
@@ -463,9 +471,10 @@ face (according to `face-differs-from-default-p')."
463;; Variables 471;; Variables
464 472
465;;;###autoload 473;;;###autoload
466(defun variable-at-point () 474(defun variable-at-point (&optional any-symbol)
467 "Return the bound variable symbol found around point. 475 "Return the bound variable symbol found around point.
468Return 0 if there is no such symbol." 476Return 0 if there is no such symbol.
477If ANY-SYMBOL is non-nil, don't insist the symbol be bound."
469 (or (condition-case () 478 (or (condition-case ()
470 (with-syntax-table emacs-lisp-mode-syntax-table 479 (with-syntax-table emacs-lisp-mode-syntax-table
471 (save-excursion 480 (save-excursion
@@ -479,12 +488,12 @@ Return 0 if there is no such symbol."
479 (error nil)) 488 (error nil))
480 (let* ((str (find-tag-default)) 489 (let* ((str (find-tag-default))
481 (sym (if str (intern-soft str)))) 490 (sym (if str (intern-soft str))))
482 (if (and sym (boundp sym)) 491 (if (and sym (or any-symbol (boundp sym)))
483 sym 492 sym
484 (save-match-data 493 (save-match-data
485 (when (and str (string-match "\\`\\W*\\(.*?\\)\\W*\\'" str)) 494 (when (and str (string-match "\\`\\W*\\(.*?\\)\\W*\\'" str))
486 (setq sym (intern-soft (match-string 1 str))) 495 (setq sym (intern-soft (match-string 1 str)))
487 (and (boundp sym) sym))))) 496 (and (or any-symbol (boundp sym)) sym)))))
488 0)) 497 0))
489 498
490;;;###autoload 499;;;###autoload
diff --git a/lisp/help-macro.el b/lisp/help-macro.el
index a36eed86d01..3a7cf0898cb 100644
--- a/lisp/help-macro.el
+++ b/lisp/help-macro.el
@@ -121,7 +121,7 @@ and then returns."
121 (if three-step-help 121 (if three-step-help
122 (progn 122 (progn
123 (setq key (let ((overriding-local-map local-map)) 123 (setq key (let ((overriding-local-map local-map))
124 (read-key-sequence nil))) 124 (read-key-sequence nil)))
125 ;; Make the HELP key translate to C-h. 125 ;; Make the HELP key translate to C-h.
126 (if (lookup-key function-key-map key) 126 (if (lookup-key function-key-map key)
127 (setq key (lookup-key function-key-map key))) 127 (setq key (lookup-key function-key-map key)))
diff --git a/lisp/imenu.el b/lisp/imenu.el
index af617498b07..6ee72a88bc4 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -532,7 +532,7 @@ A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).")
532 (push item keep-at-top) 532 (push item keep-at-top)
533 (setq menulist (delq item menulist)))) 533 (setq menulist (delq item menulist))))
534 (if imenu-sort-function 534 (if imenu-sort-function
535 (setq menulist (sort menulist imenu-sort-function))) 535 (setq menulist (sort (copy-sequence menulist) imenu-sort-function)))
536 (if (> (length menulist) imenu-max-items) 536 (if (> (length menulist) imenu-max-items)
537 (setq menulist 537 (setq menulist
538 (mapcar 538 (mapcar
@@ -817,32 +817,30 @@ depending on PATTERNS."
817 (setq start (point)) 817 (setq start (point))
818 (goto-char (match-end index)) 818 (goto-char (match-end index))
819 (setq beg (match-beginning index)) 819 (setq beg (match-beginning index))
820 (goto-char beg) 820 ;; Go to the start of the match.
821 ;; That's the official position of this definition.
822 (goto-char start)
821 (imenu-progress-message prev-pos nil t) 823 (imenu-progress-message prev-pos nil t)
822 ;; Add this sort of submenu only when we've found an 824 ;; Add this sort of submenu only when we've found an
823 ;; item for it, avoiding empty, duff menus. 825 ;; item for it, avoiding empty, duff menus.
824 (unless (assoc menu-title index-alist) 826 (unless (assoc menu-title index-alist)
825 (push (list menu-title) index-alist)) 827 (push (list menu-title) index-alist))
826 (if imenu-use-markers 828 (if imenu-use-markers
827 (setq beg (copy-marker beg))) 829 (setq start (copy-marker start)))
828 (let ((item 830 (let ((item
829 (if function 831 (if function
830 (nconc (list (match-string-no-properties index) 832 (nconc (list (match-string-no-properties index)
831 beg function) 833 start function)
832 rest) 834 rest)
833 (cons (match-string-no-properties index) 835 (cons (match-string-no-properties index)
834 beg))) 836 start)))
835 ;; This is the desired submenu, 837 ;; This is the desired submenu,
836 ;; starting with its title (or nil). 838 ;; starting with its title (or nil).
837 (menu (assoc menu-title index-alist))) 839 (menu (assoc menu-title index-alist)))
838 ;; Insert the item unless it is already present. 840 ;; Insert the item unless it is already present.
839 (unless (member item (cdr menu)) 841 (unless (member item (cdr menu))
840 (setcdr menu 842 (setcdr menu
841 (cons item (cdr menu))))) 843 (cons item (cdr menu))))))))
842 ;; Move to the start of the entire match,
843 ;; to ensure we keep moving backwards
844 ;; as long as the match is nonempty.
845 (goto-char start))))
846 (set-syntax-table old-table))) 844 (set-syntax-table old-table)))
847 (imenu-progress-message prev-pos 100 t) 845 (imenu-progress-message prev-pos 100 t)
848 ;; Sort each submenu by position. 846 ;; Sort each submenu by position.
diff --git a/lisp/info-look.el b/lisp/info-look.el
index bc886f0320c..4fc2c6b4c63 100644
--- a/lisp/info-look.el
+++ b/lisp/info-look.el
@@ -1,7 +1,7 @@
1;;; info-look.el --- major-mode-sensitive Info index lookup facility 1;;; info-look.el --- major-mode-sensitive Info index lookup facility
2;; An older version of this was known as libc.el. 2;; An older version of this was known as libc.el.
3 3
4;; Copyright (C) 1995,96,97,98,99,2001,03,04 Free Software Foundation, Inc. 4;; Copyright (C) 1995,96,97,98,99,2001,03,04,05 Free Software Foundation, Inc.
5 5
6;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org> 6;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
7;; (did not show signs of life (Nov 2001) -stef) 7;; (did not show signs of life (Nov 2001) -stef)
@@ -634,8 +634,15 @@ Return nil if there is nothing appropriate in the buffer near point."
634 :regexp "\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*" 634 :regexp "\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*"
635 :doc-spec '(("(libc)Function Index" nil 635 :doc-spec '(("(libc)Function Index" nil
636 "^[ \t]+-+ \\(Function\\|Macro\\): .*\\<" "\\>") 636 "^[ \t]+-+ \\(Function\\|Macro\\): .*\\<" "\\>")
637 ;; prefix/suffix has to match things like
638 ;; " -- Macro: int F_DUPFD"
639 ;; " -- Variable: char * tzname [2]"
640 ;; "`DBL_MAX'" (texinfo @table)
641 ;; suffix "\\>" is not used because that sends DBL_MAX to
642 ;; DBL_MAX_EXP ("_" is a non-word char)
637 ("(libc)Variable Index" nil 643 ("(libc)Variable Index" nil
638 "^[ \t]+-+ \\(Variable\\|Macro\\): .*\\<" "\\>") 644 "^\\([ \t]+-+ \\(Variable\\|Macro\\): .*\\<\\|`\\)"
645 "\\( \\|'?$\\)")
639 ("(libc)Type Index" nil 646 ("(libc)Type Index" nil
640 "^[ \t]+-+ Data Type: \\<" "\\>") 647 "^[ \t]+-+ Data Type: \\<" "\\>")
641 ("(termcap)Var Index" nil 648 ("(termcap)Var Index" nil
diff --git a/lisp/info.el b/lisp/info.el
index 750f302d422..4fcbdeb6330 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -47,6 +47,10 @@
47 "Stack of info nodes user has visited. 47 "Stack of info nodes user has visited.
48Each element of list is a list (FILENAME NODENAME BUFFERPOS).") 48Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
49 49
50(defvar Info-history-forward nil
51 "Stack of info nodes user has visited with `Info-history-back' command.
52Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
53
50(defvar Info-history-list nil 54(defvar Info-history-list nil
51 "List of all info nodes user has visited. 55 "List of all info nodes user has visited.
52Each element of list is a list (FILENAME NODENAME).") 56Each element of list is a list (FILENAME NODENAME).")
@@ -1295,7 +1299,8 @@ any double quotes or backslashes must be escaped (\\\",\\\\)."
1295 ;; Add a new unique history item to full history list 1299 ;; Add a new unique history item to full history list
1296 (let ((new-history (list Info-current-file Info-current-node))) 1300 (let ((new-history (list Info-current-file Info-current-node)))
1297 (setq Info-history-list 1301 (setq Info-history-list
1298 (cons new-history (delete new-history Info-history-list)))) 1302 (cons new-history (delete new-history Info-history-list)))
1303 (setq Info-history-forward nil))
1299 (if (not (eq Info-fontify-maximum-menu-size nil)) 1304 (if (not (eq Info-fontify-maximum-menu-size nil))
1300 (Info-fontify-node)) 1305 (Info-fontify-node))
1301 (Info-display-images-node) 1306 (Info-display-images-node)
@@ -1731,18 +1736,38 @@ If SAME-FILE is non-nil, do not move to a different Info file."
1731 (goto-char p) 1736 (goto-char p)
1732 (Info-restore-point Info-history)))) 1737 (Info-restore-point Info-history))))
1733 1738
1734(defun Info-last () 1739(defun Info-history-back ()
1735 "Go back to the last node visited." 1740 "Go back in the history to the last node visited."
1736 (interactive) 1741 (interactive)
1737 (or Info-history 1742 (or Info-history
1738 (error "This is the first Info node you looked at")) 1743 (error "This is the first Info node you looked at"))
1739 (let (filename nodename opoint) 1744 (let ((history-forward
1745 (cons (list Info-current-file Info-current-node (point))
1746 Info-history-forward))
1747 filename nodename opoint)
1740 (setq filename (car (car Info-history))) 1748 (setq filename (car (car Info-history)))
1741 (setq nodename (car (cdr (car Info-history)))) 1749 (setq nodename (car (cdr (car Info-history))))
1742 (setq opoint (car (cdr (cdr (car Info-history))))) 1750 (setq opoint (car (cdr (cdr (car Info-history)))))
1743 (setq Info-history (cdr Info-history)) 1751 (setq Info-history (cdr Info-history))
1744 (Info-find-node filename nodename) 1752 (Info-find-node filename nodename)
1745 (setq Info-history (cdr Info-history)) 1753 (setq Info-history (cdr Info-history))
1754 (setq Info-history-forward history-forward)
1755 (goto-char opoint)))
1756
1757(defalias 'Info-last 'Info-history-back)
1758
1759(defun Info-history-forward ()
1760 "Go forward in the history of visited nodes."
1761 (interactive)
1762 (or Info-history-forward
1763 (error "This is the last Info node you looked at"))
1764 (let ((history-forward (cdr Info-history-forward))
1765 filename nodename opoint)
1766 (setq filename (car (car Info-history-forward)))
1767 (setq nodename (car (cdr (car Info-history-forward))))
1768 (setq opoint (car (cdr (cdr (car Info-history-forward)))))
1769 (Info-find-node filename nodename)
1770 (setq Info-history-forward history-forward)
1746 (goto-char opoint))) 1771 (goto-char opoint)))
1747 1772
1748;;;###autoload 1773;;;###autoload
@@ -2894,12 +2919,13 @@ if point is in a menu item description, follow that menu item."
2894 (define-key Info-mode-map "g" 'Info-goto-node) 2919 (define-key Info-mode-map "g" 'Info-goto-node)
2895 (define-key Info-mode-map "h" 'Info-help) 2920 (define-key Info-mode-map "h" 'Info-help)
2896 (define-key Info-mode-map "i" 'Info-index) 2921 (define-key Info-mode-map "i" 'Info-index)
2897 (define-key Info-mode-map "l" 'Info-last) 2922 (define-key Info-mode-map "l" 'Info-history-back)
2898 (define-key Info-mode-map "L" 'Info-history) 2923 (define-key Info-mode-map "L" 'Info-history)
2899 (define-key Info-mode-map "m" 'Info-menu) 2924 (define-key Info-mode-map "m" 'Info-menu)
2900 (define-key Info-mode-map "n" 'Info-next) 2925 (define-key Info-mode-map "n" 'Info-next)
2901 (define-key Info-mode-map "p" 'Info-prev) 2926 (define-key Info-mode-map "p" 'Info-prev)
2902 (define-key Info-mode-map "q" 'Info-exit) 2927 (define-key Info-mode-map "q" 'Info-exit)
2928 (define-key Info-mode-map "r" 'Info-history-forward)
2903 (define-key Info-mode-map "s" 'Info-search) 2929 (define-key Info-mode-map "s" 'Info-search)
2904 (define-key Info-mode-map "S" 'Info-search-case-sensitively) 2930 (define-key Info-mode-map "S" 'Info-search-case-sensitively)
2905 ;; For consistency with Rmail. 2931 ;; For consistency with Rmail.
@@ -2913,6 +2939,7 @@ if point is in a menu item description, follow that menu item."
2913 (define-key Info-mode-map "," 'Info-index-next) 2939 (define-key Info-mode-map "," 'Info-index-next)
2914 (define-key Info-mode-map "\177" 'Info-scroll-down) 2940 (define-key Info-mode-map "\177" 'Info-scroll-down)
2915 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node) 2941 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
2942 (define-key Info-mode-map [follow-link] 'mouse-face)
2916 ) 2943 )
2917 2944
2918(defun Info-check-pointer (item) 2945(defun Info-check-pointer (item)
@@ -2951,8 +2978,10 @@ if point is in a menu item description, follow that menu item."
2951 :help "Search for another occurrence of regular expression"] 2978 :help "Search for another occurrence of regular expression"]
2952 ["Go to Node..." Info-goto-node 2979 ["Go to Node..." Info-goto-node
2953 :help "Go to a named node"] 2980 :help "Go to a named node"]
2954 ["Last" Info-last :active Info-history 2981 ["Back in history" Info-history-back :active Info-history
2955 :help "Go to the last node you were at"] 2982 :help "Go back in history to the last node you were at"]
2983 ["Forward in history" Info-history-forward :active Info-history-forward
2984 :help "Go forward in history"]
2956 ["History" Info-history :active Info-history-list 2985 ["History" Info-history :active Info-history-list
2957 :help "Go to menu of visited nodes"] 2986 :help "Go to menu of visited nodes"]
2958 ["Table of Contents" Info-toc 2987 ["Table of Contents" Info-toc
@@ -2980,7 +3009,8 @@ if point is in a menu item description, follow that menu item."
2980 (tool-bar-local-item-from-menu 'Info-prev "left_arrow" map Info-mode-map) 3009 (tool-bar-local-item-from-menu 'Info-prev "left_arrow" map Info-mode-map)
2981 (tool-bar-local-item-from-menu 'Info-next "right_arrow" map Info-mode-map) 3010 (tool-bar-local-item-from-menu 'Info-next "right_arrow" map Info-mode-map)
2982 (tool-bar-local-item-from-menu 'Info-up "up_arrow" map Info-mode-map) 3011 (tool-bar-local-item-from-menu 'Info-up "up_arrow" map Info-mode-map)
2983 (tool-bar-local-item-from-menu 'Info-last "undo" map Info-mode-map) 3012 (tool-bar-local-item-from-menu 'Info-history-back "back_arrow" map Info-mode-map)
3013 (tool-bar-local-item-from-menu 'Info-history-forward "fwd_arrow" map Info-mode-map)
2984 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map) 3014 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
2985 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map) 3015 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
2986 (tool-bar-local-item-from-menu 'Info-goto-node "jump_to" map Info-mode-map) 3016 (tool-bar-local-item-from-menu 'Info-goto-node "jump_to" map Info-mode-map)
@@ -3100,7 +3130,8 @@ Selecting other nodes:
3100 Picking a menu item causes another node to be selected. 3130 Picking a menu item causes another node to be selected.
3101\\[Info-directory] Go to the Info directory node. 3131\\[Info-directory] Go to the Info directory node.
3102\\[Info-follow-reference] Follow a cross reference. Reads name of reference. 3132\\[Info-follow-reference] Follow a cross reference. Reads name of reference.
3103\\[Info-last] Move to the last node you were at. 3133\\[Info-history-back] Move back in history to the last node you were at.
3134\\[Info-history-forward] Move forward in history to the node you returned from after using \\[Info-history-back].
3104\\[Info-history] Go to menu of visited nodes. 3135\\[Info-history] Go to menu of visited nodes.
3105\\[Info-toc] Go to table of contents of the current Info file. 3136\\[Info-toc] Go to table of contents of the current Info file.
3106\\[Info-top-node] Go to the Top node of this file. 3137\\[Info-top-node] Go to the Top node of this file.
@@ -3157,6 +3188,7 @@ Advanced commands:
3157 (make-local-variable 'Info-tag-table-buffer) 3188 (make-local-variable 'Info-tag-table-buffer)
3158 (setq Info-tag-table-buffer nil) 3189 (setq Info-tag-table-buffer nil)
3159 (make-local-variable 'Info-history) 3190 (make-local-variable 'Info-history)
3191 (make-local-variable 'Info-history-forward)
3160 (make-local-variable 'Info-index-alternatives) 3192 (make-local-variable 'Info-index-alternatives)
3161 (setq header-line-format 3193 (setq header-line-format
3162 (if Info-use-header-line 3194 (if Info-use-header-line
@@ -3368,7 +3400,7 @@ COMMAND must be a symbol or string."
3368 (message "Found %d other entr%s. Use %s to see %s." 3400 (message "Found %d other entr%s. Use %s to see %s."
3369 (1- num-matches) 3401 (1- num-matches)
3370 (if (> num-matches 2) "ies" "y") 3402 (if (> num-matches 2) "ies" "y")
3371 (substitute-command-keys "\\[Info-last]") 3403 (substitute-command-keys "\\[Info-history-back]")
3372 (if (> num-matches 2) "them" "it"))))) 3404 (if (> num-matches 2) "them" "it")))))
3373 (error "Couldn't find documentation for %s" command)))) 3405 (error "Couldn't find documentation for %s" command))))
3374 3406
@@ -3453,6 +3485,7 @@ Preserve text properties."
3453 (define-key keymap [header-line mouse-2] 'Info-next) 3485 (define-key keymap [header-line mouse-2] 'Info-next)
3454 (define-key keymap [header-line down-mouse-1] 'ignore) 3486 (define-key keymap [header-line down-mouse-1] 'ignore)
3455 (define-key keymap [mouse-2] 'Info-next) 3487 (define-key keymap [mouse-2] 'Info-next)
3488 (define-key keymap [follow-link] 'mouse-face)
3456 keymap) 3489 keymap)
3457 "Keymap to put on the Next link in the text or the header line.") 3490 "Keymap to put on the Next link in the text or the header line.")
3458 3491
@@ -3462,6 +3495,7 @@ Preserve text properties."
3462 (define-key keymap [header-line mouse-2] 'Info-prev) 3495 (define-key keymap [header-line mouse-2] 'Info-prev)
3463 (define-key keymap [header-line down-mouse-1] 'ignore) 3496 (define-key keymap [header-line down-mouse-1] 'ignore)
3464 (define-key keymap [mouse-2] 'Info-prev) 3497 (define-key keymap [mouse-2] 'Info-prev)
3498 (define-key keymap [follow-link] 'mouse-face)
3465 keymap) 3499 keymap)
3466 "Keymap to put on the Prev link in the text or the header line.") 3500 "Keymap to put on the Prev link in the text or the header line.")
3467 3501
@@ -3472,6 +3506,7 @@ Preserve text properties."
3472 (define-key keymap [header-line mouse-2] 'Info-up) 3506 (define-key keymap [header-line mouse-2] 'Info-up)
3473 (define-key keymap [header-line down-mouse-1] 'ignore) 3507 (define-key keymap [header-line down-mouse-1] 'ignore)
3474 (define-key keymap [mouse-2] 'Info-up) 3508 (define-key keymap [mouse-2] 'Info-up)
3509 (define-key keymap [follow-link] 'mouse-face)
3475 keymap) 3510 keymap)
3476 "Keymap to put on the Up link in the text or the header line.") 3511 "Keymap to put on the Up link in the text or the header line.")
3477 3512
@@ -3506,7 +3541,7 @@ Preserve text properties."
3506 (put-text-property tbeg nend 'mouse-face 'highlight) 3541 (put-text-property tbeg nend 'mouse-face 'highlight)
3507 (put-text-property tbeg nend 3542 (put-text-property tbeg nend
3508 'help-echo 3543 'help-echo
3509 (concat "Go to node " 3544 (concat "mouse-2: Go to node "
3510 (buffer-substring nbeg nend))) 3545 (buffer-substring nbeg nend)))
3511 ;; Always set up the text property keymap. 3546 ;; Always set up the text property keymap.
3512 ;; It will either be used in the buffer 3547 ;; It will either be used in the buffer
diff --git a/lisp/isearch.el b/lisp/isearch.el
index fb31c3a2587..7702707c6ac 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1,7 +1,7 @@
1;;; isearch.el --- incremental search minor mode 1;;; isearch.el --- incremental search minor mode
2 2
3;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1999, 3;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1999,
4;; 2000, 2001, 2003, 2004 Free Software Foundation, Inc. 4;; 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
5 5
6;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> 6;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
7;; Maintainer: FSF 7;; Maintainer: FSF
@@ -120,11 +120,6 @@ a tab, a carriage return (control-M), a newline, and `]+'."
120 :type 'regexp 120 :type 'regexp
121 :group 'isearch) 121 :group 'isearch)
122 122
123(defcustom search-highlight t
124 "*Non-nil means incremental search highlights the current match."
125 :type 'boolean
126 :group 'isearch)
127
128(defcustom search-invisible 'open 123(defcustom search-invisible 'open
129 "If t incremental search can match hidden text. 124 "If t incremental search can match hidden text.
130nil means don't match invisible text. 125nil means don't match invisible text.
@@ -199,6 +194,98 @@ Default value, nil, means edit the string instead."
199 :type 'boolean 194 :type 'boolean
200 :group 'isearch) 195 :group 'isearch)
201 196
197;;; isearch highlight customization.
198
199(defcustom search-highlight t
200 "*Non-nil means incremental search highlights the current match."
201 :type 'boolean
202 :group 'isearch)
203
204(defface isearch
205 '((((class color) (min-colors 88) (background light))
206 ;; The background must not be too dark, for that means
207 ;; the character is hard to see when the cursor is there.
208 (:background "magenta2" :foreground "lightskyblue1"))
209 (((class color) (min-colors 88) (background dark))
210 (:background "palevioletred2" :foreground "brown4"))
211 (((class color) (min-colors 16))
212 (:background "magenta4" :foreground "cyan1"))
213 (((class color) (min-colors 8))
214 (:background "magenta4" :foreground "cyan1"))
215 (t (:inverse-video t)))
216 "Face for highlighting Isearch matches."
217 :group 'isearch)
218(defvar isearch 'isearch)
219
220(defcustom isearch-lazy-highlight t
221 "*Controls the lazy-highlighting during incremental search.
222When non-nil, all text in the buffer matching the current search
223string is highlighted lazily (see `lazy-highlight-initial-delay'
224and `lazy-highlight-interval')."
225 :type 'boolean
226 :group 'lazy-highlight
227 :group 'isearch)
228
229;;; Lazy highlight customization.
230
231(defgroup lazy-highlight nil
232 "Lazy highlighting feature for matching strings."
233 :prefix "lazy-highlight-"
234 :version "21.1"
235 :group 'isearch
236 :group 'matching)
237
238(defcustom lazy-highlight-cleanup t
239 "*Controls whether to remove extra highlighting after a search.
240If this is nil, extra highlighting can be \"manually\" removed with
241\\[isearch-lazy-highlight-cleanup]."
242 :type 'boolean
243 :group 'lazy-highlight)
244(defvaralias 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup)
245(make-obsolete-variable 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup)
246
247(defcustom lazy-highlight-initial-delay 0.25
248 "*Seconds to wait before beginning to lazily highlight all matches."
249 :type 'number
250 :group 'lazy-highlight)
251(defvaralias 'isearch-lazy-highlight-initial-delay 'lazy-highlight-initial-delay)
252(make-obsolete-variable 'isearch-lazy-highlight-initial-delay 'lazy-highlight-initial-delay)
253
254(defcustom lazy-highlight-interval 0 ; 0.0625
255 "*Seconds between lazily highlighting successive matches."
256 :type 'number
257 :group 'lazy-highlight)
258(defvaralias 'isearch-lazy-highlight-interval 'lazy-highlight-interval)
259(make-obsolete-variable 'isearch-lazy-highlight-interval 'lazy-highlight-interval)
260
261(defcustom lazy-highlight-max-at-a-time 20
262 "*Maximum matches to highlight at a time (for `lazy-highlight').
263Larger values may reduce isearch's responsiveness to user input;
264smaller values make matches highlight slowly.
265A value of nil means highlight all matches."
266 :type '(choice (const :tag "All" nil)
267 (integer :tag "Some"))
268 :group 'lazy-highlight)
269(defvaralias 'isearch-lazy-highlight-max-at-a-time 'lazy-highlight-max-at-a-time)
270(make-obsolete-variable 'isearch-lazy-highlight-max-at-a-time 'lazy-highlight-max-at-a-time)
271
272(defface lazy-highlight
273 '((((class color) (min-colors 88) (background light))
274 (:background "paleturquoise"))
275 (((class color) (min-colors 88) (background dark))
276 (:background "paleturquoise4"))
277 (((class color) (min-colors 16))
278 (:background "turquoise3"))
279 (((class color) (min-colors 8))
280 (:background "turquoise3"))
281 (t (:underline t)))
282 "Face for lazy highlighting of matches other than the current one."
283 :group 'lazy-highlight)
284(put 'isearch-lazy-highlight-face 'face-alias 'lazy-highlight)
285(defvar lazy-highlight-face 'lazy-highlight)
286(defvaralias 'isearch-lazy-highlight-face 'lazy-highlight-face)
287(make-obsolete-variable 'isearch-lazy-highlight-face 'lazy-highlight-face)
288
202;; Define isearch-mode keymap. 289;; Define isearch-mode keymap.
203 290
204(defvar isearch-mode-map 291(defvar isearch-mode-map
@@ -644,7 +731,7 @@ is treated as a regexp. See \\[isearch-forward] for more info."
644 (if (< isearch-other-end (point)) ; isearch-forward? 731 (if (< isearch-other-end (point)) ; isearch-forward?
645 (isearch-highlight isearch-other-end (point)) 732 (isearch-highlight isearch-other-end (point))
646 (isearch-highlight (point) isearch-other-end)) 733 (isearch-highlight (point) isearch-other-end))
647 (isearch-dehighlight nil)) 734 (isearch-dehighlight))
648 )) 735 ))
649 (setq ;; quit-flag nil not for isearch-mode 736 (setq ;; quit-flag nil not for isearch-mode
650 isearch-adjusted nil 737 isearch-adjusted nil
@@ -672,8 +759,8 @@ is treated as a regexp. See \\[isearch-forward] for more info."
672 (setq overriding-terminal-local-map nil) 759 (setq overriding-terminal-local-map nil)
673 ;; (setq pre-command-hook isearch-old-pre-command-hook) ; for lemacs 760 ;; (setq pre-command-hook isearch-old-pre-command-hook) ; for lemacs
674 (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout) 761 (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout)
675 (isearch-dehighlight t) 762 (isearch-dehighlight)
676 (isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup) 763 (isearch-lazy-highlight-cleanup lazy-highlight-cleanup)
677 (let ((found-start (window-start (selected-window))) 764 (let ((found-start (window-start (selected-window)))
678 (found-point (point))) 765 (found-point (point)))
679 (if isearch-window-configuration 766 (if isearch-window-configuration
@@ -2142,31 +2229,8 @@ Can be changed via `isearch-search-fun-function' for special needs."
2142 (setq isearch-hidden t))))))) 2229 (setq isearch-hidden t)))))))
2143 2230
2144 2231
2145;; Highlighting
2146
2147(defvar isearch-overlay nil)
2148
2149(defun isearch-highlight (beg end)
2150 (unless (null search-highlight)
2151 (cond (isearch-overlay
2152 ;; Overlay already exists, just move it.
2153 (move-overlay isearch-overlay beg end (current-buffer)))
2154
2155 (t
2156 ;; Overlay doesn't exist, create it.
2157 (setq isearch-overlay (make-overlay beg end))
2158 (overlay-put isearch-overlay 'face isearch)
2159 (overlay-put isearch-overlay 'priority 1) ;higher than lazy overlays
2160 ))))
2161
2162(defun isearch-dehighlight (totally)
2163 (when isearch-overlay
2164 (delete-overlay isearch-overlay)))
2165
2166
2167;; General utilities 2232;; General utilities
2168 2233
2169
2170(defun isearch-no-upper-case-p (string regexp-flag) 2234(defun isearch-no-upper-case-p (string regexp-flag)
2171 "Return t if there are no upper case chars in STRING. 2235 "Return t if there are no upper case chars in STRING.
2172If REGEXP-FLAG is non-nil, disregard letters preceded by `\\' (but not `\\\\') 2236If REGEXP-FLAG is non-nil, disregard letters preceded by `\\' (but not `\\\\')
@@ -2198,12 +2262,33 @@ since they have special meaning in a regexp."
2198 (append char-or-events unread-command-events))) 2262 (append char-or-events unread-command-events)))
2199 2263
2200 2264
2265;; Highlighting
2266
2267(defvar isearch-overlay nil)
2268
2269(defun isearch-highlight (beg end)
2270 (unless (null search-highlight)
2271 (cond (isearch-overlay
2272 ;; Overlay already exists, just move it.
2273 (move-overlay isearch-overlay beg end (current-buffer)))
2274
2275 (t
2276 ;; Overlay doesn't exist, create it.
2277 (setq isearch-overlay (make-overlay beg end))
2278 (overlay-put isearch-overlay 'face isearch)
2279 (overlay-put isearch-overlay 'priority 1) ;higher than lazy overlays
2280 ))))
2281
2282(defun isearch-dehighlight ()
2283 (when isearch-overlay
2284 (delete-overlay isearch-overlay)))
2285
2201;; isearch-lazy-highlight feature 2286;; isearch-lazy-highlight feature
2202;; by Bob Glickstein <http://www.zanshin.com/~bobg/> 2287;; by Bob Glickstein <http://www.zanshin.com/~bobg/>
2203 2288
2204;; When active, *every* match for the current search string is 2289;; When active, *every* match for the current search string is
2205;; highlighted: the current one using the normal isearch match color 2290;; highlighted: the current one using the normal isearch match color
2206;; and all the others using `isearch-lazy-highlight-face'. The extra 2291;; and all the others using `isearch-lazy-highlight'. The extra
2207;; highlighting makes it easier to anticipate where the cursor will 2292;; highlighting makes it easier to anticipate where the cursor will
2208;; land each time you press C-s or C-r to repeat a pending search. 2293;; land each time you press C-s or C-r to repeat a pending search.
2209;; Highlighting of these additional matches happens in a deferred 2294;; Highlighting of these additional matches happens in a deferred
@@ -2223,81 +2308,6 @@ since they have special meaning in a regexp."
2223;; - the variable `isearch-invalid-regexp' is expected to be true 2308;; - the variable `isearch-invalid-regexp' is expected to be true
2224;; iff `isearch-string' is an invalid regexp. 2309;; iff `isearch-string' is an invalid regexp.
2225 2310
2226(defgroup isearch-lazy-highlight nil
2227 "Lazy highlighting feature for incremental search."
2228 :prefix "isearch-lazy-highlight-"
2229 :version "21.1"
2230 :group 'isearch)
2231
2232(defcustom isearch-lazy-highlight t
2233 "*Controls the lazy-highlighting during incremental searches.
2234When non-nil, all text in the buffer matching the current search
2235string is highlighted lazily (see `isearch-lazy-highlight-initial-delay'
2236and `isearch-lazy-highlight-interval')."
2237 :type 'boolean
2238 :group 'isearch-lazy-highlight)
2239
2240(defcustom isearch-lazy-highlight-cleanup t
2241 "*Controls whether to remove extra highlighting after a search.
2242If this is nil, extra highlighting can be \"manually\" removed with
2243\\[isearch-lazy-highlight-cleanup]."
2244 :type 'boolean
2245 :group 'isearch-lazy-highlight)
2246
2247(defcustom isearch-lazy-highlight-initial-delay 0.25
2248 "*Seconds to wait before beginning to lazily highlight all matches."
2249 :type 'number
2250 :group 'isearch-lazy-highlight)
2251
2252(defcustom isearch-lazy-highlight-interval 0 ; 0.0625
2253 "*Seconds between lazily highlighting successive matches."
2254 :type 'number
2255 :group 'isearch-lazy-highlight)
2256
2257(defcustom isearch-lazy-highlight-max-at-a-time 20
2258 "*Maximum matches to highlight at a time (for `isearch-lazy-highlight').
2259Larger values may reduce isearch's responsiveness to user input;
2260smaller values make matches highlight slowly.
2261A value of nil means highlight all matches."
2262 :type '(choice (const :tag "All" nil)
2263 (integer :tag "Some"))
2264 :group 'isearch-lazy-highlight)
2265
2266(defgroup isearch-faces nil
2267 "Lazy highlighting feature for incremental search."
2268 :version "21.1"
2269 :group 'isearch)
2270
2271(defface isearch
2272 '((((class color) (min-colors 88) (background light))
2273 ;; The background must not be too dark, for that means
2274 ;; the character is hard to see when the cursor is there.
2275 (:background "magenta2" :foreground "lightskyblue1"))
2276 (((class color) (min-colors 88) (background dark))
2277 (:background "palevioletred2" :foreground "brown4"))
2278 (((class color) (min-colors 16))
2279 (:background "magenta4" :foreground "cyan1"))
2280 (((class color) (min-colors 8))
2281 (:background "magenta4" :foreground "cyan1"))
2282 (t (:inverse-video t)))
2283 "Face for highlighting Isearch matches."
2284 :group 'isearch-faces)
2285(defvar isearch 'isearch)
2286
2287(defface isearch-lazy-highlight-face
2288 '((((class color) (min-colors 88) (background light))
2289 (:background "paleturquoise"))
2290 (((class color) (min-colors 88) (background dark))
2291 (:background "paleturquoise4"))
2292 (((class color) (min-colors 16))
2293 (:background "turquoise3"))
2294 (((class color) (min-colors 8))
2295 (:background "turquoise3"))
2296 (t (:underline t)))
2297 "Face for lazy highlighting of Isearch matches other than the current one."
2298 :group 'isearch-faces)
2299(defvar isearch-lazy-highlight-face 'isearch-lazy-highlight-face)
2300
2301(defvar isearch-lazy-highlight-overlays nil) 2311(defvar isearch-lazy-highlight-overlays nil)
2302(defvar isearch-lazy-highlight-wrapped nil) 2312(defvar isearch-lazy-highlight-wrapped nil)
2303(defvar isearch-lazy-highlight-start nil) 2313(defvar isearch-lazy-highlight-start nil)
@@ -2312,11 +2322,11 @@ A value of nil means highlight all matches."
2312 2322
2313(defun isearch-lazy-highlight-cleanup (&optional force) 2323(defun isearch-lazy-highlight-cleanup (&optional force)
2314 "Stop lazy highlighting and remove extra highlighting from current buffer. 2324 "Stop lazy highlighting and remove extra highlighting from current buffer.
2315FORCE non-nil means do it whether or not `isearch-lazy-highlight-cleanup' 2325FORCE non-nil means do it whether or not `lazy-highlight-cleanup'
2316is nil. This function is called when exiting an incremental search if 2326is nil. This function is called when exiting an incremental search if
2317`isearch-lazy-highlight-cleanup' is non-nil." 2327`lazy-highlight-cleanup' is non-nil."
2318 (interactive '(t)) 2328 (interactive '(t))
2319 (if (or force isearch-lazy-highlight-cleanup) 2329 (if (or force lazy-highlight-cleanup)
2320 (while isearch-lazy-highlight-overlays 2330 (while isearch-lazy-highlight-overlays
2321 (delete-overlay (car isearch-lazy-highlight-overlays)) 2331 (delete-overlay (car isearch-lazy-highlight-overlays))
2322 (setq isearch-lazy-highlight-overlays 2332 (setq isearch-lazy-highlight-overlays
@@ -2326,7 +2336,7 @@ is nil. This function is called when exiting an incremental search if
2326 (setq isearch-lazy-highlight-timer nil))) 2336 (setq isearch-lazy-highlight-timer nil)))
2327 2337
2328(defun isearch-lazy-highlight-new-loop () 2338(defun isearch-lazy-highlight-new-loop ()
2329 "Cleanup any previous `isearch-lazy-highlight' loop and begin a new one. 2339 "Cleanup any previous `lazy-highlight' loop and begin a new one.
2330This happens when `isearch-update' is invoked (which can cause the 2340This happens when `isearch-update' is invoked (which can cause the
2331search string to change or the window to scroll)." 2341search string to change or the window to scroll)."
2332 (when (and (null executing-kbd-macro) 2342 (when (and (null executing-kbd-macro)
@@ -2357,7 +2367,7 @@ search string to change or the window to scroll)."
2357 isearch-lazy-highlight-wrapped nil) 2367 isearch-lazy-highlight-wrapped nil)
2358 (unless (equal isearch-string "") 2368 (unless (equal isearch-string "")
2359 (setq isearch-lazy-highlight-timer 2369 (setq isearch-lazy-highlight-timer
2360 (run-with-idle-timer isearch-lazy-highlight-initial-delay nil 2370 (run-with-idle-timer lazy-highlight-initial-delay nil
2361 'isearch-lazy-highlight-update)))))) 2371 'isearch-lazy-highlight-update))))))
2362 2372
2363(defun isearch-lazy-highlight-search () 2373(defun isearch-lazy-highlight-search ()
@@ -2378,7 +2388,7 @@ Attempt to do the search exactly the way the pending isearch would."
2378 2388
2379(defun isearch-lazy-highlight-update () 2389(defun isearch-lazy-highlight-update ()
2380 "Update highlighting of other matches for current search." 2390 "Update highlighting of other matches for current search."
2381 (let ((max isearch-lazy-highlight-max-at-a-time) 2391 (let ((max lazy-highlight-max-at-a-time)
2382 (looping t) 2392 (looping t)
2383 nomore) 2393 nomore)
2384 (with-local-quit 2394 (with-local-quit
@@ -2437,7 +2447,7 @@ Attempt to do the search exactly the way the pending isearch would."
2437 (goto-char (window-end))))))) 2447 (goto-char (window-end)))))))
2438 (unless nomore 2448 (unless nomore
2439 (setq isearch-lazy-highlight-timer 2449 (setq isearch-lazy-highlight-timer
2440 (run-at-time isearch-lazy-highlight-interval nil 2450 (run-at-time lazy-highlight-interval nil
2441 'isearch-lazy-highlight-update))))))))) 2451 'isearch-lazy-highlight-update)))))))))
2442 2452
2443(defun isearch-resume (search regexp word forward message case-fold) 2453(defun isearch-resume (search regexp word forward message case-fold)
diff --git a/lisp/loadhist.el b/lisp/loadhist.el
index 8cbe1d80cd3..76ef87ee845 100644
--- a/lisp/loadhist.el
+++ b/lisp/loadhist.el
@@ -51,9 +51,26 @@ a buffer with no associated file, or an `eval-region', return nil."
51 (error "%S is not a currently loaded feature" feature) 51 (error "%S is not a currently loaded feature" feature)
52 (car (feature-symbols feature)))) 52 (car (feature-symbols feature))))
53 53
54(defun file-loadhist-lookup (file)
55 "Return the `load-history' element for FILE."
56 ;; First look for FILE as given.
57 (let ((symbols (assoc file load-history)))
58 ;; Try converting a library name to an absolute file name.
59 (and (null symbols)
60 (let ((absname (find-library-name file)))
61 (if (not (equal absname file))
62 (setq symbols (cdr (assoc absname load-history))))))
63 ;; Try converting an absolute file name to a library name.
64 (and (null symbols) (string-match "[.]el\\'" file)
65 (let ((libname (file-name-nondirectory file)))
66 (string-match "[.]el\\'" libname)
67 (setq libname (substring libname 0 (match-beginning 0)))
68 (setq symbols (cdr (assoc libname load-history)))))
69 symbols))
70
54(defun file-provides (file) 71(defun file-provides (file)
55 "Return the list of features provided by FILE." 72 "Return the list of features provided by FILE."
56 (let ((symbols (cdr (assoc file load-history))) 73 (let ((symbols (file-loadhist-lookup file))
57 provides) 74 provides)
58 (mapc (lambda (x) 75 (mapc (lambda (x)
59 (if (and (consp x) (eq (car x) 'provide)) 76 (if (and (consp x) (eq (car x) 'provide))
@@ -63,7 +80,7 @@ a buffer with no associated file, or an `eval-region', return nil."
63 80
64(defun file-requires (file) 81(defun file-requires (file)
65 "Return the list of features required by FILE." 82 "Return the list of features required by FILE."
66 (let ((symbols (cdr (assoc file load-history))) 83 (let ((symbols (file-loadhist-lookup file))
67 requires) 84 requires)
68 (mapc (lambda (x) 85 (mapc (lambda (x)
69 (if (and (consp x) (eq (car x) 'require)) 86 (if (and (consp x) (eq (car x) 'require))
diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el
index 1b94f179f94..2f973cdfbb9 100644
--- a/lisp/mail/mailabbrev.el
+++ b/lisp/mail/mailabbrev.el
@@ -305,10 +305,19 @@ If DEFINITION contains multiple addresses, separate them with commas."
305 end (string-match "\"[ \t,]*" definition start)) 305 end (string-match "\"[ \t,]*" definition start))
306 (setq end (string-match "[ \t,]+" definition start))) 306 (setq end (string-match "[ \t,]+" definition start)))
307 (setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start))) 307 (setq end (string-match "[ \t\n,]*,[ \t\n,]*" definition start)))
308 (setq result (cons (substring definition start end) result)) 308 (let ((tem (substring definition start end)))
309 (setq start (and end 309 ;; Advance the loop past this address.
310 (/= (match-end 0) L) 310 (setq start (and end
311 (match-end 0)))) 311 (/= (match-end 0) L)
312 (match-end 0)))
313 ;; If the full name contains a problem character, quote it.
314 (when (string-match "\\(.+?\\)[ \t]*\\(<.*>\\)" tem)
315 (if (string-match "[^- !#$%&'*+/0-9=?A-Za-z^_`{|}~]"
316 (match-string 1 tem))
317 (setq tem (replace-regexp-in-string
318 "\\(.+?\\)[ \t]*\\(<.*>\\)" "\"\\1\" \\2"
319 tem))))
320 (push tem result)))
312 (setq definition (mapconcat (function identity) 321 (setq definition (mapconcat (function identity)
313 (nreverse result) 322 (nreverse result)
314 mail-alias-separator-string))) 323 mail-alias-separator-string)))
@@ -485,7 +494,9 @@ of a mail alias. The value is set up, buffer-local, when first needed.")
485 ;; the usual syntax table. 494 ;; the usual syntax table.
486 495
487 (or (and (integerp last-command-char) 496 (or (and (integerp last-command-char)
488 (eq (char-syntax last-command-char) ?_)) 497 (or (eq (char-syntax last-command-char) ?_)
498 ;; Don't expand on @.
499 (memq last-command-char '(?@ ?. ?% ?! ?_ ?-))))
489 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop. 500 (let ((pre-abbrev-expand-hook nil)) ; That's us; don't loop.
490 ;; Use this table so that abbrevs can have hyphens in them. 501 ;; Use this table so that abbrevs can have hyphens in them.
491 (set-syntax-table mail-abbrev-syntax-table) 502 (set-syntax-table mail-abbrev-syntax-table)
@@ -610,7 +621,8 @@ Don't use this command in Lisp programs!
610 (interactive "P") 621 (interactive "P")
611 (if (looking-at "[ \t]*\n") (expand-abbrev)) 622 (if (looking-at "[ \t]*\n") (expand-abbrev))
612 (setq this-command 'end-of-buffer) 623 (setq this-command 'end-of-buffer)
613 (end-of-buffer arg)) 624 (with-no-warnings
625 (end-of-buffer arg)))
614 626
615(eval-after-load "sendmail" 627(eval-after-load "sendmail"
616 '(progn 628 '(progn
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index fddbc4d1c6b..c97f048a940 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1,6 +1,6 @@
1;;; rmail.el --- main code of "RMAIL" mail reader for Emacs 1;;; rmail.el --- main code of "RMAIL" mail reader for Emacs
2 2
3;; Copyright (C) 1985,86,87,88,93,94,95,96,97,98,2000, 01, 2004 3;; Copyright (C) 1985,86,87,88,93,94,95,96,97,98,2000,01,2004,2005
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Maintainer: FSF 6;; Maintainer: FSF
@@ -91,6 +91,9 @@
91 :prefix "rmail-edit-" 91 :prefix "rmail-edit-"
92 :group 'rmail) 92 :group 'rmail)
93 93
94(defgroup rmail-obsolete nil
95 "Rmail obsolete customization variables."
96 :group 'rmail)
94 97
95(defcustom rmail-movemail-program nil 98(defcustom rmail-movemail-program nil
96 "If non-nil, name of program for fetching new mail." 99 "If non-nil, name of program for fetching new mail."
@@ -98,15 +101,46 @@
98 :type '(choice (const nil) string)) 101 :type '(choice (const nil) string))
99 102
100(defcustom rmail-pop-password nil 103(defcustom rmail-pop-password nil
101 "*Password to use when reading mail from a POP server, if required." 104 "*Password to use when reading mail from POP server. Please, use rmail-remote-password instead."
102 :type '(choice (string :tag "Password") 105 :type '(choice (string :tag "Password")
103 (const :tag "Not Required" nil)) 106 (const :tag "Not Required" nil))
104 :group 'rmail-retrieve) 107 :group 'rmail-obsolete)
105 108
106(defcustom rmail-pop-password-required nil 109(defcustom rmail-pop-password-required nil
107 "*Non-nil if a password is required when reading mail using POP." 110 "*Non-nil if a password is required when reading mail from a POP server. Please, use rmail-remote-password-required instead."
108 :type 'boolean 111 :type 'boolean
109 :group 'rmail-retrieve) 112 :group 'rmail-obsolete)
113
114(defcustom rmail-remote-password nil
115 "*Password to use when reading mail from a remote server. This setting is ignored for mailboxes whose URL already contains a password."
116 :type '(choice (string :tag "Password")
117 (const :tag "Not Required" nil))
118 :set-after '(rmail-pop-password)
119 :set #'(lambda (symbol value)
120 (set-default symbol
121 (if (and (not value)
122 (boundp 'rmail-pop-password)
123 rmail-pop-password)
124 rmail-pop-password
125 value))
126 (setq rmail-pop-password nil))
127 :group 'rmail-retrieve
128 :version "21.3.50.1")
129
130(defcustom rmail-remote-password-required nil
131 "*Non-nil if a password is required when reading mail from a remote server."
132 :type 'boolean
133 :set-after '(rmail-pop-password-required)
134 :set #'(lambda (symbol value)
135 (set-default symbol
136 (if (and (not value)
137 (boundp 'rmail-pop-password-required)
138 rmail-pop-password-required)
139 rmail-pop-password-required
140 value))
141 (setq rmail-pop-password-required nil))
142 :group 'rmail-retrieve
143 :version "21.3.50.1")
110 144
111(defcustom rmail-movemail-flags nil 145(defcustom rmail-movemail-flags nil
112 "*List of flags to pass to movemail. 146 "*List of flags to pass to movemail.
@@ -116,13 +150,14 @@ or `-k' to enable Kerberos authentication."
116 :group 'rmail-retrieve 150 :group 'rmail-retrieve
117 :version "20.3") 151 :version "20.3")
118 152
119(defvar rmail-pop-password-error "invalid usercode or password\\| 153(defvar rmail-remote-password-error "invalid usercode or password\\|
120unknown user name or bad password" 154unknown user name or bad password\\|Authentication failed\\|MU_ERR_AUTH_FAILURE"
121 "Regular expression matching incorrect-password POP server error messages. 155 "Regular expression matching incorrect-password POP or IMAP server error
156messages.
122If you get an incorrect-password error that this expression does not match, 157If you get an incorrect-password error that this expression does not match,
123please report it with \\[report-emacs-bug].") 158please report it with \\[report-emacs-bug].")
124 159
125(defvar rmail-encoded-pop-password nil) 160(defvar rmail-encoded-remote-password nil)
126 161
127(defcustom rmail-preserve-inbox nil 162(defcustom rmail-preserve-inbox nil
128 "*Non-nil if incoming mail should be left in the user's inbox, 163 "*Non-nil if incoming mail should be left in the user's inbox,
@@ -130,6 +165,67 @@ rather than deleted, after it is retrieved."
130 :type 'boolean 165 :type 'boolean
131 :group 'rmail-retrieve) 166 :group 'rmail-retrieve)
132 167
168(defcustom rmail-movemail-search-path nil
169 "*List of directories to search for movemail (in addition to `exec-path')."
170 :group 'rmail-retrieve
171 :type '(repeat (directory)))
172
173(defun rmail-probe (prog)
174 "Determine what flavor of movemail PROG is by executing it with --version
175command line option and analyzing its output."
176 (with-temp-buffer
177 (let ((tbuf (current-buffer)))
178 (buffer-disable-undo tbuf)
179 (call-process prog nil tbuf nil "--version")
180 (if (not (buffer-modified-p tbuf))
181 ;; Should not happen...
182 nil
183 (goto-char (point-min))
184 (cond
185 ((looking-at ".*movemail: invalid option")
186 'emacs) ;; Possibly...
187 ((looking-at "movemail (GNU Mailutils .*)")
188 'mailutils)
189 (t
190 ;; FIXME:
191 'emacs))))))
192
193(defun rmail-autodetect ()
194 "Determine and return the flavor of `movemail' program in use. If
195rmail-movemail-program is set, use it. Otherwise, look for `movemail'
196in the path constructed by appending rmail-movemail-search-path,
197exec-path and exec-directory."
198 (if rmail-movemail-program
199 (rmail-probe rmail-movemail-program)
200 (catch 'scan
201 (dolist (dir (append rmail-movemail-search-path exec-path
202 (list exec-directory)))
203 (when (and dir (file-accessible-directory-p dir))
204 (let ((progname (expand-file-name "movemail" dir)))
205 (when (and (not (file-directory-p progname))
206 (file-executable-p progname))
207 (let ((x (rmail-probe progname)))
208 (when x
209 (setq rmail-movemail-program progname)
210 (throw 'scan x))))))))))
211
212(defvar rmail-movemail-variant-in-use nil
213 "The movemail variant currently in use. Known variants are:
214
215 `emacs' Means any implementation, compatible with the native Emacs one.
216 This is the default;
217 `mailutils' Means GNU mailutils implementation, capable of handling full
218mail URLs as the source mailbox;")
219
220;;;###autoload
221(defun rmail-movemail-variant-p (&rest variants)
222 "Return t if the current movemail variant is any of VARIANTS.
223Currently known variants are 'emacs and 'mailutils."
224 (when (not rmail-movemail-variant-in-use)
225 ;; Autodetect
226 (setq rmail-movemail-variant-in-use (rmail-autodetect)))
227 (not (null (member rmail-movemail-variant-in-use variants))))
228
133;;;###autoload 229;;;###autoload
134(defcustom rmail-dont-reply-to-names nil "\ 230(defcustom rmail-dont-reply-to-names nil "\
135*A regexp specifying addresses to prune from a reply message. 231*A regexp specifying addresses to prune from a reply message.
@@ -1516,6 +1612,40 @@ It returns t if it got any new messages."
1516 ;; Don't leave the buffer screwed up if we get a disk-full error. 1612 ;; Don't leave the buffer screwed up if we get a disk-full error.
1517 (or found (rmail-show-message))))) 1613 (or found (rmail-show-message)))))
1518 1614
1615(defun rmail-parse-url (file)
1616 "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD GOT-PASSWORD)
1617WHERE MAILBOX-NAME is the name of the mailbox suitable as argument to the
1618actual version of `movemail', REMOTE is non-nil if MAILBOX-NAME refers to
1619a remote mailbox, PASSWORD is the password if it should be
1620supplied as a separate argument to `movemail' or nil otherwise, GOT-PASSWORD
1621is non-nil if the user has supplied the password interactively.
1622"
1623 (if (string-match "^\\([^:]+\\)://\\(\\([^:@]+\\)\\(:\\([^@]+\\)\\)?@\\)?.*" file)
1624 (let (got-password supplied-password
1625 (proto (match-string 1 file))
1626 (user (match-string 3 file))
1627 (pass (match-string 5 file))
1628 (host (substring file (or (match-end 2)
1629 (+ 3 (match-end 1))))))
1630 (if (not pass)
1631 (when rmail-remote-password-required
1632 (setq got-password (not (rmail-have-password)))
1633 (setq supplied-password (rmail-get-remote-password
1634 (string-equal proto "imap")))))
1635
1636 (if (rmail-movemail-variant-p 'emacs)
1637 (if (string-equal proto "pop")
1638 (list (concat "po:" user ":" host)
1639 t
1640 (or pass supplied-password)
1641 got-password)
1642 (error "Emacs movemail does not support %s protocol" proto))
1643 (list file
1644 (or (string-equal proto "pop") (string-equal proto "imap"))
1645 supplied-password
1646 got-password)))
1647 (list file nil nil nil)))
1648
1519(defun rmail-insert-inbox-text (files renamep) 1649(defun rmail-insert-inbox-text (files renamep)
1520 ;; Detect a locked file now, so that we avoid moving mail 1650 ;; Detect a locked file now, so that we avoid moving mail
1521 ;; out of the real inbox file. (That could scare people.) 1651 ;; out of the real inbox file. (That could scare people.)
@@ -1524,10 +1654,15 @@ It returns t if it got any new messages."
1524 (file-name-nondirectory buffer-file-name))) 1654 (file-name-nondirectory buffer-file-name)))
1525 (let (file tofile delete-files movemail popmail got-password password) 1655 (let (file tofile delete-files movemail popmail got-password password)
1526 (while files 1656 (while files
1527 ;; Handle POP mailbox names specially; don't expand as filenames 1657 ;; Handle remote mailbox names specially; don't expand as filenames
1528 ;; in case the userid contains a directory separator. 1658 ;; in case the userid contains a directory separator.
1529 (setq file (car files)) 1659 (setq file (car files))
1530 (setq popmail (string-match "^po:" file)) 1660 (let ((url-data (rmail-parse-url file)))
1661 (setq file (nth 0 url-data))
1662 (setq popmail (nth 1 url-data))
1663 (setq password (nth 2 url-data))
1664 (setq got-password (nth 3 url-data)))
1665
1531 (if popmail 1666 (if popmail
1532 (setq renamep t) 1667 (setq renamep t)
1533 (setq file (file-truename 1668 (setq file (file-truename
@@ -1535,7 +1670,12 @@ It returns t if it got any new messages."
1535 (setq tofile (expand-file-name 1670 (setq tofile (expand-file-name
1536 ;; Generate name to move to from inbox name, 1671 ;; Generate name to move to from inbox name,
1537 ;; in case of multiple inboxes that need moving. 1672 ;; in case of multiple inboxes that need moving.
1538 (concat ".newmail-" (file-name-nondirectory file)) 1673 (concat ".newmail-"
1674 (file-name-nondirectory
1675 (if (memq system-type '(windows-nt cygwin))
1676 ;; cannot have "po:" in file name
1677 (substring file 3)
1678 file)))
1539 ;; Use the directory of this rmail file 1679 ;; Use the directory of this rmail file
1540 ;; because it's a nuisance to use the homedir 1680 ;; because it's a nuisance to use the homedir
1541 ;; if that is on a full disk and this rmail 1681 ;; if that is on a full disk and this rmail
@@ -1560,18 +1700,7 @@ It returns t if it got any new messages."
1560 (setq file (expand-file-name (user-login-name) 1700 (setq file (expand-file-name (user-login-name)
1561 file))))) 1701 file)))))
1562 (cond (popmail 1702 (cond (popmail
1563 (if rmail-pop-password-required 1703 (message "Getting mail from the remote server ..."))
1564 (progn (setq got-password (not (rmail-have-password)))
1565 (setq password (rmail-get-pop-password))))
1566 (if (memq system-type '(windows-nt cygwin))
1567 ;; cannot have "po:" in file name
1568 (setq tofile
1569 (expand-file-name
1570 (concat ".newmail-pop-"
1571 (file-name-nondirectory (substring file 3)))
1572 (file-name-directory
1573 (expand-file-name buffer-file-name)))))
1574 (message "Getting mail from post office ..."))
1575 ((and (file-exists-p tofile) 1704 ((and (file-exists-p tofile)
1576 (/= 0 (nth 7 (file-attributes tofile)))) 1705 (/= 0 (nth 7 (file-attributes tofile))))
1577 (message "Getting mail from %s..." tofile)) 1706 (message "Getting mail from %s..." tofile))
@@ -1603,50 +1732,59 @@ It returns t if it got any new messages."
1603 (write-region (point) (point) file) 1732 (write-region (point) (point) file)
1604 (file-error nil)))) 1733 (file-error nil))))
1605 (t 1734 (t
1606 (let ((errors nil)) 1735 (with-temp-buffer
1607 (unwind-protect 1736 (let ((errors (current-buffer)))
1608 (save-excursion 1737 (buffer-disable-undo errors)
1609 (setq errors (generate-new-buffer " *rmail loss*")) 1738 (let ((args
1610 (buffer-disable-undo errors) 1739 (append
1611 (let ((args 1740 (list (or rmail-movemail-program
1612 (append 1741 (expand-file-name "movemail"
1613 (list (or rmail-movemail-program 1742 exec-directory))
1614 (expand-file-name "movemail" 1743 nil errors nil)
1615 exec-directory)) 1744 (if rmail-preserve-inbox
1616 nil errors nil) 1745 (list "-p")
1617 (if rmail-preserve-inbox 1746 nil)
1618 (list "-p") 1747 (if (rmail-movemail-variant-p 'mailutils)
1619 nil) 1748 (append (list "--emacs") rmail-movemail-flags)
1620 rmail-movemail-flags 1749 rmail-movemail-flags)
1621 (list file tofile) 1750 (list file tofile)
1622 (if password (list password) nil)))) 1751 (if password (list password) nil))))
1623 (apply 'call-process args)) 1752 (apply 'call-process args))
1624 (if (not (buffer-modified-p errors)) 1753 (if (not (buffer-modified-p errors))
1625 ;; No output => movemail won 1754 ;; No output => movemail won
1626 nil 1755 nil
1627 (set-buffer errors) 1756 (set-buffer errors)
1628 (subst-char-in-region (point-min) (point-max) 1757 (subst-char-in-region (point-min) (point-max)
1629 ?\n ?\ ) 1758 ?\n ?\ )
1630 (goto-char (point-max)) 1759 (goto-char (point-max))
1631 (skip-chars-backward " \t") 1760 (skip-chars-backward " \t")
1632 (delete-region (point) (point-max)) 1761 (delete-region (point) (point-max))
1633 (goto-char (point-min)) 1762 (goto-char (point-min))
1634 (if (looking-at "movemail: ") 1763 (if (looking-at "movemail: ")
1635 (delete-region (point-min) (match-end 0))) 1764 (delete-region (point-min) (match-end 0)))
1636 (beep t) 1765 (beep t)
1637 (message "movemail: %s" 1766 ;; If we just read the password, most likely it is
1638 (buffer-substring (point-min) 1767 ;; wrong. Otherwise, see if there is a specific
1639 (point-max))) 1768 ;; reason to think that the problem is a wrong passwd.
1640 ;; If we just read the password, most likely it is 1769 (if (or got-password
1641 ;; wrong. Otherwise, see if there is a specific 1770 (re-search-forward rmail-remote-password-error
1642 ;; reason to think that the problem is a wrong passwd. 1771 nil t))
1643 (if (or got-password 1772 (rmail-set-remote-password nil))
1644 (re-search-forward rmail-pop-password-error 1773
1645 nil t)) 1774 ;; If using Mailutils, remove initial error code
1646 (rmail-set-pop-password nil)) 1775 ;; abbreviation
1647 (sit-for 3) 1776 (when (rmail-movemail-variant-p 'mailutils)
1648 nil)) 1777 (goto-char (point-min))
1649 (if errors (kill-buffer errors)))))) 1778 (when (looking-at "[A-Z][A-Z0-9_]*:")
1779 (delete-region (point-min) (match-end 0))))
1780
1781 (message "movemail: %s"
1782 (buffer-substring (point-min)
1783 (point-max)))
1784
1785 (sit-for 3)
1786 nil)))))
1787
1650 ;; At this point, TOFILE contains the name to read: 1788 ;; At this point, TOFILE contains the name to read:
1651 ;; Either the alternate name (if we renamed) 1789 ;; Either the alternate name (if we renamed)
1652 ;; or the actual inbox (if not renaming). 1790 ;; or the actual inbox (if not renaming).
@@ -3834,27 +3972,30 @@ TEXT and INDENT are not used."
3834; nor is it meant to be. 3972; nor is it meant to be.
3835 3973
3836;;;###autoload 3974;;;###autoload
3837(defun rmail-set-pop-password (password) 3975(defun rmail-set-remote-password (password)
3838 "Set PASSWORD to be used for retrieving mail from a POP server." 3976 "Set PASSWORD to be used for retrieving mail from a POP or IMAP server."
3839 (interactive "sPassword: ") 3977 (interactive "sPassword: ")
3840 (if password 3978 (if password
3841 (setq rmail-encoded-pop-password 3979 (setq rmail-encoded-remote-password
3842 (rmail-encode-string password (emacs-pid))) 3980 (rmail-encode-string password (emacs-pid)))
3843 (setq rmail-pop-password nil) 3981 (setq rmail-remote-password nil)
3844 (setq rmail-encoded-pop-password nil))) 3982 (setq rmail-encoded-remote-password nil)))
3845 3983
3846(defun rmail-get-pop-password () 3984(defun rmail-get-remote-password (imap)
3847 "Get the password for retrieving mail from a POP server. If none 3985 "Get the password for retrieving mail from a POP or IMAP server. If none
3848has been set, then prompt the user for one." 3986has been set, then prompt the user for one."
3849 (if (not rmail-encoded-pop-password) 3987 (when (not rmail-encoded-remote-password)
3850 (progn (if (not rmail-pop-password) 3988 (if (not rmail-remote-password)
3851 (setq rmail-pop-password (read-passwd "POP password: "))) 3989 (setq rmail-remote-password
3852 (rmail-set-pop-password rmail-pop-password) 3990 (read-passwd (if imap
3853 (setq rmail-pop-password nil))) 3991 "IMAP password: "
3854 (rmail-encode-string rmail-encoded-pop-password (emacs-pid))) 3992 "POP password: "))))
3993 (rmail-set-remote-password rmail-remote-password)
3994 (setq rmail-remote-password nil))
3995 (rmail-encode-string rmail-encoded-remote-password (emacs-pid)))
3855 3996
3856(defun rmail-have-password () 3997(defun rmail-have-password ()
3857 (or rmail-pop-password rmail-encoded-pop-password)) 3998 (or rmail-remote-password rmail-encoded-remote-password))
3858 3999
3859(defun rmail-encode-string (string mask) 4000(defun rmail-encode-string (string mask)
3860 "Encode STRING with integer MASK, by taking the exclusive OR of the 4001 "Encode STRING with integer MASK, by taking the exclusive OR of the
diff --git a/lisp/man.el b/lisp/man.el
index 735805f1bba..e9503ca883a 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -415,13 +415,15 @@ Otherwise, the value is whatever the function
415;; buttons 415;; buttons
416(define-button-type 'Man-xref-man-page 416(define-button-type 'Man-xref-man-page
417 'action (lambda (button) (man-follow (button-label button))) 417 'action (lambda (button) (man-follow (button-label button)))
418 'help-echo "RET, mouse-2: display this man page") 418 'follow-link t
419 'help-echo "mouse-2, RET: display this man page")
419 420
420(define-button-type 'Man-xref-header-file 421(define-button-type 'Man-xref-header-file
421 'action (lambda (button) 422 'action (lambda (button)
422 (let ((w (button-get button 'Man-target-string))) 423 (let ((w (button-get button 'Man-target-string)))
423 (unless (Man-view-header-file w) 424 (unless (Man-view-header-file w)
424 (error "Cannot find header file: %s" w)))) 425 (error "Cannot find header file: %s" w))))
426 'follow-link t
425 'help-echo "mouse-2: display this header file") 427 'help-echo "mouse-2: display this header file")
426 428
427(define-button-type 'Man-xref-normal-file 429(define-button-type 'Man-xref-normal-file
@@ -433,6 +435,7 @@ Otherwise, the value is whatever the function
433 (view-file f) 435 (view-file f)
434 (error "Cannot read a file: %s" f)) 436 (error "Cannot read a file: %s" f))
435 (error "Cannot find a file: %s" f)))) 437 (error "Cannot find a file: %s" f))))
438 'follow-link t
436 'help-echo "mouse-2: display this file") 439 'help-echo "mouse-2: display this file")
437 440
438 441
@@ -822,6 +825,7 @@ Same for the ANSI bold and normal escape sequences."
822 (goto-char (point-min)) 825 (goto-char (point-min))
823 ;; Fontify ANSI escapes. 826 ;; Fontify ANSI escapes.
824 (let ((faces nil) 827 (let ((faces nil)
828 (buffer-undo-list t)
825 (start (point))) 829 (start (point)))
826 ;; http://www.isthe.com/chongo/tech/comp/ansi_escapes.html 830 ;; http://www.isthe.com/chongo/tech/comp/ansi_escapes.html
827 ;; suggests many codes, but we only handle: 831 ;; suggests many codes, but we only handle:
@@ -853,46 +857,47 @@ Same for the ANSI bold and normal escape sequences."
853 (delete-region (match-beginning 0) (match-end 0)) 857 (delete-region (match-beginning 0) (match-end 0))
854 (setq start (point)))) 858 (setq start (point))))
855 ;; Other highlighting. 859 ;; Other highlighting.
856 (if (< (buffer-size) (position-bytes (point-max))) 860 (let ((buffer-undo-list t))
857 ;; Multibyte characters exist. 861 (if (< (buffer-size) (position-bytes (point-max)))
858 (progn 862 ;; Multibyte characters exist.
859 (goto-char (point-min)) 863 (progn
860 (while (search-forward "__\b\b" nil t) 864 (goto-char (point-min))
861 (backward-delete-char 4) 865 (while (search-forward "__\b\b" nil t)
862 (put-text-property (point) (1+ (point)) 'face Man-underline-face)) 866 (backward-delete-char 4)
863 (goto-char (point-min)) 867 (put-text-property (point) (1+ (point)) 'face Man-underline-face))
864 (while (search-forward "\b\b__" nil t) 868 (goto-char (point-min))
865 (backward-delete-char 4) 869 (while (search-forward "\b\b__" nil t)
866 (put-text-property (1- (point)) (point) 'face Man-underline-face)))) 870 (backward-delete-char 4)
867 (goto-char (point-min)) 871 (put-text-property (1- (point)) (point) 'face Man-underline-face))))
868 (while (search-forward "_\b" nil t) 872 (goto-char (point-min))
869 (backward-delete-char 2) 873 (while (search-forward "_\b" nil t)
870 (put-text-property (point) (1+ (point)) 'face Man-underline-face)) 874 (backward-delete-char 2)
871 (goto-char (point-min)) 875 (put-text-property (point) (1+ (point)) 'face Man-underline-face))
872 (while (search-forward "\b_" nil t) 876 (goto-char (point-min))
873 (backward-delete-char 2) 877 (while (search-forward "\b_" nil t)
874 (put-text-property (1- (point)) (point) 'face Man-underline-face)) 878 (backward-delete-char 2)
875 (goto-char (point-min)) 879 (put-text-property (1- (point)) (point) 'face Man-underline-face))
876 (while (re-search-forward "\\(.\\)\\(\b+\\1\\)+" nil t) 880 (goto-char (point-min))
877 (replace-match "\\1") 881 (while (re-search-forward "\\(.\\)\\(\b+\\1\\)+" nil t)
878 (put-text-property (1- (point)) (point) 'face Man-overstrike-face)) 882 (replace-match "\\1")
879 (goto-char (point-min)) 883 (put-text-property (1- (point)) (point) 'face Man-overstrike-face))
880 (while (re-search-forward "o\b\\+\\|\\+\bo" nil t) 884 (goto-char (point-min))
881 (replace-match "o") 885 (while (re-search-forward "o\b\\+\\|\\+\bo" nil t)
882 (put-text-property (1- (point)) (point) 'face 'bold)) 886 (replace-match "o")
883 (goto-char (point-min)) 887 (put-text-property (1- (point)) (point) 'face 'bold))
884 (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) 888 (goto-char (point-min))
885 (replace-match "+") 889 (while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t)
886 (put-text-property (1- (point)) (point) 'face 'bold)) 890 (replace-match "+")
887 (goto-char (point-min)) 891 (put-text-property (1- (point)) (point) 'face 'bold))
888 ;; Try to recognize common forms of cross references. 892 (goto-char (point-min))
889 (Man-highlight-references) 893 ;; Try to recognize common forms of cross references.
890 (Man-softhyphen-to-minus) 894 (Man-highlight-references)
891 (goto-char (point-min)) 895 (Man-softhyphen-to-minus)
892 (while (re-search-forward Man-heading-regexp nil t) 896 (goto-char (point-min))
893 (put-text-property (match-beginning 0) 897 (while (re-search-forward Man-heading-regexp nil t)
894 (match-end 0) 898 (put-text-property (match-beginning 0)
895 'face Man-overstrike-face)) 899 (match-end 0)
900 'face Man-overstrike-face)))
896 (message "%s man page formatted" Man-arguments)) 901 (message "%s man page formatted" Man-arguments))
897 902
898(defun Man-highlight-references () 903(defun Man-highlight-references ()
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 63e0f6c9d91..7d94b678ca2 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1,6 +1,6 @@
1;;; mouse.el --- window system-independent mouse support 1;;; mouse.el --- window system-independent mouse support
2 2
3;; Copyright (C) 1993, 94, 95, 1999, 2000, 2001, 2002, 2003, 2004 3;; Copyright (C) 1993, 94, 95, 1999, 2000, 2001, 2002, 2003, 2004, 2005
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Maintainer: FSF 6;; Maintainer: FSF
@@ -397,7 +397,6 @@ MODE-LINE-P non-nil means dragging a mode line; nil means a header line."
397 (start-nwindows (count-windows t)) 397 (start-nwindows (count-windows t))
398 (old-selected-window (selected-window)) 398 (old-selected-window (selected-window))
399 (minibuffer (frame-parameter nil 'minibuffer)) 399 (minibuffer (frame-parameter nil 'minibuffer))
400 (mouse-autoselect-window nil)
401 should-enlarge-minibuffer event mouse y top bot edges wconfig growth) 400 should-enlarge-minibuffer event mouse y top bot edges wconfig growth)
402 (track-mouse 401 (track-mouse
403 (progn 402 (progn
@@ -435,7 +434,7 @@ MODE-LINE-P non-nil means dragging a mode line; nil means a header line."
435 (cond ((integerp event) 434 (cond ((integerp event)
436 (setq done t)) 435 (setq done t))
437 436
438 ((eq (car event) 'switch-frame) 437 ((memq (car event) '(switch-frame select-window))
439 nil) 438 nil)
440 439
441 ((not (memq (car event) '(mouse-movement scroll-bar-movement))) 440 ((not (memq (car event) '(mouse-movement scroll-bar-movement)))
@@ -582,7 +581,7 @@ resized by dragging their header-line."
582 ;; unknown event. 581 ;; unknown event.
583 (cond ((integerp event) 582 (cond ((integerp event)
584 (setq done t)) 583 (setq done t))
585 ((eq (car event) 'switch-frame) 584 ((memq (car event) '(switch-frame select-window))
586 nil) 585 nil)
587 ((not (memq (car event) 586 ((not (memq (car event)
588 '(mouse-movement scroll-bar-movement))) 587 '(mouse-movement scroll-bar-movement)))
@@ -754,11 +753,11 @@ remains active. Otherwise, it remains until the next input event.
754 753
755If the click is in the echo area, display the `*Messages*' buffer." 754If the click is in the echo area, display the `*Messages*' buffer."
756 (interactive "e") 755 (interactive "e")
757 (let ((w (posn-window (event-start start-event))) 756 (let ((w (posn-window (event-start start-event))))
758 (mouse-autoselect-window nil)) 757 (if (and (window-minibuffer-p w)
759 (if (not (or (not (window-minibuffer-p w)) 758 (not (minibuffer-window-active-p w)))
760 (minibuffer-window-active-p w)))
761 (save-excursion 759 (save-excursion
760 ;; Swallow the up-event.
762 (read-event) 761 (read-event)
763 (set-buffer "*Messages*") 762 (set-buffer "*Messages*")
764 (goto-char (point-max)) 763 (goto-char (point-max))
@@ -773,21 +772,24 @@ If the click is in the echo area, display the `*Messages*' buffer."
773 772
774A clickable link is identified by one of the following methods: 773A clickable link is identified by one of the following methods:
775 774
7761) If the character at POS has a non-nil `follow-link' text or 775- If the character at POS has a non-nil `follow-link' text or
777overlay property, the value of that property is returned. 776overlay property, use the value of that property determines what
777to do.
778 778
7792) If there is a local key-binding or a keybinding at position 779- If there is a local key-binding or a keybinding at position POS
780POS for the `follow-link' event, the binding of that event 780for the `follow-link' event, the binding of that event determines
781determines whether POS is inside a link: 781what to do.
782 782
783- If the binding is `mouse-face', POS is inside a link if there 783The resulting value determine whether POS is inside a link:
784
785- If the value is `mouse-face', POS is inside a link if there
784is a non-nil `mouse-face' property at POS. Return t in this case. 786is a non-nil `mouse-face' property at POS. Return t in this case.
785 787
786- If the binding is a function, FUNC, POS is inside a link if 788- If the value is a function, FUNC, POS is inside a link if
787the call \(FUNC POS) returns non-nil. Return the return value 789the call \(FUNC POS) returns non-nil. Return the return value
788from that call. 790from that call.
789 791
790- Otherwise, return the binding of the `follow-link' binding. 792- Otherwise, return the value itself.
791 793
792The return value is interpreted as follows: 794The return value is interpreted as follows:
793 795
@@ -801,16 +803,17 @@ click is the local or global binding of that event.
801 803
802- Otherwise, the mouse-1 event is translated into a mouse-2 event 804- Otherwise, the mouse-1 event is translated into a mouse-2 event
803at the same position." 805at the same position."
804 (or (get-char-property pos 'follow-link) 806 (let ((action
805 (save-excursion 807 (or (get-char-property pos 'follow-link)
806 (goto-char pos) 808 (save-excursion
807 (let ((b (key-binding [follow-link] nil t))) 809 (goto-char pos)
808 (cond 810 (key-binding [follow-link] nil t)))))
809 ((eq b 'mouse-face) 811 (cond
810 (and (get-char-property pos 'mouse-face) t)) 812 ((eq action 'mouse-face)
811 ((functionp b) 813 (and (get-char-property pos 'mouse-face) t))
812 (funcall b pos)) 814 ((functionp action)
813 (t b)))))) 815 (funcall action pos))
816 (t action))))
814 817
815(defun mouse-drag-region-1 (start-event) 818(defun mouse-drag-region-1 (start-event)
816 (mouse-minibuffer-check start-event) 819 (mouse-minibuffer-check start-event)
@@ -858,8 +861,8 @@ at the same position."
858 (while (progn 861 (while (progn
859 (setq event (read-event)) 862 (setq event (read-event))
860 (or (mouse-movement-p event) 863 (or (mouse-movement-p event)
861 (eq (car-safe event) 'switch-frame))) 864 (memq (car-safe event) '(switch-frame select-window))))
862 (if (eq (car-safe event) 'switch-frame) 865 (if (memq (car-safe event) '(switch-frame select-window))
863 nil 866 nil
864 (setq end (event-end event) 867 (setq end (event-end event)
865 end-point (posn-point end)) 868 end-point (posn-point end))
@@ -1153,6 +1156,7 @@ If MODE is 2 then do the same for lines."
1153 (move-overlay mouse-drag-overlay (point) (mark t))) 1156 (move-overlay mouse-drag-overlay (point) (mark t)))
1154 (catch 'mouse-show-mark 1157 (catch 'mouse-show-mark
1155 ;; In this loop, execute scroll bar and switch-frame events. 1158 ;; In this loop, execute scroll bar and switch-frame events.
1159 ;; Should we similarly handle `select-window' events? --Stef
1156 ;; Also ignore down-events that are undefined. 1160 ;; Also ignore down-events that are undefined.
1157 (while (progn (setq event (read-event)) 1161 (while (progn (setq event (read-event))
1158 (setq events (append events (list event))) 1162 (setq events (append events (list event)))
@@ -1476,9 +1480,9 @@ The function returns a non-nil value if it creates a secondary selection."
1476 (while (progn 1480 (while (progn
1477 (setq event (read-event)) 1481 (setq event (read-event))
1478 (or (mouse-movement-p event) 1482 (or (mouse-movement-p event)
1479 (eq (car-safe event) 'switch-frame))) 1483 (memq (car-safe event) '(switch-frame select-window))))
1480 1484
1481 (if (eq (car-safe event) 'switch-frame) 1485 (if (memq (car-safe event) '(switch-frame select-window))
1482 nil 1486 nil
1483 (setq end (event-end event) 1487 (setq end (event-end event)
1484 end-point (posn-point end)) 1488 end-point (posn-point end))
diff --git a/lisp/progmodes/ebrowse.el b/lisp/progmodes/ebrowse.el
index 478ce403b31..bf11ea28514 100644
--- a/lisp/progmodes/ebrowse.el
+++ b/lisp/progmodes/ebrowse.el
@@ -780,16 +780,16 @@ The class tree is found in the buffer-local variable `ebrowse--tree-obarray'."
780 780
781(defun ebrowse-class-in-tree (class tree) 781(defun ebrowse-class-in-tree (class tree)
782 "Search for a class with name CLASS in TREE. 782 "Search for a class with name CLASS in TREE.
783Return the class found, if any. This function is used during the load 783If CLASS is found, return the tail of TREE starting at CLASS. This function
784phase where classes appended to a file replace older class 784is used during the load phase where classes appended to a file replace older
785information." 785class information."
786 (let ((tclass (ebrowse-ts-class class)) 786 (let ((tclass (ebrowse-ts-class class))
787 found) 787 found)
788 (while (and tree (not found)) 788 (while (and tree (not found))
789 (let ((root (car tree))) 789 (let ((root-ptr tree))
790 (when (string= (ebrowse-qualified-class-name (ebrowse-ts-class root)) 790 (when (string= (ebrowse-qualified-class-name (ebrowse-ts-class (car root-ptr)))
791 (ebrowse-qualified-class-name tclass)) 791 (ebrowse-qualified-class-name tclass))
792 (setq found root)) 792 (setq found root-ptr))
793 (setq tree (cdr tree)))) 793 (setq tree (cdr tree))))
794 found)) 794 found))
795 795
@@ -903,10 +903,10 @@ and TREE is a list of `ebrowse-ts' structures forming the class tree."
903 (let ((gc-cons-threshold 2000000)) 903 (let ((gc-cons-threshold 2000000))
904 (while (not (progn (skip-chars-forward " \t\n\r") (eobp))) 904 (while (not (progn (skip-chars-forward " \t\n\r") (eobp)))
905 (let* ((root (read (current-buffer))) 905 (let* ((root (read (current-buffer)))
906 (old-root (ebrowse-class-in-tree root tree))) 906 (old-root-ptr (ebrowse-class-in-tree root tree)))
907 (ebrowse-show-progress "Reading data" (null tree)) 907 (ebrowse-show-progress "Reading data" (null tree))
908 (if old-root 908 (if old-root-ptr
909 (setf (car old-root) root) 909 (setcar old-root-ptr root)
910 (push root tree))))) 910 (push root tree)))))
911 (garbage-collect) 911 (garbage-collect)
912 (list header tree))) 912 (list header tree)))
diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el
index 07fcda385ef..d4229cf44c6 100644
--- a/lisp/progmodes/hideshow.el
+++ b/lisp/progmodes/hideshow.el
@@ -5,7 +5,7 @@
5;; Author: Thien-Thi Nguyen <ttn@gnu.org> 5;; Author: Thien-Thi Nguyen <ttn@gnu.org>
6;; Dan Nicolaescu <dann@ics.uci.edu> 6;; Dan Nicolaescu <dann@ics.uci.edu>
7;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines 7;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines
8;; Maintainer-Version: 5.58.2.3 8;; Maintainer-Version: 5.58.2.4
9;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning 9;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning
10 10
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
@@ -233,7 +233,6 @@
233;;; Code: 233;;; Code:
234 234
235(require 'easymenu) 235(require 'easymenu)
236(eval-when-compile (require 'cl))
237 236
238;;--------------------------------------------------------------------------- 237;;---------------------------------------------------------------------------
239;; user-configurable variables 238;; user-configurable variables
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index 49d3d46acbc..4b2941bd966 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -1,6 +1,6 @@
1;;; perl-mode.el --- Perl code editing commands for GNU Emacs 1;;; perl-mode.el --- Perl code editing commands for GNU Emacs
2 2
3;; Copyright (C) 1990, 1994, 2003 Free Software Foundation, Inc. 3;; Copyright (C) 1990, 1994, 2003, 2005 Free Software Foundation, Inc.
4 4
5;; Author: William F. Mann 5;; Author: William F. Mann
6;; Maintainer: FSF 6;; Maintainer: FSF
@@ -408,7 +408,7 @@ existing comment, moves to end-of-line, or if at end-of-line already,
408create a new comment." 408create a new comment."
409 :type 'boolean) 409 :type 'boolean)
410 410
411(defcustom perl-nochange ";?#\\|\f\\|\\s(\\|\\(\\w\\|\\s_\\)+:" 411(defcustom perl-nochange ";?#\\|\f\\|\\s(\\|\\(\\w\\|\\s_\\)+:[^:]"
412 "*Lines starting with this regular expression are not auto-indented." 412 "*Lines starting with this regular expression are not auto-indented."
413 :type 'regexp) 413 :type 'regexp)
414 414
@@ -769,7 +769,7 @@ Optional argument PARSE-START should be the position of `beginning-of-defun'."
769 (skip-chars-forward " \t\f\n") 769 (skip-chars-forward " \t\f\n")
770 (cond ((looking-at ";?#") 770 (cond ((looking-at ";?#")
771 (forward-line 1) t) 771 (forward-line 1) t)
772 ((looking-at "\\(\\w\\|\\s_\\)+:") 772 ((looking-at "\\(\\w\\|\\s_\\)+:[^:]")
773 (save-excursion 773 (save-excursion
774 (end-of-line) 774 (end-of-line)
775 (setq colon-line-end (point))) 775 (setq colon-line-end (point)))
@@ -929,5 +929,5 @@ With argument, repeat that many times; negative args move backward."
929 929
930(provide 'perl-mode) 930(provide 'perl-mode)
931 931
932;;; arch-tag: 8c7ff68d-15f3-46a2-ade2-b7c41f176826 932;; arch-tag: 8c7ff68d-15f3-46a2-ade2-b7c41f176826
933;;; perl-mode.el ends here 933;;; perl-mode.el ends here
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 387e1232dc0..a1e868a3926 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -448,6 +448,7 @@ This is buffer-local in every such buffer.")
448 (define-key map "\C-c=" 'sh-set-indent) 448 (define-key map "\C-c=" 'sh-set-indent)
449 (define-key map "\C-c<" 'sh-learn-line-indent) 449 (define-key map "\C-c<" 'sh-learn-line-indent)
450 (define-key map "\C-c>" 'sh-learn-buffer-indent) 450 (define-key map "\C-c>" 'sh-learn-buffer-indent)
451 (define-key map "\C-c\C-\\" 'sh-backslash-region)
451 452
452 (define-key map "=" 'sh-assignment) 453 (define-key map "=" 'sh-assignment)
453 (define-key map "\C-c+" 'sh-add) 454 (define-key map "\C-c+" 'sh-add)
@@ -1183,6 +1184,16 @@ This is for the rc shell."
1183 :type `(choice ,@ sh-number-or-symbol-list) 1184 :type `(choice ,@ sh-number-or-symbol-list)
1184 :group 'sh-indentation) 1185 :group 'sh-indentation)
1185 1186
1187(defcustom sh-backslash-column 48
1188 "*Column in which `sh-backslash-region' inserts backslashes."
1189 :type 'integer
1190 :group 'sh)
1191
1192(defcustom sh-backslash-align t
1193 "*If non-nil, `sh-backslash-region' will align backslashes."
1194 :type 'boolean
1195 :group 'sh)
1196
1186;; Internal use - not designed to be changed by the user: 1197;; Internal use - not designed to be changed by the user:
1187 1198
1188(defun sh-mkword-regexpr (word) 1199(defun sh-mkword-regexpr (word)
@@ -3547,6 +3558,77 @@ The document is bounded by `sh-here-document-word'."
3547 (if (re-search-forward sh-end-of-command nil t) 3558 (if (re-search-forward sh-end-of-command nil t)
3548 (goto-char (match-end 1)))) 3559 (goto-char (match-end 1))))
3549 3560
3561;; Backslashification. Stolen from make-mode.el.
3562
3563(defun sh-backslash-region (from to delete-flag)
3564 "Insert, align, or delete end-of-line backslashes on the lines in the region.
3565With no argument, inserts backslashes and aligns existing backslashes.
3566With an argument, deletes the backslashes.
3567
3568This function does not modify the last line of the region if the region ends
3569right at the start of the following line; it does not modify blank lines
3570at the start of the region. So you can put the region around an entire
3571shell command and conveniently use this command."
3572 (interactive "r\nP")
3573 (save-excursion
3574 (goto-char from)
3575 (let ((column sh-backslash-column)
3576 (endmark (make-marker)))
3577 (move-marker endmark to)
3578 ;; Compute the smallest column number past the ends of all the lines.
3579 (if sh-backslash-align
3580 (progn
3581 (if (not delete-flag)
3582 (while (< (point) to)
3583 (end-of-line)
3584 (if (= (preceding-char) ?\\)
3585 (progn (forward-char -1)
3586 (skip-chars-backward " \t")))
3587 (setq column (max column (1+ (current-column))))
3588 (forward-line 1)))
3589 ;; Adjust upward to a tab column, if that doesn't push
3590 ;; past the margin.
3591 (if (> (% column tab-width) 0)
3592 (let ((adjusted (* (/ (+ column tab-width -1) tab-width)
3593 tab-width)))
3594 (if (< adjusted (window-width))
3595 (setq column adjusted))))))
3596 ;; Don't modify blank lines at start of region.
3597 (goto-char from)
3598 (while (and (< (point) endmark) (eolp))
3599 (forward-line 1))
3600 ;; Add or remove backslashes on all the lines.
3601 (while (and (< (point) endmark)
3602 ;; Don't backslashify the last line
3603 ;; if the region ends right at the start of the next line.
3604 (save-excursion
3605 (forward-line 1)
3606 (< (point) endmark)))
3607 (if (not delete-flag)
3608 (sh-append-backslash column)
3609 (sh-delete-backslash))
3610 (forward-line 1))
3611 (move-marker endmark nil))))
3612
3613(defun sh-append-backslash (column)
3614 (end-of-line)
3615 ;; Note that "\\\\" is needed to get one backslash.
3616 (if (= (preceding-char) ?\\)
3617 (progn (forward-char -1)
3618 (delete-horizontal-space)
3619 (indent-to column (if sh-backslash-align nil 1)))
3620 (indent-to column (if sh-backslash-align nil 1))
3621 (insert "\\")))
3622
3623(defun sh-delete-backslash ()
3624 (end-of-line)
3625 (or (bolp)
3626 (progn
3627 (forward-char -1)
3628 (if (looking-at "\\\\")
3629 (delete-region (1+ (point))
3630 (progn (skip-chars-backward " \t") (point)))))))
3631
3550(provide 'sh-script) 3632(provide 'sh-script)
3551 3633
3552;;; arch-tag: eccd8b72-f337-4fc2-ae86-18155a69d937 3634;;; arch-tag: eccd8b72-f337-4fc2-ae86-18155a69d937
diff --git a/lisp/replace.el b/lisp/replace.el
index 8820a768006..82b2a993fdb 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -64,6 +64,27 @@ strings or patterns."
64 :group 'matching 64 :group 'matching
65 :version "21.4") 65 :version "21.4")
66 66
67(defcustom query-replace-highlight t
68 "*Non-nil means to highlight matches during query replacement."
69 :type 'boolean
70 :group 'matching)
71
72(defcustom query-replace-lazy-highlight t
73 "*Controls the lazy-highlighting during query replacements.
74When non-nil, all text in the buffer matching the current match
75is highlighted lazily using isearch lazy highlighting (see
76`lazy-highlight-initial-delay' and `lazy-highlight-interval')."
77 :type 'boolean
78 :group 'lazy-highlight
79 :group 'matching
80 :version "21.4")
81
82(defface query-replace
83 '((t (:inherit isearch)))
84 "Face for highlighting query replacement matches."
85 :group 'matching
86 :version "21.4")
87
67(defun query-replace-descr (string) 88(defun query-replace-descr (string)
68 (mapconcat 'isearch-text-char-description string "")) 89 (mapconcat 'isearch-text-char-description string ""))
69 90
@@ -802,9 +823,10 @@ If the value is nil, don't highlight the buffer names specially."
802 (setq count (+ count (if forwardp -1 1))) 823 (setq count (+ count (if forwardp -1 1)))
803 (setq beg (line-beginning-position) 824 (setq beg (line-beginning-position)
804 end (line-end-position)) 825 end (line-end-position))
805 (if (and keep-props (boundp 'jit-lock-mode) jit-lock-mode 826 (if (and keep-props (if (boundp 'jit-lock-mode) jit-lock-mode)
806 (text-property-not-all beg end 'fontified t)) 827 (text-property-not-all beg end 'fontified t))
807 (jit-lock-fontify-now beg end)) 828 (if (fboundp 'jit-lock-fontify-now)
829 (jit-lock-fontify-now beg end)))
808 (push 830 (push
809 (funcall (if keep-props 831 (funcall (if keep-props
810 #'buffer-substring 832 #'buffer-substring
@@ -1008,9 +1030,11 @@ See also `multi-occur'."
1008 endpt (line-end-position))) 1030 endpt (line-end-position)))
1009 (setq marker (make-marker)) 1031 (setq marker (make-marker))
1010 (set-marker marker matchbeg) 1032 (set-marker marker matchbeg)
1011 (if (and keep-props (boundp 'jit-lock-mode) jit-lock-mode 1033 (if (and keep-props
1034 (if (boundp 'jit-lock-mode) jit-lock-mode)
1012 (text-property-not-all begpt endpt 'fontified t)) 1035 (text-property-not-all begpt endpt 'fontified t))
1013 (jit-lock-fontify-now begpt endpt)) 1036 (if (fboundp 'jit-lock-fontify-now)
1037 (jit-lock-fontify-now begpt endpt)))
1014 (setq curstring (buffer-substring begpt endpt)) 1038 (setq curstring (buffer-substring begpt endpt))
1015 ;; Depropertize the string, and maybe 1039 ;; Depropertize the string, and maybe
1016 ;; highlight the matches 1040 ;; highlight the matches
@@ -1258,27 +1282,6 @@ passed in. If LITERAL is set, no checking is done, anyway."
1258 (replace-match newtext fixedcase literal) 1282 (replace-match newtext fixedcase literal)
1259 noedit) 1283 noedit)
1260 1284
1261(defcustom query-replace-highlight t
1262 "*Non-nil means to highlight matches during query replacement."
1263 :type 'boolean
1264 :group 'matching)
1265
1266(defcustom query-replace-lazy-highlight t
1267 "*Controls the lazy-highlighting during query replacements.
1268When non-nil, all text in the buffer matching the current match
1269is highlighted lazily using isearch lazy highlighting (see
1270`isearch-lazy-highlight-initial-delay' and
1271`isearch-lazy-highlight-interval')."
1272 :type 'boolean
1273 :group 'matching
1274 :version "21.4")
1275
1276(defface query-replace
1277 '((t (:inherit isearch)))
1278 "Face for highlighting query replacement matches."
1279 :group 'matching
1280 :version "21.4")
1281
1282(defun perform-replace (from-string replacements 1285(defun perform-replace (from-string replacements
1283 query-flag regexp-flag delimited-flag 1286 query-flag regexp-flag delimited-flag
1284 &optional repeat-count map start end) 1287 &optional repeat-count map start end)
diff --git a/lisp/simple.el b/lisp/simple.el
index 2baacc01531..77bdb47e250 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -647,15 +647,16 @@ If BACKWARD-ONLY is non-nil, only delete spaces before point."
647 (skip-chars-backward " \t") 647 (skip-chars-backward " \t")
648 (constrain-to-field nil orig-pos))))) 648 (constrain-to-field nil orig-pos)))))
649 649
650(defun just-one-space () 650(defun just-one-space (n)
651 "Delete all spaces and tabs around point, leaving one space." 651 "Delete all spaces and tabs around point, leaving one space (or N spaces)."
652 (interactive "*") 652 (interactive "*p")
653 (let ((orig-pos (point))) 653 (let ((orig-pos (point)))
654 (skip-chars-backward " \t") 654 (skip-chars-backward " \t")
655 (constrain-to-field nil orig-pos) 655 (constrain-to-field nil orig-pos)
656 (if (= (following-char) ? ) 656 (dotimes (i n)
657 (forward-char 1) 657 (if (= (following-char) ?\ )
658 (insert ? )) 658 (forward-char 1)
659 (insert ?\ )))
659 (delete-region 660 (delete-region
660 (point) 661 (point)
661 (progn 662 (progn
@@ -899,7 +900,7 @@ display the result of expression evaluation."
899 (if (and (integerp value) 900 (if (and (integerp value)
900 (or (not (memq this-command '(eval-last-sexp eval-print-last-sexp))) 901 (or (not (memq this-command '(eval-last-sexp eval-print-last-sexp)))
901 (eq this-command last-command) 902 (eq this-command last-command)
902 (and (boundp 'edebug-active) edebug-active))) 903 (if (boundp 'edebug-active) edebug-active)))
903 (let ((char-string 904 (let ((char-string
904 (if (or (and (boundp 'edebug-active) edebug-active) 905 (if (or (and (boundp 'edebug-active) edebug-active)
905 (memq this-command '(eval-last-sexp eval-print-last-sexp))) 906 (memq this-command '(eval-last-sexp eval-print-last-sexp)))
@@ -3008,10 +3009,10 @@ Does not set point. Does nothing if mark ring is empty."
3008 (when mark-ring 3009 (when mark-ring
3009 (setq mark-ring (nconc mark-ring (list (copy-marker (mark-marker))))) 3010 (setq mark-ring (nconc mark-ring (list (copy-marker (mark-marker)))))
3010 (set-marker (mark-marker) (+ 0 (car mark-ring)) (current-buffer)) 3011 (set-marker (mark-marker) (+ 0 (car mark-ring)) (current-buffer))
3011 (deactivate-mark)
3012 (move-marker (car mark-ring) nil) 3012 (move-marker (car mark-ring) nil)
3013 (if (null (mark t)) (ding)) 3013 (if (null (mark t)) (ding))
3014 (setq mark-ring (cdr mark-ring)))) 3014 (setq mark-ring (cdr mark-ring)))
3015 (deactivate-mark))
3015 3016
3016(defalias 'exchange-dot-and-mark 'exchange-point-and-mark) 3017(defalias 'exchange-dot-and-mark 'exchange-point-and-mark)
3017(defun exchange-point-and-mark (&optional arg) 3018(defun exchange-point-and-mark (&optional arg)
@@ -3590,7 +3591,7 @@ With argument, do this that many times."
3590The place mark goes is the same place \\[forward-word] would 3591The place mark goes is the same place \\[forward-word] would
3591move to with the same argument. 3592move to with the same argument.
3592Interactively, if this command is repeated 3593Interactively, if this command is repeated
3593or (in Transient Mark mode) if the mark is active, 3594or (in Transient Mark mode) if the mark is active,
3594it marks the next ARG words after the ones already marked." 3595it marks the next ARG words after the ones already marked."
3595 (interactive "P\np") 3596 (interactive "P\np")
3596 (cond ((and allow-extend 3597 (cond ((and allow-extend
@@ -4115,7 +4116,7 @@ specification for `play-sound'."
4115 (play-sound sound))) 4116 (play-sound sound)))
4116 4117
4117(define-key global-map "\e\e\e" 'keyboard-escape-quit) 4118(define-key global-map "\e\e\e" 'keyboard-escape-quit)
4118 4119
4119(defcustom read-mail-command 'rmail 4120(defcustom read-mail-command 'rmail
4120 "*Your preference for a mail reading package. 4121 "*Your preference for a mail reading package.
4121This is used by some keybindings which support reading mail. 4122This is used by some keybindings which support reading mail.
@@ -4257,7 +4258,7 @@ Each action has the form (FUNCTION . ARGS)."
4257 (list nil nil nil current-prefix-arg)) 4258 (list nil nil nil current-prefix-arg))
4258 (compose-mail to subject other-headers continue 4259 (compose-mail to subject other-headers continue
4259 'switch-to-buffer-other-frame yank-action send-actions)) 4260 'switch-to-buffer-other-frame yank-action send-actions))
4260 4261
4261(defvar set-variable-value-history nil 4262(defvar set-variable-value-history nil
4262 "History of values entered with `set-variable'.") 4263 "History of values entered with `set-variable'.")
4263 4264
@@ -4320,7 +4321,7 @@ With a prefix argument, set VARIABLE to VALUE buffer-locally."
4320 ;; Force a thorough redisplay for the case that the variable 4321 ;; Force a thorough redisplay for the case that the variable
4321 ;; has an effect on the display, like `tab-width' has. 4322 ;; has an effect on the display, like `tab-width' has.
4322 (force-mode-line-update)) 4323 (force-mode-line-update))
4323 4324
4324;; Define the major mode for lists of completions. 4325;; Define the major mode for lists of completions.
4325 4326
4326(defvar completion-list-mode-map nil 4327(defvar completion-list-mode-map nil
@@ -4328,6 +4329,7 @@ With a prefix argument, set VARIABLE to VALUE buffer-locally."
4328(or completion-list-mode-map 4329(or completion-list-mode-map
4329 (let ((map (make-sparse-keymap))) 4330 (let ((map (make-sparse-keymap)))
4330 (define-key map [mouse-2] 'mouse-choose-completion) 4331 (define-key map [mouse-2] 'mouse-choose-completion)
4332 (define-key map [follow-link] 'mouse-face)
4331 (define-key map [down-mouse-2] nil) 4333 (define-key map [down-mouse-2] nil)
4332 (define-key map "\C-m" 'choose-completion) 4334 (define-key map "\C-m" 'choose-completion)
4333 (define-key map "\e\e\e" 'delete-completion-window) 4335 (define-key map "\e\e\e" 'delete-completion-window)
diff --git a/lisp/startup.el b/lisp/startup.el
index e806dba7716..9dc60f4705f 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -871,12 +871,6 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
871 (sit-for 1)) 871 (sit-for 1))
872 (setq user-init-file source)))) 872 (setq user-init-file source))))
873 873
874 (when (stringp custom-file)
875 (unless (assoc custom-file load-history)
876 ;; If the .emacs file has set `custom-file' but hasn't
877 ;; loaded the file yet, let's load it.
878 (load custom-file t t)))
879
880 (unless inhibit-default-init 874 (unless inhibit-default-init
881 (let ((inhibit-startup-message nil)) 875 (let ((inhibit-startup-message nil))
882 ;; Users are supposed to be told their rights. 876 ;; Users are supposed to be told their rights.
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index f3a7616bfd6..0c4aeb1bd24 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1074,15 +1074,54 @@ Protects against bogus binding of `enable-multibyte-characters' in XEmacs."
1074 (decode-coding-string str (ispell-get-coding-system)) 1074 (decode-coding-string str (ispell-get-coding-system))
1075 str)) 1075 str))
1076 1076
1077(put 'ispell-unified-chars-table 'char-table-extra-slots 0)
1078
1079;; Char-table that maps an Unicode character (charset:
1080;; latin-iso8859-1, mule-unicode-0100-24ff, mule-unicode-2500-34ff) to
1081;; a string in which all equivalent characters are listed.
1082
1083(defconst ispell-unified-chars-table
1084 (let ((table (make-char-table 'ispell-unified-chars-table)))
1085 (map-char-table
1086 #'(lambda (c v)
1087 (if (and v (/= c v))
1088 (let ((unified (or (aref table v) (string v))))
1089 (aset table v (concat unified (string c))))))
1090 ucs-mule-8859-to-mule-unicode)
1091 table))
1092
1093;; Return a string decoded from Nth element of the current dictionary
1094;; while splice equivalent characters into the string. This splicing
1095;; is done only if the string is a regular expression of the form
1096;; "[...]" because, otherwise, splicing will result in incorrect
1097;; regular expression matching.
1098
1099(defun ispell-get-decoded-string (n)
1100 (let* ((slot (assoc ispell-dictionary ispell-dictionary-alist))
1101 (str (nth n slot)))
1102 (when (and (> (length str) 0)
1103 (not (multibyte-string-p str)))
1104 (setq str (ispell-decode-string str))
1105 (if (and (= (aref str 0) ?\[)
1106 (eq (string-match "\\]" str) (1- (length str))))
1107 (setq str
1108 (string-as-multibyte
1109 (mapconcat
1110 #'(lambda (c)
1111 (let ((unichar (aref ucs-mule-8859-to-mule-unicode c)))
1112 (if unichar
1113 (aref ispell-unified-chars-table unichar)
1114 (string c))))
1115 str ""))))
1116 (setcar (nthcdr n slot) str))
1117 str))
1118
1077(defun ispell-get-casechars () 1119(defun ispell-get-casechars ()
1078 (ispell-decode-string 1120 (ispell-get-decoded-string 1))
1079 (nth 1 (assoc ispell-dictionary ispell-dictionary-alist))))
1080(defun ispell-get-not-casechars () 1121(defun ispell-get-not-casechars ()
1081 (ispell-decode-string 1122 (ispell-get-decoded-string 2))
1082 (nth 2 (assoc ispell-dictionary ispell-dictionary-alist))))
1083(defun ispell-get-otherchars () 1123(defun ispell-get-otherchars ()
1084 (ispell-decode-string 1124 (ispell-get-decoded-string 3))
1085 (nth 3 (assoc ispell-dictionary ispell-dictionary-alist))))
1086(defun ispell-get-many-otherchars-p () 1125(defun ispell-get-many-otherchars-p ()
1087 (nth 4 (assoc ispell-dictionary ispell-dictionary-alist))) 1126 (nth 4 (assoc ispell-dictionary ispell-dictionary-alist)))
1088(defun ispell-get-ispell-args () 1127(defun ispell-get-ispell-args ()
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index fc1ffb329d9..80ff7637365 100644
--- a/lisp/textmodes/org.el
+++ b/lisp/textmodes/org.el
@@ -1,11 +1,11 @@
1;; org.el --- Outline-based notes management and organizer 1;; org.el --- Outline-based notes management and organizer
2 2;; Carstens outline-mode for keeping track of everything.
3;; Copyright (c) 2003, 2004 Free Software Foundation 3;; Copyright (c) 2003, 2004 Free Software Foundation
4 4
5;; Author: Carsten Dominik <dominik at science dot uva dot nl> 5;; Author: Carsten Dominik <dominik at science dot uva dot nl>
6;; Keywords: outlines, hypermedia, calendar 6;; Keywords: outlines, hypermedia, calendar
7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ 7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
8;; Version: 3.03 8;; Version: 3.04
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -23,9 +23,7 @@
23;; along with GNU Emacs; see the file COPYING. If not, write to the 23;; along with GNU Emacs; see the file COPYING. If not, write to the
24;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25;; Boston, MA 02111-1307, USA. 25;; Boston, MA 02111-1307, USA.
26
27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28;; Carsten's outline-mode for keeping track of everything.
29;; 27;;
30;;; Commentary: 28;;; Commentary:
31;; 29;;
@@ -59,6 +57,8 @@
59;; (autoload 'org-diary "org" "Diary entries from Org mode") 57;; (autoload 'org-diary "org" "Diary entries from Org mode")
60;; (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t) 58;; (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t)
61;; (autoload 'org-store-link "org" "Store a link to the current location" t) 59;; (autoload 'org-store-link "org" "Store a link to the current location" t)
60;; (autoload 'orgtbl-mode "org" "Org tables as a minor mode" t)
61;; (autoload 'turn-on-orgtbl "org" "Org tables as a minor mode")
62;; (add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) 62;; (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
63;; (define-key global-map "\C-cl" 'org-store-link) 63;; (define-key global-map "\C-cl" 'org-store-link)
64;; (define-key global-map "\C-ca" 'org-agenda) 64;; (define-key global-map "\C-ca" 'org-agenda)
@@ -79,9 +79,18 @@
79;; 79;;
80;; Changes: 80;; Changes:
81;; ------- 81;; -------
82;; Version 3.04
83;; - Table editor optimized to need fewer realignments, and to keep
84;; table shape when typing in fields.
85;; - A new minor mode, orgtbl-mode, introduces the Org-mode table editor
86;; into arbitrary major modes.
87;; - Fixed bug with realignment in XEmacs.
88;; - Startup options can be set with special #+STARTUP line.
89;; - Heading following a match in org-occur can be suppressed.
90;;
82;; Version 3.03 91;; Version 3.03
83;; - Copyright transfer to the FSF. 92;; - Copyright transfer to the FSF.
84;; - Effect of C-u and C-u C-u in org-timeline interchanged. 93;; - Effect of C-u and C-u C-u in org-timeline swapped.
85;; - Timeline now always contains today, and `.' jumps to it. 94;; - Timeline now always contains today, and `.' jumps to it.
86;; - Table editor: 95;; - Table editor:
87;; - cut and paste of regtangular regions in tables 96;; - cut and paste of regtangular regions in tables
@@ -204,7 +213,7 @@
204 213
205;;; Customization variables 214;;; Customization variables
206 215
207(defvar org-version "3.03" 216(defvar org-version "3.04"
208 "The version number of the file org.el.") 217 "The version number of the file org.el.")
209(defun org-version (arg) 218(defun org-version (arg)
210 (interactive "P") 219 (interactive "P")
@@ -402,11 +411,11 @@ lisp variable `state'."
402 "Matches the SCHEDULED keyword together with a time stamp.") 411 "Matches the SCHEDULED keyword together with a time stamp.")
403(make-variable-buffer-local 'org-scheduled-time-regexp) 412(make-variable-buffer-local 'org-scheduled-time-regexp)
404 413
405(defun org-set-regexps () 414(defun org-set-regexps-and-options ()
406 "Precompute regular expressions for current buffer." 415 "Precompute regular expressions for current buffer."
407 (when (eq major-mode 'org-mode) 416 (when (eq major-mode 'org-mode)
408 (let ((re (org-make-options-regexp 417 (let ((re (org-make-options-regexp
409 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO"))) 418 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP")))
410 (splitre "[ \t]+") 419 (splitre "[ \t]+")
411 kwds int key value cat) 420 kwds int key value cat)
412 (save-restriction 421 (save-restriction
@@ -426,7 +435,17 @@ lisp variable `state'."
426 kwds (append kwds (org-split-string value splitre)))) 435 kwds (append kwds (org-split-string value splitre))))
427 ((equal key "TYP_TODO") 436 ((equal key "TYP_TODO")
428 (setq int 'type 437 (setq int 'type
429 kwds (append kwds (org-split-string value splitre))))) 438 kwds (append kwds (org-split-string value splitre))))
439 ((equal key "STARTUP")
440 (let ((opts (org-split-string value splitre))
441 (set '(("fold" org-startup-folded t)
442 ("nofold" org-startup-folded nil)
443 ("dlcheck" org-startup-with-deadline-check t)
444 ("nodlcheck" org-startup-with-deadline-check nil)))
445 l var val)
446 (while (setq l (assoc (pop opts) set))
447 (setq var (nth 1 l) val (nth 2 l))
448 (set (make-local-variable var) val)))))
430 ))) 449 )))
431 (and cat (set (make-local-variable 'org-category) cat)) 450 (and cat (set (make-local-variable 'org-category) cat))
432 (and kwds (set (make-local-variable 'org-todo-keywords) kwds)) 451 (and kwds (set (make-local-variable 'org-todo-keywords) kwds))
@@ -465,8 +484,6 @@ lisp variable `state'."
465 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")) 484 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>"))
466 (org-set-font-lock-defaults))) 485 (org-set-font-lock-defaults)))
467 486
468;(add-hook 'hack-local-variables-hook 'org-set-regexps)
469
470(defgroup org-time nil 487(defgroup org-time nil
471 "Options concerning time stamps and deadlines in Org-mode." 488 "Options concerning time stamps and deadlines in Org-mode."
472 :tag "Org Time" 489 :tag "Org Time"
@@ -540,7 +557,7 @@ When nil, always start on the current day."
540 :type 'number) 557 :type 'number)
541 558
542(defcustom org-agenda-include-all-todo t 559(defcustom org-agenda-include-all-todo t
543 "Non-nil means, the multifile agenda will always contain alm TODO entries. 560 "Non-nil means, the multifile agenda will always contain all TODO entries.
544When nil, date-less entries will only be shown if `org-agenda' is called 561When nil, date-less entries will only be shown if `org-agenda' is called
545with a prefix argument. 562with a prefix argument.
546When non-nil, the TODO entries will be listed at the top of the agenda, before 563When non-nil, the TODO entries will be listed at the top of the agenda, before
@@ -639,6 +656,18 @@ t Everywhere except in headlines"
639 "Formats for `format-time-string' which are used for time stamps. 656 "Formats for `format-time-string' which are used for time stamps.
640It is not recommended to change this constant.") 657It is not recommended to change this constant.")
641 658
659(defcustom org-show-following-heading t
660 "Non-nil means, show heading following match in `org-occur'.
661When doing an `org-occur' it is useful to show the headline which
662follows the match, even if they do not match the regexp. This makes it
663easier to edit directly inside the sparse tree. However, if you use
664org-occur mainly as an overview, the following headlines are
665unnecessary clutter."
666 :group 'org-structure
667 :type 'boolean)
668
669
670
642(defgroup org-link nil 671(defgroup org-link nil
643 "Options concerning links in Org-mode." 672 "Options concerning links in Org-mode."
644 :tag "Org Link" 673 :tag "Org Link"
@@ -845,11 +874,34 @@ When nil, new notes will be filed to the end of a file or entry."
845 :tag "Org Table" 874 :tag "Org Table"
846 :group 'org) 875 :group 'org)
847 876
848(defcustom org-enable-table-editor t 877(defcustom org-enable-table-editor 'optimized
849 "Non-nil means, lines starting with \"|\" are handled by the table editor. 878 "Non-nil means, lines starting with \"|\" are handled by the table editor.
850When nil, such lines will be treated like ordinary lines." 879When nil, such lines will be treated like ordinary lines.
880
881When equal to the symbol `optimized', the table editor will be optimized to
882do the following
883- Use automatic overwrite mode in front of whitespace in table fields.
884 This make the structure of the table stay in tact as long as the edited
885 field does not exceed the column width.
886- Minimize the number of realigns. Normally, the table is aligned each time
887 TAB or RET are pressed to move to another field. With optimization this
888 happens only if changes to a field might have changed the column width.
889Optimization requires replacing the functions `self-insert-command',
890`delete-char', and `backward-delete-char' in Org-mode buffers, with a
891slight (in fact: unnoticable) speed impact for normal typing. Org-mode is
892very good at guessing when a re-align will be necessary, but you can always
893force one with `C-c C-c'.
894
895I you would like to use the optimized version in Org-mode, but the un-optimized
896version in OrgTbl-mode, see the variable `orgtbl-optimized'.
897
898This variable can be used to turn on and off the table editor during a session,
899but in order to toggle optimization, a restart is required."
851 :group 'org-table 900 :group 'org-table
852 :type 'boolean) 901 :type '(choice
902 (const :tag "off" nil)
903 (const :tag "on" t)
904 (const :tag "on, optimized" optimized)))
853 905
854(defcustom org-table-default-size "5x2" 906(defcustom org-table-default-size "5x2"
855 "The default size for newly created tables, Columns x Rows." 907 "The default size for newly created tables, Columns x Rows."
@@ -1295,6 +1347,8 @@ Otherwise, the buffer will just be saved to a file and stay hidden."
1295(eval-when-compile 1347(eval-when-compile
1296 (defvar zmacs-regions) 1348 (defvar zmacs-regions)
1297 (defvar org-transient-mark-mode) 1349 (defvar org-transient-mark-mode)
1350 (defvar org-old-auto-fill-inhibit-regexp)
1351 (defvar orgtbl-mode-menu)
1298 (defvar org-html-entities) 1352 (defvar org-html-entities)
1299 (defvar org-goto-start-pos) 1353 (defvar org-goto-start-pos)
1300 (defvar org-cursor-color) 1354 (defvar org-cursor-color)
@@ -1351,7 +1405,7 @@ messages (Gnus), BBDB entries, and any files related to the project.
1351For printing and sharing of notes, an Org-mode file (or a part of it) 1405For printing and sharing of notes, an Org-mode file (or a part of it)
1352can be exported as a well-structured ASCII or HTML file. 1406can be exported as a well-structured ASCII or HTML file.
1353 1407
1354+ The following commands are available: 1408The following commands are available:
1355 1409
1356\\{org-mode-map}" 1410\\{org-mode-map}"
1357 (interactive "P") 1411 (interactive "P")
@@ -1363,10 +1417,12 @@ can be exported as a well-structured ASCII or HTML file.
1363 (org-install-agenda-files-menu) 1417 (org-install-agenda-files-menu)
1364 (setq outline-regexp "\\*+") 1418 (setq outline-regexp "\\*+")
1365 (if org-startup-truncated (setq truncate-lines t)) 1419 (if org-startup-truncated (setq truncate-lines t))
1366 (org-set-regexps) 1420 (org-set-regexps-and-options)
1367 (set (make-local-variable 'font-lock-unfontify-region-function) 1421 (set (make-local-variable 'font-lock-unfontify-region-function)
1368 'org-unfontify-region) 1422 'org-unfontify-region)
1369 ;; Activate before-change-function 1423 ;; Activate before-change-function
1424 (set (make-local-variable 'org-table-may-need-update) t)
1425 (make-local-hook 'before-change-functions) ;; needed for XEmacs
1370 (add-hook 'before-change-functions 'org-before-change-function nil 1426 (add-hook 'before-change-functions 'org-before-change-function nil
1371 'local) 1427 'local)
1372 ;; Inhibit auto-fill for headers, tables and fixed-width lines. 1428 ;; Inhibit auto-fill for headers, tables and fixed-width lines.
@@ -1507,7 +1563,7 @@ can be exported as a well-structured ASCII or HTML file.
1507(defvar org-cycle-global-status nil) 1563(defvar org-cycle-global-status nil)
1508(defvar org-cycle-subtree-status nil) 1564(defvar org-cycle-subtree-status nil)
1509(defun org-cycle (&optional arg) 1565(defun org-cycle (&optional arg)
1510 "Visibility cycling for outline(-minor)-mode. 1566 "Visibility cycling for org-mode.
1511 1567
1512- When this function is called with a prefix argument, rotate the entire 1568- When this function is called with a prefix argument, rotate the entire
1513 buffer through 3 states (global cycling) 1569 buffer through 3 states (global cycling)
@@ -1540,7 +1596,9 @@ can be exported as a well-structured ASCII or HTML file.
1540 ((org-at-table-p 'any) 1596 ((org-at-table-p 'any)
1541 ;; Enter the table or move to the next field in the table 1597 ;; Enter the table or move to the next field in the table
1542 (or (org-table-recognize-table.el) 1598 (or (org-table-recognize-table.el)
1543 (org-table-next-field))) 1599 (progn
1600 (org-table-justify-field-maybe)
1601 (org-table-next-field))))
1544 1602
1545 (arg ;; Global cycling 1603 (arg ;; Global cycling
1546 1604
@@ -1765,9 +1823,9 @@ or nil."
1765(defvar org-ignore-region nil 1823(defvar org-ignore-region nil
1766 "To temporary disable the active region.") 1824 "To temporary disable the active region.")
1767 1825
1768(defun org-insert-heading () 1826(defun org-insert-heading (arg)
1769 "Insert a new heading with same depth at point." 1827 "Insert a new heading with same depth at point."
1770 (interactive) 1828 (interactive "P")
1771 (let* ((head (save-excursion 1829 (let* ((head (save-excursion
1772 (condition-case nil 1830 (condition-case nil
1773 (org-back-to-heading) 1831 (org-back-to-heading)
@@ -2271,14 +2329,14 @@ that the match should indeed be shown."
2271 (message "%d match(es) for regexp %s" cnt regexp)) 2329 (message "%d match(es) for regexp %s" cnt regexp))
2272 cnt)) 2330 cnt))
2273 2331
2274
2275(defun org-show-hierarchy-above () 2332(defun org-show-hierarchy-above ()
2276 "Make sure point and the headings hierarchy above is visible." 2333 "Make sure point and the headings hierarchy above is visible."
2277 (if (org-on-heading-p t) 2334 (if (org-on-heading-p t)
2278 (org-flag-heading nil) ; only show the heading 2335 (org-flag-heading nil) ; only show the heading
2279 (org-show-hidden-entry)) ; show entire entry 2336 (org-show-hidden-entry)) ; show entire entry
2280 (save-excursion 2337 (save-excursion
2281 (and (outline-next-heading) 2338 (and org-show-following-heading
2339 (outline-next-heading)
2282 (org-flag-heading nil))) ; show the next heading 2340 (org-flag-heading nil))) ; show the next heading
2283 (save-excursion ; show all higher headings 2341 (save-excursion ; show all higher headings
2284 (while (condition-case nil 2342 (while (condition-case nil
@@ -2361,7 +2419,7 @@ Otherwise, only the date will be included. All parts of a date not
2361specified by the user will be filled in from the current date/time. 2419specified by the user will be filled in from the current date/time.
2362So if you press just return without typing anything, the time stamp 2420So if you press just return without typing anything, the time stamp
2363will represent the current date/time. If there is already a timestamp 2421will represent the current date/time. If there is already a timestamp
2364at the cursoe, it will be modified." 2422at the cursor, it will be modified."
2365 (interactive "P") 2423 (interactive "P")
2366 (let ((fmt (if arg (cdr org-time-stamp-formats) 2424 (let ((fmt (if arg (cdr org-time-stamp-formats)
2367 (car org-time-stamp-formats))) 2425 (car org-time-stamp-formats)))
@@ -2798,7 +2856,11 @@ If there is already a time stamp at the cursor position, update it."
2798 2856
2799;;;###autoload 2857;;;###autoload
2800(defun org-agenda-mode () 2858(defun org-agenda-mode ()
2801 "Mode for time-sorted view on action items in Org-mode files." 2859 "Mode for time-sorted view on action items in Org-mode files.
2860
2861The following commands are available:
2862
2863\\{org-agenda-mode-map}"
2802 (interactive) 2864 (interactive)
2803 (kill-all-local-variables) 2865 (kill-all-local-variables)
2804 (setq major-mode 'org-agenda-mode) 2866 (setq major-mode 'org-agenda-mode)
@@ -3118,7 +3180,7 @@ NDAYS defaults to `org-agenda-ndays'."
3118(defun org-check-agenda-file (file) 3180(defun org-check-agenda-file (file)
3119 "Make sure FILE exists. If not, ask user what to do." 3181 "Make sure FILE exists. If not, ask user what to do."
3120 ;; FIXME: this does not correctly change the menus 3182 ;; FIXME: this does not correctly change the menus
3121 ;; Could be fixed by explicitly going to the buffer, maybe. 3183 ;; Could probably be fixed by explicitly going to the buffer.
3122 (when (not (file-exists-p file)) 3184 (when (not (file-exists-p file))
3123 (message "non-existent file %s. [R]emove from agenda-files or [A]bort?" 3185 (message "non-existent file %s. [R]emove from agenda-files or [A]bort?"
3124 file) 3186 file)
@@ -4507,7 +4569,6 @@ RET at beg-of-buf -> Append to file as level 2 headline
4507RET on headline -> Store as sublevel entry to current headline 4569RET on headline -> Store as sublevel entry to current headline
4508<left>/<right> -> before/after current headline, same headings level") 4570<left>/<right> -> before/after current headline, same headings level")
4509 4571
4510;; FIXME: Document C-u C-c C-c
4511;;;###autoload 4572;;;###autoload
4512(defun org-remember-handler () 4573(defun org-remember-handler ()
4513 "Store stuff from remember.el into an org file. 4574 "Store stuff from remember.el into an org file.
@@ -4796,6 +4857,21 @@ Such a file can be imported into a spreadsheet program like Excel."
4796 (save-buffer)) 4857 (save-buffer))
4797 (kill-buffer buf))) 4858 (kill-buffer buf)))
4798 4859
4860(defvar org-table-aligned-begin-marker (make-marker)
4861 "Marker at the beginning of the table last aligned.
4862Used to check if cursor still is in that table, to minimize realignment.")
4863(defvar org-table-aligned-end-marker (make-marker)
4864 "Marker at the end of the table last aligned.
4865Used to check if cursor still is in that table, to minimize realignment.")
4866(defvar org-table-last-alignment nil
4867 "List of flags for flushright alignment, from the last re-algnment.
4868This is being used to correctly align a single field after TAB or RET.")
4869;; FIXME: The following is currently not used.
4870(defvar org-table-last-column-widths nil
4871 "List of max width of ffields in each column.
4872This is being used to correctly align a single field after TAB or RET.")
4873
4874
4799(defun org-table-align (&optional arg) 4875(defun org-table-align (&optional arg)
4800 "Align the table at point by aligning all vertical bars." 4876 "Align the table at point by aligning all vertical bars."
4801 (interactive "P") 4877 (interactive "P")
@@ -4866,6 +4942,8 @@ Such a file can be imported into a spreadsheet program like Excel."
4866 (push (>= frac org-table-number-fraction) typenums)) 4942 (push (>= frac org-table-number-fraction) typenums))
4867 (setq lengths (nreverse lengths) 4943 (setq lengths (nreverse lengths)
4868 typenums (nreverse typenums)) 4944 typenums (nreverse typenums))
4945 (setq org-table-last-alignment typenums
4946 org-table-last-column-widths lengths)
4869 ;; Compute the formats needed for output of the table 4947 ;; Compute the formats needed for output of the table
4870 (setq rfmt (concat indent "|") hfmt (concat indent "|")) 4948 (setq rfmt (concat indent "|") hfmt (concat indent "|"))
4871 (while (setq l (pop lengths)) 4949 (while (setq l (pop lengths))
@@ -4884,13 +4962,14 @@ Such a file can be imported into a spreadsheet program like Excel."
4884 ;; Replace the old one 4962 ;; Replace the old one
4885 (delete-region beg end) 4963 (delete-region beg end)
4886 (move-marker end nil) 4964 (move-marker end nil)
4965 (move-marker org-table-aligned-begin-marker (point))
4887 (insert new) 4966 (insert new)
4967 (move-marker org-table-aligned-end-marker (point))
4888 ;; Try to move to the old location (approximately) 4968 ;; Try to move to the old location (approximately)
4889 (goto-line linepos) 4969 (goto-line linepos)
4890 (set-window-start (selected-window) winstart 'noforce) 4970 (set-window-start (selected-window) winstart 'noforce)
4891 (org-table-goto-column colpos) 4971 (org-table-goto-column colpos)
4892 (setq org-table-may-need-update nil) 4972 (setq org-table-may-need-update nil)
4893 ;; (message "Aligning table...done")
4894 (if (org-in-invisibility-spec-p '(org-table)) 4973 (if (org-in-invisibility-spec-p '(org-table))
4895 (org-table-add-invisible-to-vertical-lines)) 4974 (org-table-add-invisible-to-vertical-lines))
4896 )) 4975 ))
@@ -4920,6 +4999,35 @@ With argument TABLE-TYPE, go to the end of a table.el-type table."
4920 (goto-char (match-beginning 0))) 4999 (goto-char (match-beginning 0)))
4921 (point-marker))) 5000 (point-marker)))
4922 5001
5002(defun org-table-justify-field-maybe ()
5003 "Justify the current field, text to left, number to right."
5004 (cond
5005 (org-table-may-need-update) ; Realignment will happen anyway, don't bother
5006 ((org-at-table-hline-p)
5007 ;; This is pretty stupid, but I don't know how to deal with hlines
5008 (setq org-table-may-need-update t))
5009 ((or (not (equal (marker-buffer org-table-aligned-begin-marker)
5010 (current-buffer)))
5011 (< (point) org-table-aligned-begin-marker)
5012 (>= (point) org-table-aligned-end-marker))
5013 ;; This is not the same table, force a full re-align
5014 (setq org-table-may-need-update t))
5015 (t ;; realign the current field, based on previous full realign
5016 (let* ((pos (point)) s org-table-may-need-update
5017 (col (org-table-current-column))
5018 (num (nth (1- col) org-table-last-alignment))
5019 l f)
5020 (when (> col 0)
5021 (skip-chars-backward "^|\n")
5022 (if (looking-at " *\\([^|\n]*?\\) *|")
5023 (progn
5024 (setq s (match-string 1)
5025 l (max 1 (- (match-end 0) (match-beginning 0) 3)))
5026 (setq f (format (if num " %%%ds |" " %%-%ds |") l))
5027 (replace-match (format f s t t)))
5028 (setq org-table-may-need-update t))
5029 (goto-char pos))))))
5030
4923(defun org-table-next-field (&optional arg) 5031(defun org-table-next-field (&optional arg)
4924 "Go to the next field in the current table. 5032 "Go to the next field in the current table.
4925Before doing so, re-align the table if necessary." 5033Before doing so, re-align the table if necessary."
@@ -5013,18 +5121,21 @@ I.e. not on a hline or before the first or after the last column?"
5013 (error "Not in table data field"))) 5121 (error "Not in table data field")))
5014 5122
5015(defun org-table-blank-field () 5123(defun org-table-blank-field ()
5016 "Blank the current table field." 5124 "Blank the current table field or active region."
5017 (interactive) 5125 (interactive)
5018 (org-table-check-inside-data-field) 5126 (org-table-check-inside-data-field)
5019 (skip-chars-backward "^|") 5127 (if (and (interactive-p) (org-region-active-p))
5020 (backward-char 1) 5128 (let (org-table-clip)
5021 (if (looking-at "|[^|]+") 5129 (org-table-cut-region))
5022 (let* ((pos (match-beginning 0)) 5130 (skip-chars-backward "^|")
5023 (match (match-string 0)) 5131 (backward-char 1)
5024 (len (length match))) 5132 (if (looking-at "|[^|]+")
5025 (replace-match (concat "|" (make-string (1- len) ?\ ))) 5133 (let* ((pos (match-beginning 0))
5026 (goto-char (+ 2 pos)) 5134 (match (match-string 0))
5027 (substring match 1)))) 5135 (len (length match)))
5136 (replace-match (concat "|" (make-string (1- len) ?\ )))
5137 (goto-char (+ 2 pos))
5138 (substring match 1)))))
5028 5139
5029(defun org-table-get-field (&optional n replace) 5140(defun org-table-get-field (&optional n replace)
5030 "Return the value of the field in column N of current row. 5141 "Return the value of the field in column N of current row.
@@ -5199,6 +5310,15 @@ However, when FORCE is non-nil, create new columns if necessary."
5199 (org-table-goto-column colpos)) 5310 (org-table-goto-column colpos))
5200 (org-table-align)) 5311 (org-table-align))
5201 5312
5313(defun org-table-move-column-right ()
5314 "Move column to the right."
5315 (interactive)
5316 (org-table-move-column nil))
5317(defun org-table-move-column-left ()
5318 "Move column to the left."
5319 (interactive)
5320 (org-table-move-column 'left))
5321
5202(defun org-table-move-column (&optional left) 5322(defun org-table-move-column (&optional left)
5203 "Move the current column to the right. With arg LEFT, move to the left." 5323 "Move the current column to the right. With arg LEFT, move to the left."
5204 (interactive "P") 5324 (interactive "P")
@@ -5230,6 +5350,15 @@ However, when FORCE is non-nil, create new columns if necessary."
5230 (org-table-goto-column colpos)) 5350 (org-table-goto-column colpos))
5231 (org-table-align)) 5351 (org-table-align))
5232 5352
5353(defun org-table-move-row-down ()
5354 "Move table row down."
5355 (interactive)
5356 (org-table-move-row nil))
5357(defun org-table-move-row-up ()
5358 "Move table row down."
5359 (interactive)
5360 (org-table-move-row 'up))
5361
5233(defun org-table-move-row (&optional up) 5362(defun org-table-move-row (&optional up)
5234 "Move the current table line down. With arg UP, move it up." 5363 "Move the current table line down. With arg UP, move it up."
5235 (interactive "P") 5364 (interactive "P")
@@ -5263,11 +5392,12 @@ With prefix ARG, insert below the current line."
5263 (setq line (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) line)) 5392 (setq line (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) line))
5264 (setq line (mapcar (lambda (x) (if (equal x ?|) ?| ?\ )) line))) 5393 (setq line (mapcar (lambda (x) (if (equal x ?|) ?| ?\ )) line)))
5265 (beginning-of-line (if arg 2 1)) 5394 (beginning-of-line (if arg 2 1))
5266 (apply 'insert line) 5395 (let (org-table-may-need-update)
5267 (insert "\n") 5396 (apply 'insert-before-markers line)
5397 (insert-before-markers "\n"))
5268 (beginning-of-line 0) 5398 (beginning-of-line 0)
5269 (re-search-forward "| ?" (point-at-eol) t) 5399 (re-search-forward "| ?" (point-at-eol) t)
5270 (org-table-align))) 5400 (and org-table-may-need-update (org-table-align))))
5271 5401
5272(defun org-table-insert-hline (&optional arg) 5402(defun org-table-insert-hline (&optional arg)
5273 "Insert a horizontal-line below the current line into the table. 5403 "Insert a horizontal-line below the current line into the table.
@@ -5788,6 +5918,271 @@ separator line)."
5788 (setq ndown 0))) 5918 (setq ndown 0)))
5789 (org-table-align))) 5919 (org-table-align)))
5790 5920
5921;;; The orgtbl minor mode
5922
5923;; Define a minor mode which can be used in other modes in order to
5924;; integrate the org-mode table editor.
5925
5926;; This is really a hack, because the org-mode table editor uses several
5927;; keys which normally belong to the major mode, for example the TAB and
5928;; RET keys. Here is how it works: The minor mode defines all the keys
5929;; necessary to operate the table editor, but wraps the commands into a
5930;; function which tests if the cursor is currently inside a table. If that
5931;; is the case, the table editor command is executed. However, when any of
5932;; those keys is used outside a table, the function uses `key-binding' to
5933;; look up if the key has an associated command in another currently active
5934;; keymap (minor modes, major mode, global), and executes that command.
5935;; There might be problems if any of the keys used by the table editor is
5936;; otherwise used as a prefix key.
5937
5938;; Another challenge is that the key binding for TAB can be tab or \C-i,
5939;; likewise the binding for RET can be return or \C-m. Orgtbl-mode
5940;; addresses this by checking explicitly for both bindings.
5941
5942;; The optimized version (see variable `orgtbl-optimized') takes over
5943;; all keys which are bound to `self-insert-command' in the *global map*.
5944;; Some modes bind other commands to simple characters, for example
5945;; AUCTeX binds the double quote to `Tex-insert-quote'. With orgtbl-mode
5946;; active, this binding is ignored inside tables and replaced with a
5947;; modified self-insert.
5948
5949(defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
5950 "Non-nil means, use the optimized table editor version for orgtbl-mode.
5951In the optimized version, the table editor takes over all simple keys that
5952normally just insert a character. In tables, the characters are inserted
5953in a way to minimize disturbing the table structure (i.e. in overwrite mode
5954for empty fields). Outside tables, the correct binding of the keys is
5955restored.
5956
5957The default for this option is t if the optimized version is also used in
5958Org-mode. See the variable `org-enable-table-editor' for details. Changing
5959this variable requires a restart of Emacs to become effective."
5960 :group 'org-table
5961 :type 'boolean)
5962
5963(defvar orgtbl-mode nil
5964 "Variable controlling orgtbl-mode, a minor mode enabling the org-mode
5965table editor iin arbitrary modes.")
5966(make-variable-buffer-local 'orgtbl-mode)
5967
5968(defvar orgtbl-mode-map (make-sparse-keymap)
5969 "Keymap for orgtbl-mode.")
5970
5971;;;###autoload
5972(defun turn-on-orgtbl ()
5973 "Unconditionally turn on orgtbl-mode."
5974 (orgtbl-mode 1))
5975
5976;;;###autoload
5977(defun orgtbl-mode (&optional arg)
5978 "The org-mode table editor as a minor mode for use in other modes."
5979 (interactive)
5980 (setq orgtbl-mode
5981 (if arg (> (prefix-numeric-value arg) 0) (not orgtbl-mode)))
5982 (if orgtbl-mode
5983 (progn
5984 (set (make-local-variable (quote org-table-may-need-update)) t)
5985 (make-local-hook (quote before-change-functions))
5986 (add-hook 'before-change-functions 'org-before-change-function
5987 nil 'local)
5988 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp)
5989 auto-fill-inhibit-regexp)
5990 (set (make-local-variable 'auto-fill-inhibit-regexp)
5991 (if auto-fill-inhibit-regexp
5992 (concat "\\([ \t]*|\\|" auto-fill-inhibit-regexp)
5993 "[ \t]*|"))
5994 (easy-menu-add orgtbl-mode-menu)
5995 (run-hooks (quote orgtbl-mode-hook)))
5996 (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp)
5997 (remove-hook 'before-change-functions 'org-before-change-function t)
5998 (easy-menu-remove orgtbl-mode-menu)
5999 (force-mode-line-update 'all)))
6000
6001;; Install it as a minor mode.
6002(put 'orgtbl-mode :included t)
6003(put 'orgtbl-mode :menu-tag "Org Table Mode")
6004(add-minor-mode 'orgtbl-mode " OrgTbl" orgtbl-mode-map)
6005
6006(defun orgtbl-make-binding (fun &rest keys)
6007 "Create a function for binding in the table minor mode."
6008 (list 'lambda '(arg) '(interactive "p")
6009 (list 'if
6010 '(org-at-table-p)
6011 (list 'call-interactively (list 'quote fun))
6012 (list 'let '(orgtbl-mode)
6013 (list 'call-interactively
6014 (append '(or)
6015 (mapcar (lambda (k)
6016 (list 'key-binding k))
6017 keys)
6018 '('orgtbl-error)))))))
6019
6020(defun orgtbl-error ()
6021 "Error when there is no default binding for a table key."
6022 (interactive)
6023 (error "This key is has no function outside tables"))
6024
6025;; Keybindings for the minor mode
6026(let ((bindings
6027 '(([(meta shift left)] org-table-delete-column)
6028 ([(meta left)] org-table-move-column-left)
6029 ([(meta right)] org-table-move-column-right)
6030 ([(meta shift right)] org-table-insert-column)
6031 ([(meta shift up)] org-table-kill-row)
6032 ([(meta shift down)] org-table-insert-row)
6033 ([(meta up)] org-table-move-row-up)
6034 ([(meta down)] org-table-move-row-down)
6035 ("\C-c\C-w" org-table-cut-region)
6036 ("\C-c\M-w" org-table-copy-region)
6037 ("\C-c\C-y" org-table-paste-rectangle)
6038 ("\C-c-" org-table-insert-hline)
6039 ([(shift tab)] org-table-previous-field)
6040 ("\C-c\C-c" org-table-align)
6041 ([(return)] org-table-next-row)
6042 ([(shift return)] org-table-copy-from-above)
6043 ([(meta return)] org-table-wrap-region)
6044 ("\C-c\C-q" org-table-wrap-region)
6045 ("\C-c?" org-table-current-column)
6046 ("\C-c " org-table-blank-field)
6047 ("\C-c+" org-table-sum)
6048 ("\C-c|" org-table-toggle-vline-visibility)
6049 ("\C-c=" org-table-eval-formula)))
6050 elt key fun cmd)
6051 (while (setq elt (pop bindings))
6052 (setq key (car elt)
6053 fun (nth 1 elt)
6054 cmd (orgtbl-make-binding fun key))
6055 (define-key orgtbl-mode-map key cmd)))
6056
6057;; Special treatment needed for TAB and RET
6058;(define-key orgtbl-mode-map [(return)]
6059; (orgtbl-make-binding 'org-table-next-row [(return)] "\C-m"))
6060;(define-key orgtbl-mode-map "\C-m"
6061; (orgtbl-make-binding 'org-table-next-row "\C-m" [(return)]))
6062;(define-key orgtbl-mode-map [(tab)]
6063; (orgtbl-make-binding 'org-table-next-field [(tab)] "\C-i"))
6064;(define-key orgtbl-mode-map "\C-i"
6065; (orgtbl-make-binding 'org-table-next-field "\C-i" [(tab)]))
6066
6067(define-key orgtbl-mode-map [(return)]
6068 (orgtbl-make-binding 'orgtbl-ret [(return)] "\C-m"))
6069(define-key orgtbl-mode-map "\C-m"
6070 (orgtbl-make-binding 'orgtbl-ret "\C-m" [(return)]))
6071(define-key orgtbl-mode-map [(tab)]
6072 (orgtbl-make-binding 'orgtbl-tab [(tab)] "\C-i"))
6073(define-key orgtbl-mode-map "\C-i"
6074 (orgtbl-make-binding 'orgtbl-tab "\C-i" [(tab)]))
6075
6076(when orgtbl-optimized
6077 ;; If the user wants maximum table support, we need to hijack
6078 ;; some standard editing functions
6079 (substitute-key-definition 'self-insert-command 'orgtbl-self-insert-command
6080 orgtbl-mode-map global-map)
6081 (substitute-key-definition 'delete-char 'orgtbl-delete-char
6082 orgtbl-mode-map global-map)
6083 (substitute-key-definition 'delete-backward-char 'orgtbl-delete-backward-char
6084 orgtbl-mode-map global-map)
6085 (define-key org-mode-map "|" 'self-insert-command))
6086
6087(defun orgtbl-tab ()
6088 "Justification and field motion for orgtbl-mode."
6089 (interactive)
6090 (org-table-justify-field-maybe)
6091 (org-table-next-field))
6092
6093(defun orgtbl-ret ()
6094 "Justification and field motion for orgtbl-mode."
6095 (interactive)
6096 (org-table-justify-field-maybe)
6097 (org-table-next-row))
6098
6099(defun orgtbl-self-insert-command (N)
6100 "Like `self-insert-command', use overwrite-mode for whitespace in tables.
6101If the cursor is in a table looking at whitespace, the whitespace is
6102overwritten, and the table is not marked as requiring realignment."
6103 (interactive "p")
6104 (if (and (org-at-table-p)
6105 (eq N 1)
6106 (looking-at "[^|\n]* +|"))
6107 (let (org-table-may-need-update (pos (point)))
6108 (goto-char (1- (match-end 0)))
6109 (delete-backward-char 1)
6110 (goto-char (match-beginning 0))
6111 (self-insert-command N))
6112 (setq org-table-may-need-update t)
6113 (let (orgtbl-mode)
6114 (call-interactively (key-binding (vector last-input-event))))))
6115
6116(defun orgtbl-delete-backward-char (N)
6117 "Like `delete-backward-char', insert whitespace at field end in tables.
6118When deleting backwards, in tables this function will insert whitespace in
6119front of the next \"|\" separator, to keep the table aligned. The table will
6120still be marked for re-alignment, because a narrow field may lead to a
6121reduced column width."
6122 (interactive "p")
6123 (if (and (org-at-table-p)
6124 (eq N 1)
6125 (looking-at ".*?|"))
6126 (let ((pos (point)))
6127 (backward-delete-char N)
6128 (skip-chars-forward "^|")
6129 (insert " ")
6130 (goto-char (1- pos)))
6131 (message "%s" last-input-event) (sit-for 1)
6132 (delete-backward-char N)))
6133
6134(defun orgtbl-delete-char (N)
6135 "Like `delete-char', but insert whitespace at field end in tables.
6136When deleting characters, in tables this function will insert whitespace in
6137front of the next \"|\" separator, to keep the table aligned. The table
6138will still be marked for re-alignment, because a narrow field may lead to
6139a reduced column width."
6140 (interactive "p")
6141 (if (and (org-at-table-p)
6142 (eq N 1))
6143 (if (looking-at ".*?|")
6144 (let ((pos (point)))
6145 (replace-match (concat
6146 (substring (match-string 0) 1 -1)
6147 " |"))
6148 (goto-char pos)))
6149 (delete-char N)))
6150
6151(easy-menu-define orgtbl-mode-menu orgtbl-mode-map "OrgTbl menu"
6152 '("Tbl"
6153 ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p) :keys "C-c C-c"]
6154 ["Next field" org-cycle :active (org-at-table-p) :keys "TAB"]
6155 ["Previous Field" org-shifttab :active (org-at-table-p) :keys "S-TAB"]
6156 ["Next row" org-return :active (org-at-table-p) :keys "RET"]
6157 "--"
6158 ["Blank field" org-table-blank-field :active (org-at-table-p) :keys "C-c SPC"]
6159 ["Copy field from above"
6160 org-table-copy-from-above :active (org-at-table-p) :keys "S-RET"]
6161 "--"
6162 ("Column"
6163 ["Move column left" org-metaleft :active (org-at-table-p) :keys "M-<left>"]
6164 ["Move column right" org-metaright :active (org-at-table-p) :keys "M-<right>"]
6165 ["Delete column" org-shiftmetaleft :active (org-at-table-p) :keys "M-S-<left>"]
6166 ["Insert column" org-shiftmetaright :active (org-at-table-p) :keys "M-S-<right>"])
6167 ("Row"
6168 ["Move row up" org-metaup :active (org-at-table-p) :keys "M-<up>"]
6169 ["Move row down" org-metadown :active (org-at-table-p) :keys "M-<down>"]
6170 ["Delete row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"]
6171 ["Insert row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"]
6172 "--"
6173 ["Insert hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"])
6174 ("Rectangle"
6175 ["Copy rectangle" org-copy-special :active (org-at-table-p) :keys "C-c M-w"]
6176 ["Cut rectangle" org-cut-special :active (org-at-table-p) :keys "C-c C-w"]
6177 ["Paste rectangle" org-paste-special :active (org-at-table-p) :keys "C-c C-y"]
6178 ["Fill rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"])
6179 "--"
6180 ["Which column?" org-table-current-column :active (org-at-table-p) :keys "C-c ?"]
6181 ["Sum column/rectangle" org-table-sum
6182 :active (or (org-at-table-p) (org-region-active-p)) :keys "C-c +"]
6183 ["Eval formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="]
6184 ))
6185
5791;;; Exporting 6186;;; Exporting
5792 6187
5793(defconst org-level-max 20) 6188(defconst org-level-max 20)
@@ -6300,6 +6695,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
6300#+CATEGORY: %s 6695#+CATEGORY: %s
6301#+SEQ_TODO: %s 6696#+SEQ_TODO: %s
6302#+TYP_TODO: %s 6697#+TYP_TODO: %s
6698#+STARTUP: %s %s
6303" 6699"
6304 (buffer-name) (user-full-name) user-mail-address org-export-default-language 6700 (buffer-name) (user-full-name) user-mail-address org-export-default-language
6305 org-export-headline-levels 6701 org-export-headline-levels
@@ -6318,7 +6714,10 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
6318 "TODO FEEDBACK VERIFY DONE") 6714 "TODO FEEDBACK VERIFY DONE")
6319 (if (equal org-todo-interpretation 'type) 6715 (if (equal org-todo-interpretation 'type)
6320 (mapconcat 'identity org-todo-keywords " ") 6716 (mapconcat 'identity org-todo-keywords " ")
6321 "Me Jason Marie DONE"))) 6717 "Me Jason Marie DONE")
6718 (if org-startup-folded "fold" "nofold")
6719 (if org-startup-with-deadline-check "dlcheck" "nodlcheck")
6720 ))
6322 6721
6323(defun org-insert-export-options-template () 6722(defun org-insert-export-options-template ()
6324 "Insert into the buffer a template with information for exporting." 6723 "Insert into the buffer a template with information for exporting."
@@ -7025,6 +7424,7 @@ When LEVEL is non-nil, increase section numbers on that level."
7025(define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) 7424(define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c)
7026(define-key org-mode-map [(return)] 'org-return) 7425(define-key org-mode-map [(return)] 'org-return)
7027(define-key org-mode-map [(shift return)] 'org-table-copy-from-above) 7426(define-key org-mode-map [(shift return)] 'org-table-copy-from-above)
7427(define-key org-mode-map [(meta return)] 'org-meta-return)
7028(define-key org-mode-map [(control up)] 'org-move-line-up) 7428(define-key org-mode-map [(control up)] 'org-move-line-up)
7029(define-key org-mode-map [(control down)] 'org-move-line-down) 7429(define-key org-mode-map [(control down)] 'org-move-line-down)
7030(define-key org-mode-map "\C-c?" 'org-table-current-column) 7430(define-key org-mode-map "\C-c?" 'org-table-current-column)
@@ -7041,6 +7441,105 @@ When LEVEL is non-nil, increase section numbers on that level."
7041(define-key org-mode-map "\C-c\C-xh" 'org-export-as-html) 7441(define-key org-mode-map "\C-c\C-xh" 'org-export-as-html)
7042(define-key org-mode-map "\C-c\C-x\C-h" 'org-export-as-html-and-open) 7442(define-key org-mode-map "\C-c\C-x\C-h" 'org-export-as-html-and-open)
7043 7443
7444
7445;; FIXME: Do we really need to save match data in these commands?
7446;; I would like to remove it in order to minimize impact.
7447;; Self-insert already does not preserve it. How much resources does this take???
7448
7449(defsubst org-table-p ()
7450 (if (and (eq major-mode 'org-mode) font-lock-mode)
7451 (eq (get-text-property (point) 'face) 'org-table-face)
7452 (save-match-data (org-at-table-p))))
7453
7454(defun org-self-insert-command (N)
7455 "Like `self-insert-command', use overwrite-mode for whitespace in tables.
7456If the cursor is in a table looking at whitespace, the whitespace is
7457overwritten, and the table is not marked as requiring realignment."
7458 (interactive "p")
7459 (if (and (org-table-p)
7460 (eq N 1)
7461 (looking-at "[^|\n]* +|"))
7462 (let (org-table-may-need-update (pos (point)))
7463 (goto-char (1- (match-end 0)))
7464 (delete-backward-char 1)
7465 (goto-char (match-beginning 0))
7466 (self-insert-command N))
7467 (setq org-table-may-need-update t)
7468 (self-insert-command N)))
7469
7470;; FIXME:
7471;; The following two functions might still be optimized to trigger
7472;; re-alignment less frequently. Right now they raise the flag each time
7473;; (through before-change-functions). Here is how this could be minimized:
7474;; Basically, check if the non-white field width before deletion is
7475;; equal to the column width. If yes, the delete should trigger a
7476;; re-align. I have not implemented this so far because it is not so
7477;; easy, requires grabbing the field etc. So it may finally have some
7478;; impact on typing performance which we don't want.
7479
7480;; The defsubst is only a draft, untested...
7481
7482;; Maybe it is not so important to get rid of realigns - maybe the most
7483;; important aspect is to keep the table look noce as long as possible,
7484;; which is already achieved...
7485
7486;(defsubst org-check-delete-triggers-realign ()
7487; (let ((pos (point)))
7488; (skip-chars-backward "^|\n")
7489; (and (looking-at " *\\(.*?\\) *|")
7490; (= (nth (1- (org-table-current-column))
7491; org-table-last-column-widths)
7492; (- (match-end 1) (match-beginning 1)))
7493; (setq org-table-may-need-update t))))
7494
7495(defun org-delete-backward-char (N)
7496 "Like `delete-backward-char', insert whitespace at field end in tables.
7497When deleting backwards, in tables this function will insert whitespace in
7498front of the next \"|\" separator, to keep the table aligned. The table will
7499still be marked for re-alignment, because a narrow field may lead to a
7500reduced column width."
7501 (interactive "p")
7502 (if (and (org-table-p)
7503 (eq N 1)
7504 (looking-at ".*?|"))
7505 (let ((pos (point)))
7506 (backward-delete-char N)
7507 (skip-chars-forward "^|")
7508 (insert " ")
7509 (goto-char (1- pos)))
7510 (backward-delete-char N)))
7511
7512(defun org-delete-char (N)
7513 "Like `delete-char', but insert whitespace at field end in tables.
7514When deleting characters, in tables this function will insert whitespace in
7515front of the next \"|\" separator, to keep the table aligned. The table
7516will still be marked for re-alignment, because a narrow field may lead to
7517a reduced column width."
7518 (interactive "p")
7519 (if (and (org-table-p)
7520 (eq N 1))
7521 (if (looking-at ".*?|")
7522 (let ((pos (point)))
7523 (replace-match (concat
7524 (substring (match-string 0) 1 -1)
7525 " |"))
7526 (goto-char pos)))
7527 (delete-char N)))
7528
7529;; How to do this: Measure non-white length of current string
7530;; If equal to column width, we should realign.
7531
7532(when (eq org-enable-table-editor 'optimized)
7533 ;; If the user wants maximum table support, we need to hijack
7534 ;; some standard editing functions
7535 (substitute-key-definition 'self-insert-command 'org-self-insert-command
7536 org-mode-map global-map)
7537 (substitute-key-definition 'delete-char 'org-delete-char
7538 org-mode-map global-map)
7539 (substitute-key-definition 'delete-backward-char 'org-delete-backward-char
7540 org-mode-map global-map)
7541 (define-key org-mode-map "|" 'self-insert-command))
7542
7044(defun org-shiftcursor-error () 7543(defun org-shiftcursor-error ()
7045 "Throw an error because Shift-Cursor command was applied in wrong context." 7544 "Throw an error because Shift-Cursor command was applied in wrong context."
7046 (error "This command is only active in tables and on headlines.")) 7545 (error "This command is only active in tables and on headlines."))
@@ -7173,9 +7672,18 @@ the automatic table editor has been turned off."
7173 "Call `org-table-next-row' or `newline'." 7672 "Call `org-table-next-row' or `newline'."
7174 (interactive "P") 7673 (interactive "P")
7175 (cond 7674 (cond
7176 ((org-at-table-p) (org-table-next-row)) 7675 ((org-at-table-p)
7676 (org-table-justify-field-maybe)
7677 (org-table-next-row))
7177 (t (newline)))) 7678 (t (newline))))
7178 7679
7680(defun org-meta-return (&optional arg)
7681 "Call `org-insert-heading' or `org-table-wrap-region'."
7682 (interactive "P")
7683 (cond
7684 ((org-at-table-p)
7685 (org-table-wrap-region arg))
7686 (t (org-insert-heading arg))))
7179 7687
7180;;; Menu entries 7688;;; Menu entries
7181 7689
@@ -7245,7 +7753,7 @@ the automatic table editor has been turned off."
7245 ["Check Deadlines this file" org-check-deadlines t] 7753 ["Check Deadlines this file" org-check-deadlines t]
7246 ["Timeline current file" org-timeline t] 7754 ["Timeline current file" org-timeline t]
7247 "--" 7755 "--"
7248 ["Adenda (multifile)" org-agenda-overview t]) 7756 ["Adenda (multifile)" org-agenda t])
7249 ("File List for Agenda") 7757 ("File List for Agenda")
7250 "--" 7758 "--"
7251 ("Hyperlinks" 7759 ("Hyperlinks"
@@ -7586,6 +8094,7 @@ When ENTRY is non-nil, show the entire entry."
7586 8094
7587(run-hooks 'org-load-hook) 8095(run-hooks 'org-load-hook)
7588 8096
8097;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
8098
7589;;; org.el ends here 8099;;; org.el ends here
7590 8100
7591;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el
index 534e4e7b27b..93cd0757b4e 100644
--- a/lisp/textmodes/reftex-auc.el
+++ b/lisp/textmodes/reftex-auc.el
@@ -1,8 +1,8 @@
1;;; reftex-auc.el --- RefTeX's interface to AUCTeX 1;;; reftex-auc.el --- RefTeX's interface to AUCTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index e25464c798d..6369f9637db 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -1,8 +1,8 @@
1;;; reftex-cite.el --- creating citations with RefTeX 1;;; reftex-cite.el --- creating citations with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -49,11 +49,11 @@
49 TAB Enter citation key with completion. 49 TAB Enter citation key with completion.
50 RET Accept current entry (also on mouse-2) and create \\cite macro. 50 RET Accept current entry (also on mouse-2) and create \\cite macro.
51 m / u Mark/Unmark the entry. 51 m / u Mark/Unmark the entry.
52 e / E Create BibTeX file with all (marked/unmarked) entries
52 a / A Put all (marked) entries into one/many \\cite commands.") 53 a / A Put all (marked) entries into one/many \\cite commands.")
53 54
54;; Find bibtex files 55;; Find bibtex files
55 56
56
57(defmacro reftex-with-special-syntax-for-bib (&rest body) 57(defmacro reftex-with-special-syntax-for-bib (&rest body)
58 `(let ((saved-syntax (syntax-table))) 58 `(let ((saved-syntax (syntax-table)))
59 (unwind-protect 59 (unwind-protect
@@ -311,8 +311,8 @@
311 (not (stringp (car al1)))))) 311 (not (stringp (car al1))))))
312 312
313(defun reftex-bib-sort-year (e1 e2) 313(defun reftex-bib-sort-year (e1 e2)
314 (< (string-to-int (cdr (assoc "year" e1))) 314 (< (string-to-int (or (cdr (assoc "year" e1)) "0"))
315 (string-to-int (cdr (assoc "year" e2))))) 315 (string-to-int (or (cdr (assoc "year" e2)) "0"))))
316 316
317(defun reftex-bib-sort-year-reverse (e1 e2) 317(defun reftex-bib-sort-year-reverse (e1 e2)
318 (> (string-to-int (or (cdr (assoc "year" e1)) "0")) 318 (> (string-to-int (or (cdr (assoc "year" e1)) "0"))
@@ -597,12 +597,13 @@ to `reftex-cite-format' and inserted into the buffer.
597 597
598If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. 598If NO-INSERT is non-nil, nothing is inserted, only the selected key returned.
599 599
600FORAT-KEY can be used to pre-select a citation format. 600FORMAT-KEY can be used to pre-select a citation format.
601 601
602When called with one or two `C-u' prefixes, first rescans the document. 602When called with a `C-u' prefix, prompt for optional arguments in
603When called with a numeric prefix, make that many citations. When 603cite macros. When called with a numeric prefix, make that many
604called with point inside the braces of a `\\cite' command, it will 604citations. When called with point inside the braces of a `\\cite'
605add another key, ignoring the value of `reftex-cite-format'. 605command, it will add another key, ignoring the value of
606`reftex-cite-format'.
606 607
607The regular expression uses an expanded syntax: && is interpreted as `and'. 608The regular expression uses an expanded syntax: && is interpreted as `and'.
608Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'. 609Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'.
@@ -618,7 +619,7 @@ While entering the regexp, completion on knows citation keys is possible.
618 ;; Thus look for the scanning info only if in reftex-mode. 619 ;; Thus look for the scanning info only if in reftex-mode.
619 620
620 (when reftex-mode 621 (when reftex-mode
621 (reftex-access-scan-info current-prefix-arg)) 622 (reftex-access-scan-info nil))
622 623
623 ;; Call reftex-do-citation, but protected 624 ;; Call reftex-do-citation, but protected
624 (unwind-protect 625 (unwind-protect
@@ -629,11 +630,14 @@ While entering the regexp, completion on knows citation keys is possible.
629 ;; This really does the work of reftex-citation. 630 ;; This really does the work of reftex-citation.
630 631
631 (let* ((format (reftex-figure-out-cite-format arg no-insert format-key)) 632 (let* ((format (reftex-figure-out-cite-format arg no-insert format-key))
633 (start 0)
632 (docstruct-symbol reftex-docstruct-symbol) 634 (docstruct-symbol reftex-docstruct-symbol)
633 (selected-entries (reftex-offer-bib-menu)) 635 (selected-entries (reftex-offer-bib-menu))
634 (insert-entries selected-entries) 636 (insert-entries selected-entries)
635 entry string cite-view) 637 entry string cite-view)
636 638
639 (when (stringp selected-entries)
640 (error selected-entries))
637 (unless selected-entries (error "Quit")) 641 (unless selected-entries (error "Quit"))
638 642
639 (if (stringp selected-entries) 643 (if (stringp selected-entries)
@@ -646,6 +650,7 @@ While entering the regexp, completion on knows citation keys is possible.
646 650
647 (when (eq (car selected-entries) 'concat) 651 (when (eq (car selected-entries) 'concat)
648 ;; All keys go into a single command - we need to trick a little 652 ;; All keys go into a single command - we need to trick a little
653 ;; FIXME: Unfortunately, this meens that commenting does not work right.
649 (pop selected-entries) 654 (pop selected-entries)
650 (let ((concat-keys (mapconcat 'car selected-entries ","))) 655 (let ((concat-keys (mapconcat 'car selected-entries ",")))
651 (setq insert-entries 656 (setq insert-entries
@@ -663,6 +668,24 @@ While entering the regexp, completion on knows citation keys is possible.
663 (reftex-get-bib-field "&key" entry) 668 (reftex-get-bib-field "&key" entry)
664 format) 669 format)
665 (reftex-format-citation entry format))) 670 (reftex-format-citation entry format)))
671 (when (or (eq reftex-cite-prompt-optional-args t)
672 (and reftex-cite-prompt-optional-args
673 (equal arg '(4))))
674 (let ((start 0) (nth 0) value)
675 (while (setq start (string-match "\\[\\]" string start))
676 (setq value (read-string (format "Optional argument %d: "
677 (setq nth (1+ nth)))))
678 (setq string (replace-match (concat "[" value "]") t t string))
679 (setq start (1+ start)))))
680 ;; Should we cleanup empty optional arguments?
681 ;; if the first is empty, it can be removed. If the second is empty,
682 ;; it has to go.
683 (when reftex-cite-cleanup-optional-args
684 (cond
685 ((string-match "\\[\\]\\(\\[[a-zA-Z0-9., ]+\\]\\)" string)
686 (setq string (replace-match "\\1" nil nil string)))
687 ((string-match "\\[\\]\\[\\]" string)
688 (setq string (replace-match "" t t string)))))
666 (insert string)) 689 (insert string))
667 690
668 ;; Reposition cursor? 691 ;; Reposition cursor?
@@ -842,6 +865,17 @@ While entering the regexp, completion on knows citation keys is possible.
842 (mapcar 'car (nreverse reftex-select-marked)) 865 (mapcar 'car (nreverse reftex-select-marked))
843 found-list))) 866 found-list)))
844 (throw 'done t)) 867 (throw 'done t))
868 ((eq key ?e)
869 ;; Take all (marked), and push the symbol 'concat
870 (reftex-extract-bib-file found-list reftex-select-marked)
871 (setq selected-entries "BibTeX database file created")
872 (throw 'done t))
873 ((eq key ?E)
874 ;; Take all (marked), and push the symbol 'concat
875 (reftex-extract-bib-file found-list reftex-select-marked
876 'complement)
877 (setq selected-entries "BibTeX database file created")
878 (throw 'done t))
845 ((or (eq key ?\C-m) 879 ((or (eq key ?\C-m)
846 (eq key 'return)) 880 (eq key 'return))
847 ;; Take selected 881 ;; Take selected
@@ -882,6 +916,29 @@ While entering the regexp, completion on knows citation keys is possible.
882 (ding) 916 (ding)
883 found-list))) 917 found-list)))
884 918
919(defun reftex-extract-bib-file (all &optional marked complement)
920 ;; Limit FOUND-LIST with more regular expressions
921 (let ((file (read-file-name "File to create: ")))
922 (find-file-other-window file)
923 (if (> (buffer-size) 0)
924 (unless (yes-or-no-p
925 (format "Overwrite non-empty file %s? " file))
926 (error "Abort")))
927 (erase-buffer)
928 (setq all (delq nil
929 (mapcar
930 (lambda (x)
931 (if marked
932 (if (or (and (assoc x marked) (not complement))
933 (and (not (assoc x marked)) complement))
934 (cdr (assoc "&entry" x))
935 nil)
936 (cdr (assoc "&entry" x))))
937 all)))
938 (insert (mapconcat 'identity all "\n\n"))
939 (save-buffer)
940 (goto-char (point-min))))
941
885(defun reftex-insert-bib-matches (list) 942(defun reftex-insert-bib-matches (list)
886 ;; Insert the bib matches and number them correctly 943 ;; Insert the bib matches and number them correctly
887 (let ((mouse-face 944 (let ((mouse-face
@@ -1043,5 +1100,73 @@ While entering the regexp, completion on knows citation keys is possible.
1043 1100
1044 (select-window win))) 1101 (select-window win)))
1045 1102
1103;;; Global BibTeX file
1104(defun reftex-all-used-citation-keys ()
1105 (reftex-access-scan-info)
1106 (let ((files (reftex-all-document-files)) file keys kkk kk k)
1107 (save-excursion
1108 (while (setq file (pop files))
1109 (set-buffer (reftex-get-file-buffer-force file 'mark))
1110 (save-excursion
1111 (save-restriction
1112 (widen)
1113 (goto-char (point-min))
1114 (while (re-search-forward "^[^%\n\r]*\\\\\\(bibentry\\|[a-zA-Z]*cite[a-zA-Z]*\\)\\(\\[[^\\]]*\\]\\)?{\\([^}]+\\)}" nil t)
1115 (setq kk (match-string-no-properties 3))
1116 (while (string-match "%.*\n?" kk)
1117 (setq kk (replace-match "" t t kk)))
1118 (setq kk (split-string kk "[, \t\r\n]+"))
1119 (while (setq k (pop kk))
1120 (or (member k keys)
1121 (setq keys (cons k keys)))))))))
1122 (reftex-kill-temporary-buffers)
1123 keys))
1124
1125(defun reftex-create-bibtex-file (bibfile)
1126 "Create a new BibTeX database file with all entries referenced in document.
1127The command prompts for a filename and writes the collected entries to
1128that file. Only entries referenced in the current document with
1129any \\cite-like macros are used.
1130The sequence in the new file is the same as it was in the old database."
1131 (interactive "FNew BibTeX file: ")
1132 (let ((keys (reftex-all-used-citation-keys))
1133 (files (reftex-get-bibfile-list))
1134 file key entries beg end entry)
1135 (save-excursion
1136 (while (setq file (pop files))
1137 (set-buffer (reftex-get-file-buffer-force file 'mark))
1138 (reftex-with-special-syntax-for-bib
1139 (save-excursion
1140 (save-restriction
1141 (widen)
1142 (goto-char (point-min))
1143 (while (re-search-forward
1144 "^[ \t]*@[a-zA-Z]+[ \t]*{\\([^ \t\r\n]+\\),"
1145 nil t)
1146 (setq key (match-string 1)
1147 beg (match-beginning 0)
1148 end (progn
1149 (goto-char (match-beginning 1))
1150 (condition-case nil
1151 (up-list 1)
1152 (error (goto-char (match-end 0))))
1153 (point)))
1154 (when (member key keys)
1155 (setq entry (buffer-substring beg end)
1156 entries (cons entry entries)
1157 keys (delete key keys)))))))))
1158 (find-file-other-window bibfile)
1159 (if (> (buffer-size) 0)
1160 (unless (yes-or-no-p
1161 (format "Overwrite non-empty file %s? " bibfile))
1162 (error "Abort")))
1163 (erase-buffer)
1164 (insert (mapconcat 'identity (reverse entries) "\n\n"))
1165 (goto-char (point-min))
1166 (save-buffer)
1167 (message "%d entries extracted and copied to new database"
1168 (length entries))))
1169
1170
1046;;; arch-tag: d53d0a5a-ab32-4b52-a846-2a7c3527cd89 1171;;; arch-tag: d53d0a5a-ab32-4b52-a846-2a7c3527cd89
1047;;; reftex-cite.el ends here 1172;;; reftex-cite.el ends here
diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el
index dc47a5e7564..e832465cf17 100644
--- a/lisp/textmodes/reftex-dcr.el
+++ b/lisp/textmodes/reftex-dcr.el
@@ -1,8 +1,8 @@
1;;; reftex-dcr.el --- viewing cross references and citations with RefTeX 1;;; reftex-dcr.el --- viewing cross references and citations with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6;; 6;;
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el
index 84b4c7c67f5..d4d91b476e9 100644
--- a/lisp/textmodes/reftex-global.el
+++ b/lisp/textmodes/reftex-global.el
@@ -1,8 +1,8 @@
1;;; reftex-global.el --- operations on entire documents with RefTeX 1;;; reftex-global.el --- operations on entire documents with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index 71b3b624770..cb02f2e056f 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -1,8 +1,8 @@
1;;; reftex-index.el --- index support with RefTeX 1;;; reftex-index.el --- index support with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -360,7 +360,7 @@ _ ^ Add/Remove parent key (to make this item a subitem).
360 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer))) 360 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer)))
361 match)) 361 match))
362 362
363(defun reftex-display-index (&optional tag overriding-restriction 363(defun reftex-display-index (&optional tag overriding-restriction redo
364 &rest locations) 364 &rest locations)
365 "Display a buffer with an index compiled from the current document. 365 "Display a buffer with an index compiled from the current document.
366When the document has multiple indices, first prompts for the correct one. 366When the document has multiple indices, first prompts for the correct one.
@@ -387,7 +387,7 @@ With prefix 3, restrict index to region."
387 (calling-file (buffer-file-name)) 387 (calling-file (buffer-file-name))
388 (restriction 388 (restriction
389 (or overriding-restriction 389 (or overriding-restriction
390 (and (interactive-p) 390 (and (not redo)
391 (reftex-get-restriction current-prefix-arg docstruct)))) 391 (reftex-get-restriction current-prefix-arg docstruct))))
392 (locations 392 (locations
393 ;; See if we are on an index macro as initial position 393 ;; See if we are on an index macro as initial position
@@ -427,7 +427,7 @@ With prefix 3, restrict index to region."
427 (if restriction 427 (if restriction
428 (setq reftex-index-restriction-indicator (car restriction) 428 (setq reftex-index-restriction-indicator (car restriction)
429 reftex-index-restriction-data (cdr restriction)) 429 reftex-index-restriction-data (cdr restriction))
430 (if (interactive-p) 430 (if (not redo)
431 (setq reftex-index-restriction-indicator nil 431 (setq reftex-index-restriction-indicator nil
432 reftex-index-restriction-data nil))) 432 reftex-index-restriction-data nil)))
433 (when (= (buffer-size) 0) 433 (when (= (buffer-size) 0)
@@ -703,7 +703,7 @@ The function will go to the section where the entry at point was defined."
703 (error "Don't know which file to rescan. Try `C-u r'") 703 (error "Don't know which file to rescan. Try `C-u r'")
704 (switch-to-buffer (reftex-get-file-buffer-force file)) 704 (switch-to-buffer (reftex-get-file-buffer-force file))
705 (setq current-prefix-arg '(4)) 705 (setq current-prefix-arg '(4))
706 (reftex-display-index index-tag nil line))) 706 (reftex-display-index index-tag nil 'redo line)))
707 (reftex-index-Rescan)) 707 (reftex-index-Rescan))
708 (reftex-kill-temporary-buffers))) 708 (reftex-kill-temporary-buffers)))
709(defun reftex-index-Rescan (&rest ignore) 709(defun reftex-index-Rescan (&rest ignore)
@@ -714,7 +714,7 @@ The function will go to the section where the entry at point was defined."
714 (switch-to-buffer 714 (switch-to-buffer
715 (reftex-get-file-buffer-force reftex-last-index-file)) 715 (reftex-get-file-buffer-force reftex-last-index-file))
716 (setq current-prefix-arg '(16)) 716 (setq current-prefix-arg '(16))
717 (reftex-display-index index-tag nil line))) 717 (reftex-display-index index-tag nil 'redo line)))
718(defun reftex-index-revert (&rest ignore) 718(defun reftex-index-revert (&rest ignore)
719 "Regenerate the *Index* from the internal lists. No reparsing os done." 719 "Regenerate the *Index* from the internal lists. No reparsing os done."
720 (interactive) 720 (interactive)
@@ -727,14 +727,14 @@ The function will go to the section where the entry at point was defined."
727 (reftex-erase-buffer buf) 727 (reftex-erase-buffer buf)
728 (setq current-prefix-arg nil 728 (setq current-prefix-arg nil
729 reftex-last-follow-point 1) 729 reftex-last-follow-point 1)
730 (reftex-display-index index-tag nil data line))) 730 (reftex-display-index index-tag nil 'redo data line)))
731(defun reftex-index-switch-index-tag (&rest ignore) 731(defun reftex-index-switch-index-tag (&rest ignore)
732 "Switch to a different index of the same document." 732 "Switch to a different index of the same document."
733 (interactive) 733 (interactive)
734 (switch-to-buffer 734 (switch-to-buffer
735 (reftex-get-file-buffer-force reftex-last-index-file)) 735 (reftex-get-file-buffer-force reftex-last-index-file))
736 (setq current-prefix-arg nil) 736 (setq current-prefix-arg nil)
737 (reftex-display-index)) 737 (reftex-display-index nil nil 'redo))
738 738
739(defun reftex-index-restrict-to-section (&optional force) 739(defun reftex-index-restrict-to-section (&optional force)
740 "Restrict index to entries defined in same document sect. as entry at point." 740 "Restrict index to entries defined in same document sect. as entry at point."
@@ -1352,23 +1352,23 @@ Here are all local bindings.
1352 (if (re-search-forward reftex-index-phrases-phrase-regexp12 nil t) 1352 (if (re-search-forward reftex-index-phrases-phrase-regexp12 nil t)
1353 (progn 1353 (progn
1354 (goto-char (match-beginning 0)) 1354 (goto-char (match-beginning 0))
1355 (reftex-index-this-phrase)) 1355 (reftex-index-this-phrase 'slave))
1356 (error "No more phrase lines after point")))) 1356 (error "No more phrase lines after point"))))
1357 1357
1358(defun reftex-index-this-phrase () 1358(defun reftex-index-this-phrase (&optional slave)
1359 "Index the phrase in the current line. 1359 "Index the phrase in the current line.
1360Does a global search and replace in the entire document. At each 1360Does a global search and replace in the entire document. At each
1361match, the user will be asked to confirm the replacement." 1361match, the user will be asked to confirm the replacement."
1362 (interactive) 1362 (interactive)
1363 (if (interactive-p) (reftex-index-phrases-parse-header t)) 1363 (if (not slave) (reftex-index-phrases-parse-header t))
1364 (save-excursion 1364 (save-excursion
1365 (beginning-of-line) 1365 (beginning-of-line)
1366 (cond ((looking-at reftex-index-phrases-comment-regexp) 1366 (cond ((looking-at reftex-index-phrases-comment-regexp)
1367 (if (interactive-p) (error "Comment line"))) 1367 (if (not slave) (error "Comment line")))
1368 ((looking-at "^[ \t]*$") 1368 ((looking-at "^[ \t]*$")
1369 (if (interactive-p) (error "Empty line"))) 1369 (if (not slave) (error "Empty line")))
1370 ((looking-at reftex-index-phrases-macrodef-regexp) 1370 ((looking-at reftex-index-phrases-macrodef-regexp)
1371 (if (interactive-p) (error "Macro definition line"))) 1371 (if (not slave) (error "Macro definition line")))
1372 ((looking-at reftex-index-phrases-phrase-regexp12) 1372 ((looking-at reftex-index-phrases-phrase-regexp12)
1373 ;; This is a phrase 1373 ;; This is a phrase
1374 (let* ((char (if (not (equal (match-string 1) "")) 1374 (let* ((char (if (not (equal (match-string 1) ""))
@@ -1429,7 +1429,7 @@ Calls `reftex-index-this-phrase' on each line in the region."
1429 (goto-char beg) 1429 (goto-char beg)
1430 (while (not (or (eobp) 1430 (while (not (or (eobp)
1431 (>= (point) end))) 1431 (>= (point) end)))
1432 (save-excursion (reftex-index-this-phrase)) 1432 (save-excursion (reftex-index-this-phrase 'slave))
1433 (beginning-of-line 2))) 1433 (beginning-of-line 2)))
1434 1434
1435(defun reftex-index-phrases-parse-header (&optional get-files) 1435(defun reftex-index-phrases-parse-header (&optional get-files)
@@ -1736,12 +1736,15 @@ With optional arg ALLOW-NEWLINE, allow single newline between words."
1736 "\\([ \t]*\\(\n[ \t]*\\)?\\|[ \t]\\)" 1736 "\\([ \t]*\\(\n[ \t]*\\)?\\|[ \t]\\)"
1737 "\\([ \t]+\\)"))) 1737 "\\([ \t]+\\)")))
1738 (concat (if (and as-words (string-match "\\`\\w" (car words))) 1738 (concat (if (and as-words (string-match "\\`\\w" (car words)))
1739 "\\<" "") 1739 "\\(\\<\\|[`']\\)" "")
1740 (mapconcat (lambda (w) (regexp-quote (downcase w))) 1740 (mapconcat (lambda (w) (regexp-quote
1741 (if reftex-index-phrases-case-fold-search
1742 (downcase w)
1743 w)))
1741 words space-re) 1744 words space-re)
1742 (if (and as-words 1745 (if (and as-words
1743 (string-match "\\w\\'" (nth (1- (length words)) words))) 1746 (string-match "\\w\\'" (nth (1- (length words)) words)))
1744 "\\>" "")))) 1747 "\\(\\>\\|'\\)" ""))))
1745 1748
1746(defun reftex-index-simplify-phrase (phrase) 1749(defun reftex-index-simplify-phrase (phrase)
1747 "Make phrase single spaces and single line." 1750 "Make phrase single spaces and single line."
@@ -1825,6 +1828,8 @@ both ends."
1825 (unwind-protect 1828 (unwind-protect
1826 (while (re-search-forward re nil t) 1829 (while (re-search-forward re nil t)
1827 (catch 'next-match 1830 (catch 'next-match
1831 (if (reftex-in-comment)
1832 (throw 'next-match nil))
1828 (if (and (fboundp reftex-index-verify-function) 1833 (if (and (fboundp reftex-index-verify-function)
1829 (not (funcall reftex-index-verify-function))) 1834 (not (funcall reftex-index-verify-function)))
1830 (throw 'next-match nil)) 1835 (throw 'next-match nil))
@@ -1925,7 +1930,7 @@ both ends."
1925 (reftex-unhighlight 0)))) 1930 (reftex-unhighlight 0))))
1926 1931
1927(defun reftex-index-phrase-match-is-indexed (beg end) 1932(defun reftex-index-phrase-match-is-indexed (beg end)
1928 ;; CHeck if match is in an argument of an index macro, or if an 1933 ;; Check if match is in an argument of an index macro, or if an
1929 ;; index macro is directly attached to the match. 1934 ;; index macro is directly attached to the match.
1930 (save-excursion 1935 (save-excursion
1931 (goto-char end) 1936 (goto-char end)
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index 534775bf5a5..630c7101725 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -1,8 +1,8 @@
1;;; reftex-parse.el --- parser functions for RefTeX 1;;; reftex-parse.el --- parser functions for RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6;; 6;;
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index 2d4935aedde..43095e2d684 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -1,8 +1,8 @@
1;;; reftex-ref.el --- code to create labels and references with RefTeX 1;;; reftex-ref.el --- code to create labels and references with RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -96,14 +96,27 @@ If optional BOUND is an integer, limit backward searches to that point."
96 96
97(defun reftex-label-info (label &optional file bound derive env-or-mac) 97(defun reftex-label-info (label &optional file bound derive env-or-mac)
98 ;; Return info list on LABEL at point. 98 ;; Return info list on LABEL at point.
99 (let* ((env-or-mac (or env-or-mac (reftex-label-location bound))) 99 (let* ((prefix (if (string-match "^[a-zA-Z0-9]+:" label)
100 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist))) 100 (match-string 0 label)))
101 (typekey (cdr (assoc prefix reftex-prefix-to-typekey-alist)))
101 (file (or file (buffer-file-name))) 102 (file (or file (buffer-file-name)))
102 (parse (nth 2 (assoc env-or-mac reftex-env-or-mac-alist))) 103 (trust reftex-trust-label-prefix)
103 (text (reftex-short-context env-or-mac parse reftex-location-start
104 derive))
105 (in-comment (reftex-in-comment))) 104 (in-comment (reftex-in-comment)))
106 (list label typekey text file in-comment))) 105 (if (and typekey
106 (cond ((eq trust t) t)
107 ((null trust) nil)
108 ((stringp trust) (string-match trust typekey))
109 ((listp trust) (member typekey trust))
110 (t nil)))
111 (list label typekey
112 (reftex-nicify-text (reftex-context-substring))
113 file in-comment)
114 (let* ((env-or-mac (or env-or-mac (reftex-label-location bound)))
115 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist)))
116 (parse (nth 2 (assoc env-or-mac reftex-env-or-mac-alist)))
117 (text (reftex-short-context env-or-mac parse reftex-location-start
118 derive)))
119 (list label typekey text file in-comment)))))
107 120
108;;; Creating labels --------------------------------------------------------- 121;;; Creating labels ---------------------------------------------------------
109 122
@@ -296,35 +309,43 @@ also applies `reftex-translate-to-ascii-function' to the string."
296 (while (string-match "\\%\\([a-zA-Z]\\)" prefix num) 309 (while (string-match "\\%\\([a-zA-Z]\\)" prefix num)
297 (setq letter (match-string 1 prefix)) 310 (setq letter (match-string 1 prefix))
298 (setq replace 311 (setq replace
299 (cond 312 (save-match-data
300 ((equal letter "f") 313 (cond
301 (file-name-sans-extension 314 ((equal letter "f")
302 (file-name-nondirectory (buffer-file-name)))) 315 (file-name-sans-extension
303 ((equal letter "F") 316 (file-name-nondirectory (buffer-file-name))))
304 (let ((masterdir (file-name-directory (reftex-TeX-master-file))) 317 ((equal letter "F")
305 (file (file-name-sans-extension (buffer-file-name)))) 318 (let ((masterdir (file-name-directory (reftex-TeX-master-file)))
306 (if (string-match (concat "\\`" (regexp-quote masterdir)) 319 (file (file-name-sans-extension (buffer-file-name))))
307 file) 320 (if (string-match (concat "\\`" (regexp-quote masterdir))
308 (substring file (length masterdir)) 321 file)
309 file))) 322 (substring file (length masterdir))
310 ((equal letter "u") 323 file)))
311 (or (user-login-name) "")) 324 ((equal letter "m")
312 ((equal letter "S") 325 (file-name-sans-extension
313 (let* (macro level-exp level) 326 (file-name-nondirectory (reftex-TeX-master-file))))
314 (save-excursion 327 ((equal letter "M")
315 (save-match-data 328 (file-name-nondirectory
316 (when (re-search-backward reftex-section-regexp nil t) 329 (substring (file-name-directory (reftex-TeX-master-file))
317 (setq macro (reftex-match-string 2) 330 0 -1)))
318 level-exp (cdr (assoc macro reftex-section-levels-all)) 331 ((equal letter "u")
319 level (if (symbolp level-exp) 332 (or (user-login-name) ""))
320 (abs (save-match-data 333 ((equal letter "S")
321 (funcall level-exp))) 334 (let* (macro level-exp level)
322 (abs level-exp)))) 335 (save-excursion
323 (cdr (or (assoc macro reftex-section-prefixes) 336 (save-match-data
324 (assoc level reftex-section-prefixes) 337 (when (re-search-backward reftex-section-regexp nil t)
325 (assq t reftex-section-prefixes) 338 (setq macro (reftex-match-string 2)
326 (list t "sec:"))))))) 339 level-exp (cdr (assoc macro reftex-section-levels-all))
327 (t ""))) 340 level (if (symbolp level-exp)
341 (abs (save-match-data
342 (funcall level-exp)))
343 (abs level-exp))))
344 (cdr (or (assoc macro reftex-section-prefixes)
345 (assoc level reftex-section-prefixes)
346 (assq t reftex-section-prefixes)
347 (list t "sec:")))))))
348 (t ""))))
328 (setq num (1- (+ (match-beginning 1) (length replace))) 349 (setq num (1- (+ (match-beginning 1) (length replace)))
329 prefix (replace-match replace nil nil prefix))) 350 prefix (replace-match replace nil nil prefix)))
330 prefix))) 351 prefix)))
@@ -449,7 +470,7 @@ When called with 2 C-u prefix args, disable magic word recognition."
449 470
450 ;; remove ~ if we do already have a space 471 ;; remove ~ if we do already have a space
451 (when (and (= ?~ (string-to-char form)) 472 (when (and (= ?~ (string-to-char form))
452 (member (preceding-char) '(?\ ?\t ?\n ?. ?~))) 473 (member (preceding-char) '(?\ ?\t ?\n ?~)))
453 (setq form (substring form 1))) 474 (setq form (substring form 1)))
454 ;; do we have a special format? 475 ;; do we have a special format?
455 (setq reftex-format-ref-function 476 (setq reftex-format-ref-function
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el
index 3074e83b681..8b0ebb2ca2b 100644
--- a/lisp/textmodes/reftex-sel.el
+++ b/lisp/textmodes/reftex-sel.el
@@ -1,8 +1,8 @@
1;;; reftex-sel.el --- the selection modes for RefTeX 1;;; reftex-sel.el --- the selection modes for RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -607,13 +607,11 @@ Useful for large TOC's."
607 (setq ovl (make-overlay boe eoe)) 607 (setq ovl (make-overlay boe eoe))
608 (push (list data ovl separator) reftex-select-marked) 608 (push (list data ovl separator) reftex-select-marked)
609 (overlay-put ovl 'face reftex-select-mark-face) 609 (overlay-put ovl 'face reftex-select-mark-face)
610 (if (featurep 'xemacs) 610 (overlay-put ovl 'before-string
611 ;; before-string property is broken in Emacs 611 (if separator
612 (overlay-put ovl 'before-string 612 (format "*%c%d* " separator
613 (if separator 613 (length reftex-select-marked))
614 (format "*%c%d* " separator 614 (format "*%d* " (length reftex-select-marked))))
615 (length reftex-select-marked))
616 (format "*%d* " (length reftex-select-marked)))))
617 (message "Entry has mark no. %d" (length reftex-select-marked)))) 615 (message "Entry has mark no. %d" (length reftex-select-marked))))
618 616
619(defun reftex-select-mark-comma () 617(defun reftex-select-mark-comma ()
@@ -725,7 +723,7 @@ Useful for large TOC's."
725 (define-key reftex-select-label-map (car x) (cdr x))) 723 (define-key reftex-select-label-map (car x) (cdr x)))
726 724
727;; Specific bindings in reftex-select-bib-map 725;; Specific bindings in reftex-select-bib-map
728(loop for key across "grRaA" do 726(loop for key across "grRaAeE" do
729 (define-key reftex-select-bib-map (vector (list key)) 727 (define-key reftex-select-bib-map (vector (list key))
730 (list 'lambda '() 728 (list 'lambda '()
731 "Press `?' during selection to find out about this key." 729 "Press `?' during selection to find out about this key."
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index 8d217f08dfb..ed9746f8a69 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -2,7 +2,7 @@
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -868,6 +868,7 @@ label prefix determines the wording of a reference."
868 ((and (markerp marker) (marker-buffer marker)) 868 ((and (markerp marker) (marker-buffer marker))
869 ;; Buffer is still live and we have the marker. Should be easy. 869 ;; Buffer is still live and we have the marker. Should be easy.
870 (switch-to-buffer-other-window (marker-buffer marker)) 870 (switch-to-buffer-other-window (marker-buffer marker))
871 (push-mark nil)
871 (goto-char (marker-position marker)) 872 (goto-char (marker-position marker))
872 (or (looking-at (regexp-quote literal)) 873 (or (looking-at (regexp-quote literal))
873 (looking-at (reftex-make-regexp-allow-for-ctrl-m literal)) 874 (looking-at (reftex-make-regexp-allow-for-ctrl-m literal))
@@ -1088,4 +1089,4 @@ always show the current section in connection with the option
1088 1089
1089 1090
1090;;; arch-tag: 92400ce2-0b86-4c89-a606-4ed71acea17e 1091;;; arch-tag: 92400ce2-0b86-4c89-a606-4ed71acea17e
1091;;; reftex-toc.el ends here \ No newline at end of file 1092;;; reftex-toc.el ends here
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index 53357342c51..a7c0cb1c1ad 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -1,8 +1,8 @@
1;;; reftex-vars.el --- configuration variables for RefTeX 1;;; reftex-vars.el --- configuration variables for RefTeX
2;; Copyright (c) 1997, 1998, 1999, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6 6
7;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
8 8
@@ -128,13 +128,13 @@ distribution. Mixed-case symbols are convenience aliases.")
128 128
129(defconst reftex-cite-format-builtin 129(defconst reftex-cite-format-builtin
130 '((default "Default macro \\cite{%l}" 130 '((default "Default macro \\cite{%l}"
131 "\\cite{%l}") 131 "\\cite[]{%l}")
132 (natbib "The Natbib package" 132 (natbib "The Natbib package"
133 ((?\C-m . "\\cite{%l}") 133 ((?\C-m . "\\cite[][]{%l}")
134 (?t . "\\citet{%l}") 134 (?t . "\\citet[][]{%l}")
135 (?T . "\\citet*{%l}") 135 (?T . "\\citet*[][]{%l}")
136 (?p . "\\citep{%l}") 136 (?p . "\\citep[][]{%l}")
137 (?P . "\\citep*{%l}") 137 (?P . "\\citep*[][]{%l}")
138 (?e . "\\citep[e.g.][]{%l}") 138 (?e . "\\citep[e.g.][]{%l}")
139 (?s . "\\citep[see][]{%l}") 139 (?s . "\\citep[see][]{%l}")
140 (?a . "\\citeauthor{%l}") 140 (?a . "\\citeauthor{%l}")
@@ -157,8 +157,8 @@ distribution. Mixed-case symbols are convenience aliases.")
157 (bibentry "The Bibentry package" 157 (bibentry "The Bibentry package"
158 "\\bibentry{%l}") 158 "\\bibentry{%l}")
159 (harvard "The Harvard package" 159 (harvard "The Harvard package"
160 ((?\C-m . "\\cite{%l}") 160 ((?\C-m . "\\cite[]{%l}")
161 (?p . "\\cite{%l}") 161 (?p . "\\cite[]{%l}")
162 (?t . "\\citeasnoun{%l}") 162 (?t . "\\citeasnoun{%l}")
163 (?n . "\\citeasnoun{%l}") 163 (?n . "\\citeasnoun{%l}")
164 (?s . "\\possessivecite{%l}") 164 (?s . "\\possessivecite{%l}")
@@ -166,17 +166,17 @@ distribution. Mixed-case symbols are convenience aliases.")
166 (?y . "\\citeyear{%l}") 166 (?y . "\\citeyear{%l}")
167 (?a . "\\citename{%l}"))) 167 (?a . "\\citename{%l}")))
168 (chicago "The Chicago package" 168 (chicago "The Chicago package"
169 ((?\C-m . "\\cite{%l}") 169 ((?\C-m . "\\cite[]{%l}")
170 (?t . "\\citeN{%l}") 170 (?t . "\\citeN[]{%l}")
171 (?T . "\\shortciteN{%l}") 171 (?T . "\\shortciteN{%l}")
172 (?p . "\\cite{%l}") 172 (?p . "\\cite[]{%l}")
173 (?P . "\\shortcite{%l}") 173 (?P . "\\shortcite{%l}")
174 (?a . "\\citeA{%l}") 174 (?a . "\\citeA{%l}")
175 (?A . "\\shortciteA{%l}") 175 (?A . "\\shortciteA{%l}")
176 (?y . "\\citeyear{%l}"))) 176 (?y . "\\citeyear{%l}")))
177 (astron "The Astron package" 177 (astron "The Astron package"
178 ((?\C-m . "\\cite{%l}") 178 ((?\C-m . "\\cite[]{%l}")
179 (?p . "\\cite{%l}" ) 179 (?p . "\\cite[]{%l}" )
180 (?t . "%2a (\\cite{%l})"))) 180 (?t . "%2a (\\cite{%l})")))
181 (author-year "Do-it-yourself Author-year" 181 (author-year "Do-it-yourself Author-year"
182 ((?\C-m . "\\cite{%l}") 182 ((?\C-m . "\\cite{%l}")
@@ -484,6 +484,8 @@ LABEL-PREFIX
484 empty string. The prefix may contain the following `%' escapes: 484 empty string. The prefix may contain the following `%' escapes:
485 %f Current file name with directory and extension stripped. 485 %f Current file name with directory and extension stripped.
486 %F Current file name relative to directory of master file. 486 %F Current file name relative to directory of master file.
487 %m Master file name, directory and extension stripped.
488 %M Directory name (without path) where master file is located.
487 %u User login name, on systems which support this. 489 %u User login name, on systems which support this.
488 %S A section prefix derived with variable `reftex-section-prefixes'. 490 %S A section prefix derived with variable `reftex-section-prefixes'.
489 491
@@ -631,6 +633,43 @@ the final regular expression - so %s will be replaced with the environment
631or macro." 633or macro."
632 :group 'reftex-defining-label-environments 634 :group 'reftex-defining-label-environments
633 :type '(repeat (cons (symbol) (regexp)))) 635 :type '(repeat (cons (symbol) (regexp))))
636
637(defcustom reftex-trust-label-prefix nil
638 "Non-nil means, trust the label prefix when determining label type.
639It is customary to use special label prefixes to distinguish different label
640types. The label prefixes have no syntactic meaning in LaTeX (unless
641special packages like fancyref) are being used. RefTeX can and by
642default does parse around each label to detect the correct label type,
643but this process can be slow when a document contains thousands of
644labels. If you use label prefixes consistently, you may speed up
645document parsing by setting this variable to a non-nil value. RefTeX
646will then compare the label prefix with the prefixes found in
647`reftex-label-alist' and derive the correct label type in this way.
648Possible values for this option are:
649
650t This means to trust any label prefixes found.
651regexp If a regexp, only prefixes matched by the regexp are trusted.
652list List of accepted prefixes, as strings. The colon is part of
653 the prefix, e.g. (\"fn:\" \"eqn:\" \"item:\").
654nil Never trust a label prefix.
655
656The only disadvantage of using this feature is that the label context
657displayed in the label selection buffer along with each label is
658simply some text after the label definition. This is no problem if you
659place labels keeping this in mind (e.g. *before* the equation, *at
660the beginning* of a fig/tab caption ...). Anyway, it is probably best
661to use the regexp or the list value types to fine-tune this feature.
662For example, if your document contains thousands of footnotes with
663labels fn:xxx, you may want to set this variable to the value \"^fn:$\" or
664\(\"fn:\"). Then RefTeX will still do extensive parsing for any
665non-footnote labels."
666 :group 'reftex-defining-label-environments
667 :type '(choice
668 (const :tag "Always" t)
669 (const :tag "Never" nil)
670 (regexp)
671 (repeat :tag "List"
672 (string :tag "prefix (with colon)"))))
634 673
635(defcustom reftex-special-environment-functions nil 674(defcustom reftex-special-environment-functions nil
636 "List of functions to be called when trying to figure out current environment. 675 "List of functions to be called when trying to figure out current environment.
@@ -1010,6 +1049,9 @@ display, and for (setq reftex-comment-citations t).
1010%< as a special operator kills punctuation and space around it after the 1049%< as a special operator kills punctuation and space around it after the
1011string has been formatted. 1050string has been formatted.
1012 1051
1052A pair of square brackets indicates an optional argument, and RefTeX
1053will prompt for the values of these arguments.
1054
1013Beware that all this only works with BibTeX database files. When 1055Beware that all this only works with BibTeX database files. When
1014citations are made from the \\bibitems in an explicit thebibliography 1056citations are made from the \\bibitems in an explicit thebibliography
1015environment, only %l is available. 1057environment, only %l is available.
@@ -1042,6 +1084,42 @@ E.g.: (setq reftex-cite-format 'natbib)"
1042 (cons (character :tag "Key character" ?\r) 1084 (cons (character :tag "Key character" ?\r)
1043 (string :tag "Format string" ""))))) 1085 (string :tag "Format string" "")))))
1044 1086
1087(defcustom reftex-cite-prompt-optional-args 'maybe
1088 "*Non-nil means, prompt for empty optional arguments in cite macros.
1089When an entry in `reftex-cite-format' ist given with square brackets to
1090indicate optional arguments (for example \\cite[][]{%l}), RefTeX can
1091prompt for values. Possible values are:
1092
1093nil Never prompt for optional arguments
1094t Always prompt
1095maybe Prompt only if `reftex-citation' was called with C-u prefix arg
1096
1097Unnecessary empty optional arguments are removed before insertion into
1098the buffer. See `reftex-cite-cleanup-optional-args'."
1099 :group 'reftex-citation-support
1100 :type '(choice
1101 (const :tag "Always" t)
1102 (const :tag "When called with prefix arg" maybe)
1103 (const :tag "Never" nil)))
1104
1105(defcustom reftex-cite-cleanup-optional-args t
1106 "*Non-nil means, remove unnecessary empty optional arguments in cite macros.
1107The cite macros provided by some packages (for example
1108natbib) allow specifying two optional arguments, one for a prefix to
1109the citation, and a second for a postfix. When only one optional
1110argument is given, it is interpreted as postfix. When this option is
1111t, RefTeX removes unnecessary empty optional arguments from the cite
1112macro before insertion. For example, it will change
1113 \\cite[][]{Jones} -> \\cite{Jones}
1114 \\cite[][Chapter 1]{Jones} -> \\cite[Chapter 1]{Jones}
1115 \\cite[see][]{Jones} -> \\cite[see][]{Jones}
1116 \\cite[see][Chapter 1]{Jones} -> \\cite{Jones}
1117Is is possible that other packages have other conventions about which
1118optional argument is interpreted how - that is why this cleaning up
1119can be turned off."
1120 :group 'reftex-citation-support
1121 :type 'boolean)
1122
1045(defcustom reftex-comment-citations nil 1123(defcustom reftex-comment-citations nil
1046 "*Non-nil means add a comment for each citation describing the full entry. 1124 "*Non-nil means add a comment for each citation describing the full entry.
1047The comment is formatted according to `reftex-cite-comment-format'." 1125The comment is formatted according to `reftex-cite-comment-format'."
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index c00400a7b96..e177805e9c4 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -1,8 +1,8 @@
1;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX 1;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX
2;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. 2;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Version: 4.21 5;; Version: 4.26
6;; Keywords: tex 6;; Keywords: tex
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
@@ -300,7 +300,7 @@
300;;; Define the formal stuff for a minor mode named RefTeX. 300;;; Define the formal stuff for a minor mode named RefTeX.
301;;; 301;;;
302 302
303(defconst reftex-version "RefTeX version 4.21" 303(defconst reftex-version "RefTeX version 4.26"
304 "Version string for RefTeX.") 304 "Version string for RefTeX.")
305 305
306(defvar reftex-mode nil 306(defvar reftex-mode nil
@@ -669,6 +669,8 @@ the label information is recompiled on next use."
669 669
670;; Alist relating magic words to a label type. 670;; Alist relating magic words to a label type.
671(defvar reftex-words-to-typekey-alist nil) 671(defvar reftex-words-to-typekey-alist nil)
672;; Alist relating label prefixes to a label type.
673(defvar reftex-prefix-to-typekey-alist nil)
672 674
673;; The last list-of-labels entry used in a reference. 675;; The last list-of-labels entry used in a reference.
674(defvar reftex-last-used-reference (list nil nil nil nil)) 676(defvar reftex-last-used-reference (list nil nil nil nil))
@@ -750,6 +752,7 @@ the label information is recompiled on next use."
750 reftex-typekey-to-format-alist 752 reftex-typekey-to-format-alist
751 reftex-typekey-to-prefix-alist 753 reftex-typekey-to-prefix-alist
752 reftex-words-to-typekey-alist 754 reftex-words-to-typekey-alist
755 reftex-prefix-to-typekey-alist
753 reftex-type-query-prompt 756 reftex-type-query-prompt
754 reftex-type-query-help 757 reftex-type-query-help
755 758
@@ -904,6 +907,8 @@ This enforces rescanning the buffer on next use."
904 macro verify repeat nindex tag key toc-level toc-levels) 907 macro verify repeat nindex tag key toc-level toc-levels)
905 908
906 (setq reftex-words-to-typekey-alist nil 909 (setq reftex-words-to-typekey-alist nil
910 reftex-prefix-to-typekey-alist
911 '(("sec:" . "s") ("cha:" . "s") ("chap:" . "s"))
907 reftex-typekey-list nil 912 reftex-typekey-list nil
908 reftex-typekey-to-format-alist nil 913 reftex-typekey-to-format-alist nil
909 reftex-typekey-to-prefix-alist nil 914 reftex-typekey-to-prefix-alist nil
@@ -946,6 +951,10 @@ This enforces rescanning the buffer on next use."
946 (if typekey 951 (if typekey
947 (add-to-list 'reftex-typekey-list typekey)) 952 (add-to-list 'reftex-typekey-list typekey))
948 (if (and typekey prefix 953 (if (and typekey prefix
954 (not (assoc prefix reftex-prefix-to-typekey-alist)))
955 (add-to-list 'reftex-prefix-to-typekey-alist
956 (cons prefix typekey)))
957 (if (and typekey prefix
949 (not (assoc typekey reftex-typekey-to-prefix-alist))) 958 (not (assoc typekey reftex-typekey-to-prefix-alist)))
950 (add-to-list 'reftex-typekey-to-prefix-alist 959 (add-to-list 'reftex-typekey-to-prefix-alist
951 (cons typekey prefix))) 960 (cons typekey prefix)))
@@ -1676,6 +1685,7 @@ When DIE is non-nil, throw an error if file not found."
1676 "Make a citation using BibTeX database files." t) 1685 "Make a citation using BibTeX database files." t)
1677(autoload 'reftex-default-bibliography "reftex-cite") 1686(autoload 'reftex-default-bibliography "reftex-cite")
1678(autoload 'reftex-bib-or-thebib "reftex-cite") 1687(autoload 'reftex-bib-or-thebib "reftex-cite")
1688(autoload 'reftex-create-bibtex-file "reftex-cite")
1679 1689
1680;;; ========================================================================= 1690;;; =========================================================================
1681;;; 1691;;;
@@ -2439,6 +2449,7 @@ IGNORE-WORDS List of words which should be removed from the string."
2439 ["Restore from File" (reftex-access-parse-file 'restore) t]) 2449 ["Restore from File" (reftex-access-parse-file 'restore) t])
2440 ("Global Actions" 2450 ("Global Actions"
2441 ["Search Whole Document" reftex-search-document t] 2451 ["Search Whole Document" reftex-search-document t]
2452 ["Search Again" tags-loop-continue t]
2442 ["Replace in Document" reftex-query-replace-document t] 2453 ["Replace in Document" reftex-query-replace-document t]
2443 ["Grep on Document" reftex-grep-document t] 2454 ["Grep on Document" reftex-grep-document t]
2444 "--" 2455 "--"
@@ -2447,6 +2458,8 @@ IGNORE-WORDS List of words which should be removed from the string."
2447 ["Change Label and Refs" reftex-change-label t] 2458 ["Change Label and Refs" reftex-change-label t]
2448 ["Renumber Simple Labels" reftex-renumber-simple-labels t] 2459 ["Renumber Simple Labels" reftex-renumber-simple-labels t]
2449 "--" 2460 "--"
2461 ["Create BibTeX File" reftex-create-bibtex-file t]
2462 "--"
2450 ["Create TAGS File" reftex-create-tags-file t] 2463 ["Create TAGS File" reftex-create-tags-file t]
2451 "--" 2464 "--"
2452 ["Save Document" reftex-save-all-document-buffers t]) 2465 ["Save Document" reftex-save-all-document-buffers t])
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 6da9cc23aaa..b1a1b70397a 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -1,6 +1,6 @@
1;;; sgml-mode.el --- SGML- and HTML-editing modes 1;;; sgml-mode.el --- SGML- and HTML-editing modes
2 2
3;; Copyright (C) 1992, 1995, 1996, 1998, 2001, 2002, 2003, 2004 3;; Copyright (C) 1992, 1995, 1996, 1998, 2001, 2002, 2003, 2004, 2005
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Author: James Clark <jjc@jclark.com> 6;; Author: James Clark <jjc@jclark.com>
@@ -392,6 +392,14 @@ Otherwise, it is set to be buffer-local when the file has
392 (concat "<" face ">")) 392 (concat "<" face ">"))
393 (error "Face not configured for %s mode" mode-name))) 393 (error "Face not configured for %s mode" mode-name)))
394 394
395(defun sgml-fill-nobreak ()
396 ;; Don't break between a tag name and its first argument.
397 (save-excursion
398 (skip-chars-backward " \t")
399 (and (not (zerop (skip-syntax-backward "w_")))
400 (skip-chars-backward "/?!")
401 (eq (char-before) ?<))))
402
395;;;###autoload 403;;;###autoload
396(define-derived-mode sgml-mode text-mode "SGML" 404(define-derived-mode sgml-mode text-mode "SGML"
397 "Major mode for editing SGML documents. 405 "Major mode for editing SGML documents.
@@ -422,6 +430,7 @@ Do \\[describe-key] on the following bindings to discover what they do.
422 (set (make-local-variable 'paragraph-separate) 430 (set (make-local-variable 'paragraph-separate)
423 (concat paragraph-start "$")) 431 (concat paragraph-start "$"))
424 (set (make-local-variable 'adaptive-fill-regexp) "[ \t]*") 432 (set (make-local-variable 'adaptive-fill-regexp) "[ \t]*")
433 (add-hook 'fill-nobreak-predicate 'sgml-fill-nobreak nil t)
425 (set (make-local-variable 'indent-line-function) 'sgml-indent-line) 434 (set (make-local-variable 'indent-line-function) 'sgml-indent-line)
426 (set (make-local-variable 'comment-start) "<!-- ") 435 (set (make-local-variable 'comment-start) "<!-- ")
427 (set (make-local-variable 'comment-end) " -->") 436 (set (make-local-variable 'comment-end) " -->")
@@ -1138,17 +1147,19 @@ immediately enclosing the current position.
1138Point is assumed to be outside of any tag. If we discover that it's 1147Point is assumed to be outside of any tag. If we discover that it's
1139not the case, the first tag returned is the one inside which we are." 1148not the case, the first tag returned is the one inside which we are."
1140 (let ((here (point)) 1149 (let ((here (point))
1150 (stack nil)
1141 (ignore nil) 1151 (ignore nil)
1142 (context nil) 1152 (context nil)
1143 tag-info) 1153 tag-info)
1144 ;; CONTEXT keeps track of the tag-stack 1154 ;; CONTEXT keeps track of the tag-stack
1145 ;; IGNORE keeps track of the nesting level of point relative to the 1155 ;; STACK keeps track of the end tags we've seen (and thus the start-tags
1146 ;; first (outermost) tag on the context. This is the list of 1156 ;; we'll have to ignore) when skipping over matching open..close pairs.
1147 ;; enclosing start-tags we'll have to ignore. 1157 ;; IGNORE is a list of tags that can be ignored because they have been
1158 ;; closed implicitly.
1148 (skip-chars-backward " \t\n") ; Make sure we're not at indentation. 1159 (skip-chars-backward " \t\n") ; Make sure we're not at indentation.
1149 (while 1160 (while
1150 (and (not (eq until 'now)) 1161 (and (not (eq until 'now))
1151 (or ignore 1162 (or stack
1152 (not (if until (eq until 'empty) context)) 1163 (not (if until (eq until 'empty) context))
1153 (not (sgml-at-indentation-p)) 1164 (not (sgml-at-indentation-p))
1154 (and context 1165 (and context
@@ -1172,24 +1183,25 @@ not the case, the first tag returned is the one inside which we are."
1172 ;; start-tag 1183 ;; start-tag
1173 ((eq (sgml-tag-type tag-info) 'open) 1184 ((eq (sgml-tag-type tag-info) 'open)
1174 (cond 1185 (cond
1175 ((null ignore) 1186 ((null stack)
1176 (if (and context 1187 (if (member-ignore-case (sgml-tag-name tag-info) ignore)
1177 (sgml-unclosed-tag-p (sgml-tag-name tag-info))
1178 (eq t (compare-strings
1179 (sgml-tag-name tag-info) nil nil
1180 (sgml-tag-name (car context)) nil nil t)))
1181 ;; There was an implicit end-tag. 1188 ;; There was an implicit end-tag.
1182 nil 1189 nil
1183 (push tag-info context))) 1190 (push tag-info context)
1191 ;; We're changing context so the tags implicitly closed inside
1192 ;; the previous context aren't implicitly closed here any more.
1193 ;; [ Well, actually it depends, but we don't have the info about
1194 ;; when it doesn't and when it does. --Stef ]
1195 (setq ignore nil)))
1184 ((eq t (compare-strings (sgml-tag-name tag-info) nil nil 1196 ((eq t (compare-strings (sgml-tag-name tag-info) nil nil
1185 (car ignore) nil nil t)) 1197 (car stack) nil nil t))
1186 (setq ignore (cdr ignore))) 1198 (setq stack (cdr stack)))
1187 (t 1199 (t
1188 ;; The open and close tags don't match. 1200 ;; The open and close tags don't match.
1189 (if (not sgml-xml-mode) 1201 (if (not sgml-xml-mode)
1190 (unless (sgml-unclosed-tag-p (sgml-tag-name tag-info)) 1202 (unless (sgml-unclosed-tag-p (sgml-tag-name tag-info))
1191 (message "Unclosed tag <%s>" (sgml-tag-name tag-info)) 1203 (message "Unclosed tag <%s>" (sgml-tag-name tag-info))
1192 (let ((tmp ignore)) 1204 (let ((tmp stack))
1193 ;; We could just assume that the tag is simply not closed 1205 ;; We could just assume that the tag is simply not closed
1194 ;; but it's a bad assumption when tags *are* closed but 1206 ;; but it's a bad assumption when tags *are* closed but
1195 ;; not properly nested. 1207 ;; not properly nested.
@@ -1200,13 +1212,19 @@ not the case, the first tag returned is the one inside which we are."
1200 (setq tmp (cdr tmp))) 1212 (setq tmp (cdr tmp)))
1201 (if (cdr tmp) (setcdr tmp (cddr tmp))))) 1213 (if (cdr tmp) (setcdr tmp (cddr tmp)))))
1202 (message "Unmatched tags <%s> and </%s>" 1214 (message "Unmatched tags <%s> and </%s>"
1203 (sgml-tag-name tag-info) (pop ignore)))))) 1215 (sgml-tag-name tag-info) (pop stack)))))
1216
1217 (if (and (null stack) (sgml-unclosed-tag-p (sgml-tag-name tag-info)))
1218 ;; This is a top-level open of an implicitly closed tag, so any
1219 ;; occurrence of such an open tag at the same level can be ignored
1220 ;; because it's been implicitly closed.
1221 (push (sgml-tag-name tag-info) ignore)))
1204 1222
1205 ;; end-tag 1223 ;; end-tag
1206 ((eq (sgml-tag-type tag-info) 'close) 1224 ((eq (sgml-tag-type tag-info) 'close)
1207 (if (sgml-empty-tag-p (sgml-tag-name tag-info)) 1225 (if (sgml-empty-tag-p (sgml-tag-name tag-info))
1208 (message "Spurious </%s>: empty tag" (sgml-tag-name tag-info)) 1226 (message "Spurious </%s>: empty tag" (sgml-tag-name tag-info))
1209 (push (sgml-tag-name tag-info) ignore))) 1227 (push (sgml-tag-name tag-info) stack)))
1210 )) 1228 ))
1211 1229
1212 ;; return context 1230 ;; return context
diff --git a/lisp/toolbar/README b/lisp/toolbar/README
index f7c8cb033b4..4bf1700dd91 100644
--- a/lisp/toolbar/README
+++ b/lisp/toolbar/README
@@ -5,4 +5,6 @@ The following icons are from GTK+ 2.x:
5 paste.xpm preferences.xpm print.xpm right_arrow.xpm save.xpm 5 paste.xpm preferences.xpm print.xpm right_arrow.xpm save.xpm
6 saveas.xpm search.xpm spell.xpm undo.xpm up_arrow.xpm 6 saveas.xpm search.xpm spell.xpm undo.xpm up_arrow.xpm
7 7
8 back_arrow.xpm and fwd_arrow.xpm are slightly modified undo and redo.
9
8They are not part of Emacs, but distributed and used by Emacs. 10They are not part of Emacs, but distributed and used by Emacs.
diff --git a/lisp/toolbar/back_arrow.pbm b/lisp/toolbar/back_arrow.pbm
new file mode 100644
index 00000000000..7f9b8975d2f
--- /dev/null
+++ b/lisp/toolbar/back_arrow.pbm
Binary files differ
diff --git a/lisp/toolbar/back_arrow.xpm b/lisp/toolbar/back_arrow.xpm
new file mode 100644
index 00000000000..b9b13613d81
--- /dev/null
+++ b/lisp/toolbar/back_arrow.xpm
@@ -0,0 +1,57 @@
1/* XPM */
2static char *back_arrow_xpm[] = {
3"24 24 30 1",
4" c #000000",
5". c #53692A",
6"X c #59702D",
7"o c #657255",
8"O c #6D7A5B",
9"+ c #6D8839",
10"@ c #7C9B40",
11"# c #748261",
12"$ c #7F8E6B",
13"% c #818F71",
14"& c #879772",
15"* c #8C9A7F",
16"= c #85A24D",
17"- c #8BA859",
18"; c #92AD62",
19": c #95A77E",
20"> c #98AF74",
21", c #9BB572",
22"< c #9BAA87",
23"1 c #9CAF84",
24"2 c #A4B690",
25"3 c #A8BCA6",
26"4 c #ADBDA0",
27"5 c #AFC394",
28"6 c #BAD09D",
29"7 c #B5C3A9",
30"8 c #BED2A3",
31"9 c #D5E1C6",
32"0 c #FFFFFF",
33"q c None",
34"qqqqqqqqqqqqqqqqqqqqqqqq",
35"qqqqqqqqqqqqqqqqqqqqqqqq",
36"qqqqqqqqqqqqqqqqqqqqqqqq",
37"qqqqqqqqqq qqqqqqqqqqqqq",
38"qqqqqqqqq qqqqqqqqqqqqq",
39"qqqqqqqq 9 qqqqqqqqqqqqq",
40"qqqqqqq 96 qqqqqqqqqq",
41"qqqqqq 968664% qqqqqqqqq",
42"qqqqq 966666663 qqqqqqqq",
43"qqqq <666666666* qqqqqqq",
44"qqqqq X@@@@@@;67 qqqqqq",
45"qqqqqq .@@@@@@=6$ qqqqqq",
46"qqqqqqq .@ X@,2 qqqqqq",
47"qqqqqqqq X q +-6 qqqqqq",
48"qqqqqqqqq qq @6 qqqqqq",
49"qqqqqqqqqq qqq -: qqqqqq",
50"qqqqqqqqqqqqqq >o qqqqqq",
51"qqqqqqqqqqqqqq 5 qqqqqqq",
52"qqqqqqqqqqqqq 1O qqqqqqq",
53"qqqqqqqqqqqq &# qqqqqqqq",
54"qqqqqqqqqqqqq qqqqqqqqq",
55"qqqqqqqqqqqqqqqqqqqqqqqq",
56"qqqqqqqqqqqqqqqqqqqqqqqq",
57"qqqqqqqqqqqqqqqqqqqqqqqq"};
diff --git a/lisp/toolbar/fwd_arrow.pbm b/lisp/toolbar/fwd_arrow.pbm
new file mode 100644
index 00000000000..e08e6fa35db
--- /dev/null
+++ b/lisp/toolbar/fwd_arrow.pbm
Binary files differ
diff --git a/lisp/toolbar/fwd_arrow.xpm b/lisp/toolbar/fwd_arrow.xpm
new file mode 100644
index 00000000000..5e7c5602ea1
--- /dev/null
+++ b/lisp/toolbar/fwd_arrow.xpm
@@ -0,0 +1,70 @@
1/* XPM */
2static char *fwd_arrow_xpm[] = {
3"24 24 43 1",
4" c #000000",
5". c #53692A",
6"X c #59702D",
7"o c #657255",
8"O c #6D7A5B",
9"+ c #6D8839",
10"@ c #7C9B40",
11"# c #748261",
12"$ c #7F8E6B",
13"% c #818F71",
14"& c #879772",
15"* c #8C9A7F",
16"= c #85A24D",
17"- c #8BA859",
18"; c #92AD62",
19": c #95A77E",
20"> c #98AF74",
21", c #9BB572",
22"< c #919889",
23"1 c #92998C",
24"2 c #939A8D",
25"3 c #99A28F",
26"4 c #9BAA87",
27"5 c #9CAF84",
28"6 c #A4B690",
29"7 c #A8BCA6",
30"8 c #ADBDA0",
31"9 c #AFC394",
32"0 c #BAD09D",
33"q c #B5C3A9",
34"w c #BED2A3",
35"e c #BFD3A6",
36"r c #C2D5AA",
37"t c #C5D7AE",
38"y c #C8D9B2",
39"u c #CDDCBC",
40"i c #D1DFBE",
41"p c #D2E0BF",
42"a c #D3E0C1",
43"s c #D4E0C5",
44"d c #D5E1C6",
45"f c #FFFFFF",
46"g c None",
47"gggggggggggggggggggggggg",
48"gggggggggggggggggggggggg",
49"gggggggggggggggggggggggg",
50"ggggggggggggg gggggggggg",
51"ggggggggggggg ggggggggg",
52"ggggggggggggg 2 gggggggg",
53"gggggggggg 02 ggggggg",
54"ggggggggg &6riw03 gggggg",
55"gggggggg 7suat000< ggggg",
56"ggggggg *saie000004 gggg",
57"gggggg qs;@@@@@@X ggggg",
58"gggggg $y=@@@@@@. gggggg",
59"gggggg 6,@X @. ggggggg",
60"gggggg 0@+ g X gggggggg",
61"gggggg 0@ gg ggggggggg",
62"gggggg :- ggg gggggggggg",
63"gggggg o> gggggggggggggg",
64"ggggggg 9 gggggggggggggg",
65"ggggggg O5 ggggggggggggg",
66"gggggggg #& gggggggggggg",
67"ggggggggg ggggggggggggg",
68"gggggggggggggggggggggggg",
69"gggggggggggggggggggggggg",
70"gggggggggggggggggggggggg"};
diff --git a/lisp/toolbar/lc-back_arrow.xpm b/lisp/toolbar/lc-back_arrow.xpm
new file mode 100644
index 00000000000..05a797c7a65
--- /dev/null
+++ b/lisp/toolbar/lc-back_arrow.xpm
@@ -0,0 +1,33 @@
1/* XPM */
2static char *back_arrow_xpm[] = {
3"24 24 6 1",
4" c #000000",
5". c #000100",
6"X c #6B6B66",
7"o c #87AF85",
8"O c #FFFFFF",
9"+ c None",
10"++++++++++++++++++++++++",
11"++++++++++++++++++++++++",
12"++++++++++++++++++++++++",
13"++++++++++ +++++++++++++",
14"+++++++++ .+++++++++++++",
15"++++++++ O.+++++++++++++",
16"+++++++ Oo . ++++++++++",
17"++++++ Ooooooo +++++++++",
18"+++++ Ooooooooo ++++++++",
19"++++ ooooooooooo.+++++++",
20"+++++ oooooooooo..++++++",
21"++++++.oooooooooo.++++++",
22"+++++++.oo.. oooo.++++++",
23"++++++++.o.+ ooo.++++++",
24"+++++++++..++..oo.++++++",
25"++++++++++.+++.oo.++++++",
26"++++++++++++++.oo.++++++",
27"++++++++++++++.o.+++++++",
28"+++++++++++++.oX.+++++++",
29"++++++++++++.oo.++++++++",
30"+++++++++++++..+++++++++",
31"++++++++++++++++++++++++",
32"++++++++++++++++++++++++",
33"++++++++++++++++++++++++"};
diff --git a/lisp/toolbar/lc-fwd_arrow.xpm b/lisp/toolbar/lc-fwd_arrow.xpm
new file mode 100644
index 00000000000..284b8c9bee7
--- /dev/null
+++ b/lisp/toolbar/lc-fwd_arrow.xpm
@@ -0,0 +1,32 @@
1/* XPM */
2static char *fwd_arrow_xpm[] = {
3"24 24 5 1",
4" c #000000",
5". c #000100",
6"X c #87AF85",
7"o c #FFFFFF",
8"O c None",
9"OOOOOOOOOOOOOOOOOOOOOOOO",
10"OOOOOOOOOOOOOOOOOOOOOOOO",
11"OOOOOOOOOOOOOOOOOOOOOOOO",
12"OOOOOOOOOOOOO OOOOOOOOOO",
13"OOOOOOOOOOOOO OOOOOOOOO",
14"OOOOOOOOOOOOO X OOOOOOOO",
15"OOOOOOOOOO . XX.OOOOOOO",
16"OOOOOOOOO oXXXXXX.OOOOOO",
17"OOOOOOOO.oXXXXXXXX.OOOOO",
18"OOOOOOO.oXXXXXXXXXX.OOOO",
19"OOOOOO..XXXXXXXXXX.OOOOO",
20"OOOOOO.XXXXXXXXXX.OOOOOO",
21"OOOOOO.XXXX. XX.OOOOOOO",
22"OOOOOO.XXX..O X OOOOOOOO",
23"OOOOOO.XX..OO. OOOOOOOOO",
24"OOOOOO.XX.OOO.OOOOOOOOOO",
25"OOOOOO.XX.OOOOOOOOOOOOOO",
26"OOOOOOO.X.OOOOOOOOOOOOOO",
27"OOOOOOO.XX.OOOOOOOOOOOOO",
28"OOOOOOOO.XX.OOOOOOOOOOOO",
29"OOOOOOOOO..OOOOOOOOOOOOO",
30"OOOOOOOOOOOOOOOOOOOOOOOO",
31"OOOOOOOOOOOOOOOOOOOOOOOO",
32"OOOOOOOOOOOOOOOOOOOOOOOO"};
diff --git a/lisp/type-break.el b/lisp/type-break.el
index b51a74ea37e..3a0b8b5adcc 100644
--- a/lisp/type-break.el
+++ b/lisp/type-break.el
@@ -229,7 +229,8 @@ key is pressed."
229 :group 'type-break) 229 :group 'type-break)
230 230
231(defcustom type-break-file-name (convert-standard-filename "~/.type-break") 231(defcustom type-break-file-name (convert-standard-filename "~/.type-break")
232 "*Name of file used to save state across sessions." 232 "*Name of file used to save state across sessions.
233If this is nil, no data will be saved across sessions."
233 :type 'file 234 :type 'file
234 :group 'type-break) 235 :group 'type-break)
235 236
@@ -389,6 +390,9 @@ problems."
389 (and (interactive-p) 390 (and (interactive-p)
390 (message "Type Break mode is already enabled"))) 391 (message "Type Break mode is already enabled")))
391 (type-break-mode 392 (type-break-mode
393 (with-current-buffer (find-file-noselect type-break-file-name 'nowarn)
394 (setq buffer-save-without-query t))
395
392 (or global-mode-string 396 (or global-mode-string
393 (setq global-mode-string '(""))) 397 (setq global-mode-string '("")))
394 (or (assq 'type-break-mode-line-message-mode 398 (or (assq 'type-break-mode-line-message-mode
@@ -399,7 +403,9 @@ problems."
399 (type-break-keystroke-reset) 403 (type-break-keystroke-reset)
400 (type-break-mode-line-countdown-or-break nil) 404 (type-break-mode-line-countdown-or-break nil)
401 405
402 (setq type-break-time-last-break (type-break-get-previous-time)) 406 (setq type-break-time-last-break
407 (or (type-break-get-previous-time)
408 (current-time)))
403 409
404 ;; schedule according to break time from session file 410 ;; schedule according to break time from session file
405 (type-break-schedule 411 (type-break-schedule
@@ -431,12 +437,12 @@ problems."
431 (type-break-mode-line-countdown-or-break nil) 437 (type-break-mode-line-countdown-or-break nil)
432 (type-break-cancel-schedule) 438 (type-break-cancel-schedule)
433 (do-auto-save) 439 (do-auto-save)
434 (with-current-buffer (find-file-noselect type-break-file-name 440 (when type-break-file-name
435 'nowarn) 441 (with-current-buffer (find-file-noselect type-break-file-name
436 (setq buffer-save-without-query t) 442 'nowarn)
437 (set-buffer-modified-p nil) 443 (set-buffer-modified-p nil)
438 (unlock-buffer) 444 (unlock-buffer)
439 (kill-this-buffer)) 445 (kill-this-buffer)))
440 (and (interactive-p) 446 (and (interactive-p)
441 (message "Type Break mode is disabled"))))) 447 (message "Type Break mode is disabled")))))
442 type-break-mode) 448 type-break-mode)
@@ -496,7 +502,8 @@ variable of the same name."
496 502
497(defun type-break-file-time (&optional time) 503(defun type-break-file-time (&optional time)
498 "File break time in `type-break-file-name', unless the file is locked." 504 "File break time in `type-break-file-name', unless the file is locked."
499 (if (not (stringp (file-locked-p type-break-file-name))) 505 (if (and type-break-file-name
506 (not (stringp (file-locked-p type-break-file-name))))
500 (with-current-buffer (find-file-noselect type-break-file-name 507 (with-current-buffer (find-file-noselect type-break-file-name
501 'nowarn) 508 'nowarn)
502 (let ((inhibit-read-only t)) 509 (let ((inhibit-read-only t))
@@ -507,7 +514,8 @@ variable of the same name."
507 514
508(defun type-break-file-keystroke-count () 515(defun type-break-file-keystroke-count ()
509 "File keystroke count in `type-break-file-name', unless the file is locked." 516 "File keystroke count in `type-break-file-name', unless the file is locked."
510 (if (not (stringp (file-locked-p type-break-file-name))) 517 (if (and type-break-file-name
518 (not (stringp (file-locked-p type-break-file-name))))
511 ;; Prevent deactivation of the mark in some other buffer. 519 ;; Prevent deactivation of the mark in some other buffer.
512 (let (deactivate-mark) 520 (let (deactivate-mark)
513 (with-current-buffer (find-file-noselect type-break-file-name 521 (with-current-buffer (find-file-noselect type-break-file-name
@@ -534,6 +542,8 @@ return TIME, else return nil."
534(defun type-break-choose-file () 542(defun type-break-choose-file ()
535 "Return file to read from." 543 "Return file to read from."
536 (cond 544 (cond
545 ((not type-break-file-name)
546 nil)
537 ((and (file-exists-p type-break-auto-save-file-name) 547 ((and (file-exists-p type-break-auto-save-file-name)
538 (file-readable-p type-break-auto-save-file-name)) 548 (file-readable-p type-break-auto-save-file-name))
539 type-break-auto-save-file-name) 549 type-break-auto-save-file-name)
diff --git a/lisp/uniquify.el b/lisp/uniquify.el
index b2da7971167..ea9094da78a 100644
--- a/lisp/uniquify.el
+++ b/lisp/uniquify.el
@@ -1,6 +1,7 @@
1;;; uniquify.el --- unique buffer names dependent on file name 1;;; uniquify.el --- unique buffer names dependent on file name
2 2
3;; Copyright (c) 1989,95,96,97,2001,2003 Free Software Foundation, Inc. 3;; Copyright (c) 1989, 1995, 1996, 1997, 2001, 2003, 2005
4;; Free Software Foundation, Inc.
4 5
5;; Author: Dick King <king@reasoning.com> 6;; Author: Dick King <king@reasoning.com>
6;; Maintainer: FSF 7;; Maintainer: FSF
@@ -187,9 +188,16 @@ It actually holds the list of `uniquify-item's corresponding to the conflict.")
187If `uniquify-min-dir-content' > 0, always pulls that many 188If `uniquify-min-dir-content' > 0, always pulls that many
188file name elements. 189file name elements.
189Arguments BASE, DIRNAME, and NEWBUF specify the new buffer that causes 190Arguments BASE, DIRNAME, and NEWBUF specify the new buffer that causes
190this rationaliztion." 191this rationalization."
191 (if (null dirname) 192 (interactive
192 (with-current-buffer newbuf (setq uniquify-managed nil)) 193 (list (if uniquify-managed
194 (uniquify-item-base (car uniquify-managed)) (buffer-name))
195 (uniquify-buffer-file-name (current-buffer))
196 (current-buffer)))
197 ;; Make sure we don't get confused by outdated uniquify-managed info in
198 ;; this buffer.
199 (with-current-buffer newbuf (setq uniquify-managed nil))
200 (when dirname
193 (setq dirname (expand-file-name (directory-file-name dirname))) 201 (setq dirname (expand-file-name (directory-file-name dirname)))
194 (let ((fix-list (list (uniquify-make-item base dirname newbuf))) 202 (let ((fix-list (list (uniquify-make-item base dirname newbuf)))
195 items) 203 items)
@@ -457,5 +465,5 @@ For use on `kill-buffer-hook'."
457 465
458(provide 'uniquify) 466(provide 'uniquify)
459 467
460;;; arch-tag: e763faa3-56c9-4903-8eb8-26e1c45a0065 468;; arch-tag: e763faa3-56c9-4903-8eb8-26e1c45a0065
461;;; uniquify.el ends here 469;;; uniquify.el ends here
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 9bb5ef1c3e5..19f39265251 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,13 @@
12005-01-13 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * url.el (url-retrieve-synchronously): Use accept-process-output rather
4 than sit-for.
5
62005-01-03 Klaus Straubinger <ksnetz@arcor.de> (tiny change)
7
8 * url-http.el (url-http-handle-authentication):
9 Don't kill the current buffer.
10
12004-12-11 Stefan Monnier <monnier@iro.umontreal.ca> 112004-12-11 Stefan Monnier <monnier@iro.umontreal.ca>
2 12
3 * url-handlers.el: Don't `require' everything eagerly. 13 * url-handlers.el: Don't `require' everything eagerly.
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 8a7269e6bea..2608a85963a 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -322,8 +322,8 @@ This allows us to use `mail-fetch-field', etc."
322 (let ((url-request-method url-http-method) 322 (let ((url-request-method url-http-method)
323 (url-request-data url-http-data) 323 (url-request-data url-http-data)
324 (url-request-extra-headers url-http-extra-headers)) 324 (url-request-extra-headers url-http-extra-headers))
325 (url-retrieve url url-callback-function url-callback-arguments)))) 325 (url-retrieve url url-callback-function
326 (kill-buffer (current-buffer))))) 326 url-callback-arguments)))))))
327 327
328(defun url-http-parse-response () 328(defun url-http-parse-response ()
329 "Parse just the response code." 329 "Parse just the response code."
diff --git a/lisp/url/url.el b/lisp/url/url.el
index f94e965129a..a9fd46bc23a 100644
--- a/lisp/url/url.el
+++ b/lisp/url/url.el
@@ -1,6 +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 Free Software Foundation, Inc. 3;; Copyright (c) 1996, 1997, 1998, 1999, 2001, 2004, 2005
4;; Free Software Foundation, Inc.
4 5
5;; Author: Bill Perry <wmperry@gnu.org> 6;; Author: Bill Perry <wmperry@gnu.org>
6;; Keywords: comm, data, processes, hypermedia 7;; Keywords: comm, data, processes, hypermedia
@@ -169,26 +170,25 @@ no further processing). URL is either a string or a parsed URL."
169 (url-debug 'retrieval "Synchronous fetching done (%S)" (current-buffer)) 170 (url-debug 'retrieval "Synchronous fetching done (%S)" (current-buffer))
170 (setq retrieval-done t 171 (setq retrieval-done t
171 asynch-buffer (current-buffer))))) 172 asynch-buffer (current-buffer)))))
172 (if (not asynch-buffer) 173 (let ((proc (and asynch-buffer (get-buffer-process asynch-buffer))))
173 ;; We do not need to do anything, it was a mailto or something 174 (if (null proc)
174 ;; similar that takes processing completely outside of the URL 175 ;; We do not need to do anything, it was a mailto or something
175 ;; package. 176 ;; similar that takes processing completely outside of the URL
176 nil 177 ;; package.
177 (while (not retrieval-done) 178 nil
178 (url-debug 'retrieval "Spinning in url-retrieve-synchronously: %S (%S)" 179 (while (not retrieval-done)
179 retrieval-done asynch-buffer) 180 (url-debug 'retrieval
180 ;; Quoth Stef: 181 "Spinning in url-retrieve-synchronously: %S (%S)"
181 ;; It turns out that the problem seems to be that the (sit-for 182 retrieval-done asynch-buffer)
182 ;; 0.1) below doesn't actually process the data: instead it 183 ;; We used to use `sit-for' here, but in some cases it wouldn't
183 ;; returns immediately because there is keyboard input 184 ;; work because apparently pending keyboard input would always
184 ;; waiting, so we end up spinning endlessly waiting for the 185 ;; interrupt it before it got a chance to handle process input.
185 ;; process to finish while not letting it finish. 186 ;; `sleep-for' was tried but it lead to other forms of
186 187 ;; hanging. --Stef
187 ;; However, raman claims that it blocks Emacs with Emacspeak 188 (unless (accept-process-output proc)
188 ;; for unexplained reasons. Put back for his benefit until 189 ;; accept-process-output returned nil, maybe because the process
189 ;; someone can understand it. 190 ;; exited (and may have been replaced with another).
190 ;; (sleep-for 0.1) 191 (setq proc (get-buffer-process asynch-buffer)))))
191 (sit-for 0.1))
192 asynch-buffer))) 192 asynch-buffer)))
193 193
194(defun url-mm-callback (&rest ignored) 194(defun url-mm-callback (&rest ignored)
diff --git a/lisp/vc-arch.el b/lisp/vc-arch.el
index 70dbdcc85f2..b821928c539 100644
--- a/lisp/vc-arch.el
+++ b/lisp/vc-arch.el
@@ -1,6 +1,6 @@
1;;; vc-arch.el --- VC backend for the Arch version-control system 1;;; vc-arch.el --- VC backend for the Arch version-control system
2 2
3;; Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004 3;; Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Author: FSF (see vc.el for full credits) 6;; Author: FSF (see vc.el for full credits)
@@ -270,7 +270,7 @@ Return non-nil if FILE is unchanged."
270(defun vc-arch-workfile-version (file) 270(defun vc-arch-workfile-version (file)
271 (let* ((root (expand-file-name "{arch}" (vc-arch-root file))) 271 (let* ((root (expand-file-name "{arch}" (vc-arch-root file)))
272 (defbranch (vc-arch-default-version file))) 272 (defbranch (vc-arch-default-version file)))
273 (when (and defbranch (string-match "\\`\\(.+@[^/\n]+\\)/\\(\\(\\(.*\\)--.*\\)--.*\\)\\'" defbranch)) 273 (when (and defbranch (string-match "\\`\\(.+@[^/\n]+\\)/\\(\\(\\(.*?\\)\\(?:--.*\\)?\\)--.*\\)\\'" defbranch))
274 (let* ((archive (match-string 1 defbranch)) 274 (let* ((archive (match-string 1 defbranch))
275 (category (match-string 4 defbranch)) 275 (category (match-string 4 defbranch))
276 (branch (match-string 3 defbranch)) 276 (branch (match-string 3 defbranch))
@@ -377,7 +377,7 @@ Return non-nil if FILE is unchanged."
377 (setq newvers nil)) 377 (setq newvers nil))
378 (if newvers 378 (if newvers
379 (error "Diffing specific revisions not implemented.") 379 (error "Diffing specific revisions not implemented.")
380 (let* ((async (fboundp 'start-process)) 380 (let* ((async (and (not vc-disable-async-diff) (fboundp 'start-process)))
381 ;; Run the command from the root dir. 381 ;; Run the command from the root dir.
382 (default-directory (vc-arch-root file)) 382 (default-directory (vc-arch-root file))
383 (status 383 (status
diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el
index 22346cab68c..2bca3fb90b1 100644
--- a/lisp/vc-cvs.el
+++ b/lisp/vc-cvs.el
@@ -548,7 +548,9 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
548 (append (vc-switches nil 'diff) '("/dev/null"))) 548 (append (vc-switches nil 'diff) '("/dev/null")))
549 ;; Even if it's empty, it's locally modified. 549 ;; Even if it's empty, it's locally modified.
550 1) 550 1)
551 (let* ((async (and (vc-stay-local-p file) (fboundp 'start-process))) 551 (let* ((async (and (not vc-disable-async-diff)
552 (vc-stay-local-p file)
553 (fboundp 'start-process)))
552 (status (apply 'vc-cvs-command (or buffer "*vc-diff*") 554 (status (apply 'vc-cvs-command (or buffer "*vc-diff*")
553 (if async 'async 1) 555 (if async 'async 1)
554 file "diff" 556 file "diff"
diff --git a/lisp/vc-mcvs.el b/lisp/vc-mcvs.el
index ea577489239..aca8bcd66f0 100644
--- a/lisp/vc-mcvs.el
+++ b/lisp/vc-mcvs.el
@@ -446,7 +446,9 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
446 (append (vc-switches nil 'diff) '("/dev/null"))) 446 (append (vc-switches nil 'diff) '("/dev/null")))
447 ;; Even if it's empty, it's locally modified. 447 ;; Even if it's empty, it's locally modified.
448 1) 448 1)
449 (let* ((async (and (vc-stay-local-p file) (fboundp 'start-process))) 449 (let* ((async (and (not vc-disable-async-diff)
450 (vc-stay-local-p file)
451 (fboundp 'start-process)))
450 ;; Run the command from the root dir so that `mcvs filt' returns 452 ;; Run the command from the root dir so that `mcvs filt' returns
451 ;; valid relative names. 453 ;; valid relative names.
452 (default-directory (vc-mcvs-root file)) 454 (default-directory (vc-mcvs-root file))
diff --git a/lisp/vc-svn.el b/lisp/vc-svn.el
index cbb951d60b7..f783066b39b 100644
--- a/lisp/vc-svn.el
+++ b/lisp/vc-svn.el
@@ -1,6 +1,6 @@
1;;; vc-svn.el --- non-resident support for Subversion version-control 1;;; vc-svn.el --- non-resident support for Subversion version-control
2 2
3;; Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004 3;; Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Author: FSF (see vc.el for full credits) 6;; Author: FSF (see vc.el for full credits)
@@ -352,6 +352,10 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
352(defun vc-svn-diff (file &optional oldvers newvers buffer) 352(defun vc-svn-diff (file &optional oldvers newvers buffer)
353 "Get a difference report using SVN between two versions of FILE." 353 "Get a difference report using SVN between two versions of FILE."
354 (unless buffer (setq buffer "*vc-diff*")) 354 (unless buffer (setq buffer "*vc-diff*"))
355 (if (and oldvers (equal oldvers (vc-workfile-version file)))
356 ;; Use nil rather than the current revision because svn handles it
357 ;; better (i.e. locally).
358 (setq oldvers nil))
355 (if (string= (vc-workfile-version file) "0") 359 (if (string= (vc-workfile-version file) "0")
356 ;; This file is added but not yet committed; there is no master file. 360 ;; This file is added but not yet committed; there is no master file.
357 (if (or oldvers newvers) 361 (if (or oldvers newvers)
@@ -368,7 +372,8 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
368 (if vc-svn-diff-switches 372 (if vc-svn-diff-switches
369 (vc-switches 'SVN 'diff) 373 (vc-switches 'SVN 'diff)
370 (list "-x" (mapconcat 'identity (vc-switches nil 'diff) " ")))) 374 (list "-x" (mapconcat 'identity (vc-switches nil 'diff) " "))))
371 (async (and (vc-stay-local-p file) 375 (async (and (not vc-disable-async-diff)
376 (vc-stay-local-p file)
372 (or oldvers newvers) ; Svn diffs those locally. 377 (or oldvers newvers) ; Svn diffs those locally.
373 (fboundp 'start-process)))) 378 (fboundp 'start-process))))
374 (apply 'vc-svn-command buffer 379 (apply 'vc-svn-command buffer
diff --git a/lisp/vc.el b/lisp/vc.el
index 64de0351922..4a26b88c0e3 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -152,7 +152,7 @@
152;; have such a brief-comparison feature, the default implementation of 152;; have such a brief-comparison feature, the default implementation of
153;; this function can be used, which delegates to a full 153;; this function can be used, which delegates to a full
154;; vc-BACKEND-diff. (Note that vc-BACKEND-diff must not run 154;; vc-BACKEND-diff. (Note that vc-BACKEND-diff must not run
155;; asynchronously in this case.) 155;; asynchronously in this case, see variable `vc-disable-async-diff'.)
156;; 156;;
157;; - mode-line-string (file) 157;; - mode-line-string (file)
158;; 158;;
@@ -566,6 +566,15 @@ specific to any particular backend."
566 :group 'vc 566 :group 'vc
567 :version "21.1") 567 :version "21.1")
568 568
569(defcustom vc-allow-async-revert nil
570 "*Specifies whether the diff during \\[vc-revert-buffer] may be asynchronous.
571Enabling this option means that you can confirm a revert operation even
572if the local changes in the file have not been found and displayed yet."
573 :type '(choice (const :tag "No" nil)
574 (const :tag "Yes" t))
575 :group 'vc
576 :version "21.4")
577
569;;;###autoload 578;;;###autoload
570(defcustom vc-checkout-hook nil 579(defcustom vc-checkout-hook nil
571 "*Normal hook (list of functions) run after checking out a file. 580 "*Normal hook (list of functions) run after checking out a file.
@@ -714,6 +723,11 @@ The keys are \(BUFFER . BACKEND\). See also `vc-annotate-get-backend'.")
714(defvar vc-parent-buffer-name nil) 723(defvar vc-parent-buffer-name nil)
715(put 'vc-parent-buffer-name 'permanent-local t) 724(put 'vc-parent-buffer-name 'permanent-local t)
716 725
726(defvar vc-disable-async-diff nil
727 "VC sets this to t locally to disable some async diff operations.
728Backends that offer asynchronous diffs should respect this variable
729in their implementation of vc-BACKEND-diff.")
730
717(defvar vc-log-file) 731(defvar vc-log-file)
718(defvar vc-log-version) 732(defvar vc-log-version)
719 733
@@ -2435,11 +2449,13 @@ changes found in the master file; use \\[universal-argument] \\[vc-next-action]
2435 (unless (yes-or-no-p "File seems up-to-date. Revert anyway? ") 2449 (unless (yes-or-no-p "File seems up-to-date. Revert anyway? ")
2436 (error "Revert canceled"))) 2450 (error "Revert canceled")))
2437 (unless (vc-workfile-unchanged-p file) 2451 (unless (vc-workfile-unchanged-p file)
2452 (message "Finding changes...")
2438 ;; vc-diff selects the new window, which is not what we want: 2453 ;; vc-diff selects the new window, which is not what we want:
2439 ;; if the new window is on another frame, that'd require the user 2454 ;; if the new window is on another frame, that'd require the user
2440 ;; moving her mouse to answer the yes-or-no-p question. 2455 ;; moving her mouse to answer the yes-or-no-p question.
2441 (let ((win (save-selected-window 2456 (let* ((vc-disable-async-diff (not vc-allow-async-revert))
2442 (setq status (vc-diff nil t)) (selected-window)))) 2457 (win (save-selected-window
2458 (setq status (vc-diff nil t)) (selected-window))))
2443 (vc-exec-after `(message nil)) 2459 (vc-exec-after `(message nil))
2444 (when status 2460 (when status
2445 (unwind-protect 2461 (unwind-protect
diff --git a/lisp/woman.el b/lisp/woman.el
index 610590a2972..e4b29374a05 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -1491,7 +1491,8 @@ Also make each path-info component into a list.
1491 1491
1492(defsubst woman-dired-define-key-maybe (key) 1492(defsubst woman-dired-define-key-maybe (key)
1493 "If KEY is undefined in Dired, bind it to command `woman-dired-find-file'." 1493 "If KEY is undefined in Dired, bind it to command `woman-dired-find-file'."
1494 (if (eq (lookup-key dired-mode-map key) 'undefined) 1494 (if (or (eq (lookup-key dired-mode-map key) 'undefined)
1495 (null (lookup-key dired-mode-map key)))
1495 (woman-dired-define-key key))) 1496 (woman-dired-define-key key)))
1496 1497
1497(defun woman-dired-define-keys () 1498(defun woman-dired-define-keys ()
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 19b58475a93..5709834ab91 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -43,14 +43,17 @@
43 43
44;; Support multi-click -- somehow. 44;; Support multi-click -- somehow.
45 45
46;; Clicking on the mode-line does not work, although it should.
47
48;;; Code: 46;;; Code:
49 47
50(define-key function-key-map "\e[M" 'xterm-mouse-translate) 48(define-key function-key-map "\e[M" 'xterm-mouse-translate)
51 49
52(defvar xterm-mouse-last) 50(defvar xterm-mouse-last)
53 51
52;; Mouse events symbols must have an 'event-kind property with
53;; the value 'mouse-click.
54(dolist (event-type '(mouse-1 mouse-2 mouse-3))
55 (put event-type 'event-kind 'mouse-click))
56
54(defun xterm-mouse-translate (event) 57(defun xterm-mouse-translate (event)
55 "Read a click and release event from XTerm." 58 "Read a click and release event from XTerm."
56 (save-excursion 59 (save-excursion
@@ -78,7 +81,7 @@
78 (click-where (nth 1 click-data))) 81 (click-where (nth 1 click-data)))
79 (if (memq down-binding '(nil ignore)) 82 (if (memq down-binding '(nil ignore))
80 (if (and (symbolp click-where) 83 (if (and (symbolp click-where)
81 (not (eq 'menu-bar click-where))) 84 (consp click-where))
82 (vector (list click-where click-data) click) 85 (vector (list click-where click-data) click)
83 (vector click)) 86 (vector click))
84 (setq unread-command-events 87 (setq unread-command-events
@@ -92,10 +95,9 @@
92 0 95 0
93 (list (intern (format "drag-mouse-%d" 96 (list (intern (format "drag-mouse-%d"
94 (+ 1 xterm-mouse-last))) 97 (+ 1 xterm-mouse-last)))
95 down-data click-data)) 98 down-data click-data)))))
96 )))
97 (if (and (symbolp down-where) 99 (if (and (symbolp down-where)
98 (not (eq 'menu-bar down-where))) 100 (consp down-where))
99 (vector (list down-where down-data) down) 101 (vector (list down-where down-data) down)
100 (vector down)))))))) 102 (vector down))))))))
101 103
@@ -124,30 +126,6 @@
124 (let* ((type (- (xterm-mouse-event-read) #o40)) 126 (let* ((type (- (xterm-mouse-event-read) #o40))
125 (x (- (xterm-mouse-event-read) #o40 1)) 127 (x (- (xterm-mouse-event-read) #o40 1))
126 (y (- (xterm-mouse-event-read) #o40 1)) 128 (y (- (xterm-mouse-event-read) #o40 1))
127 (point (cons x y))
128 (window (window-at x y))
129 (where (if window
130 (coordinates-in-window-p point window)
131 'menu-bar))
132 (pos (if (consp where)
133 (progn
134 (select-window window)
135 (goto-char (window-start window))
136 (move-to-window-line (-
137 (cdr where)
138 (if (or header-line-format
139 default-header-line-format)
140 1
141 0)))
142 (move-to-column (- (+ (car where) (current-column)
143 (if (string-match "\\` \\*Minibuf"
144 (buffer-name))
145 (- (minibuffer-prompt-width))
146 0)
147 (max 0 (1- (window-hscroll))))
148 left-margin-width))
149 (point))
150 where))
151 (mouse (intern 129 (mouse (intern
152 ;; For buttons > 3, the release-event looks 130 ;; For buttons > 3, the release-event looks
153 ;; differently (see xc/programs/xterm/button.c, 131 ;; differently (see xc/programs/xterm/button.c,
@@ -159,12 +137,18 @@
159 (format "mouse-%d" (+ 1 xterm-mouse-last))) 137 (format "mouse-%d" (+ 1 xterm-mouse-last)))
160 (t 138 (t
161 (setq xterm-mouse-last type) 139 (setq xterm-mouse-last type)
162 (format "down-mouse-%d" (+ 1 type))))))) 140 (format "down-mouse-%d" (+ 1 type))))))
141 (w (window-at x y))
142 (ltrb (window-edges w))
143 (left (nth 0 ltrb))
144 (top (nth 1 ltrb)))
145
163 (setq xterm-mouse-x x 146 (setq xterm-mouse-x x
164 xterm-mouse-y y) 147 xterm-mouse-y y)
165 (list mouse 148 (if w
166 (list window pos point 149 (list mouse (posn-at-x-y (- x left) (- y top) w))
167 (/ (nth 2 (current-time)) 1000))))) 150 (list mouse
151 (append (list nil 'menu-bar) (nthcdr 2 (posn-at-x-y x y w)))))))
168 152
169;;;###autoload 153;;;###autoload
170(define-minor-mode xterm-mouse-mode 154(define-minor-mode xterm-mouse-mode