aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2012-11-13 23:24:26 +0900
committerKenichi Handa2012-11-13 23:24:26 +0900
commit0cdbf84521791935fdfeabf2e84f585cc64db325 (patch)
tree68a169af3af4a8859685682ab07c05e8f9ff93b3
parente1bf05c1fbf63087801c242208212df133921ed1 (diff)
parent5745cae6984ed60299a89485aaea8f2f3fb67382 (diff)
downloademacs-0cdbf84521791935fdfeabf2e84f585cc64db325.tar.gz
emacs-0cdbf84521791935fdfeabf2e84f585cc64db325.zip
merge trunk
-rw-r--r--doc/emacs/ChangeLog52
-rw-r--r--doc/emacs/ack.texi8
-rw-r--r--doc/emacs/buffers.texi186
-rw-r--r--doc/emacs/building.texi4
-rw-r--r--doc/emacs/dired.texi20
-rw-r--r--doc/emacs/display.texi28
-rw-r--r--doc/emacs/emacs.texi3
-rw-r--r--doc/emacs/files.texi23
-rw-r--r--doc/emacs/mini.texi54
-rw-r--r--doc/emacs/misc.texi58
-rw-r--r--doc/emacs/trouble.texi59
-rw-r--r--doc/lispref/ChangeLog58
-rw-r--r--doc/lispref/control.texi13
-rw-r--r--doc/lispref/debugging.texi29
-rw-r--r--doc/lispref/edebug.texi4
-rw-r--r--doc/lispref/elisp.texi7
-rw-r--r--doc/lispref/errors.texi3
-rw-r--r--doc/lispref/frames.texi14
-rw-r--r--doc/lispref/lists.texi44
-rw-r--r--doc/lispref/os.texi49
-rw-r--r--doc/lispref/searching.texi27
-rw-r--r--doc/lispref/variables.texi123
-rw-r--r--doc/lispref/windows.texi528
-rw-r--r--doc/misc/ChangeLog49
-rw-r--r--doc/misc/cl.texi151
-rw-r--r--doc/misc/flymake.texi20
-rw-r--r--doc/misc/ses.texi123
-rw-r--r--doc/misc/texinfo.tex37
-rw-r--r--doc/misc/url.texi644
-rw-r--r--etc/ERC-NEWS4
-rw-r--r--etc/GNUS-NEWS3
-rw-r--r--etc/NEWS240
-rw-r--r--lib/makefile.w32-in12
-rw-r--r--lisp/ChangeLog338
-rw-r--r--lisp/ansi-color.el57
-rw-r--r--lisp/cedet/ChangeLog21
-rw-r--r--lisp/cedet/semantic/grammar.el4
-rw-r--r--lisp/cedet/semantic/mru-bookmark.el6
-rw-r--r--lisp/cedet/semantic/util-modes.el12
-rw-r--r--lisp/cedet/srecode/srt-mode.el4
-rw-r--r--lisp/emacs-lisp/advice.el404
-rw-r--r--lisp/emacs-lisp/bytecomp.el42
-rw-r--r--lisp/emacs-lisp/cl-extra.el7
-rw-r--r--lisp/emacs-lisp/cl-lib.el7
-rw-r--r--lisp/emacs-lisp/cl-loaddefs.el23
-rw-r--r--lisp/emacs-lisp/cl-macs.el19
-rw-r--r--lisp/emacs-lisp/cl.el74
-rw-r--r--lisp/emacs-lisp/debug.el189
-rw-r--r--lisp/emacs-lisp/elp.el332
-rw-r--r--lisp/emacs-lisp/gv.el38
-rw-r--r--lisp/emacs-lisp/nadvice.el365
-rw-r--r--lisp/env.el23
-rw-r--r--lisp/files.el49
-rw-r--r--lisp/gnus/ChangeLog5
-rw-r--r--lisp/gnus/gnus-art.el10
-rw-r--r--lisp/help.el2
-rw-r--r--lisp/ibuffer.el14
-rw-r--r--lisp/ido.el6
-rw-r--r--lisp/mail/emacsbug.el88
-rw-r--r--lisp/minibuf-eldef.el20
-rw-r--r--lisp/minibuffer.el8
-rw-r--r--lisp/net/tramp.el32
-rw-r--r--lisp/notifications.el33
-rw-r--r--lisp/progmodes/flymake.el30
-rw-r--r--lisp/progmodes/js.el35
-rw-r--r--lisp/progmodes/perl-mode.el121
-rw-r--r--lisp/progmodes/python.el137
-rw-r--r--lisp/progmodes/ruby-mode.el57
-rw-r--r--lisp/progmodes/sql.el47
-rw-r--r--lisp/server.el9
-rw-r--r--lisp/ses.el92
-rw-r--r--lisp/subr.el29
-rw-r--r--lisp/term.el18
-rw-r--r--lisp/textmodes/ispell.el284
-rw-r--r--lisp/vc/diff-mode.el96
-rw-r--r--lisp/window.el37
-rw-r--r--lisp/woman.el4
-rw-r--r--src/.gdbinit49
-rw-r--r--src/ChangeLog352
-rw-r--r--src/alloc.c193
-rw-r--r--src/buffer.c28
-rw-r--r--src/buffer.h31
-rw-r--r--src/category.c4
-rw-r--r--src/composite.c4
-rw-r--r--src/data.c70
-rw-r--r--src/dispnew.c84
-rw-r--r--src/doc.c35
-rw-r--r--src/emacs.c4
-rw-r--r--src/eval.c21
-rw-r--r--src/fileio.c10
-rw-r--r--src/fns.c178
-rw-r--r--src/font.c40
-rw-r--r--src/fontset.c9
-rw-r--r--src/frame.c343
-rw-r--r--src/frame.h4
-rw-r--r--src/image.c4
-rw-r--r--src/keyboard.c21
-rw-r--r--src/lisp.h204
-rw-r--r--src/lread.c2
-rw-r--r--src/makefile.w32-in4
-rw-r--r--src/nsfont.m15
-rw-r--r--src/nsterm.m34
-rw-r--r--src/print.c8
-rw-r--r--src/profiler.c91
-rw-r--r--src/ralloc.c34
-rw-r--r--src/regex.c2
-rw-r--r--src/termhooks.h18
-rw-r--r--src/terminal.c9
-rw-r--r--src/w32fns.c44
-rw-r--r--src/w32term.c13
-rw-r--r--src/w32term.h11
-rw-r--r--src/window.c169
-rw-r--r--src/xdisp.c81
-rw-r--r--src/xfaces.c130
-rw-r--r--src/xfns.c56
-rw-r--r--src/xmenu.c5
-rw-r--r--src/xselect.c21
-rw-r--r--src/xterm.c55
-rw-r--r--src/xterm.h6
-rw-r--r--test/ChangeLog11
-rw-r--r--test/automated/advice-tests.el73
-rw-r--r--test/automated/ruby-mode-tests.el44
122 files changed, 5154 insertions, 3375 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index c7cbc78f910..fbdb6363b34 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,55 @@
12012-11-13 Chong Yidong <cyd@gnu.org>
2
3 * building.texi (Multithreaded Debugging): gdb-stopped-hooks is
4 actually named gdb-stopped-functions.
5
62012-11-13 Glenn Morris <rgm@gnu.org>
7
8 * misc.texi (Single Shell): Mention async-shell-command-buffer.
9
102012-11-10 Glenn Morris <rgm@gnu.org>
11
12 * misc.texi (Terminal emulator): Rename `term-face' to `term'.
13
14 * emacs.texi (Acknowledgments): Add profiler author.
15 * ack.texi (Acknowledgments): Add some recent contributions.
16
172012-11-10 Chong Yidong <cyd@gnu.org>
18
19 * files.texi (Diff Mode): Doc fixes for
20 diff-delete-trailing-whitespace (Bug#12831).
21
22 * trouble.texi (Crashing): Copyedits.
23
242012-11-10 Glenn Morris <rgm@gnu.org>
25
26 * files.texi (Diff Mode): Trailing whitespace updates.
27
282012-11-10 Chong Yidong <cyd@gnu.org>
29
30 * misc.texi (Terminal emulator): Document Term mode faces.
31
32 * mini.texi (Basic Minibuffer): New node. Document
33 minibuffer-electric-default-mode.
34
35 * display.texi (Visual Line Mode): Fix index entry.
36
37 * buffers.texi (Several Buffers): List Buffer Menu command anmes,
38 and index the keybindings. Document tabulated-list-sort.
39 (Kill Buffer): Capitalize Buffer Menu.
40
41 * trouble.texi (Memory Full): Capitalize Buffer Menu.
42
432012-11-10 Eli Zaretskii <eliz@gnu.org>
44
45 * display.texi (Auto Scrolling): Clarify that scroll-step is
46 ignored when scroll-conservatively is set to a non-zero value.
47 (Bug#12801)
48
492012-11-10 Chong Yidong <cyd@gnu.org>
50
51 * dired.texi (Dired Updating): Doc fix (Bug#11744).
52
12012-10-30 Michael Albinus <michael.albinus@gmx.de> 532012-10-30 Michael Albinus <michael.albinus@gmx.de>
2 54
3 * trouble.texi (Known Problems): Mention command `debbugs-gnu-usertags'. 55 * trouble.texi (Known Problems): Mention command `debbugs-gnu-usertags'.
diff --git a/doc/emacs/ack.texi b/doc/emacs/ack.texi
index 79710f4992b..9fdead70f8a 100644
--- a/doc/emacs/ack.texi
+++ b/doc/emacs/ack.texi
@@ -244,8 +244,9 @@ files as ``thumbnails''.
244 244
245@item 245@item
246Julien Danjou wrote an implementation of ``Desktop Notifications'' 246Julien Danjou wrote an implementation of ``Desktop Notifications''
247(@file{notifications.el}); and @file{color.el}, a library for general 247(@file{notifications.el}, and related packages for ERC and Gnus);
248color manipulation. He also made various contributions to Gnus. 248and @file{color.el}, a library for general color manipulation.
249He also made various contributions to Gnus.
249 250
250@item 251@item
251Vivek Dasmohapatra wrote @file{htmlfontify.el}, to convert a buffer or 252Vivek Dasmohapatra wrote @file{htmlfontify.el}, to convert a buffer or
@@ -790,6 +791,9 @@ mode-sensitive insertion of text into new files.
790Yukihiro Matsumoto and Nobuyoshi Nakada wrote Ruby-mode. 791Yukihiro Matsumoto and Nobuyoshi Nakada wrote Ruby-mode.
791 792
792@item 793@item
794Tomohiro Matsuyama wrote the native Elisp profiler.
795
796@item
793Thomas May wrote @file{blackbox.el}, a version of the traditional 797Thomas May wrote @file{blackbox.el}, a version of the traditional
794blackbox game. 798blackbox game.
795 799
diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi
index dfd8f792300..8c6705cc0c9 100644
--- a/doc/emacs/buffers.texi
+++ b/doc/emacs/buffers.texi
@@ -309,7 +309,7 @@ whose names begin with a space, which are used internally by Emacs.
309To kill internal buffers as well, call @code{kill-matching-buffers} 309To kill internal buffers as well, call @code{kill-matching-buffers}
310with a prefix argument. 310with a prefix argument.
311 311
312 The buffer menu feature is also convenient for killing various 312 The Buffer Menu feature is also convenient for killing various
313buffers. @xref{Several Buffers}. 313buffers. @xref{Several Buffers}.
314 314
315@vindex kill-buffer-hook 315@vindex kill-buffer-hook
@@ -339,7 +339,7 @@ the Customization buffer to set the variable @code{midnight-mode} to
339 339
340@node Several Buffers 340@node Several Buffers
341@section Operating on Several Buffers 341@section Operating on Several Buffers
342@cindex buffer menu 342@cindex Buffer Menu
343 343
344@table @kbd 344@table @kbd
345@item M-x buffer-menu 345@item M-x buffer-menu
@@ -348,7 +348,7 @@ Begin editing a buffer listing all Emacs buffers.
348Similar, but do it in another window. 348Similar, but do it in another window.
349@end table 349@end table
350 350
351 The @dfn{buffer menu} opened by @kbd{C-x C-b} (@pxref{List Buffers}) 351 The @dfn{Buffer Menu} opened by @kbd{C-x C-b} (@pxref{List Buffers})
352does not merely list buffers. It also allows you to perform various 352does not merely list buffers. It also allows you to perform various
353operations on buffers, through an interface similar to Dired 353operations on buffers, through an interface similar to Dired
354(@pxref{Dired}). You can save buffers, kill them (here called 354(@pxref{Dired}). You can save buffers, kill them (here called
@@ -356,106 +356,169 @@ operations on buffers, through an interface similar to Dired
356 356
357@findex buffer-menu 357@findex buffer-menu
358@findex buffer-menu-other-window 358@findex buffer-menu-other-window
359 To use the buffer menu, type @kbd{C-x C-b} and switch to the window 359 To use the Buffer Menu, type @kbd{C-x C-b} and switch to the window
360displaying the @file{*Buffer List*} buffer. You can also type 360displaying the @file{*Buffer List*} buffer. You can also type
361@kbd{M-x buffer-menu} to open the buffer menu in the selected window. 361@kbd{M-x buffer-menu} to open the Buffer Menu in the selected window.
362Alternatively, the command @kbd{M-x buffer-menu-other-window} opens 362Alternatively, the command @kbd{M-x buffer-menu-other-window} opens
363the buffer menu in another window, and selects that window. 363the Buffer Menu in another window, and selects that window.
364 364
365 The buffer menu is a read-only buffer, and can be changed only 365 The Buffer Menu is a read-only buffer, and can be changed only
366through the special commands described in this section. The usual 366through the special commands described in this section. The usual
367cursor motion commands can be used in this buffer. The 367cursor motion commands can be used in this buffer. The following
368following commands apply to the buffer described on the current line: 368commands apply to the buffer described on the current line:
369 369
370@table @kbd 370@table @kbd
371@item d 371@item d
372Request to delete (kill) the buffer, then move down. The request 372@findex Buffer-menu-delete
373shows as a @samp{D} on the line, before the buffer name. Requested 373@kindex d @r{(Buffer Menu)}
374deletions take place when you type the @kbd{x} command. 374Flag the buffer for deletion (killing), then move point to the next
375line (@code{Buffer-menu-delete}). The deletion flag is indicated by
376the character @samp{D} on the line, before the buffer name. The
377deletion occurs only when you type the @kbd{x} command (see below).
378
375@item C-d 379@item C-d
376Like @kbd{d} but move up afterwards instead of down. 380@findex Buffer-menu-delete-backwards
381@kindex C-d @r{(Buffer Menu)}
382Like @kbd{d}, but move point up instead of down
383(@code{Buffer-menu-delete-backwards}).
384
377@item s 385@item s
378Request to save the buffer. The request shows as an @samp{S} on the 386@findex Buffer-menu-save
379line. Requested saves take place when you type the @kbd{x} command. 387@kindex s @r{(Buffer Menu)}
380You may request both saving and deletion for the same buffer. 388Flag the buffer for saving (@code{Buffer-menu-save}). The save flag
389is indicated by the character @samp{S} on the line, before the buffer
390name. The saving occurs only when you type @kbd{x}. You may request
391both saving and deletion for the same buffer.
392
381@item x 393@item x
382Perform previously requested deletions and saves. 394@findex Buffer-menu-execute
395@kindex x @r{(Buffer Menu)}
396Perform all flagged deletions and saves (@code{Buffer-menu-execute}).
397
383@item u 398@item u
384Remove any request made for the current line, and move down. 399@findex Buffer-menu-unmark
400@kindex u @r{(Buffer Menu)}
401Remove all flags from the current line, and move down
402(@code{Buffer-menu-unmark}).
403
385@item @key{DEL} 404@item @key{DEL}
386Move to previous line and remove any request made for that line. 405@findex Buffer-menu-backup-unmark
406@kindex DEL @r{(Buffer Menu)}
407Move to the previous line and remove all flags on that line
408(@code{Buffer-menu-backup-unmark}).
387@end table 409@end table
388 410
389 The @kbd{d}, @kbd{C-d}, @kbd{s} and @kbd{u} commands to add or remove 411@noindent
390flags also move down (or up) one line. They accept a numeric argument 412The commands for adding or removing flags, @kbd{d}, @kbd{C-d}, @kbd{s}
391as a repeat count. 413and @kbd{u}, all accept a numeric argument as a repeat count.
392 414
393 These commands operate immediately on the buffer listed on the current 415 The following commands operate immediately on the buffer listed on
394line: 416the current line. They also accept a numeric argument as a repeat
417count.
395 418
396@table @kbd 419@table @kbd
397@item ~ 420@item ~
398Mark the buffer ``unmodified''. The command @kbd{~} does this 421@findex Buffer-menu-not-modified
399immediately when you type it. 422@kindex ~ @r{(Buffer Menu)}
423Mark the buffer as unmodified (@code{Buffer-menu-not-modified}).
424@xref{Save Commands}.
425
400@item % 426@item %
401Toggle the buffer's read-only flag. The command @kbd{%} does 427@findex Buffer-menu-toggle-read-only
402this immediately when you type it. 428@kindex % @r{(Buffer Menu)}
429Toggle the buffer's read-only status
430(@code{Buffer-menu-toggle-read-only}). @xref{Misc Buffer}.
431
403@item t 432@item t
404Visit the buffer as a tags table. @xref{Select Tags Table}. 433@findex Buffer-menu-visit-tags-table
434@kindex % @r{(Buffer Menu)}
435Visit the buffer as a tags table
436(@code{Buffer-menu-visit-tags-table}). @xref{Select Tags Table}.
405@end table 437@end table
406 438
407 There are also commands to select another buffer or buffers: 439 The following commands are used to select another buffer or buffers:
408 440
409@table @kbd 441@table @kbd
410@item q 442@item q
411Quit the buffer menu---immediately display the most recent formerly 443@findex quit-window
412visible buffer in its place. 444@kindex q @r{(Buffer Menu)}
445Quit the Buffer Menu (@code{quit-window}). The most recent formerly
446visible buffer is displayed in its place.
447
413@item @key{RET} 448@item @key{RET}
414@itemx f 449@itemx f
415Immediately select this line's buffer in place of the @file{*Buffer 450@findex Buffer-menu-this-window
416List*} buffer. 451@kindex f @r{(Buffer Menu)}
452@kindex RET @r{(Buffer Menu)}
453Select this line's buffer, replacing the @file{*Buffer List*} buffer
454in its window (@code{Buffer-menu-this-window}).
455
417@item o 456@item o
418Immediately select this line's buffer in another window as if by 457@findex Buffer-menu-other-window
419@kbd{C-x 4 b}, leaving @file{*Buffer List*} visible. 458@kindex o @r{(Buffer Menu)}
459Select this line's buffer in another window, as if by @kbd{C-x 4 b},
460leaving @file{*Buffer List*} visible
461(@code{Buffer-menu-other-window}).
462
420@item C-o 463@item C-o
421Immediately display this line's buffer in another window, but don't 464@findex Buffer-menu-switch-other-window
422select the window. 465@kindex C-o @r{(Buffer Menu)}
466Display this line's buffer in another window, without selecting it
467(@code{Buffer-menu-switch-other-window}).
468
423@item 1 469@item 1
424Immediately select this line's buffer in a full-screen window. 470@findex Buffer-menu-1-window
471@kindex 1 @r{(Buffer Menu)}
472Select this line's buffer in a full-frame window
473(@code{Buffer-menu-1-window}).
474
425@item 2 475@item 2
426Immediately set up two windows, with this line's buffer selected in 476@findex Buffer-menu-2-window
427one, and the previously current buffer (aside from the buffer 477@kindex 2 @r{(Buffer Menu)}
428@file{*Buffer List*}) displayed in the other. 478Set up two windows on the current frame, with this line's buffer
479selected in one, and a previously current buffer (aside from
480@file{*Buffer List*}) in the other (@code{Buffer-menu-2-window}).
481
429@item b 482@item b
430Bury the buffer listed on this line. 483@findex Buffer-menu-bury
484@kindex b @r{(Buffer Menu)}
485Bury this line's buffer (@code{Buffer-menu-bury}).
486
431@item m 487@item m
488@findex Buffer-menu-mark
489@kindex m @r{(Buffer Menu)}
432Mark this line's buffer to be displayed in another window if you exit 490Mark this line's buffer to be displayed in another window if you exit
433with the @kbd{v} command. The request shows as a @samp{>} at the 491with the @kbd{v} command (@code{Buffer-menu-mark}). The display flag
434beginning of the line. (A single buffer may not have both a delete 492is indicated by the character @samp{>} at the beginning of the line.
435request and a display request.) 493(A single buffer may not have both deletion and display flags.)
494
436@item v 495@item v
437Immediately select this line's buffer, and also display in other windows 496@findex Buffer-menu-select
438any buffers previously marked with the @kbd{m} command. If you have not 497@kindex v @r{(Buffer Menu)}
439marked any buffers, this command is equivalent to @kbd{1}. 498Select this line's buffer, and also display in other windows any
499buffers flagged with the @kbd{m} command (@code{Buffer-menu-select}).
500If you have not flagged any buffers, this command is equivalent to
501@kbd{1}.
440@end table 502@end table
441 503
442 There is also a command that affects the entire buffer list: 504 The following commands affect the entire buffer list:
443 505
444@table @kbd 506@table @kbd
507@item S
508@findex tabulated-list-sort
509@kindex S @r{(Buffer Menu)}
510Sort the Buffer Menu entries according to their values in the column
511at point. With a numeric prefix argument @var{n}, sort according to
512the @var{n}-th column (@code{tabulated-list-sort}).
513
445@item T 514@item T
446Delete, or reinsert, lines for non-file buffers. This command toggles 515@findex Buffer-menu-toggle-files-only
447the inclusion of such buffers in the buffer list. 516@kindex T @r{(Buffer Menu)}
517Delete, or reinsert, lines for non-file buffers
518@code{Buffer-menu-toggle-files-only}). This command toggles the
519inclusion of such buffers in the buffer list.
448@end table 520@end table
449 521
450 What @code{buffer-menu} actually does is create and switch to a
451suitable buffer, and turn on Buffer Menu mode in it. Everything else
452described above is implemented by the special commands provided in
453Buffer Menu mode. One consequence of this is that you can switch from
454the @file{*Buffer List*} buffer to another Emacs buffer, and edit
455there. You can reselect the @file{*Buffer List*} buffer later, to
456perform the operations already requested, or you can kill it, or pay
457no further attention to it.
458
459 Normally, the buffer @file{*Buffer List*} is not updated 522 Normally, the buffer @file{*Buffer List*} is not updated
460automatically when buffers are created and killed; its contents are 523automatically when buffers are created and killed; its contents are
461just text. If you have created, deleted or renamed buffers, the way 524just text. If you have created, deleted or renamed buffers, the way
@@ -633,7 +696,6 @@ C-b}. To customize this buffer list, use the @code{bs} Custom group
633@findex msb-mode 696@findex msb-mode
634@cindex mode, MSB 697@cindex mode, MSB
635@cindex MSB mode 698@cindex MSB mode
636@cindex buffer menu
637@findex mouse-buffer-menu 699@findex mouse-buffer-menu
638@kindex C-Down-Mouse-1 700@kindex C-Down-Mouse-1
639 MSB global minor mode (``MSB'' stands for ``mouse select buffer'') 701 MSB global minor mode (``MSB'' stands for ``mouse select buffer'')
diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index 3a3630138de..e0ea72902fb 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -1244,8 +1244,8 @@ depending on the reason which caused the stop. Customize the variable
1244@code{gdb-switch-reasons} to select the stop reasons which will cause 1244@code{gdb-switch-reasons} to select the stop reasons which will cause
1245a thread switch. 1245a thread switch.
1246 1246
1247@vindex gdb-stopped-hooks 1247@vindex gdb-stopped-functions
1248 The variable @code{gdb-stopped-hooks} allows you to execute your 1248 The variable @code{gdb-stopped-functions} allows you to execute your
1249functions whenever some thread stops. 1249functions whenever some thread stops.
1250 1250
1251 In non-stop mode, you can switch between different modes for GUD 1251 In non-stop mode, you can switch between different modes for GUD
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index c08dc02b04b..69b72b2c73a 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -1170,17 +1170,17 @@ automatically when you revisit it, by setting the variable
1170 1170
1171@kindex k @r{(Dired)} 1171@kindex k @r{(Dired)}
1172@findex dired-do-kill-lines 1172@findex dired-do-kill-lines
1173 To delete the specified @emph{file lines} from the buffer---not 1173 To delete @emph{file lines} from the buffer---without actually
1174delete the files---type @kbd{k} (@code{dired-do-kill-lines}). Like 1174deleting the files---type @kbd{k} (@code{dired-do-kill-lines}). Like
1175the file-operating commands, this command operates on the next @var{n} 1175the file-operating commands, this command operates on the next @var{n}
1176files, or on the marked files if any; but it does not operate on the 1176files, or on the marked files if any. However, it does not operate on
1177current file as a last resort. 1177the current file, since otherwise mistyping @kbd{k} could be annoying.
1178 1178
1179 If you use @kbd{k} with a numeric prefix argument to kill the line 1179 If you use @kbd{k} to kill the line for a directory file which you
1180for a file that is a directory, which you have inserted in the Dired 1180had inserted in the Dired buffer as a subdirectory
1181buffer as a subdirectory, it removed that subdirectory line from the 1181(@pxref{Subdirectories in Dired}), it removes the subdirectory listing
1182buffer as well. Typing @kbd{C-u k} on the header line for a 1182as well. Typing @kbd{C-u k} on the header line for a subdirectory
1183subdirectory also removes the subdirectory line from the Dired buffer. 1183also removes the subdirectory line from the Dired buffer.
1184 1184
1185 The @kbd{g} command brings back any individual lines that you have 1185 The @kbd{g} command brings back any individual lines that you have
1186killed in this way, but not subdirectories---you must use @kbd{i} to 1186killed in this way, but not subdirectories---you must use @kbd{i} to
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 90bfcf147c5..b6ab4913f9c 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -221,20 +221,27 @@ visible portion of the text.
221if you set @code{scroll-conservatively} to a small number @var{n}, 221if you set @code{scroll-conservatively} to a small number @var{n},
222then if you move point just a little off the screen (less than @var{n} 222then if you move point just a little off the screen (less than @var{n}
223lines), Emacs scrolls the text just far enough to bring point back on 223lines), Emacs scrolls the text just far enough to bring point back on
224screen. By default, @code{scroll-conservatively} is@tie{}0. If you 224screen. If doing so fails to make point visible, Emacs centers point
225set @code{scroll-conservatively} to a large number (larger than 100), 225in the window. By default, @code{scroll-conservatively} is@tie{}0.
226Emacs will never center point as result of scrolling, even if point 226If you set @code{scroll-conservatively} to a large number (larger than
227moves far away from the text previously displayed in the window. With 227100), Emacs will never center point as result of scrolling, even if
228such a large value, Emacs will always scroll text just enough for 228point moves far away from the text previously displayed in the window.
229With such a large value, Emacs will always scroll text just enough for
229bringing point into view, so point will end up at the top or bottom of 230bringing point into view, so point will end up at the top or bottom of
230the window, depending on the scroll direction. 231the window, depending on the scroll direction.
231 232
232@vindex scroll-step 233@vindex scroll-step
233 The variable @code{scroll-step} determines how many lines to scroll 234 An alternative way of controlling how Emacs scrolls text is by
234the window when point moves off the screen. If moving by that number 235customizing the variable @code{scroll-step}. Its value determines how
235of lines fails to bring point back into view, point is centered 236many lines to scroll the window when point moves off the screen. If
236instead. The default value is zero, which causes point to always be 237moving by that number of lines fails to bring point back into view,
237centered after scrolling. 238point is centered instead. The default value is zero, which causes
239point to always be centered after scrolling.
240
241 Since both @code{scroll-conservatively} and @code{scroll-step}
242control automatic scrolling in contradicting ways, you should set only
243one of them. If you customize both, the value of
244@code{scroll-conservatively} takes precedence.
238 245
239@cindex aggressive scrolling 246@cindex aggressive scrolling
240@vindex scroll-up-aggressively 247@vindex scroll-up-aggressively
@@ -1493,6 +1500,7 @@ attempts to wrap the line at word boundaries near the right window
1493edge. This makes the text easier to read, as wrapping does not occur 1500edge. This makes the text easier to read, as wrapping does not occur
1494in the middle of words. 1501in the middle of words.
1495 1502
1503@cindex mode, Visual Line
1496@cindex Visual Line mode 1504@cindex Visual Line mode
1497@findex visual-line-mode 1505@findex visual-line-mode
1498@findex global-visual-line-mode 1506@findex global-visual-line-mode
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index e7e0feb9e88..005215de645 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -261,6 +261,7 @@ Basic Editing Commands
261 261
262The Minibuffer 262The Minibuffer
263 263
264* Basic Minibuffer:: Basic usage of the minibuffer.
264* Minibuffer File:: Entering file names with the minibuffer. 265* Minibuffer File:: Entering file names with the minibuffer.
265* Minibuffer Edit:: How to edit in the minibuffer. 266* Minibuffer Edit:: How to edit in the minibuffer.
266* Completion:: An abbreviation facility for minibuffer input. 267* Completion:: An abbreviation facility for minibuffer input.
@@ -1402,7 +1403,7 @@ Martin Lorentzon, Dave Love, Eric Ludlam, Károly L@H{o}rentey, Sascha
1402Lüdecke, Greg McGary, Roland McGrath, Michael McNamara, Alan Mackenzie, 1403Lüdecke, Greg McGary, Roland McGrath, Michael McNamara, Alan Mackenzie,
1403Christopher J.@: Madsen, Neil M.@: Mager, Ken Manheimer, Bill Mann, 1404Christopher J.@: Madsen, Neil M.@: Mager, Ken Manheimer, Bill Mann,
1404Brian Marick, Simon Marshall, Bengt Martensson, Charlie Martin, 1405Brian Marick, Simon Marshall, Bengt Martensson, Charlie Martin,
1405Yukihiro Matsumoto, David Maus, Thomas May, Will Mengarini, David 1406Yukihiro Matsumoto, Tomohiro Matsuyama, David Maus, Thomas May, Will Mengarini, David
1406Megginson, Stefan Merten, Ben A.@: Mesander, Wayne Mesard, Brad 1407Megginson, Stefan Merten, Ben A.@: Mesander, Wayne Mesard, Brad
1407Miller, Lawrence Mitchell, Richard Mlynarik, Gerd Moellmann, Stefan 1408Miller, Lawrence Mitchell, Richard Mlynarik, Gerd Moellmann, Stefan
1408Monnier, Keith Moore, Jan Moringen, Morioka Tomohiko, Glenn Morris, 1409Monnier, Keith Moore, Jan Moringen, Morioka Tomohiko, Glenn Morris,
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 36cd3658e2d..8b609891caf 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1341,7 +1341,7 @@ contents of the hunk.
1341 You can edit a Diff mode buffer like any other buffer. (If it is 1341 You can edit a Diff mode buffer like any other buffer. (If it is
1342read-only, you need to make it writable first. @xref{Misc Buffer}.) 1342read-only, you need to make it writable first. @xref{Misc Buffer}.)
1343Whenever you change a hunk, Diff mode attempts to automatically 1343Whenever you change a hunk, Diff mode attempts to automatically
1344correct the line numbers in the hunk headers, to ensure that the diff 1344correct the line numbers in the hunk headers, to ensure that the patch
1345remains ``correct''. To disable automatic line number correction, 1345remains ``correct''. To disable automatic line number correction,
1346change the variable @code{diff-update-on-the-fly} to @code{nil}. 1346change the variable @code{diff-update-on-the-fly} to @code{nil}.
1347 1347
@@ -1470,11 +1470,22 @@ name from the patch itself. This is useful for making log entries for
1470functions that are deleted by the patch. 1470functions that are deleted by the patch.
1471@end table 1471@end table
1472 1472
1473 By default, Diff mode highlights trailing whitespace on modified 1473@c Trailing whitespace is NOT shown by default.
1474lines, so that they are more obvious. This is done by enabling 1474@c Emacs's dir-locals file enables this (for some reason).
1475Whitespace mode in the Diff buffer (@pxref{Useless Whitespace}). Diff 1475@cindex trailing whitespace, in patches
1476mode buffers are set up so that Whitespace mode avoids highlighting 1476@findex diff-delete-trailing-whitespace
1477trailing whitespace occurring in the diff context. 1477 Patches sometimes include trailing whitespace on modified lines, as
1478an unintentional and undesired change. There are two ways to deal
1479with this problem. Firstly, if you enable Whitespace mode in a Diff
1480buffer (@pxref{Useless Whitespace}), it automatically highlights
1481trailing whitespace in modified lines. Secondly, you can use the
1482command @kbd{M-x diff-delete-trailing-whitespace}, which searches for
1483trailing whitespace in the lines modified by the patch, and removes
1484that whitespace in both the patch and the patched source file(s).
1485This command does not save the modifications that it makes, so you can
1486decide whether to save the changes (the list of modified files is
1487displayed in the echo area). With a prefix argument, it tries to
1488modify the original source files rather than the patched source files.
1478 1489
1479@node Misc File Ops 1490@node Misc File Ops
1480@section Miscellaneous File Operations 1491@section Miscellaneous File Operations
diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index e5a84bda56d..ebccedacc05 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -13,24 +13,54 @@ special-purpose buffer with a small amount of screen space. You can
13use the usual Emacs editing commands in the minibuffer to edit the 13use the usual Emacs editing commands in the minibuffer to edit the
14argument text. 14argument text.
15 15
16@menu
17* Basic Minibuffer:: Basic usage of the minibuffer.
18* Minibuffer File:: Entering file names with the minibuffer.
19* Minibuffer Edit:: How to edit in the minibuffer.
20* Completion:: An abbreviation facility for minibuffer input.
21* Minibuffer History:: Reusing recent minibuffer arguments.
22* Repetition:: Re-executing commands that used the minibuffer.
23* Passwords:: Entering passwords in the echo area.
24* Yes or No Prompts:: Replying yes or no in the echo area.
25@end menu
26
27@node Basic Minibuffer
28@section Using the Minibuffer
29
16@cindex prompt 30@cindex prompt
17 When the minibuffer is in use, it appears in the echo area, with a 31 When the minibuffer is in use, it appears in the echo area, with a
18cursor. The minibuffer starts with a @dfn{prompt} in a distinct 32cursor. The minibuffer starts with a @dfn{prompt}, usually ending
19color, usually ending with a colon. The prompt states what kind of 33with a colon. The prompt states what kind of input is expected, and
20input is expected, and how it will be used. 34how it will be used. The prompt is highlighted using the
35@code{minibuffer-prompt} face (@pxref{Faces}).
21 36
22 The simplest way to enter a minibuffer argument is to type the text, 37 The simplest way to enter a minibuffer argument is to type the text,
23then @key{RET} to submit the argument and exit the minibuffer. You 38then @key{RET} to submit the argument and exit the minibuffer.
24can cancel the minibuffer, and the command that wants the argument, by 39Alternatively, you can type @kbd{C-g} to exit the minibuffer by
25typing @kbd{C-g}. 40cancelling the command asking for the argument (@pxref{Quitting}).
26 41
27@cindex default argument 42@cindex default argument
28 Sometimes, a @dfn{default argument} appears in the prompt, inside 43 Sometimes, the prompt shows a @dfn{default argument}, inside
29parentheses before the colon. This default will be used as the 44parentheses before the colon. This default will be used as the
30argument if you just type @key{RET}. For example, commands that read 45argument if you just type @key{RET}. For example, commands that read
31buffer names usually show a buffer name as the default; you can type 46buffer names usually show a buffer name as the default; you can type
32@key{RET} to operate on that default buffer. 47@key{RET} to operate on that default buffer.
33 48
49@cindex Minibuffer Electric Default mode
50@cindex mode, Minibuffer Electric Default
51@findex minibuffer-electric-default-mode
52@vindex minibuffer-eldef-shorten-default
53 If you enable Minibuffer Electric Default mode, a global minor mode,
54Emacs hides the default argument as soon as you modify the contents of
55the minibuffer (since typing @key{RET} would no longer submit that
56default). If you ever bring back the original minibuffer text, the
57prompt again shows the default. Furthermore, if you change the
58variable @code{minibuffer-eldef-shorten-default} to a non-@code{nil}
59value, the default argument is displayed as @samp{[@var{default}]}
60instead of @samp{(default @var{default})}, saving some screen space.
61To enable this minor mode, type @kbd{M-x
62minibuffer-electric-default-mode}.
63
34 Since the minibuffer appears in the echo area, it can conflict with 64 Since the minibuffer appears in the echo area, it can conflict with
35other uses of the echo area. If an error message or an informative 65other uses of the echo area. If an error message or an informative
36message is emitted while the minibuffer is active, the message hides 66message is emitted while the minibuffer is active, the message hides
@@ -38,16 +68,6 @@ the minibuffer for a few seconds, or until you type something; then
38the minibuffer comes back. While the minibuffer is in use, keystrokes 68the minibuffer comes back. While the minibuffer is in use, keystrokes
39do not echo. 69do not echo.
40 70
41@menu
42* Minibuffer File:: Entering file names with the minibuffer.
43* Minibuffer Edit:: How to edit in the minibuffer.
44* Completion:: An abbreviation facility for minibuffer input.
45* Minibuffer History:: Reusing recent minibuffer arguments.
46* Repetition:: Re-executing commands that used the minibuffer.
47* Passwords:: Entering passwords in the echo area.
48* Yes or No Prompts:: Replying yes or no in the echo area.
49@end menu
50
51@node Minibuffer File 71@node Minibuffer File
52@section Minibuffers for File Names 72@section Minibuffers for File Names
53 73
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 4f0a1009e30..1836c1982e6 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -542,11 +542,19 @@ which is impossible to ignore.
542You can also type @kbd{M-&} (@code{async-shell-command}) to execute a 542You can also type @kbd{M-&} (@code{async-shell-command}) to execute a
543shell command asynchronously; this is exactly like calling @kbd{M-!} 543shell command asynchronously; this is exactly like calling @kbd{M-!}
544with a trailing @samp{&}, except that you do not need the @samp{&}. 544with a trailing @samp{&}, except that you do not need the @samp{&}.
545The output buffer for asynchronous shell commands is named 545The default output buffer for asynchronous shell commands is named
546@samp{*Async Shell Command*}. Emacs inserts the output into this 546@samp{*Async Shell Command*}. Emacs inserts the output into this
547buffer as it comes in, whether or not the buffer is visible in a 547buffer as it comes in, whether or not the buffer is visible in a
548window. 548window.
549 549
550@vindex async-shell-command-buffer
551 If you want to run more than one asynchronous shell command at the
552same time, they could end up competing for the output buffer. The
553option @code{async-shell-command-buffer} specifies what to do about
554this; e.g., whether to rename the pre-existing output buffer, or to
555use a different buffer for the new command. Consult the variable's
556documentation for more possibilities.
557
550@kindex M-| 558@kindex M-|
551@findex shell-command-on-region 559@findex shell-command-on-region
552 @kbd{M-|} (@code{shell-command-on-region}) is like @kbd{M-!}, but 560 @kbd{M-|} (@code{shell-command-on-region}) is like @kbd{M-!}, but
@@ -1186,30 +1194,39 @@ underlying shell, of course.
1186@subsection Emacs Terminal Emulator 1194@subsection Emacs Terminal Emulator
1187@findex term 1195@findex term
1188 1196
1189 To run a subshell in a terminal emulator, use @kbd{M-x term}. This 1197 To run a subshell in a text terminal emulator, use @kbd{M-x term}.
1190creates (or reuses) a buffer named @file{*terminal*}, and runs a 1198This creates (or reuses) a buffer named @file{*terminal*}, and runs a
1191subshell with input coming from your keyboard, and output going to 1199subshell with input coming from your keyboard, and output going to
1192that buffer. 1200that buffer.
1193 1201
1202@cindex line mode @r{(terminal emulator)}
1203@cindex char mode @r{(terminal emulator)}
1194 The terminal emulator uses Term mode, which has two input modes. In 1204 The terminal emulator uses Term mode, which has two input modes. In
1195line mode, Term basically acts like Shell mode (@pxref{Shell Mode}). 1205@dfn{line mode}, Term basically acts like Shell mode (@pxref{Shell
1196 1206Mode}). In @dfn{char mode}, each character is sent directly to the
1197 In char mode, each character is sent directly to the subshell, as 1207subshell, as terminal input; the sole exception is the terminal escape
1198``terminal input''. Any ``echoing'' of your input is the 1208character, which by default is @kbd{C-c} (@pxref{Term Mode}). Any
1199responsibility of the subshell. The sole exception is the terminal 1209echoing of your input is the responsibility of the subshell; any
1200escape character, which by default is @kbd{C-c} (@pxref{Term Mode}). 1210terminal output from the subshell goes into the buffer, advancing
1201Any ``terminal output'' from the subshell goes into the buffer, 1211point.
1202advancing point.
1203 1212
1204 Some programs (such as Emacs itself) need to control the appearance 1213 Some programs (such as Emacs itself) need to control the appearance
1205on the terminal screen in detail. They do this by sending special 1214of the terminal screen in detail. They do this by emitting special
1206control codes. The exact control codes needed vary from terminal to 1215control codes. Term mode recognizes and handles ANSI-standard
1207terminal, but nowadays most terminals and terminal emulators 1216VT100-style escape sequences, which are accepted by most modern
1208(including @code{xterm}) understand the ANSI-standard (VT100-style) 1217terminals, including @command{xterm}. (Hence, you can actually run
1209escape sequences. Term mode recognizes these escape sequences, and 1218Emacs inside an Emacs Term window.)
1210handles each one appropriately, changing the buffer so that the 1219
1211appearance of the window matches what it would be on a real terminal. 1220 The @code{term} face specifies the default appearance of text
1212You can actually run Emacs inside an Emacs Term window. 1221in the terminal emulator (the default is the same appearance as the
1222@code{default} face). When terminal control codes are used to change
1223the appearance of text, these are represented in the terminal emulator
1224by the faces @code{term-color-black}, @code{term-color-red},
1225@code{term-color-green}, @code{term-color-yellow}
1226@code{term-color-blue}, @code{term-color-magenta},
1227@code{term-color-cyan}, @code{term-color-white},
1228@code{term-color-underline}, and @code{term-color-bold}.
1229@xref{Faces}.
1213 1230
1214 You can also Term mode to communicate with a device connected to a 1231 You can also Term mode to communicate with a device connected to a
1215serial port. @xref{Serial Terminal}. 1232serial port. @xref{Serial Terminal}.
@@ -1224,6 +1241,9 @@ examining your input. But some shells can tell Term what the current
1224directory is. This is done automatically by @code{bash} version 1.15 1241directory is. This is done automatically by @code{bash} version 1.15
1225and later. 1242and later.
1226 1243
1244
1245
1246
1227@node Term Mode 1247@node Term Mode
1228@subsection Term Mode 1248@subsection Term Mode
1229@cindex Term mode 1249@cindex Term mode
diff --git a/doc/emacs/trouble.texi b/doc/emacs/trouble.texi
index fc99ff3d7bf..1a891a62b33 100644
--- a/doc/emacs/trouble.texi
+++ b/doc/emacs/trouble.texi
@@ -275,24 +275,25 @@ will disappear from the mode line. That means you can safely go on
275editing in the same Emacs session. 275editing in the same Emacs session.
276 276
277 Do not use @kbd{M-x buffer-menu} to save or kill buffers when you run 277 Do not use @kbd{M-x buffer-menu} to save or kill buffers when you run
278out of memory, because the buffer menu needs a fair amount of memory 278out of memory, because the Buffer Menu needs a fair amount of memory
279itself, and the reserve supply may not be enough. 279itself, and the reserve supply may not be enough.
280 280
281@node Crashing 281@node Crashing
282@subsection When Emacs Crashes 282@subsection When Emacs Crashes
283 283
284 Emacs is not supposed to crash, but if it does, before it exits it 284@cindex crash report
285reports a brief summary of the crash to the standard error stream 285 Emacs is not supposed to crash, but if it does, it produces a
286@code{stderr}. If enabled, a crashed Emacs also generates a core dump 286@dfn{crash report} prior to exiting. The crash report is printed to
287containing voluminous data about the crash. On many platforms you can 287the standard error stream. If Emacs was started from a graphical
288enable core dumps by putting the shell command @samp{ulimit -c unlimited} 288desktop, the standard error stream is commonly redirected to a file
289into your shell startup script. The crash report and core dump can be 289such as @file{~/.xsession-errors}, so you can look for the crash
290used when debugging the same version of Emacs on the same platform. 290report there.
291 291
292The format of the crash report depends on the platform, and some 292 The format of the crash report depends on the platform. On some
293platforms support backtraces. 293platforms, such as those using the GNU C Library, the crash report
294Here is an example, generated on x86-64 GNU/Linux with version 2.15 of 294includes a @dfn{backtrace} describing the execution state prior to
295the GNU C Library: 295crashing, which can be used to help debug the crash. Here is an
296example:
296 297
297@example 298@example
298Fatal error 11: Segmentation fault 299Fatal error 11: Segmentation fault
@@ -304,25 +305,18 @@ emacs[0x4ed504]
304/lib64/libpthread.so.0(read+0xe)[0x375220e08e] 305/lib64/libpthread.so.0(read+0xe)[0x375220e08e]
305emacs[0x509af6] 306emacs[0x509af6]
306emacs[0x5acc26] 307emacs[0x5acc26]
307emacs[0x5adbfb] 308@dots{}
308emacs[0x56566b]
309emacs[0x59bac3]
310emacs[0x565151]
311...
312@end example 309@end example
313 310
314@noindent 311@noindent
315The number @samp{11} is the system signal number that corresponds to 312The number @samp{11} is the system signal number corresponding to the
316the problem, a segmentation fault here. The three dots at the end 313crash---in this case a segmentation fault. The hexadecimal numbers
317indicate that Emacs suppressed further backtrace entries, in the 314are program addresses, which can be associated with source code lines
318interest of brevity. 315using a debugging tool. For example, the GDB command
319 316@samp{list *0x509af6} prints the source-code lines corresponding to
320The hexadecimal program addresses can be useful in debugging sessions. 317the @samp{emacs[0x509af6]} entry. If your system has the
321For example, the GDB command @samp{list *0x509af6} prints the 318@command{addr2line} utility, the following shell command outputs a
322source-code lines corresponding to the @samp{emacs[0x509af6]} entry in 319backtrace with source-code line numbers:
323the backtrace. Or, if your system has @command{addr2line}, the
324following shell command outputs a backtrace with source-code line
325numbers:
326 320
327@example 321@example
328sed -n 's/.*\[\(.*\)]$/\1/p' @var{backtrace} | 322sed -n 's/.*\[\(.*\)]$/\1/p' @var{backtrace} |
@@ -334,6 +328,15 @@ Here, @var{backtrace} is the name of a text file containing a copy of
334the backtrace, and @var{bindir} is the name of the directory that 328the backtrace, and @var{bindir} is the name of the directory that
335contains the Emacs executable. 329contains the Emacs executable.
336 330
331@cindex core dump
332 Optionally, Emacs can generate a @dfn{core dump} when it crashes. A
333core dump is a file containing voluminous data about the state of the
334program prior to the crash, usually examined by loading it into a
335debugger such as GDB. On many platforms, core dumps are disabled by
336default, and you must explicitly enable them by running the shell
337command @samp{ulimit -c unlimited} (e.g.@: in your shell startup
338script).
339
337@node After a Crash 340@node After a Crash
338@subsection Recovery After a Crash 341@subsection Recovery After a Crash
339 342
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 17bd43fc0d9..6d6ddf4da9a 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,61 @@
12012-11-13 Glenn Morris <rgm@gnu.org>
2
3 * variables.texi (Adding Generalized Variables):
4 At least mention gv-define-expander and gv-letplace.
5
6 * debugging.texi (Error Debugging): Mention debug-on-message.
7 (Using Debugger): Mention debugger-bury-or-kill.
8
9 * control.texi (Signaling Errors):
10 * debugging.texi (Error Debugging):
11 * errors.texi (Standard Errors): Add user-error.
12
13 * variables.texi (Adding Generalized Variables):
14 Use standard formatting for common lisp note about setf functions.
15
162012-11-10 Martin Rudalics <rudalics@gmx.at>
17
18 * elisp.texi (Top): Add Recombining Windows to menu.
19 * windows.texi (Recombining Windows): New subsection.
20 (Splitting Windows): Rewrite text on handling of window
21 combinations and move it to new subsection.
22
232012-11-10 Chong Yidong <cyd@gnu.org>
24
25 * searching.texi (Replacing Match): Document \? in replace-match.
26
27 * variables.texi (Creating Buffer-Local): Document setq-local and
28 defvar-local.
29 (Setting Generalized Variables): Arrange table alphabetically.
30
31 * lists.texi (List Elements, List Variables): Clarify descriptions
32 of push and pop for generalized variables.
33
34 * edebug.texi (Specification List): setf is no longer CL-only.
35
362012-11-10 Glenn Morris <rgm@gnu.org>
37
38 * variables.texi (Adding Generalized Variables):
39 Update description of FIX-RETURN expansion.
40
41 * variables.texi (Setting Generalized Variables):
42 Split most of previous contents into this subsection.
43 (Adding Generalized Variables): New subsection.
44 Move note on lack of setf functions here from misc/cl.texi.
45
46 * elisp.texi: Add Generalized Variables subsections to detailed menu.
47
482012-11-10 Chong Yidong <cyd@gnu.org>
49
50 * frames.texi (Initial Parameters): Doc fix (Bug#12144).
51
522012-11-08 Michael Albinus <michael.albinus@gmx.de>
53
54 * os.texi (Notifications): Update descriptions of
55 notifications-notify, notifications-close-notification and
56 notifications-get-capabilities according to latest code changes.
57 Add notifications-get-server-information.
58
12012-11-03 Chong Yidong <cyd@gnu.org> 592012-11-03 Chong Yidong <cyd@gnu.org>
2 60
3 * objects.texi (General Escape Syntax): Clarify the explanation of 61 * objects.texi (General Escape Syntax): Clarify the explanation of
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index cf393b59c49..489e5cc5b22 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -824,6 +824,19 @@ The function @code{signal} never returns.
824@end example 824@end example
825@end defun 825@end defun
826 826
827@cindex user errors, signaling
828@defun user-error format-string &rest args
829This function behaves exactly like @code{error}, except that it uses
830the error symbol @code{user-error} rather than @code{error}. As the
831name suggests, this is intended to report errors on the part of the
832user, rather than errors in the code itself. For example,
833if you try to use the command @code{Info-history-back} (@kbd{l}) to
834move back beyond the start of your Info browsing history, Emacs
835signals a @code{user-error}. Such errors do not cause entry to the
836debugger, even when @code{debug-on-error} is non-@code{nil}.
837@xref{Error Debugging}.
838@end defun
839
827@cindex CL note---no continuable errors 840@cindex CL note---no continuable errors
828@quotation 841@quotation
829@b{Common Lisp note:} Emacs Lisp has nothing like the Common Lisp 842@b{Common Lisp note:} Emacs Lisp has nothing like the Common Lisp
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi
index 2226db942d1..11532b19781 100644
--- a/doc/lispref/debugging.texi
+++ b/doc/lispref/debugging.texi
@@ -117,12 +117,12 @@ has any of those condition symbols, or if the error message matches
117any of the regular expressions, then that error does not enter the 117any of the regular expressions, then that error does not enter the
118debugger. 118debugger.
119 119
120The normal value of this variable lists several errors that happen 120The normal value of this variable includes @code{user-error}, as well
121often during editing but rarely result from bugs in Lisp programs. 121as several errors that happen often during editing but rarely result
122However, ``rarely'' is not ``never''; if your program fails with an 122from bugs in Lisp programs. However, ``rarely'' is not ``never''; if
123error that matches this list, you may try changing this list to debug 123your program fails with an error that matches this list, you may try
124the error. The easiest way is usually to set 124changing this list to debug the error. The easiest way is usually to
125@code{debug-ignored-errors} to @code{nil}. 125set @code{debug-ignored-errors} to @code{nil}.
126@end defopt 126@end defopt
127 127
128@defopt eval-expression-debug-on-error 128@defopt eval-expression-debug-on-error
@@ -163,6 +163,14 @@ supported values correspond to the signals @code{SIGUSR1} and
163@code{inhibit-quit} is set and Emacs is not otherwise responding. 163@code{inhibit-quit} is set and Emacs is not otherwise responding.
164@end defopt 164@end defopt
165 165
166@cindex message, finding what causes a particular message
167@defvar debug-on-message
168If you set @code{debug-on-message} to a regular expression,
169Emacs will enter the debugger if it displays a matching message in the
170echo area. For example, this can be useful when trying to find the
171cause of a particular message.
172@end defvar
173
166 To debug an error that happens during loading of the init 174 To debug an error that happens during loading of the init
167file, use the option @samp{--debug-init}. This binds 175file, use the option @samp{--debug-init}. This binds
168@code{debug-on-error} to @code{t} while loading the init file, and 176@code{debug-on-error} to @code{t} while loading the init file, and
@@ -314,6 +322,7 @@ is a message describing the reason that the debugger was invoked (such
314as the error message and associated data, if it was invoked due to an 322as the error message and associated data, if it was invoked due to an
315error). 323error).
316 324
325@vindex debugger-bury-or-kill
317 The backtrace buffer is read-only and uses a special major mode, 326 The backtrace buffer is read-only and uses a special major mode,
318Debugger mode, in which letters are defined as debugger commands. The 327Debugger mode, in which letters are defined as debugger commands. The
319usual Emacs editing commands are available; thus, you can switch windows 328usual Emacs editing commands are available; thus, you can switch windows
@@ -322,8 +331,12 @@ switch buffers, visit files, or do any other sort of editing. However,
322the debugger is a recursive editing level (@pxref{Recursive Editing}) 331the debugger is a recursive editing level (@pxref{Recursive Editing})
323and it is wise to go back to the backtrace buffer and exit the debugger 332and it is wise to go back to the backtrace buffer and exit the debugger
324(with the @kbd{q} command) when you are finished with it. Exiting 333(with the @kbd{q} command) when you are finished with it. Exiting
325the debugger gets out of the recursive edit and kills the backtrace 334the debugger gets out of the recursive edit and buries the backtrace
326buffer. 335buffer. (You can customize what the @kbd{q} command does with the
336backtrace buffer by setting the variable @code{debugger-bury-or-kill}.
337For example, set it to @code{kill} if you prefer to kill the buffer
338rather than bury it. Consult the variable's documentation for more
339possibilities.)
327 340
328 When the debugger has been entered, the @code{debug-on-error} 341 When the debugger has been entered, the @code{debug-on-error}
329variable is temporarily set according to 342variable is temporarily set according to
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi
index 0211f9e1b9c..b5edda06bad 100644
--- a/doc/lispref/edebug.texi
+++ b/doc/lispref/edebug.texi
@@ -1211,9 +1211,7 @@ A single unevaluated Lisp object, which is not instrumented.
1211A single evaluated expression, which is instrumented. 1211A single evaluated expression, which is instrumented.
1212 1212
1213@item place 1213@item place
1214@c I can't see that this index entry is useful without any explanation. 1214A generalized variable. @xref{Generalized Variables}.
1215@c @findex edebug-unwrap
1216A place to store a value, as in the Common Lisp @code{setf} construct.
1217 1215
1218@item body 1216@item body
1219Short for @code{&rest form}. See @code{&rest} below. 1217Short for @code{&rest form}. See @code{&rest} below.
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 06a2ebfcaf8..a70558bf09f 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -502,6 +502,11 @@ Buffer-Local Variables
502* Default Value:: The default value is seen in buffers 502* Default Value:: The default value is seen in buffers
503 that don't have their own buffer-local values. 503 that don't have their own buffer-local values.
504 504
505Generalized Variables
506
507* Setting Generalized Variables:: The @code{setf} macro.
508* Adding Generalized Variables:: Defining new @code{setf} forms.
509
505Functions 510Functions
506 511
507* What Is a Function:: Lisp functions vs. primitives; terminology. 512* What Is a Function:: Lisp functions vs. primitives; terminology.
@@ -996,6 +1001,8 @@ Windows
996* Resizing Windows:: Changing the sizes of windows. 1001* Resizing Windows:: Changing the sizes of windows.
997* Splitting Windows:: Splitting one window into two windows. 1002* Splitting Windows:: Splitting one window into two windows.
998* Deleting Windows:: Deleting a window gives its space to other windows. 1003* Deleting Windows:: Deleting a window gives its space to other windows.
1004* Recombining Windows:: Preserving the frame layout when splitting and
1005 deleting windows.
999* Selecting Windows:: The selected window is the one that you edit in. 1006* Selecting Windows:: The selected window is the one that you edit in.
1000* Cyclic Window Ordering:: Moving around the existing windows. 1007* Cyclic Window Ordering:: Moving around the existing windows.
1001* Buffers and Windows:: Each window displays the contents of a buffer. 1008* Buffers and Windows:: Each window displays the contents of a buffer.
diff --git a/doc/lispref/errors.texi b/doc/lispref/errors.texi
index a57f74d6c86..b92fd9ed665 100644
--- a/doc/lispref/errors.texi
+++ b/doc/lispref/errors.texi
@@ -172,6 +172,9 @@ The message is @samp{Text is read-only}. This is a subcategory of
172@item undefined-color 172@item undefined-color
173The message is @samp{Undefined color}. @xref{Color Names}. 173The message is @samp{Undefined color}. @xref{Color Names}.
174 174
175@item user-error
176The message is the empty string. @xref{Signaling Errors}.
177
175@item void-function 178@item void-function
176The message is @samp{Symbol's function definition is void}. 179The message is @samp{Symbol's function definition is void}.
177@xref{Function Cells}. 180@xref{Function Cells}.
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index f58d62675e5..27d55c4fdb9 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -419,16 +419,16 @@ the initial frame, specify the same parameters in
419@code{initial-frame-alist} with values that match the X resources. 419@code{initial-frame-alist} with values that match the X resources.
420@end defopt 420@end defopt
421 421
422If these parameters specify a separate @dfn{minibuffer-only frame} with
423@code{(minibuffer . nil)}, and you have not created one, Emacs creates
424one for you.
425
426@cindex minibuffer-only frame 422@cindex minibuffer-only frame
423If these parameters include @code{(minibuffer . nil)}, that indicates
424that the initial frame should have no minibuffer. In this case, Emacs
425creates a separate @dfn{minibuffer-only frame} as well.
426
427@defopt minibuffer-frame-alist 427@defopt minibuffer-frame-alist
428This variable's value is an alist of parameter values used when 428This variable's value is an alist of parameter values used when
429creating an initial minibuffer-only frame. This is the 429creating an initial minibuffer-only frame (i.e.@: the minibuffer-only
430minibuffer-only frame that Emacs creates if @code{initial-frame-alist} 430frame that Emacs creates if @code{initial-frame-alist} specifies a
431specifies a frame with no minibuffer. 431frame with no minibuffer).
432@end defopt 432@end defopt
433 433
434@defopt default-frame-alist 434@defopt default-frame-alist
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi
index 458db838177..40e8d08f72c 100644
--- a/doc/lispref/lists.texi
+++ b/doc/lispref/lists.texi
@@ -234,17 +234,15 @@ This is in contrast to @code{cdr}, which signals an error if
234@end defun 234@end defun
235 235
236@defmac pop listname 236@defmac pop listname
237This macro is a way of examining the @sc{car} of a list, 237This macro provides a convenient way to examine the @sc{car} of a
238and taking it off the list, all at once. 238list, and take it off the list, all at once. It operates on the list
239@c FIXME I don't think is a particularly good way to do it, 239stored in @var{listname}. It removes the first element from the list,
240@c but generalized variables have not been introduced yet. 240saves the @sc{cdr} into @var{listname}, then returns the removed
241(In fact, this macro can act on generalized variables, not just lists. 241element.
242@xref{Generalized Variables}.) 242
243 243In the simplest case, @var{listname} is an unquoted symbol naming a
244It operates on the list which is stored in the symbol @var{listname}. 244list; in that case, this macro is equivalent to @w{@code{(prog1
245It removes this element from the list by setting @var{listname} 245(car listname) (setq listname (cdr listname)))}}.
246to the @sc{cdr} of its old value---but it also returns the @sc{car}
247of that list, which is the element being removed.
248 246
249@example 247@example
250x 248x
@@ -255,7 +253,10 @@ x
255 @result{} (b c) 253 @result{} (b c)
256@end example 254@end example
257 255
258@noindent 256More generally, @var{listname} can be a generalized variable. In that
257case, this macro saves into @var{listname} using @code{setf}.
258@xref{Generalized Variables}.
259
259For the @code{push} macro, which adds an element to a list, 260For the @code{push} macro, which adds an element to a list,
260@xref{List Variables}. 261@xref{List Variables}.
261@end defmac 262@end defmac
@@ -683,13 +684,12 @@ Some examples:
683 These functions, and one macro, provide convenient ways 684 These functions, and one macro, provide convenient ways
684to modify a list which is stored in a variable. 685to modify a list which is stored in a variable.
685 686
686@defmac push newelt listname 687@defmac push element listname
687This macro provides an alternative way to write 688This macro creates a new list whose @sc{car} is @var{element} and
688@code{(setq @var{listname} (cons @var{newelt} @var{listname}))}. 689whose @sc{cdr} is the list specified by @var{listname}, and saves that
689@c FIXME I don't think is a particularly good way to do it, 690list in @var{listname}. In the simplest case, @var{listname} is an
690@c but generalized variables have not been introduced yet. 691unquoted symbol naming a list, and this macro is equivalent
691(In fact, this macro can act on generalized variables, not just lists. 692to @w{@code{(setq @var{listname} (cons @var{element} @var{listname}))}}.
692@xref{Generalized Variables}.)
693 693
694@example 694@example
695(setq l '(a b)) 695(setq l '(a b))
@@ -700,7 +700,11 @@ l
700 @result{} (c a b) 700 @result{} (c a b)
701@end example 701@end example
702 702
703@noindent 703More generally, @code{listname} can be a generalized variable. In
704that case, this macro does the equivalent of @w{@code{(setf
705@var{listname} (cons @var{element} @var{listname}))}}.
706@xref{Generalized Variables}.
707
704For the @code{pop} macro, which removes the first element from a list, 708For the @code{pop} macro, which removes the first element from a list,
705@xref{List Elements}. 709@xref{List Elements}.
706@end defmac 710@end defmac
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 6c5f6e85683..2f06e207fc4 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -2276,13 +2276,19 @@ These arguments should consist of alternating keyword and value pairs.
2276The supported keywords and values are as follows: 2276The supported keywords and values are as follows:
2277 2277
2278@table @code 2278@table @code
2279@item :bus @var{bus}
2280The D-Bus bus. This argument is needed only if a bus other than
2281@code{:session} shall be used.
2282
2279@item :title @var{title} 2283@item :title @var{title}
2280The notification title. 2284The notification title.
2281 2285
2282@item :body @var{text} 2286@item :body @var{text}
2283The notification body text. Depending on the implementation of the 2287The notification body text. Depending on the implementation of the
2284notification server, the text could contain HTML markups, like 2288notification server, the text could contain HTML markups, like
2285@samp{"<b>bold text</b>"}, hyperlinks, or images. 2289@samp{"<b>bold text</b>"}, hyperlinks, or images. Special HTML
2290characters must be encoded, as @samp{"Contact
2291&lt;postmaster@@localhost&gt;!"}.
2286 2292
2287@item :app-name @var{name} 2293@item :app-name @var{name}
2288The name of the application sending the notification. The default is 2294The name of the application sending the notification. The default is
@@ -2317,7 +2323,10 @@ When this keyword is given, the @var{title} string of the actions is
2317interpreted as icon name. 2323interpreted as icon name.
2318 2324
2319@item :category @var{category} 2325@item :category @var{category}
2320The type of notification this is, a string. 2326The type of notification this is, a string. See the
2327@uref{http://developer.gnome.org/notification-spec/#categories,
2328Desktop Notifications Specification} for a list of standard
2329categories.
2321 2330
2322@item :desktop-entry @var{filename} 2331@item :desktop-entry @var{filename}
2323This specifies the name of the desktop filename representing the 2332This specifies the name of the desktop filename representing the
@@ -2420,13 +2429,17 @@ A message window opens on the desktop. Press "I agree"
2420@end example 2429@end example
2421@end defun 2430@end defun
2422 2431
2423@defun notifications-close-notification id 2432@defun notifications-close-notification id &optional bus
2424This function closes a notification with identifier @var{id}. 2433This function closes a notification with identifier @var{id}.
2434@var{bus} can be a string denoting a D-Bus connection, the default is
2435@code{:session}.
2425@end defun 2436@end defun
2426 2437
2427@defun notifications-get-capabilities 2438@defun notifications-get-capabilities &optional bus
2428Returns the capabilities of the notification server, a list of strings. 2439Returns the capabilities of the notification server, a list of
2429The following capabilities can be expected: 2440symbols. @var{bus} can be a string denoting a D-Bus connection, the
2441default is @code{:session}. The following capabilities can be
2442expected:
2430 2443
2431@table @code 2444@table @code
2432@item :actions 2445@item :actions
@@ -2463,6 +2476,30 @@ Further vendor-specific caps start with @code{:x-vendor}, like
2463@code{:x-gnome-foo-cap}. 2476@code{:x-gnome-foo-cap}.
2464@end defun 2477@end defun
2465 2478
2479@defun notifications-get-server-information &optional bus
2480Return information on the notification server, a list of strings.
2481@var{bus} can be a string denoting a D-Bus connection, the default is
2482@code{:session}. The returned list is @code{(@var{name} @var{vendor}
2483@var{version} @var{spec-version})}.
2484
2485@table @var
2486@item name
2487The product name of the server.
2488
2489@item vendor
2490The vendor name. For example, @samp{"KDE"}, @samp{"GNOME"}.
2491
2492@item version
2493The server's version number.
2494
2495@item spec-version
2496The specification version the server is compliant with.
2497@end table
2498
2499If @var{SPEC_VERSION} is @code{nil}, the server supports a
2500specification prior to @samp{"1.0"}.
2501@end defun
2502
2466 2503
2467@node Dynamic Libraries 2504@node Dynamic Libraries
2468@section Dynamically Loaded Libraries 2505@section Dynamically Loaded Libraries
diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi
index 56c96363e81..f165381a0f8 100644
--- a/doc/lispref/searching.texi
+++ b/doc/lispref/searching.texi
@@ -1310,22 +1310,31 @@ part of one of the following sequences:
1310@table @asis 1310@table @asis
1311@item @samp{\&} 1311@item @samp{\&}
1312@cindex @samp{&} in replacement 1312@cindex @samp{&} in replacement
1313@samp{\&} stands for the entire text being replaced. 1313This stands for the entire text being replaced.
1314 1314
1315@item @samp{\@var{n}} 1315@item @samp{\@var{n}}, where @var{n} is a digit
1316@cindex @samp{\@var{n}} in replacement 1316@cindex @samp{\@var{n}} in replacement
1317@samp{\@var{n}}, where @var{n} is a digit, stands for the text that 1317This stands for the text that matched the @var{n}th subexpression in
1318matched the @var{n}th subexpression in the original regexp. 1318the original regexp. Subexpressions are those expressions grouped
1319Subexpressions are those expressions grouped inside @samp{\(@dots{}\)}. 1319inside @samp{\(@dots{}\)}. If the @var{n}th subexpression never
1320If the @var{n}th subexpression never matched, an empty string is substituted. 1320matched, an empty string is substituted.
1321 1321
1322@item @samp{\\} 1322@item @samp{\\}
1323@cindex @samp{\} in replacement 1323@cindex @samp{\} in replacement
1324@samp{\\} stands for a single @samp{\} in the replacement text. 1324This stands for a single @samp{\} in the replacement text.
1325
1326@item @samp{\?}
1327This stands for itself (for compatibility with @code{replace-regexp}
1328and related commands; @pxref{Regexp Replacement,,, emacs, The GNU
1329Emacs Manual}).
1325@end table 1330@end table
1326 1331
1327These substitutions occur after case conversion, if any, 1332@noindent
1328so the strings they substitute are never case-converted. 1333Any other character following @samp{\} signals an error.
1334
1335The substitutions performed by @samp{\&} and @samp{\@var{n}} occur
1336after case conversion, if any. Therefore, the strings they substitute
1337are never case-converted.
1329 1338
1330If @var{subexp} is non-@code{nil}, that says to replace just 1339If @var{subexp} is non-@code{nil}, that says to replace just
1331subexpression number @var{subexp} of the regexp that was matched, not 1340subexpression number @var{subexp} of the regexp that was matched, not
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 88b7909126e..dfde3c45c04 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1262,6 +1262,13 @@ needed if you use the @var{local} argument to @code{add-hook} or
1262@code{remove-hook}. 1262@code{remove-hook}.
1263@end deffn 1263@end deffn
1264 1264
1265@defmac setq-local variable value
1266This macro creates a buffer-local binding in the current buffer for
1267@var{variable}, and gives it the buffer-local value @var{value}. It
1268is equivalent to calling @code{make-local-variable} followed by
1269@code{setq}. @var{variable} should be an unquoted symbol.
1270@end defmac
1271
1265@deffn Command make-variable-buffer-local variable 1272@deffn Command make-variable-buffer-local variable
1266This function marks @var{variable} (a symbol) automatically 1273This function marks @var{variable} (a symbol) automatically
1267buffer-local, so that any subsequent attempt to set it will make it 1274buffer-local, so that any subsequent attempt to set it will make it
@@ -1297,6 +1304,14 @@ on having separate values in separate buffers, then using
1297@code{make-variable-buffer-local} can be the best solution. 1304@code{make-variable-buffer-local} can be the best solution.
1298@end deffn 1305@end deffn
1299 1306
1307@defmac defvar-local variable value &optional docstring
1308This macro defines @var{variable} as a variable with initial value
1309@var{value} and @var{docstring}, and marks it as automatically
1310buffer-local. It is equivalent to calling @code{defvar} followed by
1311@code{make-variable-buffer-local}. @var{variable} should be an
1312unquoted symbol.
1313@end defmac
1314
1300@defun local-variable-p variable &optional buffer 1315@defun local-variable-p variable &optional buffer
1301This returns @code{t} if @var{variable} is buffer-local in buffer 1316This returns @code{t} if @var{variable} is buffer-local in buffer
1302@var{buffer} (which defaults to the current buffer); otherwise, 1317@var{buffer} (which defaults to the current buffer); otherwise,
@@ -1948,7 +1963,6 @@ Attempting to assign them any other value will result in an error:
1948@error{} Wrong type argument: integerp, 1000.0 1963@error{} Wrong type argument: integerp, 1000.0
1949@end example 1964@end example
1950 1965
1951@c FIXME? Not sure this is the right place for this section.
1952@node Generalized Variables 1966@node Generalized Variables
1953@section Generalized Variables 1967@section Generalized Variables
1954 1968
@@ -1958,13 +1972,20 @@ a regular Lisp variable. But the @sc{car}s and @sc{cdr}s of lists, elements
1958of arrays, properties of symbols, and many other locations are also 1972of arrays, properties of symbols, and many other locations are also
1959places where Lisp values are stored. 1973places where Lisp values are stored.
1960 1974
1961@c FIXME? Not sure this is a useful analogy...
1962Generalized variables are analogous to ``lvalues'' in the C 1975Generalized variables are analogous to ``lvalues'' in the C
1963language, where @samp{x = a[i]} gets an element from an array 1976language, where @samp{x = a[i]} gets an element from an array
1964and @samp{a[i] = x} stores an element using the same notation. 1977and @samp{a[i] = x} stores an element using the same notation.
1965Just as certain forms like @code{a[i]} can be lvalues in C, there 1978Just as certain forms like @code{a[i]} can be lvalues in C, there
1966is a set of forms that can be generalized variables in Lisp. 1979is a set of forms that can be generalized variables in Lisp.
1967 1980
1981@menu
1982* Setting Generalized Variables:: The @code{setf} macro.
1983* Adding Generalized Variables:: Defining new @code{setf} forms.
1984@end menu
1985
1986@node Setting Generalized Variables
1987@subsection The @code{setf} Macro
1988
1968The @code{setf} macro is the most basic way to operate on generalized 1989The @code{setf} macro is the most basic way to operate on generalized
1969variables. The @code{setf} form is like @code{setq}, except that it 1990variables. The @code{setf} form is like @code{setq}, except that it
1970accepts arbitrary place forms on the left side rather than just 1991accepts arbitrary place forms on the left side rather than just
@@ -1998,14 +2019,16 @@ so there is no performance penalty for using it in compiled code.
1998A call to any of the following standard Lisp functions: 2019A call to any of the following standard Lisp functions:
1999 2020
2000@smallexample 2021@smallexample
2001car cdr nth nthcdr 2022aref cddr symbol-function
2002caar cadr cdar cddr 2023car elt symbol-plist
2003aref elt get gethash 2024caar get symbol-value
2004symbol-function symbol-value symbol-plist 2025cadr gethash
2026cdr nth
2027cdar nthcdr
2005@end smallexample 2028@end smallexample
2006 2029
2007@item 2030@item
2008The following Emacs-specific functions are also @code{setf}-able: 2031A call to any of the following Emacs-specific functions:
2009 2032
2010@smallexample 2033@smallexample
2011default-value process-get 2034default-value process-get
@@ -2022,8 +2045,8 @@ process-filter
2022@end itemize 2045@end itemize
2023 2046
2024@noindent 2047@noindent
2025Using any forms other than these in the @var{place} argument to 2048@code{setf} signals an error if you pass a @var{place} form that it
2026@code{setf} will signal an error. 2049does not know how to handle.
2027 2050
2028@c And for cl-lib's cl-getf. 2051@c And for cl-lib's cl-getf.
2029Note that for @code{nthcdr}, the list argument of the function must 2052Note that for @code{nthcdr}, the list argument of the function must
@@ -2049,3 +2072,85 @@ place can be used to insert or delete at any position in a list.
2049The @file{cl-lib} library defines various extensions for generalized 2072The @file{cl-lib} library defines various extensions for generalized
2050variables, including additional @code{setf} places. 2073variables, including additional @code{setf} places.
2051@xref{Generalized Variables,,, cl, Common Lisp Extensions}. 2074@xref{Generalized Variables,,, cl, Common Lisp Extensions}.
2075
2076
2077@node Adding Generalized Variables
2078@subsection Defining new @code{setf} forms
2079
2080This section describes how to define new forms that @code{setf} can
2081operate on.
2082
2083@defmac gv-define-simple-setter name setter &optional fix-return
2084This macro enables you to easily define @code{setf} methods for simple
2085cases. @var{name} is the name of a function, macro, or special form.
2086You can use this macro whenever @var{name} has a directly
2087corresponding @var{setter} function that updates it, e.g.,
2088@code{(gv-define-simple-setter car setcar)}.
2089
2090This macro translates a call of the form
2091
2092@example
2093(setf (@var{name} @var{args}@dots{}) @var{value})
2094@end example
2095
2096into
2097@example
2098(@var{setter} @var{args}@dots{} @var{value})
2099@end example
2100
2101@noindent
2102Such a @code{setf} call is documented to return @var{value}. This is
2103no problem with, e.g., @code{car} and @code{setcar}, because
2104@code{setcar} returns the value that it set. If your @var{setter}
2105function does not return @var{value}, use a non-@code{nil} value for
2106the @var{fix-return} argument of @code{gv-define-simple-setter}. This
2107expands into something equivalent to
2108@example
2109(let ((temp @var{value}))
2110 (@var{setter} @var{args}@dots{} temp)
2111 temp)
2112@end example
2113so ensuring that it returns the correct result.
2114@end defmac
2115
2116
2117@defmac gv-define-setter name arglist &rest body
2118This macro allows for more complex @code{setf} expansions than the
2119previous form. You may need to use this form, for example, if there
2120is no simple setter function to call, or if there is one but it
2121requires different arguments to the place form.
2122
2123This macro expands the form
2124@code{(setf (@var{name} @var{args}@dots{}) @var{value})} by
2125first binding the @code{setf} argument forms
2126@code{(@var{value} @var{args}@dots{})} according to @var{arglist},
2127and then executing @var{body}. @var{body} should return a Lisp
2128form that does the assignment, and finally returns the value that was
2129set. An example of using this macro is:
2130
2131@example
2132(gv-define-setter caar (val x) `(setcar (car ,x) ,val))
2133@end example
2134@end defmac
2135
2136@findex gv-define-expander
2137@findex gv-letplace
2138@c FIXME? Not sure what or how much to say about these.
2139@c See cl.texi for an example of using gv-letplace.
2140For more control over the expansion, see the macro @code{gv-define-expander}.
2141The macro @code{gv-letplace} can be useful in defining macros that
2142perform similarly to @code{setf}; for example, the @code{incf} macro
2143of Common Lisp. Consult the source file @file{gv.el} for more details.
2144
2145@cindex CL note---no @code{setf} functions
2146@quotation
2147@b{Common Lisp note:} Common Lisp defines another way to specify the
2148@code{setf} behavior of a function, namely ``@code{setf} functions'',
2149whose names are lists @code{(setf @var{name})} rather than symbols.
2150For example, @code{(defun (setf foo) @dots{})} defines the function
2151that is used when @code{setf} is applied to @code{foo}. Emacs does
2152not support this. It is a compile-time error to use @code{setf} on a
2153form that has not already had an appropriate expansion defined. In
2154Common Lisp, this is not an error since the function @code{(setf
2155@var{func})} might be defined later.
2156@end quotation
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 2fbb59cd1dd..bb02b1d54fd 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -16,8 +16,10 @@ is displayed in windows.
16* Windows and Frames:: Relating windows to the frame they appear on. 16* Windows and Frames:: Relating windows to the frame they appear on.
17* Window Sizes:: Accessing a window's size. 17* Window Sizes:: Accessing a window's size.
18* Resizing Windows:: Changing the sizes of windows. 18* Resizing Windows:: Changing the sizes of windows.
19* Splitting Windows:: Splitting one window into two windows. 19* Splitting Windows:: Creating a new window.
20* Deleting Windows:: Deleting a window gives its space to other windows. 20* Deleting Windows:: Removing a window from its frame.
21* Recombining Windows:: Preserving the frame layout when splitting and
22 deleting windows.
21* Selecting Windows:: The selected window is the one that you edit in. 23* Selecting Windows:: The selected window is the one that you edit in.
22* Cyclic Window Ordering:: Moving around the existing windows. 24* Cyclic Window Ordering:: Moving around the existing windows.
23* Buffers and Windows:: Each window displays the contents of a buffer. 25* Buffers and Windows:: Each window displays the contents of a buffer.
@@ -587,7 +589,7 @@ function @code{window-resizable} above.
587The choice of which window edges this function alters depends on the 589The choice of which window edges this function alters depends on the
588values of the option @code{window-combination-resize} and the 590values of the option @code{window-combination-resize} and the
589combination limits of the involved windows; in some cases, it may alter 591combination limits of the involved windows; in some cases, it may alter
590both edges. @xref{Splitting Windows}. To resize by moving only the 592both edges. @xref{Recombining Windows}. To resize by moving only the
591bottom or right edge of a window, use the function 593bottom or right edge of a window, use the function
592@code{adjust-window-trailing-edge}, below. 594@code{adjust-window-trailing-edge}, below.
593@end defun 595@end defun
@@ -795,26 +797,169 @@ A new live window @var{W2} is created, to the left of the internal
795window @var{W3}. A new internal window @var{W1} is created, becoming 797window @var{W3}. A new internal window @var{W1} is created, becoming
796the new root window. 798the new root window.
797 799
798@defopt window-combination-resize 800 For interactive use, Emacs provides two commands which always split
799If this variable is @code{nil}, @code{split-window} can only split a 801the selected window. These call @code{split-window} internally.
800window (denoted by @var{window}) if @var{window}'s screen area is large
801enough to accommodate both itself and the new window.
802 802
803If this variable is @code{t}, @code{split-window} tries to resize all 803@deffn Command split-window-right &optional size
804windows that are part of the same combination as @var{window}, in order 804This function splits the selected window into two side-by-side
805to accommodate the new window. In particular, this may allow 805windows, putting the selected window on the left. If @var{size} is
806@code{split-window} to succeed even if @var{window} is a fixed-size 806positive, the left window gets @var{size} columns; if @var{size} is
807window or too small to ordinarily split. Furthermore, subsequently 807negative, the right window gets @minus{}@var{size} columns.
808resizing or deleting @var{window} may resize all other windows in its 808@end deffn
809combination.
810 809
811The default is @code{nil}. Other values are reserved for future use. 810@deffn Command split-window-below &optional size
812The value of this variable is ignored when 811This function splits the selected window into two windows, one above
813@code{window-combination-limit} is non-@code{nil} (see below). 812the other, leaving the upper window selected. If @var{size} is
813positive, the upper window gets @var{size} lines; if @var{size} is
814negative, the lower window gets @minus{}@var{size} lines.
815@end deffn
816
817@defopt split-window-keep-point
818If the value of this variable is non-@code{nil} (the default),
819@code{split-window-below} behaves as described above.
820
821If it is @code{nil}, @code{split-window-below} adjusts point in each
822of the two windows to minimize redisplay. (This is useful on slow
823terminals.) It selects whichever window contains the screen line that
824point was previously on. Note that this only affects
825@code{split-window-below}, not the lower-level @code{split-window}
826function.
814@end defopt 827@end defopt
815 828
816 To illustrate the effect of @code{window-combination-resize}, 829@node Deleting Windows
817consider the following window configuration: 830@section Deleting Windows
831@cindex deleting windows
832
833 @dfn{Deleting} a window removes it from the frame's window tree. If
834the window is a live window, it disappears from the screen. If the
835window is an internal window, its child windows are deleted too.
836
837 Even after a window is deleted, it continues to exist as a Lisp
838object, until there are no more references to it. Window deletion can
839be reversed, by restoring a saved window configuration (@pxref{Window
840Configurations}).
841
842@deffn Command delete-window &optional window
843This function removes @var{window} from display and returns
844@code{nil}. If @var{window} is omitted or @code{nil}, it defaults to
845the selected window. If deleting the window would leave no more
846windows in the window tree (e.g. if it is the only live window in the
847frame), an error is signaled.
848
849By default, the space taken up by @var{window} is given to one of its
850adjacent sibling windows, if any. However, if the variable
851@code{window-combination-resize} is non-@code{nil}, the space is
852proportionally distributed among any remaining windows in the window
853combination. @xref{Recombining Windows}.
854
855The behavior of this function may be altered by the window parameters
856of @var{window}, so long as the variable
857@code{ignore-window-parameters} is @code{nil}. If the value of
858the @code{delete-window} window parameter is @code{t}, this function
859ignores all other window parameters. Otherwise, if the value of the
860@code{delete-window} window parameter is a function, that function is
861called with the argument @var{window}, in lieu of the usual action of
862@code{delete-window}. Otherwise, this function obeys the
863@code{window-atom} or @code{window-side} window parameter, if any.
864@xref{Window Parameters}.
865@end deffn
866
867@deffn Command delete-other-windows &optional window
868This function makes @var{window} fill its frame, by deleting other
869windows as necessary. If @var{window} is omitted or @code{nil}, it
870defaults to the selected window. The return value is @code{nil}.
871
872The behavior of this function may be altered by the window parameters
873of @var{window}, so long as the variable
874@code{ignore-window-parameters} is @code{nil}. If the value of
875the @code{delete-other-windows} window parameter is @code{t}, this
876function ignores all other window parameters. Otherwise, if the value
877of the @code{delete-other-windows} window parameter is a function,
878that function is called with the argument @var{window}, in lieu of the
879usual action of @code{delete-other-windows}. Otherwise, this function
880obeys the @code{window-atom} or @code{window-side} window parameter,
881if any. @xref{Window Parameters}.
882@end deffn
883
884@deffn Command delete-windows-on &optional buffer-or-name frame
885This function deletes all windows showing @var{buffer-or-name}, by
886calling @code{delete-window} on those windows. @var{buffer-or-name}
887should be a buffer, or the name of a buffer; if omitted or @code{nil},
888it defaults to the current buffer. If there are no windows showing
889the specified buffer, this function does nothing. If the specified
890buffer is a minibuffer, an error is signaled.
891
892If there is a dedicated window showing the buffer, and that window is
893the only one on its frame, this function also deletes that frame if it
894is not the only frame on the terminal.
895
896The optional argument @var{frame} specifies which frames to operate
897on:
898
899@itemize @bullet
900@item @code{nil}
901means operate on all frames.
902@item @code{t}
903means operate on the selected frame.
904@item @code{visible}
905means operate on all visible frames.
906@item @code{0}
907means operate on all visible or iconified frames.
908@item A frame
909means operate on that frame.
910@end itemize
911
912Note that this argument does not have the same meaning as in other
913functions which scan all live windows (@pxref{Cyclic Window
914Ordering}). Specifically, the meanings of @code{t} and @code{nil} here
915are the opposite of what they are in those other functions.
916@end deffn
917
918
919@node Recombining Windows
920@section Recombining Windows
921
922When deleting the last sibling of a window @code{W}, its parent window
923is deleted too, with @code{W} replacing it in the window tree. This
924means that @code{W} must be recombined with its parent's siblings to
925form a new window combination (@pxref{Windows and Frames}). In some
926occasions, deleting a live window may even entail the deletion of two
927internal windows.
928
929@smallexample
930@group
931 ______________________________________
932 | ______ ____________________________ |
933 || || __________________________ ||
934 || ||| ___________ ___________ |||
935 || |||| || ||||
936 || ||||____W6_____||_____W7____||||
937 || |||____________W4____________|||
938 || || __________________________ ||
939 || ||| |||
940 || ||| |||
941 || |||____________W5____________|||
942 ||__W2__||_____________W3_____________ |
943 |__________________W1__________________|
944
945@end group
946@end smallexample
947
948@noindent
949Deleting @code{W5} in this configuration normally causes the deletion of
950@code{W3} and @code{W4}. The remaining live windows @code{W2},
951@code{W6} and @code{W7} are recombined to form a new horizontal
952combination with parent @code{W1}.
953
954 Sometimes, however, it makes sense to not delete a parent window like
955@code{W4}. In particular, a parent window should not be removed when it
956was used to preserve a combination embedded in a combination of the same
957type. Such embeddings make sense to assure that when you split a window
958and subsequently delete the new window, Emacs reestablishes the layout
959of the associated frame as it existed before the splitting.
960
961 Consider a scenario starting with two live windows @code{W2} and
962@code{W3} and their parent @code{W1}.
818 963
819@smallexample 964@smallexample
820@group 965@group
@@ -824,10 +969,10 @@ consider the following window configuration:
824 || || 969 || ||
825 || || 970 || ||
826 || || 971 || ||
827 ||_________________W2_________________||
828 | ____________________________________ |
829 || || 972 || ||
830 || || 973 || ||
974 ||_________________W2_________________||
975 | ____________________________________ |
831 || || 976 || ||
832 || || 977 || ||
833 ||_________________W3_________________|| 978 ||_________________W3_________________||
@@ -837,8 +982,7 @@ consider the following window configuration:
837@end smallexample 982@end smallexample
838 983
839@noindent 984@noindent
840If @code{window-combination-resize} is @code{nil}, splitting window 985Split @code{W2} to make a new window @code{W4} as follows.
841@code{W3} leaves the size of @code{W2} unchanged:
842 986
843@smallexample 987@smallexample
844@group 988@group
@@ -846,24 +990,25 @@ If @code{window-combination-resize} is @code{nil}, splitting window
846 | ____________________________________ | 990 | ____________________________________ |
847 || || 991 || ||
848 || || 992 || ||
849 || ||
850 || ||
851 ||_________________W2_________________|| 993 ||_________________W2_________________||
852 | ____________________________________ | 994 | ____________________________________ |
853 || || 995 || ||
854 ||_________________W3_________________||
855 | ____________________________________ |
856 || || 996 || ||
857 ||_________________W4_________________|| 997 ||_________________W4_________________||
998 | ____________________________________ |
999 || ||
1000 || ||
1001 ||_________________W3_________________||
858 |__________________W1__________________| 1002 |__________________W1__________________|
859 1003
860@end group 1004@end group
861@end smallexample 1005@end smallexample
862 1006
863@noindent 1007@noindent
864If @code{window-combination-resize} is @code{t}, splitting @code{W3} 1008Now, when enlarging a window vertically, Emacs tries to obtain the
865instead leaves all three live windows with approximately the same 1009corresponding space from its lower sibling, provided such a window
866height: 1010exists. In our scenario, enlarging @code{W4} will steal space from
1011@code{W3}.
867 1012
868@smallexample 1013@smallexample
869@group 1014@group
@@ -875,36 +1020,119 @@ height:
875 | ____________________________________ | 1020 | ____________________________________ |
876 || || 1021 || ||
877 || || 1022 || ||
1023 || ||
1024 || ||
1025 ||_________________W4_________________||
1026 | ____________________________________ |
878 ||_________________W3_________________|| 1027 ||_________________W3_________________||
1028 |__________________W1__________________|
1029
1030@end group
1031@end smallexample
1032
1033@noindent
1034Deleting @code{W4} will now give its entire space to @code{W2},
1035including the space earlier stolen from @code{W3}.
1036
1037@smallexample
1038@group
1039 ______________________________________
879 | ____________________________________ | 1040 | ____________________________________ |
880 || || 1041 || ||
881 || || 1042 || ||
882 ||_________________W4_________________|| 1043 || ||
1044 || ||
1045 || ||
1046 || ||
1047 || ||
1048 || ||
1049 ||_________________W2_________________||
1050 | ____________________________________ |
1051 ||_________________W3_________________||
883 |__________________W1__________________| 1052 |__________________W1__________________|
884 1053
885@end group 1054@end group
886@end smallexample 1055@end smallexample
887 1056
1057@noindent
1058This can be counterintutive, in particular if @code{W4} were used for
1059displaying a buffer only temporarily (@pxref{Temporary Displays}), and
1060you want to continue working with the initial layout.
1061
1062The behavior can be fixed by making a new parent window when splitting
1063@code{W2}. The variable described next allows to do that.
1064
888@defopt window-combination-limit 1065@defopt window-combination-limit
889If the value of this variable is @code{t}, the @code{split-window} 1066This variable controls whether splitting a window shall make a new
890function always creates a new internal window. If the value is 1067parent window. The following values are recognized:
891@code{nil}, the new live window is allowed to share the existing 1068
1069@table @code
1070@item nil
1071This means that the new live window is allowed to share the existing
892parent window, if one exists, provided the split occurs in the same 1072parent window, if one exists, provided the split occurs in the same
893direction as the existing window combination (otherwise, a new 1073direction as the existing window combination (otherwise, a new internal
894internal window is created anyway). The default is @code{nil}. Other 1074window is created anyway).
895values are reserved for future use. 1075
896 1076@item window-size
897Thus, if the value of this variable is at all times @code{t}, then at 1077In this case @code{display-buffer} makes a new parent window if it is
898all times every window tree is a binary tree (a tree where each window 1078passed a @code{window-height} or @code{window-width} entry in the
899except the root window has exactly one sibling). 1079@var{alist} argument (@pxref{Display Action Functions}).
900 1080
901Furthermore, @code{split-window} calls 1081@item temp-buffer
902@code{set-window-combination-limit} on the newly-created internal 1082This value causes the creation of a new parent window when a window is
903window, recording the current value of this variable. This affects 1083split for showing a temporary buffer (@pxref{Temporary Displays}) only.
904how the window tree is rearranged when the child windows are deleted 1084
905(see below). 1085@item display-buffer
1086This means that when @code{display-buffer} (@pxref{Choosing Window})
1087splits a window it always makes a new parent window.
1088
1089@item t
1090In this case a new parent window is always created when splitting a
1091window. Thus, if the value of this variable is at all times @code{t},
1092then at all times every window tree is a binary tree (a tree where each
1093window except the root window has exactly one sibling).
1094@end table
1095
1096The default is @code{nil}. Other values are reserved for future use.
1097
1098If, as a consequence of this variable's setting, @code{split-window}
1099makes a new parent window, it also calls
1100@code{set-window-combination-limit} (see below) on the newly-created
1101internal window. This affects how the window tree is rearranged when
1102the child windows are deleted (see below).
906@end defopt 1103@end defopt
907 1104
1105 If @code{window-combination-limit} is @code{t}, splitting @code{W2} in
1106the initial configuration of our scenario would have produced this:
1107
1108@smallexample
1109@group
1110 ______________________________________
1111 | ____________________________________ |
1112 || __________________________________ ||
1113 ||| |||
1114 |||________________W2________________|||
1115 || __________________________________ ||
1116 ||| |||
1117 |||________________W4________________|||
1118 ||_________________W5_________________||
1119 | ____________________________________ |
1120 || ||
1121 || ||
1122 ||_________________W3_________________||
1123 |__________________W1__________________|
1124
1125@end group
1126@end smallexample
1127
1128@noindent
1129A new internal window @code{W5} has been created; its children are
1130@code{W2} and the new live window @code{W4}. Now, @code{W2} is the only
1131sibling of @code{W4}, so enlarging @code{W4} will try to shrink
1132@code{W2}, leaving @code{W3} unaffected. Observe that @code{W5}
1133represents a vertical combination of two windows embedded in the
1134vertical combination @code{W1}.
1135
908@cindex window combination limit 1136@cindex window combination limit
909@defun set-window-combination-limit window limit 1137@defun set-window-combination-limit window limit
910This functions sets the @dfn{combination limit} of the window 1138This functions sets the @dfn{combination limit} of the window
@@ -912,25 +1140,52 @@ This functions sets the @dfn{combination limit} of the window
912function @code{window-combination-limit}. See below for its effects; 1140function @code{window-combination-limit}. See below for its effects;
913note that it is only meaningful for internal windows. The 1141note that it is only meaningful for internal windows. The
914@code{split-window} function automatically calls this function, passing 1142@code{split-window} function automatically calls this function, passing
915the value of the variable @code{window-combination-limit} as 1143it @code{t} as @var{limit}, provided the value of the variable
916@var{limit}. 1144@code{window-combination-limit} is @code{t} when it is called.
917@end defun 1145@end defun
918 1146
919@defun window-combination-limit window 1147@defun window-combination-limit window
920This function returns the combination limit for @var{window}. 1148This function returns the combination limit for @var{window}.
921 1149
922The combination limit is meaningful only for an internal window. If 1150The combination limit is meaningful only for an internal window. If it
923it is @code{nil}, then Emacs is allowed to automatically delete 1151is @code{nil}, then Emacs is allowed to automatically delete
924@var{window}, in response to a window deletion, in order to group the 1152@var{window}, in response to a window deletion, in order to group the
925child windows of @var{window} with its sibling windows to form a new 1153child windows of @var{window} with its sibling windows to form a new
926window combination. If the combination limit is @code{t}, the child 1154window combination. If the combination limit is @code{t}, the child
927windows of @var{window} are never automatically re-combined with its 1155windows of @var{window} are never automatically recombined with its
928siblings. 1156siblings.
1157
1158If, in the configuration shown at the beginning of this section, the
1159combination limit of @code{W4} (the parent window of @code{W6} and
1160@code{W7}) is @code{t}, deleting @code{W5} will not implicitly delete
1161@code{W4} too.
929@end defun 1162@end defun
930 1163
931 To illustrate the effect of @code{window-combination-limit}, 1164Alternatively, the problems sketched above can be avoided by always
932consider the following configuration (throughout this example, we will 1165resizing all windows in the same combination whenever one of its windows
933assume that @code{window-combination-resize} is @code{nil}): 1166is split or deleted. This also permits to split windows that would be
1167otherwise too small for such an operation.
1168
1169@defopt window-combination-resize
1170If this variable is @code{nil}, @code{split-window} can only split a
1171window (denoted by @var{window}) if @var{window}'s screen area is large
1172enough to accommodate both itself and the new window.
1173
1174If this variable is @code{t}, @code{split-window} tries to resize all
1175windows that are part of the same combination as @var{window}, in order
1176to accommodate the new window. In particular, this may allow
1177@code{split-window} to succeed even if @var{window} is a fixed-size
1178window or too small to ordinarily split. Furthermore, subsequently
1179resizing or deleting @var{window} may resize all other windows in its
1180combination.
1181
1182The default is @code{nil}. Other values are reserved for future use.
1183The value of this variable is ignored when
1184@code{window-combination-limit} is non-@code{nil}.
1185@end defopt
1186
1187 To illustrate the effect of @code{window-combination-resize}, consider
1188the following frame layout.
934 1189
935@smallexample 1190@smallexample
936@group 1191@group
@@ -940,12 +1195,12 @@ assume that @code{window-combination-resize} is @code{nil}):
940 || || 1195 || ||
941 || || 1196 || ||
942 || || 1197 || ||
943 || ||
944 || ||
945 ||_________________W2_________________|| 1198 ||_________________W2_________________||
946 | ____________________________________ | 1199 | ____________________________________ |
947 || || 1200 || ||
948 || || 1201 || ||
1202 || ||
1203 || ||
949 ||_________________W3_________________|| 1204 ||_________________W3_________________||
950 |__________________W1__________________| 1205 |__________________W1__________________|
951 1206
@@ -953,8 +1208,8 @@ assume that @code{window-combination-resize} is @code{nil}):
953@end smallexample 1208@end smallexample
954 1209
955@noindent 1210@noindent
956If @code{window-combination-limit} is @code{nil}, splitting @code{W2} 1211If @code{window-combination-resize} is @code{nil}, splitting window
957into two windows, one above the other, yields 1212@code{W3} leaves the size of @code{W2} unchanged:
958 1213
959@smallexample 1214@smallexample
960@group 1215@group
@@ -962,171 +1217,50 @@ into two windows, one above the other, yields
962 | ____________________________________ | 1217 | ____________________________________ |
963 || || 1218 || ||
964 || || 1219 || ||
965 ||_________________W2_________________||
966 | ____________________________________ |
967 || || 1220 || ||
968 || || 1221 || ||
969 ||_________________W4_________________|| 1222 ||_________________W2_________________||
970 | ____________________________________ | 1223 | ____________________________________ |
971 || || 1224 || ||
972 || ||
973 ||_________________W3_________________|| 1225 ||_________________W3_________________||
1226 | ____________________________________ |
1227 || ||
1228 ||_________________W4_________________||
974 |__________________W1__________________| 1229 |__________________W1__________________|
975 1230
976@end group 1231@end group
977@end smallexample 1232@end smallexample
978 1233
979@noindent 1234@noindent
980The newly-created window, @code{W4}, shares the same internal window 1235If @code{window-combination-resize} is @code{t}, splitting @code{W3}
981@code{W1}. If @code{W4} is resized, it is allowed to resize the other 1236instead leaves all three live windows with approximately the same
982live window, @code{W3}. 1237height:
983
984 If @code{window-combination-limit} is @code{t}, splitting @code{W2}
985in the initial configuration would instead have produced this:
986 1238
987@smallexample 1239@smallexample
988@group 1240@group
989 ______________________________________ 1241 ______________________________________
990 | ____________________________________ | 1242 | ____________________________________ |
991 || __________________________________ || 1243 || ||
992 ||| ||| 1244 || ||
993 |||________________W2________________||| 1245 ||_________________W2_________________||
994 || __________________________________ ||
995 ||| |||
996 |||________________W4________________|||
997 ||_________________W5_________________||
998 | ____________________________________ | 1246 | ____________________________________ |
999 || || 1247 || ||
1000 || || 1248 || ||
1001 ||_________________W3_________________|| 1249 ||_________________W3_________________||
1250 | ____________________________________ |
1251 || ||
1252 || ||
1253 ||_________________W4_________________||
1002 |__________________W1__________________| 1254 |__________________W1__________________|
1003 1255
1004@end group 1256@end group
1005@end smallexample 1257@end smallexample
1006 1258
1007@noindent 1259@noindent
1008A new internal window @code{W5} has been created; its children are 1260Deleting any of the live windows @code{W2}, @code{W3} or @code{W4} will
1009@code{W2} and the new live window @code{W4}. Now, @code{W2} is the 1261distribute its space proportionally among the two remaining live
1010only sibling of @code{W4}, so resizing @code{W4} will resize 1262windows.
1011@code{W2}, leaving @code{W3} unaffected.
1012
1013 For interactive use, Emacs provides two commands which always split
1014the selected window. These call @code{split-window} internally.
1015
1016@deffn Command split-window-right &optional size
1017This function splits the selected window into two side-by-side
1018windows, putting the selected window on the left. If @var{size} is
1019positive, the left window gets @var{size} columns; if @var{size} is
1020negative, the right window gets @minus{}@var{size} columns.
1021@end deffn
1022
1023@deffn Command split-window-below &optional size
1024This function splits the selected window into two windows, one above
1025the other, leaving the upper window selected. If @var{size} is
1026positive, the upper window gets @var{size} lines; if @var{size} is
1027negative, the lower window gets @minus{}@var{size} lines.
1028@end deffn
1029
1030@defopt split-window-keep-point
1031If the value of this variable is non-@code{nil} (the default),
1032@code{split-window-below} behaves as described above.
1033 1263
1034If it is @code{nil}, @code{split-window-below} adjusts point in each
1035of the two windows to minimize redisplay. (This is useful on slow
1036terminals.) It selects whichever window contains the screen line that
1037point was previously on. Note that this only affects
1038@code{split-window-below}, not the lower-level @code{split-window}
1039function.
1040@end defopt
1041
1042@node Deleting Windows
1043@section Deleting Windows
1044@cindex deleting windows
1045
1046 @dfn{Deleting} a window removes it from the frame's window tree. If
1047the window is a live window, it disappears from the screen. If the
1048window is an internal window, its child windows are deleted too.
1049
1050 Even after a window is deleted, it continues to exist as a Lisp
1051object, until there are no more references to it. Window deletion can
1052be reversed, by restoring a saved window configuration (@pxref{Window
1053Configurations}).
1054
1055@deffn Command delete-window &optional window
1056This function removes @var{window} from display and returns
1057@code{nil}. If @var{window} is omitted or @code{nil}, it defaults to
1058the selected window. If deleting the window would leave no more
1059windows in the window tree (e.g. if it is the only live window in the
1060frame), an error is signaled.
1061
1062By default, the space taken up by @var{window} is given to one of its
1063adjacent sibling windows, if any. However, if the variable
1064@code{window-combination-resize} is non-@code{nil}, the space is
1065proportionally distributed among any remaining windows in the window
1066combination. @xref{Splitting Windows}.
1067
1068The behavior of this function may be altered by the window parameters
1069of @var{window}, so long as the variable
1070@code{ignore-window-parameters} is @code{nil}. If the value of
1071the @code{delete-window} window parameter is @code{t}, this function
1072ignores all other window parameters. Otherwise, if the value of the
1073@code{delete-window} window parameter is a function, that function is
1074called with the argument @var{window}, in lieu of the usual action of
1075@code{delete-window}. Otherwise, this function obeys the
1076@code{window-atom} or @code{window-side} window parameter, if any.
1077@xref{Window Parameters}.
1078@end deffn
1079
1080@deffn Command delete-other-windows &optional window
1081This function makes @var{window} fill its frame, by deleting other
1082windows as necessary. If @var{window} is omitted or @code{nil}, it
1083defaults to the selected window. The return value is @code{nil}.
1084
1085The behavior of this function may be altered by the window parameters
1086of @var{window}, so long as the variable
1087@code{ignore-window-parameters} is @code{nil}. If the value of
1088the @code{delete-other-windows} window parameter is @code{t}, this
1089function ignores all other window parameters. Otherwise, if the value
1090of the @code{delete-other-windows} window parameter is a function,
1091that function is called with the argument @var{window}, in lieu of the
1092usual action of @code{delete-other-windows}. Otherwise, this function
1093obeys the @code{window-atom} or @code{window-side} window parameter,
1094if any. @xref{Window Parameters}.
1095@end deffn
1096
1097@deffn Command delete-windows-on &optional buffer-or-name frame
1098This function deletes all windows showing @var{buffer-or-name}, by
1099calling @code{delete-window} on those windows. @var{buffer-or-name}
1100should be a buffer, or the name of a buffer; if omitted or @code{nil},
1101it defaults to the current buffer. If there are no windows showing
1102the specified buffer, this function does nothing. If the specified
1103buffer is a minibuffer, an error is signaled.
1104
1105If there is a dedicated window showing the buffer, and that window is
1106the only one on its frame, this function also deletes that frame if it
1107is not the only frame on the terminal.
1108
1109The optional argument @var{frame} specifies which frames to operate
1110on:
1111
1112@itemize @bullet
1113@item @code{nil}
1114means operate on all frames.
1115@item @code{t}
1116means operate on the selected frame.
1117@item @code{visible}
1118means operate on all visible frames.
1119@item @code{0}
1120means operate on all visible or iconified frames.
1121@item A frame
1122means operate on that frame.
1123@end itemize
1124
1125Note that this argument does not have the same meaning as in other
1126functions which scan all live windows (@pxref{Cyclic Window
1127Ordering}). Specifically, the meanings of @code{t} and @code{nil} here
1128are the opposite of what they are in those other functions.
1129@end deffn
1130 1264
1131@node Selecting Windows 1265@node Selecting Windows
1132@section Selecting Windows 1266@section Selecting Windows
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 0a32fd82044..7322613e0db 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,52 @@
12012-11-13 Glenn Morris <rgm@gnu.org>
2
3 * flymake.texi (Customizable variables)
4 (Highlighting erroneous lines): Mention flymake-error-bitmap,
5 flymake-warning-bitmap, and flymake-fringe-indicator-position.
6
72012-11-12 Vincent Belaïche <vincentb1@users.sourceforge.net>
8
9 * ses.texi: Doc for ses-rename-cell, ses-repair-cell-reference-all & ses-range.
10 In all file place SES into @acronym{...}.
11 (Advanced Features): Add key index and function index for
12 ses-set-header-row. Add description for function
13 ses-rename-cell. Add description for function
14 ses-repair-cell-reference-all.
15 (Ranges in formulas): Add description for ses-range flags.
16
172012-11-12 Paul Eggert <eggert@cs.ucla.edu>
18
19 * texinfo.tex: Merge from gnulib.
20
212012-11-10 Chong Yidong <cyd@gnu.org>
22
23 * url.texi (Introduction): Move url-configuration-directory to
24 Customization node.
25 (Parsed URIs): Split into its own node.
26 (URI Encoding): New node.
27 (Defining New URLs): Remove empty chapter.
28 (Retrieving URLs): Add an introduction. Doc fix for url-retrieve.
29 Improve docs for url-queue-*.
30 (Supported URL Types): Copyedits. Delete empty subnodes.
31
32 * url.texi (Introduction): Rename from Getting Started. Rewrite
33 the introduction.
34 (URI Parsing): Rewrite. Omit the obsolete attributes slot.
35
362012-11-10 Glenn Morris <rgm@gnu.org>
37
38 * cl.texi (Obsolete Setf Customization):
39 Revert defsetf example to the more correct let rather than prog1.
40 Give define-modify-macro, defsetf, and define-setf-method
41 gv.el replacements.
42
43 * cl.texi (Overview): Mention EIEIO here, as well as the appendix.
44 (Setf Extensions): Remove obsolete reference.
45 (Obsolete Setf Customization):
46 Move note on lack of setf functions to lispref/variables.texi.
47 Undocument get-setf-method, since it no longer exists.
48 Mention simple defsetf replaced by gv-define-simple-setter.
49
12012-11-03 Glenn Morris <rgm@gnu.org> 502012-11-03 Glenn Morris <rgm@gnu.org>
2 51
3 * cl.texi: Further general copyedits. 52 * cl.texi: Further general copyedits.
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index e182c2600f9..a50be1027f3 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -107,7 +107,8 @@ for various reasons:
107@item 107@item
108Some features are too complex or bulky relative to their benefit 108Some features are too complex or bulky relative to their benefit
109to Emacs Lisp programmers. CLOS and Common Lisp streams are fine 109to Emacs Lisp programmers. CLOS and Common Lisp streams are fine
110examples of this group. 110examples of this group. (The separate package EIEIO implements
111a subset of CLOS functionality. @xref{Top, , Introduction, eieio, EIEIO}.)
111 112
112@item 113@item
113Other features cannot be implemented without modification to the 114Other features cannot be implemented without modification to the
@@ -974,7 +975,7 @@ a
974The generalized variable @code{buffer-substring}, listed above, 975The generalized variable @code{buffer-substring}, listed above,
975also works in this way by replacing a portion of the current buffer. 976also works in this way by replacing a portion of the current buffer.
976 977
977@c FIXME? Also `eq'? (see cl-lib.el) 978@c FIXME? Also `eq'? (see cl-lib.el)
978 979
979@c Currently commented out in cl.el. 980@c Currently commented out in cl.el.
980@ignore 981@ignore
@@ -989,13 +990,10 @@ only interesting when used with places you define yourself with
989@xref{Obsolete Setf Customization}. 990@xref{Obsolete Setf Customization}.
990@end ignore 991@end ignore
991 992
993@c FIXME? Is this still true?
992@item 994@item
993A macro call, in which case the macro is expanded and @code{setf} 995A macro call, in which case the macro is expanded and @code{setf}
994is applied to the resulting form. 996is applied to the resulting form.
995
996@item
997Any form for which a @code{defsetf} or @code{define-setf-method}
998has been made. @xref{Obsolete Setf Customization}.
999@end itemize 997@end itemize
1000 998
1001@c FIXME should this be in lispref? It seems self-evident. 999@c FIXME should this be in lispref? It seems self-evident.
@@ -2867,7 +2865,6 @@ temporary variables.
2867This function creates a new, uninterned symbol (using @code{make-symbol}) 2865This function creates a new, uninterned symbol (using @code{make-symbol})
2868with a unique name. (The name of an uninterned symbol is relevant 2866with a unique name. (The name of an uninterned symbol is relevant
2869only if the symbol is printed.) By default, the name is generated 2867only if the symbol is printed.) By default, the name is generated
2870@c FIXME no longer true?
2871from an increasing sequence of numbers, @samp{G1000}, @samp{G1001}, 2868from an increasing sequence of numbers, @samp{G1000}, @samp{G1001},
2872@samp{G1002}, etc. If the optional argument @var{x} is a string, that 2869@samp{G1002}, etc. If the optional argument @var{x} is a string, that
2873string is used as a prefix instead of @samp{G}. Uninterned symbols 2870string is used as a prefix instead of @samp{G}. Uninterned symbols
@@ -4481,14 +4478,6 @@ The @code{equal} predicate does not distinguish
4481between IEEE floating-point plus and minus zero. The @code{cl-equalp} 4478between IEEE floating-point plus and minus zero. The @code{cl-equalp}
4482predicate has several differences with Common Lisp; @pxref{Predicates}. 4479predicate has several differences with Common Lisp; @pxref{Predicates}.
4483 4480
4484@c FIXME consider moving to lispref
4485@ignore
4486The @code{setf} mechanism is entirely compatible, except that
4487setf-methods return a list of five values rather than five
4488values directly. Also, the new ``@code{setf} function'' concept
4489(typified by @code{(defun (setf foo) @dots{})}) is not implemented.
4490@end ignore
4491
4492The @code{cl-do-all-symbols} form is the same as @code{cl-do-symbols} 4481The @code{cl-do-all-symbols} form is the same as @code{cl-do-symbols}
4493with no @var{obarray} argument. In Common Lisp, this form would 4482with no @var{obarray} argument. In Common Lisp, this form would
4494iterate over all symbols in all packages. Since Emacs obarrays 4483iterate over all symbols in all packages. Since Emacs obarrays
@@ -4907,15 +4896,17 @@ Common Lisp defines three macros, @code{define-modify-macro},
4907@code{defsetf}, and @code{define-setf-method}, that allow the 4896@code{defsetf}, and @code{define-setf-method}, that allow the
4908user to extend generalized variables in various ways. 4897user to extend generalized variables in various ways.
4909In Emacs, these are obsolete, replaced by various features of 4898In Emacs, these are obsolete, replaced by various features of
4910@file{gv.el} in Emacs 24.3. Many of the implementation 4899@file{gv.el} in Emacs 24.3.
4911details in the following are out-of-date. 4900@xref{Adding Generalized Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
4912@c FIXME this whole section needs updating. 4901
4913 4902
4914@defmac define-modify-macro name arglist function [doc-string] 4903@defmac define-modify-macro name arglist function [doc-string]
4915This macro defines a ``read-modify-write'' macro similar to 4904This macro defines a ``read-modify-write'' macro similar to
4916@code{cl-incf} and @code{cl-decf}. The macro @var{name} is defined 4905@code{cl-incf} and @code{cl-decf}. You can replace this macro
4917to take a @var{place} argument followed by additional arguments 4906with @code{gv-letplace}.
4918described by @var{arglist}. The call 4907
4908The macro @var{name} is defined to take a @var{place} argument
4909followed by additional arguments described by @var{arglist}. The call
4919 4910
4920@example 4911@example
4921(@var{name} @var{place} @var{args}@dots{}) 4912(@var{name} @var{place} @var{args}@dots{})
@@ -4938,8 +4929,8 @@ which in turn is roughly equivalent to
4938For example: 4929For example:
4939 4930
4940@example 4931@example
4941(define-modify-macro cl-incf (&optional (n 1)) +) 4932(define-modify-macro incf (&optional (n 1)) +)
4942(define-modify-macro cl-concatf (&rest args) concat) 4933(define-modify-macro concatf (&rest args) concat)
4943@end example 4934@end example
4944 4935
4945Note that @code{&key} is not allowed in @var{arglist}, but 4936Note that @code{&key} is not allowed in @var{arglist}, but
@@ -4948,16 +4939,31 @@ Note that @code{&key} is not allowed in @var{arglist}, but
4948Most of the modify macros defined by Common Lisp do not exactly 4939Most of the modify macros defined by Common Lisp do not exactly
4949follow the pattern of @code{define-modify-macro}. For example, 4940follow the pattern of @code{define-modify-macro}. For example,
4950@code{push} takes its arguments in the wrong order, and @code{pop} 4941@code{push} takes its arguments in the wrong order, and @code{pop}
4951is completely irregular. You can define these macros ``by hand'' 4942is completely irregular.
4952using @code{get-setf-method}, or consult the source 4943
4953to see how to use the internal @code{setf} building blocks. 4944The above @code{incf} example could be written using
4945@code{gv-letplace} as:
4946@example
4947(defmacro incf (place &optional n)
4948 (gv-letplace (getter setter) place
4949 (macroexp-let2 nil v (or n 1)
4950 (funcall setter `(+ ,v ,getter)))))
4951@end example
4952@ignore
4953(defmacro concatf (place &rest args)
4954 (gv-letplace (getter setter) place
4955 (macroexp-let2 nil v (mapconcat 'identity args "")
4956 (funcall setter `(concat ,getter ,v)))))
4957@end ignore
4954@end defmac 4958@end defmac
4955 4959
4956@defmac defsetf access-fn update-fn 4960@defmac defsetf access-fn update-fn
4957This is the simpler of two @code{defsetf} forms. Where 4961This is the simpler of two @code{defsetf} forms, and is
4958@var{access-fn} is the name of a function which accesses a place, 4962replaced by @code{gv-define-simple-setter}.
4959this declares @var{update-fn} to be the corresponding store 4963
4960function. From now on, 4964With @var{access-fn} the name of a function that accesses a place,
4965this declares @var{update-fn} to be the corresponding store function.
4966From now on,
4961 4967
4962@example 4968@example
4963(setf (@var{access-fn} @var{arg1} @var{arg2} @var{arg3}) @var{value}) 4969(setf (@var{access-fn} @var{arg1} @var{arg2} @var{arg3}) @var{value})
@@ -4972,7 +4978,7 @@ will be expanded to
4972 4978
4973@noindent 4979@noindent
4974The @var{update-fn} is required to be either a true function, or 4980The @var{update-fn} is required to be either a true function, or
4975a macro which evaluates its arguments in a function-like way. Also, 4981a macro that evaluates its arguments in a function-like way. Also,
4976the @var{update-fn} is expected to return @var{value} as its result. 4982the @var{update-fn} is expected to return @var{value} as its result.
4977Otherwise, the above expansion would not obey the rules for the way 4983Otherwise, the above expansion would not obey the rules for the way
4978@code{setf} is supposed to behave. 4984@code{setf} is supposed to behave.
@@ -4988,25 +4994,32 @@ something more like
4988 temp) 4994 temp)
4989@end example 4995@end example
4990 4996
4991Some examples of the use of @code{defsetf}, drawn from the standard 4997Some examples are:
4992suite of setf methods, are:
4993 4998
4994@example 4999@example
4995(defsetf car setcar) 5000(defsetf car setcar)
4996(defsetf symbol-value set)
4997(defsetf buffer-name rename-buffer t) 5001(defsetf buffer-name rename-buffer t)
4998@end example 5002@end example
5003
5004These translate directly to @code{gv-define-simple-setter}:
5005
5006@example
5007(gv-define-simple-setter car setcar)
5008(gv-define-simple-setter buffer-name rename-buffer t)
5009@end example
4999@end defmac 5010@end defmac
5000 5011
5001@defmac defsetf access-fn arglist (store-var) forms@dots{} 5012@defmac defsetf access-fn arglist (store-var) forms@dots{}
5002This is the second, more complex, form of @code{defsetf}. It is 5013This is the second, more complex, form of @code{defsetf}.
5003rather like @code{defmacro} except for the additional @var{store-var} 5014It can be replaced by @code{gv-define-setter}.
5004argument. The @var{forms} should return a Lisp form that stores 5015
5005the value of @var{store-var} into the generalized variable formed 5016This form of @code{defsetf} is rather like @code{defmacro} except for
5006by a call to @var{access-fn} with arguments described by @var{arglist}. 5017the additional @var{store-var} argument. The @var{forms} should
5007The @var{forms} may begin with a string which documents the @code{setf} 5018return a Lisp form that stores the value of @var{store-var} into the
5008method (analogous to the doc string that appears at the front of a 5019generalized variable formed by a call to @var{access-fn} with
5009function). 5020arguments described by @var{arglist}. The @var{forms} may begin with
5021a string which documents the @code{setf} method (analogous to the doc
5022string that appears at the front of a function).
5010 5023
5011For example, the simple form of @code{defsetf} is shorthand for 5024For example, the simple form of @code{defsetf} is shorthand for
5012 5025
@@ -5021,20 +5034,28 @@ macros like @code{cl-incf} that invoke this
5021setf-method will insert temporary variables as needed to make 5034setf-method will insert temporary variables as needed to make
5022sure the apparent order of evaluation is preserved. 5035sure the apparent order of evaluation is preserved.
5023 5036
5024Another example drawn from the standard package: 5037Another standard example:
5025 5038
5026@example 5039@example
5027(defsetf nth (n x) (store) 5040(defsetf nth (n x) (store)
5028 (list 'setcar (list 'nthcdr n x) store)) 5041 `(setcar (nthcdr ,n ,x) ,store))
5042@end example
5043
5044You could write this using @code{gv-define-setter} as:
5045
5046@example
5047(gv-define-setter nth (store n x)
5048 `(setcar (nthcdr ,n ,x) ,store))
5029@end example 5049@end example
5030@end defmac 5050@end defmac
5031 5051
5032@defmac define-setf-method access-fn arglist forms@dots{} 5052@defmac define-setf-method access-fn arglist forms@dots{}
5033This is the most general way to create new place forms. When 5053This is the most general way to create new place forms. You can
5034a @code{setf} to @var{access-fn} with arguments described by 5054replace this by @code{gv-define-setter} or @code{gv-define-expander}.
5035@var{arglist} is expanded, the @var{forms} are evaluated and 5055
5036must return a list of five items: 5056When a @code{setf} to @var{access-fn} with arguments described by
5037@c FIXME Is this still true? 5057@var{arglist} is expanded, the @var{forms} are evaluated and must
5058return a list of five items:
5038 5059
5039@enumerate 5060@enumerate
5040@item 5061@item
@@ -5063,6 +5084,9 @@ This is exactly like the Common Lisp macro of the same name,
5063except that the method returns a list of five values rather 5084except that the method returns a list of five values rather
5064than the five values themselves, since Emacs Lisp does not 5085than the five values themselves, since Emacs Lisp does not
5065support Common Lisp's notion of multiple return values. 5086support Common Lisp's notion of multiple return values.
5087(Note that the @code{setf} implementation provided by @file{gv.el}
5088does not use this five item format. Its use here is only for
5089backwards compatibility.)
5066 5090
5067Once again, the @var{forms} may begin with a documentation string. 5091Once again, the @var{forms} may begin with a documentation string.
5068 5092
@@ -5078,45 +5102,22 @@ turn out to be unnecessary, so there is little reason for the
5078setf-method itself to optimize. 5102setf-method itself to optimize.
5079@end defmac 5103@end defmac
5080 5104
5105@c Removed in Emacs 24.3, not possible to make a compatible replacement.
5106@ignore
5081@defun get-setf-method place &optional env 5107@defun get-setf-method place &optional env
5082This function returns the setf-method for @var{place}, by 5108This function returns the setf-method for @var{place}, by
5083invoking the definition previously recorded by @code{defsetf} 5109invoking the definition previously recorded by @code{defsetf}
5084or @code{define-setf-method}. The result is a list of five 5110or @code{define-setf-method}. The result is a list of five
5085values as described above. You can use this function to build 5111values as described above. You can use this function to build
5086your own @code{cl-incf}-like modify macros. 5112your own @code{cl-incf}-like modify macros.
5087@c These no longer exist.
5088@ignore
5089(Actually, it is better to use the internal functions
5090@code{cl-setf-do-modify} and @code{cl-setf-do-store}, which are a bit
5091easier to use and which also do a number of optimizations; consult the
5092source code for the @code{cl-incf} function for a simple example.)
5093@end ignore
5094 5113
5095The argument @var{env} specifies the ``environment'' to be 5114The argument @var{env} specifies the ``environment'' to be
5096passed on to @code{macroexpand} if @code{get-setf-method} should 5115passed on to @code{macroexpand} if @code{get-setf-method} should
5097need to expand a macro in @var{place}. It should come from 5116need to expand a macro in @var{place}. It should come from
5098an @code{&environment} argument to the macro or setf-method 5117an @code{&environment} argument to the macro or setf-method
5099that called @code{get-setf-method}. 5118that called @code{get-setf-method}.
5100
5101@c FIXME No longer true.
5102See also the source code for the setf-method for
5103@c Also @code{apply}, but that is commented out.
5104@code{substring}, which works by calling @code{get-setf-method} on a
5105simpler case, then massaging the result.
5106@end defun 5119@end defun
5107 5120@end ignore
5108@c FIXME does not belong here any more, maybe in lispref?
5109Modern Common Lisp defines a second, independent way to specify
5110the @code{setf} behavior of a function, namely ``@code{setf}
5111functions'' whose names are lists @code{(setf @var{name})}
5112rather than symbols. For example, @code{(defun (setf foo) @dots{})}
5113defines the function that is used when @code{setf} is applied to
5114@code{foo}. This package does not currently support @code{setf}
5115functions. In particular, it is a compile-time error to use
5116@code{setf} on a form which has not already been @code{defsetf}'d
5117or otherwise declared; in newer Common Lisps, this would not be
5118an error since the function @code{(setf @var{func})} might be
5119defined later.
5120 5121
5121 5122
5122@node GNU Free Documentation License 5123@node GNU Free Documentation License
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index 28fb7864f06..4a873490e86 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -337,6 +337,17 @@ been reported.
337A custom face for highlighting lines for which at least one warning 337A custom face for highlighting lines for which at least one warning
338and no errors have been reported. 338and no errors have been reported.
339 339
340@item flymake-error-bitmap
341A bitmap used in the fringe to mark lines for which an error has
342been reported.
343
344@item flymake-warning-bitmap
345A bitmap used in the fringe to mark lines for which a warning has
346been reported.
347
348@item flymake-fringe-indicator-position
349Which fringe (if any) should show the warning/error bitmaps.
350
340@end table 351@end table
341 352
342@node Adding support for a new syntax check tool 353@node Adding support for a new syntax check tool
@@ -718,6 +729,15 @@ are used: @code{flymake-errline} and
718@code{flymake-warnline}. Errors belonging outside the current 729@code{flymake-warnline}. Errors belonging outside the current
719buffer are considered to belong to line 1 of the current buffer. 730buffer are considered to belong to line 1 of the current buffer.
720 731
732@c This manual does not use vindex.
733@c @vindex flymake-fringe-indicator-position
734@c @vindex flymake-error-bitmap
735@c @vindex flymake-warning-bitmap
736If the option @code{flymake-fringe-indicator-position} is non-@code{nil},
737errors and warnings are also highlighted in the left or right fringe,
738using the bitmaps specified by @code{flymake-error-bitmap}
739and @code{flymake-warning-bitmap}.
740
721@node Interaction with other modes 741@node Interaction with other modes
722@section Interaction with other modes 742@section Interaction with other modes
723@cindex Interaction with other modes 743@cindex Interaction with other modes
diff --git a/doc/misc/ses.texi b/doc/misc/ses.texi
index a70bb9c407e..5de87a2f1c7 100644
--- a/doc/misc/ses.texi
+++ b/doc/misc/ses.texi
@@ -1,7 +1,7 @@
1\input texinfo @c -*-texinfo-*- 1\input texinfo @c -*-texinfo-*-
2@c %**start of header 2@c %**start of header
3@setfilename ../../info/ses 3@setfilename ../../info/ses
4@settitle SES: Simple Emacs Spreadsheet 4@settitle @acronym{SES}: Simple Emacs Spreadsheet
5@setchapternewpage off 5@setchapternewpage off
6@syncodeindex fn cp 6@syncodeindex fn cp
7@syncodeindex vr cp 7@syncodeindex vr cp
@@ -9,7 +9,7 @@
9@c %**end of header 9@c %**end of header
10 10
11@copying 11@copying
12This file documents SES: the Simple Emacs Spreadsheet. 12This file documents @acronym{SES}: the Simple Emacs Spreadsheet.
13 13
14Copyright @copyright{} 2002-2012 Free Software Foundation, Inc. 14Copyright @copyright{} 2002-2012 Free Software Foundation, Inc.
15 15
@@ -29,13 +29,13 @@ developing GNU and promoting software freedom.''
29 29
30@dircategory Emacs misc features 30@dircategory Emacs misc features
31@direntry 31@direntry
32* SES: (ses). Simple Emacs Spreadsheet. 32* @acronym{SES}: (ses). Simple Emacs Spreadsheet.
33@end direntry 33@end direntry
34 34
35@finalout 35@finalout
36 36
37@titlepage 37@titlepage
38@title SES 38@title @acronym{SES}
39@subtitle Simple Emacs Spreadsheet 39@subtitle Simple Emacs Spreadsheet
40@author Jonathan A. Yavner 40@author Jonathan A. Yavner
41@author @email{jyavner@@member.fsf.org} 41@author @email{jyavner@@member.fsf.org}
@@ -52,10 +52,10 @@ developing GNU and promoting software freedom.''
52@ifnottex 52@ifnottex
53@node Top, Sales Pitch, (dir), (dir) 53@node Top, Sales Pitch, (dir), (dir)
54@comment node-name, next, previous, up 54@comment node-name, next, previous, up
55@top SES: Simple Emacs Spreadsheet 55@top @acronym{SES}: Simple Emacs Spreadsheet
56 56
57@display 57@display
58SES is a major mode for GNU Emacs to edit spreadsheet files, which 58@acronym{SES} is a major mode for GNU Emacs to edit spreadsheet files, which
59contain a rectangular grid of cells. The cells' values are specified 59contain a rectangular grid of cells. The cells' values are specified
60by formulas that can refer to the values of other cells. 60by formulas that can refer to the values of other cells.
61@end display 61@end display
@@ -66,7 +66,7 @@ To report bugs, send email to @email{jyavner@@member.fsf.org}.
66@insertcopying 66@insertcopying
67 67
68@menu 68@menu
69* Sales Pitch:: Why use SES? 69* Sales Pitch:: Why use @acronym{SES}?
70* The Basics:: Basic spreadsheet commands 70* The Basics:: Basic spreadsheet commands
71* Advanced Features:: Want to know more? 71* Advanced Features:: Want to know more?
72* For Gurus:: Want to know @emph{even more}? 72* For Gurus:: Want to know @emph{even more}?
@@ -126,9 +126,9 @@ Moves point to cell, specified by identifier (@code{ses-jump}).
126 126
127Point is always at the left edge of a cell, or at the empty endline. 127Point is always at the left edge of a cell, or at the empty endline.
128When mark is inactive, the current cell is underlined. When mark is 128When mark is inactive, the current cell is underlined. When mark is
129active, the range is the highlighted rectangle of cells (SES always 129active, the range is the highlighted rectangle of cells (@acronym{SES} always
130uses transient mark mode). Drag the mouse from A1 to A3 to create the 130uses transient mark mode). Drag the mouse from A1 to A3 to create the
131range A1-A2. Many SES commands operate only on single cells, not 131range A1-A2. Many @acronym{SES} commands operate only on single cells, not
132ranges. 132ranges.
133 133
134@table @kbd 134@table @kbd
@@ -155,7 +155,7 @@ Highlight all cells (@code{mark-whole-buffer}).
155* Printer functions:: 155* Printer functions::
156* Clearing cells:: 156* Clearing cells::
157* Copy/cut/paste:: 157* Copy/cut/paste::
158* Customizing SES:: 158* Customizing @acronym{SES}::
159@end menu 159@end menu
160 160
161@node Formulas, Resizing, The Basics, The Basics 161@node Formulas, Resizing, The Basics, The Basics
@@ -192,7 +192,7 @@ this cell's formula will be reevaluated. While typing in the
192expression, you can use @kbd{M-@key{TAB}} to complete symbol names. 192expression, you can use @kbd{M-@key{TAB}} to complete symbol names.
193 193
194@item ' @r{(apostrophe)} 194@item ' @r{(apostrophe)}
195Enter a symbol (ses-read-symbol). SES remembers all symbols that have 195Enter a symbol (ses-read-symbol). @acronym{SES} remembers all symbols that have
196been used as formulas, so you can type just the beginning of a symbol 196been used as formulas, so you can type just the beginning of a symbol
197and use @kbd{@key{SPC}}, @kbd{@key{TAB}}, and @kbd{?} to complete it. 197and use @kbd{@key{SPC}}, @kbd{@key{TAB}}, and @kbd{?} to complete it.
198@end table 198@end table
@@ -349,7 +349,7 @@ Clear cell and move right (@code{ses-clear-cell-forward}).
349@end table 349@end table
350 350
351 351
352@node Copy/cut/paste, Customizing SES, Clearing cells, The Basics 352@node Copy/cut/paste, Customizing @acronym{SES}, Clearing cells, The Basics
353@section Copy, cut, and paste 353@section Copy, cut, and paste
354@cindex copy 354@cindex copy
355@cindex cut 355@cindex cut
@@ -365,7 +365,7 @@ Clear cell and move right (@code{ses-clear-cell-forward}).
365@findex ses-yank-pop 365@findex ses-yank-pop
366 366
367The copy functions work on rectangular regions of cells. You can paste the 367The copy functions work on rectangular regions of cells. You can paste the
368copies into non-SES buffers to export the print text. 368copies into non-@acronym{SES} buffers to export the print text.
369 369
370@table @kbd 370@table @kbd
371@item M-w 371@item M-w
@@ -394,7 +394,7 @@ Paste from kill ring (@code{yank}). The paste functions behave
394differently depending on the format of the text being inserted: 394differently depending on the format of the text being inserted:
395@itemize @bullet 395@itemize @bullet
396@item 396@item
397When pasting cells that were cut from a SES buffer, the print text is 397When pasting cells that were cut from a @acronym{SES} buffer, the print text is
398ignored and only the attached formula and printer are inserted; cell 398ignored and only the attached formula and printer are inserted; cell
399references in the formula are relocated unless you use @kbd{C-u}. 399references in the formula are relocated unless you use @kbd{C-u}.
400@item 400@item
@@ -402,7 +402,7 @@ The pasted text overwrites a rectangle of cells whose top left corner
402is the current cell. If part of the rectangle is beyond the edges of 402is the current cell. If part of the rectangle is beyond the edges of
403the spreadsheet, you must confirm the increase in spreadsheet size. 403the spreadsheet, you must confirm the increase in spreadsheet size.
404@item 404@item
405Non-SES text is usually inserted as a replacement formula for the 405Non-@acronym{SES} text is usually inserted as a replacement formula for the
406current cell. If the formula would be a symbol, it's treated as a 406current cell. If the formula would be a symbol, it's treated as a
407string unless you use @kbd{C-u}. Pasted formulas with syntax errors 407string unless you use @kbd{C-u}. Pasted formulas with syntax errors
408are always treated as strings. 408are always treated as strings.
@@ -420,12 +420,12 @@ Set point and paste from secondary clipboard (@code{mouse-yank-secondary}).
420@item M-y 420@item M-y
421Immediately after a paste, you can replace the text with a preceding 421Immediately after a paste, you can replace the text with a preceding
422element from the kill ring (@code{ses-yank-pop}). Unlike the standard 422element from the kill ring (@code{ses-yank-pop}). Unlike the standard
423Emacs yank-pop, the SES version uses @code{undo} to delete the old 423Emacs yank-pop, the @acronym{SES} version uses @code{undo} to delete the old
424yank. This doesn't make any difference? 424yank. This doesn't make any difference?
425@end table 425@end table
426 426
427@node Customizing SES, , Copy/cut/paste, The Basics 427@node Customizing @acronym{SES}, , Copy/cut/paste, The Basics
428@section Customizing SES 428@section Customizing @acronym{SES}
429@cindex customizing 429@cindex customizing
430@vindex enable-local-eval 430@vindex enable-local-eval
431@vindex ses-mode-hook 431@vindex ses-mode-hook
@@ -443,7 +443,7 @@ up or down. For diagonal movement, select two functions from the
443list. 443list.
444 444
445@code{ses-mode-hook} is a normal mode hook (list of functions to 445@code{ses-mode-hook} is a normal mode hook (list of functions to
446execute when starting SES mode for a buffer). 446execute when starting @acronym{SES} mode for a buffer).
447 447
448The variable @code{safe-functions} is a list of possibly-unsafe 448The variable @code{safe-functions} is a list of possibly-unsafe
449functions to be treated as safe when analyzing formulas and printers. 449functions to be treated as safe when analyzing formulas and printers.
@@ -469,7 +469,10 @@ safety belts!
469 469
470@table @kbd 470@table @kbd
471@item C-c M-C-h 471@item C-c M-C-h
472(@code{ses-set-header-row}). The header line at the top of the SES 472(@code{ses-set-header-row}).
473@findex ses-set-header-row
474@kindex C-c M-C-h
475The header line at the top of the @acronym{SES}
473window normally shows the column letter for each column. You can set 476window normally shows the column letter for each column. You can set
474it to show a copy of some row, such as a row of column titles, so that 477it to show a copy of some row, such as a row of column titles, so that
475row will always be visible. Default is to set the current row as the 478row will always be visible. Default is to set the current row as the
@@ -478,6 +481,16 @@ show column letters again.
478@item [header-line mouse-3] 481@item [header-line mouse-3]
479Pops up a menu to set the current row as the header, or revert to 482Pops up a menu to set the current row as the header, or revert to
480column letters. 483column letters.
484@item M-x ses-rename-cell
485@findex ses-rename-cell
486Rename a cell from a standard A1-like name to any
487string.
488@item M-x ses-repair-cell-reference-all
489@findex ses-repair-cell-reference-all
490When you interrupt a cell formula update by clicking @kbd{C-g}, then
491the cell reference link may be broken, which will jeopardize automatic
492cell update when any other cell on which it depends is changed. To
493repair that use function @code{ses-repair-cell-reference-all}
481@end table 494@end table
482 495
483@menu 496@menu
@@ -498,9 +511,9 @@ column letters.
498@findex ses-renarrow-buffer 511@findex ses-renarrow-buffer
499@findex ses-reprint-all 512@findex ses-reprint-all
500 513
501A SES file consists of a print area and a data area. Normally the 514A @acronym{SES} file consists of a print area and a data area. Normally the
502buffer is narrowed to show only the print area. The print area is 515buffer is narrowed to show only the print area. The print area is
503read-only except for special SES commands; it contains cell values 516read-only except for special @acronym{SES} commands; it contains cell values
504formatted by printer functions. The data area records the formula and 517formatted by printer functions. The data area records the formula and
505printer functions, etc. 518printer functions, etc.
506 519
@@ -576,6 +589,52 @@ If you insert a new row just beyond the end of a one-column range, or
576a new column just beyond a one-row range, the new cell is included in 589a new column just beyond a one-row range, the new cell is included in
577the range. New cells inserted just before a range are not included. 590the range. New cells inserted just before a range are not included.
578 591
592Flags can be added to @code{ses-range} immediately after the @var{to}
593cell.
594@table @code
595@item !
596Empty cells in range can be removed by adding the @code{!} flag. An
597empty cell is a cell the value of which is one of symbols @code{nil}
598or @code{*skip*}. For instance @code{(ses-range A1 A4 !)} will do the
599same as @code{(list A1 A3)} when cells @code{A2} and @code{A4} are
600empty.
601@item _
602Empty cell values are replaced by the argument following flag
603@code{_}, or @code{0} when flag @code{_} is last in argument list. For
604instance @code{(ses-range A1 A4 _ "empty")} will do the same as
605@code{(list A1 "empty" A3 "empty")} when cells @code{A2} and @code{A4}
606are empty. Similarly, @code{(ses-range A1 A4 _ )} will do the same as
607@code{(list A1 0 A3 0)}.
608@item >v
609When order matters, list cells by reading cells rowwise from top left
610to bottom right. This flag is provided for completeness only as it is
611the default reading order.
612@item <v
613List cells by reading cells rowwise from top right to bottom left.
614@item v>
615List cells by reading cells columnwise from top left to bottom right.
616@item v<
617List cells by reading cells columnwise from top right to bottom left.
618@item v
619A short hand for @code{v>}.
620@item ^
621A short hand for @code{^>}.
622@item >
623A short hand for @code{>v}.
624@item <
625A short hand for @code{>^}.
626@item *
627Instead of listing cells, it makes a Calc vector or matrix of it
628(@pxref{Top,,,calc,GNU Emacs Calc Manual}). If the range contains only
629one row or one column a vector is made, otherwise a matrix is made.
630@item *2
631Same as @code{*} except that a matrix is always made even when there
632is only one row or column in the range.
633@item *1
634Same as @code{*} except that a vector is always made even when there
635is only one row or column in the range, that is to say the
636corresponding matrix is flattened.
637@end table
579 638
580@node Sorting by column, Standard formula functions, Ranges in formulas, Advanced Features 639@node Sorting by column, Standard formula functions, Ranges in formulas, Advanced Features
581@section Sorting by column 640@section Sorting by column
@@ -653,7 +712,7 @@ the result is too wide for the available space (up to the end of the
653row or the next non-@code{nil} cell), the result is truncated if the cell's 712row or the next non-@code{nil} cell), the result is truncated if the cell's
654value is a string, or replaced with hash marks otherwise. 713value is a string, or replaced with hash marks otherwise.
655 714
656SES could get confused by printer results that contain newlines or 715@acronym{SES} could get confused by printer results that contain newlines or
657tabs, so these are replaced with question marks. 716tabs, so these are replaced with question marks.
658 717
659@table @kbd 718@table @kbd
@@ -734,7 +793,7 @@ for more info on how Lisp forms are classified as safe or unsafe.
734A common organization for spreadsheets is to have a bunch of ``detail'' 793A common organization for spreadsheets is to have a bunch of ``detail''
735rows, each perhaps describing a transaction, and then a set of 794rows, each perhaps describing a transaction, and then a set of
736``summary'' rows that each show reduced data for some subset of the 795``summary'' rows that each show reduced data for some subset of the
737details. SES supports this organization via the @code{ses-select} 796details. @acronym{SES} supports this organization via the @code{ses-select}
738function. 797function.
739 798
740@table @code 799@table @code
@@ -771,7 +830,7 @@ details-and-summary spreadsheet.
771* Nonrelocatable references:: 830* Nonrelocatable references::
772* The data area:: 831* The data area::
773* Buffer-local variables in spreadsheets:: 832* Buffer-local variables in spreadsheets::
774* Uses of defadvice in SES:: 833* Uses of defadvice in @acronym{SES}::
775@end menu 834@end menu
776 835
777@node Deferred updates, Nonrelocatable references, For Gurus, For Gurus 836@node Deferred updates, Nonrelocatable references, For Gurus, For Gurus
@@ -799,7 +858,7 @@ progress message of the form ``Writing... (@var{nnn} cells left)''.
799These deferred cell-writes cannot be interrupted by @kbd{C-g}, so 858These deferred cell-writes cannot be interrupted by @kbd{C-g}, so
800you'll just have to wait. 859you'll just have to wait.
801 860
802SES uses @code{run-with-idle-timer} to move the cell underline when 861@acronym{SES} uses @code{run-with-idle-timer} to move the cell underline when
803Emacs will be scrolling the buffer after the end of a command, and 862Emacs will be scrolling the buffer after the end of a command, and
804also to narrow and underline after @kbd{C-x C-v}. This is visible as 863also to narrow and underline after @kbd{C-x C-v}. This is visible as
805a momentary glitch after C-x C-v and certain scrolling commands. You 864a momentary glitch after C-x C-v and certain scrolling commands. You
@@ -843,14 +902,14 @@ Begins with an 014 character, followed by sets of cell-definition
843macros for each row, followed by column-widths, column-printers, 902macros for each row, followed by column-widths, column-printers,
844default-printer, and header-row. Then there's the global parameters 903default-printer, and header-row. Then there's the global parameters
845(file-format ID, numrows, numcols) and the local variables (specifying 904(file-format ID, numrows, numcols) and the local variables (specifying
846SES mode for the buffer, etc.) 905@acronym{SES} mode for the buffer, etc.)
847 906
848When a SES file is loaded, first the numrows and numcols values are 907When a @acronym{SES} file is loaded, first the numrows and numcols values are
849loaded, then the entire data area is @code{eval}ed, and finally the local 908loaded, then the entire data area is @code{eval}ed, and finally the local
850variables are processed. 909variables are processed.
851 910
852You can edit the data area, but don't insert or delete any newlines 911You can edit the data area, but don't insert or delete any newlines
853except in the local-variables part, since SES locates things by 912except in the local-variables part, since @acronym{SES} locates things by
854counting newlines. Use @kbd{C-x C-e} at the end of a line to install 913counting newlines. Use @kbd{C-x C-e} at the end of a line to install
855your edits into the spreadsheet data structures (this does not update 914your edits into the spreadsheet data structures (this does not update
856the print area, use e.g. @kbd{C-c C-l} for that). 915the print area, use e.g. @kbd{C-c C-l} for that).
@@ -866,7 +925,7 @@ data structures:
866@end table 925@end table
867 926
868 927
869@node Buffer-local variables in spreadsheets, Uses of defadvice in SES, The data area, For Gurus 928@node Buffer-local variables in spreadsheets, Uses of defadvice in @acronym{SES}, The data area, For Gurus
870@section Buffer-local variables in spreadsheets 929@section Buffer-local variables in spreadsheets
871@cindex buffer-local variables 930@cindex buffer-local variables
872@cindex variables, buffer-local 931@cindex variables, buffer-local
@@ -900,8 +959,8 @@ avoid virus warnings, each function used in a formula needs
900(put 'your-function-name 'safe-function t) 959(put 'your-function-name 'safe-function t)
901@end lisp 960@end lisp
902 961
903@node Uses of defadvice in SES, , Buffer-local variables in spreadsheets, For Gurus 962@node Uses of defadvice in @acronym{SES}, , Buffer-local variables in spreadsheets, For Gurus
904@section Uses of defadvice in SES 963@section Uses of defadvice in @acronym{SES}
905@cindex defadvice 964@cindex defadvice
906@cindex undo-more 965@cindex undo-more
907@cindex copy-region-as-kill 966@cindex copy-region-as-kill
diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex
index f3093d0853f..b5f31415771 100644
--- a/doc/misc/texinfo.tex
+++ b/doc/misc/texinfo.tex
@@ -3,7 +3,7 @@
3% Load plain if necessary, i.e., if running under initex. 3% Load plain if necessary, i.e., if running under initex.
4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi 4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5% 5%
6\def\texinfoversion{2012-09-12.16} 6\def\texinfoversion{2012-11-08.11}
7% 7%
8% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, 8% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 9% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -6559,16 +6559,9 @@ end
6559\makedispenvdef{quotation}{\quotationstart} 6559\makedispenvdef{quotation}{\quotationstart}
6560% 6560%
6561\def\quotationstart{% 6561\def\quotationstart{%
6562 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip 6562 \indentedblockstart % same as \indentedblock, but increase right margin too.
6563 \parindent=0pt
6564 %
6565 % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
6566 \ifx\nonarrowing\relax 6563 \ifx\nonarrowing\relax
6567 \advance\leftskip by \lispnarrowing
6568 \advance\rightskip by \lispnarrowing 6564 \advance\rightskip by \lispnarrowing
6569 \exdentamount = \lispnarrowing
6570 \else
6571 \let\nonarrowing = \relax
6572 \fi 6565 \fi
6573 \parsearg\quotationlabel 6566 \parsearg\quotationlabel
6574} 6567}
@@ -6594,6 +6587,32 @@ end
6594 \fi 6587 \fi
6595} 6588}
6596 6589
6590% @indentedblock is like @quotation, but indents only on the left and
6591% has no optional argument.
6592%
6593\makedispenvdef{indentedblock}{\indentedblockstart}
6594%
6595\def\indentedblockstart{%
6596 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
6597 \parindent=0pt
6598 %
6599 % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
6600 \ifx\nonarrowing\relax
6601 \advance\leftskip by \lispnarrowing
6602 \exdentamount = \lispnarrowing
6603 \else
6604 \let\nonarrowing = \relax
6605 \fi
6606}
6607
6608% Keep a nonzero parskip for the environment, since we're doing normal filling.
6609%
6610\def\Eindentedblock{%
6611 \par
6612 {\parskip=0pt \afterenvbreak}%
6613}
6614\def\Esmallindentedblock{\Eindentedblock}
6615
6597 6616
6598% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>} 6617% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
6599% If we want to allow any <char> as delimiter, 6618% If we want to allow any <char> as delimiter,
diff --git a/doc/misc/url.texi b/doc/misc/url.texi
index 898a9994a86..fdb3ab452f2 100644
--- a/doc/misc/url.texi
+++ b/doc/misc/url.texi
@@ -18,7 +18,7 @@
18@end direntry 18@end direntry
19 19
20@copying 20@copying
21This file documents the Emacs Lisp URL loading package. 21This is the manual for the @code{url} Emacs Lisp library.
22 22
23Copyright @copyright{} 1993-1999, 2002, 2004-2012 Free Software Foundation, Inc. 23Copyright @copyright{} 1993-1999, 2002, 2004-2012 Free Software Foundation, Inc.
24 24
@@ -57,10 +57,10 @@ developing GNU and promoting software freedom.''
57@end ifnottex 57@end ifnottex
58 58
59@menu 59@menu
60* Getting Started:: Preparing your program to use URLs. 60* Introduction:: About the @code{url} library.
61* URI Parsing:: Parsing (and unparsing) URIs.
61* Retrieving URLs:: How to use this package to retrieve a URL. 62* Retrieving URLs:: How to use this package to retrieve a URL.
62* Supported URL Types:: Descriptions of URL types currently supported. 63* Supported URL Types:: Descriptions of URL types currently supported.
63* Defining New URLs:: How to define a URL loader for a new protocol.
64* General Facilities:: URLs can be cached, accessed via a gateway 64* General Facilities:: URLs can be cached, accessed via a gateway
65 and tracked in a history list. 65 and tracked in a history list.
66* Customization:: Variables you can alter. 66* Customization:: Variables you can alter.
@@ -70,93 +70,129 @@ developing GNU and promoting software freedom.''
70* Concept Index:: 70* Concept Index::
71@end menu 71@end menu
72 72
73@node Getting Started 73@node Introduction
74@chapter Getting Started 74@chapter Introduction
75@cindex URLs, definition 75@cindex URL
76@cindex URIs 76@cindex URI
77@cindex uniform resource identifier
78@cindex uniform resource locator
77 79
78@dfn{Uniform Resource Locators} (URLs) are a specific form of 80A @dfn{Uniform Resource Identifier} (URI) is a specially-formatted
79@dfn{Uniform Resource Identifiers} (URI) described in RFC 2396 which 81name, such as an Internet address, that identifies some name or
80updates RFC 1738 and RFC 1808. RFC 2016 defines uniform resource 82resource. The format of URIs is described in RFC 3986, which updates
81agents. 83and replaces the earlier RFCs 2732, 2396, 1808, and 1738. A
84@dfn{Uniform Resource Locator} (URL) is an older but still-common
85term, which basically refers to a URI corresponding to a resource that
86can be accessed (usually over a network) in a specific way.
82 87
83URIs have the form @var{scheme}:@var{scheme-specific-part}, where the 88 Here are some examples of URIs (taken from RFC 3986):
84@var{scheme}s supported by this library are described below.
85@xref{Supported URL Types}.
86 89
87FTP, NFS, HTTP, HTTPS, @code{rlogin}, @code{telnet}, tn3270, 90@example
88IRC and gopher URLs all have the form 91ftp://ftp.is.co.za/rfc/rfc1808.txt
92http://www.ietf.org/rfc/rfc2396.txt
93ldap://[2001:db8::7]/c=GB?objectClass?one
94mailto:John.Doe@@example.com
95news:comp.infosystems.www.servers.unix
96tel:+1-816-555-1212
97telnet://192.0.2.16:80/
98urn:oasis:names:specification:docbook:dtd:xml:4.1.2
99@end example
100
101 This manual describes the @code{url} library, an Emacs Lisp library
102for parsing URIs and retrieving the resources to which they refer.
103(The library is so-named for historical reasons; nowadays, the ``URI''
104terminology is regarded as the more general one, and ``URL'' is
105technically obsolete despite its widespread vernacular usage.)
106
107@node URI Parsing
108@chapter URI Parsing
109
110 A URI consists of several @dfn{components}, each having a different
111meaning. For example, the URI
89 112
90@example 113@example
91@var{scheme}://@r{[}@var{userinfo}@@@r{]}@var{hostname}@r{[}:@var{port}@r{]}@r{[}/@var{path}@r{]} 114http://www.gnu.org/software/emacs/
92@end example 115@end example
116
93@noindent 117@noindent
94where @samp{@r{[}} and @samp{@r{]}} delimit optional parts. 118specifies the scheme component @samp{http}, the hostname component
95@var{userinfo} sometimes takes the form @var{username}:@var{password} 119@samp{www.gnu.org}, and the path component @samp{/software/emacs/}.
96but you should beware of the security risks of sending cleartext 120
97passwords. @var{hostname} may be a domain name or a dotted decimal 121@cindex parsed URIs
98address. If the @samp{:@var{port}} is omitted then the library will 122 The format of URIs is specified by RFC 3986. The @code{url} library
99use the ``well known'' port for that service when accessing URLs. With 123provides the Lisp function @code{url-generic-parse-url}, a (mostly)
100the possible exception of @code{telnet}, it is rare for ports to be 124standard-compliant URI parser, as well as function
101specified, and it is possible using a non-standard port may have 125@code{url-recreate-url}, which converts a parsed URI back into a URI
102undesired consequences if a different service is listening on that 126string.
103port (e.g., an HTTP URL specifying the SMTP port can cause mail to be 127
104sent). @c , but @xref{Other Variables, url-bad-port-list}. 128@defun url-generic-parse-url uri-string
105The meaning of the @var{path} component depends on the service. 129This function returns a parsed version of the string @var{uri-string}.
130@end defun
106 131
107@menu 132@defun url-recreate-url uri-obj
108* Configuration:: 133@cindex unparsing URLs
109* Parsed URLs:: URLs are parsed into vector structures. 134Given a parsed URI, this function returns the corresponding URI string.
110@end menu 135@end defun
111 136
112@node Configuration 137@cindex parsed URI
113@section Configuration 138 The return value of @code{url-generic-parse-url}, and the argument
139expected by @code{url-recreate-url}, is a @dfn{parsed URI}: a CL
140structure whose slots hold the various components of the URI.
141@xref{top,the CL Manual,,cl,GNU Emacs Common Lisp Emulation}, for
142details about CL structures. Most of the other functions in the
143@code{url} library act on parsed URIs.
114 144
115@defvar url-configuration-directory 145@menu
116@cindex @file{~/.url} 146* Parsed URIs:: Format of parsed URI structures.
117@cindex configuration files 147* URI Encoding:: Non-@acronym{ASCII} characters in URIs.
118The directory in which URL configuration files, the cache etc., 148@end menu
119reside. The old default was @file{~/.url}, and this directory
120is still used if it exists. The new default is a @file{url/}
121directory in @code{user-emacs-directory}, which is normally
122@file{~/.emacs.d}.
123@end defvar
124 149
125@node Parsed URLs 150@node Parsed URIs
126@section Parsed URLs 151@section Parsed URI structures
127@cindex parsed URLs
128The library functions typically operate on @dfn{parsed} versions of
129URLs. These are actually CL structures (vectors) of the form:
130 152
131@example 153 Each parsed URI structure contains the following slots:
132[cl-struct-url @var{type} @var{user} @var{password} @var{host} @var{port} @var{filename} @var{target} @var{attributes} @var{fullness} @var{use-cookies}]
133@end example
134 154
135@noindent where 155@table @code
136@table @var
137@item type 156@item type
138is the type of the URL scheme, e.g., @code{http} 157The URI scheme (a string, e.g.@: @code{http}). @xref{Supported URL
158Types}, for a list of schemes that the @code{url} library knows how to
159process. This slot can also be @code{nil}, if the URI is not fully
160specified.
161
139@item user 162@item user
140is the username associated with it, or @code{nil}; 163The user name (a string), or @code{nil}.
164
141@item password 165@item password
142is the user password associated with it, or @code{nil}; 166The user password (a string), or @code{nil}. The use of this URI
167component is strongly discouraged; nowadays, passwords are transmitted
168by other means, not as part of a URI.
169
143@item host 170@item host
144is the host name associated with it, or @code{nil}; 171The host name (a string), or @code{nil}. If present, this is
172typically a domain name or IP address.
173
145@item port 174@item port
146is the port number associated with it, or @code{nil}; 175The port number (an integer), or @code{nil}. Omitting this component
176usually means to use the ``standard'' port associated with the URI
177scheme.
178
147@item filename 179@item filename
148is the ``file'' part of it, or @code{nil}. This doesn't necessarily 180The combination of the ``path'' and ``query'' components of the URI (a
149actually refer to a file; 181string), or @code{nil}. If the query component is present, it is the
182substring following the first @samp{?} character, and the path
183component is the substring before the @samp{?}. The meaning of these
184components is scheme-dependent; they do not necessarily refer to a
185file on a disk.
186
150@item target 187@item target
151is the target part, or @code{nil}; 188The fragment component (a string), or @code{nil}. The fragment
152@item attributes 189component specifies a ``secondary resource'', such as a section of a
153is the attributes associated with it, or @code{nil}; 190webpage.
191
154@item fullness 192@item fullness
155is @code{t} for a fully-specified URL, with a host part indicated by 193This is @code{t} if the URI is fully specified, i.e.@: the
156@samp{//} after the scheme part. 194hierarchical components of the URI (the hostname and/or username
157@item use-cookies 195and/or password) are preceded by @samp{//}.
158is @code{nil} to neither send or store cookies to the server, @code{t}
159otherwise.
160@end table 196@end table
161 197
162@findex url-type 198@findex url-type
@@ -168,64 +204,165 @@ otherwise.
168@findex url-target 204@findex url-target
169@findex url-attributes 205@findex url-attributes
170@findex url-fullness 206@findex url-fullness
171These attributes have accessors named @code{url-@var{part}}, where 207These slots have accessors named @code{url-@var{part}}, where
172@var{part} is the name of one of the elements above, e.g., 208@var{part} is the slot name. For example, the accessor for the
173@code{url-host}. These attributes can be set with the same accessors 209@code{host} slot is the function @code{url-host}. The @code{url-port}
174using @code{setf}: 210accessor returns the default port for the URI scheme if the parsed
211URI's @var{port} slot is @code{nil}.
212
213 The slots can be set using @code{setf}. For example:
175 214
176@example 215@example
177(setf (url-port url) 80) 216(setf (url-port url) 80)
178@end example 217@end example
179 218
180If @var{port} is @var{nil}, @code{url-port} returns the default port 219@node URI Encoding
181of the protocol. 220@section URI Encoding
182 221
183There are functions for parsing and unparsing between the string and 222@cindex percent encoding
184vector forms. 223 The @code{url-generic-parse-url} parser does not obey RFC 3986 in
224one respect: it allows non-@acronym{ASCII} characters in URI strings.
225
226 Strictly speaking, RFC 3986 compatible URIs may only consist of
227@acronym{ASCII} characters; non-@acronym{ASCII} characters are
228represented by converting them to UTF-8 byte sequences, and performing
229@dfn{percent encoding} on the bytes. For example, the o-umlaut
230character is converted to the UTF-8 byte sequence @samp{\xD3\xA7},
231then percent encoded to @samp{%D3%A7}. (Certain ``reserved''
232@acronym{ASCII} characters must also be percent encoded when they
233appear in URI components.)
234
235 The function @code{url-encode-url} can be used to convert a URI
236string containing arbitrary characters to one that is properly
237percent-encoded in accordance with RFC 3986.
238
239@defun url-encode-url url-string
240This function return a properly URI-encoded version of
241@var{url-string}. It also performs @dfn{URI normalization},
242e.g.@: converting the scheme component to lowercase if it was
243previously uppercase.
244@end defun
185 245
186@defun url-generic-parse-url url 246 To convert between a string containing arbitrary characters and a
187Return a parsed version of the string @var{url}. 247percent-encoded all-@acronym{ASCII} string, use the functions
248@code{url-hexify-string} and @code{url-unhex-string}:
249
250@defun url-hexify-string string &optional allowed-chars
251This function performs percent-encoding on @var{string}, and returns
252the result.
253
254If @var{string} is multibyte, it is first converted to a UTF-8 byte
255string. Each byte corresponding to an allowed character is left
256as-is, while all other bytes are converted to a three-character
257sequence: @samp{%} followed by two upper-case hex digits.
258
259@vindex url-unreserved-chars
260@cindex unreserved characters
261The allowed characters are specified by @var{allowed-chars}. If this
262argument is @code{nil}, the allowed characters are those specified as
263@dfn{unreserved characters} by RFC 3986 (see the variable
264@code{url-unreserved-chars}). Otherwise, @var{allowed-chars} should
265be a vector whose @var{n}-th element is non-@code{nil} if character
266@var{n} is allowed.
188@end defun 267@end defun
189 268
190@defun url-recreate-url url 269@defun url-unhex-string string &optional allow-newlines
191@cindex unparsing URLs 270This function replaces percent-encoding sequences in @var{string} with
192Recreates a URL string from the parsed @var{url}. 271their character equivalents, and returns the resulting string.
272
273If @var{allow-newlines} is non-@code{nil}, it allows the decoding of
274carriage returns and line feeds, which are normally forbidden in URIs.
193@end defun 275@end defun
194 276
195@node Retrieving URLs 277@node Retrieving URLs
196@chapter Retrieving URLs 278@chapter Retrieving URLs
197 279
280 The @code{url} library defines the following three functions for
281retrieving the data specified by a URL. The actual retrieval protocol
282depends on the URL's URI scheme, and is performed by lower-level
283scheme-specific functions. (Those lower-level functions are not
284documented here, and generally should not be called directly.)
285
286 In each of these functions, the @var{url} argument can be either a
287string or a parsed URL structure. If it is a string, that string is
288passed through @code{url-encode-url} before using it, to ensure that
289it is properly URI-encoded (@pxref{URI Encoding}).
290
198@defun url-retrieve-synchronously url 291@defun url-retrieve-synchronously url
199Retrieve @var{url} synchronously and return a buffer containing the 292This function synchronously retrieves the data specified by @var{url},
200data. @var{url} is either a string or a parsed URL structure. Return 293and returns a buffer containing the data. The return value is
201@code{nil} if there are no data associated with it (the case for dired, 294@code{nil} if there is no data associated with the URL (as is the case
202info, or mailto URLs that need no further processing). 295for @code{dired}, @code{info}, and @code{mailto} URLs).
203@end defun 296@end defun
204 297
205@defun url-retrieve url callback &optional cbargs silent no-cookies 298@defun url-retrieve url callback &optional cbargs silent no-cookies
206Retrieve @var{url} asynchronously and call @var{callback} with args 299This function retrieves @var{url} asynchronously, calling the function
207@var{cbargs} when finished. The callback is called when the object 300@var{callback} when the object has been completely retrieved. The
208has been completely retrieved, with the current buffer containing the 301return value is the buffer into which the data will be inserted, or
209object and any MIME headers associated with it. @var{url} is either a 302@code{nil} if the process has already completed.
210string or a parsed URL structure. Returns the buffer @var{url} will 303
211load into, or @code{nil} if the process has already completed. 304The callback function is called this way:
212If the optional argument @var{silent} is non-@code{nil}, suppress 305
213progress messages. If the optional argument @var{no-cookies} is 306@example
214non-@code{nil}, do not store or send cookies. 307(apply @var{callback} @var{status} @var{cbargs})
308@end example
309
310@noindent
311where @var{status} is a plist representing what happened during the
312retrieval, with most recent events first, or an empty list if no
313events have occurred. Each pair in the plist is one of:
314
315@table @code
316@item (:redirect @var{redirected-to})
317This means that the request was redirected to the URL
318@var{redirected-to}.
319
320@item (:error (@var{error-symbol} . @var{data}))
321This means that an error occurred. If so desired, the error can be
322signaled with @code{(signal @var{error-symbol} @var{data})}.
323@end table
324
325When the callback function is called, the current buffer is the one
326containing the retrieved data (if any). The buffer also contains any
327MIME headers associated with the data retrieval.
328
329If the optional argument @var{silent} is non-@code{nil}, progress
330messages are suppressed. If the optional argument @var{no-cookies} is
331non-@code{nil}, cookies are not stored or sent.
215@end defun 332@end defun
216 333
217@vindex url-queue-parallel-processes
218@vindex url-queue-timeout
219@defun url-queue-retrieve url callback &optional cbargs silent no-cookies 334@defun url-queue-retrieve url callback &optional cbargs silent no-cookies
220This acts like the @code{url-retrieve} function, but with limits on 335This function acts like @code{url-retrieve}, but with limits on the
221the degree of parallelism. The option @code{url-queue-parallel-processes} 336number of concurrently-running network processes. The option
222controls the number of concurrent processes, and the option 337@code{url-queue-parallel-processes} controls the number of concurrent
223@code{url-queue-timeout} sets a timeout in seconds. 338processes, and the option @code{url-queue-timeout} sets a timeout in
339seconds.
340
341To use this function, you must @code{(require 'url-queue)}.
224@end defun 342@end defun
225 343
344@vindex url-queue-parallel-processes
345@defopt url-queue-parallel-processes
346The value of this option is an integer specifying the maximum number
347of concurrent @code{url-queue-retrieve} network processes. If the
348number of @code{url-queue-retrieve} calls is larger than this number,
349later ones are queued until ealier ones are finished.
350@end defopt
351
352@vindex url-queue-timeout
353@defopt url-queue-timeout
354The value of this option is a number specifying the maximum lifetime
355of a @code{url-queue-retrieve} network process, once it is started.
356If a process is not finished by then, it is killed and removed from
357the queue.
358@end defopt
359
226@node Supported URL Types 360@node Supported URL Types
227@chapter Supported URL Types 361@chapter Supported URL Types
228 362
363This chapter describes functions and variables affecting URL retrieval
364for specific schemes.
365
229@menu 366@menu
230* http/https:: Hypertext Transfer Protocol. 367* http/https:: Hypertext Transfer Protocol.
231* file/ftp:: Local files and FTP archives. 368* file/ftp:: Local files and FTP archives.
@@ -236,48 +373,31 @@ controls the number of concurrent processes, and the option
236* irc:: Internet Relay Chat. 373* irc:: Internet Relay Chat.
237* data:: Embedded data URLs. 374* data:: Embedded data URLs.
238* nfs:: Networked File System 375* nfs:: Networked File System
239@c * finger::
240@c * gopher::
241@c * netrek::
242@c * prospero::
243* cid:: Content-ID.
244* about::
245* ldap:: Lightweight Directory Access Protocol 376* ldap:: Lightweight Directory Access Protocol
246* imap:: IMAP mailboxes.
247* man:: Unix man pages. 377* man:: Unix man pages.
248@end menu 378@end menu
249 379
250@node http/https 380@node http/https
251@section @code{http} and @code{https} 381@section @code{http} and @code{https}
252 382
253The scheme @code{http} is Hypertext Transfer Protocol. The library 383The @code{http} scheme refers to the Hypertext Transfer Protocol. The
254supports version 1.1, specified in RFC 2616. (This supersedes 1.0, 384@code{url} library supports HTTP version 1.1, specified in RFC 2616.
255defined in RFC 1945) HTTP URLs have the following form, where most of 385Its default port is 80.
256the parts are optional: 386
257@example 387 The @code{https} scheme is a secure version of @code{http}, with
258http://@var{user}:@var{password}@@@var{host}:@var{port}/@var{path}?@var{searchpart}#@var{fragment} 388transmission via SSL. It is defined in RFC 2069, and its default port
259@end example 389is 443. When using @code{https}, the @code{url} library performs SSL
260@c The @code{:@var{port}} part is optional, and @var{port} defaults to 390encryption via the @code{ssl} library, by forcing the @code{ssl}
261@c 80. The @code{/@var{path}} part, if present, is a slash-separated 391gateway method to be used. @xref{Gateways in general}.
262@c series elements. The @code{?@var{searchpart}}, if present, is the
263@c query for a search or the content of a form submission. The
264@c @code{#fragment} part, if present, is a location in the document.
265
266The scheme @code{https} is a secure version of @code{http}, with
267transmission via SSL. It is defined in RFC 2069. Its default port is
268443. This scheme depends on SSL support in Emacs via the
269@file{ssl.el} library and is actually implemented by forcing the
270@code{ssl} gateway method to be used. @xref{Gateways in general}.
271 392
272@defopt url-honor-refresh-requests 393@defopt url-honor-refresh-requests
273This controls honoring of HTTP @samp{Refresh} headers by which 394If this option is non-@code{nil} (the default), the @code{url} library
274servers can direct clients to reload documents from the same URL or a 395honors the HTTP @samp{Refresh} header, which is used by servers to
275or different one. @code{nil} means they will not be honored, 396direct clients to reload documents from the same URL or a or different
276@code{t} (the default) means they will always be honored, and 397one. If the value is @code{nil}, the @samp{Refresh} header is
277otherwise the user will be asked on each request. 398ignored; any other value means to ask the user on each request.
278@end defopt 399@end defopt
279 400
280
281@menu 401@menu
282* Cookies:: 402* Cookies::
283* HTTP language/coding:: 403* HTTP language/coding::
@@ -409,26 +529,32 @@ emacs-mime, The Emacs MIME Manual}.
409@cindex compressed files 529@cindex compressed files
410@cindex dired 530@cindex dired
411 531
532The @code{ftp} and @code{file} schemes are defined in RFC 1808. The
533@code{url} library treats @samp{ftp:} and @samp{file:} as synonymous.
534Such URLs have the form
535
412@example 536@example
413ftp://@var{user}:@var{password}@@@var{host}:@var{port}/@var{file} 537ftp://@var{user}:@var{password}@@@var{host}:@var{port}/@var{file}
414file://@var{user}:@var{password}@@@var{host}:@var{port}/@var{file} 538file://@var{user}:@var{password}@@@var{host}:@var{port}/@var{file}
415@end example 539@end example
416 540
417These schemes are defined in RFC 1808. 541@noindent
418@samp{ftp:} and @samp{file:} are synonymous in this library. They 542If the URL specifies a local file, it is retrieved by reading the file
419allow reading arbitrary files from hosts. Either @samp{ange-ftp} 543contents in the usual way. If it specifies a remote file, it is
420(Emacs) or @samp{efs} (XEmacs) is used to retrieve them from remote 544retrieved using the Ange-FTP package. @xref{Remote Files,,, emacs,
421hosts. Local files are accessed directly. 545The GNU Emacs Manual}.
422 546
423Compressed files are handled, but support is hard-coded so that 547 When retrieving a compressed file, it is automatically uncompressed
424@code{jka-compr-compression-info-list} and so on have no affect. 548if it has the file suffix @file{.z}, @file{.gz}, @file{.Z},
425Suffixes recognized are @samp{.z}, @samp{.gz}, @samp{.Z} and 549@file{.bz2}, or @file{.xz}. (The list of supported suffixes is
426@samp{.bz2}. 550hard-coded, and cannot be altered by customizing
551@code{jka-compr-compression-info-list}.)
427 552
428@defopt url-directory-index-file 553@defopt url-directory-index-file
429The filename to look for when indexing a directory, default 554This option specifies the filename to look for when a @code{file} or
430@samp{"index.html"}. If this file exists, and is readable, then it 555@code{ftp} URL specifies a directory. The default is
431will be viewed instead of using @code{dired} to view the directory. 556@file{index.html}. If this file exists and is readable, it is viewed.
557Otherwise, Emacs visits the directory using Dired.
432@end defopt 558@end defopt
433 559
434@node info 560@node info
@@ -437,47 +563,53 @@ will be viewed instead of using @code{dired} to view the directory.
437@cindex Texinfo 563@cindex Texinfo
438@findex Info-goto-node 564@findex Info-goto-node
439 565
566The @code{info} scheme is non-standard. Such URLs have the form
567
440@example 568@example
441info:@var{file}#@var{node} 569info:@var{file}#@var{node}
442@end example 570@end example
443 571
444Info URLs are not officially defined. They invoke 572@noindent
445@code{Info-goto-node} with argument @samp{(@var{file})@var{node}}. 573and are retrieved by invoking @code{Info-goto-node} with argument
446@samp{#@var{node}} is optional, defaulting to @samp{Top}. 574@samp{(@var{file})@var{node}}. If @samp{#@var{node}} is omitted, the
575@samp{Top} node is opened.
447 576
448@node mailto 577@node mailto
449@section mailto 578@section mailto
450 579
451@cindex mailto 580@cindex mailto
452@cindex email 581@cindex email
453A mailto URL will send an email message to the address in the 582A @code{mailto} URL specifies an email message to be sent to a given
454URL, for example @samp{mailto:foo@@bar.com} would compose a 583email address. For example, @samp{mailto:foo@@bar.com} specifies
455message to @samp{foo@@bar.com}. 584sending a message to @samp{foo@@bar.com}. The ``retrieval method''
456 585for such URLs is to open a mail composition buffer in which the
457@defopt url-mail-command 586appropriate content (e.g.@: the recipient address) has been filled in.
458@vindex mail-user-agent
459The function called whenever url needs to send mail. This should
460normally be left to default from @var{mail-user-agent}. @xref{Mail
461Methods, , Mail-Composition Methods, emacs, The GNU Emacs Manual}.
462@end defopt
463 587
464An @samp{X-Url-From} header field containing the URL of the document 588 As defined in RFC 2368, a @code{mailto} URL has the form
465that contained the mailto URL is added if that URL is known.
466 589
467RFC 2368 extends the definition of mailto URLs in RFC 1738.
468The form of a mailto URL is
469@example 590@example
470@samp{mailto:@var{mailbox}[?@var{header}=@var{contents}[&@var{header}=@var{contents}]]} 591@samp{mailto:@var{mailbox}[?@var{header}=@var{contents}[&@var{header}=@var{contents}]]}
471@end example 592@end example
472@noindent where an arbitrary number of @var{header}s can be added. If the
473@var{header} is @samp{body}, then @var{contents} is put in the body
474otherwise a @var{header} header field is created with @var{contents}
475as its contents. Note that the URL library does not consider any
476headers ``dangerous'' so you should check them before sending the
477message.
478 593
479@c Fixme: update 594@noindent
480Email messages are defined in @sc{rfc}822. 595where an arbitrary number of @var{header}s can be added. If the
596@var{header} is @samp{body}, then @var{contents} is put in the message
597body; otherwise, a @var{header} header field is created with
598@var{contents} as its contents. Note that the @code{url} library does
599not perform any checking of @var{header} or @var{contents}, so you
600should check them before sending the message.
601
602@defopt url-mail-command
603@vindex mail-user-agent
604The value of this variable is the function called whenever url needs
605to send mail. This should normally be left its default, which is the
606standard mail-composition command @code{compose-mail}. @xref{Sending
607Mail,,, emacs, The GNU Emacs Manual}.
608@end defopt
609
610 If the document containing the @code{mailto} URL itself possessed a
611known URL, Emacs automatically inserts an @samp{X-Url-From} header
612field into the mail buffer, specifying that URL.
481 613
482@node news/nntp/snews 614@node news/nntp/snews
483@section @code{news}, @code{nntp} and @code{snews} 615@section @code{news}, @code{nntp} and @code{snews}
@@ -487,11 +619,13 @@ Email messages are defined in @sc{rfc}822.
487@cindex NNTP 619@cindex NNTP
488@cindex snews 620@cindex snews
489 621
490@c draft-gilman-news-url-01 622The @code{news}, @code{nntp}, and @code{snews} schemes, defined in RFC
491The network news URL scheme take the following forms following RFC 6231738, are used for reading Usenet newsgroups. For compatibility with
4921738 except that for compatibility with other clients, host and port 624non-standard-compliant news clients, the @code{url} library allows
493fields may be included in news URLs though they are properly only 625host and port fields to be included in @code{news} URLs, even though
494allowed for nntp an snews. 626they are properly only allowed for @code{nntp} and @code{snews}.
627
628 @code{news} and @code{nntp} URLs have the following form:
495 629
496@table @samp 630@table @samp
497@item news:@var{newsgroup} 631@item news:@var{newsgroup}
@@ -506,24 +640,22 @@ Retrieves a list of all available newsgroups;
506Similar to the @samp{news} versions. 640Similar to the @samp{news} versions.
507@end table 641@end table
508 642
509@samp{:@var{port}} is optional and defaults to :119. 643 The default port for @code{nntp} (and @code{news}) is 119. The
510 644difference between an @code{nntp} URL and a @code{news} URL is that an
511@samp{snews} is the same as @samp{nntp} except that the default port 645@code{nttp} URL may specify an article by its number. The
512is :563. 646@samp{snews} scheme is the same as @samp{nntp}, except that it is
513@cindex SSL 647tunneled through SSL and has default port 563.
514(It is tunneled through SSL.)
515 648
516An @samp{nntp} URL is the same as a news URL, except that the URL may 649 These URLs are retrieved via the Gnus package.
517specify an article by its number.
518 650
519@defopt url-news-server
520This variable can be used to override the default news server.
521Usually this will be set by the Gnus package, which is used to fetch
522news.
523@cindex environment variable 651@cindex environment variable
524@vindex NNTPSERVER 652@vindex NNTPSERVER
525It may be set from the conventional environment variable 653@defopt url-news-server
526@code{NNTPSERVER}. 654This variable specifies the default news server from which to fetch
655news, if no server was specified in the URL. The default value,
656@code{nil}, means to use the server specified by the standard
657environment variable @samp{NNTPSERVER}, or @samp{news} if that
658environment variable is unset.
527@end defopt 659@end defopt
528 660
529@node rlogin/telnet/tn3270 661@node rlogin/telnet/tn3270
@@ -534,12 +666,15 @@ It may be set from the conventional environment variable
534@cindex terminal emulation 666@cindex terminal emulation
535@findex terminal-emulator 667@findex terminal-emulator
536 668
537These URL schemes from RFC 1738 for logon via a terminal emulator have 669These URL schemes are defined in RFC 1738, and are used for logging in
538the form 670via a terminal emulator. They have the form
671
539@example 672@example
540telnet://@var{user}:@var{password}@@@var{host}:@var{port} 673telnet://@var{user}:@var{password}@@@var{host}:@var{port}
541@end example 674@end example
542but the @code{:@var{password}} component is ignored. 675
676@noindent
677but the @var{password} component is ignored.
543 678
544To handle rlogin, telnet and tn3270 URLs, a @code{rlogin}, 679To handle rlogin, telnet and tn3270 URLs, a @code{rlogin},
545@code{telnet} or @code{tn3270} (the program names and arguments are 680@code{telnet} or @code{tn3270} (the program names and arguments are
@@ -553,39 +688,43 @@ Well-known ports are used if the URL does not specify a port.
553@cindex ZEN IRC 688@cindex ZEN IRC
554@cindex ERC 689@cindex ERC
555@cindex rcirc 690@cindex rcirc
556@c Fixme: reference (was http://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt) 691
557@dfn{Internet Relay Chat} (IRC) is handled by handing off the @sc{irc} 692 The @code{irc} scheme is defined in the Internet Draft at
558session to a function named in @code{url-irc-function}. 693@url{http://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt} (which
694was never approved as an RFC). Such URLs have the form
695
696@example
697irc://@var{host}:@var{port}/@var{target},@var{needpass}
698@end example
699
700@noindent
701and are retrieved by opening an @acronym{IRC} session using the
702function specified by @code{url-irc-function}.
559 703
560@defopt url-irc-function 704@defopt url-irc-function
561A function to actually open an IRC connection. 705The value of this option is a function, which is called to open an IRC
562This function 706connection for @code{irc} URLs. This function must take five
563must take five arguments, @var{host}, @var{port}, @var{channel}, 707arguments, @var{host}, @var{port}, @var{channel}, @var{user} and
564@var{user} and @var{password}. The @var{channel} argument specifies the 708@var{password}. The @var{channel} argument specifies the channel to
565channel to join immediately, this can be @code{nil}. By default this is 709join immediately, and may be @code{nil}.
566@code{url-irc-rcirc}. 710
711The default is @code{url-irc-rcirc}, which uses the Rcirc package.
712Other options are @code{url-irc-erc} (which uses ERC) and
713@code{url-irc-zenirc} (which uses ZenIRC).
567@end defopt 714@end defopt
568@defun url-irc-rcirc host port channel user password
569Processes the arguments and lets @code{rcirc} handle the session.
570@end defun
571@defun url-irc-erc host port channel user password
572Processes the arguments and lets @code{ERC} handle the session.
573@end defun
574@defun url-irc-zenirc host port channel user password
575Processes the arguments and lets @code{zenirc} handle the session.
576@end defun
577 715
578@node data 716@node data
579@section data 717@section data
580@cindex data URLs 718@cindex data URLs
581 719
720 The @code{data} scheme, defined in RFC 2397, contains MIME data in
721the URL itself. Such URLs have the form
722
582@example 723@example
583data:@r{[}@var{media-type}@r{]}@r{[};@var{base64}@r{]},@var{data} 724data:@r{[}@var{media-type}@r{]}@r{[};@var{base64}@r{]},@var{data}
584@end example 725@end example
585 726
586Data URLs contain MIME data in the URL itself. They are defined in 727@noindent
587RFC 2397.
588
589@var{media-type} is a MIME @samp{Content-Type} string, possibly 728@var{media-type} is a MIME @samp{Content-Type} string, possibly
590including parameters. It defaults to 729including parameters. It defaults to
591@samp{text/plain;charset=US-ASCII}. The @samp{text/plain} can be 730@samp{text/plain;charset=US-ASCII}. The @samp{text/plain} can be
@@ -598,14 +737,14 @@ present, the @var{data} are base64-encoded.
598@cindex Network File System 737@cindex Network File System
599@cindex automounter 738@cindex automounter
600 739
740The @code{nfs} scheme, defined in RFC 2224, is similar to @code{ftp}
741except that it points to a file on a remote host that is handled by an
742NFS automounter on the local host. Such URLs have the form
743
601@example 744@example
602nfs://@var{user}:@var{password}@@@var{host}:@var{port}/@var{file} 745nfs://@var{user}:@var{password}@@@var{host}:@var{port}/@var{file}
603@end example 746@end example
604 747
605The @samp{nfs:} scheme is defined in RFC 2224. It is similar to
606@samp{ftp:} except that it points to a file on a remote host that is
607handled by the automounter on the local host.
608
609@defvar url-nfs-automounter-directory-spec 748@defvar url-nfs-automounter-directory-spec
610@end defvar 749@end defvar
611A string saying how to invoke the NFS automounter. Certain @samp{%} 750A string saying how to invoke the NFS automounter. Certain @samp{%}
@@ -628,15 +767,6 @@ A literal @samp{%}.
628 767
629Each can be used any number of times. 768Each can be used any number of times.
630 769
631@node cid
632@section cid
633@cindex Content-ID
634
635RFC 2111
636
637@node about
638@section about
639
640@node ldap 770@node ldap
641@section ldap 771@section ldap
642@cindex LDAP 772@cindex LDAP
@@ -644,50 +774,21 @@ RFC 2111
644 774
645The LDAP scheme is defined in RFC 2255. 775The LDAP scheme is defined in RFC 2255.
646 776
647@node imap
648@section imap
649@cindex IMAP
650
651RFC 2192
652
653@node man 777@node man
654@section man 778@section man
655@cindex @command{man} 779@cindex @command{man}
656@cindex Unix man pages 780@cindex Unix man pages
657@findex man 781@findex man
658 782
783The @code{man} scheme is a non-standard one. Such URLs have the form
784
659@example 785@example
660@samp{man:@var{page-spec}} 786@samp{man:@var{page-spec}}
661@end example 787@end example
662 788
663This is a non-standard scheme. @var{page-spec} is passed directly to 789@noindent
664the Lisp @code{man} function. 790and are retrieved by passing @var{page-spec} to the Lisp function
665 791@code{man}.
666@node Defining New URLs
667@chapter Defining New URLs
668
669@menu
670* Naming conventions::
671* Required functions::
672* Optional functions::
673* Asynchronous fetching::
674* Supporting file-name-handlers::
675@end menu
676
677@node Naming conventions
678@section Naming conventions
679
680@node Required functions
681@section Required functions
682
683@node Optional functions
684@section Optional functions
685
686@node Asynchronous fetching
687@section Asynchronous fetching
688
689@node Supporting file-name-handlers
690@section Supporting file-name-handlers
691 792
692@node General Facilities 793@node General Facilities
693@chapter General Facilities 794@chapter General Facilities
@@ -1108,11 +1209,9 @@ You can use this function to do completion of URLs from the history.
1108@node Customization 1209@node Customization
1109@chapter Customization 1210@chapter Customization
1110 1211
1111@section Environment Variables
1112
1113@cindex environment variables 1212@cindex environment variables
1114The following environment variables affect the library's operation at 1213 The following environment variables affect the @code{url} library's
1115startup. 1214operation at startup.
1116 1215
1117@table @code 1216@table @code
1118@item TMPDIR 1217@item TMPDIR
@@ -1122,10 +1221,21 @@ If this is defined, @var{url-temporary-directory} is initialized from
1122it. 1221it.
1123@end table 1222@end table
1124 1223
1125@section General User Options 1224 The following user options affect the general operation of
1225@code{url} library.
1126 1226
1127The following user options, settable with Customize, affect the 1227@defopt url-configuration-directory
1128general operation of the package. 1228@cindex configuration files
1229The value of this variable specifies the name of the directory where
1230the @code{url} library stores its various configuration files, cache
1231files, etc.
1232
1233The default value specifies a subdirectory named @file{url/} in the
1234standard Emacs user data directory specified by the variable
1235@code{user-emacs-directory} (normally @file{~/.emacs.d}). However,
1236the old default was @file{~/.url}, and this directory is used instead
1237if it exists.
1238@end defopt
1129 1239
1130@defopt url-debug 1240@defopt url-debug
1131@cindex debugging 1241@cindex debugging
diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index 68b4e7e8168..a1c7b7012f8 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -1,8 +1,10 @@
1ERC NEWS -*- outline -*- 1ERC NEWS -*- outline -*-
2 2
3Copyright (C) 2006-2012 Free Software Foundation, Inc. 3Copyright (C) 2006-2012 Free Software Foundation, Inc.
4See the end of the file for license conditions. 4See the end of the file for license conditions.
5 5
6* For changes after ERC 5.3, see the main Emacs NEWS file
7
6* Changes in ERC 5.3 8* Changes in ERC 5.3
7 9
8** New function `erc-tls' is to be used for connecting to a server via TLS. 10** New function `erc-tls' is to be used for connecting to a server via TLS.
diff --git a/etc/GNUS-NEWS b/etc/GNUS-NEWS
index c5fca9de929..2417c1c35ce 100644
--- a/etc/GNUS-NEWS
+++ b/etc/GNUS-NEWS
@@ -9,6 +9,9 @@ For older news, see Gnus info node "New Features".
9 9
10* New features 10* New features
11 11
12** New package `gnus-notifications.el' can send notifications when you
13 receive new messages.
14
12** If you have the "tnef" program installed, Gnus will display ms-tnef 15** If you have the "tnef" program installed, Gnus will display ms-tnef
13 files, aka "winmail.dat". 16 files, aka "winmail.dat".
14 17
diff --git a/etc/NEWS b/etc/NEWS
index 2b56ea9f540..fbe24c8345f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -25,10 +25,39 @@ so we will look at it and add it to the manual.
25* Startup Changes in Emacs 24.4 25* Startup Changes in Emacs 24.4
26* Changes in Emacs 24.4 26* Changes in Emacs 24.4
27* Editing Changes in Emacs 24.4 27* Editing Changes in Emacs 24.4
28
29
28* Changes in Specialized Modes and Packages in Emacs 24.4 30* Changes in Specialized Modes and Packages in Emacs 24.4
31
32+++
33** New function `ses-rename-cell' to give SES cells arbitrary names.
34
35
29* New Modes and Packages in Emacs 24.4 36* New Modes and Packages in Emacs 24.4
37** New nadvice.el package offering lighter-weight advice facilities.
38It is layered as:
39- add-function/remove-function which can be used to add/remove code on any
40 function-carrying place, such as process-filters or `<foo>-function' hooks.
41- advice-add/advice-remove to add/remove a piece of advice on a named function,
42 much like `defadvice' does.
43
30* Incompatible Lisp Changes in Emacs 24.4 44* Incompatible Lisp Changes in Emacs 24.4
45
46** `defadvice' does not honor the `freeze' flag any more.
47
48** `dolist' in lexical-binding mode does not bind VAR in RESULT any more.
49VAR was bound to nil which was not tremendously useful and just lead to
50spurious warnings about an unused var.
51
31* Lisp changes in Emacs 24.4 52* Lisp changes in Emacs 24.4
53
54** New function special-form-p.
55** Docstrings can be made dynamic by adding a `dynamic-docstring-function'
56text-property on the first char.
57
58** The `defalias-fset-function' property lets you catch calls to defalias
59and redirect them to your own function instead of `fset'.
60
32* Changes in Emacs 24.4 on non-free operating systems 61* Changes in Emacs 24.4 on non-free operating systems
33 62
34 63
@@ -138,15 +167,15 @@ autoloads have been redefined as functions).
138--- 167---
139*** In minibuffer filename prompts, `C-M-f' and `C-M-b' now move to the 168*** In minibuffer filename prompts, `C-M-f' and `C-M-b' now move to the
140next and previous path separator, respectively. 169next and previous path separator, respectively.
141 170+++
142*** minibuffer-electric-default-mode can rewrite (default ...) to [...]. 171*** minibuffer-electric-default-mode can rewrite (default ...) to [...].
143Just set minibuffer-eldef-shorten-default to t before enabling the mode. 172Just set minibuffer-eldef-shorten-default to t before enabling the mode.
144 173
174+++
145** ImageMagick support, if available, is automatically enabled. 175** ImageMagick support, if available, is automatically enabled.
146It is no longer necessary to call `imagemagick-register-types' 176It is no longer necessary to call `imagemagick-register-types'
147explicitly to install ImageMagick image types; that function is called 177explicitly to install ImageMagick image types; that function is called
148automatically at startup, or when customizing a relevant imagemagick- 178automatically at startup, or when customizing an imagemagick- option.
149option.
150+++ 179+++
151*** Setting `imagemagick-types-inhibit' to t now disables the use of 180*** Setting `imagemagick-types-inhibit' to t now disables the use of
152ImageMagick to view images. You must call imagemagick-register-types 181ImageMagick to view images. You must call imagemagick-register-types
@@ -176,6 +205,7 @@ and sorted above the other "available" packages by default.
176** `C-x C-q' is now bound to the new minor mode `read-only-mode'. 205** `C-x C-q' is now bound to the new minor mode `read-only-mode'.
177This minor mode replaces `toggle-read-only', which is now obsolete. 206This minor mode replaces `toggle-read-only', which is now obsolete.
178 207
208+++
179** Emacs now generates backtraces on fatal errors. 209** Emacs now generates backtraces on fatal errors.
180On encountering a fatal error, Emacs now outputs a textual description 210On encountering a fatal error, Emacs now outputs a textual description
181of the fatal signal, and a short backtrace on platforms like glibc 211of the fatal signal, and a short backtrace on platforms like glibc
@@ -347,13 +377,16 @@ of `symbol-function' in place forms.
347A side effect is that vars without corresponding value are bound to nil 377A side effect is that vars without corresponding value are bound to nil
348rather than making them unbound. 378rather than making them unbound.
349 379
350*** The following methods of extending `setf' are obsolete. 380+++
351Use gv.el instead (FIXME; details). 381*** The following methods of extending `setf' are obsolete
352`define-setf-expander', `defsetf', `define-modify-macro' 382(use features from gv.el instead):
383`define-modify-macro' (use `gv-letplace')
384`defsetf' (use `gv-define-simple-setter' or `gv-define-setter')
385`define-setf-expander' (use `gv-define-setter' or `gv-define-expander')
386`get-setf-method' no longer exists (see "Incompatible Lisp Changes")
353 387
354** Compilation mode
355+++ 388+++
356*** New option `compilation-always-kill'. 389** New compilation option `compilation-always-kill'.
357 390
358** Customize 391** Customize
359--- 392---
@@ -363,10 +396,9 @@ Use gv.el instead (FIXME; details).
363`customize-apropos-options' (i.e. the prefix argument does nothing for 396`customize-apropos-options' (i.e. the prefix argument does nothing for
364these commands now). 397these commands now).
365 398
366** Desktop
367--- 399---
368*** `desktop-path' no longer includes the "." directory. Desktop 400** `desktop-path' no longer includes the "." directory.
369files are now located in ~/.emacs.d by default. 401Desktop files are now located in ~/.emacs.d by default.
370 402
371** D-Bus 403** D-Bus
372 404
@@ -400,18 +432,21 @@ details.
400 432
401** Diff mode 433** Diff mode
402 434
435---
403*** Changes are now highlighted using the same color scheme as in 436*** Changes are now highlighted using the same color scheme as in
404modern VCSes. Deletions are displayed in red (new faces 437modern VCSes. Deletions are displayed in red (new faces
405`diff-refine-removed' and `smerge-refined-removed' and new definition 438`diff-refine-removed' and `smerge-refined-removed', and new definition
406of `diff-removed'), insertions in green (new faces `diff-refine-added' 439of `diff-removed'), insertions in green (new faces `diff-refine-added'
407and `smerge-refined-added' and new definition of `diff-added'). 440and `smerge-refined-added', and new definition of `diff-added').
408 441
442---
409*** The variable `diff-use-changed-face' defines whether to use the 443*** The variable `diff-use-changed-face' defines whether to use the
410face `diff-changed', or `diff-removed' and `diff-added' to highlight 444face `diff-changed', or `diff-removed' and `diff-added' to highlight
411changes in context diffs. 445changes in context diffs.
412 446
413*** The new command `diff-remove-trailing-whitespace' fixes trailing 447+++
414whitespace problems introduced by the diff. 448*** The new command `diff-delete-trailing-whitespace' removes trailing
449whitespace introduced by a diff.
415 450
416** Dired 451** Dired
417+++ 452+++
@@ -437,37 +472,37 @@ The global binding for `M-=', `count-words-region' is in effect.
437--- 472---
438** Ediff now uses the same color scheme as Diff mode. 473** Ediff now uses the same color scheme as Diff mode.
439 474
440** erc will look up server/channel names via auth-source and use the 475** ERC
441channel keys found, if any. 476
477*** New package `erc-desktop-notifications.el', which can send a notification
478when you receive a private message or your nickname is mentioned.
479
480*** ERC will look up server/channel names via auth-source and use any
481channel keys found.
442 482
483+++
443** Flymake uses fringe bitmaps to indicate errors and warnings. 484** Flymake uses fringe bitmaps to indicate errors and warnings.
444See `flymake-fringe-indicator-position', `flymake-error-bitmap' and 485See `flymake-fringe-indicator-position', `flymake-error-bitmap' and
445`flymake-warning-bitmap'. 486`flymake-warning-bitmap'.
446 487
447** Follow mode
448---
449*** The obsolete variable `follow-mode-off-hook' has been removed.
450--- 488---
451*** Follow mode no longer works by using advice. 489** Follow mode no longer works by using advice.
452The option `follow-intercept-processes' has been removed. 490The option `follow-intercept-processes' has been removed.
453 491
454** FFAP 492---
455 493** The FFAP option `ffap-url-unwrap-remote' can now be a list of strings,
456*** The option `ffap-url-unwrap-remote' can now be a list of strings, 494specifying URL types that should be converted to remote file names at
457specifying URL types which should be converted to remote file names at
458the FFAP prompt. The default is now '("ftp"). 495the FFAP prompt. The default is now '("ftp").
459 496
460** Generic-x 497---
461`javascript-generic-mode' is now an obsolete alias for `js-mode'. 498** New Ibuffer `derived-mode' filter, bound to `/ M'.
462
463** Ibuffer
464
465*** New `derived-mode' filter, bound to `/ M'.
466The old binding for `/ M' (filter by used-mode) is now bound to `/ m'. 499The old binding for `/ M' (filter by used-mode) is now bound to `/ m'.
467 500
468** Mouse Avoidance mode 501---
502** `javascript-generic-mode' is now an obsolete alias for `js-mode'.
503
469+++ 504+++
470*** New variable `mouse-avoidance-banish-position' specifies where the 505** New option `mouse-avoidance-banish-position' specifies where the
471`banish' mouse avoidance setting moves the mouse. 506`banish' mouse avoidance setting moves the mouse.
472 507
473+++ 508+++
@@ -475,11 +510,14 @@ The old binding for `/ M' (filter by used-mode) is now bound to `/ m'.
475The function `notifications-get-capabilities' returns the supported 510The function `notifications-get-capabilities' returns the supported
476server properties. 511server properties.
477 512
513---
478** In Perl mode, new option `perl-indent-parens-as-block' causes non-block 514** In Perl mode, new option `perl-indent-parens-as-block' causes non-block
479closing brackets to be aligned with the line of the opening bracket. 515closing brackets to be aligned with the line of the opening bracket.
480 516
517---
481** In Proced mode, new command `proced-renice' renices marked processes. 518** In Proced mode, new command `proced-renice' renices marked processes.
482 519
520---
483** Python mode 521** Python mode
484 522
485A new version of python.el, which provides several new features, including: 523A new version of python.el, which provides several new features, including:
@@ -526,6 +564,8 @@ python-insert-while | python-skeleton-while
526python-find-function | python-nav-jump-to-defun 564python-find-function | python-nav-jump-to-defun
527python-next-statement | python-nav-forward-sentence 565python-next-statement | python-nav-forward-sentence
528python-previous-statement | python-nav-backward-sentence 566python-previous-statement | python-nav-backward-sentence
567python-beginning-of-defun-function | python-nav-beginning-of-defun
568python-end-of-defun-function | python-nav-end-of-defun
529python-send-buffer | python-shell-send-buffer 569python-send-buffer | python-shell-send-buffer
530python-send-defun | python-shell-send-defun 570python-send-defun | python-shell-send-defun
531python-send-region | python-shell-send-region 571python-send-region | python-shell-send-region
@@ -535,37 +575,28 @@ python-send-string | python-shell-send-string
535python-switch-to-python | python-shell-switch-to-shell 575python-switch-to-python | python-shell-switch-to-shell
536python-describe-symbol | python-eldoc-at-point 576python-describe-symbol | python-eldoc-at-point
537 577
578---
538** reStructuredText mode 579** reStructuredText mode
539 580
540*** Rebind nearly all keys making room for more keys and complying 581*** Keybindings (see `C-c C-h'), TAB indentation, filling and auto-filling,
541better to usage in other modes. Describe bindings with C-c C-h. 582fontification, comment handling, and customization have all been revised
542 583and improved.
543*** Major revision of indentation working very similar to other
544modes. TAB is your friend.
545
546*** Major revision of filling working fine with most of
547reStructuredText syntax. Support auto-filling.
548 584
549*** Major revision of comment handling. 585*** Support for `imenu' and `which-function-mode'.
550 586
551*** Major revision of fontification working with `jit-lock-mode'. 587*** The reStructuredText syntax is more closely covered.
552 588Sphinx support has been improved.
553*** Cover reStructuredText syntax more closely. Improve
554the experience for Sphinx users.
555 589
556*** `rst-insert-list' inserts new list or continues existing lists. 590*** `rst-insert-list' inserts new list or continues existing lists.
557 591
558*** Extend correct and improve customization. 592*** A negative prefix argument always works for `rst-adjust'.
559
560*** Negative prefix argument always works for `rst-adjust'.
561 593
562*** Reset window configuration after displaying TOC. 594*** The window configuration is reset after displaying a TOC.
563 595
564*** Package version in `rst-version'. 596*** The constant `rst-version' describes the rst.el package version.
565 597
566*** Support `imenu' and `which-func'. 598---
567 599** Shell Script mode
568** SH Script mode
569 600
570*** Pairing of parens/quotes uses electric-pair-mode instead of skeleton-pair. 601*** Pairing of parens/quotes uses electric-pair-mode instead of skeleton-pair.
571 602
@@ -573,49 +604,46 @@ the experience for Sphinx users.
573 604
574*** `sh-use-smie' lets you choose a new indentation and navigation code. 605*** `sh-use-smie' lets you choose a new indentation and navigation code.
575 606
576** Shell 607+++
577 608** New option `async-shell-command-buffer' specifies the buffer to use
578*** New option `async-shell-command-buffer' specifies what buffer to use 609for a new asynchronous `shell-command' when the default output buffer
579for a new asynchronous shell command when the default output buffer 610`*Async Shell Command*' is already in use.
580`*Async Shell Command*' is already taken by another running command.
581
582** SQL Mode
583
584*** DB2 added `sql-db2-escape-newlines'
585 611
612---
613** SQL mode has a new option `sql-db2-escape-newlines'.
586If non-nil, newlines sent to the command interpreter will be escaped 614If non-nil, newlines sent to the command interpreter will be escaped
587by a backslash. The default does not escape the newlines and assumes 615by a backslash. The default does not escape the newlines and assumes
588that the sql statement will be terminated by a semicolon. 616that the sql statement will be terminated by a semicolon.
589 617
590** Tabulated List and packages derived from it 618** Tabulated List and packages derived from it
591 619+++
592*** New command `tabulated-list-sort', bound to `S', sorts the column 620*** New command `tabulated-list-sort', bound to `S', sorts the column
593at point, or the Nth column if a numeric prefix argument is given. 621at point, or the Nth column if a numeric prefix argument is given.
594 622
595** Term 623** Term
596 624+++
597The variables `term-default-fg-color' and `term-default-bg-color' are 625*** The variables `term-default-fg-color' and `term-default-bg-color' are
598now deprecated in favor of the `term-face' face, that you can 626now deprecated in favor of the customizable face `term'.
599customize. Also, it is now possible to customize how are displayed the 627+++
600ANSI terminal colors and styles by customizing the corresponding 628*** You can customize how to display ANSI terminal colors and styles
601`term-color-<COLOR>', `term-color-underline' and `term-color-bold' 629by customizing the corresponding `term-color-<COLOR>',
602faces. 630`term-color-underline' and `term-color-bold' faces.
603 631
604** Tramp 632** Tramp
605+++ 633+++
606*** The syntax has been extended in order to allow ad-hoc proxy 634*** The syntax has been extended in order to allow ad-hoc proxy definitions.
607definitions. See the manual for details. 635See the manual for details.
608+++ 636+++
609*** Remote processes are now supported also on remote Windows host. 637*** Remote processes are now supported also on remote Windows host.
610 638
611** URL 639** URL
612 640+++
613*** Structs made by `url-generic-parse-url' have nil `attributes' slot. 641*** Structs made by `url-generic-parse-url' have nil `attributes' slot.
614Previously, this slot stored semicolon-separated attribute-value pairs 642Previously, this slot stored semicolon-separated attribute-value pairs
615appended to some imap URLs, but this is not compatible with RFC 3986. 643appended to some imap URLs, but this is not compatible with RFC 3986.
616So now the `filename' slot stores the entire path and query components 644So now the `filename' slot stores the entire path and query components
617and the `attributes' slot is always nil. 645and the `attributes' slot is always nil.
618 646+++
619*** New function `url-encode-url' for encoding a URI string. 647*** New function `url-encode-url' for encoding a URI string.
620The `url-retrieve' function now uses this to encode its URL argument, 648The `url-retrieve' function now uses this to encode its URL argument,
621in case that is not properly encoded. 649in case that is not properly encoded.
@@ -631,9 +659,8 @@ in case that is not properly encoded.
631 659
632*** Accepts \r and \f as whitespace. 660*** Accepts \r and \f as whitespace.
633 661
634** Which Function mode
635+++ 662+++
636*** `which-func-modes' now defaults to t, so Which Function mode, when 663** `which-func-modes' now defaults to t, so Which Function mode, when
637enabled, applies to all applicable major modes. 664enabled, applies to all applicable major modes.
638 665
639--- 666---
@@ -674,6 +701,8 @@ And in any case it's just a terrible package: ugly semantics, terrible
674inefficiency, and not namespace-clean. 701inefficiency, and not namespace-clean.
675--- 702---
676*** bruce.el 703*** bruce.el
704+++
705*** cust-print.el
677--- 706---
678*** ledit.el 707*** ledit.el
679--- 708---
@@ -682,14 +711,6 @@ inefficiency, and not namespace-clean.
682*** mouse-sel.el 711*** mouse-sel.el
683--- 712---
684*** patcomp.el 713*** patcomp.el
685+++
686*** cust-print.el
687
688
689* New Modes and Packages in Emacs 24.3
690
691FIXME? erc-desktop-notifications.el, gv.el, profiler.el,
692gnus-notifications.el, mm-archive.el
693 714
694 715
695* Incompatible Lisp Changes in Emacs 24.3 716* Incompatible Lisp Changes in Emacs 24.3
@@ -708,6 +729,7 @@ sequence in later calls.
708font name as a string. Whether it returns a font spec or a font name 729font name as a string. Whether it returns a font spec or a font name
709depends on the graphical library. 730depends on the graphical library.
710 731
732+++
711** If the NEWTEXT arg to `replace-match' contains a substring "\?", 733** If the NEWTEXT arg to `replace-match' contains a substring "\?",
712that substring is inserted literally even if the LITERAL arg is 734that substring is inserted literally even if the LITERAL arg is
713non-nil, instead of causing an error to be signaled. 735non-nil, instead of causing an error to be signaled.
@@ -733,6 +755,13 @@ third argument is a frame (that usage was obsolete since Emacs 22.2).
733but keywords or keyword-string pairs. The old argument list will 755but keywords or keyword-string pairs. The old argument list will
734still be supported for Emacs 24.x. 756still be supported for Emacs 24.x.
735 757
758+++
759** The CL package's `get-setf-method' function no longer exists.
760Generalized variables are now part of core Emacs Lisp, and implemented
761differently to the way cl.el used to do it. It is not possible to
762define a compatible replacement for `get-setf-method'. See the file
763gv.el for internal details of the new implementation.
764
736** Spelling changes. 765** Spelling changes.
737Some Lisp symbols have been renamed to avoid problems with spelling 766Some Lisp symbols have been renamed to avoid problems with spelling
738that is incorrect or inconsistent with how Emacs normally spells a word. 767that is incorrect or inconsistent with how Emacs normally spells a word.
@@ -764,16 +793,18 @@ are deprecated and will be removed eventually.
764 deactivate-current-input-method-function 793 deactivate-current-input-method-function
765 794
766+++ 795+++
767** Some obsolete functions, variables, and faces were removed: 796** Some obsolete functions, variables, and faces have been removed:
797*** `last-input-char', `last-command-char', `unread-command-char'
768*** `facemenu-unlisted-faces' 798*** `facemenu-unlisted-faces'
769*** `rmail-decode-mime-charset' 799*** `rmail-decode-mime-charset'
770*** `last-input-char', `last-command-char', `unread-command-char'.
771*** `iswitchb-read-buffer' 800*** `iswitchb-read-buffer'
772*** `sc-version', `sc-submit-bug-report' 801*** `sc-version', `sc-submit-bug-report'
773*** `set-char-table-default' 802*** `set-char-table-default'
774*** `string-to-sequence' (use `string-to-list' or `string-to-vector'). 803*** `string-to-sequence' (use `string-to-list' or `string-to-vector')
775*** `compile-internal' 804*** `compile-internal'
805*** `modeline'
776*** `mode-line-inverse-video' 806*** `mode-line-inverse-video'
807*** `follow-mode-off-hook'
777*** `cvs-commit-buffer-require-final-newline' 808*** `cvs-commit-buffer-require-final-newline'
778(use `log-edit-require-final-newline' instead) 809(use `log-edit-require-final-newline' instead)
779*** `cvs-changelog-full-paragraphs' 810*** `cvs-changelog-full-paragraphs'
@@ -782,18 +813,20 @@ are deprecated and will be removed eventually.
782*** `vc-ignore-vc-files' (use `vc-handled-backends' instead) 813*** `vc-ignore-vc-files' (use `vc-handled-backends' instead)
783*** `vc-master-templates' (use `vc-handled-backends' instead) 814*** `vc-master-templates' (use `vc-handled-backends' instead)
784*** `vc-checkout-carefully' 815*** `vc-checkout-carefully'
785*** `modeline'
786 816
787 817
788* Lisp changes in Emacs 24.3 818* Lisp changes in Emacs 24.3
789 819
790** New sampling-based Elisp profiler. 820** New sampling-based Elisp profiler.
791Try M-x profiler-start ... M-x profiler-stop; and then M-x profiler-report. 821Try M-x profiler-start, do some work, and then call M-x profiler-report.
792The sampling rate can be based on CPU time (only supported on some 822When finished, use M-x profiler-stop. The sampling rate can be based on
793systems), or based on memory allocations. 823CPU time (only supported on some systems) or memory allocations.
794 824
825+++
795** CL-style generalized variables are now in core Elisp. 826** CL-style generalized variables are now in core Elisp.
796`setf' is autoloaded; `push' and `pop' accept generalized variables. 827`setf' is autoloaded; `push' and `pop' accept generalized variables.
828You can define your own generalized variables using `gv-define-simple-setter',
829`gv-define-setter', etc.
797 830
798+++ 831+++
799** `defun' also accepts a (declare DECLS) form, like `defmacro'. 832** `defun' also accepts a (declare DECLS) form, like `defmacro'.
@@ -817,15 +850,19 @@ table, but with a different prefix.
817 850
818** Debugger changes 851** Debugger changes
819 852
853+++
820*** New error type and new function `user-error'. 854*** New error type and new function `user-error'.
821These do not trigger the debugger. 855These do not trigger the debugger.
822 856
823*** New option `debugger-bury-or-kill'. 857+++
858*** New option `debugger-bury-or-kill', saying what to do with the
859debugger buffer when exiting debug.
824 860
861+++
825*** Set `debug-on-message' to enter the debugger when a certain 862*** Set `debug-on-message' to enter the debugger when a certain
826message is displayed in the echo area. This can be useful when trying 863message is displayed in the echo area. This can be useful when trying
827to work out which code is doing something. 864to work out which code is doing something.
828 865---
829*** New var `inhibit-debugger', automatically set to prevent accidental 866*** New var `inhibit-debugger', automatically set to prevent accidental
830recursive invocations. 867recursive invocations.
831 868
@@ -833,7 +870,7 @@ recursive invocations.
833+++ 870+++
834*** The functions get-lru-window, get-mru-window and get-largest-window 871*** The functions get-lru-window, get-mru-window and get-largest-window
835now accept a third argument to avoid choosing the selected window. 872now accept a third argument to avoid choosing the selected window.
836 873+++
837*** Additional values recognized for option `window-combination-limit'. 874*** Additional values recognized for option `window-combination-limit'.
838 875
839*** New macro `with-temp-buffer-window'. 876*** New macro `with-temp-buffer-window'.
@@ -886,7 +923,7 @@ in Emacs 24.1:
886*** `current-time-string' no longer requires that its argument's year 923*** `current-time-string' no longer requires that its argument's year
887must be in the range 1000..9999. It now works with any year supported 924must be in the range 1000..9999. It now works with any year supported
888by the underlying C implementation. 925by the underlying C implementation.
889 926+++
890*** `current-time' now returns extended-format time stamps 927*** `current-time' now returns extended-format time stamps
891(HIGH LOW USEC PSEC), where the new PSEC slot specifies picoseconds. 928(HIGH LOW USEC PSEC), where the new PSEC slot specifies picoseconds.
892PSEC is typically a multiple of 1000 on current machines. Other 929PSEC is typically a multiple of 1000 on current machines. Other
@@ -898,7 +935,7 @@ stamps are still accepted.
898[TRIGGERED-P HI-SECS LO-SECS USECS REPEAT-DELAY FUNCTION ARGS IDLE-DELAY PSECS]. 935[TRIGGERED-P HI-SECS LO-SECS USECS REPEAT-DELAY FUNCTION ARGS IDLE-DELAY PSECS].
899The PSECS slot is new, and uses picosecond resolution. It can be 936The PSECS slot is new, and uses picosecond resolution. It can be
900accessed via the new timer--psecs accessor. 937accessed via the new timer--psecs accessor.
901 938+++
902*** Last-modified time stamps in undo lists now are of the form 939*** Last-modified time stamps in undo lists now are of the form
903(t HI-SECS LO-SECS USECS PSECS) instead of (t HI-SECS . LO-SECS). 940(t HI-SECS LO-SECS USECS PSECS) instead of (t HI-SECS . LO-SECS).
904 941
@@ -919,9 +956,9 @@ describing the cycle.
919 956
920** Miscellaneous new functions: 957** Miscellaneous new functions:
921+++ 958+++
922*** `autoloadp' 959*** `autoloadp' tests if its argument is an autoloaded object.
923+++ 960+++
924*** `autoload-do-load' 961*** `autoload-do-load' performs the autoloading operation.
925+++ 962+++
926*** `buffer-narrowed-p' tests if the buffer is narrowed. 963*** `buffer-narrowed-p' tests if the buffer is narrowed.
927+++ 964+++
@@ -938,6 +975,7 @@ describing the cycle.
938+++ 975+++
939*** `tty-top-frame' returns the topmost frame of a text terminal. 976*** `tty-top-frame' returns the topmost frame of a text terminal.
940 977
978+++
941** New macros `setq-local' and `defvar-local'. 979** New macros `setq-local' and `defvar-local'.
942 980
943+++ 981+++
@@ -948,13 +986,13 @@ See the "Face Attributes" section of the Elisp manual.
948 986
949** The following functions and variables are obsolete: 987** The following functions and variables are obsolete:
950--- 988---
951*** `automount-dir-prefix' 989*** `automount-dir-prefix' (use `directory-abbrev-alist')
952+++ 990+++
953*** `buffer-has-markers-at' 991*** `buffer-has-markers-at'
954--- 992---
955*** `macro-declaration-function' (use `macro-declarations-alist') 993*** `macro-declaration-function' (use `macro-declarations-alist')
956--- 994---
957*** `window-system-version' 995*** `window-system-version' (provides no useful information)
958--- 996---
959*** `dired-pop-to-buffer' (use `dired-mark-pop-up') 997*** `dired-pop-to-buffer' (use `dired-mark-pop-up')
960--- 998---
diff --git a/lib/makefile.w32-in b/lib/makefile.w32-in
index 7e807278a40..67171e07900 100644
--- a/lib/makefile.w32-in
+++ b/lib/makefile.w32-in
@@ -116,6 +116,12 @@ $(BLD)/c-strcasecmp.$(O) : \
116 $(CONFIG_H) \ 116 $(CONFIG_H) \
117 $(C_CTYPE_H) 117 $(C_CTYPE_H)
118 118
119$(BLD)/c-strncasecmp.$(O) : \
120 $(GNU_LIB)/c-strncasecmp.c \
121 $(GNU_LIB)/c-strcase.h \
122 $(CONFIG_H) \
123 $(C_CTYPE_H)
124
119$(BLD)/close-stream.$(O) : \ 125$(BLD)/close-stream.$(O) : \
120 $(GNU_LIB)/close-stream.c \ 126 $(GNU_LIB)/close-stream.c \
121 $(GNU_LIB)/close-stream.h \ 127 $(GNU_LIB)/close-stream.h \
@@ -123,12 +129,6 @@ $(BLD)/close-stream.$(O) : \
123 $(NT_INC)/stdbool.h \ 129 $(NT_INC)/stdbool.h \
124 $(CONFIG_H) 130 $(CONFIG_H)
125 131
126$(BLD)/c-strncasecmp.$(O) : \
127 $(GNU_LIB)/c-strncasecmp.c \
128 $(GNU_LIB)/c-strcase.h \
129 $(CONFIG_H) \
130 $(C_CTYPE_H)
131
132$(BLD)/dtoastr.$(O) : \ 132$(BLD)/dtoastr.$(O) : \
133 $(GNU_LIB)/dtoastr.c \ 133 $(GNU_LIB)/dtoastr.c \
134 $(FTOASTR_C) 134 $(FTOASTR_C)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2347b7f6e93..fc69b8643b6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,335 @@
12012-11-13 Dmitry Gutov <dgutov@yandex.ru>
2
3 * progmodes/ruby-mode.el (ruby-add-log-current-method): Print the
4 period before class method names, not after. Remove handling of
5 one impossible case. Add comments.
6
72012-11-13 Stefan Monnier <monnier@iro.umontreal.ca>
8
9 * emacs-lisp/advice.el: Remove support for freezing.
10 (ad-make-freeze-docstring, ad-make-freeze-definition): Remove functions.
11 (ad-make-single-advice-docstring, ad-defadvice-flags, defadvice):
12 Remove support for `freeze'.
13
14 * emacs-lisp/cl.el (dolist, dotimes, declare): Use advice-add to
15 override the default.
16 * emacs-lisp/cl-macs.el (cl-dolist, cl-dotimes): Rewrite without using
17 cl--dotimes/dolist.
18 * subr.el (dolist, dotimes, declare): Redefine them normally, even when
19 `cl' is loaded.
20
21 * emacs-lisp/nadvice.el (advice--normalize): New function, extracted
22 from add-advice.
23 (advice--strip-macro): New function.
24 (advice--defalias-fset): Use them to handle macros.
25 (advice-add): Use them.
26 (advice-member-p): Correctly handle macros.
27
282012-11-13 Dmitry Gutov <dgutov@yandex.ru>
29
30 * progmodes/ruby-mode.el (ruby-font-lock-keywords):
31 Never font-lock the beginning of singleton class as heredoc.
32
332012-11-13 Stefan Monnier <monnier@iro.umontreal.ca>
34
35 * emacs-lisp/gv.el (gv-define-simple-setter): One more fix (bug#12871).
36
372012-11-13 Wolfgang Jenkner <wjenkner@inode.at>
38
39 * ansi-color.el (ansi-color-apply-sequence): Implement SGR codes
40 39 and 49 (bug#12792). Also, treat unimplemented parameters as 0,
41 thereby restoring the behavior of revisions prior to 2012-08-15T03:33:55Z!monnier@iro.umontreal.ca.
42
432012-11-13 Fabián Ezequiel Gallina <fgallina@cuca>
44
45 Fix end-of-defun misbehavior.
46 * progmodes/python.el (python-nav-beginning-of-defun): Rename from
47 python-beginning-of-defun-function. Handle nested defuns
48 correctly.
49 (python-nav-end-of-defun): Rename from
50 python-end-of-defun-function. Ensure forward movement.
51 (python-info-current-defun): Reimplement to work as intended
52 with new fixed python-nav-{end,beginning}-of-defun. Stop scanning
53 parent defuns as soon as possible.
54
552012-11-13 Glenn Morris <rgm@gnu.org>
56
57 * progmodes/flymake.el (flymake-error-bitmap)
58 (flymake-warning-bitmap, flymake-fringe-indicator-position): Doc fixes.
59 (flymake-error-bitmap, flymake-warning-bitmap): Fix :types.
60
612012-11-13 Dmitry Gutov <dgutov@yandex.ru>
62
63 * progmodes/ruby-mode.el (ruby-move-to-block): When moving
64 backward, always stop at indentation. Reverts the change from
65 2012-08-12T22:06:56Z!monnier@iro.umontreal.ca (Bug#12851).
66
672012-11-13 Glenn Morris <rgm@gnu.org>
68
69 * ibuffer.el (ibuffer-mode-map, ibuffer-mode):
70 Add ibuffer-filter-by-derived-mode.
71
72 * ibuffer.el (ibuffer-mode-map): Don't have two menu items with
73 the same name shadowing each other.
74
75 * window.el (with-temp-buffer-window): Doc tweak.
76
77 * emacs-lisp/debug.el (debugger-bury-or-kill): Doc tweak.
78
79 * help.el (temp-buffer-max-height):
80 * window.el (fit-frame-to-buffer, fit-frame-to-buffer-bottom-margin):
81 * emacs-lisp/debug.el (debugger-bury-or-kill): Fix :version.
82
832012-11-12 Stefan Monnier <monnier@iro.umontreal.ca>
84
85 * emacs-lisp/nadvice.el: New package.
86 * subr.el (special-form-p): New function.
87 * emacs-lisp/elp.el: Use lexical-binding and advice-add.
88 (elp-all-instrumented-list): Remove var.
89 (elp-not-profilable): Remove elp-wrapper.
90 (elp-profilable-p): Use autoloadp and special-form-p.
91 (elp--advice-name): New const.
92 (elp-instrument-function): Use advice-add.
93 (elp--instrumented-p): New predicate.
94 (elp-restore-function): Use advice-remove.
95 (elp-restore-all, elp-reset-all): Use mapatoms.
96 (elp-set-master): Use elp--instrumented-p.
97 (elp--make-wrapper): Rename from elp-wrapper, return a function
98 suitable for advice-add. Use cl-inf.
99 (elp-results): Use mapatoms+elp--instrumented-p.
100 * emacs-lisp/debug.el: Use lexical-binding and advice-add.
101 (debug-function-list): Remove var.
102 (debug): Rename arg, and then let-bind it explicitly inside.
103 (debugger-setup-buffer): Rename arg.
104 (debugger-setup-buffer): Adjust counts to new debug-on-entry setup.
105 (debugger-frame-number): Adjust to new debug-on-entry setup.
106 (debug--implement-debug-on-entry): Rename from
107 implement-debug-on-entry, add argument.
108 (debugger-special-form-p): Remove, use special-form-p instead.
109 (debug-on-entry): Use advice-add.
110 (debug--function-list): New function.
111 (cancel-debug-on-entry): Use it, along with advice-remove.
112 (debug-arglist, debug-convert-byte-code, debug-on-entry-1): Remove.
113 (debugger-list-functions): Use debug--function-list instead of
114 debug-function-list.
115 * emacs-lisp/advice.el (ad-save-real-definition): Remove, unused.
116 (ad-special-form-p): Remove, use special-form-p instead.
117 (ad-set-advice-info): Use add-function and remove-function.
118 (ad--defalias-fset): Adjust accordingly.
119
1202012-11-10 Glenn Morris <rgm@gnu.org>
121
122 * mail/emacsbug.el (report-emacs-bug-tracker-url)
123 (report-emacs-bug-bug-alist, report-emacs-bug-choice-widget)
124 (report-emacs-bug-create-existing-bugs-buffer)
125 (report-emacs-bug-parse-query-results)
126 (report-emacs-bug-query-existing-bugs): Remove. (Bug#7449)
127
128 * term.el (term-default-fg-color, term-default-bg-color):
129 Make obsolete, rather than just saying "deprecated" in the doc.
130
131 * term.el (term): Rename from `term-face'.
132 (term-current-face, ansi-term-color-vector)
133 (term-default-fg-color, term-default-bg-color, term-ansi-reset):
134 Update all users.
135
1362012-11-10 Jan Djärv <jan.h.d@swipnet.se>
137
138 * server.el (server-create-window-system-frame): Handle Nextstep
139 specially (Bug#12780).
140
1412012-11-10 Glenn Morris <rgm@gnu.org>
142
143 * mail/emacsbug.el (report-emacs-bug-query-existing-bugs):
144 Unautoload, and make obsolete. (Bug#7449)
145
1462012-11-10 Chong Yidong <cyd@gnu.org>
147
148 * vc/diff-mode.el (diff-delete-trailing-whitespace): Rewrite, and
149 rename from diff-remove-trailing-whitespace (Bug#12831).
150
1512012-11-10 Stefan Monnier <monnier@iro.umontreal.ca>
152
153 * emacs-lisp/advice.el: Require `cl-lib' at run-time to fix
154 miscompilation of trace.el.
155
1562012-11-10 Glenn Morris <rgm@gnu.org>
157
158 * vc/diff-mode.el (diff-remove-trailing-whitespace): Doc fix.
159
1602012-11-10 Stefan Monnier <monnier@iro.umontreal.ca>
161
162 * emacs-lisp/gv.el (gv-define-simple-setter): Fix last change
163 (bug#12812).
164
1652012-11-10 Chong Yidong <cyd@gnu.org>
166
167 * minibuf-eldef.el (minibuffer-eldef-shorten-default): Convert to
168 a defcustom with an appropriate :set function.
169 (minibuffer-default--in-prompt-regexps): New function.
170
1712012-11-10 Glenn Morris <rgm@gnu.org>
172
173 * emacs-lisp/cl.el (define-setf-expander, defsetf)
174 (define-modify-macro): Doc fixes.
175
176 * emacs-lisp/gv.el (gv-letplace): Fix doc typo.
177 (gv-define-simple-setter): Update doc of `fix-return'.
178
1792012-11-10 Stefan Monnier <monnier@iro.umontreal.ca>
180
181 * emacs-lisp/gv.el (gv-define-simple-setter): Don't evaluate `val'
182 twice when `fix-return' is set (bug#12813).
183
184 * emacs-lisp/cl.el (defsetf): Pass the third arg to
185 gv-define-simple-setter (bug#12812).
186
187 * woman.el (woman-decode-region): Disable adaptive-fill when rendering
188 (bug#12756).
189
1902012-11-10 Glenn Morris <rgm@gnu.org>
191
192 * emacs-lisp/gv.el (gv-define-setter): Fix doc typo.
193
194 * emacs-lisp/cl-extra.el (cl-prettyexpand):
195 * emacs-lisp/cl-lib.el (cl-proclaim, cl-declaim):
196 * emacs-lisp/cl-macs.el (cl-destructuring-bind, cl-locally)
197 (cl-the, cl-compiler-macroexpand): Add basic doc strings.
198
199 * emacs-lisp/cl-extra.el (cl-maplist, cl-mapcan): Doc fix.
200
2012012-11-10 Leo Liu <sdl.web@gmail.com>
202
203 * ido.el (ido-set-matches-1): Improve flex matching performance by
204 removing backtracking in the regexp (suggested by Stefan). (Bug#12796)
205
2062012-11-09 Stefan Monnier <monnier@iro.umontreal.ca>
207
208 * emacs-lisp/advice.el (ad-set-advice-info): Set defalias-fset-function.
209 (ad--defalias-fset): New function.
210 (ad-safe-fset): Remove.
211 (ad-make-freeze-definition): Use cl-letf*.
212
2132012-11-09 Stefan Monnier <monnier@iro.umontreal.ca>
214
215 * subr.el (dolist): Don't bind VAR in RESULT.
216
217 * emacs-lisp/advice.el: Miscellaneous cleanup. Use lexical-binding.
218 (fset, documentation): Don't save real def since we don't advise.
219 (ad-do-advised-functions): Remove problematic `result-form'.
220 (ad-safe-fset): `ad-real-fset' => `fset'.
221 (ad-read-advised-function): Don't assume that ad-do-advised-functions
222 uses CL's dolist internally.
223 (ad-arglist): Remove unused arg `name'.
224 (ad-docstring, ad-make-advised-docstring):
225 `ad-real-documentation' => `documentation'.
226 (warning-suppress-types): Declare.
227 (ad-set-arguments): Simple CSE.
228 (ad-recover-normality): Sanity check.
229
230 * emacs-lisp/bytecomp.el (byte-compile-out-toplevel): Don't turn
231 (funcall '(lambda ..) ..) into ((lambda ..) ..).
232
2332012-11-09 Vincent Belaïche <vincentb1@users.sourceforge.net>
234
235 * ses.el: symbol to coordinate mapping is made by symbol property
236 `ses-cell'. This means that the same mapping is done for all SES
237 sheets. That is good enough for cells with standard A1 names, but
238 not for named cell. So a hash map is added for the latter.
239 (defconst ses-localvars): Add local variable ses--named-cell-hashmap
240 (ses-sym-rowcol): Use hashmap for named cell.
241 (ses-is-cell-sym-p): New defun.
242 (ses-decode-cell-symbol): New defun.
243 (ses-create-cell-variable): Add cell to hashmap when name is not
244 A1-like.
245 (ses-rename-cell): Check that cell new name is not already in
246 spreadsheet with the use of ses-is-cell-sym-p
247 (ses-rename-cell): Use hash map for named cells, but accept also
248 renaming back to A1-like.
249
2502012-11-09 Stefan Monnier <monnier@iro.umontreal.ca>
251
252 * emacs-lisp/advice.el: Use new dynamic docstrings.
253 (ad-make-advised-definition-docstring, ad-advised-definition-p):
254 Use dynamic-docstring-function instead of ad-advice-info.
255 (ad--make-advised-docstring): New function extracted from
256 ad-make-advised-docstring.
257 (ad-make-advised-docstring): Use it.
258 * progmodes/sql.el (sql--make-help-docstring): New function, extracted
259 from sql-help.
260 (sql-help): Use it with dynamic-docstring-function.
261
262 * env.el (env--substitute-vars-regexp): Don't use rx (for bootstrap).
263
2642012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
265
266 * files.el (hack-one-local-variable--obsolete): New function.
267 (hack-one-local-variable): Use it for obsolete settings.
268
269 * subr.el (locate-user-emacs-file): If both old and new name exist, use
270 the new name.
271
272 * progmodes/js.el (js--filling-paragraph): New var.
273 (c-forward-sws, c-backward-sws, c-beginning-of-macro): Advise.
274 (js-c-fill-paragraph): Prefer advice to cl-letf so the rebinding is
275 less sneaky.
276
2772012-11-08 Julien Danjou <julien@danjou.info>
278
279 * progmodes/ruby-mode.el (auto-mode-alist): Add Rakefile in
280 `auto-mode-alist' (Bug#12835).
281
2822012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
283
284 * progmodes/perl-mode.el (perl-prettify-symbols): New defcustom.
285 (perl--prettify-symbols-alist): New const.
286 (perl--font-lock-compose-symbol, perl--font-lock-symbols-keywords):
287 New functions.
288 (perl-font-lock-keywords-2): Use them.
289 (perl-electric-noindent-p): New function.
290 (perl-mode): Use it to set up electric-indent-mode.
291 (perl-electric-terminator, perl-indent-command): Mark obsolete.
292 (perl-mode-map): Remove bindings for them.
293 (perl-imenu-generic-expression, perl-outline-level):
294 Match functions&packages in column>0.
295
296 * env.el (env--substitute-vars-regexp): New const.
297 (substitute-env-vars): Use it. Add `only-defined' arg.
298 * net/tramp.el (tramp-replace-environment-variables): Use it.
299
300 * emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment):
301 Byte-compile *before* eval in eval-and-compile.
302 (byte-compile-log-warning): Remove redundant inhibit-read-only.
303 (byte-compile-file-form-autoload): Don't hide actual definition.
304 (byte-compile-maybe-guarded): Accept `functionp' as well.
305
306 * emacs-lisp/gv.el (gv-ref, gv-deref): New function and macro.
307
3082012-11-07 Michael Albinus <michael.albinus@gmx.de>
309
310 * notifications.el (notifications-get-server-information-method):
311 New defconst.
312 (notifications-get-capabilities): Fix docstring.
313 (notifications-get-server-information): New defun.
314
3152012-11-06 Agustín Martín Domingo <agustin.martin@hispalinux.es>
316
317 * textmodes/ispell.el (ispell-region): Standard re-indent for better
318 readability.
319
320 * textmodes/ispell.el: Experimental support for support debugging.
321 (ispell-create-debug-buffer): Create a `ispell-debug-buffer' debug
322 buffer for ispell.
323 (ispell-print-if-debug): New function to print stuff to
324 `ispell-debug-buffer' if debugging is enabled.
325 (ispell-region, ispell-process-line): Use `ispell-print-if-debug' to
326 show some debugging info.
327 (ispell-buffer-with-debug): New function that creates a debugging
328 buffer and calls `ispell-buffer' with debugging enabled.
329
330 * textmodes/ispell.el (ispell-region): Do not prefix sent string by
331 comment in autoconf mode. (Bug#12768)
332
12012-11-06 Dmitry Antipov <dmantipov@yandex.ru> 3332012-11-06 Dmitry Antipov <dmantipov@yandex.ru>
2 334
3 * emacs-lisp/byte-opt.el (toplevel): Add compare-window-configurations, 335 * emacs-lisp/byte-opt.el (toplevel): Add compare-window-configurations,
@@ -20,8 +352,8 @@
20 352
212012-11-05 Agustín Martín Domingo <agustin.martin@hispalinux.es> 3532012-11-05 Agustín Martín Domingo <agustin.martin@hispalinux.es>
22 354
23 * textmodes/ispell.el (ispell-program-name): Update 355 * textmodes/ispell.el (ispell-program-name):
24 spellchecker parameters when customized. 356 Update spellchecker parameters when customized.
25 357
262012-11-04 Glenn Morris <rgm@gnu.org> 3582012-11-04 Glenn Morris <rgm@gnu.org>
27 359
@@ -415,7 +747,7 @@
4152012-10-19 Stefan Monnier <monnier@iro.umontreal.ca> 7472012-10-19 Stefan Monnier <monnier@iro.umontreal.ca>
416 748
417 * minibuffer.el (minibuffer-force-complete): Make the next completion use 749 * minibuffer.el (minibuffer-force-complete): Make the next completion use
418 the same completion-field (bug@12221). 750 the same completion-field (bug#12221).
419 751
4202012-10-19 Martin Rudalics <rudalics@gmx.at> 7522012-10-19 Martin Rudalics <rudalics@gmx.at>
421 753
diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index 047b4b944b9..da2880c404c 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -534,34 +534,39 @@ Returns nil only if there's no match for `ansi-color-parameter-regexp'."
534 534
535ESCAPE-SEQ is an escape sequence parsed by `ansi-color-parse-sequence'. 535ESCAPE-SEQ is an escape sequence parsed by `ansi-color-parse-sequence'.
536 536
537If the new codes resulting from ESCAPE-SEQ start with 0, then the 537For each new code, the following happens: if it is 1-7, add it to
538old codes are discarded and the remaining new codes are 538the list of codes; if it is 21-25 or 27, delete appropriate
539processed. Otherwise, for each new code: if it is 21-25 or 27-29 539parameters from the list of codes; if it is 30-37 resp. 39, the
540delete appropriate parameters from the list of codes; any other 540foreground color code is replaced or added resp. deleted; if it
541code that makes sense is added to the list of codes. Finally, 541is 40-47 resp. 49, the background color code is replaced or added
542the so changed list of codes is returned." 542resp. deleted; any other code is discarded together with the old
543codes. Finally, the so changed list of codes is returned."
543 (let ((new-codes (ansi-color-parse-sequence escape-sequence))) 544 (let ((new-codes (ansi-color-parse-sequence escape-sequence)))
544 (while new-codes 545 (while new-codes
545 (setq codes 546 (let* ((new (pop new-codes))
546 (let ((new (pop new-codes))) 547 (q (/ new 10)))
547 (cond ((zerop new) 548 (setq codes
548 nil) 549 (pcase q
549 ((or (<= new 20) 550 (0 (unless (memq new '(0 8 9))
550 (>= new 30)) 551 (cons new (remq new codes))))
551 (if (memq new codes) 552 (2 (unless (memq new '(20 26 28 29))
552 codes 553 ;; The standard says `21 doubly underlined' while
553 (cons new codes))) 554 ;; http://en.wikipedia.org/wiki/ANSI_escape_code claims
554 ;; The standard says `21 doubly underlined' while 555 ;; `21 Bright/Bold: off or Underline: Double'.
555 ;; http://en.wikipedia.org/wiki/ANSI_escape_code claims 556 (remq (- new 20) (pcase new
556 ;; `21 Bright/Bold: off or Underline: Double'. 557 (22 (remq 1 codes))
557 ((/= new 26) 558 (25 (remq 6 codes))
558 (remq (- new 20) 559 (_ codes)))))
559 (cond ((= new 22) 560 ((or 3 4) (let ((r (mod new 10)))
560 (remq 1 codes)) 561 (unless (= r 8)
561 ((= new 25) 562 (let (beg)
562 (remq 6 codes)) 563 (while (and codes (/= q (/ (car codes) 10)))
563 (t codes)))) 564 (push (pop codes) beg))
564 (t codes))))) 565 (setq codes (nconc (nreverse beg) (cdr codes)))
566 (if (= r 9)
567 codes
568 (cons new codes))))))
569 (_ nil)))))
565 codes)) 570 codes))
566 571
567(defun ansi-color-make-color-map () 572(defun ansi-color-make-color-map ()
diff --git a/lisp/cedet/ChangeLog b/lisp/cedet/ChangeLog
index 6f2669e9fee..755f4c8159b 100644
--- a/lisp/cedet/ChangeLog
+++ b/lisp/cedet/ChangeLog
@@ -1,7 +1,20 @@
12012-11-13 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * semantic/mru-bookmark.el (semantic-mru-bookmark-mode):
4 * semantic/grammar.el (semantic-grammar-mode):
5 * semantic/util-modes.el (semantic-highlight-edits-mode)
6 (semantic-show-parser-state-mode): Avoid obsolete name
7 semantic-edits-new-change-hooks (bug#12869).
8
92012-11-13 Glenn Morris <rgm@gnu.org>
10
11 * srecode/srt-mode.el (srecode-template-mode):
12 Don't change global values of comment-start, comment-end. (Bug#12781)
13
12012-10-25 David Engster <deng@randomsample.de> 142012-10-25 David Engster <deng@randomsample.de>
2 15
3 * semantic/analyze.el (semantic-analyze-dereference-alias): New 16 * semantic/analyze.el (semantic-analyze-dereference-alias):
4 function to dereference aliases. 17 New function to dereference aliases.
5 (semantic-analyze-current-context-default): Use it. 18 (semantic-analyze-current-context-default): Use it.
6 19
7 * semantic/grammar.el (semantic-grammar-create-package): 20 * semantic/grammar.el (semantic-grammar-create-package):
@@ -12,8 +25,8 @@
12 25
13 * semantic.el (semantic-elapsed-time): Make it a defsubst. 26 * semantic.el (semantic-elapsed-time): Make it a defsubst.
14 27
15 * srecode/dictionary.el (srecode-adebug-dictionary): Remove 28 * srecode/dictionary.el (srecode-adebug-dictionary):
16 require for `semantic'. 29 Remove require for `semantic'.
17 30
18 * srecode/map.el: 31 * srecode/map.el:
19 * srecode/insert.el: Declare functions from `data-debug'. 32 * srecode/insert.el: Declare functions from `data-debug'.
diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index c0e7b8f9038..8535c067e09 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -1333,8 +1333,8 @@ the change bounds to encompass the whole nonterminal tag."
1333 (add-hook 'before-change-functions 1333 (add-hook 'before-change-functions
1334 'semantic--grammar-clear-macros-regexp-2 nil t) 1334 'semantic--grammar-clear-macros-regexp-2 nil t)
1335 ;; Handle safe re-parse of grammar rules. 1335 ;; Handle safe re-parse of grammar rules.
1336 (semantic-make-local-hook 'semantic-edits-new-change-hooks) 1336 (semantic-make-local-hook 'semantic-edits-new-change-functions)
1337 (add-hook 'semantic-edits-new-change-hooks 1337 (add-hook 'semantic-edits-new-change-functions
1338 'semantic-grammar-edits-new-change-hook-fcn 1338 'semantic-grammar-edits-new-change-hook-fcn
1339 nil t) 1339 nil t)
1340 (semantic-run-mode-hooks 'semantic-grammar-mode-hook)) 1340 (semantic-run-mode-hooks 'semantic-grammar-mode-hook))
diff --git a/lisp/cedet/semantic/mru-bookmark.el b/lisp/cedet/semantic/mru-bookmark.el
index d042ba42582..1358fc7d062 100644
--- a/lisp/cedet/semantic/mru-bookmark.el
+++ b/lisp/cedet/semantic/mru-bookmark.el
@@ -292,13 +292,13 @@ minor mode is enabled."
292 (setq semantic-mru-bookmark-mode nil) 292 (setq semantic-mru-bookmark-mode nil)
293 (error "Buffer %s was not set up for parsing" 293 (error "Buffer %s was not set up for parsing"
294 (buffer-name))) 294 (buffer-name)))
295 (semantic-make-local-hook 'semantic-edits-new-change-hooks) 295 (semantic-make-local-hook 'semantic-edits-new-change-functions)
296 (add-hook 'semantic-edits-new-change-hooks 296 (add-hook 'semantic-edits-new-change-functions
297 'semantic-mru-bookmark-change-hook-fcn nil t) 297 'semantic-mru-bookmark-change-hook-fcn nil t)
298 (add-hook 'semantic-edits-move-change-hooks 298 (add-hook 'semantic-edits-move-change-hooks
299 'semantic-mru-bookmark-change-hook-fcn nil t)) 299 'semantic-mru-bookmark-change-hook-fcn nil t))
300 ;; Remove hooks 300 ;; Remove hooks
301 (remove-hook 'semantic-edits-new-change-hooks 301 (remove-hook 'semantic-edits-new-change-functions
302 'semantic-mru-bookmark-change-hook-fcn t) 302 'semantic-mru-bookmark-change-hook-fcn t)
303 (remove-hook 'semantic-edits-move-change-hooks 303 (remove-hook 'semantic-edits-move-change-hooks
304 'semantic-mru-bookmark-change-hook-fcn t))) 304 'semantic-mru-bookmark-change-hook-fcn t)))
diff --git a/lisp/cedet/semantic/util-modes.el b/lisp/cedet/semantic/util-modes.el
index c9a0faefe6c..744d37ff189 100644
--- a/lisp/cedet/semantic/util-modes.el
+++ b/lisp/cedet/semantic/util-modes.el
@@ -221,11 +221,11 @@ minor mode is enabled."
221 (setq semantic-highlight-edits-mode nil) 221 (setq semantic-highlight-edits-mode nil)
222 (error "Buffer %s was not set up for parsing" 222 (error "Buffer %s was not set up for parsing"
223 (buffer-name))) 223 (buffer-name)))
224 (semantic-make-local-hook 'semantic-edits-new-change-hooks) 224 (semantic-make-local-hook 'semantic-edits-new-change-functions)
225 (add-hook 'semantic-edits-new-change-hooks 225 (add-hook 'semantic-edits-new-change-functions
226 'semantic-highlight-edits-new-change-hook-fcn nil t)) 226 'semantic-highlight-edits-new-change-hook-fcn nil t))
227 ;; Remove hooks 227 ;; Remove hooks
228 (remove-hook 'semantic-edits-new-change-hooks 228 (remove-hook 'semantic-edits-new-change-functions
229 'semantic-highlight-edits-new-change-hook-fcn t))) 229 'semantic-highlight-edits-new-change-hook-fcn t)))
230 230
231(semantic-add-minor-mode 'semantic-highlight-edits-mode 231(semantic-add-minor-mode 'semantic-highlight-edits-mode
@@ -460,8 +460,8 @@ minor mode is enabled."
460 (append mode-line-modified 460 (append mode-line-modified
461 '(semantic-show-parser-state-string)))) 461 '(semantic-show-parser-state-string))))
462 ;; Add hooks 462 ;; Add hooks
463 (semantic-make-local-hook 'semantic-edits-new-change-hooks) 463 (semantic-make-local-hook 'semantic-edits-new-change-functions)
464 (add-hook 'semantic-edits-new-change-hooks 464 (add-hook 'semantic-edits-new-change-functions
465 'semantic-show-parser-state-marker nil t) 465 'semantic-show-parser-state-marker nil t)
466 (semantic-make-local-hook 'semantic-edits-incremental-reparse-failed-hook) 466 (semantic-make-local-hook 'semantic-edits-incremental-reparse-failed-hook)
467 (add-hook 'semantic-edits-incremental-reparse-failed-hook 467 (add-hook 'semantic-edits-incremental-reparse-failed-hook
@@ -491,7 +491,7 @@ minor mode is enabled."
491 (setq mode-line-modified 491 (setq mode-line-modified
492 (delq 'semantic-show-parser-state-string mode-line-modified)) 492 (delq 'semantic-show-parser-state-string mode-line-modified))
493 ;; Remove hooks 493 ;; Remove hooks
494 (remove-hook 'semantic-edits-new-change-hooks 494 (remove-hook 'semantic-edits-new-change-functions
495 'semantic-show-parser-state-marker t) 495 'semantic-show-parser-state-marker t)
496 (remove-hook 'semantic-edits-incremental-reparse-failed-hook 496 (remove-hook 'semantic-edits-incremental-reparse-failed-hook
497 'semantic-show-parser-state-marker t) 497 'semantic-show-parser-state-marker t)
diff --git a/lisp/cedet/srecode/srt-mode.el b/lisp/cedet/srecode/srt-mode.el
index 12fc08b90e4..298c8949435 100644
--- a/lisp/cedet/srecode/srt-mode.el
+++ b/lisp/cedet/srecode/srt-mode.el
@@ -189,8 +189,8 @@ we can tell font lock about them.")
189;;;###autoload 189;;;###autoload
190(define-derived-mode srecode-template-mode fundamental-mode "SRecorder" 190(define-derived-mode srecode-template-mode fundamental-mode "SRecorder"
191 "Major-mode for writing SRecode macros." 191 "Major-mode for writing SRecode macros."
192 (setq comment-start ";;" 192 (set (make-local-variable 'comment-start) ";;")
193 comment-end "") 193 (set (make-local-variable 'comment-end) "")
194 (set (make-local-variable 'parse-sexp-ignore-comments) t) 194 (set (make-local-variable 'parse-sexp-ignore-comments) t)
195 (set (make-local-variable 'comment-start-skip) 195 (set (make-local-variable 'comment-start-skip)
196 "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *") 196 "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index bd85238e23e..ecaf6861a6c 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -1,4 +1,4 @@
1;;; advice.el --- An overloading mechanism for Emacs Lisp functions 1;;; advice.el --- An overloading mechanism for Emacs Lisp functions -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 1993-1994, 2000-2012 Free Software Foundation, Inc. 3;; Copyright (C) 1993-1994, 2000-2012 Free Software Foundation, Inc.
4 4
@@ -1709,7 +1709,8 @@
1709;; During a normal load this is a noop: 1709;; During a normal load this is a noop:
1710(require 'advice-preload "advice.el") 1710(require 'advice-preload "advice.el")
1711(require 'macroexp) 1711(require 'macroexp)
1712(eval-when-compile (require 'cl-lib)) 1712;; At run-time also, since ad-do-advised-functions returns code that uses it.
1713(require 'cl-lib)
1713 1714
1714;; @@ Variable definitions: 1715;; @@ Variable definitions:
1715;; ======================== 1716;; ========================
@@ -1775,36 +1776,6 @@ generates a copy of TREE."
1775 (funcall fUnCtIoN tReE)) 1776 (funcall fUnCtIoN tReE))
1776 (t tReE))) 1777 (t tReE)))
1777 1778
1778;; @@ Save real definitions of subrs used by Advice:
1779;; =================================================
1780;; Advice depends on the real, unmodified functionality of various subrs,
1781;; we save them here so advised versions will not interfere (eventually,
1782;; we will save all subrs used in code generated by Advice):
1783
1784(defmacro ad-save-real-definition (function)
1785 (let ((saved-function (intern (format "ad-real-%s" function))))
1786 ;; Make sure the compiler is loaded during macro expansion:
1787 (require 'byte-compile "bytecomp")
1788 `(if (not (fboundp ',saved-function))
1789 (progn (fset ',saved-function (symbol-function ',function))
1790 ;; Copy byte-compiler properties:
1791 ,@(if (get function 'byte-compile)
1792 `((put ',saved-function 'byte-compile
1793 ',(get function 'byte-compile))))
1794 ,@(if (get function 'byte-opcode)
1795 `((put ',saved-function 'byte-opcode
1796 ',(get function 'byte-opcode))))))))
1797
1798(defun ad-save-real-definitions ()
1799 ;; Macro expansion will hardcode the values of the various byte-compiler
1800 ;; properties into the compiled version of this function such that the
1801 ;; proper values will be available at runtime without loading the compiler:
1802 (ad-save-real-definition fset)
1803 (ad-save-real-definition documentation))
1804
1805(ad-save-real-definitions)
1806
1807
1808;; @@ Advice info access fns: 1779;; @@ Advice info access fns:
1809;; ========================== 1780;; ==========================
1810 1781
@@ -1839,15 +1810,13 @@ generates a copy of TREE."
1839 ad-advised-functions))) 1810 ad-advised-functions)))
1840 1811
1841(defmacro ad-do-advised-functions (varform &rest body) 1812(defmacro ad-do-advised-functions (varform &rest body)
1842 "`dolist'-style iterator that maps over `ad-advised-functions'. 1813 "`dolist'-style iterator that maps over advised functions.
1843\(ad-do-advised-functions (VAR [RESULT-FORM]) 1814\(ad-do-advised-functions (VAR)
1844 BODY-FORM...) 1815 BODY-FORM...)
1845On each iteration VAR will be bound to the name of an advised function 1816On each iteration VAR will be bound to the name of an advised function
1846\(a symbol)." 1817\(a symbol)."
1847 (declare (indent 1)) 1818 (declare (indent 1))
1848 `(cl-dolist (,(car varform) 1819 `(cl-dolist (,(car varform) ad-advised-functions)
1849 ad-advised-functions
1850 ,(car (cdr varform)))
1851 (setq ,(car varform) (intern (car ,(car varform)))) 1820 (setq ,(car varform) (intern (car ,(car varform))))
1852 ,@body)) 1821 ,@body))
1853 1822
@@ -1857,8 +1826,15 @@ On each iteration VAR will be bound to the name of an advised function
1857(defmacro ad-get-advice-info-macro (function) 1826(defmacro ad-get-advice-info-macro (function)
1858 `(get ,function 'ad-advice-info)) 1827 `(get ,function 'ad-advice-info))
1859 1828
1860(defmacro ad-set-advice-info (function advice-info) 1829(defsubst ad-set-advice-info (function advice-info)
1861 `(put ,function 'ad-advice-info ,advice-info)) 1830 (cond
1831 (advice-info
1832 (add-function :around (get function 'defalias-fset-function)
1833 #'ad--defalias-fset))
1834 ((get function 'defalias-fset-function)
1835 (remove-function (get function 'defalias-fset-function)
1836 #'ad--defalias-fset)))
1837 (put function 'ad-advice-info advice-info))
1862 1838
1863(defmacro ad-copy-advice-info (function) 1839(defmacro ad-copy-advice-info (function)
1864 `(copy-tree (get ,function 'ad-advice-info))) 1840 `(copy-tree (get ,function 'ad-advice-info)))
@@ -1866,7 +1842,7 @@ On each iteration VAR will be bound to the name of an advised function
1866(defmacro ad-is-advised (function) 1842(defmacro ad-is-advised (function)
1867 "Return non-nil if FUNCTION has any advice info associated with it. 1843 "Return non-nil if FUNCTION has any advice info associated with it.
1868This does not mean that the advice is also active." 1844This does not mean that the advice is also active."
1869 (list 'ad-get-advice-info-macro function)) 1845 `(ad-get-advice-info-macro ,function))
1870 1846
1871(defun ad-initialize-advice-info (function) 1847(defun ad-initialize-advice-info (function)
1872 "Initialize the advice info for FUNCTION. 1848 "Initialize the advice info for FUNCTION.
@@ -1949,7 +1925,7 @@ Redefining advices affect the construction of an advised definition."
1949(defun ad-has-any-advice (function) 1925(defun ad-has-any-advice (function)
1950 "True if the advice info of FUNCTION defines at least one advice." 1926 "True if the advice info of FUNCTION defines at least one advice."
1951 (and (ad-is-advised function) 1927 (and (ad-is-advised function)
1952 (cl-dolist (class ad-advice-classes nil) 1928 (cl-dolist (class ad-advice-classes)
1953 (if (ad-get-advice-info-field function class) 1929 (if (ad-get-advice-info-field function class)
1954 (cl-return t))))) 1930 (cl-return t)))))
1955 1931
@@ -1965,18 +1941,10 @@ Redefining advices affect the construction of an advised definition."
1965;; @@ Dealing with automatic advice activation via `fset/defalias': 1941;; @@ Dealing with automatic advice activation via `fset/defalias':
1966;; ================================================================ 1942;; ================================================================
1967 1943
1968;; Since Emacs 19.26 the built-in versions of `fset' and `defalias' 1944;; Automatic activation happens when a function gets defined via `defalias',
1969;; take care of automatic advice activation, hence, we don't have to 1945;; which calls the `defalias-fset-function' (which we set to
1970;; hack it anymore by advising `fset/defun/defmacro/byte-code/etc'. 1946;; `ad--defalias-fset') instead of `fset', if non-nil.
1971 1947
1972;; The functionality of the new `fset' is as follows:
1973;;
1974;; fset(sym,newdef)
1975;; assign NEWDEF to SYM
1976;; if (get SYM 'ad-advice-info)
1977;; ad-activate-internal(SYM, nil)
1978;; return (symbol-function SYM)
1979;;
1980;; Whether advised definitions created by automatic activations will be 1948;; Whether advised definitions created by automatic activations will be
1981;; compiled depends on the value of `ad-default-compilation-action'. 1949;; compiled depends on the value of `ad-default-compilation-action'.
1982 1950
@@ -1988,13 +1956,17 @@ Redefining advices affect the construction of an advised definition."
1988;; to `ad-activate' by using `ad-with-auto-activation-disabled' where 1956;; to `ad-activate' by using `ad-with-auto-activation-disabled' where
1989;; appropriate, especially in a safe version of `fset'. 1957;; appropriate, especially in a safe version of `fset'.
1990 1958
1959(defun ad--defalias-fset (fsetfun function definition)
1960 (funcall (or fsetfun #'fset) function definition)
1961 (ad-activate-internal function nil))
1962
1991;; For now define `ad-activate-internal' to the dummy definition: 1963;; For now define `ad-activate-internal' to the dummy definition:
1992(defun ad-activate-internal (function &optional compile) 1964(defun ad-activate-internal (_function &optional _compile)
1993 "Automatic advice activation is disabled. `ad-start-advice' enables it." 1965 "Automatic advice activation is disabled. `ad-start-advice' enables it."
1994 nil) 1966 nil)
1995 1967
1996;; This is just a copy of the above: 1968;; This is just a copy of the above:
1997(defun ad-activate-internal-off (function &optional compile) 1969(defun ad-activate-internal-off (_function &optional _compile)
1998 "Automatic advice activation is disabled. `ad-start-advice' enables it." 1970 "Automatic advice activation is disabled. `ad-start-advice' enables it."
1999 nil) 1971 nil)
2000 1972
@@ -2005,12 +1977,6 @@ Redefining advices affect the construction of an advised definition."
2005 `(let ((ad-activate-on-top-level nil)) 1977 `(let ((ad-activate-on-top-level nil))
2006 ,@body)) 1978 ,@body))
2007 1979
2008(defun ad-safe-fset (symbol definition)
2009 "A safe `fset' which will never call `ad-activate-internal' recursively."
2010 (ad-with-auto-activation-disabled
2011 (ad-real-fset symbol definition)))
2012
2013
2014;; @@ Access functions for original definitions: 1980;; @@ Access functions for original definitions:
2015;; ============================================ 1981;; ============================================
2016;; The advice-info of an advised function contains its `origname' which is 1982;; The advice-info of an advised function contains its `origname' which is
@@ -2030,8 +1996,7 @@ Redefining advices affect the construction of an advised definition."
2030 (symbol-function origname)))) 1996 (symbol-function origname))))
2031 1997
2032(defmacro ad-set-orig-definition (function definition) 1998(defmacro ad-set-orig-definition (function definition)
2033 `(ad-safe-fset 1999 `(fset (ad-get-advice-info-field ,function 'origname) ,definition))
2034 (ad-get-advice-info-field ,function 'origname) ,definition))
2035 2000
2036(defmacro ad-clear-orig-definition (function) 2001(defmacro ad-clear-orig-definition (function)
2037 `(fmakunbound (ad-get-advice-info-field ,function 'origname))) 2002 `(fmakunbound (ad-get-advice-info-field ,function 'origname)))
@@ -2052,7 +2017,7 @@ function at point for which PREDICATE returns non-nil)."
2052 (error "ad-read-advised-function: There are no advised functions")) 2017 (error "ad-read-advised-function: There are no advised functions"))
2053 (setq default 2018 (setq default
2054 (or default 2019 (or default
2055 ;; Prefer func name at point, if it's in ad-advised-functions etc. 2020 ;; Prefer func name at point, if it's an advised function etc.
2056 (let ((function (progn 2021 (let ((function (progn
2057 (require 'help) 2022 (require 'help)
2058 (function-called-at-point)))) 2023 (function-called-at-point))))
@@ -2061,24 +2026,20 @@ function at point for which PREDICATE returns non-nil)."
2061 (or (null predicate) 2026 (or (null predicate)
2062 (funcall predicate function)) 2027 (funcall predicate function))
2063 function)) 2028 function))
2064 (ad-do-advised-functions (function) 2029 (cl-block nil
2065 (if (or (null predicate) 2030 (ad-do-advised-functions (function)
2066 (funcall predicate function)) 2031 (if (or (null predicate)
2067 (cl-return function))) 2032 (funcall predicate function))
2033 (cl-return function))))
2068 (error "ad-read-advised-function: %s" 2034 (error "ad-read-advised-function: %s"
2069 "There are no qualifying advised functions"))) 2035 "There are no qualifying advised functions")))
2070 (let* ((ad-pReDiCaTe predicate) 2036 (let* ((function
2071 (function
2072 (completing-read 2037 (completing-read
2073 (format "%s (default %s): " (or prompt "Function") default) 2038 (format "%s (default %s): " (or prompt "Function") default)
2074 ad-advised-functions 2039 ad-advised-functions
2075 (if predicate 2040 (if predicate
2076 (function 2041 (lambda (function)
2077 (lambda (function) 2042 (funcall predicate (intern (car function)))))
2078 ;; Oops, no closures - the joys of dynamic scoping:
2079 ;; `predicate' clashed with the `predicate' argument
2080 ;; of `completing-read'.....
2081 (funcall ad-pReDiCaTe (intern (car function))))))
2082 t))) 2043 t)))
2083 (if (equal function "") 2044 (if (equal function "")
2084 (if (ad-is-advised default) 2045 (if (ad-is-advised default)
@@ -2331,12 +2292,6 @@ See Info node `(elisp)Computed Advice' for detailed documentation."
2331 "Take a macro function DEFINITION and make a lambda out of it." 2292 "Take a macro function DEFINITION and make a lambda out of it."
2332 `(cdr ,definition)) 2293 `(cdr ,definition))
2333 2294
2334(defun ad-special-form-p (definition)
2335 "Non-nil if and only if DEFINITION is a special form."
2336 (if (and (symbolp definition) (fboundp definition))
2337 (setq definition (indirect-function definition)))
2338 (and (subrp definition) (eq (cdr (subr-arity definition)) 'unevalled)))
2339
2340(defmacro ad-subr-p (definition) 2295(defmacro ad-subr-p (definition)
2341 ;;"non-nil if DEFINITION is a subr." 2296 ;;"non-nil if DEFINITION is a subr."
2342 (list 'subrp definition)) 2297 (list 'subrp definition))
@@ -2376,10 +2331,8 @@ See Info node `(elisp)Computed Advice' for detailed documentation."
2376 (cdr definition)) 2331 (cdr definition))
2377 (t nil))) 2332 (t nil)))
2378 2333
2379(defun ad-arglist (definition &optional name) 2334(defun ad-arglist (definition)
2380 "Return the argument list of DEFINITION. 2335 "Return the argument list of DEFINITION."
2381If DEFINITION could be from a subr then its NAME should be
2382supplied to make subr arglist lookup more efficient."
2383 (require 'help-fns) 2336 (require 'help-fns)
2384 (help-function-arglist 2337 (help-function-arglist
2385 (if (or (ad-macro-p definition) (ad-advice-p definition)) 2338 (if (or (ad-macro-p definition) (ad-advice-p definition))
@@ -2391,7 +2344,7 @@ supplied to make subr arglist lookup more efficient."
2391 "Return the unexpanded docstring of DEFINITION." 2344 "Return the unexpanded docstring of DEFINITION."
2392 (let ((docstring 2345 (let ((docstring
2393 (if (ad-compiled-p definition) 2346 (if (ad-compiled-p definition)
2394 (ad-real-documentation definition t) 2347 (documentation definition t)
2395 (car (cdr (cdr (ad-lambda-expression definition))))))) 2348 (car (cdr (cdr (ad-lambda-expression definition)))))))
2396 (if (or (stringp docstring) 2349 (if (or (stringp docstring)
2397 (natnump docstring)) 2350 (natnump docstring))
@@ -2414,13 +2367,15 @@ Like `interactive-form', but also works on pieces of advice."
2414 (if (ad-interactive-form definition) 1 0)) 2367 (if (ad-interactive-form definition) 1 0))
2415 (cdr (cdr (ad-lambda-expression definition))))))) 2368 (cdr (cdr (ad-lambda-expression definition)))))))
2416 2369
2417(defun ad-make-advised-definition-docstring (function) 2370(defun ad-make-advised-definition-docstring (_function)
2418 "Make an identifying docstring for the advised definition of FUNCTION. 2371 "Make an identifying docstring for the advised definition of FUNCTION.
2419Put function name into the documentation string so we can infer 2372Put function name into the documentation string so we can infer
2420the name of the advised function from the docstring. This is needed 2373the name of the advised function from the docstring. This is needed
2421to generate a proper advised docstring even if we are just given a 2374to generate a proper advised docstring even if we are just given a
2422definition (see the code for `documentation')." 2375definition (see the code for `documentation')."
2423 (propertize "Advice doc string" 'ad-advice-info function)) 2376 (eval-when-compile
2377 (propertize "Advice doc string" 'dynamic-docstring-function
2378 #'ad--make-advised-docstring)))
2424 2379
2425(defun ad-advised-definition-p (definition) 2380(defun ad-advised-definition-p (definition)
2426 "Return non-nil if DEFINITION was generated from advice information." 2381 "Return non-nil if DEFINITION was generated from advice information."
@@ -2429,14 +2384,14 @@ definition (see the code for `documentation')."
2429 (ad-compiled-p definition)) 2384 (ad-compiled-p definition))
2430 (let ((docstring (ad-docstring definition))) 2385 (let ((docstring (ad-docstring definition)))
2431 (and (stringp docstring) 2386 (and (stringp docstring)
2432 (get-text-property 0 'ad-advice-info docstring))))) 2387 (get-text-property 0 'dynamic-docstring-function docstring)))))
2433 2388
2434(defun ad-definition-type (definition) 2389(defun ad-definition-type (definition)
2435 "Return symbol that describes the type of DEFINITION." 2390 "Return symbol that describes the type of DEFINITION."
2436 (cond 2391 (cond
2437 ((ad-macro-p definition) 'macro) 2392 ((ad-macro-p definition) 'macro)
2438 ((ad-subr-p definition) 2393 ((ad-subr-p definition)
2439 (if (ad-special-form-p definition) 2394 (if (special-form-p definition)
2440 'special-form 2395 'special-form
2441 'subr)) 2396 'subr))
2442 ((or (ad-lambda-p definition) 2397 ((or (ad-lambda-p definition)
@@ -2473,6 +2428,7 @@ For that it has to be fbound with a non-autoload definition."
2473 (ad-macro-p (symbol-function function))) 2428 (ad-macro-p (symbol-function function)))
2474 (not (ad-compiled-p (symbol-function function))))) 2429 (not (ad-compiled-p (symbol-function function)))))
2475 2430
2431(defvar warning-suppress-types) ;From warnings.el.
2476(defun ad-compile-function (function) 2432(defun ad-compile-function (function)
2477 "Byte-compiles FUNCTION (or macro) if it is not yet compiled." 2433 "Byte-compiles FUNCTION (or macro) if it is not yet compiled."
2478 (interactive "aByte-compile function: ") 2434 (interactive "aByte-compile function: ")
@@ -2603,24 +2559,20 @@ The assignment starts at position INDEX."
2603 (let ((values-index 0) 2559 (let ((values-index 0)
2604 argument-access set-forms) 2560 argument-access set-forms)
2605 (while (setq argument-access (ad-access-argument arglist index)) 2561 (while (setq argument-access (ad-access-argument arglist index))
2606 (if (symbolp argument-access) 2562 (push (if (symbolp argument-access)
2607 (setq set-forms 2563 (ad-set-argument
2608 (cons (ad-set-argument 2564 arglist index
2609 arglist index 2565 (ad-element-access values-index 'ad-vAlUeS))
2610 (ad-element-access values-index 'ad-vAlUeS)) 2566 (setq arglist nil) ;; Terminate loop.
2611 set-forms)) 2567 (if (= (car argument-access) 0)
2612 (setq set-forms 2568 `(setq
2613 (cons (if (= (car argument-access) 0) 2569 ,(car (cdr argument-access))
2614 (list 'setq 2570 ,(ad-list-access values-index 'ad-vAlUeS))
2615 (car (cdr argument-access)) 2571 `(setcdr
2616 (ad-list-access values-index 'ad-vAlUeS)) 2572 ,(ad-list-access (1- (car argument-access))
2617 (list 'setcdr 2573 (car (cdr argument-access)))
2618 (ad-list-access (1- (car argument-access)) 2574 ,(ad-list-access values-index 'ad-vAlUeS))))
2619 (car (cdr argument-access))) 2575 set-forms)
2620 (ad-list-access values-index 'ad-vAlUeS)))
2621 set-forms))
2622 ;; terminate loop
2623 (setq arglist nil))
2624 (setq index (1+ index)) 2576 (setq index (1+ index))
2625 (setq values-index (1+ values-index))) 2577 (setq values-index (1+ values-index)))
2626 (if (null set-forms) 2578 (if (null set-forms)
@@ -2629,8 +2581,8 @@ The assignment starts at position INDEX."
2629 (if (= (length set-forms) 1) 2581 (if (= (length set-forms) 1)
2630 ;; For exactly one set-form we can use values-form directly,... 2582 ;; For exactly one set-form we can use values-form directly,...
2631 (ad-substitute-tree 2583 (ad-substitute-tree
2632 (function (lambda (form) (eq form 'ad-vAlUeS))) 2584 (lambda (form) (eq form 'ad-vAlUeS))
2633 (function (lambda (form) values-form)) 2585 (lambda (_form) values-form)
2634 (car set-forms)) 2586 (car set-forms))
2635 ;; ...if we have more we have to bind it to a variable: 2587 ;; ...if we have more we have to bind it to a variable:
2636 `(let ((ad-vAlUeS ,values-form)) 2588 `(let ((ad-vAlUeS ,values-form))
@@ -2700,11 +2652,10 @@ Example: `(ad-map-arglists '(a &rest args) '(w x y z))' will return
2700 (cond (need-apply 2652 (cond (need-apply
2701 ;; `apply' can take care of that directly: 2653 ;; `apply' can take care of that directly:
2702 (append source-reqopt-args (list source-rest-arg))) 2654 (append source-reqopt-args (list source-rest-arg)))
2703 (t (mapcar (function 2655 (t (mapcar (lambda (_arg)
2704 (lambda (arg) 2656 (setq target-arg-index (1+ target-arg-index))
2705 (setq target-arg-index (1+ target-arg-index)) 2657 (ad-get-argument
2706 (ad-get-argument 2658 source-arglist target-arg-index))
2707 source-arglist target-arg-index)))
2708 (append target-reqopt-args 2659 (append target-reqopt-args
2709 (and target-rest-arg 2660 (and target-rest-arg
2710 ;; If we have a rest arg gobble up 2661 ;; If we have a rest arg gobble up
@@ -2735,11 +2686,6 @@ Example: `(ad-map-arglists '(a &rest args) '(w x y z))' will return
2735 (let ((advice-docstring (ad-docstring (ad-advice-definition advice)))) 2686 (let ((advice-docstring (ad-docstring (ad-advice-definition advice))))
2736 (cond ((eq style 'plain) 2687 (cond ((eq style 'plain)
2737 advice-docstring) 2688 advice-docstring)
2738 ((eq style 'freeze)
2739 (format "Permanent %s-advice `%s':%s%s"
2740 class (ad-advice-name advice)
2741 (if advice-docstring "\n" "")
2742 (or advice-docstring "")))
2743 (t (if advice-docstring 2689 (t (if advice-docstring
2744 (format "%s-advice `%s':\n%s" 2690 (format "%s-advice `%s':\n%s"
2745 (capitalize (symbol-name class)) 2691 (capitalize (symbol-name class))
@@ -2752,20 +2698,24 @@ Example: `(ad-map-arglists '(a &rest args) '(w x y z))' will return
2752(require 'help-fns) ;For help-split-fundoc and help-add-fundoc-usage. 2698(require 'help-fns) ;For help-split-fundoc and help-add-fundoc-usage.
2753 2699
2754(defun ad-make-advised-docstring (function &optional style) 2700(defun ad-make-advised-docstring (function &optional style)
2701 (let* ((origdef (ad-real-orig-definition function))
2702 (origdoc
2703 ;; Retrieve raw doc, key substitution will be taken care of later:
2704 (documentation origdef t)))
2705 (ad--make-advised-docstring origdoc function style)))
2706
2707(defun ad--make-advised-docstring (origdoc function &optional style)
2755 "Construct a documentation string for the advised FUNCTION. 2708 "Construct a documentation string for the advised FUNCTION.
2756It concatenates the original documentation with the documentation 2709It concatenates the original documentation with the documentation
2757strings of the individual pieces of advice which will be formatted 2710strings of the individual pieces of advice which will be formatted
2758according to STYLE. STYLE can be `plain' or `freeze', everything else 2711according to STYLE. STYLE can be `plain', everything else
2759will be interpreted as `default'. The order of the advice documentation 2712will be interpreted as `default'. The order of the advice documentation
2760strings corresponds to before/around/after and the individual ordering 2713strings corresponds to before/around/after and the individual ordering
2761in any of these classes." 2714in any of these classes."
2762 (let* ((origdef (ad-real-orig-definition function)) 2715 (let* ((origdef (ad-real-orig-definition function))
2763 (origtype (symbol-name (ad-definition-type origdef))) 2716 (origtype (symbol-name (ad-definition-type origdef)))
2764 (origdoc
2765 ;; Retrieve raw doc, key substitution will be taken care of later:
2766 (ad-real-documentation origdef t))
2767 (usage (help-split-fundoc origdoc function)) 2717 (usage (help-split-fundoc origdoc function))
2768 paragraphs advice-docstring ad-usage) 2718 paragraphs advice-docstring)
2769 (setq usage (if (null usage) t (setq origdoc (cdr usage)) (car usage))) 2719 (setq usage (if (null usage) t (setq origdoc (cdr usage)) (car usage)))
2770 (if origdoc (setq paragraphs (list origdoc))) 2720 (if origdoc (setq paragraphs (list origdoc)))
2771 (unless (eq style 'plain) 2721 (unless (eq style 'plain)
@@ -2780,13 +2730,13 @@ in any of these classes."
2780 (propertize 2730 (propertize
2781 ;; separate paragraphs with blank lines: 2731 ;; separate paragraphs with blank lines:
2782 (mapconcat 'identity (nreverse paragraphs) "\n\n") 2732 (mapconcat 'identity (nreverse paragraphs) "\n\n")
2783 'ad-advice-info function))) 2733 ;; FIXME: what is this for?
2734 'dynamic-docstring-function
2735 #'ad--make-advised-docstring)))
2784 (help-add-fundoc-usage origdoc usage))) 2736 (help-add-fundoc-usage origdoc usage)))
2785 2737
2786(defun ad-make-plain-docstring (function) 2738(defun ad-make-plain-docstring (function)
2787 (ad-make-advised-docstring function 'plain)) 2739 (ad-make-advised-docstring function 'plain))
2788(defun ad-make-freeze-docstring (function)
2789 (ad-make-advised-docstring function 'freeze))
2790 2740
2791;; @@@ Accessing overriding arglists and interactive forms: 2741;; @@@ Accessing overriding arglists and interactive forms:
2792;; ======================================================== 2742;; ========================================================
@@ -2823,10 +2773,10 @@ in any of these classes."
2823 (origname (ad-get-advice-info-field function 'origname)) 2773 (origname (ad-get-advice-info-field function 'origname))
2824 (orig-interactive-p (commandp origdef)) 2774 (orig-interactive-p (commandp origdef))
2825 (orig-subr-p (ad-subr-p origdef)) 2775 (orig-subr-p (ad-subr-p origdef))
2826 (orig-special-form-p (ad-special-form-p origdef)) 2776 (orig-special-form-p (special-form-p origdef))
2827 (orig-macro-p (ad-macro-p origdef)) 2777 (orig-macro-p (ad-macro-p origdef))
2828 ;; Construct the individual pieces that we need for assembly: 2778 ;; Construct the individual pieces that we need for assembly:
2829 (orig-arglist (ad-arglist origdef function)) 2779 (orig-arglist (ad-arglist origdef))
2830 (advised-arglist (or (ad-advised-arglist function) 2780 (advised-arglist (or (ad-advised-arglist function)
2831 orig-arglist)) 2781 orig-arglist))
2832 (advised-interactive-form (ad-advised-interactive-form function)) 2782 (advised-interactive-form (ad-advised-interactive-form function))
@@ -2921,8 +2871,8 @@ should be modified. The assembled function will be returned."
2921 (setq around-form-protected t)) 2871 (setq around-form-protected t))
2922 (setq around-form 2872 (setq around-form
2923 (ad-substitute-tree 2873 (ad-substitute-tree
2924 (function (lambda (form) (eq form 'ad-do-it))) 2874 (lambda (form) (eq form 'ad-do-it))
2925 (function (lambda (form) around-form)) 2875 (lambda (_form) around-form)
2926 (macroexp-progn (ad-body-forms (ad-advice-definition advice)))))) 2876 (macroexp-progn (ad-body-forms (ad-advice-definition advice))))))
2927 2877
2928 (setq after-forms 2878 (setq after-forms
@@ -3057,10 +3007,10 @@ advised definition from scratch."
3057 (mapcar (function (lambda (advice) (ad-advice-name advice))) 3007 (mapcar (function (lambda (advice) (ad-advice-name advice)))
3058 (ad-get-enabled-advices function 'after)) 3008 (ad-get-enabled-advices function 'after))
3059 (ad-definition-type original-definition) 3009 (ad-definition-type original-definition)
3060 (if (equal (ad-arglist original-definition function) 3010 (if (equal (ad-arglist original-definition)
3061 (ad-arglist cached-definition)) 3011 (ad-arglist cached-definition))
3062 t 3012 t
3063 (ad-arglist original-definition function)) 3013 (ad-arglist original-definition))
3064 (if (eq (ad-definition-type original-definition) 'function) 3014 (if (eq (ad-definition-type original-definition) 'function)
3065 (equal (interactive-form original-definition) 3015 (equal (interactive-form original-definition)
3066 (interactive-form cached-definition)))))) 3016 (interactive-form cached-definition))))))
@@ -3105,7 +3055,7 @@ advised definition from scratch."
3105 (and (eq (nth 3 cache-id) (ad-definition-type original-definition)) 3055 (and (eq (nth 3 cache-id) (ad-definition-type original-definition))
3106 (setq code 'arglist-mismatch) 3056 (setq code 'arglist-mismatch)
3107 (equal (if (eq (nth 4 cache-id) t) 3057 (equal (if (eq (nth 4 cache-id) t)
3108 (ad-arglist original-definition function) 3058 (ad-arglist original-definition)
3109 (nth 4 cache-id) ) 3059 (nth 4 cache-id) )
3110 (ad-arglist cached-definition)) 3060 (ad-arglist cached-definition))
3111 (setq code 'interactive-form-mismatch) 3061 (setq code 'interactive-form-mismatch)
@@ -3164,94 +3114,10 @@ advised definition from scratch."
3164 (ad-set-advice-info function old-advice-info) 3114 (ad-set-advice-info function old-advice-info)
3165 ;; Don't `fset' function to nil if it was previously unbound: 3115 ;; Don't `fset' function to nil if it was previously unbound:
3166 (if function-defined-p 3116 (if function-defined-p
3167 (ad-safe-fset function old-definition) 3117 (fset function old-definition)
3168 (fmakunbound function))))) 3118 (fmakunbound function)))))
3169 3119
3170 3120
3171;; @@ Freezing:
3172;; ============
3173;; Freezing transforms a `defadvice' into a redefining `defun/defmacro'
3174;; for the advised function without keeping any advice information. This
3175;; feature was jwz's idea: It generates a dumpable function definition
3176;; whose documentation can be written to the DOC file, and the generated
3177;; code does not need any Advice runtime support. Of course, frozen advices
3178;; cannot be undone.
3179
3180;; Freezing only considers the advice of the particular `defadvice', other
3181;; already existing advices for the same function will be ignored. To ensure
3182;; proper interaction when an already advised function gets redefined with
3183;; a frozen advice, frozen advices always use the actual original definition
3184;; of the function, i.e., they are always at the core of the onion. E.g., if
3185;; an already advised function gets redefined with a frozen advice and then
3186;; unadvised, the frozen advice remains as the new definition of the function.
3187
3188;; While multiple freeze advices for a single function or freeze-advising
3189;; of an already advised function are possible, they are better avoided,
3190;; because definition/compile/load ordering is relevant, and it becomes
3191;; incomprehensible pretty quickly.
3192
3193(defun ad-make-freeze-definition (function advice class position)
3194 (if (not (ad-has-proper-definition function))
3195 (error
3196 "ad-make-freeze-definition: `%s' is not yet defined"
3197 function))
3198 (let* ((name (ad-advice-name advice))
3199 ;; With a unique origname we can have multiple freeze advices
3200 ;; for the same function, each overloading the previous one:
3201 (unique-origname
3202 (intern (format "%s-%s-%s" (ad-make-origname function) class name)))
3203 (orig-definition
3204 ;; If FUNCTION is already advised, we'll use its current origdef
3205 ;; as the original definition of the frozen advice:
3206 (or (ad-get-orig-definition function)
3207 (symbol-function function)))
3208 (old-advice-info
3209 (if (ad-is-advised function)
3210 (ad-copy-advice-info function)))
3211 (real-docstring-fn
3212 (symbol-function 'ad-make-advised-definition-docstring))
3213 (real-origname-fn
3214 (symbol-function 'ad-make-origname))
3215 (frozen-definition
3216 (unwind-protect
3217 (progn
3218 ;; Make sure we construct a proper docstring:
3219 (ad-safe-fset 'ad-make-advised-definition-docstring
3220 'ad-make-freeze-docstring)
3221 ;; Make sure `unique-origname' is used as the origname:
3222 (ad-safe-fset 'ad-make-origname (lambda (x) unique-origname))
3223 ;; No we reset all current advice information to nil and
3224 ;; generate an advised definition that's solely determined
3225 ;; by ADVICE and the current origdef of FUNCTION:
3226 (ad-set-advice-info function nil)
3227 (ad-add-advice function advice class position)
3228 ;; The following will provide proper real docstrings as
3229 ;; well as a definition that will make the compiler happy:
3230 (ad-set-orig-definition function orig-definition)
3231 (ad-make-advised-definition function))
3232 ;; Restore the old advice state:
3233 (ad-set-advice-info function old-advice-info)
3234 ;; Restore functions:
3235 (ad-safe-fset
3236 'ad-make-advised-definition-docstring real-docstring-fn)
3237 (ad-safe-fset 'ad-make-origname real-origname-fn))))
3238 (if frozen-definition
3239 (let* ((macro-p (ad-macro-p frozen-definition))
3240 (body (cdr (if macro-p
3241 (ad-lambdafy frozen-definition)
3242 frozen-definition))))
3243 `(progn
3244 (if (not (fboundp ',unique-origname))
3245 (fset ',unique-origname
3246 ;; avoid infinite recursion in case the function
3247 ;; we want to freeze is already advised:
3248 (or (ad-get-orig-definition ',function)
3249 (symbol-function ',function))))
3250 (,(if macro-p 'defmacro 'defun)
3251 ,function
3252 ,@body))))))
3253
3254
3255;; @@ Activation and definition handling: 3121;; @@ Activation and definition handling:
3256;; ====================================== 3122;; ======================================
3257 3123
@@ -3282,7 +3148,7 @@ The current definition and its cache-id will be put into the cache."
3282 (let ((verified-cached-definition 3148 (let ((verified-cached-definition
3283 (if (ad-verify-cache-id function) 3149 (if (ad-verify-cache-id function)
3284 (ad-get-cache-definition function)))) 3150 (ad-get-cache-definition function))))
3285 (ad-safe-fset function 3151 (fset function
3286 (or verified-cached-definition 3152 (or verified-cached-definition
3287 (ad-make-advised-definition function))) 3153 (ad-make-advised-definition function)))
3288 (if (ad-should-compile function compile) 3154 (if (ad-should-compile function compile)
@@ -3324,7 +3190,7 @@ the value of `ad-redefinition-action' and de/activate again."
3324 (error "ad-handle-definition (see its doc): `%s' %s" 3190 (error "ad-handle-definition (see its doc): `%s' %s"
3325 function "invalidly redefined") 3191 function "invalidly redefined")
3326 (if (eq ad-redefinition-action 'discard) 3192 (if (eq ad-redefinition-action 'discard)
3327 (ad-safe-fset function original-definition) 3193 (fset function original-definition)
3328 (ad-set-orig-definition function current-definition) 3194 (ad-set-orig-definition function current-definition)
3329 (if (eq ad-redefinition-action 'warn) 3195 (if (eq ad-redefinition-action 'warn)
3330 (message "ad-handle-definition: `%s' got redefined" 3196 (message "ad-handle-definition: `%s' got redefined"
@@ -3399,7 +3265,7 @@ a call to `ad-activate'."
3399 (if (not (ad-get-orig-definition function)) 3265 (if (not (ad-get-orig-definition function))
3400 (error "ad-deactivate: `%s' has no original definition" 3266 (error "ad-deactivate: `%s' has no original definition"
3401 function) 3267 function)
3402 (ad-safe-fset function (ad-get-orig-definition function)) 3268 (fset function (ad-get-orig-definition function))
3403 (ad-set-advice-info-field function 'active nil) 3269 (ad-set-advice-info-field function 'active nil)
3404 (eval (ad-make-hook-form function 'deactivation)) 3270 (eval (ad-make-hook-form function 'deactivation))
3405 function))))) 3271 function)))))
@@ -3437,7 +3303,7 @@ Use in emergencies."
3437 (completing-read "Recover advised function: " obarray nil t)))) 3303 (completing-read "Recover advised function: " obarray nil t))))
3438 (cond ((ad-is-advised function) 3304 (cond ((ad-is-advised function)
3439 (cond ((ad-get-orig-definition function) 3305 (cond ((ad-get-orig-definition function)
3440 (ad-safe-fset function (ad-get-orig-definition function)) 3306 (fset function (ad-get-orig-definition function))
3441 (ad-clear-orig-definition function))) 3307 (ad-clear-orig-definition function)))
3442 (ad-set-advice-info function nil) 3308 (ad-set-advice-info function nil)
3443 (ad-pop-advised-function function)))) 3309 (ad-pop-advised-function function))))
@@ -3518,7 +3384,7 @@ deactivation, which might run hooks and get into other trouble."
3518;; Completion alist of valid `defadvice' flags 3384;; Completion alist of valid `defadvice' flags
3519(defvar ad-defadvice-flags 3385(defvar ad-defadvice-flags
3520 '(("protect") ("disable") ("activate") 3386 '(("protect") ("disable") ("activate")
3521 ("compile") ("preactivate") ("freeze"))) 3387 ("compile") ("preactivate")))
3522 3388
3523;;;###autoload 3389;;;###autoload
3524(defmacro defadvice (function args &rest body) 3390(defmacro defadvice (function args &rest body)
@@ -3537,7 +3403,7 @@ POSITION ::= `first' | `last' | NUMBER. Optional, defaults to `first',
3537ARGLIST ::= An optional argument list to be used for the advised function 3403ARGLIST ::= An optional argument list to be used for the advised function
3538 instead of the argument list of the original. The first one found in 3404 instead of the argument list of the original. The first one found in
3539 before/around/after-advices will be used. 3405 before/around/after-advices will be used.
3540FLAG ::= `protect'|`disable'|`activate'|`compile'|`preactivate'|`freeze'. 3406FLAG ::= `protect'|`disable'|`activate'|`compile'|`preactivate'.
3541 All flags can be specified with unambiguous initial substrings. 3407 All flags can be specified with unambiguous initial substrings.
3542DOCSTRING ::= Optional documentation for this piece of advice. 3408DOCSTRING ::= Optional documentation for this piece of advice.
3543INTERACTIVE-FORM ::= Optional interactive form to be used for the advised 3409INTERACTIVE-FORM ::= Optional interactive form to be used for the advised
@@ -3563,13 +3429,6 @@ time. This generates a compiled advised definition according to the current
3563advice state that will be used during activation if appropriate. Only use 3429advice state that will be used during activation if appropriate. Only use
3564this if the `defadvice' gets actually compiled. 3430this if the `defadvice' gets actually compiled.
3565 3431
3566`freeze': Expands the `defadvice' into a redefining `defun/defmacro' according
3567to this particular single advice. No other advice information will be saved.
3568Frozen advices cannot be undone, they behave like a hard redefinition of
3569the advised function. `freeze' implies `activate' and `preactivate'. The
3570documentation of the advised function can be dumped onto the `DOC' file
3571during preloading.
3572
3573See Info node `(elisp)Advising Functions' for comprehensive documentation. 3432See Info node `(elisp)Advising Functions' for comprehensive documentation.
3574usage: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...) 3433usage: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...)
3575 [DOCSTRING] [INTERACTIVE-FORM] 3434 [DOCSTRING] [INTERACTIVE-FORM]
@@ -3619,29 +3478,24 @@ usage: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...)
3619 (ad-preactivate-advice 3478 (ad-preactivate-advice
3620 function advice class position)))) 3479 function advice class position))))
3621 ;; Now for the things to be done at evaluation time: 3480 ;; Now for the things to be done at evaluation time:
3622 (if (memq 'freeze flags) 3481 `(progn
3623 ;; jwz's idea: Freeze the advised definition into a dumpable 3482 (ad-add-advice ',function ',advice ',class ',position)
3624 ;; defun/defmacro whose docs can be written to the DOC file: 3483 ,@(if preactivation
3625 (ad-make-freeze-definition function advice class position) 3484 `((ad-set-cache
3626 ;; the normal case: 3485 ',function
3627 `(progn 3486 ;; the function will get compiled:
3628 (ad-add-advice ',function ',advice ',class ',position) 3487 ,(cond ((ad-macro-p (car preactivation))
3629 ,@(if preactivation 3488 `(ad-macrofy
3630 `((ad-set-cache 3489 (function
3631 ',function 3490 ,(ad-lambdafy
3632 ;; the function will get compiled: 3491 (car preactivation)))))
3633 ,(cond ((ad-macro-p (car preactivation)) 3492 (t `(function
3634 `(ad-macrofy 3493 ,(car preactivation))))
3635 (function 3494 ',(car (cdr preactivation)))))
3636 ,(ad-lambdafy 3495 ,@(if (memq 'activate flags)
3637 (car preactivation))))) 3496 `((ad-activate ',function
3638 (t `(function 3497 ,(if (memq 'compile flags) t))))
3639 ,(car preactivation)))) 3498 ',function)))
3640 ',(car (cdr preactivation)))))
3641 ,@(if (memq 'activate flags)
3642 `((ad-activate ',function
3643 ,(if (memq 'compile flags) t))))
3644 ',function))))
3645 3499
3646 3500
3647;; @@ Tools: 3501;; @@ Tools:
@@ -3669,28 +3523,22 @@ undone on exit of this macro."
3669 ;; Make forms to redefine functions to their 3523 ;; Make forms to redefine functions to their
3670 ;; original definitions if they are advised: 3524 ;; original definitions if they are advised:
3671 (setq index -1) 3525 (setq index -1)
3672 (mapcar 3526 (mapcar (lambda (function)
3673 (function 3527 (setq index (1+ index))
3674 (lambda (function) 3528 `(fset ',function
3675 (setq index (1+ index)) 3529 (or (ad-get-orig-definition ',function)
3676 `(ad-safe-fset 3530 ,(car (nth index current-bindings)))))
3677 ',function 3531 functions))
3678 (or (ad-get-orig-definition ',function)
3679 ,(car (nth index current-bindings))))))
3680 functions))
3681 ,@body) 3532 ,@body)
3682 ,@(progn 3533 ,@(progn
3683 ;; Make forms to back-define functions to the definitions 3534 ;; Make forms to back-define functions to the definitions
3684 ;; they had outside this macro call: 3535 ;; they had outside this macro call:
3685 (setq index -1) 3536 (setq index -1)
3686 (mapcar 3537 (mapcar (lambda (function)
3687 (function 3538 (setq index (1+ index))
3688 (lambda (function) 3539 `(fset ',function
3689 (setq index (1+ index)) 3540 ,(car (nth index current-bindings))))
3690 `(ad-safe-fset 3541 functions))))))
3691 ',function
3692 ,(car (nth index current-bindings)))))
3693 functions))))))
3694 3542
3695 3543
3696;; @@ Starting, stopping and recovering from the advice package magic: 3544;; @@ Starting, stopping and recovering from the advice package magic:
@@ -3701,7 +3549,7 @@ undone on exit of this macro."
3701 (interactive) 3549 (interactive)
3702 ;; Advising `ad-activate-internal' means death!! 3550 ;; Advising `ad-activate-internal' means death!!
3703 (ad-set-advice-info 'ad-activate-internal nil) 3551 (ad-set-advice-info 'ad-activate-internal nil)
3704 (ad-safe-fset 'ad-activate-internal 'ad-activate)) 3552 (fset 'ad-activate-internal 'ad-activate))
3705 3553
3706(defun ad-stop-advice () 3554(defun ad-stop-advice ()
3707 "Stop the automatic advice handling magic. 3555 "Stop the automatic advice handling magic.
@@ -3709,7 +3557,7 @@ You should only need this in case of Advice-related emergencies."
3709 (interactive) 3557 (interactive)
3710 ;; Advising `ad-activate-internal' means death!! 3558 ;; Advising `ad-activate-internal' means death!!
3711 (ad-set-advice-info 'ad-activate-internal nil) 3559 (ad-set-advice-info 'ad-activate-internal nil)
3712 (ad-safe-fset 'ad-activate-internal 'ad-activate-internal-off)) 3560 (fset 'ad-activate-internal 'ad-activate-internal-off))
3713 3561
3714(defun ad-recover-normality () 3562(defun ad-recover-normality ()
3715 "Undo all advice related redefinitions and unadvises everything. 3563 "Undo all advice related redefinitions and unadvises everything.
@@ -3717,9 +3565,11 @@ Use only in REAL emergencies."
3717 (interactive) 3565 (interactive)
3718 ;; Advising `ad-activate-internal' means death!! 3566 ;; Advising `ad-activate-internal' means death!!
3719 (ad-set-advice-info 'ad-activate-internal nil) 3567 (ad-set-advice-info 'ad-activate-internal nil)
3720 (ad-safe-fset 'ad-activate-internal 'ad-activate-internal-off) 3568 (fset 'ad-activate-internal 'ad-activate-internal-off)
3721 (ad-recover-all) 3569 (ad-recover-all)
3722 (setq ad-advised-functions nil)) 3570 (ad-do-advised-functions (function)
3571 (message "Oops! Left over advised function %S" function)
3572 (ad-pop-advised-function function)))
3723 3573
3724(ad-start-advice) 3574(ad-start-advice)
3725 3575
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e776df4ef37..a325e0f3e44 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -419,8 +419,8 @@ This list lives partly on the stack.")
419 419
420(defconst byte-compile-initial-macro-environment 420(defconst byte-compile-initial-macro-environment
421 '( 421 '(
422;; (byte-compiler-options . (lambda (&rest forms) 422 ;; (byte-compiler-options . (lambda (&rest forms)
423;; (apply 'byte-compiler-options-handler forms))) 423 ;; (apply 'byte-compiler-options-handler forms)))
424 (declare-function . byte-compile-macroexpand-declare-function) 424 (declare-function . byte-compile-macroexpand-declare-function)
425 (eval-when-compile . (lambda (&rest body) 425 (eval-when-compile . (lambda (&rest body)
426 (list 426 (list
@@ -429,8 +429,19 @@ This list lives partly on the stack.")
429 (byte-compile-top-level 429 (byte-compile-top-level
430 (byte-compile-preprocess (cons 'progn body))))))) 430 (byte-compile-preprocess (cons 'progn body)))))))
431 (eval-and-compile . (lambda (&rest body) 431 (eval-and-compile . (lambda (&rest body)
432 (byte-compile-eval-before-compile (cons 'progn body)) 432 ;; Byte compile before running it. Do it piece by
433 (cons 'progn body)))) 433 ;; piece, in case further expressions need earlier
434 ;; ones to be evaluated already, as is the case in
435 ;; eieio.el.
436 `(progn
437 ,@(mapcar (lambda (exp)
438 (let ((cexp
439 (byte-compile-top-level
440 (byte-compile-preprocess
441 exp))))
442 (eval cexp)
443 cexp))
444 body)))))
434 "The default macro-environment passed to macroexpand by the compiler. 445 "The default macro-environment passed to macroexpand by the compiler.
435Placing a macro here will cause a macro to have different semantics when 446Placing a macro here will cause a macro to have different semantics when
436expanded by the compiler as when expanded by the interpreter.") 447expanded by the compiler as when expanded by the interpreter.")
@@ -731,9 +742,11 @@ otherwise pop it")
731;; Also, this lets us notice references to free variables. 742;; Also, this lets us notice references to free variables.
732 743
733(defmacro byte-compile-push-bytecodes (&rest args) 744(defmacro byte-compile-push-bytecodes (&rest args)
734 "Push BYTE... onto BYTES, and increment PC by the number of bytes pushed. 745 "Push bytes onto BVAR, and increment CVAR by the number of bytes pushed.
735ARGS is of the form (BYTE... BYTES PC), where BYTES and PC are variable names. 746BVAR and CVAR are variables which are updated after evaluating
736BYTES and PC are updated after evaluating all the arguments." 747all the arguments.
748
749\(fn BYTE1 BYTE2 ... BYTEn BVAR CVAR)"
737 (let ((byte-exprs (butlast args 2)) 750 (let ((byte-exprs (butlast args 2))
738 (bytes-var (car (last args 2))) 751 (bytes-var (car (last args 2)))
739 (pc-var (car (last args)))) 752 (pc-var (car (last args))))
@@ -1097,8 +1110,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
1097(defun byte-compile-log-warning (string &optional fill level) 1110(defun byte-compile-log-warning (string &optional fill level)
1098 (let ((warning-prefix-function 'byte-compile-warning-prefix) 1111 (let ((warning-prefix-function 'byte-compile-warning-prefix)
1099 (warning-type-format "") 1112 (warning-type-format "")
1100 (warning-fill-prefix (if fill " ")) 1113 (warning-fill-prefix (if fill " ")))
1101 (inhibit-read-only t))
1102 (display-warning 'bytecomp string level byte-compile-log-buffer))) 1114 (display-warning 'bytecomp string level byte-compile-log-buffer)))
1103 1115
1104(defun byte-compile-warn (format &rest args) 1116(defun byte-compile-warn (format &rest args)
@@ -2189,7 +2201,10 @@ list that represents a doc string reference.
2189 (when (and (consp (nth 1 form)) 2201 (when (and (consp (nth 1 form))
2190 (eq (car (nth 1 form)) 'quote) 2202 (eq (car (nth 1 form)) 'quote)
2191 (consp (cdr (nth 1 form))) 2203 (consp (cdr (nth 1 form)))
2192 (symbolp (nth 1 (nth 1 form)))) 2204 (symbolp (nth 1 (nth 1 form)))
2205 ;; Don't add it if it's already defined. Otherwise, it might
2206 ;; hide the actual definition.
2207 (not (fboundp (nth 1 (nth 1 form)))))
2193 (push (cons (nth 1 (nth 1 form)) 2208 (push (cons (nth 1 (nth 1 form))
2194 (cons 'autoload (cdr (cdr form)))) 2209 (cons 'autoload (cdr (cdr form))))
2195 byte-compile-function-environment) 2210 byte-compile-function-environment)
@@ -2808,7 +2823,8 @@ for symbols generated by the byte compiler itself."
2808 (setq body (nreverse body)) 2823 (setq body (nreverse body))
2809 (setq body (list 2824 (setq body (list
2810 (if (and (eq tmp 'funcall) 2825 (if (and (eq tmp 'funcall)
2811 (eq (car-safe (car body)) 'quote)) 2826 (eq (car-safe (car body)) 'quote)
2827 (symbolp (nth 1 (car body))))
2812 (cons (nth 1 (car body)) (cdr body)) 2828 (cons (nth 1 (car body)) (cdr body))
2813 (cons tmp body)))) 2829 (cons tmp body))))
2814 (or (eq output-type 'file) 2830 (or (eq output-type 'file)
@@ -3689,10 +3705,10 @@ If CONDITION's value is (not (featurep 'emacs)) or (featurep 'xemacs),
3689that suppresses all warnings during execution of BODY." 3705that suppresses all warnings during execution of BODY."
3690 (declare (indent 1) (debug t)) 3706 (declare (indent 1) (debug t))
3691 `(let* ((fbound-list (byte-compile-find-bound-condition 3707 `(let* ((fbound-list (byte-compile-find-bound-condition
3692 ,condition (list 'fboundp) 3708 ,condition '(fboundp functionp)
3693 byte-compile-unresolved-functions)) 3709 byte-compile-unresolved-functions))
3694 (bound-list (byte-compile-find-bound-condition 3710 (bound-list (byte-compile-find-bound-condition
3695 ,condition (list 'boundp 'default-boundp))) 3711 ,condition '(boundp default-boundp)))
3696 ;; Maybe add to the bound list. 3712 ;; Maybe add to the bound list.
3697 (byte-compile-bound-variables 3713 (byte-compile-bound-variables
3698 (append bound-list byte-compile-bound-variables))) 3714 (append bound-list byte-compile-bound-variables)))
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index a57de344cf3..7c25972835b 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -131,7 +131,7 @@ TYPE is the sequence type to return.
131;;;###autoload 131;;;###autoload
132(defun cl-maplist (cl-func cl-list &rest cl-rest) 132(defun cl-maplist (cl-func cl-list &rest cl-rest)
133 "Map FUNCTION to each sublist of LIST or LISTs. 133 "Map FUNCTION to each sublist of LIST or LISTs.
134Like `mapcar', except applies to lists and their cdr's rather than to 134Like `cl-mapcar', except applies to lists and their cdr's rather than to
135the elements themselves. 135the elements themselves.
136\n(fn FUNCTION LIST...)" 136\n(fn FUNCTION LIST...)"
137 (if cl-rest 137 (if cl-rest
@@ -170,7 +170,7 @@ the elements themselves.
170 170
171;;;###autoload 171;;;###autoload
172(defun cl-mapcan (cl-func cl-seq &rest cl-rest) 172(defun cl-mapcan (cl-func cl-seq &rest cl-rest)
173 "Like `mapcar', but nconc's together the values returned by the function. 173 "Like `cl-mapcar', but nconc's together the values returned by the function.
174\n(fn FUNCTION SEQUENCE...)" 174\n(fn FUNCTION SEQUENCE...)"
175 (apply 'nconc (apply 'cl-mapcar cl-func cl-seq cl-rest))) 175 (apply 'nconc (apply 'cl-mapcar cl-func cl-seq cl-rest)))
176 176
@@ -675,6 +675,9 @@ PROPLIST is a list of the sort returned by `symbol-plist'.
675 675
676;;;###autoload 676;;;###autoload
677(defun cl-prettyexpand (form &optional full) 677(defun cl-prettyexpand (form &optional full)
678 "Expand macros in FORM and insert the pretty-printed result.
679Optional argument FULL non-nil means to expand all macros,
680including `cl-block' and `cl-eval-when'."
678 (message "Expanding...") 681 (message "Expanding...")
679 (let ((cl--compiling-file full) 682 (let ((cl--compiling-file full)
680 (byte-compile-macro-environment nil)) 683 (byte-compile-macro-environment nil))
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index 034a5c7517e..a9be08b1383 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -251,12 +251,17 @@ one value.
251(defvar cl-proclaims-deferred nil) 251(defvar cl-proclaims-deferred nil)
252 252
253(defun cl-proclaim (spec) 253(defun cl-proclaim (spec)
254 "Record a global declaration specified by SPEC."
254 (if (fboundp 'cl-do-proclaim) (cl-do-proclaim spec t) 255 (if (fboundp 'cl-do-proclaim) (cl-do-proclaim spec t)
255 (push spec cl-proclaims-deferred)) 256 (push spec cl-proclaims-deferred))
256 nil) 257 nil)
257 258
258(defmacro cl-declaim (&rest specs) 259(defmacro cl-declaim (&rest specs)
259 (let ((body (mapcar (function (lambda (x) (list 'cl-proclaim (list 'quote x)))) 260 "Like `cl-proclaim', but takes any number of unevaluated, unquoted arguments.
261Puts `(cl-eval-when (compile load eval) ...)' around the declarations
262so that they are registered at compile-time as well as run-time."
263 (let ((body (mapcar (function (lambda (x)
264 (list 'cl-proclaim (list 'quote x))))
260 specs))) 265 specs)))
261 (if (cl--compiling-file) (cl-list* 'cl-eval-when '(compile load eval) body) 266 (if (cl--compiling-file) (cl-list* 'cl-eval-when '(compile load eval) body)
262 (cons 'progn body)))) ; avoid loading cl-macs.el for cl-eval-when 267 (cons 'progn body)))) ; avoid loading cl-macs.el for cl-eval-when
diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el
index 551043caa5e..eb58d17c02e 100644
--- a/lisp/emacs-lisp/cl-loaddefs.el
+++ b/lisp/emacs-lisp/cl-loaddefs.el
@@ -11,7 +11,7 @@
11;;;;;; cl--map-overlays cl--map-intervals cl--map-keymap-recursively 11;;;;;; cl--map-overlays cl--map-intervals cl--map-keymap-recursively
12;;;;;; cl-notevery cl-notany cl-every cl-some cl-mapcon cl-mapcan 12;;;;;; cl-notevery cl-notany cl-every cl-some cl-mapcon cl-mapcan
13;;;;;; cl-mapl cl-mapc cl-maplist cl-map cl--mapcar-many cl-equalp 13;;;;;; cl-mapl cl-mapc cl-maplist cl-map cl--mapcar-many cl-equalp
14;;;;;; cl-coerce) "cl-extra" "cl-extra.el" "0e9284b6492cc98eee7c85ae4e5322ee") 14;;;;;; cl-coerce) "cl-extra" "cl-extra.el" "8e9fee941c465ac0fee9b92a92d64154")
15;;; Generated autoloads from cl-extra.el 15;;; Generated autoloads from cl-extra.el
16 16
17(autoload 'cl-coerce "cl-extra" "\ 17(autoload 'cl-coerce "cl-extra" "\
@@ -41,7 +41,7 @@ TYPE is the sequence type to return.
41 41
42(autoload 'cl-maplist "cl-extra" "\ 42(autoload 'cl-maplist "cl-extra" "\
43Map FUNCTION to each sublist of LIST or LISTs. 43Map FUNCTION to each sublist of LIST or LISTs.
44Like `mapcar', except applies to lists and their cdr's rather than to 44Like `cl-mapcar', except applies to lists and their cdr's rather than to
45the elements themselves. 45the elements themselves.
46 46
47\(fn FUNCTION LIST...)" nil nil) 47\(fn FUNCTION LIST...)" nil nil)
@@ -57,7 +57,7 @@ Like `cl-maplist', but does not accumulate values returned by the function.
57\(fn FUNCTION LIST...)" nil nil) 57\(fn FUNCTION LIST...)" nil nil)
58 58
59(autoload 'cl-mapcan "cl-extra" "\ 59(autoload 'cl-mapcan "cl-extra" "\
60Like `mapcar', but nconc's together the values returned by the function. 60Like `cl-mapcar', but nconc's together the values returned by the function.
61 61
62\(fn FUNCTION SEQUENCE...)" nil nil) 62\(fn FUNCTION SEQUENCE...)" nil nil)
63 63
@@ -248,7 +248,9 @@ Remove from SYMBOL's plist the property PROPNAME and its value.
248\(fn SYMBOL PROPNAME)" nil nil) 248\(fn SYMBOL PROPNAME)" nil nil)
249 249
250(autoload 'cl-prettyexpand "cl-extra" "\ 250(autoload 'cl-prettyexpand "cl-extra" "\
251 251Expand macros in FORM and insert the pretty-printed result.
252Optional argument FULL non-nil means to expand all macros,
253including `cl-block' and `cl-eval-when'.
252 254
253\(fn FORM &optional FULL)" nil nil) 255\(fn FORM &optional FULL)" nil nil)
254 256
@@ -265,7 +267,7 @@ Remove from SYMBOL's plist the property PROPNAME and its value.
265;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when 267;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when
266;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp 268;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp
267;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*) 269;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*)
268;;;;;; "cl-macs" "cl-macs.el" "57cf89149db1e8ea6bc1582713980cf8") 270;;;;;; "cl-macs" "cl-macs.el" "c7ad09a74a1d2969406e7e2aaf3812fc")
269;;; Generated autoloads from cl-macs.el 271;;; Generated autoloads from cl-macs.el
270 272
271(autoload 'cl--compiler-macro-list* "cl-macs" "\ 273(autoload 'cl--compiler-macro-list* "cl-macs" "\
@@ -320,7 +322,7 @@ its argument list allows full Common Lisp conventions.
320\(fn FUNC)" nil t) 322\(fn FUNC)" nil t)
321 323
322(autoload 'cl-destructuring-bind "cl-macs" "\ 324(autoload 'cl-destructuring-bind "cl-macs" "\
323 325Bind the variables in ARGS to the result of EXPR and execute BODY.
324 326
325\(fn ARGS EXPR &rest BODY)" nil t) 327\(fn ARGS EXPR &rest BODY)" nil t)
326 328
@@ -564,12 +566,12 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C).
564(put 'cl-multiple-value-setq 'lisp-indent-function '1) 566(put 'cl-multiple-value-setq 'lisp-indent-function '1)
565 567
566(autoload 'cl-locally "cl-macs" "\ 568(autoload 'cl-locally "cl-macs" "\
567 569Equivalent to `progn'.
568 570
569\(fn &rest BODY)" nil t) 571\(fn &rest BODY)" nil t)
570 572
571(autoload 'cl-the "cl-macs" "\ 573(autoload 'cl-the "cl-macs" "\
572 574At present this ignores _TYPE and is simply equivalent to FORM.
573 575
574\(fn TYPE FORM)" nil t) 576\(fn TYPE FORM)" nil t)
575 577
@@ -721,7 +723,10 @@ and then returning foo.
721\(fn FUNC ARGS &rest BODY)" nil t) 723\(fn FUNC ARGS &rest BODY)" nil t)
722 724
723(autoload 'cl-compiler-macroexpand "cl-macs" "\ 725(autoload 'cl-compiler-macroexpand "cl-macs" "\
724 726Like `macroexpand', but for compiler macros.
727Expands FORM repeatedly until no further expansion is possible.
728Returns FORM unchanged if it has no compiler macro, or if it has a
729macro that returns its `&whole' argument.
725 730
726\(fn FORM)" nil nil) 731\(fn FORM)" nil nil)
727 732
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 8d240774edb..3c46c40242d 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -554,6 +554,7 @@ its argument list allows full Common Lisp conventions."
554 554
555;;;###autoload 555;;;###autoload
556(defmacro cl-destructuring-bind (args expr &rest body) 556(defmacro cl-destructuring-bind (args expr &rest body)
557 "Bind the variables in ARGS to the result of EXPR and execute BODY."
557 (declare (indent 2) 558 (declare (indent 2)
558 (debug (&define cl-macro-list def-form cl-declarations def-body))) 559 (debug (&define cl-macro-list def-form cl-declarations def-body)))
559 (let* ((cl--bind-lets nil) (cl--bind-forms nil) (cl--bind-inits nil) 560 (let* ((cl--bind-lets nil) (cl--bind-forms nil) (cl--bind-inits nil)
@@ -1546,9 +1547,9 @@ An implicit nil block is established around the loop.
1546\(fn (VAR LIST [RESULT]) BODY...)" 1547\(fn (VAR LIST [RESULT]) BODY...)"
1547 (declare (debug ((symbolp form &optional form) cl-declarations body)) 1548 (declare (debug ((symbolp form &optional form) cl-declarations body))
1548 (indent 1)) 1549 (indent 1))
1549 `(cl-block nil 1550 (let ((loop `(dolist ,spec ,@body)))
1550 (,(if (eq 'cl-dolist (symbol-function 'dolist)) 'cl--dolist 'dolist) 1551 (if (advice-member-p #'cl--wrap-in-nil-block 'dolist)
1551 ,spec ,@body))) 1552 loop `(cl-block nil ,loop))))
1552 1553
1553;;;###autoload 1554;;;###autoload
1554(defmacro cl-dotimes (spec &rest body) 1555(defmacro cl-dotimes (spec &rest body)
@@ -1559,9 +1560,9 @@ nil.
1559 1560
1560\(fn (VAR COUNT [RESULT]) BODY...)" 1561\(fn (VAR COUNT [RESULT]) BODY...)"
1561 (declare (debug cl-dolist) (indent 1)) 1562 (declare (debug cl-dolist) (indent 1))
1562 `(cl-block nil 1563 (let ((loop `(dotimes ,spec ,@body)))
1563 (,(if (eq 'cl-dotimes (symbol-function 'dotimes)) 'cl--dotimes 'dotimes) 1564 (if (advice-member-p #'cl--wrap-in-nil-block 'dotimes)
1564 ,spec ,@body))) 1565 loop `(cl-block nil ,loop))))
1565 1566
1566;;;###autoload 1567;;;###autoload
1567(defmacro cl-do-symbols (spec &rest body) 1568(defmacro cl-do-symbols (spec &rest body)
@@ -1886,10 +1887,12 @@ values. For compatibility, (cl-values A B C) is a synonym for (list A B C).
1886 1887
1887;;;###autoload 1888;;;###autoload
1888(defmacro cl-locally (&rest body) 1889(defmacro cl-locally (&rest body)
1890 "Equivalent to `progn'."
1889 (declare (debug t)) 1891 (declare (debug t))
1890 (cons 'progn body)) 1892 (cons 'progn body))
1891;;;###autoload 1893;;;###autoload
1892(defmacro cl-the (_type form) 1894(defmacro cl-the (_type form)
1895 "At present this ignores _TYPE and is simply equivalent to FORM."
1893 (declare (indent 1) (debug (cl-type-spec form))) 1896 (declare (indent 1) (debug (cl-type-spec form)))
1894 form) 1897 form)
1895 1898
@@ -2537,6 +2540,10 @@ and then returning foo."
2537 2540
2538;;;###autoload 2541;;;###autoload
2539(defun cl-compiler-macroexpand (form) 2542(defun cl-compiler-macroexpand (form)
2543 "Like `macroexpand', but for compiler macros.
2544Expands FORM repeatedly until no further expansion is possible.
2545Returns FORM unchanged if it has no compiler macro, or if it has a
2546macro that returns its `&whole' argument."
2540 (while 2547 (while
2541 (let ((func (car-safe form)) (handler nil)) 2548 (let ((func (car-safe form)) (handler nil))
2542 (while (and (symbolp func) 2549 (while (and (symbolp func)
diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
index d3ef83961e2..40d12358b17 100644
--- a/lisp/emacs-lisp/cl.el
+++ b/lisp/emacs-lisp/cl.el
@@ -107,14 +107,6 @@
107 )) 107 ))
108 (defvaralias var (intern (format "cl-%s" var)))) 108 (defvaralias var (intern (format "cl-%s" var))))
109 109
110;; Before overwriting subr.el's `dotimes' and `dolist', let's remember
111;; them under a different name, so we can use them in our implementation
112;; of `dotimes' and `dolist'.
113(unless (fboundp 'cl--dotimes)
114 (defalias 'cl--dotimes (symbol-function 'dotimes) "The non-CL `dotimes'."))
115(unless (fboundp 'cl--dolist)
116 (defalias 'cl--dolist (symbol-function 'dolist) "The non-CL `dolist'."))
117
118(dolist (fun '( 110(dolist (fun '(
119 (get* . cl-get) 111 (get* . cl-get)
120 (random* . cl-random) 112 (random* . cl-random)
@@ -228,7 +220,6 @@
228 remf 220 remf
229 psetf 221 psetf
230 (define-setf-method . define-setf-expander) 222 (define-setf-method . define-setf-expander)
231 declare
232 the 223 the
233 locally 224 locally
234 multiple-value-setq 225 multiple-value-setq
@@ -239,8 +230,6 @@
239 psetq 230 psetq
240 do-all-symbols 231 do-all-symbols
241 do-symbols 232 do-symbols
242 dotimes
243 dolist
244 do* 233 do*
245 do 234 do
246 loop 235 loop
@@ -322,6 +311,15 @@
322 (intern (format "cl-%s" fun))))) 311 (intern (format "cl-%s" fun)))))
323 (defalias fun new))) 312 (defalias fun new)))
324 313
314(defun cl--wrap-in-nil-block (fun &rest args)
315 `(cl-block nil ,(apply fun args)))
316(advice-add 'dolist :around #'cl--wrap-in-nil-block)
317(advice-add 'dotimes :around #'cl--wrap-in-nil-block)
318
319(defun cl--pass-args-to-cl-declare (&rest specs)
320 (macroexpand `(cl-declare ,@specs)))
321(advice-add 'declare :after #'cl--pass-args-to-cl-declare)
322
325;;; Features provided a bit differently in Elisp. 323;;; Features provided a bit differently in Elisp.
326 324
327;; First, the old lexical-let is now better served by `lexical-binding', tho 325;; First, the old lexical-let is now better served by `lexical-binding', tho
@@ -547,13 +545,15 @@ deprecated usage of `symbol-function' in place forms)." ; bug#12760
547 545
548(defmacro define-setf-expander (name arglist &rest body) 546(defmacro define-setf-expander (name arglist &rest body)
549 "Define a `setf' method. 547 "Define a `setf' method.
550This method shows how to handle `setf's to places of the form (NAME ARGS...). 548This method shows how to handle `setf's to places of the form
551The argument forms ARGS are bound according to ARGLIST, as if NAME were 549\(NAME ARGS...). The argument forms ARGS are bound according to
552going to be expanded as a macro, then the BODY forms are executed and must 550ARGLIST, as if NAME were going to be expanded as a macro, then
553return a list of five elements: a temporary-variables list, a value-forms 551the BODY forms are executed and must return a list of five elements:
554list, a store-variables list (of length one), a store-form, and an access- 552a temporary-variables list, a value-forms list, a store-variables list
555form. See `gv-define-expander', `gv-define-setter', and `gv-define-expander' 553\(of length one), a store-form, and an access- form.
556for a better and simpler ways to define setf-methods." 554
555See `gv-define-expander', and `gv-define-setter' for better and
556simpler ways to define setf-methods."
557 (declare (debug 557 (declare (debug
558 (&define name cl-lambda-list cl-declarations-or-string def-body))) 558 (&define name cl-lambda-list cl-declarations-or-string def-body)))
559 `(progn 559 `(progn
@@ -566,23 +566,31 @@ for a better and simpler ways to define setf-methods."
566 566
567(defmacro defsetf (name arg1 &rest args) 567(defmacro defsetf (name arg1 &rest args)
568 "Define a `setf' method. 568 "Define a `setf' method.
569This macro is an easy-to-use substitute for `define-setf-expander' that works 569This macro is an easy-to-use substitute for `define-setf-expander'
570well for simple place forms. In the simple `defsetf' form, `setf's of 570that works well for simple place forms.
571the form (setf (NAME ARGS...) VAL) are transformed to function or macro 571
572calls of the form (FUNC ARGS... VAL). Example: 572In the simple `defsetf' form, `setf's of the form (setf (NAME
573ARGS...) VAL) are transformed to function or macro calls of the
574form (FUNC ARGS... VAL). For example:
573 575
574 (defsetf aref aset) 576 (defsetf aref aset)
575 577
578You can replace this form with `gv-define-simple-setter'.
579
576Alternate form: (defsetf NAME ARGLIST (STORE) BODY...). 580Alternate form: (defsetf NAME ARGLIST (STORE) BODY...).
577Here, the above `setf' call is expanded by binding the argument forms ARGS 581
578according to ARGLIST, binding the value form VAL to STORE, then executing 582Here, the above `setf' call is expanded by binding the argument
579BODY, which must return a Lisp form that does the necessary `setf' operation. 583forms ARGS according to ARGLIST, binding the value form VAL to
580Actually, ARGLIST and STORE may be bound to temporary variables which are 584STORE, then executing BODY, which must return a Lisp form that
581introduced automatically to preserve proper execution order of the arguments. 585does the necessary `setf' operation. Actually, ARGLIST and STORE
582Example: 586may be bound to temporary variables which are introduced
587automatically to preserve proper execution order of the arguments.
588For example:
583 589
584 (defsetf nth (n x) (v) `(setcar (nthcdr ,n ,x) ,v)) 590 (defsetf nth (n x) (v) `(setcar (nthcdr ,n ,x) ,v))
585 591
592You can replace this form with `gv-define-setter'.
593
586\(fn NAME [FUNC | ARGLIST (STORE) BODY...])" 594\(fn NAME [FUNC | ARGLIST (STORE) BODY...])"
587 (declare (debug 595 (declare (debug
588 (&define name 596 (&define name
@@ -597,7 +605,7 @@ Example:
597 (cl-function 605 (cl-function
598 (lambda (,@(car args) ,@arg1) ,@(cdr args))) 606 (lambda (,@(car args) ,@arg1) ,@(cdr args)))
599 do args))) 607 do args)))
600 `(gv-define-simple-setter ,name ,arg1))) 608 `(gv-define-simple-setter ,name ,arg1 ,(car args))))
601 609
602;; FIXME: CL used to provide a setf method for `apply', but I haven't been able 610;; FIXME: CL used to provide a setf method for `apply', but I haven't been able
603;; to find a case where it worked. The code below tries to handle it as well. 611;; to find a case where it worked. The code below tries to handle it as well.
@@ -639,8 +647,12 @@ Example:
639 647
640(defmacro define-modify-macro (name arglist func &optional doc) 648(defmacro define-modify-macro (name arglist func &optional doc)
641 "Define a `setf'-like modify macro. 649 "Define a `setf'-like modify macro.
642If NAME is called, it combines its PLACE argument with the other arguments 650If NAME is called, it combines its PLACE argument with the other
643from ARGLIST using FUNC: (define-modify-macro incf (&optional (n 1)) +)" 651arguments from ARGLIST using FUNC. For example:
652
653 (define-modify-macro incf (&optional (n 1)) +)
654
655You can replace this macro with `gv-letplace'."
644 (declare (debug 656 (declare (debug
645 (&define name cl-lambda-list ;; should exclude &key 657 (&define name cl-lambda-list ;; should exclude &key
646 symbolp &optional stringp))) 658 symbolp &optional stringp)))
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index c04e68c0cfa..a378941a5a4 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -1,4 +1,4 @@
1;;; debug.el --- debuggers and related commands for Emacs 1;;; debug.el --- debuggers and related commands for Emacs -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 1985-1986, 1994, 2001-2012 Free Software Foundation, Inc. 3;; Copyright (C) 1985-1986, 1994, 2001-2012 Free Software Foundation, Inc.
4 4
@@ -49,9 +49,9 @@ the middle is discarded, and just the beginning and end are displayed."
49 :version "21.1") 49 :version "21.1")
50 50
51(defcustom debugger-bury-or-kill 'bury 51(defcustom debugger-bury-or-kill 'bury
52 "How to proceed with the debugger buffer when exiting `debug'. 52 "What to do with the debugger buffer when exiting `debug'.
53The value used here affects the behavior of operations on any 53The value affects the behavior of operations on any window
54window previously showing the debugger buffer. 54previously showing the debugger buffer.
55 55
56`nil' means that if its window is not deleted when exiting the 56`nil' means that if its window is not deleted when exiting the
57 debugger, invoking `switch-to-prev-buffer' will usually show 57 debugger, invoking `switch-to-prev-buffer' will usually show
@@ -79,10 +79,7 @@ The value used here is passed to `quit-restore-window'."
79 (const :tag "Bury" bury) 79 (const :tag "Bury" bury)
80 (const :tag "Kill" kill)) 80 (const :tag "Kill" kill))
81 :group 'debugger 81 :group 'debugger
82 :version "24.2") 82 :version "24.3")
83
84(defvar debug-function-list nil
85 "List of functions currently set for debug on entry.")
86 83
87(defvar debugger-step-after-exit nil 84(defvar debugger-step-after-exit nil
88 "Non-nil means \"single-step\" after the debugger exits.") 85 "Non-nil means \"single-step\" after the debugger exits.")
@@ -146,7 +143,7 @@ where CAUSE can be:
146;;;###autoload 143;;;###autoload
147(setq debugger 'debug) 144(setq debugger 'debug)
148;;;###autoload 145;;;###autoload
149(defun debug (&rest debugger-args) 146(defun debug (&rest args)
150 "Enter debugger. \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger. 147 "Enter debugger. \\<debugger-mode-map>`\\[debugger-continue]' returns from the debugger.
151Arguments are mainly for use when this is called from the internals 148Arguments are mainly for use when this is called from the internals
152of the evaluator. 149of the evaluator.
@@ -165,6 +162,7 @@ first will be printed into the backtrace buffer."
165 (if (get-buffer "*Backtrace*") 162 (if (get-buffer "*Backtrace*")
166 (with-current-buffer (get-buffer "*Backtrace*") 163 (with-current-buffer (get-buffer "*Backtrace*")
167 (list major-mode (buffer-string))))) 164 (list major-mode (buffer-string)))))
165 (debugger-args args)
168 (debugger-buffer (get-buffer-create "*Backtrace*")) 166 (debugger-buffer (get-buffer-create "*Backtrace*"))
169 (debugger-old-buffer (current-buffer)) 167 (debugger-old-buffer (current-buffer))
170 (debugger-window nil) 168 (debugger-window nil)
@@ -219,7 +217,7 @@ first will be printed into the backtrace buffer."
219 (save-excursion 217 (save-excursion
220 (when (eq (car debugger-args) 'debug) 218 (when (eq (car debugger-args) 'debug)
221 ;; Skip the frames for backtrace-debug, byte-code, 219 ;; Skip the frames for backtrace-debug, byte-code,
222 ;; and implement-debug-on-entry. 220 ;; debug--implement-debug-on-entry and the advice's `apply'.
223 (backtrace-debug 4 t) 221 (backtrace-debug 4 t)
224 ;; Place an extra debug-on-exit for macro's. 222 ;; Place an extra debug-on-exit for macro's.
225 (when (eq 'lambda (car-safe (cadr (backtrace-frame 4)))) 223 (when (eq 'lambda (car-safe (cadr (backtrace-frame 4))))
@@ -318,7 +316,7 @@ first will be printed into the backtrace buffer."
318 (setq debug-on-next-call debugger-step-after-exit) 316 (setq debug-on-next-call debugger-step-after-exit)
319 debugger-value))) 317 debugger-value)))
320 318
321(defun debugger-setup-buffer (debugger-args) 319(defun debugger-setup-buffer (args)
322 "Initialize the `*Backtrace*' buffer for entry to the debugger. 320 "Initialize the `*Backtrace*' buffer for entry to the debugger.
323That buffer should be current already." 321That buffer should be current already."
324 (setq buffer-read-only nil) 322 (setq buffer-read-only nil)
@@ -334,20 +332,22 @@ That buffer should be current already."
334 (delete-region (point) 332 (delete-region (point)
335 (progn 333 (progn
336 (search-forward "\n debug(") 334 (search-forward "\n debug(")
337 (forward-line (if (eq (car debugger-args) 'debug) 335 (forward-line (if (eq (car args) 'debug)
338 2 ; Remove implement-debug-on-entry frame. 336 ;; Remove debug--implement-debug-on-entry
337 ;; and the advice's `apply' frame.
338 3
339 1)) 339 1))
340 (point))) 340 (point)))
341 (insert "Debugger entered") 341 (insert "Debugger entered")
342 ;; lambda is for debug-on-call when a function call is next. 342 ;; lambda is for debug-on-call when a function call is next.
343 ;; debug is for debug-on-entry function called. 343 ;; debug is for debug-on-entry function called.
344 (pcase (car debugger-args) 344 (pcase (car args)
345 ((or `lambda `debug) 345 ((or `lambda `debug)
346 (insert "--entering a function:\n")) 346 (insert "--entering a function:\n"))
347 ;; Exiting a function. 347 ;; Exiting a function.
348 (`exit 348 (`exit
349 (insert "--returning value: ") 349 (insert "--returning value: ")
350 (setq debugger-value (nth 1 debugger-args)) 350 (setq debugger-value (nth 1 args))
351 (prin1 debugger-value (current-buffer)) 351 (prin1 debugger-value (current-buffer))
352 (insert ?\n) 352 (insert ?\n)
353 (delete-char 1) 353 (delete-char 1)
@@ -356,7 +356,7 @@ That buffer should be current already."
356 ;; Debugger entered for an error. 356 ;; Debugger entered for an error.
357 (`error 357 (`error
358 (insert "--Lisp error: ") 358 (insert "--Lisp error: ")
359 (prin1 (nth 1 debugger-args) (current-buffer)) 359 (prin1 (nth 1 args) (current-buffer))
360 (insert ?\n)) 360 (insert ?\n))
361 ;; debug-on-call, when the next thing is an eval. 361 ;; debug-on-call, when the next thing is an eval.
362 (`t 362 (`t
@@ -364,8 +364,8 @@ That buffer should be current already."
364 ;; User calls debug directly. 364 ;; User calls debug directly.
365 (_ 365 (_
366 (insert ": ") 366 (insert ": ")
367 (prin1 (if (eq (car debugger-args) 'nil) 367 (prin1 (if (eq (car args) 'nil)
368 (cdr debugger-args) debugger-args) 368 (cdr args) args)
369 (current-buffer)) 369 (current-buffer))
370 (insert ?\n))) 370 (insert ?\n)))
371 ;; After any frame that uses eval-buffer, 371 ;; After any frame that uses eval-buffer,
@@ -525,9 +525,10 @@ removes itself from that hook."
525 (count 0)) 525 (count 0))
526 (while (not (eq (cadr (backtrace-frame count)) 'debug)) 526 (while (not (eq (cadr (backtrace-frame count)) 'debug))
527 (setq count (1+ count))) 527 (setq count (1+ count)))
528 ;; Skip implement-debug-on-entry frame. 528 ;; Skip debug--implement-debug-on-entry frame.
529 (when (eq 'implement-debug-on-entry (cadr (backtrace-frame (1+ count)))) 529 (when (eq 'debug--implement-debug-on-entry
530 (setq count (1+ count))) 530 (cadr (backtrace-frame (1+ count))))
531 (setq count (+ 2 count)))
531 (goto-char (point-min)) 532 (goto-char (point-min))
532 (when (looking-at "Debugger entered--\\(Lisp error\\|returning value\\):") 533 (when (looking-at "Debugger entered--\\(Lisp error\\|returning value\\):")
533 (goto-char (match-end 0)) 534 (goto-char (match-end 0))
@@ -694,10 +695,10 @@ Applies to the frame whose line point is on in the backtrace."
694 :help "Continue to exit from this frame, with all debug-on-entry suspended")) 695 :help "Continue to exit from this frame, with all debug-on-entry suspended"))
695 (define-key menu-map [deb-cont] 696 (define-key menu-map [deb-cont]
696 '(menu-item "Continue" debugger-continue 697 '(menu-item "Continue" debugger-continue
697 :help "Continue, evaluating this expression without stopping")) 698 :help "Continue, evaluating this expression without stopping"))
698 (define-key menu-map [deb-step] 699 (define-key menu-map [deb-step]
699 '(menu-item "Step through" debugger-step-through 700 '(menu-item "Step through" debugger-step-through
700 :help "Proceed, stepping through subexpressions of this expression")) 701 :help "Proceed, stepping through subexpressions of this expression"))
701 map)) 702 map))
702 703
703(put 'debugger-mode 'mode-class 'special) 704(put 'debugger-mode 'mode-class 'special)
@@ -777,7 +778,7 @@ For the cross-reference format, see `help-make-xrefs'."
777 778
778;; When you change this, you may also need to change the number of 779;; When you change this, you may also need to change the number of
779;; frames that the debugger skips. 780;; frames that the debugger skips.
780(defun implement-debug-on-entry () 781(defun debug--implement-debug-on-entry (&rest _ignore)
781 "Conditionally call the debugger. 782 "Conditionally call the debugger.
782A call to this function is inserted by `debug-on-entry' to cause 783A call to this function is inserted by `debug-on-entry' to cause
783functions to break on entry." 784functions to break on entry."
@@ -785,12 +786,6 @@ functions to break on entry."
785 nil 786 nil
786 (funcall debugger 'debug))) 787 (funcall debugger 'debug)))
787 788
788(defun debugger-special-form-p (symbol)
789 "Return whether SYMBOL is a special form."
790 (and (fboundp symbol)
791 (subrp (symbol-function symbol))
792 (eq (cdr (subr-arity (symbol-function symbol))) 'unevalled)))
793
794;;;###autoload 789;;;###autoload
795(defun debug-on-entry (function) 790(defun debug-on-entry (function)
796 "Request FUNCTION to invoke debugger each time it is called. 791 "Request FUNCTION to invoke debugger each time it is called.
@@ -808,7 +803,7 @@ Use \\[cancel-debug-on-entry] to cancel the effect of this command.
808Redefining FUNCTION also cancels it." 803Redefining FUNCTION also cancels it."
809 (interactive 804 (interactive
810 (let ((fn (function-called-at-point)) val) 805 (let ((fn (function-called-at-point)) val)
811 (when (debugger-special-form-p fn) 806 (when (special-form-p fn)
812 (setq fn nil)) 807 (setq fn nil))
813 (setq val (completing-read 808 (setq val (completing-read
814 (if fn 809 (if fn
@@ -817,36 +812,21 @@ Redefining FUNCTION also cancels it."
817 obarray 812 obarray
818 #'(lambda (symbol) 813 #'(lambda (symbol)
819 (and (fboundp symbol) 814 (and (fboundp symbol)
820 (not (debugger-special-form-p symbol)))) 815 (not (special-form-p symbol))))
821 t nil nil (symbol-name fn))) 816 t nil nil (symbol-name fn)))
822 (list (if (equal val "") fn (intern val))))) 817 (list (if (equal val "") fn (intern val)))))
823 ;; FIXME: Use advice.el. 818 (advice-add function :before #'debug--implement-debug-on-entry)
824 (when (debugger-special-form-p function)
825 (error "Function %s is a special form" function))
826 (if (or (symbolp (symbol-function function))
827 (subrp (symbol-function function)))
828 ;; The function is built-in or aliased to another function.
829 ;; Create a wrapper in which we can add the debug call.
830 (fset function `(lambda (&rest debug-on-entry-args)
831 ,(interactive-form (symbol-function function))
832 (apply ',(symbol-function function)
833 debug-on-entry-args)))
834 (when (autoloadp (symbol-function function))
835 ;; The function is autoloaded. Load its real definition.
836 (autoload-do-load (symbol-function function) function))
837 (when (or (not (consp (symbol-function function)))
838 (and (eq (car (symbol-function function)) 'macro)
839 (not (consp (cdr (symbol-function function))))))
840 ;; The function is byte-compiled. Create a wrapper in which
841 ;; we can add the debug call.
842 (debug-convert-byte-code function)))
843 (unless (consp (symbol-function function))
844 (error "Definition of %s is not a list" function))
845 (fset function (debug-on-entry-1 function t))
846 (unless (memq function debug-function-list)
847 (push function debug-function-list))
848 function) 819 function)
849 820
821(defun debug--function-list ()
822 "List of functions currently set for debug on entry."
823 (let ((funs '()))
824 (mapatoms
825 (lambda (s)
826 (when (advice-member-p #'debug--implement-debug-on-entry s)
827 (push s funs))))
828 funs))
829
850;;;###autoload 830;;;###autoload
851(defun cancel-debug-on-entry (&optional function) 831(defun cancel-debug-on-entry (&optional function)
852 "Undo effect of \\[debug-on-entry] on FUNCTION. 832 "Undo effect of \\[debug-on-entry] on FUNCTION.
@@ -857,80 +837,16 @@ To specify a nil argument interactively, exit with an empty minibuffer."
857 (list (let ((name 837 (list (let ((name
858 (completing-read 838 (completing-read
859 "Cancel debug on entry to function (default all functions): " 839 "Cancel debug on entry to function (default all functions): "
860 (mapcar 'symbol-name debug-function-list) nil t))) 840 (mapcar #'symbol-name (debug--function-list)) nil t)))
861 (when name 841 (when name
862 (unless (string= name "") 842 (unless (string= name "")
863 (intern name)))))) 843 (intern name))))))
864 (if (and function 844 (if function
865 (not (string= function ""))) ; Pre 22.1 compatibility test.
866 (progn 845 (progn
867 (let ((defn (debug-on-entry-1 function nil))) 846 (advice-remove function #'debug--implement-debug-on-entry)
868 (condition-case nil
869 (when (and (equal (nth 1 defn) '(&rest debug-on-entry-args))
870 (eq (car (nth 3 defn)) 'apply))
871 ;; `defn' is a wrapper introduced in debug-on-entry.
872 ;; Get rid of it since we don't need it any more.
873 (setq defn (nth 1 (nth 1 (nth 3 defn)))))
874 (error nil))
875 (fset function defn))
876 (setq debug-function-list (delq function debug-function-list))
877 function) 847 function)
878 (message "Cancelling debug-on-entry for all functions") 848 (message "Cancelling debug-on-entry for all functions")
879 (mapcar 'cancel-debug-on-entry debug-function-list))) 849 (mapcar #'cancel-debug-on-entry (debug--function-list))))
880
881(defun debug-arglist (definition)
882 ;; FIXME: copied from ad-arglist.
883 "Return the argument list of DEFINITION."
884 (require 'help-fns)
885 (help-function-arglist definition 'preserve-names))
886
887(defun debug-convert-byte-code (function)
888 (let* ((defn (symbol-function function))
889 (macro (eq (car-safe defn) 'macro)))
890 (when macro (setq defn (cdr defn)))
891 (when (byte-code-function-p defn)
892 (let* ((args (debug-arglist defn))
893 (body
894 `((,(if (memq '&rest args) #'apply #'funcall)
895 ,defn
896 ,@(remq '&rest (remq '&optional args))))))
897 (if (> (length defn) 5)
898 ;; The mere presence of field 5 is sufficient to make
899 ;; it interactive.
900 (push `(interactive ,(aref defn 5)) body))
901 (if (and (> (length defn) 4) (aref defn 4))
902 ;; Use `documentation' here, to get the actual string,
903 ;; in case the compiled function has a reference
904 ;; to the .elc file.
905 (setq body (cons (documentation function) body)))
906 (setq defn `(closure (t) ,args ,@body)))
907 (when macro (setq defn (cons 'macro defn)))
908 (fset function defn))))
909
910(defun debug-on-entry-1 (function flag)
911 (let* ((defn (symbol-function function))
912 (tail defn))
913 (when (eq (car-safe tail) 'macro)
914 (setq tail (cdr tail)))
915 (if (not (memq (car-safe tail) '(closure lambda)))
916 ;; Only signal an error when we try to set debug-on-entry.
917 ;; When we try to clear debug-on-entry, we are now done.
918 (when flag
919 (error "%s is not a user-defined Lisp function" function))
920 (if (eq (car tail) 'closure) (setq tail (cdr tail)))
921 (setq tail (cdr tail))
922 ;; Skip the docstring.
923 (when (and (stringp (cadr tail)) (cddr tail))
924 (setq tail (cdr tail)))
925 ;; Skip the interactive form.
926 (when (eq 'interactive (car-safe (cadr tail)))
927 (setq tail (cdr tail)))
928 (unless (eq flag (equal (cadr tail) '(implement-debug-on-entry)))
929 ;; Add/remove debug statement as needed.
930 (setcdr tail (if flag
931 (cons '(implement-debug-on-entry) (cdr tail))
932 (cddr tail)))))
933 defn))
934 850
935(defun debugger-list-functions () 851(defun debugger-list-functions ()
936 "Display a list of all the functions now set to debug on entry." 852 "Display a list of all the functions now set to debug on entry."
@@ -940,17 +856,18 @@ To specify a nil argument interactively, exit with an empty minibuffer."
940 (called-interactively-p 'interactive)) 856 (called-interactively-p 'interactive))
941 (with-output-to-temp-buffer (help-buffer) 857 (with-output-to-temp-buffer (help-buffer)
942 (with-current-buffer standard-output 858 (with-current-buffer standard-output
943 (if (null debug-function-list) 859 (let ((funs (debug--function-list)))
944 (princ "No debug-on-entry functions now\n") 860 (if (null funs)
945 (princ "Functions set to debug on entry:\n\n") 861 (princ "No debug-on-entry functions now\n")
946 (dolist (fun debug-function-list) 862 (princ "Functions set to debug on entry:\n\n")
947 (make-text-button (point) (progn (prin1 fun) (point)) 863 (dolist (fun funs)
948 'type 'help-function 864 (make-text-button (point) (progn (prin1 fun) (point))
949 'help-args (list fun)) 865 'type 'help-function
950 (terpri)) 866 'help-args (list fun))
951 (terpri) 867 (terpri))
952 (princ "Note: if you have redefined a function, then it may no longer\n") 868 (terpri)
953 (princ "be set to debug on entry, even if it is in the list."))))) 869 (princ "Note: if you have redefined a function, then it may no longer\n")
870 (princ "be set to debug on entry, even if it is in the list."))))))
954 871
955(provide 'debug) 872(provide 'debug)
956 873
diff --git a/lisp/emacs-lisp/elp.el b/lisp/emacs-lisp/elp.el
index b94817cdb02..067b45f5cd8 100644
--- a/lisp/emacs-lisp/elp.el
+++ b/lisp/emacs-lisp/elp.el
@@ -1,4 +1,4 @@
1;;; elp.el --- Emacs Lisp Profiler 1;;; elp.el --- Emacs Lisp Profiler -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 1994-1995, 1997-1998, 2001-2012 3;; Copyright (C) 1994-1995, 1997-1998, 2001-2012
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
@@ -124,6 +124,7 @@
124 124
125;;; Code: 125;;; Code:
126 126
127(eval-when-compile (require 'cl-lib))
127 128
128;; start of user configuration variables 129;; start of user configuration variables
129;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 130;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
@@ -148,9 +149,9 @@ Results are displayed with the `elp-results' command."
148 "Non-nil specifies ELP results sorting function. 149 "Non-nil specifies ELP results sorting function.
149These functions are currently available: 150These functions are currently available:
150 151
151 elp-sort-by-call-count -- sort by the highest call count 152 `elp-sort-by-call-count' -- sort by the highest call count
152 elp-sort-by-total-time -- sort by the highest total time 153 `elp-sort-by-total-time' -- sort by the highest total time
153 elp-sort-by-average-time -- sort by the highest average times 154 `elp-sort-by-average-time' -- sort by the highest average times
154 155
155You can write your own sort function. It should adhere to the 156You can write your own sort function. It should adhere to the
156interface specified by the PREDICATE argument for `sort'. 157interface specified by the PREDICATE argument for `sort'.
@@ -167,7 +168,7 @@ If a number, no function that has been called fewer than that number
167of times will be displayed in the output buffer. If nil, all 168of times will be displayed in the output buffer. If nil, all
168functions will be displayed." 169functions will be displayed."
169 :type '(choice integer 170 :type '(choice integer
170 (const :tag "Show All" nil)) 171 (const :tag "Show All" nil))
171 :group 'elp) 172 :group 'elp)
172 173
173(defcustom elp-use-standard-output nil 174(defcustom elp-use-standard-output nil
@@ -193,9 +194,6 @@ In other words, a new unique buffer is create every time you run
193(defconst elp-timer-info-property 'elp-info 194(defconst elp-timer-info-property 'elp-info
194 "ELP information property name.") 195 "ELP information property name.")
195 196
196(defvar elp-all-instrumented-list nil
197 "List of all functions currently being instrumented.")
198
199(defvar elp-record-p t 197(defvar elp-record-p t
200 "Controls whether functions should record times or not. 198 "Controls whether functions should record times or not.
201This variable is set by the master function.") 199This variable is set by the master function.")
@@ -205,7 +203,7 @@ This variable is set by the master function.")
205 203
206(defvar elp-not-profilable 204(defvar elp-not-profilable
207 ;; First, the functions used inside each instrumented function: 205 ;; First, the functions used inside each instrumented function:
208 '(elp-wrapper called-interactively-p 206 '(called-interactively-p
209 ;; Then the functions used by the above functions. I used 207 ;; Then the functions used by the above functions. I used
210 ;; (delq nil (mapcar (lambda (x) (and (symbolp x) (fboundp x) x)) 208 ;; (delq nil (mapcar (lambda (x) (and (symbolp x) (fboundp x) x))
211 ;; (aref (symbol-function 'elp-wrapper) 2))) 209 ;; (aref (symbol-function 'elp-wrapper) 2)))
@@ -223,60 +221,21 @@ them would thus lead to infinite recursion.")
223 (fboundp fun) 221 (fboundp fun)
224 (not (or (memq fun elp-not-profilable) 222 (not (or (memq fun elp-not-profilable)
225 (keymapp fun) 223 (keymapp fun)
226 (memq (car-safe (symbol-function fun)) '(autoload macro)) 224 (autoloadp (symbol-function fun)) ;FIXME: Why not just load it?
227 (condition-case nil 225 (special-form-p fun)))))
228 (when (subrp (indirect-function fun))
229 (eq 'unevalled
230 (cdr (subr-arity (indirect-function fun)))))
231 (error nil))))))
232 226
227(defconst elp--advice-name 'ELP-instrumentation\ )
233 228
234;;;###autoload 229;;;###autoload
235(defun elp-instrument-function (funsym) 230(defun elp-instrument-function (funsym)
236 "Instrument FUNSYM for profiling. 231 "Instrument FUNSYM for profiling.
237FUNSYM must be a symbol of a defined function." 232FUNSYM must be a symbol of a defined function."
238 (interactive "aFunction to instrument: ") 233 (interactive "aFunction to instrument: ")
239 ;; restore the function. this is necessary to avoid infinite 234 (let* ((infovec (vector 0 0)))
240 ;; recursion of already instrumented functions (i.e. elp-wrapper
241 ;; calling elp-wrapper ad infinitum). it is better to simply
242 ;; restore the function than to throw an error. this will work
243 ;; properly in the face of eval-defun because if the function was
244 ;; redefined, only the timer info will be nil'd out since
245 ;; elp-restore-function is smart enough not to trash the new
246 ;; definition.
247 (elp-restore-function funsym)
248 (let* ((funguts (symbol-function funsym))
249 (infovec (vector 0 0 funguts))
250 (newguts '(lambda (&rest args))))
251 ;; we cannot profile macros
252 (and (eq (car-safe funguts) 'macro)
253 (error "ELP cannot profile macro: %s" funsym))
254 ;; TBD: at some point it might be better to load the autoloaded
255 ;; function instead of throwing an error. if we do this, then we
256 ;; probably want elp-instrument-package to be updated with the
257 ;; newly loaded list of functions. i'm not sure it's smart to do
258 ;; the autoload here, since that could have side effects, and
259 ;; elp-instrument-function is similar (in my mind) to defun-ish
260 ;; type functionality (i.e. it shouldn't execute the function).
261 (and (autoloadp funguts)
262 (error "ELP cannot profile autoloaded function: %s" funsym))
263 ;; We cannot profile functions used internally during profiling. 235 ;; We cannot profile functions used internally during profiling.
264 (unless (elp-profilable-p funsym) 236 (unless (elp-profilable-p funsym)
265 (error "ELP cannot profile the function: %s" funsym)) 237 (error "ELP cannot profile the function: %s" funsym))
266 ;; put rest of newguts together 238 ;; The info vector data structure is a 2 element vector. The 0th
267 (if (commandp funsym)
268 (setq newguts (append newguts '((interactive)))))
269 (setq newguts (append newguts `((elp-wrapper
270 (quote ,funsym)
271 ,(when (commandp funsym)
272 '(called-interactively-p 'any))
273 args))))
274 ;; to record profiling times, we set the symbol's function
275 ;; definition so that it runs the elp-wrapper function with the
276 ;; function symbol as an argument. We place the old function
277 ;; definition on the info vector.
278 ;;
279 ;; The info vector data structure is a 3 element vector. The 0th
280 ;; element is the call-count, i.e. the total number of times this 239 ;; element is the call-count, i.e. the total number of times this
281 ;; function has been entered. This value is bumped up on entry to 240 ;; function has been entered. This value is bumped up on entry to
282 ;; the function so that non-local exists are still recorded. TBD: 241 ;; the function so that non-local exists are still recorded. TBD:
@@ -285,72 +244,45 @@ FUNSYM must be a symbol of a defined function."
285 ;; The 1st element is the total amount of time in seconds that has 244 ;; The 1st element is the total amount of time in seconds that has
286 ;; been spent inside this function. This number is added to on 245 ;; been spent inside this function. This number is added to on
287 ;; function exit. 246 ;; function exit.
288 ;;
289 ;; The 2nd element is the old function definition list. This gets
290 ;; funcall'd in between start/end time retrievals. I believe that
291 ;; this lets us profile even byte-compiled functions.
292 247
293 ;; put the info vector on the property list 248 ;; Put the info vector on the property list.
294 (put funsym elp-timer-info-property infovec) 249 (put funsym elp-timer-info-property infovec)
295 250
296 ;; Set the symbol's new profiling function definition to run 251 ;; Set the symbol's new profiling function definition to run
297 ;; elp-wrapper. 252 ;; ELP wrapper.
298 (let ((advice-info (get funsym 'ad-advice-info))) 253 (advice-add funsym :around (elp--make-wrapper funsym)
299 (if advice-info 254 `((name . ,elp--advice-name)))))
300 (progn 255
301 ;; If function is advised, don't let Advice change 256(defun elp--instrumented-p (sym)
302 ;; its definition from under us during the `fset'. 257 (advice-member-p elp--advice-name sym))
303 (put funsym 'ad-advice-info nil)
304 (fset funsym newguts)
305 (put funsym 'ad-advice-info advice-info))
306 (fset funsym newguts)))
307
308 ;; add this function to the instrumentation list
309 (unless (memq funsym elp-all-instrumented-list)
310 (push funsym elp-all-instrumented-list))))
311 258
312(defun elp-restore-function (funsym) 259(defun elp-restore-function (funsym)
313 "Restore an instrumented function to its original definition. 260 "Restore an instrumented function to its original definition.
314Argument FUNSYM is the symbol of a defined function." 261Argument FUNSYM is the symbol of a defined function."
315 (interactive "aFunction to restore: ") 262 (interactive
316 (let ((info (get funsym elp-timer-info-property))) 263 (list
317 ;; delete the function from the all instrumented list 264 (intern
318 (setq elp-all-instrumented-list 265 (completing-read "Function to restore: " obarray
319 (delq funsym elp-all-instrumented-list)) 266 #'elp--instrumented-p t))))
320 267 ;; If the function was the master, reset the master.
321 ;; if the function was the master, reset the master 268 (if (eq funsym elp-master)
322 (if (eq funsym elp-master) 269 (setq elp-master nil
323 (setq elp-master nil 270 elp-record-p t))
324 elp-record-p t)) 271
325 272 ;; Zap the properties.
326 ;; zap the properties 273 (put funsym elp-timer-info-property nil)
327 (put funsym elp-timer-info-property nil) 274
328 275 (advice-remove funsym elp--advice-name))
329 ;; restore the original function definition, but if the function
330 ;; wasn't instrumented do nothing. we do this after the above
331 ;; because its possible the function got un-instrumented due to
332 ;; circumstances beyond our control. Also, check to make sure
333 ;; that the current function symbol points to elp-wrapper. If
334 ;; not, then the user probably did an eval-defun, or loaded a
335 ;; byte-compiled version, while the function was instrumented and
336 ;; we don't want to destroy the new definition. can it ever be
337 ;; the case that a lisp function can be compiled instrumented?
338 (and info
339 (functionp funsym)
340 (not (byte-code-function-p (symbol-function funsym)))
341 (assq 'elp-wrapper (symbol-function funsym))
342 (fset funsym (aref info 2)))))
343 276
344;;;###autoload 277;;;###autoload
345(defun elp-instrument-list (&optional list) 278(defun elp-instrument-list (&optional list)
346 "Instrument, for profiling, all functions in `elp-function-list'. 279 "Instrument, for profiling, all functions in `elp-function-list'.
347Use optional LIST if provided instead. 280Use optional LIST if provided instead.
348If called interactively, read LIST using the minibuffer." 281If called interactively, read LIST using the minibuffer."
349 (interactive "PList of functions to instrument: ") 282 (interactive "PList of functions to instrument: ") ;FIXME: Doesn't work?!
350 (unless (listp list) 283 (unless (listp list)
351 (signal 'wrong-type-argument (list 'listp list))) 284 (signal 'wrong-type-argument (list 'listp list)))
352 (let ((list (or list elp-function-list))) 285 (mapcar #'elp-instrument-function (or list elp-function-list)))
353 (mapcar 'elp-instrument-function list)))
354 286
355;;;###autoload 287;;;###autoload
356(defun elp-instrument-package (prefix) 288(defun elp-instrument-package (prefix)
@@ -371,15 +303,13 @@ For example, to instrument all ELP functions, do the following:
371(defun elp-restore-list (&optional list) 303(defun elp-restore-list (&optional list)
372 "Restore the original definitions for all functions in `elp-function-list'. 304 "Restore the original definitions for all functions in `elp-function-list'.
373Use optional LIST if provided instead." 305Use optional LIST if provided instead."
374 (interactive "PList of functions to restore: ") 306 (interactive "PList of functions to restore: ") ;FIXME: Doesn't work!?
375 (let ((list (or list elp-function-list))) 307 (mapcar #'elp-restore-function (or list elp-function-list)))
376 (mapcar 'elp-restore-function list)))
377 308
378(defun elp-restore-all () 309(defun elp-restore-all ()
379 "Restore the original definitions of all functions being profiled." 310 "Restore the original definitions of all functions being profiled."
380 (interactive) 311 (interactive)
381 (elp-restore-list elp-all-instrumented-list)) 312 (mapatoms #'elp-restore-function))
382
383 313
384(defun elp-reset-function (funsym) 314(defun elp-reset-function (funsym)
385 "Reset the profiling information for FUNSYM." 315 "Reset the profiling information for FUNSYM."
@@ -395,30 +325,36 @@ Use optional LIST if provided instead."
395(defun elp-reset-list (&optional list) 325(defun elp-reset-list (&optional list)
396 "Reset the profiling information for all functions in `elp-function-list'. 326 "Reset the profiling information for all functions in `elp-function-list'.
397Use optional LIST if provided instead." 327Use optional LIST if provided instead."
398 (interactive "PList of functions to reset: ") 328 (interactive "PList of functions to reset: ") ;FIXME: Doesn't work!?
399 (let ((list (or list elp-function-list))) 329 (let ((list (or list elp-function-list)))
400 (mapcar 'elp-reset-function list))) 330 (mapcar 'elp-reset-function list)))
401 331
402(defun elp-reset-all () 332(defun elp-reset-all ()
403 "Reset the profiling information for all functions being profiled." 333 "Reset the profiling information for all functions being profiled."
404 (interactive) 334 (interactive)
405 (elp-reset-list elp-all-instrumented-list)) 335 (mapatoms (lambda (sym)
336 (if (get sym elp-timer-info-property)
337 (elp-reset-function sym)))))
406 338
407(defun elp-set-master (funsym) 339(defun elp-set-master (funsym)
408 "Set the master function for profiling." 340 "Set the master function for profiling."
409 (interactive "aMaster function: ") 341 (interactive
410 ;; when there's a master function, recording is turned off by 342 (list
411 ;; default 343 (intern
344 (completing-read "Master function: " obarray
345 #'elp--instrumented-p
346 t nil nil (if elp-master (symbol-name elp-master))))))
347 ;; When there's a master function, recording is turned off by default.
412 (setq elp-master funsym 348 (setq elp-master funsym
413 elp-record-p nil) 349 elp-record-p nil)
414 ;; make sure master function is instrumented 350 ;; Make sure master function is instrumented.
415 (or (memq funsym elp-all-instrumented-list) 351 (or (elp--instrumented-p funsym)
416 (elp-instrument-function funsym))) 352 (elp-instrument-function funsym)))
417 353
418(defun elp-unset-master () 354(defun elp-unset-master ()
419 "Unset the master function." 355 "Unset the master function."
420 (interactive) 356 (interactive)
421 ;; when there's no master function, recording is turned on by default. 357 ;; When there's no master function, recording is turned on by default.
422 (setq elp-master nil 358 (setq elp-master nil
423 elp-record-p t)) 359 elp-record-p t))
424 360
@@ -426,49 +362,40 @@ Use optional LIST if provided instead."
426(defsubst elp-elapsed-time (start end) 362(defsubst elp-elapsed-time (start end)
427 (float-time (time-subtract end start))) 363 (float-time (time-subtract end start)))
428 364
429(defun elp-wrapper (funsym interactive-p args) 365(defun elp--make-wrapper (funsym)
430 "This function has been instrumented for profiling by the ELP. 366 "Make the piece of advice that instruments FUNSYM."
367 (lambda (func &rest args)
368 "This function has been instrumented for profiling by the ELP.
431ELP is the Emacs Lisp Profiler. To restore the function to its 369ELP is the Emacs Lisp Profiler. To restore the function to its
432original definition, use \\[elp-restore-function] or \\[elp-restore-all]." 370original definition, use \\[elp-restore-function] or \\[elp-restore-all]."
433 ;; turn on recording if this is the master function 371 ;; turn on recording if this is the master function
434 (if (and elp-master 372 (if (and elp-master
435 (eq funsym elp-master)) 373 (eq funsym elp-master))
436 (setq elp-record-p t)) 374 (setq elp-record-p t))
437 ;; get info vector and original function symbol 375 ;; get info vector and original function symbol
438 (let* ((info (get funsym elp-timer-info-property)) 376 (let* ((info (get funsym elp-timer-info-property))
439 (func (aref info 2)) 377 result)
440 result) 378 (or func
441 (or func 379 (error "%s is not instrumented for profiling" funsym))
442 (error "%s is not instrumented for profiling" funsym)) 380 (if (not elp-record-p)
443 (if (not elp-record-p) 381 ;; when not recording, just call the original function symbol
444 ;; when not recording, just call the original function symbol 382 ;; and return the results.
445 ;; and return the results. 383 (setq result (apply func args))
446 (setq result 384 ;; we are recording times
447 (if interactive-p 385 (let (enter-time exit-time)
448 (call-interactively func) 386 ;; increment the call-counter
449 (apply func args))) 387 (cl-incf (aref info 0))
450 ;; we are recording times
451 (let (enter-time exit-time)
452 ;; increment the call-counter
453 (aset info 0 (1+ (aref info 0)))
454 ;; now call the old symbol function, checking to see if it
455 ;; should be called interactively. make sure we return the
456 ;; correct value
457 (if interactive-p
458 (setq enter-time (current-time)
459 result (call-interactively func)
460 exit-time (current-time))
461 (setq enter-time (current-time) 388 (setq enter-time (current-time)
462 result (apply func args) 389 result (apply func args)
463 exit-time (current-time))) 390 exit-time (current-time))
464 ;; calculate total time in function 391 ;; calculate total time in function
465 (aset info 1 (+ (aref info 1) (elp-elapsed-time enter-time exit-time))) 392 (cl-incf (aref info 1) (elp-elapsed-time enter-time exit-time))
466 )) 393 ))
467 ;; turn off recording if this is the master function 394 ;; turn off recording if this is the master function
468 (if (and elp-master 395 (if (and elp-master
469 (eq funsym elp-master)) 396 (eq funsym elp-master))
470 (setq elp-record-p nil)) 397 (setq elp-record-p nil))
471 result)) 398 result)))
472 399
473 400
474;; shut the byte-compiler up 401;; shut the byte-compiler up
@@ -582,57 +509,58 @@ displayed."
582 (elp-et-len (length et-header)) 509 (elp-et-len (length et-header))
583 (at-header "Average Time") 510 (at-header "Average Time")
584 (elp-at-len (length at-header)) 511 (elp-at-len (length at-header))
585 (resvec 512 (resvec '())
586 (mapcar
587 (function
588 (lambda (funsym)
589 (let* ((info (get funsym elp-timer-info-property))
590 (symname (format "%s" funsym))
591 (cc (aref info 0))
592 (tt (aref info 1)))
593 (if (not info)
594 (insert "No profiling information found for: "
595 symname)
596 (setq longest (max longest (length symname)))
597 (vector cc tt (if (zerop cc)
598 0.0 ;avoid arithmetic div-by-zero errors
599 (/ (float tt) (float cc)))
600 symname)))))
601 elp-all-instrumented-list))
602 ) ; end let* 513 ) ; end let*
514 (mapatoms
515 (lambda (funsym)
516 (when (elp--instrumented-p funsym)
517 (let* ((info (get funsym elp-timer-info-property))
518 (symname (format "%s" funsym))
519 (cc (aref info 0))
520 (tt (aref info 1)))
521 (if (not info)
522 (insert "No profiling information found for: "
523 symname)
524 (setq longest (max longest (length symname)))
525 (push
526 (vector cc tt (if (zerop cc)
527 0.0 ;avoid arithmetic div-by-zero errors
528 (/ (float tt) (float cc)))
529 symname)
530 resvec))))))
603 ;; If printing to stdout, insert the header so it will print. 531 ;; If printing to stdout, insert the header so it will print.
604 ;; Otherwise use header-line-format. 532 ;; Otherwise use header-line-format.
605 (setq elp-field-len (max titlelen longest)) 533 (setq elp-field-len (max titlelen longest))
606 (if (or elp-use-standard-output noninteractive) 534 (if (or elp-use-standard-output noninteractive)
607 (progn 535 (progn
608 (insert title) 536 (insert title)
609 (if (> longest titlelen) 537 (if (> longest titlelen)
610 (progn 538 (progn
611 (insert-char 32 (- longest titlelen)))) 539 (insert-char 32 (- longest titlelen))))
612 (insert " " cc-header " " et-header " " at-header "\n") 540 (insert " " cc-header " " et-header " " at-header "\n")
613 (insert-char ?= elp-field-len) 541 (insert-char ?= elp-field-len)
614 (insert " ") 542 (insert " ")
615 (insert-char ?= elp-cc-len) 543 (insert-char ?= elp-cc-len)
616 (insert " ") 544 (insert " ")
617 (insert-char ?= elp-et-len) 545 (insert-char ?= elp-et-len)
618 (insert " ") 546 (insert " ")
619 (insert-char ?= elp-at-len) 547 (insert-char ?= elp-at-len)
620 (insert "\n")) 548 (insert "\n"))
621 (let ((column 0)) 549 (let ((column 0))
622 (setq header-line-format 550 (setq header-line-format
623 (mapconcat 551 (mapconcat
624 (lambda (title) 552 (lambda (title)
625 (prog1 553 (prog1
626 (concat 554 (concat
627 (propertize " " 555 (propertize " "
628 'display (list 'space :align-to column) 556 'display (list 'space :align-to column)
629 'face 'fixed-pitch) 557 'face 'fixed-pitch)
630 title) 558 title)
631 (setq column (+ column 2 559 (setq column (+ column 2
632 (if (= column 0) 560 (if (= column 0)
633 elp-field-len 561 elp-field-len
634 (length title)))))) 562 (length title))))))
635 (list title cc-header et-header at-header) "")))) 563 (list title cc-header et-header at-header) ""))))
636 ;; if sorting is enabled, then sort the results list. in either 564 ;; if sorting is enabled, then sort the results list. in either
637 ;; case, call elp-output-result to output the result in the 565 ;; case, call elp-output-result to output the result in the
638 ;; buffer 566 ;; buffer
@@ -644,7 +572,7 @@ displayed."
644 (pop-to-buffer resultsbuf) 572 (pop-to-buffer resultsbuf)
645 ;; copy results to standard-output? 573 ;; copy results to standard-output?
646 (if (or elp-use-standard-output noninteractive) 574 (if (or elp-use-standard-output noninteractive)
647 (princ (buffer-substring (point-min) (point-max))) 575 (princ (buffer-substring (point-min) (point-max)))
648 (goto-char (point-min))) 576 (goto-char (point-min)))
649 ;; reset profiling info if desired 577 ;; reset profiling info if desired
650 (and elp-reset-after-results 578 (and elp-reset-after-results
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index d6c91539a90..02eec08f96b 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -111,7 +111,7 @@ DO must return an Elisp expression."
111GETTER will be bound to a copyable expression that returns the value 111GETTER will be bound to a copyable expression that returns the value
112of PLACE. 112of PLACE.
113SETTER will be bound to a function that takes an expression V and returns 113SETTER will be bound to a function that takes an expression V and returns
114and new expression that sets PLACE to V. 114a new expression that sets PLACE to V.
115BODY should return some Elisp expression E manipulating PLACE via GETTER 115BODY should return some Elisp expression E manipulating PLACE via GETTER
116and SETTER. 116and SETTER.
117The returned value will then be an Elisp expression that first evaluates 117The returned value will then be an Elisp expression that first evaluates
@@ -194,7 +194,7 @@ well for simple place forms.
194Assignments of VAL to (NAME ARGS...) are expanded by binding the argument 194Assignments of VAL to (NAME ARGS...) are expanded by binding the argument
195forms (VAL ARGS...) according to ARGLIST, then executing BODY, which must 195forms (VAL ARGS...) according to ARGLIST, then executing BODY, which must
196return a Lisp form that does the assignment. 196return a Lisp form that does the assignment.
197The first arg in ARLIST (the one that receives VAL) receives an expression 197The first arg in ARGLIST (the one that receives VAL) receives an expression
198which can do arbitrary things, whereas the other arguments are all guaranteed 198which can do arbitrary things, whereas the other arguments are all guaranteed
199to be pure and copyable. Example use: 199to be pure and copyable. Example use:
200 (gv-define-setter aref (v a i) `(aset ,a ,i ,v))" 200 (gv-define-setter aref (v a i) `(aset ,a ,i ,v))"
@@ -209,13 +209,21 @@ to be pure and copyable. Example use:
209This macro is an easy-to-use substitute for `gv-define-expander' that works 209This macro is an easy-to-use substitute for `gv-define-expander' that works
210well for simple place forms. Assignments of VAL to (NAME ARGS...) are 210well for simple place forms. Assignments of VAL to (NAME ARGS...) are
211turned into calls of the form (SETTER ARGS... VAL). 211turned into calls of the form (SETTER ARGS... VAL).
212
212If FIX-RETURN is non-nil, then SETTER is not assumed to return VAL and 213If FIX-RETURN is non-nil, then SETTER is not assumed to return VAL and
213instead the assignment is turned into (prog1 VAL (SETTER ARGS... VAL)) 214instead the assignment is turned into something equivalent to
215 \(let ((temp VAL))
216 (SETTER ARGS... temp)
217 temp)
214so as to preserve the semantics of `setf'." 218so as to preserve the semantics of `setf'."
215 (declare (debug (sexp (&or symbolp lambda-expr) &optional sexp))) 219 (declare (debug (sexp (&or symbolp lambda-expr) &optional sexp)))
216 (let ((set-call `(cons ',setter (append args (list val)))))
217 `(gv-define-setter ,name (val &rest args) 220 `(gv-define-setter ,name (val &rest args)
218 ,(if fix-return `(list 'prog1 val ,set-call) set-call)))) 221 ,(if fix-return
222 `(macroexp-let2 nil v val
223 `(progn
224 (,',setter ,@(append args (list v)))
225 ,v))
226 `(cons ',setter (append args (list val))))))
219 227
220;;; Typical operations on generalized variables. 228;;; Typical operations on generalized variables.
221 229
@@ -433,6 +441,26 @@ The return value is the last VAL in the list.
433 `(logior (logand ,v ,mask) 441 `(logior (logand ,v ,mask)
434 (logand ,getter (lognot ,mask)))))))))) 442 (logand ,getter (lognot ,mask))))))))))
435 443
444;;; References
445
446;;;###autoload
447(defmacro gv-ref (place)
448 "Return a reference to PLACE.
449This is like the `&' operator of the C language."
450 (gv-letplace (getter setter) place
451 `(cons (lambda () ,getter)
452 (lambda (gv--val) ,(funcall setter 'gv--val)))))
453
454(defsubst gv-deref (ref)
455 "Dereference REF, returning the referenced value.
456This is like the `*' operator of the C language.
457REF must have been previously obtained with `gv-ref'."
458 (funcall (car ref)))
459;; Don't use `declare' because it seems to introduce circularity problems:
460;; Warning: Eager macro-expansion skipped due to cycle:
461;; … => (load "gv.el") => (macroexpand-all (defsubst gv-deref …)) => (macroexpand (defun …)) => (load "gv.el")
462(gv-define-setter gv-deref (v ref) `(funcall (cdr ,ref) ,v))
463
436;;; Vaguely related definitions that should be moved elsewhere. 464;;; Vaguely related definitions that should be moved elsewhere.
437 465
438;; (defun alist-get (key alist) 466;; (defun alist-get (key alist)
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
new file mode 100644
index 00000000000..ca1ebf3cad2
--- /dev/null
+++ b/lisp/emacs-lisp/nadvice.el
@@ -0,0 +1,365 @@
1;;; nadvice.el --- Light-weight advice primitives for Elisp functions -*- lexical-binding: t -*-
2
3;; Copyright (C) 2012 Free Software Foundation, Inc.
4
5;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6;; Keywords: extensions, lisp, tools
7;; Package: emacs
8
9;; This program is free software; you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; This program is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;; This package lets you add behavior (which we call "piece of advice") to
25;; existing functions, like the old `advice.el' package, but with much fewer
26;; bells ans whistles. It comes in 2 parts:
27;;
28;; - The first part lets you add/remove functions, similarly to
29;; add/remove-hook, from any "place" (i.e. as accepted by `setf') that
30;; holds a function.
31;; This part provides mainly 2 macros: `add-function' and `remove-function'.
32;;
33;; - The second part provides `add-advice' and `remove-advice' which are
34;; refined version of the previous macros specially tailored for the case
35;; where the place that we want to modify is a `symbol-function'.
36
37;;; Code:
38
39;;;; Lightweight advice/hook
40(defvar advice--where-alist
41 '((:around "\300\301\302\003#\207" 5)
42 (:before "\300\301\002\"\210\300\302\002\"\207" 4)
43 (:after "\300\302\002\"\300\301\003\"\210\207" 5)
44 (:after-until "\300\302\002\"\206\013\000\300\301\002\"\207" 4)
45 (:after-while "\300\302\002\"\205\013\000\300\301\002\"\207" 4)
46 (:before-until "\300\301\002\"\206\013\000\300\302\002\"\207" 4)
47 (:before-while "\300\301\002\"\205\013\000\300\302\002\"\207" 4))
48 "List of descriptions of how to add a function.
49Each element has the form (WHERE BYTECODE STACK) where:
50 WHERE is a keyword indicating where the function is added.
51 BYTECODE is the corresponding byte-code that will be used.
52 STACK is the amount of stack space needed by the byte-code.")
53
54(defvar advice--bytecodes (mapcar #'cadr advice--where-alist))
55
56(defun advice--p (object)
57 (and (byte-code-function-p object)
58 (eq 128 (aref object 0))
59 (memq (length object) '(5 6))
60 (memq (aref object 1) advice--bytecodes)
61 (eq #'apply (aref (aref object 2) 0))))
62
63(defsubst advice--car (f) (aref (aref f 2) 1))
64(defsubst advice--cdr (f) (aref (aref f 2) 2))
65(defsubst advice--props (f) (aref (aref f 2) 3))
66
67(defun advice--make-docstring (_string function)
68 "Build the raw doc-string of SYMBOL, presumably advised."
69 (let ((flist (indirect-function function))
70 (docstring nil))
71 (if (eq 'macro (car-safe flist)) (setq flist (cdr flist)))
72 (while (advice--p flist)
73 (let ((bytecode (aref flist 1))
74 (where nil))
75 (dolist (elem advice--where-alist)
76 (if (eq bytecode (cadr elem)) (setq where (car elem))))
77 (setq docstring
78 (concat
79 docstring
80 (propertize (format "%s advice: " where)
81 'face 'warning)
82 (let ((fun (advice--car flist)))
83 (if (symbolp fun) (format "`%S'" fun)
84 (let* ((name (cdr (assq 'name (advice--props flist))))
85 (doc (documentation fun t))
86 (usage (help-split-fundoc doc function)))
87 (if usage (setq doc (cdr usage)))
88 (if name
89 (if doc
90 (format "%s\n%s" name doc)
91 (format "%s" name))
92 (or doc "No documentation")))))
93 "\n")))
94 (setq flist (advice--cdr flist)))
95 (if docstring (setq docstring (concat docstring "\n")))
96 (let* ((origdoc (unless (eq function flist) ;Avoid inf-loops.
97 (documentation flist t)))
98 (usage (help-split-fundoc origdoc function)))
99 (setq usage (if (null usage)
100 (let ((arglist (help-function-arglist flist)))
101 (format "%S" (help-make-usage function arglist)))
102 (setq origdoc (cdr usage)) (car usage)))
103 (help-add-fundoc-usage (concat docstring origdoc) usage))))
104
105(defvar advice--docstring
106 ;; Can't eval-when-compile nor use defconst because it then gets pure-copied,
107 ;; which drops the text-properties.
108 ;;(eval-when-compile
109 (propertize "Advised function"
110 'dynamic-docstring-function #'advice--make-docstring)) ;; )
111
112(defun advice--make-interactive-form (function main)
113 ;; TODO: Make it possible to do around-like advising on the
114 ;; interactive forms (bug#12844).
115 ;; TODO: make it so that interactive spec can be a constant which
116 ;; dynamically checks the advice--car/cdr to do its job.
117 ;; TODO: Implement interactive-read-args:
118 ;;(when (or (commandp function) (commandp main))
119 ;; `(interactive-read-args
120 ;; (cadr (or (interactive-form function) (interactive-form main)))))
121 ;; FIXME: This loads autoloaded functions too eagerly.
122 (cadr (or (interactive-form function)
123 (interactive-form main))))
124
125(defsubst advice--make-1 (byte-code stack-depth function main props)
126 "Build a function value that adds FUNCTION to MAIN."
127 (let ((adv-sig (gethash main advertised-signature-table))
128 (advice
129 (apply #'make-byte-code 128 byte-code
130 (vector #'apply function main props) stack-depth
131 advice--docstring
132 (when (or (commandp function) (commandp main))
133 (list (advice--make-interactive-form
134 function main))))))
135 (when adv-sig (puthash advice adv-sig advertised-signature-table))
136 advice))
137
138(defun advice--make (where function main props)
139 "Build a function value that adds FUNCTION to MAIN at WHERE.
140WHERE is a symbol to select an entry in `advice--where-alist'."
141 (let ((desc (assq where advice--where-alist)))
142 (unless desc (error "Unknown add-function location `%S'" where))
143 (advice--make-1 (nth 1 desc) (nth 2 desc)
144 function main props)))
145
146(defun advice--member-p (function definition)
147 (let ((found nil))
148 (while (and (not found) (advice--p definition))
149 (if (or (equal function (advice--car definition))
150 (equal function (cdr (assq 'name (advice--props definition)))))
151 (setq found t)
152 (setq definition (advice--cdr definition))))
153 found))
154
155;;;###autoload
156(defun advice--remove-function (flist function)
157 (if (not (advice--p flist))
158 flist
159 (let ((first (advice--car flist))
160 (props (advice--props flist)))
161 (if (or (equal function first)
162 (equal function (cdr (assq 'name props))))
163 (advice--cdr flist)
164 (let* ((rest (advice--cdr flist))
165 (nrest (advice--remove-function rest function)))
166 (if (eq rest nrest) flist
167 (advice--make-1 (aref flist 1) (aref flist 3)
168 first nrest props)))))))
169
170;;;###autoload
171(defmacro add-function (where place function &optional props)
172 ;; TODO:
173 ;; - provide something like `around' for interactive forms.
174 ;; - provide some kind of buffer-local functionality at least when `place'
175 ;; is a variable.
176 ;; - obsolete with-wrapper-hook (mostly requires buffer-local support).
177 ;; - provide some kind of control over ordering. E.g. debug-on-entry, ELP
178 ;; and tracing want to stay first.
179 ;; - maybe also let `where' specify some kind of predicate and use it
180 ;; to implement things like mode-local or eieio-defmethod.
181 ;; :before is like a normal add-hook on a normal hook.
182 ;; :before-while is like add-hook on run-hook-with-args-until-failure.
183 ;; :before-until is like add-hook on run-hook-with-args-until-success.
184 ;; Same with :after-* but for (add-hook ... 'append).
185 "Add a piece of advice on the function stored at PLACE.
186FUNCTION describes the code to add. WHERE describes where to add it.
187WHERE can be explained by showing the resulting new function, as the
188result of combining FUNCTION and the previous value of PLACE, which we
189call OLDFUN here:
190`:before' (lambda (&rest r) (apply FUNCTION r) (apply OLDFUN r))
191`:after' (lambda (&rest r) (prog1 (apply OLDFUN r) (apply FUNCTION r)))
192`:around' (lambda (&rest r) (apply FUNCTION OLDFUN r))
193`:before-while' (lambda (&rest r) (and (apply FUNCTION r) (apply OLDFUN r)))
194`:before-until' (lambda (&rest r) (or (apply FUNCTION r) (apply OLDFUN r)))
195`:after-while' (lambda (&rest r) (and (apply OLDFUN r) (apply FUNCTION r)))
196`:after-until' (lambda (&rest r) (or (apply OLDFUN r) (apply FUNCTION r)))
197If FUNCTION was already added, do nothing.
198PROPS is an alist of additional properties, among which the following have
199a special meaning:
200- `name': a string or symbol. It can be used to refer to this piece of advice."
201 (declare (debug t)) ;;(indent 2)
202 `(advice--add-function ,where (gv-ref ,place) ,function ,props))
203
204;;;###autoload
205(defun advice--add-function (where ref function props)
206 (unless (advice--member-p function (gv-deref ref))
207 (setf (gv-deref ref)
208 (advice--make where function (gv-deref ref) props))))
209
210(defmacro remove-function (place function)
211 "Remove the FUNCTION piece of advice from PLACE.
212If FUNCTION was not added to PLACE, do nothing.
213Instead of FUNCTION being the actual function, it can also be the `name'
214of the piece of advice."
215 (declare (debug t))
216 (gv-letplace (getter setter) place
217 (macroexp-let2 nil new `(advice--remove-function ,getter ,function)
218 `(unless (eq ,new ,getter) ,(funcall setter new)))))
219
220;;;; Specific application of add-function to `symbol-function' for advice.
221
222(defun advice--subst-main (old new)
223 (if (not (advice--p old))
224 new
225 (let* ((first (advice--car old))
226 (rest (advice--cdr old))
227 (props (advice--props old))
228 (nrest (advice--subst-main rest new)))
229 (if (equal rest nrest) old
230 (advice--make-1 (aref old 1) (aref old 3)
231 first nrest props)))))
232
233(defun advice--normalize (symbol def)
234 (cond
235 ((special-form-p def)
236 ;; Not worth the trouble trying to handle this, I think.
237 (error "add-advice failure: %S is a special form" symbol))
238 ((and (symbolp def)
239 (eq 'macro (car-safe (ignore-errors (indirect-function def)))))
240 (let ((newval (cons 'macro (cdr (indirect-function def)))))
241 (put symbol 'advice--saved-rewrite (cons def newval))
242 newval))
243 ;; `f' might be a pure (hence read-only) cons!
244 ((and (eq 'macro (car-safe def))
245 (not (ignore-errors (setcdr def (cdr def)) t)))
246 (cons 'macro (cdr def)))
247 (t def)))
248
249(defsubst advice--strip-macro (x)
250 (if (eq 'macro (car-safe x)) (cdr x) x))
251
252(defun advice--defalias-fset (fsetfun symbol newdef)
253 (when (get symbol 'advice--saved-rewrite)
254 (put symbol 'advice--saved-rewrite nil))
255 (setq newdef (advice--normalize symbol newdef))
256 (let* ((olddef (advice--strip-macro
257 (if (fboundp symbol) (symbol-function symbol))))
258 (oldadv
259 (cond
260 ((null (get symbol 'advice--pending))
261 (or olddef
262 (progn
263 (message "Delayed advice activation failed for %s: no data"
264 symbol)
265 nil)))
266 ((or (not olddef) (autoloadp olddef))
267 (prog1 (get symbol 'advice--pending)
268 (put symbol 'advice--pending nil)))
269 (t (message "Dropping left-over advice--pending for %s" symbol)
270 (put symbol 'advice--pending nil)
271 olddef))))
272 (let* ((snewdef (advice--strip-macro newdef))
273 (snewadv (advice--subst-main oldadv snewdef)))
274 (funcall (or fsetfun #'fset) symbol
275 (if (eq snewdef newdef) snewadv (cons 'macro snewadv))))))
276
277
278;;;###autoload
279(defun advice-add (symbol where function &optional props)
280 "Like `add-function' but for the function named SYMBOL.
281Contrary to `add-function', this will properly handle the cases where SYMBOL
282is defined as a macro, alias, command, ..."
283 ;; TODO:
284 ;; - record the advice location, to display in describe-function.
285 ;; - change all defadvice in lisp/**/*.el.
286 ;; - rewrite advice.el on top of this.
287 ;; - obsolete advice.el.
288 ;; To make advice.el and nadvice.el interoperate properly I see 2 different
289 ;; ways:
290 ;; - keep them separate: complete the defalias-fset-function setter with
291 ;; a matching accessor which both nadvice.el and advice.el will have to use
292 ;; in place of symbol-function. This can probably be made to work, but
293 ;; they have to agree on a "protocol".
294 ;; - layer advice.el on top of nadvice.el. I prefer this approach. the
295 ;; simplest way is to make advice.el build one ad-Advice-foo function for
296 ;; each advised function which is advice-added/removed whenever ad-activate
297 ;; ad-deactivate is called.
298 (let* ((f (and (fboundp symbol) (symbol-function symbol)))
299 (nf (advice--normalize symbol f)))
300 (unless (eq f nf) ;; Most importantly, if nf == nil!
301 (fset symbol nf))
302 (add-function where (cond
303 ((eq (car-safe nf) 'macro) (cdr nf))
304 ;; If the function is not yet defined, we can't yet
305 ;; install the advice.
306 ;; FIXME: If it's an autoloaded command, we also
307 ;; have a problem because we need to load the
308 ;; command to build the interactive-form.
309 ((or (not nf) (and (autoloadp nf))) ;; (commandp nf)
310 (get symbol 'advice--pending))
311 (t (symbol-function symbol)))
312 function props)
313 (add-function :around (get symbol 'defalias-fset-function)
314 #'advice--defalias-fset))
315 nil)
316
317;;;###autoload
318(defun advice-remove (symbol function)
319 "Like `remove-function' but for the function named SYMBOL.
320Contrary to `remove-function', this will work also when SYMBOL is a macro
321and it will not signal an error if SYMBOL is not `fboundp'.
322Instead of the actual function to remove, FUNCTION can also be the `name'
323of the piece of advice."
324 (when (fboundp symbol)
325 (let ((f (symbol-function symbol)))
326 ;; Can't use the `if' place here, because the body is too large,
327 ;; resulting in use of code that only works with lexical-scoping.
328 (remove-function (if (eq (car-safe f) 'macro)
329 (cdr f)
330 (symbol-function symbol))
331 function)
332 (unless (advice--p
333 (if (eq (car-safe f) 'macro) (cdr f) (symbol-function symbol)))
334 ;; Not advised any more.
335 (remove-function (get symbol 'defalias-fset-function)
336 #'advice--defalias-fset)
337 (if (eq (symbol-function symbol)
338 (cdr (get symbol 'advice--saved-rewrite)))
339 (fset symbol (car (get symbol 'advice--saved-rewrite))))))
340 nil))
341
342;; (defun advice-mapc (fun symbol)
343;; "Apply FUN to every function added as advice to SYMBOL.
344;; FUN is called with a two arguments: the function that was added, and the
345;; properties alist that was specified when it was added."
346;; (let ((def (or (get symbol 'advice--pending)
347;; (if (fboundp symbol) (symbol-function symbol)))))
348;; (while (advice--p def)
349;; (funcall fun (advice--car def) (advice--props def))
350;; (setq def (advice--cdr def)))))
351
352;;;###autoload
353(defun advice-member-p (advice function-name)
354 "Return non-nil if ADVICE has been added to FUNCTION-NAME.
355Instead of ADVICE being the actual function, it can also be the `name'
356of the piece of advice."
357 (advice--member-p advice
358 (or (get function-name 'advice--pending)
359 (advice--strip-macro
360 (if (fboundp function-name)
361 (symbol-function function-name))))))
362
363
364(provide 'nadvice)
365;;; nadvice.el ends here
diff --git a/lisp/env.el b/lisp/env.el
index d0d8ed0b998..5f7c61b719a 100644
--- a/lisp/env.el
+++ b/lisp/env.el
@@ -57,31 +57,28 @@ If it is also not t, RET does not exit if it does non-null completion."
57;; History list for VALUE argument to setenv. 57;; History list for VALUE argument to setenv.
58(defvar setenv-history nil) 58(defvar setenv-history nil)
59 59
60(defconst env--substitute-vars-regexp
61 "\\$\\(?:\\(?1:[[:alnum:]_]+\\)\\|{\\(?1:[^{}]+\\)}\\|\\$\\)")
60 62
61(defun substitute-env-vars (string) 63(defun substitute-env-vars (string &optional only-defined)
62 "Substitute environment variables referred to in STRING. 64 "Substitute environment variables referred to in STRING.
63`$FOO' where FOO is an environment variable name means to substitute 65`$FOO' where FOO is an environment variable name means to substitute
64the value of that variable. The variable name should be terminated 66the value of that variable. The variable name should be terminated
65with a character not a letter, digit or underscore; otherwise, enclose 67with a character not a letter, digit or underscore; otherwise, enclose
66the entire variable name in braces. For instance, in `ab$cd-x', 68the entire variable name in braces. For instance, in `ab$cd-x',
67`$cd' is treated as an environment variable. 69`$cd' is treated as an environment variable.
70If ONLY-DEFINED is nil, references to undefined environment variables
71are replaced by the empty string; if it is non-nil, they are left unchanged.
68 72
69Use `$$' to insert a single dollar sign." 73Use `$$' to insert a single dollar sign."
70 (let ((start 0)) 74 (let ((start 0))
71 (while (string-match 75 (while (string-match env--substitute-vars-regexp string start)
72 (eval-when-compile
73 (rx (or (and "$" (submatch (1+ (regexp "[[:alnum:]_]"))))
74 (and "${" (submatch (minimal-match (0+ anything))) "}")
75 "$$")))
76 string start)
77 (cond ((match-beginning 1) 76 (cond ((match-beginning 1)
78 (let ((value (getenv (match-string 1 string)))) 77 (let ((value (getenv (match-string 1 string))))
78 (if (and (null value) only-defined)
79 (setq start (match-end 0))
79 (setq string (replace-match (or value "") t t string) 80 (setq string (replace-match (or value "") t t string)
80 start (+ (match-beginning 0) (length value))))) 81 start (+ (match-beginning 0) (length value))))))
81 ((match-beginning 2)
82 (let ((value (getenv (match-string 2 string))))
83 (setq string (replace-match (or value "") t t string)
84 start (+ (match-beginning 0) (length value)))))
85 (t 82 (t
86 (setq string (replace-match "$" t t string) 83 (setq string (replace-match "$" t t string)
87 start (+ (match-beginning 0) 1))))) 84 start (+ (match-beginning 0) 1)))))
@@ -185,7 +182,7 @@ VARIABLE should be a string. Value is nil if VARIABLE is undefined in
185the environment. Otherwise, value is a string. 182the environment. Otherwise, value is a string.
186 183
187If optional parameter FRAME is non-nil, then it should be a 184If optional parameter FRAME is non-nil, then it should be a
188frame. This function will look up VARIABLE in its 'environment 185frame. This function will look up VARIABLE in its `environment'
189parameter. 186parameter.
190 187
191Otherwise, this function searches `process-environment' for 188Otherwise, this function searches `process-environment' for
diff --git a/lisp/files.el b/lisp/files.el
index 26c5c683b3d..8e8a178caab 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3387,30 +3387,39 @@ It is dangerous if either of these conditions are met:
3387 (setq ok t))) 3387 (setq ok t)))
3388 ok)))))))) 3388 ok))))))))
3389 3389
3390(defun hack-one-local-variable--obsolete (var)
3391 (let ((o (get var 'byte-obsolete-variable)))
3392 (when o
3393 (let ((instead (nth 0 o))
3394 (since (nth 2 o)))
3395 (message "%s is obsolete%s; %s"
3396 var (if since (format " (since %s)" since))
3397 (if (stringp instead) instead
3398 (format "use `%s' instead" instead)))))))
3399
3390(defun hack-one-local-variable (var val) 3400(defun hack-one-local-variable (var val)
3391 "Set local variable VAR with value VAL. 3401 "Set local variable VAR with value VAL.
3392If VAR is `mode', call `VAL-mode' as a function unless it's 3402If VAR is `mode', call `VAL-mode' as a function unless it's
3393already the major mode." 3403already the major mode."
3394 (cond ((eq var 'mode) 3404 (pcase var
3395 (let ((mode (intern (concat (downcase (symbol-name val)) 3405 (`mode
3396 "-mode")))) 3406 (let ((mode (intern (concat (downcase (symbol-name val))
3397 (unless (eq (indirect-function mode) 3407 "-mode"))))
3398 (indirect-function major-mode)) 3408 (unless (eq (indirect-function mode)
3399 (if (memq mode minor-mode-list) 3409 (indirect-function major-mode))
3400 ;; A minor mode must be passed an argument. 3410 (funcall mode))))
3401 ;; Otherwise, if the user enables the minor mode in a 3411 (`eval
3402 ;; major mode hook, this would toggle it off. 3412 (pcase val
3403 (funcall mode 1) 3413 (`(add-hook ',hook . ,_) (hack-one-local-variable--obsolete hook)))
3404 (funcall mode))))) 3414 (save-excursion (eval val)))
3405 ((eq var 'eval) 3415 (_
3406 (save-excursion (eval val))) 3416 (hack-one-local-variable--obsolete var)
3407 (t 3417 ;; Make sure the string has no text properties.
3408 ;; Make sure the string has no text properties. 3418 ;; Some text properties can get evaluated in various ways,
3409 ;; Some text properties can get evaluated in various ways, 3419 ;; so it is risky to put them on with a local variable list.
3410 ;; so it is risky to put them on with a local variable list. 3420 (if (stringp val)
3411 (if (stringp val) 3421 (set-text-properties 0 (length val) nil val))
3412 (set-text-properties 0 (length val) nil val)) 3422 (set (make-local-variable var) val))))
3413 (set (make-local-variable var) val))))
3414 3423
3415;;; Handling directory-local variables, aka project settings. 3424;;; Handling directory-local variables, aka project settings.
3416 3425
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 78204897cf1..5f635e59cdf 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,8 @@
12012-11-08 Katsumi Yamaoka <yamaoka@jpl.org>
2
3 * gnus-art.el (gnus-article-browse-html-parts): Always replace charset
4 in meta tag with the one the part specifies in its header.
5
12012-11-02 Stephen Eglen <S.J.Eglen@damtp.cam.ac.uk> 62012-11-02 Stephen Eglen <S.J.Eglen@damtp.cam.ac.uk>
2 7
3 * gnus-dired.el (gnus-dired-attach): Attach to last used message buffer 8 * gnus-dired.el (gnus-dired-attach): Attach to last used message buffer
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 6c827e070cb..edcd7da2ddd 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -2877,7 +2877,7 @@ message header will be added to the bodies of the \"text/html\" parts."
2877 ;; Add a meta html tag to specify charset and a header. 2877 ;; Add a meta html tag to specify charset and a header.
2878 (cond 2878 (cond
2879 (header 2879 (header
2880 (let (title eheader body hcharset coding force-charset) 2880 (let (title eheader body hcharset coding)
2881 (with-temp-buffer 2881 (with-temp-buffer
2882 (mm-enable-multibyte) 2882 (mm-enable-multibyte)
2883 (setq case-fold-search t) 2883 (setq case-fold-search t)
@@ -2900,8 +2900,7 @@ message header will be added to the bodies of the \"text/html\" parts."
2900 charset) 2900 charset)
2901 title (when title 2901 title (when title
2902 (mm-encode-coding-string title charset)) 2902 (mm-encode-coding-string title charset))
2903 body (mm-encode-coding-string content charset) 2903 body (mm-encode-coding-string content charset))
2904 force-charset t)
2905 (setq hcharset (mm-find-mime-charset-region (point-min) 2904 (setq hcharset (mm-find-mime-charset-region (point-min)
2906 (point-max))) 2905 (point-max)))
2907 (cond ((= (length hcharset) 1) 2906 (cond ((= (length hcharset) 1)
@@ -2932,8 +2931,7 @@ message header will be added to the bodies of the \"text/html\" parts."
2932 body (mm-encode-coding-string 2931 body (mm-encode-coding-string
2933 (mm-decode-coding-string 2932 (mm-decode-coding-string
2934 content body) 2933 content body)
2935 charset) 2934 charset))))
2936 force-charset t)))
2937 (setq charset hcharset 2935 (setq charset hcharset
2938 eheader (mm-encode-coding-string 2936 eheader (mm-encode-coding-string
2939 (buffer-string) coding) 2937 (buffer-string) coding)
@@ -2947,7 +2945,7 @@ message header will be added to the bodies of the \"text/html\" parts."
2947 (mm-disable-multibyte) 2945 (mm-disable-multibyte)
2948 (insert body) 2946 (insert body)
2949 (when charset 2947 (when charset
2950 (mm-add-meta-html-tag handle charset force-charset)) 2948 (mm-add-meta-html-tag handle charset t))
2951 (when title 2949 (when title
2952 (goto-char (point-min)) 2950 (goto-char (point-min))
2953 (unless (search-forward "<title>" nil t) 2951 (unless (search-forward "<title>" nil t)
diff --git a/lisp/help.el b/lisp/help.el
index 449818207b3..de2a22714f9 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -979,7 +979,7 @@ buffer, and should return a positive integer. At the time the
979function is called, the window to be resized is selected." 979function is called, the window to be resized is selected."
980 :type '(choice integer function) 980 :type '(choice integer function)
981 :group 'help 981 :group 'help
982 :version "24.2") 982 :version "24.3")
983 983
984(define-minor-mode temp-buffer-resize-mode 984(define-minor-mode temp-buffer-resize-mode
985 "Toggle auto-resizing temporary buffer windows (Temp Buffer Resize Mode). 985 "Toggle auto-resizing temporary buffer windows (Temp Buffer Resize Mode).
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index c9dcff41618..72ca189e9d5 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -632,10 +632,13 @@ directory, like `default-directory'."
632 '(menu-item "Disable all filtering" ibuffer-filter-disable 632 '(menu-item "Disable all filtering" ibuffer-filter-disable
633 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers))) 633 :enable (and (featurep 'ibuf-ext) ibuffer-filtering-qualifiers)))
634 (define-key-after map [menu-bar view filter filter-by-mode] 634 (define-key-after map [menu-bar view filter filter-by-mode]
635 '(menu-item "Add filter by major mode..." ibuffer-filter-by-mode)) 635 '(menu-item "Add filter by any major mode..." ibuffer-filter-by-mode))
636 (define-key-after map [menu-bar view filter filter-by-mode] 636 (define-key-after map [menu-bar view filter filter-by-used-mode]
637 '(menu-item "Add filter by major mode in use..." 637 '(menu-item "Add filter by a major mode in use..."
638 ibuffer-filter-by-used-mode)) 638 ibuffer-filter-by-used-mode))
639 (define-key-after map [menu-bar view filter filter-by-derived-mode]
640 '(menu-item "Add filter by derived mode..."
641 ibuffer-filter-by-derived-mode))
639 (define-key-after map [menu-bar view filter filter-by-name] 642 (define-key-after map [menu-bar view filter filter-by-name]
640 '(menu-item "Add filter by buffer name..." ibuffer-filter-by-name)) 643 '(menu-item "Add filter by buffer name..." ibuffer-filter-by-name))
641 (define-key-after map [menu-bar view filter filter-by-filename] 644 (define-key-after map [menu-bar view filter filter-by-filename]
@@ -2438,8 +2441,9 @@ Marking commands:
2438 2441
2439Filtering commands: 2442Filtering commands:
2440 2443
2441 '\\[ibuffer-filter-by-mode]' - Add a filter by major mode. 2444 '\\[ibuffer-filter-by-mode]' - Add a filter by any major mode.
2442 '\\[ibuffer-filter-by-used-mode]' - Add a filter by major mode now in use. 2445 '\\[ibuffer-filter-by-used-mode]' - Add a filter by a major mode now in use.
2446 '\\[ibuffer-filter-by-derived-mode]' - Add a filter by derived mode.
2443 '\\[ibuffer-filter-by-name]' - Add a filter by buffer name. 2447 '\\[ibuffer-filter-by-name]' - Add a filter by buffer name.
2444 '\\[ibuffer-filter-by-content]' - Add a filter by buffer content. 2448 '\\[ibuffer-filter-by-content]' - Add a filter by buffer content.
2445 '\\[ibuffer-filter-by-filename]' - Add a filter by filename. 2449 '\\[ibuffer-filter-by-filename]' - Add a filter by filename.
diff --git a/lisp/ido.el b/lisp/ido.el
index 4ab183b3207..f4f9c27c847 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -3764,7 +3764,11 @@ This is to make them appear as if they were \"virtual buffers\"."
3764 ido-enable-flex-matching 3764 ido-enable-flex-matching
3765 (> (length ido-text) 1) 3765 (> (length ido-text) 1)
3766 (not ido-enable-regexp)) 3766 (not ido-enable-regexp))
3767 (setq re (mapconcat #'regexp-quote (split-string ido-text "") ".*")) 3767 (setq re (concat (regexp-quote (string (aref ido-text 0)))
3768 (mapconcat (lambda (c)
3769 (concat "[^" (string c) "]*"
3770 (regexp-quote (string c))))
3771 (substring ido-text 1) "")))
3768 (if ido-enable-prefix 3772 (if ido-enable-prefix
3769 (setq re (concat "\\`" re))) 3773 (setq re (concat "\\`" re)))
3770 (mapc 3774 (mapc
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index 0066847e995..1d9d098e71c 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -60,10 +60,6 @@
60 60
61;; User options end here. 61;; User options end here.
62 62
63(defvar report-emacs-bug-tracker-url "http://debbugs.gnu.org/cgi/"
64 "Base URL of the GNU bugtracker.
65Used for querying duplicates and linking to existing bugs.")
66
67(defvar report-emacs-bug-orig-text nil 63(defvar report-emacs-bug-orig-text nil
68 "The automatically-created initial text of the bug report.") 64 "The automatically-created initial text of the bug report.")
69 65
@@ -444,90 +440,6 @@ and send the mail again%s."
444 (delete-region pos (field-end (1+ pos))))))) 440 (delete-region pos (field-end (1+ pos)))))))
445 441
446 442
447;; Querying the bug database
448
449(defvar report-emacs-bug-bug-alist nil)
450(make-variable-buffer-local 'report-emacs-bug-bug-alist)
451(defvar report-emacs-bug-choice-widget nil)
452(make-variable-buffer-local 'report-emacs-bug-choice-widget)
453
454(defun report-emacs-bug-create-existing-bugs-buffer (bugs keywords)
455 (switch-to-buffer (get-buffer-create "*Existing Emacs Bugs*"))
456 (setq buffer-read-only t)
457 (let ((inhibit-read-only t))
458 (erase-buffer)
459 (setq report-emacs-bug-bug-alist bugs)
460 (widget-insert (propertize (concat "Already known bugs ("
461 keywords "):\n\n")
462 'face 'bold))
463 (if bugs
464 (setq report-emacs-bug-choice-widget
465 (apply 'widget-create 'radio-button-choice
466 :value (caar bugs)
467 (let (items)
468 (dolist (bug bugs)
469 (push (list
470 'url-link
471 :format (concat "Bug#" (number-to-string (nth 2 bug))
472 ": " (cadr bug) "\n %[%v%]\n")
473 ;; FIXME: Why is only the link of the
474 ;; active item clickable?
475 (car bug))
476 items))
477 (nreverse items))))
478 (widget-insert "No bugs matching your keywords found.\n"))
479 (widget-insert "\n")
480 (widget-create 'push-button
481 :notify (lambda (&rest ignore)
482 ;; TODO: Do something!
483 (message "Reporting new bug!"))
484 "Report new bug")
485 (when bugs
486 (widget-insert " ")
487 (widget-create 'push-button
488 :notify (lambda (&rest ignore)
489 (let ((val (widget-value report-emacs-bug-choice-widget)))
490 ;; TODO: Do something!
491 (message "Appending to bug %s!"
492 (nth 2 (assoc val report-emacs-bug-bug-alist)))))
493 "Append to chosen bug"))
494 (widget-insert " ")
495 (widget-create 'push-button
496 :notify (lambda (&rest ignore)
497 (kill-buffer))
498 "Quit reporting bug")
499 (widget-insert "\n"))
500 (use-local-map widget-keymap)
501 (widget-setup)
502 (goto-char (point-min)))
503
504(defun report-emacs-bug-parse-query-results (status keywords)
505 (goto-char (point-min))
506 (let (buglist)
507 (while (re-search-forward "<a href=\"bugreport\\.cgi\\?bug=\\([[:digit:]]+\\)\">\\([^<]+\\)</a>" nil t)
508 (let ((number (match-string 1))
509 (subject (match-string 2)))
510 (when (not (string-match "^#" subject))
511 (push (list
512 ;; first the bug URL
513 (concat report-emacs-bug-tracker-url
514 "bugreport.cgi?bug=" number)
515 ;; then the subject and number
516 subject (string-to-number number))
517 buglist))))
518 (report-emacs-bug-create-existing-bugs-buffer (nreverse buglist) keywords)))
519
520;;;###autoload
521(defun report-emacs-bug-query-existing-bugs (keywords)
522 "Query for KEYWORDS at `report-emacs-bug-tracker-url', and return the result.
523The result is an alist with items of the form (URL SUBJECT NO)."
524 (interactive "sBug keywords (comma separated): ")
525 (url-retrieve (concat report-emacs-bug-tracker-url
526 "pkgreport.cgi?include=subject%3A"
527 (replace-regexp-in-string "[[:space:]]+" "+" keywords)
528 ";package=emacs")
529 'report-emacs-bug-parse-query-results (list keywords)))
530
531(provide 'emacsbug) 443(provide 'emacsbug)
532 444
533;;; emacsbug.el ends here 445;;; emacsbug.el ends here
diff --git a/lisp/minibuf-eldef.el b/lisp/minibuf-eldef.el
index 92d5ec821b0..950c28b227f 100644
--- a/lisp/minibuf-eldef.el
+++ b/lisp/minibuf-eldef.el
@@ -33,13 +33,25 @@
33 33
34;;; Code: 34;;; Code:
35 35
36(defvar minibuffer-eldef-shorten-default nil 36(defvar minibuffer-eldef-shorten-default)
37 "If non-nil, shorten \"(default ...)\" to \"[...]\" in minibuffer prompts.")
38 37
39(defvar minibuffer-default-in-prompt-regexps 38(defun minibuffer-default--in-prompt-regexps ()
40 `(("\\( (default\\(?: is\\)? \\(.*\\))\\):? \\'" 39 `(("\\( (default\\(?: is\\)? \\(.*\\))\\):? \\'"
41 1 ,(if minibuffer-eldef-shorten-default " [\\2]")) 40 1 ,(if minibuffer-eldef-shorten-default " [\\2]"))
42 ("\\( \\[.*\\]\\):? *\\'" 1)) 41 ("\\( \\[.*\\]\\):? *\\'" 1)))
42
43(defcustom minibuffer-eldef-shorten-default nil
44 "If non-nil, shorten \"(default ...)\" to \"[...]\" in minibuffer prompts."
45 :set (lambda (symbol value)
46 (set-default symbol value)
47 (setq-default minibuffer-default-in-prompt-regexps
48 (minibuffer-default--in-prompt-regexps)))
49 :type 'boolean
50 :group 'minibuffer
51 :version "24.3")
52
53(defvar minibuffer-default-in-prompt-regexps
54 (minibuffer-default--in-prompt-regexps)
43 "A list of regexps matching the parts of minibuffer prompts showing defaults. 55 "A list of regexps matching the parts of minibuffer prompts showing defaults.
44When `minibuffer-electric-default-mode' is active, these regexps are 56When `minibuffer-electric-default-mode' is active, these regexps are
45used to identify the portions of prompts to elide. 57used to identify the portions of prompts to elide.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 38347f23f7d..6e704fad807 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -51,6 +51,9 @@
51 51
52;;; Todo: 52;;; Todo:
53 53
54;; - Make *Completions* readable even if some of the completion
55;; entries have LF chars or spaces in them (including at
56;; beginning/end) or are very long.
54;; - for M-x, cycle-sort commands that have no key binding first. 57;; - for M-x, cycle-sort commands that have no key binding first.
55;; - Make things like icomplete-mode or lightning-completion work with 58;; - Make things like icomplete-mode or lightning-completion work with
56;; completion-in-region-mode. 59;; completion-in-region-mode.
@@ -74,6 +77,9 @@
74;; - whether the user wants completion to pay attention to case. 77;; - whether the user wants completion to pay attention to case.
75;; e.g. we may want to make it possible for the user to say "first try 78;; e.g. we may want to make it possible for the user to say "first try
76;; completion case-sensitively, and if that fails, try to ignore case". 79;; completion case-sensitively, and if that fails, try to ignore case".
80;; Maybe the trick is that we should distinguish completion-ignore-case in
81;; try/all-completions (obey user's preference) from its use in
82;; test-completion (obey the underlying object's semantics).
77 83
78;; - add support for ** to pcm. 84;; - add support for ** to pcm.
79;; - Add vc-file-name-completion-table to read-file-name-internal. 85;; - Add vc-file-name-completion-table to read-file-name-internal.
@@ -2048,6 +2054,8 @@ This is only used when the minibuffer area has no active minibuffer.")
2048 process-environment)) 2054 process-environment))
2049 2055
2050(defconst completion--embedded-envvar-re 2056(defconst completion--embedded-envvar-re
2057 ;; We can't reuse env--substitute-vars-regexp because we need to match only
2058 ;; potentially-unfinished envvars at end of string.
2051 (concat "\\(?:^\\|[^$]\\(?:\\$\\$\\)*\\)" 2059 (concat "\\(?:^\\|[^$]\\(?:\\$\\$\\)*\\)"
2052 "$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'")) 2060 "$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'"))
2053 2061
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 874c0aa7fef..caaae5d553e 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1748,20 +1748,26 @@ value of `default-file-modes', without execute permissions."
1748 (or (file-modes filename) 1748 (or (file-modes filename)
1749 (logand (default-file-modes) (tramp-compat-octal-to-decimal "0666")))) 1749 (logand (default-file-modes) (tramp-compat-octal-to-decimal "0666"))))
1750 1750
1751(defun tramp-replace-environment-variables (filename) 1751(defalias 'tramp-replace-environment-variables
1752 "Replace environment variables in FILENAME. 1752 (if (ignore-errors
1753 (equal "${ tramp?}" (substitute-env-vars "${ tramp?}" 'only-defined)))
1754 (lambda (filename)
1755 "Like `substitute-env-vars' with `only-defined' non-nil."
1756 (substitute-env-vars filename 'only-defined))
1757 (lambda (filename)
1758 "Replace environment variables in FILENAME.
1753Return the string with the replaced variables." 1759Return the string with the replaced variables."
1754 (save-match-data 1760 (save-match-data
1755 (let ((idx (string-match "$\\(\\w+\\)" filename))) 1761 (let ((idx (string-match "$\\(\\w+\\)" filename)))
1756 ;; `$' is coded as `$$'. 1762 ;; `$' is coded as `$$'.
1757 (when (and idx 1763 (when (and idx
1758 (or (zerop idx) (not (eq ?$ (aref filename (1- idx))))) 1764 (or (zerop idx) (not (eq ?$ (aref filename (1- idx)))))
1759 (getenv (match-string 1 filename))) 1765 (getenv (match-string 1 filename)))
1760 (setq filename 1766 (setq filename
1761 (replace-match 1767 (replace-match
1762 (substitute-in-file-name (match-string 0 filename)) 1768 (substitute-in-file-name (match-string 0 filename))
1763 t nil filename))) 1769 t nil filename)))
1764 filename))) 1770 filename)))))
1765 1771
1766;; In XEmacs, electricity is implemented via a key map for ?/ and ?~, 1772;; In XEmacs, electricity is implemented via a key map for ?/ and ?~,
1767;; which calls corresponding functions (see minibuf.el). 1773;; which calls corresponding functions (see minibuf.el).
diff --git a/lisp/notifications.el b/lisp/notifications.el
index 792298c26b7..6f477eb4cdd 100644
--- a/lisp/notifications.el
+++ b/lisp/notifications.el
@@ -66,6 +66,9 @@
66(defconst notifications-get-capabilities-method "GetCapabilities" 66(defconst notifications-get-capabilities-method "GetCapabilities"
67 "D-Bus notifications get capabilities method.") 67 "D-Bus notifications get capabilities method.")
68 68
69(defconst notifications-get-server-information-method "GetServerInformation"
70 "D-Bus notifications get server information method.")
71
69(defconst notifications-action-signal "ActionInvoked" 72(defconst notifications-action-signal "ActionInvoked"
70 "D-Bus notifications action signal.") 73 "D-Bus notifications action signal.")
71 74
@@ -349,7 +352,7 @@ BUS can be a string denoting a D-Bus connection, the default is `:session'."
349(defvar dbus-debug) ; used in the macroexpansion of dbus-ignore-errors 352(defvar dbus-debug) ; used in the macroexpansion of dbus-ignore-errors
350 353
351(defun notifications-get-capabilities (&optional bus) 354(defun notifications-get-capabilities (&optional bus)
352 "Return the capabilities of the notification server, a list of strings. 355 "Return the capabilities of the notification server, a list of symbols.
353BUS can be a string denoting a D-Bus connection, the default is `:session'. 356BUS can be a string denoting a D-Bus connection, the default is `:session'.
354The following capabilities can be expected: 357The following capabilities can be expected:
355 358
@@ -371,12 +374,34 @@ The following capabilities can be expected:
371 374
372Further vendor-specific caps start with `:x-vendor', like `:x-gnome-foo-cap'." 375Further vendor-specific caps start with `:x-vendor', like `:x-gnome-foo-cap'."
373 (dbus-ignore-errors 376 (dbus-ignore-errors
374 (mapcar 377 (mapcar
375 (lambda (x) (intern (concat ":" x))) 378 (lambda (x) (intern (concat ":" x)))
379 (dbus-call-method (or bus :session)
380 notifications-service
381 notifications-path
382 notifications-interface
383 notifications-get-capabilities-method))))
384
385(defun notifications-get-server-information (&optional bus)
386 "Return information on the notification server, a list of strings.
387BUS can be a string denoting a D-Bus connection, the default is `:session'.
388The returned list is (NAME VENDOR VERSION SPEC-VERSION).
389
390 NAME The product name of the server.
391 VENDOR The vendor name. For example, \"KDE\", \"GNOME\".
392 VERSION The server's version number.
393 SPEC-VERSION The specification version the server is compliant with.
394
395If SPEC_VERSION is missing, the server supports a specification
396prior to \"1.0\".
397
398See `notifications-specification-version' for the specification
399version this library is compliant with."
400 (dbus-ignore-errors
376 (dbus-call-method (or bus :session) 401 (dbus-call-method (or bus :session)
377 notifications-service 402 notifications-service
378 notifications-path 403 notifications-path
379 notifications-interface 404 notifications-interface
380 notifications-get-capabilities-method)))) 405 notifications-get-server-information-method)))
381 406
382(provide 'notifications) 407(provide 'notifications)
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 2614af9ffa4..5ba84f8991e 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -764,25 +764,39 @@ line number outside the file being compiled."
764 (and (overlayp ov) (overlay-get ov 'flymake-overlay))) 764 (and (overlayp ov) (overlay-get ov 'flymake-overlay)))
765 765
766(defcustom flymake-error-bitmap '(exclamation-mark error) 766(defcustom flymake-error-bitmap '(exclamation-mark error)
767 "Bitmap used in the fringe for indicating errors. 767 "Bitmap (a symbol) used in the fringe for indicating errors.
768The value may also be a list of two elements where the second 768The value may also be a list of two elements where the second
769element specifies the face for the bitmap." 769element specifies the face for the bitmap. For possible bitmap
770symbols, see `fringe-bitmaps'. See also `flymake-warning-bitmap'.
771
772The option `flymake-fringe-indicator-position' controls how and where
773this is used."
770 :group 'flymake 774 :group 'flymake
771 :version "24.3" 775 :version "24.3"
772 :type 'symbol) 776 :type '(choice (symbol :tag "Bitmap")
777 (list :tag "Bitmap and face"
778 (symbol :tag "Bitmap")
779 (face :tag "Face"))))
773 780
774(defcustom flymake-warning-bitmap 'question-mark 781(defcustom flymake-warning-bitmap 'question-mark
775 "Bitmap used in the fringe for indicating warnings. 782 "Bitmap (a symbol) used in the fringe for indicating warnings.
776The value may also be a list of two elements where the second 783The value may also be a list of two elements where the second
777element specifies the face for the bitmap." 784element specifies the face for the bitmap. For possible bitmap
785symbols, see `fringe-bitmaps'. See also `flymake-error-bitmap'.
786
787The option `flymake-fringe-indicator-position' controls how and where
788this is used."
778 :group 'flymake 789 :group 'flymake
779 :version "24.3" 790 :version "24.3"
780 :type 'symbol) 791 :type '(choice (symbol :tag "Bitmap")
792 (list :tag "Bitmap and face"
793 (symbol :tag "Bitmap")
794 (face :tag "Face"))))
781 795
782(defcustom flymake-fringe-indicator-position 'left-fringe 796(defcustom flymake-fringe-indicator-position 'left-fringe
783 "The position to put flymake fringe indicator. 797 "The position to put flymake fringe indicator.
784The value can be nil, left-fringe or right-fringe. 798The value can be nil (do not use indicators), `left-fringe' or `right-fringe'.
785Fringe indicators are disabled if nil." 799See `flymake-error-bitmap' and `flymake-warning-bitmap'."
786 :group 'flymake 800 :group 'flymake
787 :version "24.3" 801 :version "24.3"
788 :type '(choice (const left-fringe) 802 :type '(choice (const left-fringe)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index d954cd53e0a..33ef7607671 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1823,22 +1823,31 @@ nil."
1823 1823
1824;;; Filling 1824;;; Filling
1825 1825
1826(defvar js--filling-paragraph nil)
1827
1828;; FIXME: Such redefinitions are bad style. We should try and use some other
1829;; way to get the same result.
1830(defadvice c-forward-sws (around js-fill-paragraph activate)
1831 (if js--filling-paragraph
1832 (setq ad-return-value (js--forward-syntactic-ws (ad-get-arg 0)))
1833 ad-do-it))
1834
1835(defadvice c-backward-sws (around js-fill-paragraph activate)
1836 (if js--filling-paragraph
1837 (setq ad-return-value (js--backward-syntactic-ws (ad-get-arg 0)))
1838 ad-do-it))
1839
1840(defadvice c-beginning-of-macro (around js-fill-paragraph activate)
1841 (if js--filling-paragraph
1842 (setq ad-return-value (js--beginning-of-macro (ad-get-arg 0)))
1843 ad-do-it))
1844
1826(defun js-c-fill-paragraph (&optional justify) 1845(defun js-c-fill-paragraph (&optional justify)
1827 "Fill the paragraph with `c-fill-paragraph'." 1846 "Fill the paragraph with `c-fill-paragraph'."
1828 (interactive "*P") 1847 (interactive "*P")
1829 ;; FIXME: Such redefinitions are bad style. We should try and use some other 1848 (let ((js--filling-paragraph t)
1830 ;; way to get the same result. 1849 (fill-paragraph-function 'c-fill-paragraph))
1831 (cl-letf (((symbol-function 'c-forward-sws) 1850 (c-fill-paragraph justify)))
1832 (lambda (&optional limit)
1833 (js--forward-syntactic-ws limit)))
1834 ((symbol-function 'c-backward-sws)
1835 (lambda (&optional limit)
1836 (js--backward-syntactic-ws limit)))
1837 ((symbol-function 'c-beginning-of-macro)
1838 (lambda (&optional limit)
1839 (js--beginning-of-macro limit))))
1840 (let ((fill-paragraph-function 'c-fill-paragraph))
1841 (c-fill-paragraph justify))))
1842 1851
1843;;; Type database and Imenu 1852;;; Type database and Imenu
1844 1853
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index 3dd9a48bb33..d2f7fc7a059 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -1,4 +1,4 @@
1;;; perl-mode.el --- Perl code editing commands for GNU Emacs 1;;; perl-mode.el --- Perl code editing commands for GNU Emacs -*- coding: utf-8 -*-
2 2
3;; Copyright (C) 1990, 1994, 2001-2012 Free Software Foundation, Inc. 3;; Copyright (C) 1990, 1994, 2001-2012 Free Software Foundation, Inc.
4 4
@@ -102,11 +102,6 @@
102 102
103;;; Code: 103;;; Code:
104 104
105
106(defvar font-lock-comment-face)
107(defvar font-lock-doc-face)
108(defvar font-lock-string-face)
109
110(defgroup perl nil 105(defgroup perl nil
111 "Major mode for editing Perl code." 106 "Major mode for editing Perl code."
112 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) 107 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
@@ -119,16 +114,11 @@
119 114
120(defvar perl-mode-map 115(defvar perl-mode-map
121 (let ((map (make-sparse-keymap))) 116 (let ((map (make-sparse-keymap)))
122 (define-key map "{" 'perl-electric-terminator)
123 (define-key map "}" 'perl-electric-terminator)
124 (define-key map ";" 'perl-electric-terminator)
125 (define-key map ":" 'perl-electric-terminator)
126 (define-key map "\e\C-a" 'perl-beginning-of-function) 117 (define-key map "\e\C-a" 'perl-beginning-of-function)
127 (define-key map "\e\C-e" 'perl-end-of-function) 118 (define-key map "\e\C-e" 'perl-end-of-function)
128 (define-key map "\e\C-h" 'perl-mark-function) 119 (define-key map "\e\C-h" 'perl-mark-function)
129 (define-key map "\e\C-q" 'perl-indent-exp) 120 (define-key map "\e\C-q" 'perl-indent-exp)
130 (define-key map "\177" 'backward-delete-char-untabify) 121 (define-key map "\177" 'backward-delete-char-untabify)
131 (define-key map "\t" 'perl-indent-command)
132 map) 122 map)
133 "Keymap used in Perl mode.") 123 "Keymap used in Perl mode.")
134 124
@@ -158,16 +148,54 @@
158 148
159(defvar perl-imenu-generic-expression 149(defvar perl-imenu-generic-expression
160 '(;; Functions 150 '(;; Functions
161 (nil "^sub\\s-+\\([-A-Za-z0-9+_:]+\\)" 1) 151 (nil "^[ \t]*sub\\s-+\\([-A-Za-z0-9+_:]+\\)" 1)
162 ;;Variables 152 ;;Variables
163 ("Variables" "^\\(?:my\\|our\\)\\s-+\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1) 153 ("Variables" "^\\(?:my\\|our\\)\\s-+\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1)
164 ("Packages" "^package\\s-+\\([-A-Za-z0-9+_:]+\\);" 1) 154 ("Packages" "^[ \t]*package\\s-+\\([-A-Za-z0-9+_:]+\\);" 1)
165 ("Doc sections" "^=head[0-9][ \t]+\\(.*\\)" 1)) 155 ("Doc sections" "^=head[0-9][ \t]+\\(.*\\)" 1))
166 "Imenu generic expression for Perl mode. See `imenu-generic-expression'.") 156 "Imenu generic expression for Perl mode. See `imenu-generic-expression'.")
167 157
168;; Regexps updated with help from Tom Tromey <tromey@cambric.colorado.edu> and 158;; Regexps updated with help from Tom Tromey <tromey@cambric.colorado.edu> and
169;; Jim Campbell <jec@murzim.ca.boeing.com>. 159;; Jim Campbell <jec@murzim.ca.boeing.com>.
170 160
161(defcustom perl-prettify-symbols t
162 "If non-nil, some symbols will be displayed using Unicode chars."
163 :type 'boolean)
164
165(defconst perl--prettify-symbols-alist
166 '(;;("andalso" . ?∧) ("orelse" . ?∨) ("as" . ?≡)("not" . ?¬)
167 ;;("div" . ?÷) ("*" . ?×) ("o" . ?○)
168 ("->" . ?→)
169 ("=>" . ?⇒)
170 ;;("<-" . ?â†) ("<>" . ?≠) (">=" . ?≥) ("<=" . ?≤) ("..." . ?⋯)
171 ("::" . ?∷)
172 ))
173
174(defun perl--font-lock-compose-symbol ()
175 "Compose a sequence of ascii chars into a symbol.
176Regexp match data 0 points to the chars."
177 ;; Check that the chars should really be composed into a symbol.
178 (let* ((start (match-beginning 0))
179 (end (match-end 0))
180 (syntaxes (if (eq (char-syntax (char-after start)) ?w)
181 '(?w) '(?. ?\\))))
182 (if (or (memq (char-syntax (or (char-before start) ?\ )) syntaxes)
183 (memq (char-syntax (or (char-after end) ?\ )) syntaxes)
184 (nth 8 (syntax-ppss)))
185 ;; No composition for you. Let's actually remove any composition
186 ;; we may have added earlier and which is now incorrect.
187 (remove-text-properties start end '(composition))
188 ;; That's a symbol alright, so add the composition.
189 (compose-region start end (cdr (assoc (match-string 0)
190 perl--prettify-symbols-alist)))))
191 ;; Return nil because we're not adding any face property.
192 nil)
193
194(defun perl--font-lock-symbols-keywords ()
195 (when perl-prettify-symbols
196 `((,(regexp-opt (mapcar 'car perl--prettify-symbols-alist) t)
197 (0 (perl--font-lock-compose-symbol))))))
198
171(defconst perl-font-lock-keywords-1 199(defconst perl-font-lock-keywords-1
172 '(;; What is this for? 200 '(;; What is this for?
173 ;;("\\(--- .* ---\\|=== .* ===\\)" . font-lock-string-face) 201 ;;("\\(--- .* ---\\|=== .* ===\\)" . font-lock-string-face)
@@ -190,32 +218,32 @@
190 "Subdued level highlighting for Perl mode.") 218 "Subdued level highlighting for Perl mode.")
191 219
192(defconst perl-font-lock-keywords-2 220(defconst perl-font-lock-keywords-2
193 (append perl-font-lock-keywords-1 221 (append
194 (list 222 perl-font-lock-keywords-1
195 ;; 223 `( ;; Fontify keywords, except those fontified otherwise.
196 ;; Fontify keywords, except those fontified otherwise. 224 ,(concat "\\<"
197 (concat "\\<" 225 (regexp-opt '("if" "until" "while" "elsif" "else" "unless"
198 (regexp-opt '("if" "until" "while" "elsif" "else" "unless" 226 "do" "dump" "for" "foreach" "exit" "die"
199 "do" "dump" "for" "foreach" "exit" "die" 227 "BEGIN" "END" "return" "exec" "eval") t)
200 "BEGIN" "END" "return" "exec" "eval") t) 228 "\\>")
201 "\\>") 229 ;;
202 ;; 230 ;; Fontify local and my keywords as types.
203 ;; Fontify local and my keywords as types. 231 ("\\<\\(local\\|my\\)\\>" . font-lock-type-face)
204 '("\\<\\(local\\|my\\)\\>" . font-lock-type-face) 232 ;;
205 ;; 233 ;; Fontify function, variable and file name references.
206 ;; Fontify function, variable and file name references. 234 ("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face)
207 '("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face) 235 ;; Additionally underline non-scalar variables. Maybe this is a bad idea.
208 ;; Additionally underline non-scalar variables. Maybe this is a bad idea. 236 ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face)
209 ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face) 237 ("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
210 '("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face) 238 ("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
211 '("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
212 (2 (cons font-lock-variable-name-face '(underline)))) 239 (2 (cons font-lock-variable-name-face '(underline))))
213 '("<\\(\\sw+\\)>" 1 font-lock-constant-face) 240 ("<\\(\\sw+\\)>" 1 font-lock-constant-face)
214 ;; 241 ;;
215 ;; Fontify keywords with/and labels as we do in `c++-font-lock-keywords'. 242 ;; Fontify keywords with/and labels as we do in `c++-font-lock-keywords'.
216 '("\\<\\(continue\\|goto\\|last\\|next\\|redo\\)\\>[ \t]*\\(\\sw+\\)?" 243 ("\\<\\(continue\\|goto\\|last\\|next\\|redo\\)\\>[ \t]*\\(\\sw+\\)?"
217 (1 font-lock-keyword-face) (2 font-lock-constant-face nil t)) 244 (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
218 '("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-constant-face))) 245 ("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-constant-face)
246 ,@(perl--font-lock-symbols-keywords)))
219 "Gaudy level highlighting for Perl mode.") 247 "Gaudy level highlighting for Perl mode.")
220 248
221(defvar perl-font-lock-keywords perl-font-lock-keywords-1 249(defvar perl-font-lock-keywords perl-font-lock-keywords-1
@@ -543,8 +571,10 @@ create a new comment."
543 571
544(defun perl-outline-level () 572(defun perl-outline-level ()
545 (cond 573 (cond
546 ((looking-at "package\\s-") 0) 574 ((looking-at "[ \t]*\\(package\\)\\s-")
547 ((looking-at "sub\\s-") 1) 575 (- (match-beginning 1) (match-beginning 0)))
576 ((looking-at "[ \t]*s\\(ub\\)\\s-")
577 (- (match-beginning 1) (match-beginning 0)))
548 ((looking-at "=head[0-9]") (- (char-before (match-end 0)) ?0)) 578 ((looking-at "=head[0-9]") (- (char-before (match-end 0)) ?0))
549 ((looking-at "=cut") 1) 579 ((looking-at "=cut") 1)
550 (t 3))) 580 (t 3)))
@@ -621,6 +651,11 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'."
621 #'perl-syntax-propertize-function) 651 #'perl-syntax-propertize-function)
622 (add-hook 'syntax-propertize-extend-region-functions 652 (add-hook 'syntax-propertize-extend-region-functions
623 #'syntax-propertize-multiline 'append 'local) 653 #'syntax-propertize-multiline 'append 'local)
654 ;; Electricity.
655 ;; FIXME: setup electric-layout-rules.
656 (set (make-local-variable 'electric-indent-chars)
657 (append '(?\{ ?\} ?\; ?\:) electric-indent-chars))
658 (add-hook 'electric-indent-functions #'perl-electric-noindent-p nil t)
624 ;; Tell imenu how to handle Perl. 659 ;; Tell imenu how to handle Perl.
625 (set (make-local-variable 'imenu-generic-expression) 660 (set (make-local-variable 'imenu-generic-expression)
626 perl-imenu-generic-expression) 661 perl-imenu-generic-expression)
@@ -637,7 +672,11 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'."
637 0 ;Existing comment at bol stays there. 672 0 ;Existing comment at bol stays there.
638 comment-column)) 673 comment-column))
639 674
640(defalias 'electric-perl-terminator 'perl-electric-terminator) 675(define-obsolete-function-alias 'electric-perl-terminator
676 'perl-electric-terminator "22.1")
677(defun perl-electric-noindent-p (char)
678 (unless (eolp) 'no-indent))
679
641(defun perl-electric-terminator (arg) 680(defun perl-electric-terminator (arg)
642 "Insert character and maybe adjust indentation. 681 "Insert character and maybe adjust indentation.
643If at end-of-line, and not in a comment or a quote, correct the indentation." 682If at end-of-line, and not in a comment or a quote, correct the indentation."
@@ -661,6 +700,7 @@ If at end-of-line, and not in a comment or a quote, correct the indentation."
661 (perl-indent-line) 700 (perl-indent-line)
662 (delete-char -1)))) 701 (delete-char -1))))
663 (self-insert-command (prefix-numeric-value arg))) 702 (self-insert-command (prefix-numeric-value arg)))
703(make-obsolete 'perl-electric-terminator 'electric-indent-mode "24.4")
664 704
665;; not used anymore, but may be useful someday: 705;; not used anymore, but may be useful someday:
666;;(defun perl-inside-parens-p () 706;;(defun perl-inside-parens-p ()
@@ -744,6 +784,7 @@ following list:
744 (t 784 (t
745 (message "Use backslash to quote # characters.") 785 (message "Use backslash to quote # characters.")
746 (ding t))))))))) 786 (ding t)))))))))
787(make-obsolete 'perl-indent-command 'indent-according-to-mode "24.4")
747 788
748(defun perl-indent-line (&optional nochange parse-start) 789(defun perl-indent-line (&optional nochange parse-start)
749 "Indent current line as Perl code. 790 "Indent current line as Perl code.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ee98feaef5e..949b0252bf1 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1074,12 +1074,9 @@ automatically if needed."
1074The name of the defun should be grouped so it can be retrieved 1074The name of the defun should be grouped so it can be retrieved
1075via `match-string'.") 1075via `match-string'.")
1076 1076
1077(defun python-nav-beginning-of-defun (&optional arg) 1077(defun python-nav--beginning-of-defun (&optional arg)
1078 "Move point to `beginning-of-defun'. 1078 "Internal implementation of `python-nav-beginning-of-defun'.
1079With positive ARG move search backwards. With negative do the 1079With positive ARG search backwards, else search forwards."
1080same but forward. When ARG is nil or 0 defaults to 1. This is
1081the main part of `python-beginning-of-defun-function'. Return
1082non-nil if point is moved to `beginning-of-defun'."
1083 (when (or (null arg) (= arg 0)) (setq arg 1)) 1080 (when (or (null arg) (= arg 0)) (setq arg 1))
1084 (let* ((re-search-fn (if (> arg 0) 1081 (let* ((re-search-fn (if (> arg 0)
1085 #'re-search-backward 1082 #'re-search-backward
@@ -1087,6 +1084,15 @@ non-nil if point is moved to `beginning-of-defun'."
1087 (line-beg-pos (line-beginning-position)) 1084 (line-beg-pos (line-beginning-position))
1088 (line-content-start (+ line-beg-pos (current-indentation))) 1085 (line-content-start (+ line-beg-pos (current-indentation)))
1089 (pos (point-marker)) 1086 (pos (point-marker))
1087 (beg-indentation
1088 (and (> arg 0)
1089 (save-excursion
1090 (and (python-info-current-line-empty-p)
1091 (python-util-forward-comment -1))
1092 (python-nav-beginning-of-statement)
1093 (if (python-info-looking-at-beginning-of-defun)
1094 (+ (current-indentation) python-indent-offset)
1095 (current-indentation)))))
1090 (found 1096 (found
1091 (progn 1097 (progn
1092 (when (and (< arg 0) 1098 (when (and (< arg 0)
@@ -1094,7 +1100,12 @@ non-nil if point is moved to `beginning-of-defun'."
1094 (end-of-line 1)) 1100 (end-of-line 1))
1095 (while (and (funcall re-search-fn 1101 (while (and (funcall re-search-fn
1096 python-nav-beginning-of-defun-regexp nil t) 1102 python-nav-beginning-of-defun-regexp nil t)
1097 (python-syntax-context-type))) 1103 (or (python-syntax-context-type)
1104 ;; Handle nested defuns when moving
1105 ;; backwards by checking indentation.
1106 (and (> arg 0)
1107 (not (= (current-indentation) 0))
1108 (>= (current-indentation) beg-indentation)))))
1098 (and (python-info-looking-at-beginning-of-defun) 1109 (and (python-info-looking-at-beginning-of-defun)
1099 (or (not (= (line-number-at-pos pos) 1110 (or (not (= (line-number-at-pos pos)
1100 (line-number-at-pos))) 1111 (line-number-at-pos)))
@@ -1105,55 +1116,43 @@ non-nil if point is moved to `beginning-of-defun'."
1105 (or (beginning-of-line 1) t) 1116 (or (beginning-of-line 1) t)
1106 (and (goto-char pos) nil)))) 1117 (and (goto-char pos) nil))))
1107 1118
1108(defun python-beginning-of-defun-function (&optional arg) 1119(defun python-nav-beginning-of-defun (&optional arg)
1109 "Move point to the beginning of def or class. 1120 "Move point to `beginning-of-defun'.
1110With positive ARG move that number of functions backwards. With 1121With positive ARG search backwards else search forward. When ARG
1111negative do the same but forward. When ARG is nil or 0 defaults 1122is nil or 0 defaults to 1. When searching backwards nested
1112to 1. Return non-nil if point is moved to `beginning-of-defun'." 1123defuns are handled with care depending on current point
1124position. Return non-nil if point is moved to
1125`beginning-of-defun'."
1113 (when (or (null arg) (= arg 0)) (setq arg 1)) 1126 (when (or (null arg) (= arg 0)) (setq arg 1))
1114 (let ((found)) 1127 (let ((found))
1115 (cond ((and (eq this-command 'mark-defun) 1128 (cond ((and (eq this-command 'mark-defun)
1116 (python-info-looking-at-beginning-of-defun))) 1129 (python-info-looking-at-beginning-of-defun)))
1117 (t 1130 (t
1118 (dotimes (i (if (> arg 0) arg (- arg))) 1131 (dotimes (i (if (> arg 0) arg (- arg)))
1119 (when (and (python-nav-beginning-of-defun arg) 1132 (when (and (python-nav--beginning-of-defun arg)
1120 (not found)) 1133 (not found))
1121 (setq found t))))) 1134 (setq found t)))))
1122 found)) 1135 found))
1123 1136
1124(defun python-end-of-defun-function () 1137(defun python-nav-end-of-defun ()
1125 "Move point to the end of def or class. 1138 "Move point to the end of def or class.
1126Returns nil if point is not in a def or class." 1139Returns nil if point is not in a def or class."
1127 (interactive) 1140 (interactive)
1128 (let ((beg-defun-indent)) 1141 (let ((beg-defun-indent)
1142 (beg-pos (point)))
1129 (when (or (python-info-looking-at-beginning-of-defun) 1143 (when (or (python-info-looking-at-beginning-of-defun)
1130 (python-beginning-of-defun-function 1) 1144 (python-nav-beginning-of-defun 1)
1131 (python-beginning-of-defun-function -1)) 1145 (python-nav-beginning-of-defun -1))
1132 (setq beg-defun-indent (current-indentation)) 1146 (setq beg-defun-indent (current-indentation))
1147 (while (progn
1148 (python-nav-end-of-statement)
1149 (python-util-forward-comment 1)
1150 (and (> (current-indentation) beg-defun-indent)
1151 (not (eobp)))))
1152 (python-util-forward-comment -1)
1133 (forward-line 1) 1153 (forward-line 1)
1134 ;; Go as forward as possible 1154 ;; Ensure point moves forward.
1135 (while (and (or 1155 (and (> beg-pos (point)) (goto-char beg-pos)))))
1136 (python-nav-beginning-of-defun -1)
1137 (and (goto-char (point-max)) nil))
1138 (> (current-indentation) beg-defun-indent)))
1139 (beginning-of-line 1)
1140 ;; Go as backwards as possible
1141 (while (and (forward-line -1)
1142 (not (bobp))
1143 (or (not (current-word))
1144 (equal (char-after (+ (point) (current-indentation))) ?#)
1145 (<= (current-indentation) beg-defun-indent)
1146 (looking-at (python-rx decorator))
1147 (python-syntax-context-type))))
1148 (forward-line 1)
1149 ;; If point falls inside a paren or string context the point is
1150 ;; forwarded at the end of it (or end of buffer if its not closed)
1151 (let ((context-type (python-syntax-context-type)))
1152 (when (memq context-type '(paren string))
1153 ;; Slow but safe.
1154 (while (and (not (eobp))
1155 (python-syntax-context-type))
1156 (forward-line 1)))))))
1157 1156
1158(defun python-nav-beginning-of-statement () 1157(defun python-nav-beginning-of-statement ()
1159 "Move to start of current statement." 1158 "Move to start of current statement."
@@ -2022,7 +2021,7 @@ When argument ARG is non-nil do not include decorators."
2022 (python-shell-send-region 2021 (python-shell-send-region
2023 (progn 2022 (progn
2024 (end-of-line 1) 2023 (end-of-line 1)
2025 (while (and (or (python-beginning-of-defun-function) 2024 (while (and (or (python-nav-beginning-of-defun)
2026 (beginning-of-line 1)) 2025 (beginning-of-line 1))
2027 (> (current-indentation) 0))) 2026 (> (current-indentation) 0)))
2028 (when (not arg) 2027 (when (not arg)
@@ -2031,7 +2030,7 @@ When argument ARG is non-nil do not include decorators."
2031 (forward-line 1)) 2030 (forward-line 1))
2032 (point-marker)) 2031 (point-marker))
2033 (progn 2032 (progn
2034 (or (python-end-of-defun-function) 2033 (or (python-nav-end-of-defun)
2035 (end-of-line 1)) 2034 (end-of-line 1))
2036 (point-marker))))) 2035 (point-marker)))))
2037 2036
@@ -2879,38 +2878,40 @@ Optional argument INCLUDE-TYPE indicates to include the type of the defun.
2879This function is compatible to be used as 2878This function is compatible to be used as
2880`add-log-current-defun-function' since it returns nil if point is 2879`add-log-current-defun-function' since it returns nil if point is
2881not inside a defun." 2880not inside a defun."
2882 (let ((names '())
2883 (starting-indentation)
2884 (starting-point)
2885 (first-run t))
2886 (save-restriction 2881 (save-restriction
2887 (widen) 2882 (widen)
2888 (save-excursion 2883 (save-excursion
2889 (setq starting-point (point-marker))
2890 (setq starting-indentation (save-excursion
2891 (python-nav-beginning-of-statement)
2892 (current-indentation)))
2893 (end-of-line 1) 2884 (end-of-line 1)
2894 (while (python-beginning-of-defun-function 1) 2885 (let ((names)
2895 (when (or (< (current-indentation) starting-indentation) 2886 (starting-indentation
2896 (and first-run 2887 (save-excursion
2897 (< 2888 (and
2898 starting-point 2889 (python-nav-beginning-of-defun 1)
2899 (save-excursion 2890 ;; This extra number is just for checking code
2900 (python-end-of-defun-function) 2891 ;; against indentation to work well on first run.
2901 (point-marker))))) 2892 (+ (current-indentation) 4))))
2902 (setq first-run nil) 2893 (starting-point (point)))
2903 (setq starting-indentation (current-indentation)) 2894 ;; Check point is inside a defun.
2904 (looking-at python-nav-beginning-of-defun-regexp) 2895 (when (and starting-indentation
2905 (setq names (cons 2896 (< starting-point
2897 (save-excursion
2898 (python-nav-end-of-defun)
2899 (point))))
2900 (catch 'exit
2901 (while (python-nav-beginning-of-defun 1)
2902 (when (< (current-indentation) starting-indentation)
2903 (setq starting-indentation (current-indentation))
2904 (setq names
2905 (cons
2906 (if (not include-type) 2906 (if (not include-type)
2907 (match-string-no-properties 1) 2907 (match-string-no-properties 1)
2908 (mapconcat 'identity 2908 (mapconcat 'identity
2909 (split-string 2909 (split-string
2910 (match-string-no-properties 0)) " ")) 2910 (match-string-no-properties 0)) " "))
2911 names)))))) 2911 names)))
2912 (when names 2912 (and (= (current-indentation) 0) (throw 'exit t)))))
2913 (mapconcat (lambda (string) string) names ".")))) 2913 (and names
2914 (mapconcat (lambda (string) string) names "."))))))
2914 2915
2915(defun python-info-current-symbol (&optional replace-self) 2916(defun python-info-current-symbol (&optional replace-self)
2916 "Return current symbol using dotty syntax. 2917 "Return current symbol using dotty syntax.
@@ -3200,9 +3201,9 @@ if that value is non-nil."
3200 'python-fill-paragraph) 3201 'python-fill-paragraph)
3201 3202
3202 (set (make-local-variable 'beginning-of-defun-function) 3203 (set (make-local-variable 'beginning-of-defun-function)
3203 #'python-beginning-of-defun-function) 3204 #'python-nav-beginning-of-defun)
3204 (set (make-local-variable 'end-of-defun-function) 3205 (set (make-local-variable 'end-of-defun-function)
3205 #'python-end-of-defun-function) 3206 #'python-nav-end-of-defun)
3206 3207
3207 (add-hook 'completion-at-point-functions 3208 (add-hook 'completion-at-point-functions
3208 'python-completion-complete-at-point nil 'local) 3209 'python-completion-complete-at-point nil 'local)
@@ -3230,7 +3231,7 @@ if that value is non-nil."
3230 (add-to-list 'hs-special-modes-alist 3231 (add-to-list 'hs-special-modes-alist
3231 `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#" 3232 `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#"
3232 ,(lambda (arg) 3233 ,(lambda (arg)
3233 (python-end-of-defun-function)) nil)) 3234 (python-nav-end-of-defun)) nil))
3234 3235
3235 (set (make-local-variable 'mode-require-final-newline) t) 3236 (set (make-local-variable 'mode-require-final-newline) t)
3236 3237
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 84cf7308d75..7c72b73a879 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -898,17 +898,7 @@ or blocks containing the current block."
898 (back-to-indentation) 898 (back-to-indentation)
899 (if (looking-at (concat "\\<\\(" ruby-block-mid-re "\\)\\>")) 899 (if (looking-at (concat "\\<\\(" ruby-block-mid-re "\\)\\>"))
900 (setq done nil))))) 900 (setq done nil)))))
901 (back-to-indentation) 901 (back-to-indentation)))
902 (when (< n 0)
903 (let ((eol (point-at-eol)) state next)
904 (if (< orig eol) (setq eol orig))
905 (setq orig (point))
906 (while (and (setq next (apply 'ruby-parse-partial eol state))
907 (< (point) eol))
908 (setq state next))
909 (when (cdaadr state)
910 (goto-char (cdaadr state)))
911 (backward-word)))))
912 902
913(defun ruby-beginning-of-block (&optional arg) 903(defun ruby-beginning-of-block (&optional arg)
914 "Move backward to the beginning of the current block. 904 "Move backward to the beginning of the current block.
@@ -1043,21 +1033,19 @@ For example:
1043 #exit 1033 #exit
1044 String#gsub 1034 String#gsub
1045 Net::HTTP#active? 1035 Net::HTTP#active?
1046 File::open. 1036 File.open
1047 1037
1048See `add-log-current-defun-function'." 1038See `add-log-current-defun-function'."
1049 ;; TODO: Document body
1050 ;; Why does this append a period to class methods?
1051 (condition-case nil 1039 (condition-case nil
1052 (save-excursion 1040 (save-excursion
1053 (let (mname mlist (indent 0)) 1041 (let (mname mlist (indent 0))
1054 ;; get current method (or class/module) 1042 ;; Get the current method definition (or class/module).
1055 (if (re-search-backward 1043 (if (re-search-backward
1056 (concat "^[ \t]*" ruby-defun-beg-re "[ \t]+" 1044 (concat "^[ \t]*" ruby-defun-beg-re "[ \t]+"
1057 "\\(" 1045 "\\("
1058 ;; \\. and :: for class method 1046 ;; \\. and :: for class methods
1059 "\\([A-Za-z_]" ruby-symbol-re "*\\|\\.\\|::" "\\)" 1047 "\\([A-Za-z_]" ruby-symbol-re "*\\|\\.\\|::" "\\)"
1060 "+\\)") 1048 "+\\)")
1061 nil t) 1049 nil t)
1062 (progn 1050 (progn
1063 (setq mname (match-string 2)) 1051 (setq mname (match-string 2))
@@ -1066,7 +1054,7 @@ See `add-log-current-defun-function'."
1066 (goto-char (match-beginning 1)) 1054 (goto-char (match-beginning 1))
1067 (setq indent (current-column)) 1055 (setq indent (current-column))
1068 (beginning-of-line))) 1056 (beginning-of-line)))
1069 ;; nest class/module 1057 ;; Walk up the class/module nesting.
1070 (while (and (> indent 0) 1058 (while (and (> indent 0)
1071 (re-search-backward 1059 (re-search-backward
1072 (concat 1060 (concat
@@ -1079,28 +1067,26 @@ See `add-log-current-defun-function'."
1079 (setq mlist (cons (match-string 2) mlist)) 1067 (setq mlist (cons (match-string 2) mlist))
1080 (setq indent (current-column)) 1068 (setq indent (current-column))
1081 (beginning-of-line)))) 1069 (beginning-of-line))))
1070 ;; Process the method name.
1082 (when mname 1071 (when mname
1083 (let ((mn (split-string mname "\\.\\|::"))) 1072 (let ((mn (split-string mname "\\.\\|::")))
1084 (if (cdr mn) 1073 (if (cdr mn)
1085 (progn 1074 (progn
1086 (cond 1075 (unless (string-equal "self" (car mn)) ; def self.foo
1087 ((string-equal "" (car mn)) 1076 ;; def C.foo
1088 (setq mn (cdr mn) mlist nil)) 1077 (let ((ml (nreverse mlist)))
1089 ((string-equal "self" (car mn)) 1078 ;; If the method name references one of the
1090 (setq mn (cdr mn))) 1079 ;; containing modules, drop the more nested ones.
1091 ((let ((ml (nreverse mlist)))
1092 (while ml 1080 (while ml
1093 (if (string-equal (car ml) (car mn)) 1081 (if (string-equal (car ml) (car mn))
1094 (setq mlist (nreverse (cdr ml)) ml nil)) 1082 (setq mlist (nreverse (cdr ml)) ml nil))
1095 (or (setq ml (cdr ml)) (nreverse mlist)))))) 1083 (or (setq ml (cdr ml)) (nreverse mlist))))
1096 (if mlist 1084 (if mlist
1097 (setcdr (last mlist) mn) 1085 (setcdr (last mlist) (butlast mn))
1098 (setq mlist mn)) 1086 (setq mlist (butlast mn))))
1099 (setq mn (last mn 2)) 1087 (setq mname (concat "." (car (last mn)))))
1100 (setq mname (concat "." (cadr mn)))
1101 (setcdr mn nil))
1102 (setq mname (concat "#" mname))))) 1088 (setq mname (concat "#" mname)))))
1103 ;; generate string 1089 ;; Generate the string.
1104 (if (consp mlist) 1090 (if (consp mlist)
1105 (setq mlist (mapconcat (function identity) mlist "::"))) 1091 (setq mlist (mapconcat (function identity) mlist "::")))
1106 (if mname 1092 (if mname
@@ -1561,7 +1547,8 @@ See `font-lock-syntax-table'.")
1561 ruby-keyword-end-re) 1547 ruby-keyword-end-re)
1562 2) 1548 2)
1563 ;; here-doc beginnings 1549 ;; here-doc beginnings
1564 (list ruby-here-doc-beg-re 0 'font-lock-string-face) 1550 `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0))
1551 'font-lock-string-face))
1565 ;; variables 1552 ;; variables
1566 '("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(nil\\|self\\|true\\|false\\)\\>" 1553 '("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(nil\\|self\\|true\\|false\\)\\>"
1567 2 font-lock-variable-name-face) 1554 2 font-lock-variable-name-face)
@@ -1638,6 +1625,8 @@ The variable `ruby-indent-level' controls the amount of indentation.
1638 1625
1639;;;###autoload 1626;;;###autoload
1640(add-to-list 'auto-mode-alist (cons (purecopy "\\.rb\\'") 'ruby-mode)) 1627(add-to-list 'auto-mode-alist (cons (purecopy "\\.rb\\'") 'ruby-mode))
1628;;;###autoload
1629(add-to-list 'auto-mode-alist '("Rakefile\\'" . ruby-mode))
1641 1630
1642;;;###autoload 1631;;;###autoload
1643(dolist (name (list "ruby" "rbx" "jruby" "ruby1.9" "ruby1.8")) 1632(dolist (name (list "ruby" "rbx" "jruby" "ruby1.9" "ruby1.8"))
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 3d5abc4df62..64b87d9e436 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -2802,8 +2802,12 @@ each line with INDENT."
2802 doc)) 2802 doc))
2803 2803
2804;;;###autoload 2804;;;###autoload
2805(defun sql-help () 2805(eval
2806 "Show short help for the SQL modes. 2806 ;; FIXME: This dynamic-docstring-function trick doesn't work for byte-compiled
2807 ;; functions, because of the lazy-loading of docstrings, which strips away
2808 ;; text properties.
2809 '(defun sql-help ()
2810 #("Show short help for the SQL modes.
2807 2811
2808Use an entry function to open an interactive SQL buffer. This buffer is 2812Use an entry function to open an interactive SQL buffer. This buffer is
2809usually named `*SQL*'. The name of the major mode is SQLi. 2813usually named `*SQL*'. The name of the major mode is SQLi.
@@ -2834,32 +2838,23 @@ anything. The name of the major mode is SQL.
2834In this SQL buffer (SQL mode), you can send the region or the entire 2838In this SQL buffer (SQL mode), you can send the region or the entire
2835buffer to the interactive SQL buffer (SQLi mode). The results are 2839buffer to the interactive SQL buffer (SQLi mode). The results are
2836appended to the SQLi buffer without disturbing your SQL buffer." 2840appended to the SQLi buffer without disturbing your SQL buffer."
2841 0 1 (dynamic-docstring-function sql--make-help-docstring))
2837 (interactive) 2842 (interactive)
2843 (describe-function 'sql-help)))
2838 2844
2839 ;; Insert references to loaded products into the help buffer string 2845(defun sql--make-help-docstring (doc _fun)
2840 (let ((doc (documentation 'sql-help t)) 2846 "Insert references to loaded products into the help buffer string."
2841 changedp) 2847
2842 (setq changedp nil) 2848 ;; Insert FREE software list
2843 2849 (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]FREE\\s-*\n" doc 0)
2844 ;; Insert FREE software list 2850 (setq doc (replace-match (sql-help-list-products (match-string 1 doc) t)
2845 (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]FREE\\s-*\n" doc 0) 2851 t t doc 0)))
2846 (setq doc (replace-match (sql-help-list-products (match-string 1 doc) t) 2852
2847 t t doc 0) 2853 ;; Insert non-FREE software list
2848 changedp t)) 2854 (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]NONFREE\\s-*\n" doc 0)
2849 2855 (setq doc (replace-match (sql-help-list-products (match-string 1 doc) nil)
2850 ;; Insert non-FREE software list 2856 t t doc 0)))
2851 (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]NONFREE\\s-*\n" doc 0) 2857 doc)
2852 (setq doc (replace-match (sql-help-list-products (match-string 1 doc) nil)
2853 t t doc 0)
2854 changedp t))
2855
2856 ;; If we changed the help text, save the change so that the help
2857 ;; sub-system will see it
2858 (when changedp
2859 (put 'sql-help 'function-documentation doc)))
2860
2861 ;; Call help on this function
2862 (describe-function 'sql-help))
2863 2858
2864(defun sql-read-passwd (prompt &optional default) 2859(defun sql-read-passwd (prompt &optional default)
2865 "Read a password using PROMPT. Optional DEFAULT is password to start with." 2860 "Read a password using PROMPT. Optional DEFAULT is password to start with."
diff --git a/lisp/server.el b/lisp/server.el
index 7a356a90378..c78e3e376aa 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -842,6 +842,15 @@ This handles splitting the command if it would be bigger than
842 (unless (assq w window-system-initialization-alist) 842 (unless (assq w window-system-initialization-alist)
843 (setq w nil)) 843 (setq w nil))
844 844
845 ;; Special case for ns. This is because DISPLAY may not be set at all
846 ;; which in the ns case isn't an error. The variable display then becomes
847 ;; the fully qualified hostname, which make-frame-on-display below
848 ;; does not understand and throws an error.
849 ;; It may also be a valid X display, but if Emacs is compiled for ns, it
850 ;; can not make X frames.
851 (if (featurep 'ns-win)
852 (setq w 'ns display "ns"))
853
845 (cond (w 854 (cond (w
846 ;; Flag frame as client-created, but use a dummy client. 855 ;; Flag frame as client-created, but use a dummy client.
847 ;; This will prevent the frame from being deleted when 856 ;; This will prevent the frame from being deleted when
diff --git a/lisp/ses.el b/lisp/ses.el
index 7cdac74e310..27b906d22e3 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -278,6 +278,7 @@ default printer and then modify its output.")
278 ses--default-printer 278 ses--default-printer
279 ses--deferred-narrow ses--deferred-recalc 279 ses--deferred-narrow ses--deferred-recalc
280 ses--deferred-write ses--file-format 280 ses--deferred-write ses--file-format
281 ses--named-cell-hashmap
281 (ses--header-hscroll . -1) ; Flag for "initial recalc needed" 282 (ses--header-hscroll . -1) ; Flag for "initial recalc needed"
282 ses--header-row ses--header-string ses--linewidth 283 ses--header-row ses--header-string ses--linewidth
283 ses--numcols ses--numrows ses--symbolic-formulas 284 ses--numcols ses--numrows ses--symbolic-formulas
@@ -511,9 +512,22 @@ PROPERTY-NAME."
511 `(aref ses--col-printers ,col)) 512 `(aref ses--col-printers ,col))
512 513
513(defmacro ses-sym-rowcol (sym) 514(defmacro ses-sym-rowcol (sym)
514 "From a cell-symbol SYM, gets the cons (row . col). A1 => (0 . 0). 515 "From a cell-symbol SYM, gets the cons (row . col). A1 => (0 . 0). Result
515Result is nil if SYM is not a symbol that names a cell." 516is nil if SYM is not a symbol that names a cell."
516 `(and (symbolp ,sym) (get ,sym 'ses-cell))) 517 `(let ((rc (and (symbolp ,sym) (get ,sym 'ses-cell))))
518 (if (eq rc :ses-named)
519 (gethash ,sym ses--named-cell-hashmap)
520 rc)))
521
522(defun ses-is-cell-sym-p (sym)
523 "Check whether SYM point at a cell of this spread sheet."
524 (let ((rowcol (get sym 'ses-cell)))
525 (and rowcol
526 (if (eq rowcol :ses-named)
527 (and ses--named-cell-hashmap (gethash sym ses--named-cell-hashmap))
528 (and (< (car rowcol) ses--numrows)
529 (< (cdr rowcol) ses--numcols)
530 (eq (ses-cell-symbol (car rowcol) (cdr rowcol)) sym))))))
517 531
518(defmacro ses-cell (sym value formula printer references) 532(defmacro ses-cell (sym value formula printer references)
519 "Load a cell SYM from the spreadsheet file. Does not recompute VALUE from 533 "Load a cell SYM from the spreadsheet file. Does not recompute VALUE from
@@ -682,6 +696,28 @@ for this spreadsheet."
682 "Produce a symbol that names the cell (ROW,COL). (0,0) => 'A1." 696 "Produce a symbol that names the cell (ROW,COL). (0,0) => 'A1."
683 (intern (concat (ses-column-letter col) (number-to-string (1+ row))))) 697 (intern (concat (ses-column-letter col) (number-to-string (1+ row)))))
684 698
699(defun ses-decode-cell-symbol (str)
700 "Decode a symbol \"A1\" => (0,0). Returns `nil' if STR is not a
701 canonical cell name. Does not save match data."
702 (let (case-fold-search)
703 (and (string-match "\\`\\([A-Z]+\\)\\([0-9]+\\)\\'" str)
704 (let* ((col-str (match-string-no-properties 1 str))
705 (col 0)
706 (col-offset 0)
707 (col-base 1)
708 (col-idx (1- (length col-str)))
709 (row (1- (string-to-number (match-string-no-properties 2 str)))))
710 (and (>= row 0)
711 (progn
712 (while
713 (progn
714 (setq col (+ col (* (- (aref col-str col-idx) ?A) col-base))
715 col-base (* col-base 26)
716 col-idx (1- col-idx))
717 (and (>= col-idx 0)
718 (setq col (+ col col-base)))))
719 (cons row col)))))))
720
685(defun ses-create-cell-variable-range (minrow maxrow mincol maxcol) 721(defun ses-create-cell-variable-range (minrow maxrow mincol maxcol)
686 "Create buffer-local variables for cells. This is undoable." 722 "Create buffer-local variables for cells. This is undoable."
687 (push `(apply ses-destroy-cell-variable-range ,minrow ,maxrow ,mincol ,maxcol) 723 (push `(apply ses-destroy-cell-variable-range ,minrow ,maxrow ,mincol ,maxcol)
@@ -704,7 +740,11 @@ row and column of the cell, with numbering starting from 0.
704Return nil in case of failure." 740Return nil in case of failure."
705 (unless (local-variable-p sym) 741 (unless (local-variable-p sym)
706 (make-local-variable sym) 742 (make-local-variable sym)
707 (put sym 'ses-cell (cons row col)))) 743 (if (let (case-fold-search) (string-match "\\`[A-Z]+[0-9]+\\'" (symbol-name sym)))
744 (put sym 'ses-cell (cons row col))
745 (put sym 'ses-cell :ses-named)
746 (setq ses--named-cell-hashmap (or ses--named-cell-hashmap (make-hash-table :test 'eq)))
747 (puthash sym (cons row col) ses--named-cell-hashmap))))
708 748
709;; We do not delete the ses-cell properties for the cell-variables, in 749;; We do not delete the ses-cell properties for the cell-variables, in
710;; case a formula that refers to this cell is in the kill-ring and is 750;; case a formula that refers to this cell is in the kill-ring and is
@@ -3211,27 +3251,36 @@ highlighted range in the spreadsheet."
3211(defun ses-rename-cell (new-name &optional cell) 3251(defun ses-rename-cell (new-name &optional cell)
3212 "Rename current cell." 3252 "Rename current cell."
3213 (interactive "*SEnter new name: ") 3253 (interactive "*SEnter new name: ")
3214 (and (local-variable-p new-name) 3254 (or
3215 (ses-sym-rowcol new-name) 3255 (and (local-variable-p new-name)
3216 ;; this test is needed because ses-cell property of deleted cells 3256 (ses-is-cell-sym-p new-name)
3217 ;; is not deleted in case of subsequent undo 3257 (error "Already a cell name"))
3218 (memq new-name ses--renamed-cell-symb-list) 3258 (and (boundp new-name)
3219 (error "Already a cell name")) 3259 (null (yes-or-no-p (format "`%S' is already bound outside this buffer, continue? "
3220 (and (boundp new-name) 3260 new-name)))
3221 (null (yes-or-no-p (format "`%S' is already bound outside this buffer, continue? " 3261 (error "Already a bound cell name")))
3222 new-name))) 3262 (let* (curcell
3223 (error "Already a bound cell name")) 3263 (sym (if (ses-cell-p cell)
3224 (let* ((sym (if (ses-cell-p cell)
3225 (ses-cell-symbol cell) 3264 (ses-cell-symbol cell)
3226 (setq cell nil) 3265 (setq cell nil
3266 curcell t)
3227 (ses-check-curcell) 3267 (ses-check-curcell)
3228 ses--curcell)) 3268 ses--curcell))
3229 (rowcol (ses-sym-rowcol sym)) 3269 (rowcol (ses-sym-rowcol sym))
3230 (row (car rowcol)) 3270 (row (car rowcol))
3231 (col (cdr rowcol))) 3271 (col (cdr rowcol))
3232 (setq cell (or cell (ses-get-cell row col))) 3272 new-rowcol old-name)
3233 (push `(ses-rename-cell ,(ses-cell-symbol cell) ,cell) buffer-undo-list) 3273 (setq cell (or cell (ses-get-cell row col))
3234 (put new-name 'ses-cell rowcol) 3274 old-name (ses-cell-symbol cell)
3275 new-rowcol (ses-decode-cell-symbol (symbol-name new-name)))
3276 (if new-rowcol
3277 (if (equal new-rowcol rowcol)
3278 (put new-name 'ses-cell rowcol)
3279 (error "Not a valid name for this cell location"))
3280 (setq ses--named-cell-hashmap (or ses--named-cell-hashmap (make-hash-table :test 'eq)))
3281 (put new-name 'ses-cell :ses-named)
3282 (puthash new-name rowcol ses--named-cell-hashmap))
3283 (push `(ses-rename-cell ,old-name ,cell) buffer-undo-list)
3235 ;; replace name by new name in formula of cells refering to renamed cell 3284 ;; replace name by new name in formula of cells refering to renamed cell
3236 (dolist (ref (ses-cell-references cell)) 3285 (dolist (ref (ses-cell-references cell))
3237 (let* ((x (ses-sym-rowcol ref)) 3286 (let* ((x (ses-sym-rowcol ref))
@@ -3251,9 +3300,8 @@ highlighted range in the spreadsheet."
3251 (push new-name ses--renamed-cell-symb-list) 3300 (push new-name ses--renamed-cell-symb-list)
3252 (set new-name (symbol-value sym)) 3301 (set new-name (symbol-value sym))
3253 (aset cell 0 new-name) 3302 (aset cell 0 new-name)
3254 (put sym 'ses-cell nil)
3255 (makunbound sym) 3303 (makunbound sym)
3256 (setq sym new-name) 3304 (and curcell (setq ses--curcell new-name))
3257 (let* ((pos (point)) 3305 (let* ((pos (point))
3258 (inhibit-read-only t) 3306 (inhibit-read-only t)
3259 (col (current-column)) 3307 (col (current-column))
diff --git a/lisp/subr.el b/lisp/subr.el
index d328b7cddf5..b0ac2dd2106 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -195,11 +195,6 @@ value of last one, or nil if there are none.
195 (declare (indent 1) (debug t)) 195 (declare (indent 1) (debug t))
196 (cons 'if (cons cond (cons nil body)))) 196 (cons 'if (cons cond (cons nil body))))
197 197
198(if (null (featurep 'cl))
199 (progn
200 ;; If we reload subr.el after having loaded CL, be careful not to
201 ;; overwrite CL's extended definition of `dolist', `dotimes', `declare'.
202
203(defmacro dolist (spec &rest body) 198(defmacro dolist (spec &rest body)
204 "Loop over a list. 199 "Loop over a list.
205Evaluate BODY with VAR bound to each car from LIST, in turn. 200Evaluate BODY with VAR bound to each car from LIST, in turn.
@@ -222,9 +217,7 @@ Then evaluate RESULT to get return value, default nil.
222 (let ((,(car spec) (car ,temp))) 217 (let ((,(car spec) (car ,temp)))
223 ,@body 218 ,@body
224 (setq ,temp (cdr ,temp)))) 219 (setq ,temp (cdr ,temp))))
225 ,@(if (cdr (cdr spec)) 220 ,@(cdr (cdr spec)))
226 ;; FIXME: This let often leads to "unused var" warnings.
227 `((let ((,(car spec) nil)) ,@(cdr (cdr spec))))))
228 `(let ((,temp ,(nth 1 spec)) 221 `(let ((,temp ,(nth 1 spec))
229 ,(car spec)) 222 ,(car spec))
230 (while ,temp 223 (while ,temp
@@ -281,7 +274,6 @@ The possible values of SPECS are specified by
281`defun-declarations-alist' and `macro-declarations-alist'." 274`defun-declarations-alist' and `macro-declarations-alist'."
282 ;; FIXME: edebug spec should pay attention to defun-declarations-alist. 275 ;; FIXME: edebug spec should pay attention to defun-declarations-alist.
283 nil) 276 nil)
284))
285 277
286(defmacro ignore-errors (&rest body) 278(defmacro ignore-errors (&rest body)
287 "Execute BODY; if an error occurs, return nil. 279 "Execute BODY; if an error occurs, return nil.
@@ -2657,13 +2649,17 @@ See also `locate-user-emacs-file'.")
2657 2649
2658(defun locate-user-emacs-file (new-name &optional old-name) 2650(defun locate-user-emacs-file (new-name &optional old-name)
2659 "Return an absolute per-user Emacs-specific file name. 2651 "Return an absolute per-user Emacs-specific file name.
2660If OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME. 2652If NEW-NAME exists in `user-emacs-directory', return it.
2653Else If OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME.
2661Else return NEW-NAME in `user-emacs-directory', creating the 2654Else return NEW-NAME in `user-emacs-directory', creating the
2662directory if it does not exist." 2655directory if it does not exist."
2663 (convert-standard-filename 2656 (convert-standard-filename
2664 (let* ((home (concat "~" (or init-file-user ""))) 2657 (let* ((home (concat "~" (or init-file-user "")))
2665 (at-home (and old-name (expand-file-name old-name home)))) 2658 (at-home (and old-name (expand-file-name old-name home)))
2666 (if (and at-home (file-readable-p at-home)) 2659 (bestname (abbreviate-file-name
2660 (expand-file-name new-name user-emacs-directory))))
2661 (if (and at-home (not (file-readable-p bestname))
2662 (file-readable-p at-home))
2667 at-home 2663 at-home
2668 ;; Make sure `user-emacs-directory' exists, 2664 ;; Make sure `user-emacs-directory' exists,
2669 ;; unless we're in batch mode or dumping Emacs 2665 ;; unless we're in batch mode or dumping Emacs
@@ -2677,8 +2673,7 @@ directory if it does not exist."
2677 (set-default-file-modes ?\700) 2673 (set-default-file-modes ?\700)
2678 (make-directory user-emacs-directory)) 2674 (make-directory user-emacs-directory))
2679 (set-default-file-modes umask)))) 2675 (set-default-file-modes umask))))
2680 (abbreviate-file-name 2676 bestname))))
2681 (expand-file-name new-name user-emacs-directory))))))
2682 2677
2683;;;; Misc. useful functions. 2678;;;; Misc. useful functions.
2684 2679
@@ -2808,6 +2803,12 @@ Otherwise, return nil."
2808Otherwise, return nil." 2803Otherwise, return nil."
2809 (and (memq object '(nil t)) t)) 2804 (and (memq object '(nil t)) t))
2810 2805
2806(defun special-form-p (object)
2807 "Non-nil if and only if OBJECT is a special form."
2808 (if (and (symbolp object) (fboundp object))
2809 (setq object (indirect-function object)))
2810 (and (subrp object) (eq (cdr (subr-arity object)) 'unevalled)))
2811
2811(defun field-at-pos (pos) 2812(defun field-at-pos (pos)
2812 "Return the field at position POS, taking stickiness etc into account." 2813 "Return the field at position POS, taking stickiness etc into account."
2813 (let ((raw-field (get-char-property (field-beginning pos) 'field))) 2814 (let ((raw-field (get-char-property (field-beginning pos) 'field)))
diff --git a/lisp/term.el b/lisp/term.el
index 7567bd38f5a..e6466b8fa95 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -452,7 +452,7 @@ state 4: term-terminal-parameter contains pending output.")
452 "A queue of strings whose echo we want suppressed.") 452 "A queue of strings whose echo we want suppressed.")
453(defvar term-terminal-parameter) 453(defvar term-terminal-parameter)
454(defvar term-terminal-previous-parameter) 454(defvar term-terminal-previous-parameter)
455(defvar term-current-face 'term-face) 455(defvar term-current-face 'term)
456(defvar term-scroll-start 0 "Top-most line (inclusive) of scrolling region.") 456(defvar term-scroll-start 0 "Top-most line (inclusive) of scrolling region.")
457(defvar term-scroll-end) ; Number of line (zero-based) after scrolling region. 457(defvar term-scroll-end) ; Number of line (zero-based) after scrolling region.
458(defvar term-pager-count nil 458(defvar term-pager-count nil
@@ -759,7 +759,7 @@ Buffer local variable.")
759 759
760;;; Faces 760;;; Faces
761(defvar ansi-term-color-vector 761(defvar ansi-term-color-vector
762 [term-face 762 [term
763 term-color-black 763 term-color-black
764 term-color-red 764 term-color-red
765 term-color-green 765 term-color-green
@@ -770,18 +770,20 @@ Buffer local variable.")
770 term-color-white]) 770 term-color-white])
771 771
772(defcustom term-default-fg-color nil 772(defcustom term-default-fg-color nil
773 "If non-nil, default color for foreground in Term mode. 773 "If non-nil, default color for foreground in Term mode."
774This is deprecated in favor of customizing the `term-face' face."
775 :group 'term 774 :group 'term
776 :type 'string) 775 :type 'string)
776(make-obsolete-variable 'term-default-fg-color "use the face `term' instead."
777 "24.3")
777 778
778(defcustom term-default-bg-color nil 779(defcustom term-default-bg-color nil
779 "If non-nil, default color for foreground in Term mode. 780 "If non-nil, default color for foreground in Term mode."
780This is deprecated in favor of customizing the `term-face' face."
781 :group 'term 781 :group 'term
782 :type 'string) 782 :type 'string)
783(make-obsolete-variable 'term-default-bg-color "use the face `term' instead."
784 "24.3")
783 785
784(defface term-face 786(defface term
785 `((t 787 `((t
786 :foreground ,term-default-fg-color 788 :foreground ,term-default-fg-color
787 :background ,term-default-bg-color 789 :background ,term-default-bg-color
@@ -988,7 +990,7 @@ is buffer-local."
988 dt)) 990 dt))
989 991
990(defun term-ansi-reset () 992(defun term-ansi-reset ()
991 (setq term-current-face 'term-face) 993 (setq term-current-face 'term)
992 (setq term-ansi-current-underline nil) 994 (setq term-ansi-current-underline nil)
993 (setq term-ansi-current-bold nil) 995 (setq term-ansi-current-bold nil)
994 (setq term-ansi-current-reverse nil) 996 (setq term-ansi-current-reverse nil)
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index de60ac37d9e..f667525397c 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -907,6 +907,24 @@ Otherwise returns the library directory name, if that is defined."
907 (setq default-directory (expand-file-name "~/"))) 907 (setq default-directory (expand-file-name "~/")))
908 (apply 'call-process-region args))) 908 (apply 'call-process-region args)))
909 909
910(defun ispell-create-debug-buffer (&optional append)
911 "Create an ispell debug buffer for debugging output.
912Use APPEND to append the info to previous buffer if exists,
913otherwise is reset. Returns name of ispell debug buffer.
914See `ispell-buffer-with-debug' for an example of use."
915 (let ((ispell-debug-buffer (get-buffer-create "*ispell-debug*")))
916 (with-current-buffer ispell-debug-buffer
917 (if append
918 (insert
919 (format "-----------------------------------------------\n"))
920 (erase-buffer)))
921 ispell-debug-buffer))
922
923(defsubst ispell-print-if-debug (string)
924 "Print STRING to `ispell-debug-buffer' buffer if enabled."
925 (if (boundp 'ispell-debug-buffer)
926 (with-current-buffer ispell-debug-buffer
927 (insert string))))
910 928
911 929
912;; The preparation of the menu bar menu must be autoloaded 930;; The preparation of the menu bar menu must be autoloaded
@@ -2902,114 +2920,142 @@ amount for last line processed."
2902 (if (not recheckp) 2920 (if (not recheckp)
2903 (ispell-accept-buffer-local-defs)) ; set up dictionary, local words, etc. 2921 (ispell-accept-buffer-local-defs)) ; set up dictionary, local words, etc.
2904 (let ((skip-region-start (make-marker)) 2922 (let ((skip-region-start (make-marker))
2905 (rstart (make-marker))) 2923 (rstart (make-marker))
2906 (unwind-protect 2924 (region-type (if (and (= reg-start (point-min)) (= reg-end (point-max)))
2907 (save-excursion 2925 (buffer-name) "region"))
2908 (message "Spell-checking %s using %s with %s dictionary..." 2926 (program-basename (file-name-nondirectory ispell-program-name))
2909 (if (and (= reg-start (point-min)) (= reg-end (point-max))) 2927 (dictionary (or ispell-current-dictionary "default")))
2910 (buffer-name) "region") 2928 (unwind-protect
2911 (file-name-nondirectory ispell-program-name) 2929 (save-excursion
2912 (or ispell-current-dictionary "default")) 2930 (message "Spell-checking %s using %s with %s dictionary..."
2913 ;; Returns cursor to original location. 2931 region-type program-basename dictionary)
2914 (save-window-excursion 2932 ;; Returns cursor to original location.
2915 (goto-char reg-start) 2933 (save-window-excursion
2916 (let ((transient-mark-mode) 2934 (goto-char reg-start)
2917 (case-fold-search case-fold-search) 2935 (let ((transient-mark-mode)
2918 (query-fcc t) 2936 (case-fold-search case-fold-search)
2919 in-comment key) 2937 (query-fcc t)
2920 (let (message-log-max) 2938 in-comment key)
2921 (message "searching for regions to skip")) 2939 (ispell-print-if-debug
2922 (if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t) 2940 (concat
2923 (progn 2941 (format
2924 (setq key (match-string-no-properties 0)) 2942 "ispell-region: (ispell-skip-region-list):\n%s\n"
2925 (set-marker skip-region-start (- (point) (length key))) 2943 (ispell-skip-region-list))
2926 (goto-char reg-start))) 2944 (format
2927 (let (message-log-max) 2945 "ispell-region: (ispell-begin-skip-region-regexp):\n%s\n"
2928 (message 2946 (ispell-begin-skip-region-regexp))
2929 "Continuing spelling check using %s with %s dictionary..." 2947 "ispell-region: Search for first region to skip after (ispell-begin-skip-region-regexp)\n"))
2930 (file-name-nondirectory ispell-program-name) 2948 (if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t)
2931 (or ispell-current-dictionary "default")))
2932 (set-marker rstart reg-start)
2933 (set-marker ispell-region-end reg-end)
2934 (while (and (not ispell-quit)
2935 (< (point) ispell-region-end))
2936 ;; spell-check region with skipping
2937 (if (and (marker-position skip-region-start)
2938 (<= skip-region-start (point)))
2939 (progn 2949 (progn
2940 ;; If region inside line comment, must keep comment start. 2950 (setq key (match-string-no-properties 0))
2941 (setq in-comment (point) 2951 (set-marker skip-region-start (- (point) (length key)))
2942 in-comment 2952 (goto-char reg-start)
2943 (and comment-start 2953 (ispell-print-if-debug
2944 (or (null comment-end) (string= "" comment-end)) 2954 (format "ispell-region: First skip: %s at (pos,line,column): (%s,%s,%s).\n"
2945 (save-excursion 2955 key
2946 (beginning-of-line) 2956 (save-excursion (goto-char skip-region-start) (point))
2947 (re-search-forward comment-start in-comment t)) 2957 (line-number-at-pos skip-region-start)
2948 comment-start)) 2958 (save-excursion (goto-char skip-region-start) (current-column))))))
2949 ;; Can change skip-regexps (in ispell-message) 2959 (ispell-print-if-debug
2950 (ispell-skip-region key) ; moves pt past region. 2960 (format
2951 (set-marker rstart (point)) 2961 "ispell-region: Continue spell-checking with %s and %s dictionary...\n"
2952 ;; check for saving large attachments... 2962 program-basename dictionary))
2953 (setq query-fcc (and query-fcc 2963 (set-marker rstart reg-start)
2954 (ispell-ignore-fcc skip-region-start 2964 (set-marker ispell-region-end reg-end)
2955 rstart))) 2965 (while (and (not ispell-quit)
2956 (if (and (< rstart ispell-region-end) 2966 (< (point) ispell-region-end))
2957 (re-search-forward 2967 ;; spell-check region with skipping
2958 (ispell-begin-skip-region-regexp) 2968 (if (and (marker-position skip-region-start)
2959 ispell-region-end t)) 2969 (<= skip-region-start (point)))
2960 (progn 2970 (progn
2961 (setq key (match-string-no-properties 0)) 2971 ;; If region inside line comment, must keep comment start.
2962 (set-marker skip-region-start 2972 (setq in-comment (point)
2963 (- (point) (length key))) 2973 in-comment
2964 (goto-char rstart)) 2974 (and comment-start
2965 (set-marker skip-region-start nil)))) 2975 (or (null comment-end) (string= "" comment-end))
2966 (setq reg-end (max (point) 2976 (save-excursion
2967 (if (marker-position skip-region-start) 2977 (beginning-of-line)
2968 (min skip-region-start ispell-region-end) 2978 (re-search-forward comment-start in-comment t))
2969 (marker-position ispell-region-end)))) 2979 comment-start))
2970 (let* ((ispell-start (point)) 2980 ;; Can change skip-regexps (in ispell-message)
2971 (ispell-end (min (point-at-eol) reg-end)) 2981 (ispell-skip-region key) ; moves pt past region.
2972 (string (ispell-get-line 2982 (set-marker rstart (point))
2973 ispell-start ispell-end in-comment))) 2983 ;; check for saving large attachments...
2974 (if in-comment ; account for comment chars added 2984 (setq query-fcc (and query-fcc
2975 (setq ispell-start (- ispell-start (length in-comment)) 2985 (ispell-ignore-fcc skip-region-start
2976 in-comment nil)) 2986 rstart)))
2977 (setq ispell-end (point)) ; "end" tracks region retrieved. 2987 (if (and (< rstart ispell-region-end)
2978 (if string ; there is something to spell check! 2988 (re-search-forward
2979 ;; (special start end) 2989 (ispell-begin-skip-region-regexp)
2980 (setq shift (ispell-process-line string 2990 ispell-region-end t))
2981 (and recheckp shift)))) 2991 (progn
2982 (goto-char ispell-end))))) 2992 (setq key (match-string-no-properties 0))
2983 (if ispell-quit 2993 (set-marker skip-region-start
2984 nil 2994 (- (point) (length key)))
2985 (or shift 0))) 2995 (goto-char rstart)
2986 ;; protected 2996 (ispell-print-if-debug
2987 (if (and (not (and recheckp ispell-keep-choices-win)) 2997 (format "ispell-region: Next skip: %s at (pos,line,column): (%s,%s,%s).\n"
2988 (get-buffer ispell-choices-buffer)) 2998 key
2989 (kill-buffer ispell-choices-buffer)) 2999 (save-excursion (goto-char skip-region-start) (point))
2990 (set-marker skip-region-start nil) 3000 (line-number-at-pos skip-region-start)
2991 (set-marker rstart nil) 3001 (save-excursion (goto-char skip-region-start) (current-column)))))
2992 (if ispell-quit 3002 (set-marker skip-region-start nil))))
2993 (progn 3003 (setq reg-end (max (point)
2994 ;; preserve or clear the region for ispell-continue. 3004 (if (marker-position skip-region-start)
2995 (if (not (numberp ispell-quit)) 3005 (min skip-region-start ispell-region-end)
2996 (set-marker ispell-region-end nil) 3006 (marker-position ispell-region-end))))
2997 ;; Ispell-continue enabled - ispell-region-end is set. 3007 (let* ((ispell-start (point))
2998 (goto-char ispell-quit)) 3008 (ispell-end (min (point-at-eol) reg-end))
2999 ;; Check for aborting 3009 ;; See if line must be prefixed by comment string to let ispell know this is
3000 (if (and ispell-checking-message (numberp ispell-quit)) 3010 ;; part of a comment string. This is only supported in some modes.
3001 (progn 3011 ;; In particular, this is not supported in autoconf mode where adding the
3002 (setq ispell-quit nil) 3012 ;; comment string messes everything up because ispell tries to spellcheck the
3003 (error "Message send aborted"))) 3013 ;; `dnl' string header causing misalignments in some cases (debbugs.gnu.org: #12768).
3004 (if (not recheckp) (setq ispell-quit nil))) 3014 (add-comment (and in-comment
3005 (if (not recheckp) (set-marker ispell-region-end nil)) 3015 (not (string= in-comment "dnl "))
3006 ;; Only save if successful exit. 3016 in-comment))
3007 (ispell-pdict-save ispell-silently-savep) 3017 (string (ispell-get-line
3008 (message "Spell-checking %s using %s with %s dictionary...done" 3018 ispell-start ispell-end add-comment)))
3009 (if (and (= reg-start (point-min)) (= reg-end (point-max))) 3019 (ispell-print-if-debug
3010 (buffer-name) "region") 3020 (format
3011 (file-name-nondirectory ispell-program-name) 3021 "ispell-region: string pos (%s->%s), eol: %s, [in-comment]: [%s], [add-comment]: [%s], [string]: [%s]\n"
3012 (or ispell-current-dictionary "default")))))) 3022 ispell-start ispell-end (point-at-eol) in-comment add-comment string))
3023 (if add-comment ; account for comment chars added
3024 (setq ispell-start (- ispell-start (length add-comment))
3025 add-comment nil))
3026 (setq ispell-end (point)) ; "end" tracks region retrieved.
3027 (if string ; there is something to spell check!
3028 ;; (special start end)
3029 (setq shift (ispell-process-line string
3030 (and recheckp shift))))
3031 (goto-char ispell-end)))))
3032 (if ispell-quit
3033 nil
3034 (or shift 0)))
3035 ;; protected
3036 (if (and (not (and recheckp ispell-keep-choices-win))
3037 (get-buffer ispell-choices-buffer))
3038 (kill-buffer ispell-choices-buffer))
3039 (set-marker skip-region-start nil)
3040 (set-marker rstart nil)
3041 (if ispell-quit
3042 (progn
3043 ;; preserve or clear the region for ispell-continue.
3044 (if (not (numberp ispell-quit))
3045 (set-marker ispell-region-end nil)
3046 ;; Ispell-continue enabled - ispell-region-end is set.
3047 (goto-char ispell-quit))
3048 ;; Check for aborting
3049 (if (and ispell-checking-message (numberp ispell-quit))
3050 (progn
3051 (setq ispell-quit nil)
3052 (error "Message send aborted")))
3053 (if (not recheckp) (setq ispell-quit nil)))
3054 (if (not recheckp) (set-marker ispell-region-end nil))
3055 ;; Only save if successful exit.
3056 (ispell-pdict-save ispell-silently-savep)
3057 (message "Spell-checking %s using %s with %s dictionary...done"
3058 region-type program-basename dictionary)))))
3013 3059
3014 3060
3015(defun ispell-begin-skip-region-regexp () 3061(defun ispell-begin-skip-region-regexp ()
@@ -3256,10 +3302,19 @@ Returns the sum SHIFT due to changes in word replacements."
3256 ;; Alignment cannot be tracked and this error will occur when 3302 ;; Alignment cannot be tracked and this error will occur when
3257 ;; `query-replace' makes multiple corrections on the starting line. 3303 ;; `query-replace' makes multiple corrections on the starting line.
3258 (or (ispell-looking-at (car poss)) 3304 (or (ispell-looking-at (car poss))
3259 ;; This occurs due to filter pipe problems 3305 ;; This error occurs due to filter pipe problems
3260 (error (concat "Ispell misalignment: word " 3306 (let* ((ispell-pipe-word (car poss))
3261 "`%s' point %d; probably incompatible versions") 3307 (actual-point (marker-position word-start))
3262 (car poss) (marker-position word-start))) 3308 (actual-line (line-number-at-pos actual-point))
3309 (actual-column (save-excursion (goto-char actual-point) (current-column))))
3310 (ispell-print-if-debug
3311 (concat
3312 "ispell-process-line: Ispell misalignment error:\n"
3313 (format " [Word from ispell pipe]: [%s], actual (point,line,column): (%s,%s,%s)\n"
3314 ispell-pipe-word actual-point actual-line actual-column)))
3315 (error (concat "Ispell misalignment: word "
3316 "`%s' point %d; probably incompatible versions")
3317 ispell-pipe-word actual-point)))
3263 ;; ispell-cmd-loop can go recursive & change buffer 3318 ;; ispell-cmd-loop can go recursive & change buffer
3264 (if ispell-keep-choices-win 3319 (if ispell-keep-choices-win
3265 (setq replace (ispell-command-loop 3320 (setq replace (ispell-command-loop
@@ -3393,6 +3448,13 @@ Returns the sum SHIFT due to changes in word replacements."
3393 (interactive) 3448 (interactive)
3394 (ispell-region (point-min) (point-max))) 3449 (ispell-region (point-min) (point-max)))
3395 3450
3451;;;###autoload
3452(defun ispell-buffer-with-debug (&optional append)
3453 "`ispell-buffer' with some output sent to `ispell-debug-buffer' buffer.
3454Use APPEND to append the info to previous buffer if exists."
3455 (interactive)
3456 (let ((ispell-debug-buffer (ispell-create-debug-buffer append)))
3457 (ispell-buffer)))
3396 3458
3397;;;###autoload 3459;;;###autoload
3398(defun ispell-continue () 3460(defun ispell-continue ()
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 49b76a8e3bc..26c64ce2ad3 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -178,7 +178,7 @@ when editing big diffs)."
178 ["Unified -> Context" diff-unified->context 178 ["Unified -> Context" diff-unified->context
179 :help "Convert unified diffs to context diffs"] 179 :help "Convert unified diffs to context diffs"]
180 ;;["Fixup Headers" diff-fixup-modifs (not buffer-read-only)] 180 ;;["Fixup Headers" diff-fixup-modifs (not buffer-read-only)]
181 ["Remove trailing whitespace" diff-remove-trailing-whitespace 181 ["Remove trailing whitespace" diff-delete-trailing-whitespace
182 :help "Remove trailing whitespace problems introduced by the diff"] 182 :help "Remove trailing whitespace problems introduced by the diff"]
183 ["Show trailing whitespace" whitespace-mode 183 ["Show trailing whitespace" whitespace-mode
184 :style toggle :selected (bound-and-true-p whitespace-mode) 184 :style toggle :selected (bound-and-true-p whitespace-mode)
@@ -2048,35 +2048,71 @@ I.e. like `add-change-log-entry-other-window' but applied to all hunks."
2048 ;; When there's no more hunks, diff-hunk-next signals an error. 2048 ;; When there's no more hunks, diff-hunk-next signals an error.
2049 (error nil)))) 2049 (error nil))))
2050 2050
2051(defun diff-remove-trailing-whitespace () 2051(defun diff-delete-trailing-whitespace (&optional other-file)
2052 "When on a buffer that contains a diff, inspects the 2052 "Remove trailing whitespace from lines modified in this diff.
2053differences and removes trailing whitespace (spaces, tabs) from 2053This edits both the current Diff mode buffer and the patched
2054the lines modified or introduced by this diff. Shows a message 2054source file(s). If `diff-jump-to-old-file' is non-nil, edit the
2055with the name of the altered buffers, which are unsaved. If a 2055original (unpatched) source file instead. With a prefix argument
2056file referenced on the diff has no buffer and needs to be fixed, 2056OTHER-FILE, flip the choice of which source file to edit.
2057a buffer visiting that file is created." 2057
2058 (interactive) 2058If a file referenced in the diff has no buffer and needs to be
2059 ;; We assume that the diff header has no trailing whitespace. 2059fixed, visit it in a buffer."
2060 (let ((modified-buffers nil)) 2060 (interactive "P")
2061 (save-excursion 2061 (save-excursion
2062 (goto-char (point-min)) 2062 (goto-char (point-min))
2063 (while (re-search-forward "^[+!>].*[ \t]+$" (point-max) t) 2063 (let* ((other (diff-xor other-file diff-jump-to-old-file))
2064 (pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,_switched) 2064 (modified-buffers nil)
2065 (diff-find-source-location t t))) 2065 (style (save-excursion
2066 (when line-offset 2066 (when (re-search-forward diff-hunk-header-re nil t)
2067 (with-current-buffer buf 2067 (goto-char (match-beginning 0))
2068 (save-excursion 2068 (diff-hunk-style))))
2069 (goto-char (+ (car pos) (cdr src))) 2069 (regexp (concat "^[" (if other "-<" "+>") "!]"
2070 (beginning-of-line) 2070 (if (eq style 'context) " " "")
2071 (when (re-search-forward "\\([ \t]+\\)$" (line-end-position) t) 2071 ".*?\\([ \t]+\\)$"))
2072 (unless (memq buf modified-buffers) 2072 (inhibit-read-only t)
2073 (push buf modified-buffers)) 2073 (end-marker (make-marker))
2074 (replace-match "")))))))) 2074 hunk-end)
2075 (if modified-buffers 2075 ;; Move to the first hunk.
2076 (message "Deleted new trailing whitespace from: %s" 2076 (re-search-forward diff-hunk-header-re nil 1)
2077 (mapconcat (lambda (buf) (concat "`" (buffer-name buf) "'")) 2077 (while (progn (save-excursion
2078 modified-buffers " ")) 2078 (re-search-forward diff-hunk-header-re nil 1)
2079 (message "No trailing whitespace fixes needed.")))) 2079 (setq hunk-end (point)))
2080 (< (point) hunk-end))
2081 ;; For context diffs, search only in the appropriate half of
2082 ;; the hunk. For other diffs, search within the entire hunk.
2083 (if (not (eq style 'context))
2084 (set-marker end-marker hunk-end)
2085 (let ((mid-hunk
2086 (save-excursion
2087 (re-search-forward diff-context-mid-hunk-header-re hunk-end)
2088 (point))))
2089 (if other
2090 (set-marker end-marker mid-hunk)
2091 (goto-char mid-hunk)
2092 (set-marker end-marker hunk-end))))
2093 (while (re-search-forward regexp end-marker t)
2094 (let ((match-data (match-data)))
2095 (pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,_switched)
2096 (diff-find-source-location other-file)))
2097 (when line-offset
2098 ;; Remove the whitespace in the Diff mode buffer.
2099 (set-match-data match-data)
2100 (replace-match "" t t nil 1)
2101 ;; Remove the whitespace in the source buffer.
2102 (with-current-buffer buf
2103 (save-excursion
2104 (goto-char (+ (car pos) (cdr src)))
2105 (beginning-of-line)
2106 (when (re-search-forward "\\([ \t]+\\)$" (line-end-position) t)
2107 (unless (memq buf modified-buffers)
2108 (push buf modified-buffers))
2109 (replace-match ""))))))))
2110 (goto-char hunk-end))
2111 (if modified-buffers
2112 (message "Deleted trailing whitespace from %s."
2113 (mapconcat (lambda (buf) (concat "`" (buffer-name buf) "'"))
2114 modified-buffers ", "))
2115 (message "No trailing whitespace to delete.")))))
2080 2116
2081;; provide the package 2117;; provide the package
2082(provide 'diff-mode) 2118(provide 'diff-mode)
diff --git a/lisp/window.el b/lisp/window.el
index be6ddf8ab9e..30ee622cfe6 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -143,37 +143,36 @@ to `display-buffer'."
143 window)))) 143 window))))
144 144
145(defmacro with-temp-buffer-window (buffer-or-name action quit-function &rest body) 145(defmacro with-temp-buffer-window (buffer-or-name action quit-function &rest body)
146 "Evaluate BODY and display buffer specified by BUFFER-OR-NAME. 146 "Evaluate BODY and display the buffer specified by BUFFER-OR-NAME.
147BUFFER-OR-NAME must specify either a live buffer or the name of a 147BUFFER-OR-NAME must specify either a live buffer, or the name of a
148buffer. If no buffer with such a name exists, create one. 148buffer (if it does not exist, this macro creates it).
149 149
150Make sure the specified buffer is empty before evaluating BODY. 150Make sure the specified buffer is empty before evaluating BODY.
151Do not make that buffer current for BODY. Instead, bind 151Do not make that buffer current for BODY. Instead, bind
152`standard-output' to that buffer, so that output generated with 152`standard-output' to that buffer, so that output generated with
153`prin1' and similar functions in BODY goes into that buffer. 153`prin1' and similar functions in BODY goes into that buffer.
154 154
155After evaluating BODY, mark the specified buffer unmodified and 155After evaluating BODY, this marks the specified buffer unmodified and
156read-only, and display it in a window via `display-buffer'. Pass 156read-only, and displays it in a window via `display-buffer', passing
157ACTION as action argument to `display-buffer'. Automatically 157ACTION as the action argument to `display-buffer'. It automatically
158shrink the window used if `temp-buffer-resize-mode' is enabled. 158shrinks the relevant window if `temp-buffer-resize-mode' is enabled.
159 159
160Return the value returned by BODY unless QUIT-FUNCTION specifies 160Returns the value returned by BODY, unless QUIT-FUNCTION specifies
161a function. In that case, run the function with two arguments - 161a function. In that case, runs the function with two arguments -
162the window showing the specified buffer and the value returned by 162the window showing the specified buffer and the value returned by
163BODY - and return the value returned by that function. 163BODY - and returns the value returned by that function.
164 164
165If the buffer is displayed on a new frame, the window manager may 165If the buffer is displayed on a new frame, the window manager may
166decide to select that frame. In that case, it's usually a good 166decide to select that frame. In that case, it's usually a good
167strategy if the function specified by QUIT-FUNCTION selects the 167strategy if the function specified by QUIT-FUNCTION selects the
168window showing the buffer before reading a value from the 168window showing the buffer before reading a value from the
169minibuffer, for example, when asking a `yes-or-no-p' question. 169minibuffer; for example, when asking a `yes-or-no-p' question.
170 170
171This construct is similar to `with-output-to-temp-buffer' but 171This construct is similar to `with-output-to-temp-buffer', but does
172does neither put the buffer in help mode nor does it call 172not put the buffer in help mode, or call `temp-buffer-show-function'.
173`temp-buffer-show-function'. It also runs different hooks, 173It also runs different hooks, namely `temp-buffer-window-setup-hook'
174namely `temp-buffer-window-setup-hook' (with the specified buffer 174\(with the specified buffer current) and `temp-buffer-window-show-hook'
175current) and `temp-buffer-window-show-hook' (with the specified 175\(with the specified buffer current and the window showing it selected).
176buffer current and the window showing it selected).
177 176
178Since this macro calls `display-buffer', the window displaying 177Since this macro calls `display-buffer', the window displaying
179the buffer is usually not selected and the specified buffer 178the buffer is usually not selected and the specified buffer
@@ -6065,7 +6064,7 @@ A frame can be resized if and only if its root window is a live
6065window. The height of the root window is subject to the values 6064window. The height of the root window is subject to the values
6066of `fit-frame-to-buffer-max-height' and `window-min-height'." 6065of `fit-frame-to-buffer-max-height' and `window-min-height'."
6067 :type 'boolean 6066 :type 'boolean
6068 :version "24.2" 6067 :version "24.3"
6069 :group 'help) 6068 :group 'help)
6070 6069
6071(defcustom fit-frame-to-buffer-bottom-margin 4 6070(defcustom fit-frame-to-buffer-bottom-margin 4
@@ -6073,7 +6072,7 @@ of `fit-frame-to-buffer-max-height' and `window-min-height'."
6073This is the number of lines `fit-frame-to-buffer' leaves free at the 6072This is the number of lines `fit-frame-to-buffer' leaves free at the
6074bottom of the display in order to not obscure the system task bar." 6073bottom of the display in order to not obscure the system task bar."
6075 :type 'integer 6074 :type 'integer
6076 :version "24.2" 6075 :version "24.3"
6077 :group 'windows) 6076 :group 'windows)
6078 6077
6079(defun fit-frame-to-buffer (&optional frame max-height min-height) 6078(defun fit-frame-to-buffer (&optional frame max-height min-height)
diff --git a/lisp/woman.el b/lisp/woman.el
index e41c489dbfa..974a7d72465 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -2253,7 +2253,9 @@ Currently set only from '\" t in the first line of the source file.")
2253 (set-face-font 'woman-symbol woman-symbol-font 2253 (set-face-font 'woman-symbol woman-symbol-font
2254 (and (frame-live-p woman-frame) woman-frame))) 2254 (and (frame-live-p woman-frame) woman-frame)))
2255 2255
2256 ;; Set syntax and display tables: 2256 (setq-local adaptive-fill-mode nil) ; No special "%" "#" etc filling.
2257
2258 ;; Set syntax and display tables:
2257 (set-syntax-table woman-syntax-table) 2259 (set-syntax-table woman-syntax-table)
2258 (woman-set-buffer-display-table) 2260 (woman-set-buffer-display-table)
2259 2261
diff --git a/src/.gdbinit b/src/.gdbinit
index 952d7392a4c..fa580cc99bf 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -650,19 +650,52 @@ If the first type printed is Lisp_Vector or Lisp_Misc,
650a second line gives the more precise type. 650a second line gives the more precise type.
651end 651end
652 652
653define pvectype
654 set $size = ((struct Lisp_Vector *) $arg0)->header.size
655 if ($size & PSEUDOVECTOR_FLAG)
656 output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS)
657 else
658 output PVEC_NORMAL_VECTOR
659 end
660 echo \n
661end
662document pvectype
663Print the subtype of vectorlike object.
664Takes one argument, a pointer to an object.
665end
666
653define xvectype 667define xvectype
654 xgetptr $ 668 xgetptr $
655 set $size = ((struct Lisp_Vector *) $ptr)->header.size 669 pvectype $ptr
670end
671document xvectype
672Print the subtype of vectorlike object.
673This command assumes that $ is a Lisp_Object.
674end
675
676define pvecsize
677 set $size = ((struct Lisp_Vector *) $arg0)->header.size
656 if ($size & PSEUDOVECTOR_FLAG) 678 if ($size & PSEUDOVECTOR_FLAG)
657 output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_SIZE_BITS) 679 output ($size & PSEUDOVECTOR_SIZE_MASK)
680 echo \n
681 output (($size & PSEUDOVECTOR_REST_MASK) >> PSEUDOVECTOR_SIZE_BITS)
658 else 682 else
659 output $size & ~ARRAY_MARK_FLAG 683 output ($size & ~ARRAY_MARK_FLAG)
660 end 684 end
661 echo \n 685 echo \n
662end 686end
663document xvectype 687document pvecsize
664Print the size or vector subtype of $. 688Print the size of vectorlike object.
665This command assumes that $ is a vector or pseudovector. 689Takes one argument, a pointer to an object.
690end
691
692define xvecsize
693 xgetptr $
694 pvecsize $ptr
695end
696document xvecsize
697Print the size of $
698This command assumes that $ is a Lisp_Object.
666end 699end
667 700
668define xmisctype 701define xmisctype
@@ -996,7 +1029,7 @@ define xpr
996 if $type == Lisp_Vectorlike 1029 if $type == Lisp_Vectorlike
997 set $size = ((struct Lisp_Vector *) $ptr)->header.size 1030 set $size = ((struct Lisp_Vector *) $ptr)->header.size
998 if ($size & PSEUDOVECTOR_FLAG) 1031 if ($size & PSEUDOVECTOR_FLAG)
999 set $vec = (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_SIZE_BITS) 1032 set $vec = (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS)
1000 if $vec == PVEC_NORMAL_VECTOR 1033 if $vec == PVEC_NORMAL_VECTOR
1001 xvector 1034 xvector
1002 end 1035 end
@@ -1132,7 +1165,7 @@ define xbacktrace
1132 xgetptr ($bt->function) 1165 xgetptr ($bt->function)
1133 set $size = ((struct Lisp_Vector *) $ptr)->header.size 1166 set $size = ((struct Lisp_Vector *) $ptr)->header.size
1134 if ($size & PSEUDOVECTOR_FLAG) 1167 if ($size & PSEUDOVECTOR_FLAG)
1135 output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_SIZE_BITS) 1168 output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS)
1136 else 1169 else
1137 output $size & ~ARRAY_MARK_FLAG 1170 output $size & ~ARRAY_MARK_FLAG
1138 end 1171 end
diff --git a/src/ChangeLog b/src/ChangeLog
index efe5e59cb73..e67518d63ba 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -3,6 +3,346 @@
3 * font.c (font_unparse_xlfd): Exclude special characters from the 3 * font.c (font_unparse_xlfd): Exclude special characters from the
4 generating XLFD name. 4 generating XLFD name.
5 5
62012-11-13 Dmitry Antipov <dmantipov@yandex.ru>
7
8 Omit glyphs initialization at startup.
9 * dispnew.c (glyphs_initialized_initially_p): Remove.
10 (adjust_frame_glyphs_initially): Likewise. Adjust users.
11 (Fredraw_frame): Move actual code from here...
12 (redraw_here): ...to here. Add eassert. Adjust comment.
13 (Fredraw_display): Use redraw_frame.
14 * xdisp.c (clear_garbaged_frames): Likewise.
15
162012-11-13 Eli Zaretskii <eliz@gnu.org>
17
18 * xdisp.c (decode_mode_spec): Limit the value of WIDTH argument
19 passed to pint2str and pint2hrstr to be at most the size of the
20 frame's decode_mode_spec_buffer. This avoids crashes with very
21 large values of FIELD_WIDTH argument to decode_mode_spec.
22 (Bug#12867)
23
242012-11-13 Paul Eggert <eggert@cs.ucla.edu>
25
26 Fix a race with verify-visited-file-modtime (Bug#12863).
27 Since at least 1991 Emacs has ignored an mtime difference of no
28 more than one second, but my guess is that this was to work around
29 file system bugs that were fixed long ago. Since the race is
30 causing problems now, let's remove that code.
31 * fileio.c (Fverify_visited_file_modtime): Do not accept a file
32 whose time stamp is off by no more than a second. Insist that the
33 file time stamps match exactly.
34
352012-11-12 Dmitry Antipov <dmantipov@yandex.ru>
36
37 * frame.h (struct frame): Convert external_tool_bar member to
38 1-bit unsigned bitfield.
39 * termhooks.h (struct terminal): Remove mouse_moved member since
40 all users are long dead. Adjust comment on mouse_position_hook.
41
422012-11-12 Dmitry Antipov <dmantipov@yandex.ru>
43
44 Simplify by using FOR_EACH_FRAME here and there.
45 * frame.c (next_frame, prev_frame, other_visible_frames)
46 (delete_frame, visible-frame-list): Use FOR_EACH_FRAME.
47 * w32term.c (x_window_to_scroll_bar): Likewise.
48 * window.c (window_list): Likewise.
49 * xdisp.c (x_consider_frame_title): Likewise.
50 * xfaces.c ( Fdisplay_supports_face_attributes_p): Likewise.
51 * xfns.c (x_window_to_frame, x_any_window_to_frame)
52 (x_menubar_window_to_frame, x_top_window_to_frame): Likewise.
53 * xmenu.c (menubar_id_to_frame): Likewise.
54 * xselect.c (frame_for_x_selection): Likewise.
55 * xterm.c (x_frame_of_widget, x_window_to_scroll_bar)
56 (x_window_to_menu_bar): Likewise.
57 * w32fns.c (x_window_to_frame): Likewise. Adjust comment.
58
592012-11-12 Paul Eggert <eggert@cs.ucla.edu>
60
61 * data.c (Qdefalias_fset_function): Now static.
62
63 Another tweak to vectorlike_header change.
64 * alloc.c (struct Lisp_Vectorlike_Free, NEXT_IN_FREE_LIST):
65 Remove, and replace all uses with ...
66 (next_in_free_list, set_next_in_free_list):
67 New functions, which respect C's aliasing rules better.
68
692012-11-11 Paul Eggert <eggert@cs.ucla.edu>
70
71 * window.c (list4i): Rename from 'quad'. All uses changed.
72 Needed because <sys/types.h> defines 'quad' on Solaris 10.
73
742012-11-11 Juanma Barranquero <lekktu@gmail.com>
75
76 * xdisp.c (start_hourglass) [HAVE_NTGUI]: Add block to silence
77 warning about mixing declarations and code in ISO C90.
78
792012-11-10 Martin Rudalics <rudalics@gmx.at>
80
81 * window.c (Fsplit_window_internal): Set combination limit of
82 new parent window to t iff Vwindow_combination_limit is t;
83 fixing a regression introduced with the change from 2012-09-22.
84 (Fset_window_combination_limit): Fix doc-string.
85
862012-11-10 Eli Zaretskii <eliz@gnu.org>
87
88 * xdisp.c (try_scrolling): Fix correction of aggressive-scroll
89 amount when the scroll margins are too large. When scrolling
90 backwards in the buffer, give up if cannot reach point or the
91 scroll margin within a reasonable number of screen lines. Fixes
92 point position in window under scroll-up/down-aggressively when
93 point is positioned many lines beyond the window top/bottom.
94 (Bug#12811)
95
96 * ralloc.c (relinquish): If real_morecore fails to return memory
97 to the system, don't crash; instead, leave the last heap
98 unchanged and return. (Bug#12774)
99
1002012-11-09 Stefan Monnier <monnier@iro.umontreal.ca>
101
102 * lisp.h (AUTOLOADP): New macro.
103 * eval.c (Fautoload): Don't attach to loadhist, call Fdefalias instead.
104 * data.c (Ffset): Remove special ad-advice-info handling.
105 (Fdefalias): Handle autoload definitions and new Qdefalias_fset_function.
106 (Fsubr_arity): CSE.
107 (Finteractive_form): Simplify.
108 (Fquo): Don't insist on having at least 2 arguments.
109 (Qdefalias_fset_function): New var.
110
1112012-11-09 Jan Djärv <jan.h.d@swipnet.se>
112
113 * image.c (xpm_make_color_table_h): Change to hashtest_equal.
114
115 * nsfont.m (Qcondensed, Qexpanded): New variables.
116 (ns_descriptor_to_entity): Restore Qcondensed, Qexpanded setting.
117 (syms_of_nsfont): Defsym Qcondensed, Qexpanded.
118
1192012-11-09 Dmitry Antipov <dmantipov@yandex.ru>
120
121 Fix recently introduced crash on MS-Windows (Bug#12839).
122 * w32term.h (struct scroll_bar): Use convenient header.
123 (SCROLL_BAR_VEC_SIZE): Remove.
124 * w32term.c (x_scroll_bar_create): Use VECSIZE.
125
1262012-11-09 Dmitry Antipov <dmantipov@yandex.ru>
127
128 Tweak last vectorlike_header change.
129 * alloc.c (struct Lisp_Vectorlike_Free): Special type to represent
130 vectorlike object on the free list. This is introduced to avoid
131 some (but not all) pointer casting and aliasing problems, see
132 http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00105.html.
133 * .gdbinit (pvectype, pvecsize): New commands to examine vectorlike
134 objects.
135 (xvectype, xvecsize): Use them to examine Lisp_Object values.
136
1372012-11-09 Jan Djärv <jan.h.d@swipnet.se>
138
139 * nsfont.m (ns_descriptor_to_entity): Qcondensed and Qexpanded has
140 been removed, so remove them here also.
141
1422012-11-09 Stefan Monnier <monnier@iro.umontreal.ca>
143
144 * doc.c (Fdocumentation): Handle new property
145 dynamic-docstring-function to replace the old ad-advice-info.
146
1472012-11-09 Paul Eggert <eggert@cs.ucla.edu>
148
149 * fns.c (Qeql, hashtest_eq): Now static.
150
1512012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
152
153 * lisp.h (XHASH): Redefine to be imperfect and fit in a Lisp int.
154 * fns.c (hashfn_eq, hashfn_eql, sxhash):
155 * profiler.c (hashfn_profiler): Don't use XUINT on non-integers.
156 * buffer.c (compare_overlays): Use XLI rather than XHASH.
157
1582012-11-08 Paul Eggert <eggert@cs.ucla.edu>
159
160 Use same hash function for hashfn_profiler as for hash_string etc.
161 * fns.c (SXHASH_COMBINE): Remove. All uses replaced by sxhash_combine.
162 * lisp.h (sxhash_combine): New inline function, with the contents
163 of the old SXHASH_COMBINE.
164 * profiler.c (hashfn_profiler): Use it, instead of having a
165 special hash function containing a comparison that always yields 1.
166
1672012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
168
169 * xfaces.c (Qultra_light, Qreverse_oblique, Qreverse_italic)
170 (Qultra_condensed, Qextra_condensed, Qcondensed, Qsemi_condensed)
171 (Qsemi_expanded, Qextra_expanded, Qexpanded, Qultra_expanded):
172 Remove unused vars.
173
1742012-11-08 Jan Djärv <jan.h.d@swipnet.se>
175
176 * image.c (xpm_make_color_table_h): Fix compiler error because
177 make_hash_table changed.
178
1792012-11-08 Thomas Kappler <tkappler@gmail.com> (tiny change)
180
181 * nsfont.m (ns_findfonts): Handle empty matchingDescs (Bug#11541).
182
1832012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
184
185 Use ad-hoc comparison function for the profiler's hash-tables.
186 * profiler.c (Qprofiler_backtrace_equal, hashtest_profiler): New vars.
187 (make_log): Use them.
188 (handle_profiler_signal): Don't inhibit quit any longer since we don't
189 call Fequal any more.
190 (Ffunction_equal): New function.
191 (cmpfn_profiler, hashfn_profiler): New functions.
192 (syms_of_profiler): Initialize them.
193 * lisp.h (struct hash_table_test): New struct.
194 (struct Lisp_Hash_Table): Use it.
195 * alloc.c (mark_object): Mark hash_table_test fields of hash tables.
196 * fns.c (make_hash_table): Take a struct to describe the test.
197 (cmpfn_eql, cmpfn_equal, cmpfn_user_defined, hashfn_eq, hashfn_eql)
198 (hashfn_equal, hashfn_user_defined): Adjust to new calling convention.
199 (hash_lookup, hash_remove_from_table): Move assertion checking of
200 hashfn result here. Check hash-equality before calling cmpfn.
201 (Fmake_hash_table): Adjust call to make_hash_table.
202 (hashtest_eq, hashtest_eql, hashtest_equal): New structs.
203 (syms_of_fns): Initialize them.
204 * emacs.c (main): Move syms_of_fns earlier.
205 * xterm.c (syms_of_xterm):
206 * category.c (hash_get_category_set): Adjust call to make_hash_table.
207 * print.c (print_object): Adjust to new hash-table struct.
208 * composite.c (composition_gstring_put_cache): Adjust to new hashfn.
209
2102012-11-08 Eli Zaretskii <eliz@gnu.org>
211
212 * w32fns.c (modifier_set): Fix handling of Scroll Lock when the
213 value of w32-scroll-lock-modifier is neither nil nor one of the
214 known key modifiers. (Bug#12806)
215
2162012-11-08 Dmitry Antipov <dmantipov@yandex.ru>
217
218 Shrink struct vectorlike_header to the only size field.
219 * lisp.h (enum pvec_type): Avoid explicit enum member values.
220 Adjust comment.
221 (enum More_Lisp_Bits): Change PSEUDOVECTOR_SIZE_BITS and
222 PVEC_TYPE_MASK to arrange new bitfield in the vector header.
223 (PSEUDOVECTOR_REST_BITS, PSEUDOVECTOR_REST_MASK): New members.
224 (PSEUDOVECTOR_AREA_BITS): New member used to extract subtype
225 information from the vector header. Adjust comment.
226 (XSETPVECTYPE, XSETPVECTYPESIZE, XSETTYPED_PSEUDOVECTOR)
227 (PSEUDOVECTOR_TYPEP, DEFUN): Adjust to match new vector header
228 layout.
229 (XSETSUBR, SUBRP): Adjust to match new Lisp_Subr layout.
230 (struct vectorlike_header): Remove next member. Adjust comment.
231 (struct Lisp_Subr): Add convenient header. Adjust comment.
232 (allocate_pseudovector): Adjust prototype.
233 * alloc.c (mark_glyph_matrix, mark_face_cache, allocate_string)
234 (sweep_string, lisp_malloc): Remove useless prototypes.
235 (enum mem_type): Adjust comment.
236 (NEXT_IN_FREE_LIST): New macro.
237 (SETUP_ON_FREE_LIST): Adjust XSETPVECTYPESIZE usage.
238 (Fmake_bool_vector): Likewise.
239 (struct large_vector): New type to represent allocation unit for
240 the vectors with the memory footprint more than VBLOOCK_BYTES_MAX.
241 (large_vectors): Change type to struct large_vector.
242 (allocate_vector_from_block): Simplify.
243 (PSEUDOVECTOR_NBYTES): Replace with...
244 (vector_nbytes): ...new function. Adjust users.
245 (sweep_vectors): Adjust processing of large vectors.
246 (allocate_vectorlike): Likewise.
247 (allocate_pseudovector): Change type of 3rd arg to enum pvec_type.
248 Add easserts. Adjust XSETPVECTYPESIZE usage.
249 (allocate_buffer): Use BUFFER_PVEC_INIT.
250 (live_vector_p): Adjust to match large vector.
251 * buffer.c (init_buffer_once): Use BUFFER_PVEC_INIT.
252 * buffer.h (struct buffer): Add next member.
253 (BUFFER_LISP_SIZE, BUFFER_REST_SIZE, BUFFER_PVEC_INIT):
254 New macros.
255 (FOR_EACH_BUFFER): Adjust to match struct buffer change.
256 * fns.c (internal_equal): Adjust to match enum pvec_type change.
257 (copy_hash_table): Adjust to match vector header change.
258 * lread.c (defsubr): Use XSETPVECTYPE.
259 * .gdbinit (xpr, xbacktrace): Adjust to match vector header change.
260 (xvectype): Likewise. Print PVEC_NORMAL_VECTOR for regular vectors.
261 (xvecsize): New command.
262
2632012-11-08 Dmitry Antipov <dmantipov@yandex.ru>
264
265 * keyboard.c (event_to_kboard): Do not dereference
266 frame_or_window field of SELECTION_REQUEST_EVENT
267 and SELECTION_CLEAR_EVENT events (Bug#12814).
268 * xterm.h (struct selection_input_event): Adjust comment.
269
2702012-11-07 Eli Zaretskii <eliz@gnu.org>
271
272 * w32fns.c (modifier_set): Don't report modifiers from toggle key,
273 such as Scroll Lock, if the respective keys are treated as
274 function keys, not as modifiers. This avoids destroying non-ASCII
275 keyboard input when Scroll Lock is toggled ON. (Bug#12806)
276
2772012-11-07 Dmitry Antipov <dmantipov@yandex.ru>
278
279 * xfns.c (Fx_wm_set_size_hint): Use check_x_frame. Adjust docstring.
280
2812012-11-06 Paul Eggert <eggert@cs.ucla.edu>
282
283 Restore some duplicate definitions (Bug#12814).
284 This undoes part of the 2012-11-03 changes. Some people build
285 with plain -g rather than with -g3, and they need the duplicate
286 definitions for .gdbinit to work; see <http://bugs.gnu.org/12814#26>.
287 * lisp.h (GCTYPEBITS, ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, VALMASK):
288 Define as macros, as well as as enums or as constants.
289
2902012-11-06 Jan Djärv <jan.h.d@swipnet.se>
291
292 * nsterm.m (convert_ns_to_X_keysym, keyDown:): Add NSNumericPadKeyMask
293 to keypad keys (Bug#12816).
294
2952012-11-06 Paul Eggert <eggert@cs.ucla.edu>
296
297 Minor adjustments of recently-changed frame functions.
298 * buffer.c (Fbuffer_list): Omit CHECK_FRAME, since arg is already
299 known to be a frame (we're in the FRAMEP branch).
300 * lisp.h (Qframep): Remove decl. frame.h declares this.
301 * window.c (quad): Args are of type EMACS_INT, not ptrdiff_t,
302 since they're meant for Lisp fixnum values.
303
3042012-11-06 Dmitry Antipov <dmantipov@yandex.ru>
305
306 * window.c (Fwindow_combination_limit): Revert to the only
307 required argument and adjust docstring as suggested in
308 http://lists.gnu.org/archive/html/emacs-diffs/2012-11/msg01082.html
309 by Martin Rudalics <rudalics@gmx.at>.
310
3112012-11-06 Dmitry Antipov <dmantipov@yandex.ru>
312
313 Widely used frame validity and checking functions.
314 * frame.h (decode_live_frame, decode_any_frame): Add prototypes.
315 * frame.c (decode_live_frame, decode_any_frame): New functions.
316 (delete_frame, Fredirect_frame_focus, Fframe_parameters)
317 (Fframe_parameter, Fframe_char_height, Fframe_char_width)
318 (Fframe_pixel_height, Fframe_pixel_width, Ftool_bar_pixel_width)
319 (Fframe_pointer_visible_p): Use decode_any_frame.
320 (Fmake_frame_visible, Fmake_frame_invisible, Ficonify_frame)
321 (Fraise_frame, Flower_frame, Fmodify_frame_parameters)
322 (Fset_frame_height, Fset_frame_width): Use decode_live_frame.
323 (Fframe_focus): Likewise. Allow zero number of arguments.
324 Adjust docstring.
325 (frame_buffer_list, frame_buffer_predicate): Remove.
326 * lisp.h (frame_buffer_predicate): Remove prototype.
327 * buffer.c (Fother_buffer): Use decode_any_frame.
328 * xdisp.c (Ftool_bar_lines_needed): Likewise.
329 * xfaces.c (Fcolor_gray_p, Fcolor_supported_p): Likewise.
330 * font.c (Ffont_face_attributes, Ffont_family_list, Fopen_font)
331 (Fclose_font, Ffont_info): Use decode_live_frame.
332 * fontset.c (check_fontset_name): Likewise.
333 * terminal.c (Fframe_terminal): Likewise.
334 * w32fns.c (check_x_frame): Likewise.
335 * window.c (Fminibuffer_window, Fwindow_at)
336 (Fcurrent_window_configuration): Likewise.
337 (Frun_window_configuration_change_hook, Fwindow_resize_apply):
338 Likewise. Allow zero number of arguments. Adjust docstring.
339 * dispnew.c (Fredraw_frame): Likewise.
340 * xfaces.c (frame_or_selected_frame): Remove.
341 (Fx_list_fonts, Finternal_get_lisp_face_attribute, Fface_font)
342 (Finternal_lisp_face_equal_p, Finternal_lisp_face_empty_p)
343 (Fframe_face_alist): Use decode_live_frame.
344 * xfns.c (check_x_frame): Likewise.
345
62012-11-06 Dmitry Antipov <dmantipov@yandex.ru> 3462012-11-06 Dmitry Antipov <dmantipov@yandex.ru>
7 347
8 * window.c (quad): New function. 348 * window.c (quad): New function.
@@ -58,8 +398,8 @@
58 398
59 Remove EMACS_OUTQSIZE+sleep hack. 399 Remove EMACS_OUTQSIZE+sleep hack.
60 * dispnew.c (update_frame_1): Remove hack for terminals slower 400 * dispnew.c (update_frame_1): Remove hack for terminals slower
61 than 2400 bps, which throttled Emacs by having it sleep. This 401 than 2400 bps, which throttled Emacs by having it sleep.
62 code hasn't worked since at least 2007, when the multi-tty stuff 402 This code hasn't worked since at least 2007, when the multi-tty stuff
63 was added, and anyway those old terminals are long dead. 403 was added, and anyway those old terminals are long dead.
64 * systty.h (EMACS_OUTQSIZE): Remove; unused. The macro isn't used even 404 * systty.h (EMACS_OUTQSIZE): Remove; unused. The macro isn't used even
65 without the dispnew.c change, as dispnew.c doesn't include systty.h. 405 without the dispnew.c change, as dispnew.c doesn't include systty.h.
@@ -98,8 +438,8 @@
98 waitpid only on subprocesses that Emacs itself creates. 438 waitpid only on subprocesses that Emacs itself creates.
99 * process.c (create_process, record_child_status_change): 439 * process.c (create_process, record_child_status_change):
100 Don't use special value -1 in pid field, as the caller now must 440 Don't use special value -1 in pid field, as the caller now must
101 know the pid rather than having the callee infer it. The 441 know the pid rather than having the callee infer it.
102 inference was sometimes incorrect anyway, due to another race. 442 The inference was sometimes incorrect anyway, due to another race.
103 (create_process): Set new 'alive' member if child is created. 443 (create_process): Set new 'alive' member if child is created.
104 (process_status_retrieved): New function. 444 (process_status_retrieved): New function.
105 (record_child_status_change): Use it. 445 (record_child_status_change): Use it.
@@ -260,8 +600,8 @@
260 600
2612012-10-29 Daniel Colascione <dancol@dancol.org> 6012012-10-29 Daniel Colascione <dancol@dancol.org>
262 602
263 * cygw32.h, cygw32.c (Qutf_16le, from_unicode, to_unicode): In 603 * cygw32.h, cygw32.c (Qutf_16le, from_unicode, to_unicode):
264 preparation for fixing bug#12739, move these functions from 604 In preparation for fixing bug#12739, move these functions from
265 here... 605 here...
266 606
267 * coding.h, coding.c: ... to here, and compile them only when 607 * coding.h, coding.c: ... to here, and compile them only when
diff --git a/src/alloc.c b/src/alloc.c
index 5bb528c64ab..a66a752f5dc 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -216,23 +216,19 @@ static Lisp_Object Qpost_gc_hook;
216static void mark_terminals (void); 216static void mark_terminals (void);
217static void gc_sweep (void); 217static void gc_sweep (void);
218static Lisp_Object make_pure_vector (ptrdiff_t); 218static Lisp_Object make_pure_vector (ptrdiff_t);
219static void mark_glyph_matrix (struct glyph_matrix *);
220static void mark_face_cache (struct face_cache *);
221static void mark_buffer (struct buffer *); 219static void mark_buffer (struct buffer *);
222 220
223#if !defined REL_ALLOC || defined SYSTEM_MALLOC 221#if !defined REL_ALLOC || defined SYSTEM_MALLOC
224static void refill_memory_reserve (void); 222static void refill_memory_reserve (void);
225#endif 223#endif
226static struct Lisp_String *allocate_string (void);
227static void compact_small_strings (void); 224static void compact_small_strings (void);
228static void free_large_strings (void); 225static void free_large_strings (void);
229static void sweep_strings (void);
230static void free_misc (Lisp_Object); 226static void free_misc (Lisp_Object);
231extern Lisp_Object which_symbols (Lisp_Object, EMACS_INT) EXTERNALLY_VISIBLE; 227extern Lisp_Object which_symbols (Lisp_Object, EMACS_INT) EXTERNALLY_VISIBLE;
232 228
233/* When scanning the C stack for live Lisp objects, Emacs keeps track 229/* When scanning the C stack for live Lisp objects, Emacs keeps track of
234 of what memory allocated via lisp_malloc is intended for what 230 what memory allocated via lisp_malloc and lisp_align_malloc is intended
235 purpose. This enumeration specifies the type of memory. */ 231 for what purpose. This enumeration specifies the type of memory. */
236 232
237enum mem_type 233enum mem_type
238{ 234{
@@ -243,10 +239,9 @@ enum mem_type
243 MEM_TYPE_MISC, 239 MEM_TYPE_MISC,
244 MEM_TYPE_SYMBOL, 240 MEM_TYPE_SYMBOL,
245 MEM_TYPE_FLOAT, 241 MEM_TYPE_FLOAT,
246 /* We used to keep separate mem_types for subtypes of vectors such as 242 /* Since all non-bool pseudovectors are small enough to be
247 process, hash_table, frame, terminal, and window, but we never made 243 allocated from vector blocks, this memory type denotes
248 use of the distinction, so it only caused source-code complexity 244 large regular vectors and large bool pseudovectors. */
249 and runtime slowdown. Minor but pointless. */
250 MEM_TYPE_VECTORLIKE, 245 MEM_TYPE_VECTORLIKE,
251 /* Special type to denote vector blocks. */ 246 /* Special type to denote vector blocks. */
252 MEM_TYPE_VECTOR_BLOCK, 247 MEM_TYPE_VECTOR_BLOCK,
@@ -254,9 +249,6 @@ enum mem_type
254 MEM_TYPE_SPARE 249 MEM_TYPE_SPARE
255}; 250};
256 251
257static void *lisp_malloc (size_t, enum mem_type);
258
259
260#if GC_MARK_STACK || defined GC_MALLOC_CHECK 252#if GC_MARK_STACK || defined GC_MALLOC_CHECK
261 253
262#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 254#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
@@ -2040,7 +2032,7 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */)
2040 val = Fmake_vector (make_number (length_in_elts + extra_bool_elts), Qnil); 2032 val = Fmake_vector (make_number (length_in_elts + extra_bool_elts), Qnil);
2041 2033
2042 /* No Lisp_Object to trace in there. */ 2034 /* No Lisp_Object to trace in there. */
2043 XSETPVECTYPESIZE (XVECTOR (val), PVEC_BOOL_VECTOR, 0); 2035 XSETPVECTYPESIZE (XVECTOR (val), PVEC_BOOL_VECTOR, 0, 0);
2044 2036
2045 p = XBOOL_VECTOR (val); 2037 p = XBOOL_VECTOR (val);
2046 p->size = XFASTINT (length); 2038 p->size = XFASTINT (length);
@@ -2619,19 +2611,54 @@ verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS));
2619 2611
2620#define VINDEX(nbytes) (((nbytes) - VBLOCK_BYTES_MIN) / roundup_size) 2612#define VINDEX(nbytes) (((nbytes) - VBLOCK_BYTES_MIN) / roundup_size)
2621 2613
2614/* Get and set the next field in block-allocated vectorlike objects on
2615 the free list. Doing it this way respects C's aliasing rules.
2616 We could instead make 'contents' a union, but that would mean
2617 changes everywhere that the code uses 'contents'. */
2618static struct Lisp_Vector *
2619next_in_free_list (struct Lisp_Vector *v)
2620{
2621 intptr_t i = XLI (v->contents[0]);
2622 return (struct Lisp_Vector *) i;
2623}
2624static void
2625set_next_in_free_list (struct Lisp_Vector *v, struct Lisp_Vector *next)
2626{
2627 v->contents[0] = XIL ((intptr_t) next);
2628}
2629
2622/* Common shortcut to setup vector on a free list. */ 2630/* Common shortcut to setup vector on a free list. */
2623 2631
2624#define SETUP_ON_FREE_LIST(v, nbytes, index) \ 2632#define SETUP_ON_FREE_LIST(v, nbytes, tmp) \
2625 do { \ 2633 do { \
2626 XSETPVECTYPESIZE (v, PVEC_FREE, nbytes); \ 2634 (tmp) = ((nbytes - header_size) / word_size); \
2627 eassert ((nbytes) % roundup_size == 0); \ 2635 XSETPVECTYPESIZE (v, PVEC_FREE, 0, (tmp)); \
2628 (index) = VINDEX (nbytes); \ 2636 eassert ((nbytes) % roundup_size == 0); \
2629 eassert ((index) < VECTOR_MAX_FREE_LIST_INDEX); \ 2637 (tmp) = VINDEX (nbytes); \
2630 (v)->header.next.vector = vector_free_lists[index]; \ 2638 eassert ((tmp) < VECTOR_MAX_FREE_LIST_INDEX); \
2631 vector_free_lists[index] = (v); \ 2639 set_next_in_free_list (v, vector_free_lists[tmp]); \
2632 total_free_vector_slots += (nbytes) / word_size; \ 2640 vector_free_lists[tmp] = (v); \
2641 total_free_vector_slots += (nbytes) / word_size; \
2633 } while (0) 2642 } while (0)
2634 2643
2644/* This internal type is used to maintain the list of large vectors
2645 which are allocated at their own, e.g. outside of vector blocks. */
2646
2647struct large_vector
2648{
2649 union {
2650 struct large_vector *vector;
2651#if USE_LSB_TAG
2652 /* We need to maintain ROUNDUP_SIZE alignment for the vector member. */
2653 unsigned char c[vroundup (sizeof (struct large_vector *))];
2654#endif
2655 } next;
2656 struct Lisp_Vector v;
2657};
2658
2659/* This internal type is used to maintain an underlying storage
2660 for small vectors. */
2661
2635struct vector_block 2662struct vector_block
2636{ 2663{
2637 char data[VECTOR_BLOCK_BYTES]; 2664 char data[VECTOR_BLOCK_BYTES];
@@ -2649,7 +2676,7 @@ static struct Lisp_Vector *vector_free_lists[VECTOR_MAX_FREE_LIST_INDEX];
2649 2676
2650/* Singly-linked list of large vectors. */ 2677/* Singly-linked list of large vectors. */
2651 2678
2652static struct Lisp_Vector *large_vectors; 2679static struct large_vector *large_vectors;
2653 2680
2654/* The only vector with 0 slots, allocated from pure space. */ 2681/* The only vector with 0 slots, allocated from pure space. */
2655 2682
@@ -2693,7 +2720,7 @@ init_vectors (void)
2693static struct Lisp_Vector * 2720static struct Lisp_Vector *
2694allocate_vector_from_block (size_t nbytes) 2721allocate_vector_from_block (size_t nbytes)
2695{ 2722{
2696 struct Lisp_Vector *vector, *rest; 2723 struct Lisp_Vector *vector;
2697 struct vector_block *block; 2724 struct vector_block *block;
2698 size_t index, restbytes; 2725 size_t index, restbytes;
2699 2726
@@ -2706,8 +2733,7 @@ allocate_vector_from_block (size_t nbytes)
2706 if (vector_free_lists[index]) 2733 if (vector_free_lists[index])
2707 { 2734 {
2708 vector = vector_free_lists[index]; 2735 vector = vector_free_lists[index];
2709 vector_free_lists[index] = vector->header.next.vector; 2736 vector_free_lists[index] = next_in_free_list (vector);
2710 vector->header.next.nbytes = nbytes;
2711 total_free_vector_slots -= nbytes / word_size; 2737 total_free_vector_slots -= nbytes / word_size;
2712 return vector; 2738 return vector;
2713 } 2739 }
@@ -2721,16 +2747,14 @@ allocate_vector_from_block (size_t nbytes)
2721 { 2747 {
2722 /* This vector is larger than requested. */ 2748 /* This vector is larger than requested. */
2723 vector = vector_free_lists[index]; 2749 vector = vector_free_lists[index];
2724 vector_free_lists[index] = vector->header.next.vector; 2750 vector_free_lists[index] = next_in_free_list (vector);
2725 vector->header.next.nbytes = nbytes;
2726 total_free_vector_slots -= nbytes / word_size; 2751 total_free_vector_slots -= nbytes / word_size;
2727 2752
2728 /* Excess bytes are used for the smaller vector, 2753 /* Excess bytes are used for the smaller vector,
2729 which should be set on an appropriate free list. */ 2754 which should be set on an appropriate free list. */
2730 restbytes = index * roundup_size + VBLOCK_BYTES_MIN - nbytes; 2755 restbytes = index * roundup_size + VBLOCK_BYTES_MIN - nbytes;
2731 eassert (restbytes % roundup_size == 0); 2756 eassert (restbytes % roundup_size == 0);
2732 rest = ADVANCE (vector, nbytes); 2757 SETUP_ON_FREE_LIST (ADVANCE (vector, nbytes), restbytes, index);
2733 SETUP_ON_FREE_LIST (rest, restbytes, index);
2734 return vector; 2758 return vector;
2735 } 2759 }
2736 2760
@@ -2739,7 +2763,6 @@ allocate_vector_from_block (size_t nbytes)
2739 2763
2740 /* New vector will be at the beginning of this block. */ 2764 /* New vector will be at the beginning of this block. */
2741 vector = (struct Lisp_Vector *) block->data; 2765 vector = (struct Lisp_Vector *) block->data;
2742 vector->header.next.nbytes = nbytes;
2743 2766
2744 /* If the rest of space from this block is large enough 2767 /* If the rest of space from this block is large enough
2745 for one-slot vector at least, set up it on a free list. */ 2768 for one-slot vector at least, set up it on a free list. */
@@ -2747,11 +2770,10 @@ allocate_vector_from_block (size_t nbytes)
2747 if (restbytes >= VBLOCK_BYTES_MIN) 2770 if (restbytes >= VBLOCK_BYTES_MIN)
2748 { 2771 {
2749 eassert (restbytes % roundup_size == 0); 2772 eassert (restbytes % roundup_size == 0);
2750 rest = ADVANCE (vector, nbytes); 2773 SETUP_ON_FREE_LIST (ADVANCE (vector, nbytes), restbytes, index);
2751 SETUP_ON_FREE_LIST (rest, restbytes, index);
2752 } 2774 }
2753 return vector; 2775 return vector;
2754 } 2776}
2755 2777
2756/* Nonzero if VECTOR pointer is valid pointer inside BLOCK. */ 2778/* Nonzero if VECTOR pointer is valid pointer inside BLOCK. */
2757 2779
@@ -2759,15 +2781,30 @@ allocate_vector_from_block (size_t nbytes)
2759 ((char *) (vector) <= (block)->data \ 2781 ((char *) (vector) <= (block)->data \
2760 + VECTOR_BLOCK_BYTES - VBLOCK_BYTES_MIN) 2782 + VECTOR_BLOCK_BYTES - VBLOCK_BYTES_MIN)
2761 2783
2762/* Number of bytes used by vector-block-allocated object. This is the only 2784/* Return the memory footprint of V in bytes. */
2763 place where we actually use the `nbytes' field of the vector-header.
2764 I.e. we could get rid of the `nbytes' field by computing it based on the
2765 vector-type. */
2766 2785
2767#define PSEUDOVECTOR_NBYTES(vector) \ 2786static ptrdiff_t
2768 (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_FREE) \ 2787vector_nbytes (struct Lisp_Vector *v)
2769 ? vector->header.size & PSEUDOVECTOR_SIZE_MASK \ 2788{
2770 : vector->header.next.nbytes) 2789 ptrdiff_t size = v->header.size & ~ARRAY_MARK_FLAG;
2790
2791 if (size & PSEUDOVECTOR_FLAG)
2792 {
2793 if (PSEUDOVECTOR_TYPEP (&v->header, PVEC_BOOL_VECTOR))
2794 size = (bool_header_size
2795 + (((struct Lisp_Bool_Vector *) v)->size
2796 + BOOL_VECTOR_BITS_PER_CHAR - 1)
2797 / BOOL_VECTOR_BITS_PER_CHAR);
2798 else
2799 size = (header_size
2800 + ((size & PSEUDOVECTOR_SIZE_MASK)
2801 + ((size & PSEUDOVECTOR_REST_MASK)
2802 >> PSEUDOVECTOR_SIZE_BITS)) * word_size);
2803 }
2804 else
2805 size = header_size + size * word_size;
2806 return vroundup (size);
2807}
2771 2808
2772/* Reclaim space used by unmarked vectors. */ 2809/* Reclaim space used by unmarked vectors. */
2773 2810
@@ -2775,7 +2812,8 @@ static void
2775sweep_vectors (void) 2812sweep_vectors (void)
2776{ 2813{
2777 struct vector_block *block = vector_blocks, **bprev = &vector_blocks; 2814 struct vector_block *block = vector_blocks, **bprev = &vector_blocks;
2778 struct Lisp_Vector *vector, *next, **vprev = &large_vectors; 2815 struct large_vector *lv, **lvprev = &large_vectors;
2816 struct Lisp_Vector *vector, *next;
2779 2817
2780 total_vectors = total_vector_slots = total_free_vector_slots = 0; 2818 total_vectors = total_vector_slots = total_free_vector_slots = 0;
2781 memset (vector_free_lists, 0, sizeof (vector_free_lists)); 2819 memset (vector_free_lists, 0, sizeof (vector_free_lists));
@@ -2785,6 +2823,7 @@ sweep_vectors (void)
2785 for (block = vector_blocks; block; block = *bprev) 2823 for (block = vector_blocks; block; block = *bprev)
2786 { 2824 {
2787 bool free_this_block = 0; 2825 bool free_this_block = 0;
2826 ptrdiff_t nbytes;
2788 2827
2789 for (vector = (struct Lisp_Vector *) block->data; 2828 for (vector = (struct Lisp_Vector *) block->data;
2790 VECTOR_IN_BLOCK (vector, block); vector = next) 2829 VECTOR_IN_BLOCK (vector, block); vector = next)
@@ -2793,14 +2832,16 @@ sweep_vectors (void)
2793 { 2832 {
2794 VECTOR_UNMARK (vector); 2833 VECTOR_UNMARK (vector);
2795 total_vectors++; 2834 total_vectors++;
2796 total_vector_slots += vector->header.next.nbytes / word_size; 2835 nbytes = vector_nbytes (vector);
2797 next = ADVANCE (vector, vector->header.next.nbytes); 2836 total_vector_slots += nbytes / word_size;
2837 next = ADVANCE (vector, nbytes);
2798 } 2838 }
2799 else 2839 else
2800 { 2840 {
2801 ptrdiff_t nbytes = PSEUDOVECTOR_NBYTES (vector); 2841 ptrdiff_t total_bytes;
2802 ptrdiff_t total_bytes = nbytes;
2803 2842
2843 nbytes = vector_nbytes (vector);
2844 total_bytes = nbytes;
2804 next = ADVANCE (vector, nbytes); 2845 next = ADVANCE (vector, nbytes);
2805 2846
2806 /* While NEXT is not marked, try to coalesce with VECTOR, 2847 /* While NEXT is not marked, try to coalesce with VECTOR,
@@ -2810,7 +2851,7 @@ sweep_vectors (void)
2810 { 2851 {
2811 if (VECTOR_MARKED_P (next)) 2852 if (VECTOR_MARKED_P (next))
2812 break; 2853 break;
2813 nbytes = PSEUDOVECTOR_NBYTES (next); 2854 nbytes = vector_nbytes (next);
2814 total_bytes += nbytes; 2855 total_bytes += nbytes;
2815 next = ADVANCE (next, nbytes); 2856 next = ADVANCE (next, nbytes);
2816 } 2857 }
@@ -2844,8 +2885,9 @@ sweep_vectors (void)
2844 2885
2845 /* Sweep large vectors. */ 2886 /* Sweep large vectors. */
2846 2887
2847 for (vector = large_vectors; vector; vector = *vprev) 2888 for (lv = large_vectors; lv; lv = *lvprev)
2848 { 2889 {
2890 vector = &lv->v;
2849 if (VECTOR_MARKED_P (vector)) 2891 if (VECTOR_MARKED_P (vector))
2850 { 2892 {
2851 VECTOR_UNMARK (vector); 2893 VECTOR_UNMARK (vector);
@@ -2867,12 +2909,12 @@ sweep_vectors (void)
2867 else 2909 else
2868 total_vector_slots 2910 total_vector_slots
2869 += header_size / word_size + vector->header.size; 2911 += header_size / word_size + vector->header.size;
2870 vprev = &vector->header.next.vector; 2912 lvprev = &lv->next.vector;
2871 } 2913 }
2872 else 2914 else
2873 { 2915 {
2874 *vprev = vector->header.next.vector; 2916 *lvprev = lv->next.vector;
2875 lisp_free (vector); 2917 lisp_free (lv);
2876 } 2918 }
2877 } 2919 }
2878} 2920}
@@ -2904,9 +2946,12 @@ allocate_vectorlike (ptrdiff_t len)
2904 p = allocate_vector_from_block (vroundup (nbytes)); 2946 p = allocate_vector_from_block (vroundup (nbytes));
2905 else 2947 else
2906 { 2948 {
2907 p = lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); 2949 struct large_vector *lv
2908 p->header.next.vector = large_vectors; 2950 = lisp_malloc (sizeof (*lv) + (len - 1) * word_size,
2909 large_vectors = p; 2951 MEM_TYPE_VECTORLIKE);
2952 lv->next.vector = large_vectors;
2953 large_vectors = lv;
2954 p = &lv->v;
2910 } 2955 }
2911 2956
2912#ifdef DOUG_LEA_MALLOC 2957#ifdef DOUG_LEA_MALLOC
@@ -2943,16 +2988,21 @@ allocate_vector (EMACS_INT len)
2943/* Allocate other vector-like structures. */ 2988/* Allocate other vector-like structures. */
2944 2989
2945struct Lisp_Vector * 2990struct Lisp_Vector *
2946allocate_pseudovector (int memlen, int lisplen, int tag) 2991allocate_pseudovector (int memlen, int lisplen, enum pvec_type tag)
2947{ 2992{
2948 struct Lisp_Vector *v = allocate_vectorlike (memlen); 2993 struct Lisp_Vector *v = allocate_vectorlike (memlen);
2949 int i; 2994 int i;
2950 2995
2996 /* Catch bogus values. */
2997 eassert (tag <= PVEC_FONT);
2998 eassert (memlen - lisplen <= (1 << PSEUDOVECTOR_REST_BITS) - 1);
2999 eassert (lisplen <= (1 << PSEUDOVECTOR_SIZE_BITS) - 1);
3000
2951 /* Only the first lisplen slots will be traced normally by the GC. */ 3001 /* Only the first lisplen slots will be traced normally by the GC. */
2952 for (i = 0; i < lisplen; ++i) 3002 for (i = 0; i < lisplen; ++i)
2953 v->contents[i] = Qnil; 3003 v->contents[i] = Qnil;
2954 3004
2955 XSETPVECTYPESIZE (v, tag, lisplen); 3005 XSETPVECTYPESIZE (v, tag, lisplen, memlen - lisplen);
2956 return v; 3006 return v;
2957} 3007}
2958 3008
@@ -2961,10 +3011,9 @@ allocate_buffer (void)
2961{ 3011{
2962 struct buffer *b = lisp_malloc (sizeof *b, MEM_TYPE_BUFFER); 3012 struct buffer *b = lisp_malloc (sizeof *b, MEM_TYPE_BUFFER);
2963 3013
2964 XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text) 3014 BUFFER_PVEC_INIT (b);
2965 - header_size) / word_size);
2966 /* Put B on the chain of all buffers including killed ones. */ 3015 /* Put B on the chain of all buffers including killed ones. */
2967 b->header.next.buffer = all_buffers; 3016 b->next = all_buffers;
2968 all_buffers = b; 3017 all_buffers = b;
2969 /* Note that the rest fields of B are not initialized. */ 3018 /* Note that the rest fields of B are not initialized. */
2970 return b; 3019 return b;
@@ -4068,16 +4117,15 @@ live_vector_p (struct mem_node *m, void *p)
4068 while (VECTOR_IN_BLOCK (vector, block) 4117 while (VECTOR_IN_BLOCK (vector, block)
4069 && vector <= (struct Lisp_Vector *) p) 4118 && vector <= (struct Lisp_Vector *) p)
4070 { 4119 {
4071 if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_FREE)) 4120 if (!PSEUDOVECTOR_TYPEP (&vector->header, PVEC_FREE) && vector == p)
4072 vector = ADVANCE (vector, (vector->header.size
4073 & PSEUDOVECTOR_SIZE_MASK));
4074 else if (vector == p)
4075 return 1; 4121 return 1;
4076 else 4122 else
4077 vector = ADVANCE (vector, vector->header.next.nbytes); 4123 vector = ADVANCE (vector, vector_nbytes (vector));
4078 } 4124 }
4079 } 4125 }
4080 else if (m->type == MEM_TYPE_VECTORLIKE && p == m->start) 4126 else if (m->type == MEM_TYPE_VECTORLIKE
4127 && (char *) p == ((char *) m->start
4128 + offsetof (struct large_vector, v)))
4081 /* This memory node corresponds to a large vector. */ 4129 /* This memory node corresponds to a large vector. */
4082 return 1; 4130 return 1;
4083 return 0; 4131 return 0;
@@ -5687,7 +5735,7 @@ mark_object (Lisp_Object arg)
5687 5735
5688 if (ptr->header.size & PSEUDOVECTOR_FLAG) 5736 if (ptr->header.size & PSEUDOVECTOR_FLAG)
5689 pvectype = ((ptr->header.size & PVEC_TYPE_MASK) 5737 pvectype = ((ptr->header.size & PVEC_TYPE_MASK)
5690 >> PSEUDOVECTOR_SIZE_BITS); 5738 >> PSEUDOVECTOR_AREA_BITS);
5691 else 5739 else
5692 pvectype = PVEC_NORMAL_VECTOR; 5740 pvectype = PVEC_NORMAL_VECTOR;
5693 5741
@@ -5766,6 +5814,9 @@ mark_object (Lisp_Object arg)
5766 struct Lisp_Hash_Table *h = (struct Lisp_Hash_Table *) ptr; 5814 struct Lisp_Hash_Table *h = (struct Lisp_Hash_Table *) ptr;
5767 5815
5768 mark_vectorlike (ptr); 5816 mark_vectorlike (ptr);
5817 mark_object (h->test.name);
5818 mark_object (h->test.user_hash_function);
5819 mark_object (h->test.user_cmp_function);
5769 /* If hash table is not weak, mark all keys and values. 5820 /* If hash table is not weak, mark all keys and values.
5770 For weak tables, mark only the vector. */ 5821 For weak tables, mark only the vector. */
5771 if (NILP (h->weak)) 5822 if (NILP (h->weak))
@@ -6317,7 +6368,7 @@ gc_sweep (void)
6317 for (buffer = all_buffers; buffer; buffer = *bprev) 6368 for (buffer = all_buffers; buffer; buffer = *bprev)
6318 if (!VECTOR_MARKED_P (buffer)) 6369 if (!VECTOR_MARKED_P (buffer))
6319 { 6370 {
6320 *bprev = buffer->header.next.buffer; 6371 *bprev = buffer->next;
6321 lisp_free (buffer); 6372 lisp_free (buffer);
6322 } 6373 }
6323 else 6374 else
@@ -6326,7 +6377,7 @@ gc_sweep (void)
6326 /* Do not use buffer_(set|get)_intervals here. */ 6377 /* Do not use buffer_(set|get)_intervals here. */
6327 buffer->text->intervals = balance_intervals (buffer->text->intervals); 6378 buffer->text->intervals = balance_intervals (buffer->text->intervals);
6328 total_buffers++; 6379 total_buffers++;
6329 bprev = &buffer->header.next.buffer; 6380 bprev = &buffer->next;
6330 } 6381 }
6331 } 6382 }
6332 6383
diff --git a/src/buffer.c b/src/buffer.c
index 347f27edc3a..619a729a859 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -406,7 +406,6 @@ followed by the rest of the buffers. */)
406 Lisp_Object framelist, prevlist, tail; 406 Lisp_Object framelist, prevlist, tail;
407 Lisp_Object args[3]; 407 Lisp_Object args[3];
408 408
409 CHECK_FRAME (frame);
410 framelist = Fcopy_sequence (XFRAME (frame)->buffer_list); 409 framelist = Fcopy_sequence (XFRAME (frame)->buffer_list);
411 prevlist = Fnreverse (Fcopy_sequence 410 prevlist = Fnreverse (Fcopy_sequence
412 (XFRAME (frame)->buried_buffer_list)); 411 (XFRAME (frame)->buried_buffer_list));
@@ -1543,17 +1542,11 @@ list first, followed by the list of all buffers. If no other buffer
1543exists, return the buffer `*scratch*' (creating it if necessary). */) 1542exists, return the buffer `*scratch*' (creating it if necessary). */)
1544 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame) 1543 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame)
1545{ 1544{
1546 Lisp_Object tail, buf, pred; 1545 struct frame *f = decode_any_frame (frame);
1547 Lisp_Object notsogood = Qnil; 1546 Lisp_Object tail = f->buffer_list, pred = f->buffer_predicate;
1547 Lisp_Object buf, notsogood = Qnil;
1548 1548
1549 if (NILP (frame))
1550 frame = selected_frame;
1551
1552 CHECK_FRAME (frame);
1553
1554 pred = frame_buffer_predicate (frame);
1555 /* Consider buffers that have been seen in the frame first. */ 1549 /* Consider buffers that have been seen in the frame first. */
1556 tail = XFRAME (frame)->buffer_list;
1557 for (; CONSP (tail); tail = XCDR (tail)) 1550 for (; CONSP (tail); tail = XCDR (tail))
1558 { 1551 {
1559 buf = XCAR (tail); 1552 buf = XCAR (tail);
@@ -2109,7 +2102,7 @@ set_buffer_internal_1 (register struct buffer *b)
2109 return; 2102 return;
2110 2103
2111 BUFFER_CHECK_INDIRECTION (b); 2104 BUFFER_CHECK_INDIRECTION (b);
2112 2105
2113 old_buf = current_buffer; 2106 old_buf = current_buffer;
2114 current_buffer = b; 2107 current_buffer = b;
2115 last_known_column_point = -1; /* invalidate indentation cache */ 2108 last_known_column_point = -1; /* invalidate indentation cache */
@@ -3139,8 +3132,8 @@ compare_overlays (const void *v1, const void *v2)
3139 between "equal" overlays. The result can still change between 3132 between "equal" overlays. The result can still change between
3140 invocations of Emacs, but it won't change in the middle of 3133 invocations of Emacs, but it won't change in the middle of
3141 `find_field' (bug#6830). */ 3134 `find_field' (bug#6830). */
3142 if (XHASH (s1->overlay) != XHASH (s2->overlay)) 3135 if (!EQ (s1->overlay, s2->overlay))
3143 return XHASH (s1->overlay) < XHASH (s2->overlay) ? -1 : 1; 3136 return XLI (s1->overlay) < XLI (s2->overlay) ? -1 : 1;
3144 return 0; 3137 return 0;
3145} 3138}
3146 3139
@@ -5112,11 +5105,6 @@ void
5112init_buffer_once (void) 5105init_buffer_once (void)
5113{ 5106{
5114 int idx; 5107 int idx;
5115 /* If you add, remove, or reorder Lisp_Objects in a struct buffer, make
5116 sure that this is still correct. Otherwise, mark_vectorlike may not
5117 trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */
5118 const int pvecsize
5119 = (offsetof (struct buffer, own_text) - header_size) / word_size;
5120 5108
5121 memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags); 5109 memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags);
5122 5110
@@ -5139,8 +5127,8 @@ init_buffer_once (void)
5139 /* This is not strictly necessary, but let's make them initialized. */ 5127 /* This is not strictly necessary, but let's make them initialized. */
5140 bset_name (&buffer_defaults, build_pure_c_string (" *buffer-defaults*")); 5128 bset_name (&buffer_defaults, build_pure_c_string (" *buffer-defaults*"));
5141 bset_name (&buffer_local_symbols, build_pure_c_string (" *buffer-local-symbols*")); 5129 bset_name (&buffer_local_symbols, build_pure_c_string (" *buffer-local-symbols*"));
5142 XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); 5130 BUFFER_PVEC_INIT (&buffer_defaults);
5143 XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); 5131 BUFFER_PVEC_INIT (&buffer_local_symbols);
5144 5132
5145 /* Set up the default values of various buffer slots. */ 5133 /* Set up the default values of various buffer slots. */
5146 /* Must do these before making the first buffer! */ 5134 /* Must do these before making the first buffer! */
diff --git a/src/buffer.h b/src/buffer.h
index 9e0e9eef0b1..fbbbf1b8434 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -482,11 +482,6 @@ struct buffer_text
482 482
483struct buffer 483struct buffer
484{ 484{
485 /* HEADER.NEXT is the next buffer, in chain of all buffers, including killed
486 buffers. This chain, starting from all_buffers, is used only for garbage
487 collection, in order to collect killed buffers properly. Note that large
488 vectors and large pseudo-vector objects are all on another chain starting
489 from large_vectors. */
490 struct vectorlike_header header; 485 struct vectorlike_header header;
491 486
492 /* The name of this buffer. */ 487 /* The name of this buffer. */
@@ -750,6 +745,9 @@ struct buffer
750 In an indirect buffer, this is the own_text field of another buffer. */ 745 In an indirect buffer, this is the own_text field of another buffer. */
751 struct buffer_text *text; 746 struct buffer_text *text;
752 747
748 /* Next buffer, in chain of all buffers, including killed ones. */
749 struct buffer *next;
750
753 /* Char position of point in buffer. */ 751 /* Char position of point in buffer. */
754 ptrdiff_t pt; 752 ptrdiff_t pt;
755 753
@@ -959,6 +957,27 @@ bset_width_table (struct buffer *b, Lisp_Object val)
959 b->INTERNAL_FIELD (width_table) = val; 957 b->INTERNAL_FIELD (width_table) = val;
960} 958}
961 959
960/* Number of Lisp_Objects at the beginning of struct buffer.
961 If you add, remove, or reorder Lisp_Objects within buffer
962 structure, make sure that this is still correct. */
963
964#define BUFFER_LISP_SIZE \
965 ((offsetof (struct buffer, own_text) - header_size) / word_size)
966
967/* Size of the struct buffer part beyond leading Lisp_Objects, in word_size
968 units. Rounding is needed for --with-wide-int configuration. */
969
970#define BUFFER_REST_SIZE \
971 ((((sizeof (struct buffer) - offsetof (struct buffer, own_text)) \
972 + (word_size - 1)) & ~(word_size - 1)) / word_size)
973
974/* Initialize the pseudovector header of buffer object. BUFFER_LISP_SIZE
975 is required for GC, but BUFFER_REST_SIZE is set up just to be consistent
976 with other pseudovectors. */
977
978#define BUFFER_PVEC_INIT(b) \
979 XSETPVECTYPESIZE (b, PVEC_BUFFER, BUFFER_LISP_SIZE, BUFFER_REST_SIZE)
980
962/* Convenient check whether buffer B is live. */ 981/* Convenient check whether buffer B is live. */
963 982
964#define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name))) 983#define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name)))
@@ -986,7 +1005,7 @@ extern struct buffer *all_buffers;
986/* Used to iterate over the chain above. */ 1005/* Used to iterate over the chain above. */
987 1006
988#define FOR_EACH_BUFFER(b) \ 1007#define FOR_EACH_BUFFER(b) \
989 for ((b) = all_buffers; (b); (b) = (b)->header.next.buffer) 1008 for ((b) = all_buffers; (b); (b) = (b)->next)
990 1009
991/* This points to the current buffer. */ 1010/* This points to the current buffer. */
992 1011
diff --git a/src/category.c b/src/category.c
index fe02303f679..31cc90bca68 100644
--- a/src/category.c
+++ b/src/category.c
@@ -78,10 +78,10 @@ hash_get_category_set (Lisp_Object table, Lisp_Object category_set)
78 if (NILP (XCHAR_TABLE (table)->extras[1])) 78 if (NILP (XCHAR_TABLE (table)->extras[1]))
79 set_char_table_extras 79 set_char_table_extras
80 (table, 1, 80 (table, 1,
81 make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), 81 make_hash_table (hashtest_equal, make_number (DEFAULT_HASH_SIZE),
82 make_float (DEFAULT_REHASH_SIZE), 82 make_float (DEFAULT_REHASH_SIZE),
83 make_float (DEFAULT_REHASH_THRESHOLD), 83 make_float (DEFAULT_REHASH_THRESHOLD),
84 Qnil, Qnil, Qnil)); 84 Qnil));
85 h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]); 85 h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]);
86 i = hash_lookup (h, category_set, &hash); 86 i = hash_lookup (h, category_set, &hash);
87 if (i >= 0) 87 if (i >= 0)
diff --git a/src/composite.c b/src/composite.c
index 6c603fab3fc..bcde0a4c9e6 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -676,7 +676,7 @@ composition_gstring_put_cache (Lisp_Object gstring, ptrdiff_t len)
676 ptrdiff_t i; 676 ptrdiff_t i;
677 677
678 header = LGSTRING_HEADER (gstring); 678 header = LGSTRING_HEADER (gstring);
679 hash = h->hashfn (h, header); 679 hash = h->test.hashfn (&h->test, header);
680 if (len < 0) 680 if (len < 0)
681 { 681 {
682 ptrdiff_t j, glyph_len = LGSTRING_GLYPH_LEN (gstring); 682 ptrdiff_t j, glyph_len = LGSTRING_GLYPH_LEN (gstring);
@@ -1382,7 +1382,7 @@ composition_update_it (struct composition_it *cmp_it, ptrdiff_t charpos, ptrdiff
1382 } 1382 }
1383 else 1383 else
1384 { 1384 {
1385 /* automatic composition */ 1385 /* Automatic composition. */
1386 Lisp_Object gstring = composition_gstring_from_id (cmp_it->id); 1386 Lisp_Object gstring = composition_gstring_from_id (cmp_it->id);
1387 Lisp_Object glyph; 1387 Lisp_Object glyph;
1388 ptrdiff_t from; 1388 ptrdiff_t from;
diff --git a/src/data.c b/src/data.c
index abcdd4dca0d..09899400b68 100644
--- a/src/data.c
+++ b/src/data.c
@@ -81,6 +81,7 @@ Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
81static Lisp_Object Qdefun; 81static Lisp_Object Qdefun;
82 82
83Lisp_Object Qinteractive_form; 83Lisp_Object Qinteractive_form;
84static Lisp_Object Qdefalias_fset_function;
84 85
85static void swap_in_symval_forwarding (struct Lisp_Symbol *, struct Lisp_Buffer_Local_Value *); 86static void swap_in_symval_forwarding (struct Lisp_Symbol *, struct Lisp_Buffer_Local_Value *);
86 87
@@ -444,7 +445,7 @@ DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0,
444} 445}
445 446
446 447
447/* Extract and set components of lists */ 448/* Extract and set components of lists. */
448 449
449DEFUN ("car", Fcar, Scar, 1, 1, 0, 450DEFUN ("car", Fcar, Scar, 1, 1, 0,
450 doc: /* Return the car of LIST. If arg is nil, return nil. 451 doc: /* Return the car of LIST. If arg is nil, return nil.
@@ -608,27 +609,18 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
608 (register Lisp_Object symbol, Lisp_Object definition) 609 (register Lisp_Object symbol, Lisp_Object definition)
609{ 610{
610 register Lisp_Object function; 611 register Lisp_Object function;
611
612 CHECK_SYMBOL (symbol); 612 CHECK_SYMBOL (symbol);
613 if (NILP (symbol) || EQ (symbol, Qt))
614 xsignal1 (Qsetting_constant, symbol);
615 613
616 function = XSYMBOL (symbol)->function; 614 function = XSYMBOL (symbol)->function;
617 615
618 if (!NILP (Vautoload_queue) && !EQ (function, Qunbound)) 616 if (!NILP (Vautoload_queue) && !EQ (function, Qunbound))
619 Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue); 617 Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);
620 618
621 if (CONSP (function) && EQ (XCAR (function), Qautoload)) 619 if (AUTOLOADP (function))
622 Fput (symbol, Qautoload, XCDR (function)); 620 Fput (symbol, Qautoload, XCDR (function));
623 621
624 set_symbol_function (symbol, definition); 622 set_symbol_function (symbol, definition);
625 /* Handle automatic advice activation. */ 623
626 if (CONSP (XSYMBOL (symbol)->plist)
627 && !NILP (Fget (symbol, Qad_advice_info)))
628 {
629 call2 (Qad_activate_internal, symbol, Qnil);
630 definition = XSYMBOL (symbol)->function;
631 }
632 return definition; 624 return definition;
633} 625}
634 626
@@ -642,15 +634,32 @@ The return value is undefined. */)
642 (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring) 634 (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring)
643{ 635{
644 CHECK_SYMBOL (symbol); 636 CHECK_SYMBOL (symbol);
645 if (CONSP (XSYMBOL (symbol)->function)
646 && EQ (XCAR (XSYMBOL (symbol)->function), Qautoload))
647 LOADHIST_ATTACH (Fcons (Qt, symbol));
648 if (!NILP (Vpurify_flag) 637 if (!NILP (Vpurify_flag)
649 /* If `definition' is a keymap, immutable (and copying) is wrong. */ 638 /* If `definition' is a keymap, immutable (and copying) is wrong. */
650 && !KEYMAPP (definition)) 639 && !KEYMAPP (definition))
651 definition = Fpurecopy (definition); 640 definition = Fpurecopy (definition);
652 definition = Ffset (symbol, definition); 641
653 LOADHIST_ATTACH (Fcons (Qdefun, symbol)); 642 {
643 bool autoload = AUTOLOADP (definition);
644 if (NILP (Vpurify_flag) || !autoload)
645 { /* Only add autoload entries after dumping, because the ones before are
646 not useful and else we get loads of them from the loaddefs.el. */
647
648 if (AUTOLOADP (XSYMBOL (symbol)->function))
649 /* Remember that the function was already an autoload. */
650 LOADHIST_ATTACH (Fcons (Qt, symbol));
651 LOADHIST_ATTACH (Fcons (autoload ? Qautoload : Qdefun, symbol));
652 }
653 }
654
655 { /* Handle automatic advice activation. */
656 Lisp_Object hook = Fget (symbol, Qdefalias_fset_function);
657 if (!NILP (hook))
658 call2 (hook, symbol, definition);
659 else
660 Ffset (symbol, definition);
661 }
662
654 if (!NILP (docstring)) 663 if (!NILP (docstring))
655 Fput (symbol, Qfunction_documentation, docstring); 664 Fput (symbol, Qfunction_documentation, docstring);
656 /* We used to return `definition', but now that `defun' and `defmacro' expand 665 /* We used to return `definition', but now that `defun' and `defmacro' expand
@@ -680,12 +689,10 @@ function with `&rest' args, or `unevalled' for a special form. */)
680 CHECK_SUBR (subr); 689 CHECK_SUBR (subr);
681 minargs = XSUBR (subr)->min_args; 690 minargs = XSUBR (subr)->min_args;
682 maxargs = XSUBR (subr)->max_args; 691 maxargs = XSUBR (subr)->max_args;
683 if (maxargs == MANY) 692 return Fcons (make_number (minargs),
684 return Fcons (make_number (minargs), Qmany); 693 maxargs == MANY ? Qmany
685 else if (maxargs == UNEVALLED) 694 : maxargs == UNEVALLED ? Qunevalled
686 return Fcons (make_number (minargs), Qunevalled); 695 : make_number (maxargs));
687 else
688 return Fcons (make_number (minargs), make_number (maxargs));
689} 696}
690 697
691DEFUN ("subr-name", Fsubr_name, Ssubr_name, 1, 1, 0, 698DEFUN ("subr-name", Fsubr_name, Ssubr_name, 1, 1, 0,
@@ -711,7 +718,7 @@ Value, if non-nil, is a list \(interactive SPEC). */)
711 return Qnil; 718 return Qnil;
712 719
713 /* Use an `interactive-form' property if present, analogous to the 720 /* Use an `interactive-form' property if present, analogous to the
714 function-documentation property. */ 721 function-documentation property. */
715 fun = cmd; 722 fun = cmd;
716 while (SYMBOLP (fun)) 723 while (SYMBOLP (fun))
717 { 724 {
@@ -735,6 +742,8 @@ Value, if non-nil, is a list \(interactive SPEC). */)
735 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE) 742 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE)
736 return list2 (Qinteractive, AREF (fun, COMPILED_INTERACTIVE)); 743 return list2 (Qinteractive, AREF (fun, COMPILED_INTERACTIVE));
737 } 744 }
745 else if (AUTOLOADP (fun))
746 return Finteractive_form (Fautoload_do_load (fun, cmd, Qnil));
738 else if (CONSP (fun)) 747 else if (CONSP (fun))
739 { 748 {
740 Lisp_Object funcar = XCAR (fun); 749 Lisp_Object funcar = XCAR (fun);
@@ -742,14 +751,6 @@ Value, if non-nil, is a list \(interactive SPEC). */)
742 return Fassq (Qinteractive, Fcdr (Fcdr (XCDR (fun)))); 751 return Fassq (Qinteractive, Fcdr (Fcdr (XCDR (fun))));
743 else if (EQ (funcar, Qlambda)) 752 else if (EQ (funcar, Qlambda))
744 return Fassq (Qinteractive, Fcdr (XCDR (fun))); 753 return Fassq (Qinteractive, Fcdr (XCDR (fun)));
745 else if (EQ (funcar, Qautoload))
746 {
747 struct gcpro gcpro1;
748 GCPRO1 (cmd);
749 Fautoload_do_load (fun, cmd, Qnil);
750 UNGCPRO;
751 return Finteractive_form (cmd);
752 }
753 } 754 }
754 return Qnil; 755 return Qnil;
755} 756}
@@ -2695,10 +2696,10 @@ usage: (* &rest NUMBERS-OR-MARKERS) */)
2695 return arith_driver (Amult, nargs, args); 2696 return arith_driver (Amult, nargs, args);
2696} 2697}
2697 2698
2698DEFUN ("/", Fquo, Squo, 2, MANY, 0, 2699DEFUN ("/", Fquo, Squo, 1, MANY, 0,
2699 doc: /* Return first argument divided by all the remaining arguments. 2700 doc: /* Return first argument divided by all the remaining arguments.
2700The arguments must be numbers or markers. 2701The arguments must be numbers or markers.
2701usage: (/ DIVIDEND DIVISOR &rest DIVISORS) */) 2702usage: (/ DIVIDEND &rest DIVISORS) */)
2702 (ptrdiff_t nargs, Lisp_Object *args) 2703 (ptrdiff_t nargs, Lisp_Object *args)
2703{ 2704{
2704 ptrdiff_t argnum; 2705 ptrdiff_t argnum;
@@ -3063,6 +3064,7 @@ syms_of_data (void)
3063 DEFSYM (Qfont_object, "font-object"); 3064 DEFSYM (Qfont_object, "font-object");
3064 3065
3065 DEFSYM (Qinteractive_form, "interactive-form"); 3066 DEFSYM (Qinteractive_form, "interactive-form");
3067 DEFSYM (Qdefalias_fset_function, "defalias-fset-function");
3066 3068
3067 defsubr (&Sindirect_variable); 3069 defsubr (&Sindirect_variable);
3068 defsubr (&Sinteractive_form); 3070 defsubr (&Sinteractive_form);
diff --git a/src/dispnew.c b/src/dispnew.c
index 907259a3e94..675c06c22e9 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -141,10 +141,6 @@ struct frame *last_nonminibuf_frame;
141 141
142static bool delayed_size_change; 142static bool delayed_size_change;
143 143
144/* 1 means glyph initialization has been completed at startup. */
145
146static bool glyphs_initialized_initially_p;
147
148/* Updated window if != 0. Set by update_window. */ 144/* Updated window if != 0. Set by update_window. */
149 145
150struct window *updated_window; 146struct window *updated_window;
@@ -1850,43 +1846,6 @@ adjust_glyphs (struct frame *f)
1850 unblock_input (); 1846 unblock_input ();
1851} 1847}
1852 1848
1853
1854/* Adjust frame glyphs when Emacs is initialized.
1855
1856 To be called from init_display.
1857
1858 We need a glyph matrix because redraw will happen soon.
1859 Unfortunately, window sizes on selected_frame are not yet set to
1860 meaningful values. I believe we can assume that there are only two
1861 windows on the frame---the mini-buffer and the root window. Frame
1862 height and width seem to be correct so far. So, set the sizes of
1863 windows to estimated values. */
1864
1865static void
1866adjust_frame_glyphs_initially (void)
1867{
1868 struct frame *sf = SELECTED_FRAME ();
1869 struct window *root = XWINDOW (sf->root_window);
1870 struct window *mini = XWINDOW (root->next);
1871 int frame_lines = FRAME_LINES (sf);
1872 int frame_cols = FRAME_COLS (sf);
1873 int top_margin = FRAME_TOP_MARGIN (sf);
1874
1875 /* Do it for the root window. */
1876 wset_top_line (root, make_number (top_margin));
1877 wset_total_lines (root, make_number (frame_lines - 1 - top_margin));
1878 wset_total_cols (root, make_number (frame_cols));
1879
1880 /* Do it for the mini-buffer window. */
1881 wset_top_line (mini, make_number (frame_lines - 1));
1882 wset_total_lines (mini, make_number (1));
1883 wset_total_cols (mini, make_number (frame_cols));
1884
1885 adjust_frame_glyphs (sf);
1886 glyphs_initialized_initially_p = 1;
1887}
1888
1889
1890/* Allocate/reallocate glyph matrices of a single frame F. */ 1849/* Allocate/reallocate glyph matrices of a single frame F. */
1891 1850
1892static void 1851static void
@@ -3071,21 +3030,13 @@ window_to_frame_hpos (struct window *w, int hpos)
3071 Redrawing Frames 3030 Redrawing Frames
3072 **********************************************************************/ 3031 **********************************************************************/
3073 3032
3074DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, 3033/* Redraw frame F. */
3075 doc: /* Clear frame FRAME and output again what is supposed to appear on it. */)
3076 (Lisp_Object frame)
3077{
3078 struct frame *f;
3079
3080 CHECK_LIVE_FRAME (frame);
3081 f = XFRAME (frame);
3082
3083 /* Ignore redraw requests, if frame has no glyphs yet.
3084 (Implementation note: It still has to be checked why we are
3085 called so early here). */
3086 if (!glyphs_initialized_initially_p)
3087 return Qnil;
3088 3034
3035void
3036redraw_frame (struct frame *f)
3037{
3038 /* Error if F has no glyphs. */
3039 eassert (f->glyphs_initialized_p);
3089 update_begin (f); 3040 update_begin (f);
3090#ifdef MSDOS 3041#ifdef MSDOS
3091 if (FRAME_MSDOS_P (f)) 3042 if (FRAME_MSDOS_P (f))
@@ -3102,22 +3053,17 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
3102 mark_window_display_accurate (FRAME_ROOT_WINDOW (f), 0); 3053 mark_window_display_accurate (FRAME_ROOT_WINDOW (f), 0);
3103 set_window_update_flags (XWINDOW (FRAME_ROOT_WINDOW (f)), 1); 3054 set_window_update_flags (XWINDOW (FRAME_ROOT_WINDOW (f)), 1);
3104 f->garbaged = 0; 3055 f->garbaged = 0;
3105 return Qnil;
3106} 3056}
3107 3057
3108 3058DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 0, 1, 0,
3109/* Redraw frame F. This is nothing more than a call to the Lisp 3059 doc: /* Clear frame FRAME and output again what is supposed to appear on it.
3110 function redraw-frame. */ 3060If FRAME is omitted or nil, the selected frame is used. */)
3111 3061 (Lisp_Object frame)
3112void
3113redraw_frame (struct frame *f)
3114{ 3062{
3115 Lisp_Object frame; 3063 redraw_frame (decode_live_frame (frame));
3116 XSETFRAME (frame, f); 3064 return Qnil;
3117 Fredraw_frame (frame);
3118} 3065}
3119 3066
3120
3121DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "", 3067DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "",
3122 doc: /* Clear and redisplay all visible frames. */) 3068 doc: /* Clear and redisplay all visible frames. */)
3123 (void) 3069 (void)
@@ -3126,7 +3072,7 @@ DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "",
3126 3072
3127 FOR_EACH_FRAME (tail, frame) 3073 FOR_EACH_FRAME (tail, frame)
3128 if (FRAME_VISIBLE_P (XFRAME (frame))) 3074 if (FRAME_VISIBLE_P (XFRAME (frame)))
3129 Fredraw_frame (frame); 3075 redraw_frame (XFRAME (frame));
3130 3076
3131 return Qnil; 3077 return Qnil;
3132} 3078}
@@ -6210,7 +6156,6 @@ init_display (void)
6210 So call tgetent. */ 6156 So call tgetent. */
6211 { char b[2044]; tgetent (b, "xterm");} 6157 { char b[2044]; tgetent (b, "xterm");}
6212#endif 6158#endif
6213 adjust_frame_glyphs_initially ();
6214 return; 6159 return;
6215 } 6160 }
6216#endif /* HAVE_X_WINDOWS */ 6161#endif /* HAVE_X_WINDOWS */
@@ -6220,7 +6165,6 @@ init_display (void)
6220 { 6165 {
6221 Vinitial_window_system = Qw32; 6166 Vinitial_window_system = Qw32;
6222 Vwindow_system_version = make_number (1); 6167 Vwindow_system_version = make_number (1);
6223 adjust_frame_glyphs_initially ();
6224 return; 6168 return;
6225 } 6169 }
6226#endif /* HAVE_NTGUI */ 6170#endif /* HAVE_NTGUI */
@@ -6234,7 +6178,6 @@ init_display (void)
6234 { 6178 {
6235 Vinitial_window_system = Qns; 6179 Vinitial_window_system = Qns;
6236 Vwindow_system_version = make_number (10); 6180 Vwindow_system_version = make_number (10);
6237 adjust_frame_glyphs_initially ();
6238 return; 6181 return;
6239 } 6182 }
6240#endif 6183#endif
@@ -6324,7 +6267,6 @@ init_display (void)
6324 fatal ("screen size %dx%d too big", width, height); 6267 fatal ("screen size %dx%d too big", width, height);
6325 } 6268 }
6326 6269
6327 adjust_frame_glyphs_initially ();
6328 calculate_costs (XFRAME (selected_frame)); 6270 calculate_costs (XFRAME (selected_frame));
6329 6271
6330 /* Set up faces of the initial terminal frame of a dumped Emacs. */ 6272 /* Set up faces of the initial terminal frame of a dumped Emacs. */
diff --git a/src/doc.c b/src/doc.c
index 9ead1addfba..1d3d1e64442 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <config.h> 21#include <config.h>
22 22
23#include <sys/types.h> 23#include <sys/types.h>
24#include <sys/file.h> /* Must be after sys/types.h for USG*/ 24#include <sys/file.h> /* Must be after sys/types.h for USG. */
25#include <fcntl.h> 25#include <fcntl.h>
26#include <unistd.h> 26#include <unistd.h>
27 27
@@ -42,7 +42,7 @@ static ptrdiff_t get_doc_string_buffer_size;
42 42
43static unsigned char *read_bytecode_pointer; 43static unsigned char *read_bytecode_pointer;
44 44
45/* readchar in lread.c calls back here to fetch the next byte. 45/* `readchar' in lread.c calls back here to fetch the next byte.
46 If UNREADFLAG is 1, we unread a byte. */ 46 If UNREADFLAG is 1, we unread a byte. */
47 47
48int 48int
@@ -338,15 +338,9 @@ string is passed through `substitute-command-keys'. */)
338 338
339 doc = Qnil; 339 doc = Qnil;
340 340
341 if (SYMBOLP (function))
342 {
343 Lisp_Object tem = Fget (function, Qfunction_documentation);
344 if (!NILP (tem))
345 return Fdocumentation_property (function, Qfunction_documentation,
346 raw);
347 }
348
349 fun = Findirect_function (function, Qnil); 341 fun = Findirect_function (function, Qnil);
342 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
343 fun = XCDR (fun);
350 if (SUBRP (fun)) 344 if (SUBRP (fun))
351 { 345 {
352 if (XSUBR (fun)->doc == 0) 346 if (XSUBR (fun)->doc == 0)
@@ -400,8 +394,6 @@ string is passed through `substitute-command-keys'. */)
400 else 394 else
401 return Qnil; 395 return Qnil;
402 } 396 }
403 else if (EQ (funcar, Qmacro))
404 return Fdocumentation (Fcdr (fun), raw);
405 else 397 else
406 goto oops; 398 goto oops;
407 } 399 }
@@ -411,16 +403,19 @@ string is passed through `substitute-command-keys'. */)
411 xsignal1 (Qinvalid_function, fun); 403 xsignal1 (Qinvalid_function, fun);
412 } 404 }
413 405
414 /* Check for an advised function. Its doc string 406 /* Check for a dynamic docstring. These come with
415 has an `ad-advice-info' text property. */ 407 a dynamic-docstring-function text property. */
416 if (STRINGP (doc)) 408 if (STRINGP (doc))
417 { 409 {
418 Lisp_Object innerfunc; 410 Lisp_Object func
419 innerfunc = Fget_text_property (make_number (0), 411 = Fget_text_property (make_number (0),
420 intern ("ad-advice-info"), 412 intern ("dynamic-docstring-function"),
421 doc); 413 doc);
422 if (! NILP (innerfunc)) 414 if (!NILP (func))
423 doc = call1 (intern ("ad-make-advised-docstring"), innerfunc); 415 /* Pass both `doc' and `function' since `function' can be needed, and
416 finding `doc' can be annoying: calling `documentation' is not an
417 option because it would infloop. */
418 doc = call2 (func, doc, function);
424 } 419 }
425 420
426 /* If DOC is 0, it's typically because of a dumped file missing 421 /* If DOC is 0, it's typically because of a dumped file missing
@@ -528,6 +523,8 @@ store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
528 { 523 {
529 tem = Fcdr (Fcdr (fun)); 524 tem = Fcdr (Fcdr (fun));
530 if (CONSP (tem) && INTEGERP (XCAR (tem))) 525 if (CONSP (tem) && INTEGERP (XCAR (tem)))
526 /* FIXME: This modifies typically pure hash-cons'd data, so its
527 correctness is quite delicate. */
531 XSETCAR (tem, make_number (offset)); 528 XSETCAR (tem, make_number (offset));
532 } 529 }
533 else if (EQ (tem, Qmacro)) 530 else if (EQ (tem, Qmacro))
diff --git a/src/emacs.c b/src/emacs.c
index f12713b9628..fee9c332c55 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1154,6 +1154,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1154 1154
1155 /* Called before syms_of_fileio, because it sets up Qerror_condition. */ 1155 /* Called before syms_of_fileio, because it sets up Qerror_condition. */
1156 syms_of_data (); 1156 syms_of_data ();
1157 syms_of_fns (); /* Before syms_of_charset which uses hashtables. */
1157 syms_of_fileio (); 1158 syms_of_fileio ();
1158 /* Before syms_of_coding to initialize Vgc_cons_threshold. */ 1159 /* Before syms_of_coding to initialize Vgc_cons_threshold. */
1159 syms_of_alloc (); 1160 syms_of_alloc ();
@@ -1165,7 +1166,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1165 1166
1166 init_window_once (); /* Init the window system. */ 1167 init_window_once (); /* Init the window system. */
1167#ifdef HAVE_WINDOW_SYSTEM 1168#ifdef HAVE_WINDOW_SYSTEM
1168 init_fringe_once (); /* Swap bitmaps if necessary. */ 1169 init_fringe_once (); /* Swap bitmaps if necessary. */
1169#endif /* HAVE_WINDOW_SYSTEM */ 1170#endif /* HAVE_WINDOW_SYSTEM */
1170 } 1171 }
1171 1172
@@ -1348,7 +1349,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1348 syms_of_lread (); 1349 syms_of_lread ();
1349 syms_of_print (); 1350 syms_of_print ();
1350 syms_of_eval (); 1351 syms_of_eval ();
1351 syms_of_fns ();
1352 syms_of_floatfns (); 1352 syms_of_floatfns ();
1353 1353
1354 syms_of_buffer (); 1354 syms_of_buffer ();
diff --git a/src/eval.c b/src/eval.c
index 975204da017..dcd48cb7250 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1876,26 +1876,19 @@ this does nothing and returns nil. */)
1876 CHECK_STRING (file); 1876 CHECK_STRING (file);
1877 1877
1878 /* If function is defined and not as an autoload, don't override. */ 1878 /* If function is defined and not as an autoload, don't override. */
1879 if ((CONSP (XSYMBOL (function)->function) 1879 if (!EQ (XSYMBOL (function)->function, Qunbound)
1880 && EQ (XCAR (XSYMBOL (function)->function), Qautoload))) 1880 && !AUTOLOADP (XSYMBOL (function)->function))
1881 /* Remember that the function was already an autoload. */
1882 LOADHIST_ATTACH (Fcons (Qt, function));
1883 else if (!EQ (XSYMBOL (function)->function, Qunbound))
1884 return Qnil; 1881 return Qnil;
1885 1882
1886 if (NILP (Vpurify_flag)) 1883 if (!NILP (Vpurify_flag) && EQ (docstring, make_number (0)))
1887 /* Only add entries after dumping, because the ones before are
1888 not useful and else we get loads of them from the loaddefs.el. */
1889 LOADHIST_ATTACH (Fcons (Qautoload, function));
1890 else if (EQ (docstring, make_number (0)))
1891 /* `read1' in lread.c has found the docstring starting with "\ 1884 /* `read1' in lread.c has found the docstring starting with "\
1892 and assumed the docstring will be provided by Snarf-documentation, so it 1885 and assumed the docstring will be provided by Snarf-documentation, so it
1893 passed us 0 instead. But that leads to accidental sharing in purecopy's 1886 passed us 0 instead. But that leads to accidental sharing in purecopy's
1894 hash-consing, so we use a (hopefully) unique integer instead. */ 1887 hash-consing, so we use a (hopefully) unique integer instead. */
1895 docstring = make_number (XUNTAG (function, Lisp_Symbol)); 1888 docstring = make_number (XHASH (function));
1896 return Ffset (function, 1889 return Fdefalias (function,
1897 Fpurecopy (list5 (Qautoload, file, docstring, 1890 list5 (Qautoload, file, docstring, interactive, type),
1898 interactive, type))); 1891 Qnil);
1899} 1892}
1900 1893
1901Lisp_Object 1894Lisp_Object
diff --git a/src/fileio.c b/src/fileio.c
index d47d7dd9e0b..b9541e78838 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5076,7 +5076,7 @@ See Info node `(elisp)Modification Time' for more details. */)
5076 struct stat st; 5076 struct stat st;
5077 Lisp_Object handler; 5077 Lisp_Object handler;
5078 Lisp_Object filename; 5078 Lisp_Object filename;
5079 EMACS_TIME mtime, diff; 5079 EMACS_TIME mtime;
5080 5080
5081 if (NILP (buf)) 5081 if (NILP (buf))
5082 b = current_buffer; 5082 b = current_buffer;
@@ -5101,13 +5101,7 @@ See Info node `(elisp)Modification Time' for more details. */)
5101 mtime = (stat (SSDATA (filename), &st) == 0 5101 mtime = (stat (SSDATA (filename), &st) == 0
5102 ? get_stat_mtime (&st) 5102 ? get_stat_mtime (&st)
5103 : time_error_value (errno)); 5103 : time_error_value (errno));
5104 if ((EMACS_TIME_EQ (mtime, b->modtime) 5104 if (EMACS_TIME_EQ (mtime, b->modtime)
5105 /* If both exist, accept them if they are off by one second. */
5106 || (EMACS_TIME_VALID_P (mtime) && EMACS_TIME_VALID_P (b->modtime)
5107 && ((diff = (EMACS_TIME_LT (mtime, b->modtime)
5108 ? sub_emacs_time (b->modtime, mtime)
5109 : sub_emacs_time (mtime, b->modtime))),
5110 EMACS_TIME_LE (diff, make_emacs_time (1, 0)))))
5111 && (st.st_size == b->modtime_size 5105 && (st.st_size == b->modtime_size
5112 || b->modtime_size < 0)) 5106 || b->modtime_size < 0))
5113 return Qt; 5107 return Qt;
diff --git a/src/fns.c b/src/fns.c
index b1ba5ce9509..7c2222e9805 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2014,7 +2014,7 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props)
2014 d1 = extract_float (o1); 2014 d1 = extract_float (o1);
2015 d2 = extract_float (o2); 2015 d2 = extract_float (o2);
2016 /* If d is a NaN, then d != d. Two NaNs should be `equal' even 2016 /* If d is a NaN, then d != d. Two NaNs should be `equal' even
2017 though they are not =. */ 2017 though they are not =. */
2018 return d1 == d2 || (d1 != d1 && d2 != d2); 2018 return d1 == d2 || (d1 != d1 && d2 != d2);
2019 } 2019 }
2020 2020
@@ -2076,9 +2076,8 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props)
2076 are sensible to compare, so eliminate the others now. */ 2076 are sensible to compare, so eliminate the others now. */
2077 if (size & PSEUDOVECTOR_FLAG) 2077 if (size & PSEUDOVECTOR_FLAG)
2078 { 2078 {
2079 if (!(size & ((PVEC_COMPILED | PVEC_CHAR_TABLE 2079 if (((size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS)
2080 | PVEC_SUB_CHAR_TABLE | PVEC_FONT) 2080 < PVEC_COMPILED)
2081 << PSEUDOVECTOR_SIZE_BITS)))
2082 return 0; 2081 return 0;
2083 size &= PSEUDOVECTOR_SIZE_MASK; 2082 size &= PSEUDOVECTOR_SIZE_MASK;
2084 } 2083 }
@@ -3332,8 +3331,8 @@ static struct Lisp_Hash_Table *weak_hash_tables;
3332 3331
3333/* Various symbols. */ 3332/* Various symbols. */
3334 3333
3335static Lisp_Object Qhash_table_p, Qkey, Qvalue; 3334static Lisp_Object Qhash_table_p, Qkey, Qvalue, Qeql;
3336Lisp_Object Qeq, Qeql, Qequal; 3335Lisp_Object Qeq, Qequal;
3337Lisp_Object QCtest, QCsize, QCrehash_size, QCrehash_threshold, QCweakness; 3336Lisp_Object QCtest, QCsize, QCrehash_size, QCrehash_threshold, QCweakness;
3338static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value; 3337static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value;
3339 3338
@@ -3425,14 +3424,17 @@ larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max)
3425 Low-level Functions 3424 Low-level Functions
3426 ***********************************************************************/ 3425 ***********************************************************************/
3427 3426
3427static struct hash_table_test hashtest_eq;
3428struct hash_table_test hashtest_eql, hashtest_equal;
3429
3428/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code 3430/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code
3429 HASH2 in hash table H using `eql'. Value is true if KEY1 and 3431 HASH2 in hash table H using `eql'. Value is true if KEY1 and
3430 KEY2 are the same. */ 3432 KEY2 are the same. */
3431 3433
3432static bool 3434static bool
3433cmpfn_eql (struct Lisp_Hash_Table *h, 3435cmpfn_eql (struct hash_table_test *ht,
3434 Lisp_Object key1, EMACS_UINT hash1, 3436 Lisp_Object key1,
3435 Lisp_Object key2, EMACS_UINT hash2) 3437 Lisp_Object key2)
3436{ 3438{
3437 return (FLOATP (key1) 3439 return (FLOATP (key1)
3438 && FLOATP (key2) 3440 && FLOATP (key2)
@@ -3445,11 +3447,11 @@ cmpfn_eql (struct Lisp_Hash_Table *h,
3445 KEY2 are the same. */ 3447 KEY2 are the same. */
3446 3448
3447static bool 3449static bool
3448cmpfn_equal (struct Lisp_Hash_Table *h, 3450cmpfn_equal (struct hash_table_test *ht,
3449 Lisp_Object key1, EMACS_UINT hash1, 3451 Lisp_Object key1,
3450 Lisp_Object key2, EMACS_UINT hash2) 3452 Lisp_Object key2)
3451{ 3453{
3452 return hash1 == hash2 && !NILP (Fequal (key1, key2)); 3454 return !NILP (Fequal (key1, key2));
3453} 3455}
3454 3456
3455 3457
@@ -3458,21 +3460,16 @@ cmpfn_equal (struct Lisp_Hash_Table *h,
3458 if KEY1 and KEY2 are the same. */ 3460 if KEY1 and KEY2 are the same. */
3459 3461
3460static bool 3462static bool
3461cmpfn_user_defined (struct Lisp_Hash_Table *h, 3463cmpfn_user_defined (struct hash_table_test *ht,
3462 Lisp_Object key1, EMACS_UINT hash1, 3464 Lisp_Object key1,
3463 Lisp_Object key2, EMACS_UINT hash2) 3465 Lisp_Object key2)
3464{ 3466{
3465 if (hash1 == hash2) 3467 Lisp_Object args[3];
3466 {
3467 Lisp_Object args[3];
3468 3468
3469 args[0] = h->user_cmp_function; 3469 args[0] = ht->user_cmp_function;
3470 args[1] = key1; 3470 args[1] = key1;
3471 args[2] = key2; 3471 args[2] = key2;
3472 return !NILP (Ffuncall (3, args)); 3472 return !NILP (Ffuncall (3, args));
3473 }
3474 else
3475 return 0;
3476} 3473}
3477 3474
3478 3475
@@ -3481,54 +3478,48 @@ cmpfn_user_defined (struct Lisp_Hash_Table *h,
3481 in a Lisp integer. */ 3478 in a Lisp integer. */
3482 3479
3483static EMACS_UINT 3480static EMACS_UINT
3484hashfn_eq (struct Lisp_Hash_Table *h, Lisp_Object key) 3481hashfn_eq (struct hash_table_test *ht, Lisp_Object key)
3485{ 3482{
3486 EMACS_UINT hash = XUINT (key) ^ XTYPE (key); 3483 EMACS_UINT hash = XHASH (key) ^ XTYPE (key);
3487 eassert ((hash & ~INTMASK) == 0);
3488 return hash; 3484 return hash;
3489} 3485}
3490 3486
3491
3492/* Value is a hash code for KEY for use in hash table H which uses 3487/* Value is a hash code for KEY for use in hash table H which uses
3493 `eql' to compare keys. The hash code returned is guaranteed to fit 3488 `eql' to compare keys. The hash code returned is guaranteed to fit
3494 in a Lisp integer. */ 3489 in a Lisp integer. */
3495 3490
3496static EMACS_UINT 3491static EMACS_UINT
3497hashfn_eql (struct Lisp_Hash_Table *h, Lisp_Object key) 3492hashfn_eql (struct hash_table_test *ht, Lisp_Object key)
3498{ 3493{
3499 EMACS_UINT hash; 3494 EMACS_UINT hash;
3500 if (FLOATP (key)) 3495 if (FLOATP (key))
3501 hash = sxhash (key, 0); 3496 hash = sxhash (key, 0);
3502 else 3497 else
3503 hash = XUINT (key) ^ XTYPE (key); 3498 hash = XHASH (key) ^ XTYPE (key);
3504 eassert ((hash & ~INTMASK) == 0);
3505 return hash; 3499 return hash;
3506} 3500}
3507 3501
3508
3509/* Value is a hash code for KEY for use in hash table H which uses 3502/* Value is a hash code for KEY for use in hash table H which uses
3510 `equal' to compare keys. The hash code returned is guaranteed to fit 3503 `equal' to compare keys. The hash code returned is guaranteed to fit
3511 in a Lisp integer. */ 3504 in a Lisp integer. */
3512 3505
3513static EMACS_UINT 3506static EMACS_UINT
3514hashfn_equal (struct Lisp_Hash_Table *h, Lisp_Object key) 3507hashfn_equal (struct hash_table_test *ht, Lisp_Object key)
3515{ 3508{
3516 EMACS_UINT hash = sxhash (key, 0); 3509 EMACS_UINT hash = sxhash (key, 0);
3517 eassert ((hash & ~INTMASK) == 0);
3518 return hash; 3510 return hash;
3519} 3511}
3520 3512
3521
3522/* Value is a hash code for KEY for use in hash table H which uses as 3513/* Value is a hash code for KEY for use in hash table H which uses as
3523 user-defined function to compare keys. The hash code returned is 3514 user-defined function to compare keys. The hash code returned is
3524 guaranteed to fit in a Lisp integer. */ 3515 guaranteed to fit in a Lisp integer. */
3525 3516
3526static EMACS_UINT 3517static EMACS_UINT
3527hashfn_user_defined (struct Lisp_Hash_Table *h, Lisp_Object key) 3518hashfn_user_defined (struct hash_table_test *ht, Lisp_Object key)
3528{ 3519{
3529 Lisp_Object args[2], hash; 3520 Lisp_Object args[2], hash;
3530 3521
3531 args[0] = h->user_hash_function; 3522 args[0] = ht->user_hash_function;
3532 args[1] = key; 3523 args[1] = key;
3533 hash = Ffuncall (2, args); 3524 hash = Ffuncall (2, args);
3534 if (!INTEGERP (hash)) 3525 if (!INTEGERP (hash))
@@ -3564,9 +3555,9 @@ hashfn_user_defined (struct Lisp_Hash_Table *h, Lisp_Object key)
3564 one of the symbols `key', `value', `key-or-value', or `key-and-value'. */ 3555 one of the symbols `key', `value', `key-or-value', or `key-and-value'. */
3565 3556
3566Lisp_Object 3557Lisp_Object
3567make_hash_table (Lisp_Object test, Lisp_Object size, Lisp_Object rehash_size, 3558make_hash_table (struct hash_table_test test,
3568 Lisp_Object rehash_threshold, Lisp_Object weak, 3559 Lisp_Object size, Lisp_Object rehash_size,
3569 Lisp_Object user_test, Lisp_Object user_hash) 3560 Lisp_Object rehash_threshold, Lisp_Object weak)
3570{ 3561{
3571 struct Lisp_Hash_Table *h; 3562 struct Lisp_Hash_Table *h;
3572 Lisp_Object table; 3563 Lisp_Object table;
@@ -3575,7 +3566,7 @@ make_hash_table (Lisp_Object test, Lisp_Object size, Lisp_Object rehash_size,
3575 double index_float; 3566 double index_float;
3576 3567
3577 /* Preconditions. */ 3568 /* Preconditions. */
3578 eassert (SYMBOLP (test)); 3569 eassert (SYMBOLP (test.name));
3579 eassert (INTEGERP (size) && XINT (size) >= 0); 3570 eassert (INTEGERP (size) && XINT (size) >= 0);
3580 eassert ((INTEGERP (rehash_size) && XINT (rehash_size) > 0) 3571 eassert ((INTEGERP (rehash_size) && XINT (rehash_size) > 0)
3581 || (FLOATP (rehash_size) && 1 < XFLOAT_DATA (rehash_size))); 3572 || (FLOATP (rehash_size) && 1 < XFLOAT_DATA (rehash_size)));
@@ -3599,29 +3590,6 @@ make_hash_table (Lisp_Object test, Lisp_Object size, Lisp_Object rehash_size,
3599 3590
3600 /* Initialize hash table slots. */ 3591 /* Initialize hash table slots. */
3601 h->test = test; 3592 h->test = test;
3602 if (EQ (test, Qeql))
3603 {
3604 h->cmpfn = cmpfn_eql;
3605 h->hashfn = hashfn_eql;
3606 }
3607 else if (EQ (test, Qeq))
3608 {
3609 h->cmpfn = NULL;
3610 h->hashfn = hashfn_eq;
3611 }
3612 else if (EQ (test, Qequal))
3613 {
3614 h->cmpfn = cmpfn_equal;
3615 h->hashfn = hashfn_equal;
3616 }
3617 else
3618 {
3619 h->user_cmp_function = user_test;
3620 h->user_hash_function = user_hash;
3621 h->cmpfn = cmpfn_user_defined;
3622 h->hashfn = hashfn_user_defined;
3623 }
3624
3625 h->weak = weak; 3593 h->weak = weak;
3626 h->rehash_threshold = rehash_threshold; 3594 h->rehash_threshold = rehash_threshold;
3627 h->rehash_size = rehash_size; 3595 h->rehash_size = rehash_size;
@@ -3661,12 +3629,9 @@ copy_hash_table (struct Lisp_Hash_Table *h1)
3661{ 3629{
3662 Lisp_Object table; 3630 Lisp_Object table;
3663 struct Lisp_Hash_Table *h2; 3631 struct Lisp_Hash_Table *h2;
3664 struct Lisp_Vector *next;
3665 3632
3666 h2 = allocate_hash_table (); 3633 h2 = allocate_hash_table ();
3667 next = h2->header.next.vector;
3668 *h2 = *h1; 3634 *h2 = *h1;
3669 h2->header.next.vector = next;
3670 h2->key_and_value = Fcopy_sequence (h1->key_and_value); 3635 h2->key_and_value = Fcopy_sequence (h1->key_and_value);
3671 h2->hash = Fcopy_sequence (h1->hash); 3636 h2->hash = Fcopy_sequence (h1->hash);
3672 h2->next = Fcopy_sequence (h1->next); 3637 h2->next = Fcopy_sequence (h1->next);
@@ -3780,7 +3745,8 @@ hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash)
3780 ptrdiff_t start_of_bucket; 3745 ptrdiff_t start_of_bucket;
3781 Lisp_Object idx; 3746 Lisp_Object idx;
3782 3747
3783 hash_code = h->hashfn (h, key); 3748 hash_code = h->test.hashfn (&h->test, key);
3749 eassert ((hash_code & ~INTMASK) == 0);
3784 if (hash) 3750 if (hash)
3785 *hash = hash_code; 3751 *hash = hash_code;
3786 3752
@@ -3792,9 +3758,9 @@ hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, EMACS_UINT *hash)
3792 { 3758 {
3793 ptrdiff_t i = XFASTINT (idx); 3759 ptrdiff_t i = XFASTINT (idx);
3794 if (EQ (key, HASH_KEY (h, i)) 3760 if (EQ (key, HASH_KEY (h, i))
3795 || (h->cmpfn 3761 || (h->test.cmpfn
3796 && h->cmpfn (h, key, hash_code, 3762 && hash_code == XUINT (HASH_HASH (h, i))
3797 HASH_KEY (h, i), XUINT (HASH_HASH (h, i))))) 3763 && h->test.cmpfn (&h->test, key, HASH_KEY (h, i))))
3798 break; 3764 break;
3799 idx = HASH_NEXT (h, i); 3765 idx = HASH_NEXT (h, i);
3800 } 3766 }
@@ -3845,7 +3811,8 @@ hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key)
3845 ptrdiff_t start_of_bucket; 3811 ptrdiff_t start_of_bucket;
3846 Lisp_Object idx, prev; 3812 Lisp_Object idx, prev;
3847 3813
3848 hash_code = h->hashfn (h, key); 3814 hash_code = h->test.hashfn (&h->test, key);
3815 eassert ((hash_code & ~INTMASK) == 0);
3849 start_of_bucket = hash_code % ASIZE (h->index); 3816 start_of_bucket = hash_code % ASIZE (h->index);
3850 idx = HASH_INDEX (h, start_of_bucket); 3817 idx = HASH_INDEX (h, start_of_bucket);
3851 prev = Qnil; 3818 prev = Qnil;
@@ -3856,9 +3823,9 @@ hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key)
3856 ptrdiff_t i = XFASTINT (idx); 3823 ptrdiff_t i = XFASTINT (idx);
3857 3824
3858 if (EQ (key, HASH_KEY (h, i)) 3825 if (EQ (key, HASH_KEY (h, i))
3859 || (h->cmpfn 3826 || (h->test.cmpfn
3860 && h->cmpfn (h, key, hash_code, 3827 && hash_code == XUINT (HASH_HASH (h, i))
3861 HASH_KEY (h, i), XUINT (HASH_HASH (h, i))))) 3828 && h->test.cmpfn (&h->test, key, HASH_KEY (h, i))))
3862 { 3829 {
3863 /* Take entry out of collision chain. */ 3830 /* Take entry out of collision chain. */
3864 if (NILP (prev)) 3831 if (NILP (prev))
@@ -4070,13 +4037,6 @@ sweep_weak_hash_tables (void)
4070 4037
4071#define SXHASH_MAX_LEN 7 4038#define SXHASH_MAX_LEN 7
4072 4039
4073/* Combine two integers X and Y for hashing. The result might not fit
4074 into a Lisp integer. */
4075
4076#define SXHASH_COMBINE(X, Y) \
4077 ((((EMACS_UINT) (X) << 4) + ((EMACS_UINT) (X) >> (BITS_PER_EMACS_INT - 4))) \
4078 + (EMACS_UINT) (Y))
4079
4080/* Hash X, returning a value that fits into a Lisp integer. */ 4040/* Hash X, returning a value that fits into a Lisp integer. */
4081#define SXHASH_REDUCE(X) \ 4041#define SXHASH_REDUCE(X) \
4082 ((((X) ^ (X) >> (BITS_PER_EMACS_INT - FIXNUM_BITS))) & INTMASK) 4042 ((((X) ^ (X) >> (BITS_PER_EMACS_INT - FIXNUM_BITS))) & INTMASK)
@@ -4095,7 +4055,7 @@ hash_string (char const *ptr, ptrdiff_t len)
4095 while (p != end) 4055 while (p != end)
4096 { 4056 {
4097 c = *p++; 4057 c = *p++;
4098 hash = SXHASH_COMBINE (hash, c); 4058 hash = sxhash_combine (hash, c);
4099 } 4059 }
4100 4060
4101 return hash; 4061 return hash;
@@ -4129,7 +4089,7 @@ sxhash_float (double val)
4129 u.val = val; 4089 u.val = val;
4130 memset (&u.val + 1, 0, sizeof u - sizeof u.val); 4090 memset (&u.val + 1, 0, sizeof u - sizeof u.val);
4131 for (i = 0; i < WORDS_PER_DOUBLE; i++) 4091 for (i = 0; i < WORDS_PER_DOUBLE; i++)
4132 hash = SXHASH_COMBINE (hash, u.word[i]); 4092 hash = sxhash_combine (hash, u.word[i]);
4133 return SXHASH_REDUCE (hash); 4093 return SXHASH_REDUCE (hash);
4134} 4094}
4135 4095
@@ -4148,13 +4108,13 @@ sxhash_list (Lisp_Object list, int depth)
4148 list = XCDR (list), ++i) 4108 list = XCDR (list), ++i)
4149 { 4109 {
4150 EMACS_UINT hash2 = sxhash (XCAR (list), depth + 1); 4110 EMACS_UINT hash2 = sxhash (XCAR (list), depth + 1);
4151 hash = SXHASH_COMBINE (hash, hash2); 4111 hash = sxhash_combine (hash, hash2);
4152 } 4112 }
4153 4113
4154 if (!NILP (list)) 4114 if (!NILP (list))
4155 { 4115 {
4156 EMACS_UINT hash2 = sxhash (list, depth + 1); 4116 EMACS_UINT hash2 = sxhash (list, depth + 1);
4157 hash = SXHASH_COMBINE (hash, hash2); 4117 hash = sxhash_combine (hash, hash2);
4158 } 4118 }
4159 4119
4160 return SXHASH_REDUCE (hash); 4120 return SXHASH_REDUCE (hash);
@@ -4174,7 +4134,7 @@ sxhash_vector (Lisp_Object vec, int depth)
4174 for (i = 0; i < n; ++i) 4134 for (i = 0; i < n; ++i)
4175 { 4135 {
4176 EMACS_UINT hash2 = sxhash (AREF (vec, i), depth + 1); 4136 EMACS_UINT hash2 = sxhash (AREF (vec, i), depth + 1);
4177 hash = SXHASH_COMBINE (hash, hash2); 4137 hash = sxhash_combine (hash, hash2);
4178 } 4138 }
4179 4139
4180 return SXHASH_REDUCE (hash); 4140 return SXHASH_REDUCE (hash);
@@ -4190,7 +4150,7 @@ sxhash_bool_vector (Lisp_Object vec)
4190 4150
4191 n = min (SXHASH_MAX_LEN, XBOOL_VECTOR (vec)->header.size); 4151 n = min (SXHASH_MAX_LEN, XBOOL_VECTOR (vec)->header.size);
4192 for (i = 0; i < n; ++i) 4152 for (i = 0; i < n; ++i)
4193 hash = SXHASH_COMBINE (hash, XBOOL_VECTOR (vec)->data[i]); 4153 hash = sxhash_combine (hash, XBOOL_VECTOR (vec)->data[i]);
4194 4154
4195 return SXHASH_REDUCE (hash); 4155 return SXHASH_REDUCE (hash);
4196} 4156}
@@ -4214,7 +4174,7 @@ sxhash (Lisp_Object obj, int depth)
4214 break; 4174 break;
4215 4175
4216 case Lisp_Misc: 4176 case Lisp_Misc:
4217 hash = XUINT (obj); 4177 hash = XHASH (obj);
4218 break; 4178 break;
4219 4179
4220 case Lisp_Symbol: 4180 case Lisp_Symbol:
@@ -4238,7 +4198,7 @@ sxhash (Lisp_Object obj, int depth)
4238 else 4198 else
4239 /* Others are `equal' if they are `eq', so let's take their 4199 /* Others are `equal' if they are `eq', so let's take their
4240 address as hash. */ 4200 address as hash. */
4241 hash = XUINT (obj); 4201 hash = XHASH (obj);
4242 break; 4202 break;
4243 4203
4244 case Lisp_Cons: 4204 case Lisp_Cons:
@@ -4307,7 +4267,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4307 (ptrdiff_t nargs, Lisp_Object *args) 4267 (ptrdiff_t nargs, Lisp_Object *args)
4308{ 4268{
4309 Lisp_Object test, size, rehash_size, rehash_threshold, weak; 4269 Lisp_Object test, size, rehash_size, rehash_threshold, weak;
4310 Lisp_Object user_test, user_hash; 4270 struct hash_table_test testdesc;
4311 char *used; 4271 char *used;
4312 ptrdiff_t i; 4272 ptrdiff_t i;
4313 4273
@@ -4319,7 +4279,13 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4319 /* See if there's a `:test TEST' among the arguments. */ 4279 /* See if there's a `:test TEST' among the arguments. */
4320 i = get_key_arg (QCtest, nargs, args, used); 4280 i = get_key_arg (QCtest, nargs, args, used);
4321 test = i ? args[i] : Qeql; 4281 test = i ? args[i] : Qeql;
4322 if (!EQ (test, Qeq) && !EQ (test, Qeql) && !EQ (test, Qequal)) 4282 if (EQ (test, Qeq))
4283 testdesc = hashtest_eq;
4284 else if (EQ (test, Qeql))
4285 testdesc = hashtest_eql;
4286 else if (EQ (test, Qequal))
4287 testdesc = hashtest_equal;
4288 else
4323 { 4289 {
4324 /* See if it is a user-defined test. */ 4290 /* See if it is a user-defined test. */
4325 Lisp_Object prop; 4291 Lisp_Object prop;
@@ -4327,11 +4293,12 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4327 prop = Fget (test, Qhash_table_test); 4293 prop = Fget (test, Qhash_table_test);
4328 if (!CONSP (prop) || !CONSP (XCDR (prop))) 4294 if (!CONSP (prop) || !CONSP (XCDR (prop)))
4329 signal_error ("Invalid hash table test", test); 4295 signal_error ("Invalid hash table test", test);
4330 user_test = XCAR (prop); 4296 testdesc.name = test;
4331 user_hash = XCAR (XCDR (prop)); 4297 testdesc.user_cmp_function = XCAR (prop);
4298 testdesc.user_hash_function = XCAR (XCDR (prop));
4299 testdesc.hashfn = hashfn_user_defined;
4300 testdesc.cmpfn = cmpfn_user_defined;
4332 } 4301 }
4333 else
4334 user_test = user_hash = Qnil;
4335 4302
4336 /* See if there's a `:size SIZE' argument. */ 4303 /* See if there's a `:size SIZE' argument. */
4337 i = get_key_arg (QCsize, nargs, args, used); 4304 i = get_key_arg (QCsize, nargs, args, used);
@@ -4373,8 +4340,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4373 if (!used[i]) 4340 if (!used[i])
4374 signal_error ("Invalid argument list", args[i]); 4341 signal_error ("Invalid argument list", args[i]);
4375 4342
4376 return make_hash_table (test, size, rehash_size, rehash_threshold, weak, 4343 return make_hash_table (testdesc, size, rehash_size, rehash_threshold, weak);
4377 user_test, user_hash);
4378} 4344}
4379 4345
4380 4346
@@ -4428,7 +4394,7 @@ DEFUN ("hash-table-test", Fhash_table_test, Shash_table_test, 1, 1, 0,
4428 doc: /* Return the test TABLE uses. */) 4394 doc: /* Return the test TABLE uses. */)
4429 (Lisp_Object table) 4395 (Lisp_Object table)
4430{ 4396{
4431 return check_hash_table (table)->test; 4397 return check_hash_table (table)->test.name;
4432} 4398}
4433 4399
4434 4400
@@ -4992,4 +4958,14 @@ this variable. */);
4992 defsubr (&Smd5); 4958 defsubr (&Smd5);
4993 defsubr (&Ssecure_hash); 4959 defsubr (&Ssecure_hash);
4994 defsubr (&Slocale_info); 4960 defsubr (&Slocale_info);
4961
4962 {
4963 struct hash_table_test
4964 eq = { Qeq, Qnil, Qnil, NULL, hashfn_eq },
4965 eql = { Qeql, Qnil, Qnil, cmpfn_eql, hashfn_eql },
4966 equal = { Qequal, Qnil, Qnil, cmpfn_equal, hashfn_equal };
4967 hashtest_eq = eq;
4968 hashtest_eql = eql;
4969 hashtest_equal = equal;
4970 }
4995} 4971}
diff --git a/src/font.c b/src/font.c
index 1ec5929506e..c57ca3ccec4 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4006,16 +4006,11 @@ The optional argument FRAME specifies the frame that the face attributes
4006are to be displayed on. If omitted, the selected frame is used. */) 4006are to be displayed on. If omitted, the selected frame is used. */)
4007 (Lisp_Object font, Lisp_Object frame) 4007 (Lisp_Object font, Lisp_Object frame)
4008{ 4008{
4009 struct frame *f; 4009 struct frame *f = decode_live_frame (frame);
4010 Lisp_Object plist[10]; 4010 Lisp_Object plist[10];
4011 Lisp_Object val; 4011 Lisp_Object val;
4012 int n = 0; 4012 int n = 0;
4013 4013
4014 if (NILP (frame))
4015 frame = selected_frame;
4016 CHECK_LIVE_FRAME (frame);
4017 f = XFRAME (frame);
4018
4019 if (STRINGP (font)) 4014 if (STRINGP (font))
4020 { 4015 {
4021 int fontset = fs_query_fontset (font, 0); 4016 int fontset = fs_query_fontset (font, 0);
@@ -4165,18 +4160,15 @@ how close they are to PREFER. */)
4165 4160
4166DEFUN ("font-family-list", Ffont_family_list, Sfont_family_list, 0, 1, 0, 4161DEFUN ("font-family-list", Ffont_family_list, Sfont_family_list, 0, 1, 0,
4167 doc: /* List available font families on the current frame. 4162 doc: /* List available font families on the current frame.
4168Optional argument FRAME, if non-nil, specifies the target frame. */) 4163If FRAME is omitted or nil, the selected frame is used. */)
4169 (Lisp_Object frame) 4164 (Lisp_Object frame)
4170{ 4165{
4171 FRAME_PTR f; 4166 struct frame *f = decode_live_frame (frame);
4172 struct font_driver_list *driver_list; 4167 struct font_driver_list *driver_list;
4173 Lisp_Object list; 4168 Lisp_Object list = Qnil;
4169
4170 XSETFRAME (frame, f);
4174 4171
4175 if (NILP (frame))
4176 frame = selected_frame;
4177 CHECK_LIVE_FRAME (frame);
4178 f = XFRAME (frame);
4179 list = Qnil;
4180 for (driver_list = f->font_driver_list; driver_list; 4172 for (driver_list = f->font_driver_list; driver_list;
4181 driver_list = driver_list->next) 4173 driver_list = driver_list->next)
4182 if (driver_list->driver->list_family) 4174 if (driver_list->driver->list_family)
@@ -4544,11 +4536,9 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4544 (Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame) 4536 (Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame)
4545{ 4537{
4546 EMACS_INT isize; 4538 EMACS_INT isize;
4539 struct frame *f = decode_live_frame (frame);
4547 4540
4548 CHECK_FONT_ENTITY (font_entity); 4541 CHECK_FONT_ENTITY (font_entity);
4549 if (NILP (frame))
4550 frame = selected_frame;
4551 CHECK_LIVE_FRAME (frame);
4552 4542
4553 if (NILP (size)) 4543 if (NILP (size))
4554 isize = XINT (AREF (font_entity, FONT_SIZE_INDEX)); 4544 isize = XINT (AREF (font_entity, FONT_SIZE_INDEX));
@@ -4556,7 +4546,7 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4556 { 4546 {
4557 CHECK_NUMBER_OR_FLOAT (size); 4547 CHECK_NUMBER_OR_FLOAT (size);
4558 if (FLOATP (size)) 4548 if (FLOATP (size))
4559 isize = POINT_TO_PIXEL (XFLOAT_DATA (size), XFRAME (frame)->resy); 4549 isize = POINT_TO_PIXEL (XFLOAT_DATA (size), f->resy);
4560 else 4550 else
4561 isize = XINT (size); 4551 isize = XINT (size);
4562 if (! (INT_MIN <= isize && isize <= INT_MAX)) 4552 if (! (INT_MIN <= isize && isize <= INT_MAX))
@@ -4564,7 +4554,7 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4564 if (isize == 0) 4554 if (isize == 0)
4565 isize = 120; 4555 isize = 120;
4566 } 4556 }
4567 return font_open_entity (XFRAME (frame), font_entity, isize); 4557 return font_open_entity (f, font_entity, isize);
4568} 4558}
4569 4559
4570DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, 4560DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0,
@@ -4572,10 +4562,7 @@ DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0,
4572 (Lisp_Object font_object, Lisp_Object frame) 4562 (Lisp_Object font_object, Lisp_Object frame)
4573{ 4563{
4574 CHECK_FONT_OBJECT (font_object); 4564 CHECK_FONT_OBJECT (font_object);
4575 if (NILP (frame)) 4565 font_close_object (decode_live_frame (frame), font_object);
4576 frame = selected_frame;
4577 CHECK_LIVE_FRAME (frame);
4578 font_close_object (XFRAME (frame), font_object);
4579 return Qnil; 4566 return Qnil;
4580} 4567}
4581 4568
@@ -4860,7 +4847,7 @@ where
4860If the named font is not yet loaded, return nil. */) 4847If the named font is not yet loaded, return nil. */)
4861 (Lisp_Object name, Lisp_Object frame) 4848 (Lisp_Object name, Lisp_Object frame)
4862{ 4849{
4863 FRAME_PTR f; 4850 struct frame *f;
4864 struct font *font; 4851 struct font *font;
4865 Lisp_Object info; 4852 Lisp_Object info;
4866 Lisp_Object font_object; 4853 Lisp_Object font_object;
@@ -4869,10 +4856,7 @@ If the named font is not yet loaded, return nil. */)
4869 4856
4870 if (! FONTP (name)) 4857 if (! FONTP (name))
4871 CHECK_STRING (name); 4858 CHECK_STRING (name);
4872 if (NILP (frame)) 4859 f = decode_live_frame (frame);
4873 frame = selected_frame;
4874 CHECK_LIVE_FRAME (frame);
4875 f = XFRAME (frame);
4876 4860
4877 if (STRINGP (name)) 4861 if (STRINGP (name))
4878 { 4862 {
diff --git a/src/fontset.c b/src/fontset.c
index da745b31ca1..b76a216bac2 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1326,17 +1326,14 @@ static Lisp_Object
1326check_fontset_name (Lisp_Object name, Lisp_Object *frame) 1326check_fontset_name (Lisp_Object name, Lisp_Object *frame)
1327{ 1327{
1328 int id; 1328 int id;
1329 struct frame *f = decode_live_frame (*frame);
1329 1330
1330 if (NILP (*frame)) 1331 XSETFRAME (*frame, f);
1331 *frame = selected_frame;
1332 CHECK_LIVE_FRAME (*frame);
1333 1332
1334 if (EQ (name, Qt)) 1333 if (EQ (name, Qt))
1335 return Vdefault_fontset; 1334 return Vdefault_fontset;
1336 if (NILP (name)) 1335 if (NILP (name))
1337 { 1336 id = FRAME_FONTSET (f);
1338 id = FRAME_FONTSET (XFRAME (*frame));
1339 }
1340 else 1337 else
1341 { 1338 {
1342 CHECK_STRING (name); 1339 CHECK_STRING (name);
diff --git a/src/frame.c b/src/frame.c
index 1d375380d56..d580bf7f148 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -131,7 +131,24 @@ fset_minibuffer_window (struct frame *f, Lisp_Object val)
131 f->minibuffer_window = val; 131 f->minibuffer_window = val;
132} 132}
133 133
134 134struct frame *
135decode_live_frame (register Lisp_Object frame)
136{
137 if (NILP (frame))
138 frame = selected_frame;
139 CHECK_LIVE_FRAME (frame);
140 return XFRAME (frame);
141}
142
143struct frame *
144decode_any_frame (register Lisp_Object frame)
145{
146 if (NILP (frame))
147 frame = selected_frame;
148 CHECK_FRAME (frame);
149 return XFRAME (frame);
150}
151
135static void 152static void
136set_menu_bar_lines_1 (Lisp_Object window, int n) 153set_menu_bar_lines_1 (Lisp_Object window, int n)
137{ 154{
@@ -889,7 +906,7 @@ DEFUN ("frame-list", Fframe_list, Sframe_list,
889static Lisp_Object 906static Lisp_Object
890next_frame (Lisp_Object frame, Lisp_Object minibuf) 907next_frame (Lisp_Object frame, Lisp_Object minibuf)
891{ 908{
892 Lisp_Object tail; 909 Lisp_Object f, tail;
893 int passed = 0; 910 int passed = 0;
894 911
895 /* There must always be at least one frame in Vframe_list. */ 912 /* There must always be at least one frame in Vframe_list. */
@@ -901,12 +918,8 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf)
901 CHECK_LIVE_FRAME (frame); 918 CHECK_LIVE_FRAME (frame);
902 919
903 while (1) 920 while (1)
904 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 921 FOR_EACH_FRAME (tail, f)
905 { 922 {
906 Lisp_Object f;
907
908 f = XCAR (tail);
909
910 if (passed 923 if (passed
911 && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame)) 924 && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame))
912 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) 925 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
@@ -967,22 +980,13 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf)
967static Lisp_Object 980static Lisp_Object
968prev_frame (Lisp_Object frame, Lisp_Object minibuf) 981prev_frame (Lisp_Object frame, Lisp_Object minibuf)
969{ 982{
970 Lisp_Object tail; 983 Lisp_Object f, tail, prev = Qnil;
971 Lisp_Object prev;
972 984
973 /* There must always be at least one frame in Vframe_list. */ 985 /* There must always be at least one frame in Vframe_list. */
974 if (! CONSP (Vframe_list)) 986 eassert (CONSP (Vframe_list));
975 emacs_abort ();
976 987
977 prev = Qnil; 988 FOR_EACH_FRAME (tail, f)
978 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
979 { 989 {
980 Lisp_Object f;
981
982 f = XCAR (tail);
983 if (!FRAMEP (f))
984 emacs_abort ();
985
986 if (EQ (frame, f) && !NILP (prev)) 990 if (EQ (frame, f) && !NILP (prev))
987 return prev; 991 return prev;
988 992
@@ -1083,11 +1087,10 @@ Otherwise, include all frames. */)
1083static int 1087static int
1084other_visible_frames (FRAME_PTR f) 1088other_visible_frames (FRAME_PTR f)
1085{ 1089{
1086 Lisp_Object frames; 1090 Lisp_Object frames, this;
1087 1091
1088 for (frames = Vframe_list; CONSP (frames); frames = XCDR (frames)) 1092 FOR_EACH_FRAME (frames, this)
1089 { 1093 {
1090 Lisp_Object this = XCAR (frames);
1091 if (f == XFRAME (this)) 1094 if (f == XFRAME (this))
1092 continue; 1095 continue;
1093 1096
@@ -1118,23 +1121,12 @@ other_visible_frames (FRAME_PTR f)
1118Lisp_Object 1121Lisp_Object
1119delete_frame (Lisp_Object frame, Lisp_Object force) 1122delete_frame (Lisp_Object frame, Lisp_Object force)
1120{ 1123{
1121 struct frame *f; 1124 struct frame *f = decode_any_frame (frame);
1122 struct frame *sf = SELECTED_FRAME (); 1125 struct frame *sf = SELECTED_FRAME ();
1123 struct kboard *kb; 1126 struct kboard *kb;
1124 1127
1125 int minibuffer_selected, is_tooltip_frame; 1128 int minibuffer_selected, is_tooltip_frame;
1126 1129
1127 if (EQ (frame, Qnil))
1128 {
1129 f = sf;
1130 XSETFRAME (frame, f);
1131 }
1132 else
1133 {
1134 CHECK_FRAME (frame);
1135 f = XFRAME (frame);
1136 }
1137
1138 if (! FRAME_LIVE_P (f)) 1130 if (! FRAME_LIVE_P (f))
1139 return Qnil; 1131 return Qnil;
1140 1132
@@ -1146,19 +1138,16 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1146 if (NILP (XCDR (Vframe_list)) && !EQ (force, Qnoelisp)) 1138 if (NILP (XCDR (Vframe_list)) && !EQ (force, Qnoelisp))
1147 error ("Attempt to delete the only frame"); 1139 error ("Attempt to delete the only frame");
1148 1140
1141 XSETFRAME (frame, f);
1142
1149 /* Does this frame have a minibuffer, and is it the surrogate 1143 /* Does this frame have a minibuffer, and is it the surrogate
1150 minibuffer for any other frame? */ 1144 minibuffer for any other frame? */
1151 if (FRAME_HAS_MINIBUF_P (XFRAME (frame))) 1145 if (FRAME_HAS_MINIBUF_P (f))
1152 { 1146 {
1153 Lisp_Object frames; 1147 Lisp_Object frames, this;
1154 1148
1155 for (frames = Vframe_list; 1149 FOR_EACH_FRAME (frames, this)
1156 CONSP (frames);
1157 frames = XCDR (frames))
1158 { 1150 {
1159 Lisp_Object this;
1160 this = XCAR (frames);
1161
1162 if (! EQ (this, frame) 1151 if (! EQ (this, frame)
1163 && EQ (frame, 1152 && EQ (frame,
1164 WINDOW_FRAME (XWINDOW 1153 WINDOW_FRAME (XWINDOW
@@ -1351,15 +1340,13 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1351 another one. */ 1340 another one. */
1352 if (f == last_nonminibuf_frame) 1341 if (f == last_nonminibuf_frame)
1353 { 1342 {
1354 Lisp_Object frames; 1343 Lisp_Object frames, this;
1355 1344
1356 last_nonminibuf_frame = 0; 1345 last_nonminibuf_frame = 0;
1357 1346
1358 for (frames = Vframe_list; 1347 FOR_EACH_FRAME (frames, this)
1359 CONSP (frames);
1360 frames = XCDR (frames))
1361 { 1348 {
1362 f = XFRAME (XCAR (frames)); 1349 f = XFRAME (this);
1363 if (!FRAME_MINIBUF_ONLY_P (f)) 1350 if (!FRAME_MINIBUF_ONLY_P (f))
1364 { 1351 {
1365 last_nonminibuf_frame = f; 1352 last_nonminibuf_frame = f;
@@ -1372,27 +1359,13 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1372 single-kboard state if we're in it for this kboard. */ 1359 single-kboard state if we're in it for this kboard. */
1373 if (kb != NULL) 1360 if (kb != NULL)
1374 { 1361 {
1375 Lisp_Object frames; 1362 Lisp_Object frames, this;
1376 /* Some frame we found on the same kboard, or nil if there are none. */ 1363 /* Some frame we found on the same kboard, or nil if there are none. */
1377 Lisp_Object frame_on_same_kboard; 1364 Lisp_Object frame_on_same_kboard = Qnil;
1378
1379 frame_on_same_kboard = Qnil;
1380
1381 for (frames = Vframe_list;
1382 CONSP (frames);
1383 frames = XCDR (frames))
1384 {
1385 Lisp_Object this;
1386 struct frame *f1;
1387 1365
1388 this = XCAR (frames); 1366 FOR_EACH_FRAME (frames, this)
1389 if (!FRAMEP (this)) 1367 if (kb == FRAME_KBOARD (XFRAME (this)))
1390 emacs_abort (); 1368 frame_on_same_kboard = this;
1391 f1 = XFRAME (this);
1392
1393 if (kb == FRAME_KBOARD (f1))
1394 frame_on_same_kboard = this;
1395 }
1396 1369
1397 if (NILP (frame_on_same_kboard)) 1370 if (NILP (frame_on_same_kboard))
1398 not_single_kboard_state (kb); 1371 not_single_kboard_state (kb);
@@ -1404,27 +1377,16 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1404 frames with other windows. */ 1377 frames with other windows. */
1405 if (kb != NULL && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame))) 1378 if (kb != NULL && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame)))
1406 { 1379 {
1407 Lisp_Object frames; 1380 Lisp_Object frames, this;
1408 1381
1409 /* The last frame we saw with a minibuffer, minibuffer-only or not. */ 1382 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1410 Lisp_Object frame_with_minibuf; 1383 Lisp_Object frame_with_minibuf = Qnil;
1411 /* Some frame we found on the same kboard, or nil if there are none. */ 1384 /* Some frame we found on the same kboard, or nil if there are none. */
1412 Lisp_Object frame_on_same_kboard; 1385 Lisp_Object frame_on_same_kboard = Qnil;
1413 1386
1414 frame_on_same_kboard = Qnil; 1387 FOR_EACH_FRAME (frames, this)
1415 frame_with_minibuf = Qnil;
1416
1417 for (frames = Vframe_list;
1418 CONSP (frames);
1419 frames = XCDR (frames))
1420 { 1388 {
1421 Lisp_Object this; 1389 struct frame *f1 = XFRAME (this);
1422 struct frame *f1;
1423
1424 this = XCAR (frames);
1425 if (!FRAMEP (this))
1426 emacs_abort ();
1427 f1 = XFRAME (this);
1428 1390
1429 /* Consider only frames on the same kboard 1391 /* Consider only frames on the same kboard
1430 and only those with minibuffers. */ 1392 and only those with minibuffers. */
@@ -1663,25 +1625,23 @@ DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
1663If omitted, FRAME defaults to the currently selected frame. */) 1625If omitted, FRAME defaults to the currently selected frame. */)
1664 (Lisp_Object frame) 1626 (Lisp_Object frame)
1665{ 1627{
1666 if (NILP (frame)) 1628 struct frame *f = decode_live_frame (frame);
1667 frame = selected_frame;
1668
1669 CHECK_LIVE_FRAME (frame);
1670 1629
1671 /* I think this should be done with a hook. */ 1630 /* I think this should be done with a hook. */
1672#ifdef HAVE_WINDOW_SYSTEM 1631#ifdef HAVE_WINDOW_SYSTEM
1673 if (FRAME_WINDOW_P (XFRAME (frame))) 1632 if (FRAME_WINDOW_P (f))
1674 { 1633 {
1675 FRAME_SAMPLE_VISIBILITY (XFRAME (frame)); 1634 FRAME_SAMPLE_VISIBILITY (f);
1676 x_make_frame_visible (XFRAME (frame)); 1635 x_make_frame_visible (f);
1677 } 1636 }
1678#endif 1637#endif
1679 1638
1680 make_frame_visible_1 (XFRAME (frame)->root_window); 1639 make_frame_visible_1 (f->root_window);
1681 1640
1682 /* Make menu bar update for the Buffers and Frames menus. */ 1641 /* Make menu bar update for the Buffers and Frames menus. */
1683 windows_or_buffers_changed++; 1642 windows_or_buffers_changed++;
1684 1643
1644 XSETFRAME (frame, f);
1685 return frame; 1645 return frame;
1686} 1646}
1687 1647
@@ -1722,16 +1682,13 @@ always considered visible, whether or not they are currently being
1722displayed in the terminal. */) 1682displayed in the terminal. */)
1723 (Lisp_Object frame, Lisp_Object force) 1683 (Lisp_Object frame, Lisp_Object force)
1724{ 1684{
1725 if (NILP (frame)) 1685 struct frame *f = decode_live_frame (frame);
1726 frame = selected_frame;
1727
1728 CHECK_LIVE_FRAME (frame);
1729 1686
1730 if (NILP (force) && !other_visible_frames (XFRAME (frame))) 1687 if (NILP (force) && !other_visible_frames (f))
1731 error ("Attempt to make invisible the sole visible or iconified frame"); 1688 error ("Attempt to make invisible the sole visible or iconified frame");
1732 1689
1733 /* Don't allow minibuf_window to remain on a deleted frame. */ 1690 /* Don't allow minibuf_window to remain on a deleted frame. */
1734 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) 1691 if (EQ (f->minibuffer_window, minibuf_window))
1735 { 1692 {
1736 struct frame *sf = XFRAME (selected_frame); 1693 struct frame *sf = XFRAME (selected_frame);
1737 /* Use set_window_buffer instead of Fset_window_buffer (see 1694 /* Use set_window_buffer instead of Fset_window_buffer (see
@@ -1743,8 +1700,8 @@ displayed in the terminal. */)
1743 1700
1744 /* I think this should be done with a hook. */ 1701 /* I think this should be done with a hook. */
1745#ifdef HAVE_WINDOW_SYSTEM 1702#ifdef HAVE_WINDOW_SYSTEM
1746 if (FRAME_WINDOW_P (XFRAME (frame))) 1703 if (FRAME_WINDOW_P (f))
1747 x_make_frame_invisible (XFRAME (frame)); 1704 x_make_frame_invisible (f);
1748#endif 1705#endif
1749 1706
1750 /* Make menu bar update for the Buffers and Frames menus. */ 1707 /* Make menu bar update for the Buffers and Frames menus. */
@@ -1759,19 +1716,10 @@ DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
1759If omitted, FRAME defaults to the currently selected frame. */) 1716If omitted, FRAME defaults to the currently selected frame. */)
1760 (Lisp_Object frame) 1717 (Lisp_Object frame)
1761{ 1718{
1762 if (NILP (frame)) 1719 struct frame *f = decode_live_frame (frame);
1763 frame = selected_frame;
1764
1765 CHECK_LIVE_FRAME (frame);
1766
1767#if 0 /* This isn't logically necessary, and it can do GC. */
1768 /* Don't let the frame remain selected. */
1769 if (EQ (frame, selected_frame))
1770 Fhandle_switch_frame (next_frame (frame, Qt));
1771#endif
1772 1720
1773 /* Don't allow minibuf_window to remain on an iconified frame. */ 1721 /* Don't allow minibuf_window to remain on an iconified frame. */
1774 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) 1722 if (EQ (f->minibuffer_window, minibuf_window))
1775 { 1723 {
1776 struct frame *sf = XFRAME (selected_frame); 1724 struct frame *sf = XFRAME (selected_frame);
1777 /* Use set_window_buffer instead of Fset_window_buffer (see 1725 /* Use set_window_buffer instead of Fset_window_buffer (see
@@ -1783,8 +1731,8 @@ If omitted, FRAME defaults to the currently selected frame. */)
1783 1731
1784 /* I think this should be done with a hook. */ 1732 /* I think this should be done with a hook. */
1785#ifdef HAVE_WINDOW_SYSTEM 1733#ifdef HAVE_WINDOW_SYSTEM
1786 if (FRAME_WINDOW_P (XFRAME (frame))) 1734 if (FRAME_WINDOW_P (f))
1787 x_iconify_frame (XFRAME (frame)); 1735 x_iconify_frame (f);
1788#endif 1736#endif
1789 1737
1790 /* Make menu bar update for the Buffers and Frames menus. */ 1738 /* Make menu bar update for the Buffers and Frames menus. */
@@ -1822,20 +1770,12 @@ DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
1822 doc: /* Return a list of all frames now \"visible\" (being updated). */) 1770 doc: /* Return a list of all frames now \"visible\" (being updated). */)
1823 (void) 1771 (void)
1824{ 1772{
1825 Lisp_Object tail, frame; 1773 Lisp_Object tail, frame, value = Qnil;
1826 struct frame *f; 1774
1827 Lisp_Object value; 1775 FOR_EACH_FRAME (tail, frame)
1776 if (FRAME_VISIBLE_P (XFRAME (frame)))
1777 value = Fcons (frame, value);
1828 1778
1829 value = Qnil;
1830 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
1831 {
1832 frame = XCAR (tail);
1833 if (!FRAMEP (frame))
1834 continue;
1835 f = XFRAME (frame);
1836 if (FRAME_VISIBLE_P (f))
1837 value = Fcons (frame, value);
1838 }
1839 return value; 1779 return value;
1840} 1780}
1841 1781
@@ -1848,13 +1788,9 @@ If Emacs is displaying on an ordinary terminal or some other device which
1848doesn't support multiple overlapping frames, this function selects FRAME. */) 1788doesn't support multiple overlapping frames, this function selects FRAME. */)
1849 (Lisp_Object frame) 1789 (Lisp_Object frame)
1850{ 1790{
1851 struct frame *f; 1791 struct frame *f = decode_live_frame (frame);
1852 if (NILP (frame))
1853 frame = selected_frame;
1854
1855 CHECK_LIVE_FRAME (frame);
1856 1792
1857 f = XFRAME (frame); 1793 XSETFRAME (frame, f);
1858 1794
1859 if (FRAME_TERMCAP_P (f)) 1795 if (FRAME_TERMCAP_P (f))
1860 /* On a text terminal select FRAME. */ 1796 /* On a text terminal select FRAME. */
@@ -1877,14 +1813,7 @@ If Emacs is displaying on an ordinary terminal or some other device which
1877doesn't support multiple overlapping frames, this function does nothing. */) 1813doesn't support multiple overlapping frames, this function does nothing. */)
1878 (Lisp_Object frame) 1814 (Lisp_Object frame)
1879{ 1815{
1880 struct frame *f; 1816 struct frame *f = decode_live_frame (frame);
1881
1882 if (NILP (frame))
1883 frame = selected_frame;
1884
1885 CHECK_LIVE_FRAME (frame);
1886
1887 f = XFRAME (frame);
1888 1817
1889 if (FRAME_TERMINAL (f)->frame_raise_lower_hook) 1818 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
1890 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0); 1819 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0);
@@ -1920,18 +1849,14 @@ is affected by `select-frame', while the latter is not.
1920The redirection lasts until `redirect-frame-focus' is called to change it. */) 1849The redirection lasts until `redirect-frame-focus' is called to change it. */)
1921 (Lisp_Object frame, Lisp_Object focus_frame) 1850 (Lisp_Object frame, Lisp_Object focus_frame)
1922{ 1851{
1923 struct frame *f;
1924
1925 /* Note that we don't check for a live frame here. It's reasonable 1852 /* Note that we don't check for a live frame here. It's reasonable
1926 to redirect the focus of a frame you're about to delete, if you 1853 to redirect the focus of a frame you're about to delete, if you
1927 know what other frame should receive those keystrokes. */ 1854 know what other frame should receive those keystrokes. */
1928 CHECK_FRAME (frame); 1855 struct frame *f = decode_any_frame (frame);
1929 1856
1930 if (! NILP (focus_frame)) 1857 if (! NILP (focus_frame))
1931 CHECK_LIVE_FRAME (focus_frame); 1858 CHECK_LIVE_FRAME (focus_frame);
1932 1859
1933 f = XFRAME (frame);
1934
1935 fset_focus_frame (f, focus_frame); 1860 fset_focus_frame (f, focus_frame);
1936 1861
1937 if (FRAME_TERMINAL (f)->frame_rehighlight_hook) 1862 if (FRAME_TERMINAL (f)->frame_rehighlight_hook)
@@ -1941,15 +1866,14 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */)
1941} 1866}
1942 1867
1943 1868
1944DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0, 1869DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 0, 1, 0,
1945 doc: /* Return the frame to which FRAME's keystrokes are currently being sent. 1870 doc: /* Return the frame to which FRAME's keystrokes are currently being sent.
1946This returns nil if FRAME's focus is not redirected. 1871If FRAME is omitted or nil, the selected frame is used.
1872Return nil if FRAME's focus is not redirected.
1947See `redirect-frame-focus'. */) 1873See `redirect-frame-focus'. */)
1948 (Lisp_Object frame) 1874 (Lisp_Object frame)
1949{ 1875{
1950 CHECK_LIVE_FRAME (frame); 1876 return FRAME_FOCUS_FRAME (decode_live_frame (frame));
1951
1952 return FRAME_FOCUS_FRAME (XFRAME (frame));
1953} 1877}
1954 1878
1955 1879
@@ -1972,22 +1896,6 @@ get_frame_param (register struct frame *frame, Lisp_Object prop)
1972} 1896}
1973#endif 1897#endif
1974 1898
1975/* Return the buffer-predicate of the selected frame. */
1976
1977Lisp_Object
1978frame_buffer_predicate (Lisp_Object frame)
1979{
1980 return XFRAME (frame)->buffer_predicate;
1981}
1982
1983/* Return the buffer-list of the selected frame. */
1984
1985static Lisp_Object
1986frame_buffer_list (Lisp_Object frame)
1987{
1988 return XFRAME (frame)->buffer_list;
1989}
1990
1991/* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */ 1899/* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1992 1900
1993void 1901void
@@ -2166,20 +2074,14 @@ DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
2166 doc: /* Return the parameters-alist of frame FRAME. 2074 doc: /* Return the parameters-alist of frame FRAME.
2167It is a list of elements of the form (PARM . VALUE), where PARM is a symbol. 2075It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2168The meaningful PARMs depend on the kind of frame. 2076The meaningful PARMs depend on the kind of frame.
2169If FRAME is omitted, return information on the currently selected frame. */) 2077If FRAME is omitted or nil, return information on the currently selected frame. */)
2170 (Lisp_Object frame) 2078 (Lisp_Object frame)
2171{ 2079{
2172 Lisp_Object alist; 2080 Lisp_Object alist;
2173 FRAME_PTR f; 2081 struct frame *f = decode_any_frame (frame);
2174 int height, width; 2082 int height, width;
2175 struct gcpro gcpro1; 2083 struct gcpro gcpro1;
2176 2084
2177 if (NILP (frame))
2178 frame = selected_frame;
2179
2180 CHECK_FRAME (frame);
2181 f = XFRAME (frame);
2182
2183 if (!FRAME_LIVE_P (f)) 2085 if (!FRAME_LIVE_P (f))
2184 return Qnil; 2086 return Qnil;
2185 2087
@@ -2240,9 +2142,8 @@ If FRAME is omitted, return information on the currently selected frame. */)
2240 : FRAME_MINIBUF_ONLY_P (f) ? Qonly 2142 : FRAME_MINIBUF_ONLY_P (f) ? Qonly
2241 : FRAME_MINIBUF_WINDOW (f))); 2143 : FRAME_MINIBUF_WINDOW (f)));
2242 store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil)); 2144 store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
2243 store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame)); 2145 store_in_alist (&alist, Qbuffer_list, f->buffer_list);
2244 store_in_alist (&alist, Qburied_buffer_list, 2146 store_in_alist (&alist, Qburied_buffer_list, f->buried_buffer_list);
2245 XFRAME (frame)->buried_buffer_list);
2246 2147
2247 /* I think this should be done with a hook. */ 2148 /* I think this should be done with a hook. */
2248#ifdef HAVE_WINDOW_SYSTEM 2149#ifdef HAVE_WINDOW_SYSTEM
@@ -2267,17 +2168,12 @@ DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0,
2267If FRAME is nil, describe the currently selected frame. */) 2168If FRAME is nil, describe the currently selected frame. */)
2268 (Lisp_Object frame, Lisp_Object parameter) 2169 (Lisp_Object frame, Lisp_Object parameter)
2269{ 2170{
2270 struct frame *f; 2171 struct frame *f = decode_any_frame (frame);
2271 Lisp_Object value; 2172 Lisp_Object value = Qnil;
2272 2173
2273 if (NILP (frame))
2274 frame = selected_frame;
2275 else
2276 CHECK_FRAME (frame);
2277 CHECK_SYMBOL (parameter); 2174 CHECK_SYMBOL (parameter);
2278 2175
2279 f = XFRAME (frame); 2176 XSETFRAME (frame, f);
2280 value = Qnil;
2281 2177
2282 if (FRAME_LIVE_P (f)) 2178 if (FRAME_LIVE_P (f))
2283 { 2179 {
@@ -2357,14 +2253,9 @@ Note that this functionality is obsolete as of Emacs 22.2, and its
2357use is not recommended. Explicitly check for a frame-parameter instead. */) 2253use is not recommended. Explicitly check for a frame-parameter instead. */)
2358 (Lisp_Object frame, Lisp_Object alist) 2254 (Lisp_Object frame, Lisp_Object alist)
2359{ 2255{
2360 FRAME_PTR f; 2256 struct frame *f = decode_live_frame (frame);
2361 register Lisp_Object tail, prop, val; 2257 register Lisp_Object tail, prop, val;
2362 2258
2363 if (EQ (frame, Qnil))
2364 frame = selected_frame;
2365 CHECK_LIVE_FRAME (frame);
2366 f = XFRAME (frame);
2367
2368 /* I think this should be done with a hook. */ 2259 /* I think this should be done with a hook. */
2369#ifdef HAVE_WINDOW_SYSTEM 2260#ifdef HAVE_WINDOW_SYSTEM
2370 if (FRAME_WINDOW_P (f)) 2261 if (FRAME_WINDOW_P (f))
@@ -2419,18 +2310,13 @@ use is not recommended. Explicitly check for a frame-parameter instead. */)
2419DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height, 2310DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
2420 0, 1, 0, 2311 0, 1, 0,
2421 doc: /* Height in pixels of a line in the font in frame FRAME. 2312 doc: /* Height in pixels of a line in the font in frame FRAME.
2422If FRAME is omitted, the selected frame is used. 2313If FRAME is omitted or nil, the selected frame is used.
2423For a terminal frame, the value is always 1. */) 2314For a terminal frame, the value is always 1. */)
2424 (Lisp_Object frame) 2315 (Lisp_Object frame)
2425{ 2316{
2426 struct frame *f;
2427
2428 if (NILP (frame))
2429 frame = selected_frame;
2430 CHECK_FRAME (frame);
2431 f = XFRAME (frame);
2432
2433#ifdef HAVE_WINDOW_SYSTEM 2317#ifdef HAVE_WINDOW_SYSTEM
2318 struct frame *f = decode_any_frame (frame);
2319
2434 if (FRAME_WINDOW_P (f)) 2320 if (FRAME_WINDOW_P (f))
2435 return make_number (x_char_height (f)); 2321 return make_number (x_char_height (f));
2436 else 2322 else
@@ -2442,19 +2328,14 @@ For a terminal frame, the value is always 1. */)
2442DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width, 2328DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
2443 0, 1, 0, 2329 0, 1, 0,
2444 doc: /* Width in pixels of characters in the font in frame FRAME. 2330 doc: /* Width in pixels of characters in the font in frame FRAME.
2445If FRAME is omitted, the selected frame is used. 2331If FRAME is omitted or nil, the selected frame is used.
2446On a graphical screen, the width is the standard width of the default font. 2332On a graphical screen, the width is the standard width of the default font.
2447For a terminal screen, the value is always 1. */) 2333For a terminal screen, the value is always 1. */)
2448 (Lisp_Object frame) 2334 (Lisp_Object frame)
2449{ 2335{
2450 struct frame *f;
2451
2452 if (NILP (frame))
2453 frame = selected_frame;
2454 CHECK_FRAME (frame);
2455 f = XFRAME (frame);
2456
2457#ifdef HAVE_WINDOW_SYSTEM 2336#ifdef HAVE_WINDOW_SYSTEM
2337 struct frame *f = decode_any_frame (frame);
2338
2458 if (FRAME_WINDOW_P (f)) 2339 if (FRAME_WINDOW_P (f))
2459 return make_number (x_char_width (f)); 2340 return make_number (x_char_width (f));
2460 else 2341 else
@@ -2465,7 +2346,7 @@ For a terminal screen, the value is always 1. */)
2465DEFUN ("frame-pixel-height", Fframe_pixel_height, 2346DEFUN ("frame-pixel-height", Fframe_pixel_height,
2466 Sframe_pixel_height, 0, 1, 0, 2347 Sframe_pixel_height, 0, 1, 0,
2467 doc: /* Return a FRAME's height in pixels. 2348 doc: /* Return a FRAME's height in pixels.
2468If FRAME is omitted, the selected frame is used. The exact value 2349If FRAME is omitted or nil, the selected frame is used. The exact value
2469of the result depends on the window-system and toolkit in use: 2350of the result depends on the window-system and toolkit in use:
2470 2351
2471In the Gtk+ version of Emacs, it includes only any window (including 2352In the Gtk+ version of Emacs, it includes only any window (including
@@ -2480,12 +2361,7 @@ result is really in characters rather than pixels (i.e., is identical
2480to `frame-height'). */) 2361to `frame-height'). */)
2481 (Lisp_Object frame) 2362 (Lisp_Object frame)
2482{ 2363{
2483 struct frame *f; 2364 struct frame *f = decode_any_frame (frame);
2484
2485 if (NILP (frame))
2486 frame = selected_frame;
2487 CHECK_FRAME (frame);
2488 f = XFRAME (frame);
2489 2365
2490#ifdef HAVE_WINDOW_SYSTEM 2366#ifdef HAVE_WINDOW_SYSTEM
2491 if (FRAME_WINDOW_P (f)) 2367 if (FRAME_WINDOW_P (f))
@@ -2499,15 +2375,10 @@ DEFUN ("frame-pixel-width", Fframe_pixel_width,
2499 Sframe_pixel_width, 0, 1, 0, 2375 Sframe_pixel_width, 0, 1, 0,
2500 doc: /* Return FRAME's width in pixels. 2376 doc: /* Return FRAME's width in pixels.
2501For a terminal frame, the result really gives the width in characters. 2377For a terminal frame, the result really gives the width in characters.
2502If FRAME is omitted, the selected frame is used. */) 2378If FRAME is omitted or nil, the selected frame is used. */)
2503 (Lisp_Object frame) 2379 (Lisp_Object frame)
2504{ 2380{
2505 struct frame *f; 2381 struct frame *f = decode_any_frame (frame);
2506
2507 if (NILP (frame))
2508 frame = selected_frame;
2509 CHECK_FRAME (frame);
2510 f = XFRAME (frame);
2511 2382
2512#ifdef HAVE_WINDOW_SYSTEM 2383#ifdef HAVE_WINDOW_SYSTEM
2513 if (FRAME_WINDOW_P (f)) 2384 if (FRAME_WINDOW_P (f))
@@ -2521,17 +2392,15 @@ DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width,
2521 Stool_bar_pixel_width, 0, 1, 0, 2392 Stool_bar_pixel_width, 0, 1, 0,
2522 doc: /* Return width in pixels of FRAME's tool bar. 2393 doc: /* Return width in pixels of FRAME's tool bar.
2523The result is greater than zero only when the tool bar is on the left 2394The result is greater than zero only when the tool bar is on the left
2524or right side of FRAME. If FRAME is omitted, the selected frame is 2395or right side of FRAME. If FRAME is omitted or nil, the selected frame
2525used. */) 2396is used. */)
2526 (Lisp_Object frame) 2397 (Lisp_Object frame)
2527{ 2398{
2528 if (NILP (frame))
2529 frame = selected_frame;
2530 CHECK_FRAME (frame);
2531
2532#ifdef FRAME_TOOLBAR_WIDTH 2399#ifdef FRAME_TOOLBAR_WIDTH
2533 if (FRAME_WINDOW_P (XFRAME (frame))) 2400 struct frame *f = decode_any_frame (frame);
2534 return make_number (FRAME_TOOLBAR_WIDTH (XFRAME (frame))); 2401
2402 if (FRAME_WINDOW_P (f))
2403 return make_number (FRAME_TOOLBAR_WIDTH (f));
2535#endif 2404#endif
2536 return make_number (0); 2405 return make_number (0);
2537} 2406}
@@ -2542,13 +2411,9 @@ Optional third arg non-nil means that redisplay should use LINES lines
2542but that the idea of the actual height of the frame should not be changed. */) 2411but that the idea of the actual height of the frame should not be changed. */)
2543 (Lisp_Object frame, Lisp_Object lines, Lisp_Object pretend) 2412 (Lisp_Object frame, Lisp_Object lines, Lisp_Object pretend)
2544{ 2413{
2545 register struct frame *f; 2414 register struct frame *f = decode_live_frame (frame);
2546 2415
2547 CHECK_TYPE_RANGED_INTEGER (int, lines); 2416 CHECK_TYPE_RANGED_INTEGER (int, lines);
2548 if (NILP (frame))
2549 frame = selected_frame;
2550 CHECK_LIVE_FRAME (frame);
2551 f = XFRAME (frame);
2552 2417
2553 /* I think this should be done with a hook. */ 2418 /* I think this should be done with a hook. */
2554#ifdef HAVE_WINDOW_SYSTEM 2419#ifdef HAVE_WINDOW_SYSTEM
@@ -2570,12 +2435,9 @@ Optional third arg non-nil means that redisplay should use COLS columns
2570but that the idea of the actual width of the frame should not be changed. */) 2435but that the idea of the actual width of the frame should not be changed. */)
2571 (Lisp_Object frame, Lisp_Object cols, Lisp_Object pretend) 2436 (Lisp_Object frame, Lisp_Object cols, Lisp_Object pretend)
2572{ 2437{
2573 register struct frame *f; 2438 register struct frame *f = decode_live_frame (frame);
2439
2574 CHECK_TYPE_RANGED_INTEGER (int, cols); 2440 CHECK_TYPE_RANGED_INTEGER (int, cols);
2575 if (NILP (frame))
2576 frame = selected_frame;
2577 CHECK_LIVE_FRAME (frame);
2578 f = XFRAME (frame);
2579 2441
2580 /* I think this should be done with a hook. */ 2442 /* I think this should be done with a hook. */
2581#ifdef HAVE_WINDOW_SYSTEM 2443#ifdef HAVE_WINDOW_SYSTEM
@@ -4292,12 +4154,7 @@ Otherwise it returns nil. FRAME omitted or nil means the
4292selected frame. This is useful when `make-pointer-invisible' is set. */) 4154selected frame. This is useful when `make-pointer-invisible' is set. */)
4293 (Lisp_Object frame) 4155 (Lisp_Object frame)
4294{ 4156{
4295 if (NILP (frame)) 4157 return decode_any_frame (frame)->pointer_invisible ? Qnil : Qt;
4296 frame = selected_frame;
4297
4298 CHECK_FRAME (frame);
4299
4300 return (XFRAME (frame)->pointer_invisible ? Qnil : Qt);
4301} 4158}
4302 4159
4303 4160
diff --git a/src/frame.h b/src/frame.h
index eea618df797..35cbc44becc 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -237,7 +237,7 @@ struct frame
237 237
238#if defined (USE_GTK) || defined (HAVE_NS) 238#if defined (USE_GTK) || defined (HAVE_NS)
239 /* Nonzero means using a tool bar that comes from the toolkit. */ 239 /* Nonzero means using a tool bar that comes from the toolkit. */
240 int external_tool_bar; 240 unsigned external_tool_bar : 1;
241#endif 241#endif
242 242
243 /* Margin at the top of the frame. Used to display the tool-bar. */ 243 /* Margin at the top of the frame. Used to display the tool-bar. */
@@ -943,6 +943,8 @@ extern Lisp_Object Qnoelisp;
943extern struct frame *last_nonminibuf_frame; 943extern struct frame *last_nonminibuf_frame;
944 944
945extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); 945extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
946extern struct frame *decode_live_frame (Lisp_Object);
947extern struct frame *decode_any_frame (Lisp_Object);
946extern struct frame *make_initial_frame (void); 948extern struct frame *make_initial_frame (void);
947extern struct frame *make_frame (int); 949extern struct frame *make_frame (int);
948#ifdef HAVE_WINDOW_SYSTEM 950#ifdef HAVE_WINDOW_SYSTEM
diff --git a/src/image.c b/src/image.c
index 538ae2b7772..07db6cece1f 100644
--- a/src/image.c
+++ b/src/image.c
@@ -3731,10 +3731,10 @@ xpm_make_color_table_h (void (**put_func) (Lisp_Object,
3731{ 3731{
3732 *put_func = xpm_put_color_table_h; 3732 *put_func = xpm_put_color_table_h;
3733 *get_func = xpm_get_color_table_h; 3733 *get_func = xpm_get_color_table_h;
3734 return make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), 3734 return make_hash_table (hashtest_equal, make_number (DEFAULT_HASH_SIZE),
3735 make_float (DEFAULT_REHASH_SIZE), 3735 make_float (DEFAULT_REHASH_SIZE),
3736 make_float (DEFAULT_REHASH_THRESHOLD), 3736 make_float (DEFAULT_REHASH_THRESHOLD),
3737 Qnil, Qnil, Qnil); 3737 Qnil);
3738} 3738}
3739 3739
3740static void 3740static void
diff --git a/src/keyboard.c b/src/keyboard.c
index dfd4d0c2648..8f3a206139d 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3416,13 +3416,20 @@ int stop_character EXTERNALLY_VISIBLE;
3416static KBOARD * 3416static KBOARD *
3417event_to_kboard (struct input_event *event) 3417event_to_kboard (struct input_event *event)
3418{ 3418{
3419 Lisp_Object obj = event->frame_or_window; 3419 /* Not applicable for these special events. */
3420 /* There are some events that set this field to nil or string. */ 3420 if (event->kind == SELECTION_REQUEST_EVENT
3421 if (WINDOWP (obj)) 3421 || event->kind == SELECTION_CLEAR_EVENT)
3422 obj = WINDOW_FRAME (XWINDOW (obj)); 3422 return NULL;
3423 /* Also ignore dead frames here. */ 3423 else
3424 return ((FRAMEP (obj) && FRAME_LIVE_P (XFRAME (obj))) 3424 {
3425 ? FRAME_KBOARD (XFRAME (obj)) : NULL); 3425 Lisp_Object obj = event->frame_or_window;
3426 /* There are some events that set this field to nil or string. */
3427 if (WINDOWP (obj))
3428 obj = WINDOW_FRAME (XWINDOW (obj));
3429 /* Also ignore dead frames here. */
3430 return ((FRAMEP (obj) && FRAME_LIVE_P (XFRAME (obj)))
3431 ? FRAME_KBOARD (XFRAME (obj)) : NULL);
3432 }
3426} 3433}
3427 3434
3428#ifdef subprocesses 3435#ifdef subprocesses
diff --git a/src/lisp.h b/src/lisp.h
index e9f47f4ed27..72e38fa4653 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -152,15 +152,18 @@ extern bool suppress_checking EXTERNALLY_VISIBLE;
152 on the few static Lisp_Objects used: all the defsubr as well 152 on the few static Lisp_Objects used: all the defsubr as well
153 as the two special buffers buffer_defaults and buffer_local_symbols. */ 153 as the two special buffers buffer_defaults and buffer_local_symbols. */
154 154
155/* Number of bits in a Lisp_Object tag. This can be used in #if. */ 155enum Lisp_Bits
156 {
157 /* Number of bits in a Lisp_Object tag. This can be used in #if,
158 and for GDB's sake also as a regular symbol. */
159 GCTYPEBITS =
156#define GCTYPEBITS 3 160#define GCTYPEBITS 3
161 GCTYPEBITS,
157 162
158/* 2**GCTYPEBITS. This must be a macro that expands to a literal 163 /* 2**GCTYPEBITS. This must be a macro that expands to a literal
159 integer constant, for MSVC. */ 164 integer constant, for MSVC. */
160#define GCALIGNMENT 8 165#define GCALIGNMENT 8
161 166
162enum Lisp_Bits
163 {
164 /* Number of bits in a Lisp_Object value, not counting the tag. */ 167 /* Number of bits in a Lisp_Object value, not counting the tag. */
165 VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS, 168 VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS,
166 169
@@ -378,11 +381,15 @@ enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 0 };
378 381
379/* In the size word of a vector, this bit means the vector has been marked. */ 382/* In the size word of a vector, this bit means the vector has been marked. */
380 383
384static ptrdiff_t const ARRAY_MARK_FLAG
381#define ARRAY_MARK_FLAG PTRDIFF_MIN 385#define ARRAY_MARK_FLAG PTRDIFF_MIN
386 = ARRAY_MARK_FLAG;
382 387
383/* In the size word of a struct Lisp_Vector, this bit means it's really 388/* In the size word of a struct Lisp_Vector, this bit means it's really
384 some other vector-like object. */ 389 some other vector-like object. */
390static ptrdiff_t const PSEUDOVECTOR_FLAG
385#define PSEUDOVECTOR_FLAG (PTRDIFF_MAX - PTRDIFF_MAX / 2) 391#define PSEUDOVECTOR_FLAG (PTRDIFF_MAX - PTRDIFF_MAX / 2)
392 = PSEUDOVECTOR_FLAG;
386 393
387/* In a pseudovector, the size field actually contains a word with one 394/* In a pseudovector, the size field actually contains a word with one
388 PSEUDOVECTOR_FLAG bit set, and one of the following values extracted 395 PSEUDOVECTOR_FLAG bit set, and one of the following values extracted
@@ -401,14 +408,11 @@ enum pvec_type
401 PVEC_WINDOW_CONFIGURATION, 408 PVEC_WINDOW_CONFIGURATION,
402 PVEC_SUBR, 409 PVEC_SUBR,
403 PVEC_OTHER, 410 PVEC_OTHER,
404 /* These last 4 are special because we OR them in fns.c:internal_equal, 411 /* These should be last, check internal_equal to see why. */
405 so they have to use a disjoint bit pattern: 412 PVEC_COMPILED,
406 if (!(size & (PVEC_COMPILED | PVEC_CHAR_TABLE 413 PVEC_CHAR_TABLE,
407 | PVEC_SUB_CHAR_TABLE | PVEC_FONT))) */ 414 PVEC_SUB_CHAR_TABLE,
408 PVEC_COMPILED = 0x10, 415 PVEC_FONT /* Should be last because it's used for range checking. */
409 PVEC_CHAR_TABLE = 0x20,
410 PVEC_SUB_CHAR_TABLE = 0x30,
411 PVEC_FONT = 0x40
412}; 416};
413 417
414/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers 418/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
@@ -428,9 +432,18 @@ enum More_Lisp_Bits
428 only the number of Lisp_Object fields (that need to be traced by GC). 432 only the number of Lisp_Object fields (that need to be traced by GC).
429 The distinction is used, e.g., by Lisp_Process, which places extra 433 The distinction is used, e.g., by Lisp_Process, which places extra
430 non-Lisp_Object fields at the end of the structure. */ 434 non-Lisp_Object fields at the end of the structure. */
431 PSEUDOVECTOR_SIZE_BITS = 16, 435 PSEUDOVECTOR_SIZE_BITS = 12,
432 PSEUDOVECTOR_SIZE_MASK = (1 << PSEUDOVECTOR_SIZE_BITS) - 1, 436 PSEUDOVECTOR_SIZE_MASK = (1 << PSEUDOVECTOR_SIZE_BITS) - 1,
433 PVEC_TYPE_MASK = 0x0fff << PSEUDOVECTOR_SIZE_BITS, 437
438 /* To calculate the memory footprint of the pseudovector, it's useful
439 to store the size of non-Lisp area in word_size units here. */
440 PSEUDOVECTOR_REST_BITS = 12,
441 PSEUDOVECTOR_REST_MASK = (((1 << PSEUDOVECTOR_REST_BITS) - 1)
442 << PSEUDOVECTOR_SIZE_BITS),
443
444 /* Used to extract pseudovector subtype information. */
445 PSEUDOVECTOR_AREA_BITS = PSEUDOVECTOR_SIZE_BITS + PSEUDOVECTOR_REST_BITS,
446 PVEC_TYPE_MASK = 0x3f << PSEUDOVECTOR_AREA_BITS,
434 447
435 /* Number of bits to put in each character in the internal representation 448 /* Number of bits to put in each character in the internal representation
436 of bool vectors. This should not vary across implementations. */ 449 of bool vectors. This should not vary across implementations. */
@@ -441,9 +454,6 @@ enum More_Lisp_Bits
441 For example, if tem is a Lisp_Object whose type is Lisp_Cons, 454 For example, if tem is a Lisp_Object whose type is Lisp_Cons,
442 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */ 455 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
443 456
444/* Return a perfect hash of the Lisp_Object representation. */
445#define XHASH(a) XLI (a)
446
447#if USE_LSB_TAG 457#if USE_LSB_TAG
448 458
449enum lsb_bits 459enum lsb_bits
@@ -464,7 +474,9 @@ enum lsb_bits
464 474
465#else /* not USE_LSB_TAG */ 475#else /* not USE_LSB_TAG */
466 476
477static EMACS_INT const VALMASK
467#define VALMASK VAL_MAX 478#define VALMASK VAL_MAX
479 = VALMASK;
468 480
469#define XTYPE(a) ((enum Lisp_Type) ((EMACS_UINT) XLI (a) >> VALBITS)) 481#define XTYPE(a) ((enum Lisp_Type) ((EMACS_UINT) XLI (a) >> VALBITS))
470 482
@@ -494,6 +506,11 @@ enum lsb_bits
494 506
495#endif /* not USE_LSB_TAG */ 507#endif /* not USE_LSB_TAG */
496 508
509/* Return a (Lisp-integer sized) hash of the Lisp_Object value. Happens to be
510 like XUINT right now, but XUINT should only be applied to objects we know
511 are integers. */
512#define XHASH(a) XUINT (a)
513
497/* For integers known to be positive, XFASTINT sometimes provides 514/* For integers known to be positive, XFASTINT sometimes provides
498 faster retrieval and XSETFASTINT provides faster storage. 515 faster retrieval and XSETFASTINT provides faster storage.
499 If not, fallback on the non-accelerated path. */ 516 If not, fallback on the non-accelerated path. */
@@ -509,7 +526,7 @@ enum lsb_bits
509# define XUNTAG(a, type) XPNTR (a) 526# define XUNTAG(a, type) XPNTR (a)
510#endif 527#endif
511 528
512#define EQ(x, y) (XHASH (x) == XHASH (y)) 529#define EQ(x, y) (XLI (x) == XLI (y))
513 530
514/* Largest and smallest representable fixnum values. These are the C 531/* Largest and smallest representable fixnum values. These are the C
515 values. They are macros for use in static initializers. */ 532 values. They are macros for use in static initializers. */
@@ -599,13 +616,13 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
599 616
600/* Pseudovector types. */ 617/* Pseudovector types. */
601 618
602#define XSETPVECTYPE(v, code) XSETTYPED_PVECTYPE (v, header.size, code) 619#define XSETPVECTYPE(v, code) \
603#define XSETTYPED_PVECTYPE(v, size_member, code) \ 620 ((v)->header.size |= PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_AREA_BITS))
604 ((v)->size_member |= PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_SIZE_BITS)) 621#define XSETPVECTYPESIZE(v, code, lispsize, restsize) \
605#define XSETPVECTYPESIZE(v, code, sizeval) \
606 ((v)->header.size = (PSEUDOVECTOR_FLAG \ 622 ((v)->header.size = (PSEUDOVECTOR_FLAG \
607 | ((code) << PSEUDOVECTOR_SIZE_BITS) \ 623 | ((code) << PSEUDOVECTOR_AREA_BITS) \
608 | (sizeval))) 624 | ((restsize) << PSEUDOVECTOR_SIZE_BITS) \
625 | (lispsize)))
609 626
610/* The cast to struct vectorlike_header * avoids aliasing issues. */ 627/* The cast to struct vectorlike_header * avoids aliasing issues. */
611#define XSETPSEUDOVECTOR(a, b, code) \ 628#define XSETPSEUDOVECTOR(a, b, code) \
@@ -617,16 +634,14 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
617#define XSETTYPED_PSEUDOVECTOR(a, b, size, code) \ 634#define XSETTYPED_PSEUDOVECTOR(a, b, size, code) \
618 (XSETVECTOR (a, b), \ 635 (XSETVECTOR (a, b), \
619 eassert ((size & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK)) \ 636 eassert ((size & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK)) \
620 == (PSEUDOVECTOR_FLAG | (code << PSEUDOVECTOR_SIZE_BITS)))) 637 == (PSEUDOVECTOR_FLAG | (code << PSEUDOVECTOR_AREA_BITS))))
621 638
622#define XSETWINDOW_CONFIGURATION(a, b) \ 639#define XSETWINDOW_CONFIGURATION(a, b) \
623 (XSETPSEUDOVECTOR (a, b, PVEC_WINDOW_CONFIGURATION)) 640 (XSETPSEUDOVECTOR (a, b, PVEC_WINDOW_CONFIGURATION))
624#define XSETPROCESS(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_PROCESS)) 641#define XSETPROCESS(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_PROCESS))
625#define XSETWINDOW(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_WINDOW)) 642#define XSETWINDOW(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_WINDOW))
626#define XSETTERMINAL(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_TERMINAL)) 643#define XSETTERMINAL(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_TERMINAL))
627/* XSETSUBR is special since Lisp_Subr lacks struct vectorlike_header. */ 644#define XSETSUBR(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_SUBR))
628#define XSETSUBR(a, b) \
629 XSETTYPED_PSEUDOVECTOR (a, b, XSUBR (a)->size, PVEC_SUBR)
630#define XSETCOMPILED(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_COMPILED)) 645#define XSETCOMPILED(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_COMPILED))
631#define XSETBUFFER(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_BUFFER)) 646#define XSETBUFFER(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_BUFFER))
632#define XSETCHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_CHAR_TABLE)) 647#define XSETCHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_CHAR_TABLE))
@@ -793,7 +808,7 @@ struct Lisp_String
793 }; 808 };
794 809
795/* Header of vector-like objects. This documents the layout constraints on 810/* Header of vector-like objects. This documents the layout constraints on
796 vectors and pseudovectors other than struct Lisp_Subr. It also prevents 811 vectors and pseudovectors (objects of PVEC_xxx subtype). It also prevents
797 compilers from being fooled by Emacs's type punning: the XSETPSEUDOVECTOR 812 compilers from being fooled by Emacs's type punning: the XSETPSEUDOVECTOR
798 and PSEUDOVECTORP macros cast their pointers to struct vectorlike_header *, 813 and PSEUDOVECTORP macros cast their pointers to struct vectorlike_header *,
799 because when two such pointers potentially alias, a compiler won't 814 because when two such pointers potentially alias, a compiler won't
@@ -801,43 +816,26 @@ struct Lisp_String
801 <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8546>. */ 816 <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8546>. */
802struct vectorlike_header 817struct vectorlike_header
803 { 818 {
804 /* This field contains various pieces of information: 819 /* The only field contains various pieces of information:
805 - The MSB (ARRAY_MARK_FLAG) holds the gcmarkbit. 820 - The MSB (ARRAY_MARK_FLAG) holds the gcmarkbit.
806 - The next bit (PSEUDOVECTOR_FLAG) indicates whether this is a plain 821 - The next bit (PSEUDOVECTOR_FLAG) indicates whether this is a plain
807 vector (0) or a pseudovector (1). 822 vector (0) or a pseudovector (1).
808 - If PSEUDOVECTOR_FLAG is 0, the rest holds the size (number 823 - If PSEUDOVECTOR_FLAG is 0, the rest holds the size (number
809 of slots) of the vector. 824 of slots) of the vector.
810 - If PSEUDOVECTOR_FLAG is 1, the rest is subdivided into 825 - If PSEUDOVECTOR_FLAG is 1, the rest is subdivided into three fields:
811 a "pvec type" tag held in PVEC_TYPE_MASK and a size held in the lowest 826 - a) pseudovector subtype held in PVEC_TYPE_MASK field;
812 PSEUDOVECTOR_SIZE_BITS. That size normally indicates the number of 827 - b) number of Lisp_Objects slots at the beginning of the object
813 Lisp_Object slots at the beginning of the object that need to be 828 held in PSEUDOVECTOR_SIZE_MASK field. These objects are always
814 traced by the GC, tho some types use it slightly differently. 829 traced by the GC;
815 - E.g. if the pvec type is PVEC_FREE it means this is an unallocated 830 - c) size of the rest fields held in PSEUDOVECTOR_REST_MASK and
816 vector on a free-list and PSEUDOVECTOR_SIZE_BITS indicates its size 831 measured in word_size units. Rest fields may also include
817 in bytes. */ 832 Lisp_Objects, but these objects usually needs some special treatment
833 during GC.
834 There are some exceptions. For PVEC_FREE, b) is always zero. For
835 PVEC_BOOL_VECTOR and PVEC_SUBR, both b) and c) are always zero.
836 Current layout limits the pseudovectors to 63 PVEC_xxx subtypes,
837 4095 Lisp_Objects in GC-ed area and 4095 word-sized other slots. */
818 ptrdiff_t size; 838 ptrdiff_t size;
819
820 /* When the vector is allocated from a vector block, NBYTES is used
821 if the vector is not on a free list, and VECTOR is used otherwise.
822 For large vector-like objects, BUFFER or VECTOR is used as a pointer
823 to the next vector-like object. It is generally a buffer or a
824 Lisp_Vector alias, so for convenience it is a union instead of a
825 pointer: this way, one can write P->next.vector instead of ((struct
826 Lisp_Vector *) P->next). */
827 union {
828 /* This is only needed for small vectors that are not free because the
829 `size' field only gives us the number of Lisp_Object slots, whereas we
830 need to know the total size, including non-Lisp_Object data.
831 FIXME: figure out a way to store this info elsewhere so we can
832 finally get rid of this extra word of overhead. */
833 ptrdiff_t nbytes;
834 struct buffer *buffer;
835 /* FIXME: This can be removed: For large vectors, this field could be
836 placed *before* the vector itself. And for small vectors on a free
837 list, this field could be stored in the vector's bytes, since the
838 empty vector is handled specially anyway. */
839 struct Lisp_Vector *vector;
840 } next;
841 }; 839 };
842 840
843/* Regular vector is just a header plus array of Lisp_Objects. */ 841/* Regular vector is just a header plus array of Lisp_Objects. */
@@ -1011,15 +1009,11 @@ struct Lisp_Sub_Char_Table
1011 1009
1012/* This structure describes a built-in function. 1010/* This structure describes a built-in function.
1013 It is generated by the DEFUN macro only. 1011 It is generated by the DEFUN macro only.
1014 defsubr makes it into a Lisp object. 1012 defsubr makes it into a Lisp object. */
1015
1016 This type is treated in most respects as a pseudovector,
1017 but since we never dynamically allocate or free them,
1018 we don't need a struct vectorlike_header and its 'next' field. */
1019 1013
1020struct Lisp_Subr 1014struct Lisp_Subr
1021 { 1015 {
1022 ptrdiff_t size; 1016 struct vectorlike_header header;
1023 union { 1017 union {
1024 Lisp_Object (*a0) (void); 1018 Lisp_Object (*a0) (void);
1025 Lisp_Object (*a1) (Lisp_Object); 1019 Lisp_Object (*a1) (Lisp_Object);
@@ -1167,14 +1161,29 @@ struct Lisp_Symbol
1167 1161
1168/* The structure of a Lisp hash table. */ 1162/* The structure of a Lisp hash table. */
1169 1163
1164struct hash_table_test
1165{
1166 /* Name of the function used to compare keys. */
1167 Lisp_Object name;
1168
1169 /* User-supplied hash function, or nil. */
1170 Lisp_Object user_hash_function;
1171
1172 /* User-supplied key comparison function, or nil. */
1173 Lisp_Object user_cmp_function;
1174
1175 /* C function to compare two keys. */
1176 bool (*cmpfn) (struct hash_table_test *t, Lisp_Object, Lisp_Object);
1177
1178 /* C function to compute hash code. */
1179 EMACS_UINT (*hashfn) (struct hash_table_test *t, Lisp_Object);
1180};
1181
1170struct Lisp_Hash_Table 1182struct Lisp_Hash_Table
1171{ 1183{
1172 /* This is for Lisp; the hash table code does not refer to it. */ 1184 /* This is for Lisp; the hash table code does not refer to it. */
1173 struct vectorlike_header header; 1185 struct vectorlike_header header;
1174 1186
1175 /* Function used to compare keys. */
1176 Lisp_Object test;
1177
1178 /* Nil if table is non-weak. Otherwise a symbol describing the 1187 /* Nil if table is non-weak. Otherwise a symbol describing the
1179 weakness of the table. */ 1188 weakness of the table. */
1180 Lisp_Object weak; 1189 Lisp_Object weak;
@@ -1205,12 +1214,6 @@ struct Lisp_Hash_Table
1205 hash table size to reduce collisions. */ 1214 hash table size to reduce collisions. */
1206 Lisp_Object index; 1215 Lisp_Object index;
1207 1216
1208 /* User-supplied hash function, or nil. */
1209 Lisp_Object user_hash_function;
1210
1211 /* User-supplied key comparison function, or nil. */
1212 Lisp_Object user_cmp_function;
1213
1214 /* Only the fields above are traced normally by the GC. The ones below 1217 /* Only the fields above are traced normally by the GC. The ones below
1215 `count' are special and are either ignored by the GC or traced in 1218 `count' are special and are either ignored by the GC or traced in
1216 a special way (e.g. because of weakness). */ 1219 a special way (e.g. because of weakness). */
@@ -1223,17 +1226,12 @@ struct Lisp_Hash_Table
1223 This is gc_marked specially if the table is weak. */ 1226 This is gc_marked specially if the table is weak. */
1224 Lisp_Object key_and_value; 1227 Lisp_Object key_and_value;
1225 1228
1229 /* The comparison and hash functions. */
1230 struct hash_table_test test;
1231
1226 /* Next weak hash table if this is a weak hash table. The head 1232 /* Next weak hash table if this is a weak hash table. The head
1227 of the list is in weak_hash_tables. */ 1233 of the list is in weak_hash_tables. */
1228 struct Lisp_Hash_Table *next_weak; 1234 struct Lisp_Hash_Table *next_weak;
1229
1230 /* C function to compare two keys. */
1231 bool (*cmpfn) (struct Lisp_Hash_Table *,
1232 Lisp_Object, EMACS_UINT,
1233 Lisp_Object, EMACS_UINT);
1234
1235 /* C function to compute hash code. */
1236 EMACS_UINT (*hashfn) (struct Lisp_Hash_Table *, Lisp_Object);
1237}; 1235};
1238 1236
1239 1237
@@ -1288,6 +1286,15 @@ static double const DEFAULT_REHASH_THRESHOLD = 0.8;
1288 1286
1289static double const DEFAULT_REHASH_SIZE = 1.5; 1287static double const DEFAULT_REHASH_SIZE = 1.5;
1290 1288
1289/* Combine two integers X and Y for hashing. The result might not fit
1290 into a Lisp integer. */
1291
1292LISP_INLINE EMACS_UINT
1293sxhash_combine (EMACS_UINT x, EMACS_UINT y)
1294{
1295 return (x << 4) + (x >> (BITS_PER_EMACS_INT - 4)) + y;
1296}
1297
1291/* These structures are used for various misc types. */ 1298/* These structures are used for various misc types. */
1292 1299
1293struct Lisp_Misc_Any /* Supertype of all Misc types. */ 1300struct Lisp_Misc_Any /* Supertype of all Misc types. */
@@ -1687,6 +1694,8 @@ typedef struct {
1687#define MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker) 1694#define MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker)
1688#define SAVE_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value) 1695#define SAVE_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value)
1689 1696
1697#define AUTOLOADP(x) (CONSP (x) && EQ (Qautoload, XCAR (x)))
1698
1690#define INTFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Int) 1699#define INTFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Int)
1691#define BOOLFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Bool) 1700#define BOOLFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Bool)
1692#define OBJFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Obj) 1701#define OBJFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Obj)
@@ -1700,7 +1709,7 @@ typedef struct {
1700 1709
1701#define PSEUDOVECTOR_TYPEP(v, code) \ 1710#define PSEUDOVECTOR_TYPEP(v, code) \
1702 (((v)->size & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK)) \ 1711 (((v)->size & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK)) \
1703 == (PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_SIZE_BITS))) 1712 == (PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_AREA_BITS)))
1704 1713
1705/* True if object X, with internal type struct T *, is a pseudovector whose 1714/* True if object X, with internal type struct T *, is a pseudovector whose
1706 code is CODE. */ 1715 code is CODE. */
@@ -1713,8 +1722,7 @@ typedef struct {
1713#define PROCESSP(x) PSEUDOVECTORP (x, PVEC_PROCESS) 1722#define PROCESSP(x) PSEUDOVECTORP (x, PVEC_PROCESS)
1714#define WINDOWP(x) PSEUDOVECTORP (x, PVEC_WINDOW) 1723#define WINDOWP(x) PSEUDOVECTORP (x, PVEC_WINDOW)
1715#define TERMINALP(x) PSEUDOVECTORP (x, PVEC_TERMINAL) 1724#define TERMINALP(x) PSEUDOVECTORP (x, PVEC_TERMINAL)
1716/* SUBRP is special since Lisp_Subr lacks struct vectorlike_header. */ 1725#define SUBRP(x) PSEUDOVECTORP (x, PVEC_SUBR)
1717#define SUBRP(x) TYPED_PSEUDOVECTORP (x, Lisp_Subr, PVEC_SUBR)
1718#define COMPILEDP(x) PSEUDOVECTORP (x, PVEC_COMPILED) 1726#define COMPILEDP(x) PSEUDOVECTORP (x, PVEC_COMPILED)
1719#define BUFFERP(x) PSEUDOVECTORP (x, PVEC_BUFFER) 1727#define BUFFERP(x) PSEUDOVECTORP (x, PVEC_BUFFER)
1720#define CHAR_TABLE_P(x) PSEUDOVECTORP (x, PVEC_CHAR_TABLE) 1728#define CHAR_TABLE_P(x) PSEUDOVECTORP (x, PVEC_CHAR_TABLE)
@@ -1889,8 +1897,8 @@ typedef struct {
1889#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 1897#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1890 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 1898 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1891 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \ 1899 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
1892 { (PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS) \ 1900 { { (PVEC_SUBR << PSEUDOVECTOR_AREA_BITS) \
1893 | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \ 1901 | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)) }, \
1894 { (Lisp_Object (__cdecl *)(void))fnname }, \ 1902 { (Lisp_Object (__cdecl *)(void))fnname }, \
1895 minargs, maxargs, lname, intspec, 0}; \ 1903 minargs, maxargs, lname, intspec, 0}; \
1896 Lisp_Object fnname 1904 Lisp_Object fnname
@@ -1898,8 +1906,8 @@ typedef struct {
1898#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 1906#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1899 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 1907 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1900 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \ 1908 static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
1901 { PVEC_SUBR << PSEUDOVECTOR_SIZE_BITS, \ 1909 { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \
1902 { .a ## maxargs = fnname }, \ 1910 { .a ## maxargs = fnname }, \
1903 minargs, maxargs, lname, intspec, 0}; \ 1911 minargs, maxargs, lname, intspec, 0}; \
1904 Lisp_Object fnname 1912 Lisp_Object fnname
1905#endif 1913#endif
@@ -2628,9 +2636,6 @@ extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
2628 2636
2629EXFUN (Fbyteorder, 0) ATTRIBUTE_CONST; 2637EXFUN (Fbyteorder, 0) ATTRIBUTE_CONST;
2630 2638
2631/* Defined in frame.c. */
2632extern Lisp_Object Qframep;
2633
2634/* Defined in data.c. */ 2639/* Defined in data.c. */
2635extern Lisp_Object indirect_function (Lisp_Object); 2640extern Lisp_Object indirect_function (Lisp_Object);
2636extern Lisp_Object find_symbol_value (Lisp_Object); 2641extern Lisp_Object find_symbol_value (Lisp_Object);
@@ -2716,15 +2721,15 @@ extern Lisp_Object larger_vector (Lisp_Object, ptrdiff_t, ptrdiff_t);
2716extern void sweep_weak_hash_tables (void); 2721extern void sweep_weak_hash_tables (void);
2717extern Lisp_Object Qcursor_in_echo_area; 2722extern Lisp_Object Qcursor_in_echo_area;
2718extern Lisp_Object Qstring_lessp; 2723extern Lisp_Object Qstring_lessp;
2719extern Lisp_Object QCsize, QCtest, QCweakness, Qequal, Qeq, Qeql; 2724extern Lisp_Object QCsize, QCtest, QCweakness, Qequal, Qeq;
2720EMACS_UINT hash_string (char const *, ptrdiff_t); 2725EMACS_UINT hash_string (char const *, ptrdiff_t);
2721EMACS_UINT sxhash (Lisp_Object, int); 2726EMACS_UINT sxhash (Lisp_Object, int);
2722Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object, 2727Lisp_Object make_hash_table (struct hash_table_test, Lisp_Object, Lisp_Object,
2723 Lisp_Object, Lisp_Object, Lisp_Object, 2728 Lisp_Object, Lisp_Object);
2724 Lisp_Object);
2725ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *); 2729ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *);
2726ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, 2730ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object,
2727 EMACS_UINT); 2731 EMACS_UINT);
2732extern struct hash_table_test hashtest_eql, hashtest_equal;
2728 2733
2729extern Lisp_Object substring_both (Lisp_Object, ptrdiff_t, ptrdiff_t, 2734extern Lisp_Object substring_both (Lisp_Object, ptrdiff_t, ptrdiff_t,
2730 ptrdiff_t, ptrdiff_t); 2735 ptrdiff_t, ptrdiff_t);
@@ -2946,7 +2951,7 @@ extern void make_byte_code (struct Lisp_Vector *);
2946extern Lisp_Object Qautomatic_gc; 2951extern Lisp_Object Qautomatic_gc;
2947extern Lisp_Object Qchar_table_extra_slots; 2952extern Lisp_Object Qchar_table_extra_slots;
2948extern struct Lisp_Vector *allocate_vector (EMACS_INT); 2953extern struct Lisp_Vector *allocate_vector (EMACS_INT);
2949extern struct Lisp_Vector *allocate_pseudovector (int memlen, int lisplen, int tag); 2954extern struct Lisp_Vector *allocate_pseudovector (int, int, enum pvec_type);
2950#define ALLOCATE_PSEUDOVECTOR(typ,field,tag) \ 2955#define ALLOCATE_PSEUDOVECTOR(typ,field,tag) \
2951 ((typ*) \ 2956 ((typ*) \
2952 allocate_pseudovector \ 2957 allocate_pseudovector \
@@ -3298,7 +3303,6 @@ extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object);
3298#if HAVE_NS 3303#if HAVE_NS
3299extern Lisp_Object get_frame_param (struct frame *, Lisp_Object); 3304extern Lisp_Object get_frame_param (struct frame *, Lisp_Object);
3300#endif 3305#endif
3301extern Lisp_Object frame_buffer_predicate (Lisp_Object);
3302extern void frames_discard_buffer (Lisp_Object); 3306extern void frames_discard_buffer (Lisp_Object);
3303extern void syms_of_frame (void); 3307extern void syms_of_frame (void);
3304 3308
diff --git a/src/lread.c b/src/lread.c
index 94744620279..3a82e0057e2 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3981,7 +3981,7 @@ defsubr (struct Lisp_Subr *sname)
3981{ 3981{
3982 Lisp_Object sym, tem; 3982 Lisp_Object sym, tem;
3983 sym = intern_c_string (sname->symbol_name); 3983 sym = intern_c_string (sname->symbol_name);
3984 XSETTYPED_PVECTYPE (sname, size, PVEC_SUBR); 3984 XSETPVECTYPE (sname, PVEC_SUBR);
3985 XSETSUBR (tem, sname); 3985 XSETSUBR (tem, sname);
3986 set_symbol_function (sym, tem); 3986 set_symbol_function (sym, tem);
3987} 3987}
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 9df5dedb7ea..f5cab34d7dc 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -1475,8 +1475,8 @@ $(BLD)/unexw32.$(O) : \
1475 $(SRC)/w32.h \ 1475 $(SRC)/w32.h \
1476 $(SRC)/w32common.h \ 1476 $(SRC)/w32common.h \
1477 $(SRC)/w32heap.h \ 1477 $(SRC)/w32heap.h \
1478 $(LISP_H) \ 1478 $(CONFIG_H) \
1479 $(CONFIG_H) 1479 $(LISP_H)
1480 1480
1481$(BLD)/vm-limit.$(O) : \ 1481$(BLD)/vm-limit.$(O) : \
1482 $(SRC)/vm-limit.c \ 1482 $(SRC)/vm-limit.c \
diff --git a/src/nsfont.m b/src/nsfont.m
index 4f29d1d54a9..2ba38b7570e 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -46,8 +46,9 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu)
46#define NSFONT_TRACE 0 46#define NSFONT_TRACE 0
47 47
48extern Lisp_Object Qns; 48extern Lisp_Object Qns;
49extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded; 49extern Lisp_Object Qnormal, Qbold, Qitalic;
50static Lisp_Object Qapple, Qroman, Qmedium; 50static Lisp_Object Qapple, Qroman, Qmedium;
51static Lisp_Object Qcondensed, Qexpanded;
51extern Lisp_Object Qappend; 52extern Lisp_Object Qappend;
52extern float ns_antialias_threshold; 53extern float ns_antialias_threshold;
53extern int ns_tmp_flags; 54extern int ns_tmp_flags;
@@ -201,8 +202,8 @@ ns_descriptor_to_entity (NSFontDescriptor *desc,
201 make_number (100 + 100 202 make_number (100 + 100
202 * ns_attribute_fvalue (desc, NSFontSlantTrait)));*/ 203 * ns_attribute_fvalue (desc, NSFontSlantTrait)));*/
203 FONT_SET_STYLE (font_entity, FONT_WIDTH_INDEX, 204 FONT_SET_STYLE (font_entity, FONT_WIDTH_INDEX,
204 traits & NSFontCondensedTrait ? Qcondensed : 205 traits & NSFontCondensedTrait ? Qcondensed :
205 traits & NSFontExpandedTrait ? Qexpanded : Qnormal); 206 traits & NSFontExpandedTrait ? Qexpanded : Qnormal);
206/* FONT_SET_STYLE (font_entity, FONT_WIDTH_INDEX, 207/* FONT_SET_STYLE (font_entity, FONT_WIDTH_INDEX,
207 make_number (100 + 100 208 make_number (100 + 100
208 * ns_attribute_fvalue (desc, NSFontWidthTrait)));*/ 209 * ns_attribute_fvalue (desc, NSFontWidthTrait)));*/
@@ -559,7 +560,11 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch)
559 if (isMatch) 560 if (isMatch)
560 [fkeys removeObject: NSFontFamilyAttribute]; 561 [fkeys removeObject: NSFontFamilyAttribute];
561 562
562 matchingDescs = [fdesc matchingFontDescriptorsWithMandatoryKeys: fkeys]; 563 if ([fkeys count] > 0)
564 matchingDescs = [fdesc matchingFontDescriptorsWithMandatoryKeys: fkeys];
565 else
566 matchingDescs = [NSMutableArray array];
567
563 if (NSFONT_TRACE) 568 if (NSFONT_TRACE)
564 NSLog(@"Got desc %@ and found %d matching fonts from it: ", fdesc, 569 NSLog(@"Got desc %@ and found %d matching fonts from it: ", fdesc,
565 [matchingDescs count]); 570 [matchingDescs count]);
@@ -1507,6 +1512,8 @@ syms_of_nsfont (void)
1507{ 1512{
1508 nsfont_driver.type = Qns; 1513 nsfont_driver.type = Qns;
1509 register_font_driver (&nsfont_driver, NULL); 1514 register_font_driver (&nsfont_driver, NULL);
1515 DEFSYM (Qcondensed, "condensed");
1516 DEFSYM (Qexpanded, "expanded");
1510 DEFSYM (Qapple, "apple"); 1517 DEFSYM (Qapple, "apple");
1511 DEFSYM (Qroman, "roman"); 1518 DEFSYM (Qroman, "roman");
1512 DEFSYM (Qmedium, "medium"); 1519 DEFSYM (Qmedium, "medium");
diff --git a/src/nsterm.m b/src/nsterm.m
index e4621247854..7ba1608268b 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -145,22 +145,22 @@ static unsigned convert_ns_to_X_keysym[] =
145 NSNewlineCharacter, 0x0D, 145 NSNewlineCharacter, 0x0D,
146 NSEnterCharacter, 0x8D, 146 NSEnterCharacter, 0x8D,
147 147
148 0x41, 0xAE, /* KP_Decimal */ 148 0x41|NSNumericPadKeyMask, 0xAE, /* KP_Decimal */
149 0x43, 0xAA, /* KP_Multiply */ 149 0x43|NSNumericPadKeyMask, 0xAA, /* KP_Multiply */
150 0x45, 0xAB, /* KP_Add */ 150 0x45|NSNumericPadKeyMask, 0xAB, /* KP_Add */
151 0x4B, 0xAF, /* KP_Divide */ 151 0x4B|NSNumericPadKeyMask, 0xAF, /* KP_Divide */
152 0x4E, 0xAD, /* KP_Subtract */ 152 0x4E|NSNumericPadKeyMask, 0xAD, /* KP_Subtract */
153 0x51, 0xBD, /* KP_Equal */ 153 0x51|NSNumericPadKeyMask, 0xBD, /* KP_Equal */
154 0x52, 0xB0, /* KP_0 */ 154 0x52|NSNumericPadKeyMask, 0xB0, /* KP_0 */
155 0x53, 0xB1, /* KP_1 */ 155 0x53|NSNumericPadKeyMask, 0xB1, /* KP_1 */
156 0x54, 0xB2, /* KP_2 */ 156 0x54|NSNumericPadKeyMask, 0xB2, /* KP_2 */
157 0x55, 0xB3, /* KP_3 */ 157 0x55|NSNumericPadKeyMask, 0xB3, /* KP_3 */
158 0x56, 0xB4, /* KP_4 */ 158 0x56|NSNumericPadKeyMask, 0xB4, /* KP_4 */
159 0x57, 0xB5, /* KP_5 */ 159 0x57|NSNumericPadKeyMask, 0xB5, /* KP_5 */
160 0x58, 0xB6, /* KP_6 */ 160 0x58|NSNumericPadKeyMask, 0xB6, /* KP_6 */
161 0x59, 0xB7, /* KP_7 */ 161 0x59|NSNumericPadKeyMask, 0xB7, /* KP_7 */
162 0x5B, 0xB8, /* KP_8 */ 162 0x5B|NSNumericPadKeyMask, 0xB8, /* KP_8 */
163 0x5C, 0xB9, /* KP_9 */ 163 0x5C|NSNumericPadKeyMask, 0xB9, /* KP_9 */
164 164
165 0x1B, 0x1B /* escape */ 165 0x1B, 0x1B /* escape */
166}; 166};
@@ -4829,7 +4829,7 @@ not_in_argv (NSString *arg)
4829 4829
4830 /* is it a "function key"? */ 4830 /* is it a "function key"? */
4831 fnKeysym = (code < 0x00ff && (flags&NSNumericPadKeyMask)) 4831 fnKeysym = (code < 0x00ff && (flags&NSNumericPadKeyMask))
4832 ? ns_convert_key ([theEvent keyCode]) 4832 ? ns_convert_key ([theEvent keyCode] | NSNumericPadKeyMask)
4833 : ns_convert_key (code); 4833 : ns_convert_key (code);
4834 4834
4835 if (fnKeysym) 4835 if (fnKeysym)
diff --git a/src/print.c b/src/print.c
index ccf0e8ed7cc..bf86be5622e 100644
--- a/src/print.c
+++ b/src/print.c
@@ -798,7 +798,7 @@ safe_debug_print (Lisp_Object arg)
798 else 798 else
799 fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n", 799 fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
800 !valid ? "INVALID" : "SOME", 800 !valid ? "INVALID" : "SOME",
801 XHASH (arg)); 801 XLI (arg));
802} 802}
803 803
804 804
@@ -1815,14 +1815,14 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1815#endif 1815#endif
1816 /* Implement a readable output, e.g.: 1816 /* Implement a readable output, e.g.:
1817 #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ 1817 #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
1818 /* Always print the size. */ 1818 /* Always print the size. */
1819 len = sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next)); 1819 len = sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next));
1820 strout (buf, len, len, printcharfun); 1820 strout (buf, len, len, printcharfun);
1821 1821
1822 if (!NILP (h->test)) 1822 if (!NILP (h->test.name))
1823 { 1823 {
1824 strout (" test ", -1, -1, printcharfun); 1824 strout (" test ", -1, -1, printcharfun);
1825 print_object (h->test, printcharfun, escapeflag); 1825 print_object (h->test.name, printcharfun, escapeflag);
1826 } 1826 }
1827 1827
1828 if (!NILP (h->weak)) 1828 if (!NILP (h->weak))
diff --git a/src/profiler.c b/src/profiler.c
index 51580710f28..3d8f7243d2f 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -35,6 +35,9 @@ saturated_add (EMACS_INT a, EMACS_INT b)
35 35
36typedef struct Lisp_Hash_Table log_t; 36typedef struct Lisp_Hash_Table log_t;
37 37
38static Lisp_Object Qprofiler_backtrace_equal;
39static struct hash_table_test hashtest_profiler;
40
38static Lisp_Object 41static Lisp_Object
39make_log (int heap_size, int max_stack_depth) 42make_log (int heap_size, int max_stack_depth)
40{ 43{
@@ -42,10 +45,11 @@ make_log (int heap_size, int max_stack_depth)
42 a special way. This is OK as long as the object is not exposed 45 a special way. This is OK as long as the object is not exposed
43 to Elisp, i.e. until it is returned by *-profiler-log, after which 46 to Elisp, i.e. until it is returned by *-profiler-log, after which
44 it can't be used any more. */ 47 it can't be used any more. */
45 Lisp_Object log = make_hash_table (Qequal, make_number (heap_size), 48 Lisp_Object log = make_hash_table (hashtest_profiler,
49 make_number (heap_size),
46 make_float (DEFAULT_REHASH_SIZE), 50 make_float (DEFAULT_REHASH_SIZE),
47 make_float (DEFAULT_REHASH_THRESHOLD), 51 make_float (DEFAULT_REHASH_THRESHOLD),
48 Qnil, Qnil, Qnil); 52 Qnil);
49 struct Lisp_Hash_Table *h = XHASH_TABLE (log); 53 struct Lisp_Hash_Table *h = XHASH_TABLE (log);
50 54
51 /* What is special about our hash-tables is that the keys are pre-filled 55 /* What is special about our hash-tables is that the keys are pre-filled
@@ -238,8 +242,6 @@ handle_profiler_signal (int signal)
238 cpu_gc_count = saturated_add (cpu_gc_count, 1); 242 cpu_gc_count = saturated_add (cpu_gc_count, 1);
239 else 243 else
240 { 244 {
241 Lisp_Object oquit;
242 bool saved_pending_signals;
243 EMACS_INT count = 1; 245 EMACS_INT count = 1;
244#ifdef HAVE_ITIMERSPEC 246#ifdef HAVE_ITIMERSPEC
245 if (profiler_timer_ok) 247 if (profiler_timer_ok)
@@ -249,19 +251,8 @@ handle_profiler_signal (int signal)
249 count += overruns; 251 count += overruns;
250 } 252 }
251#endif 253#endif
252 /* record_backtrace uses hash functions that call Fequal, which
253 uses QUIT, which can call malloc, which can cause disaster in
254 a signal handler. So inhibit QUIT. */
255 oquit = Vinhibit_quit;
256 saved_pending_signals = pending_signals;
257 Vinhibit_quit = Qt;
258 pending_signals = 0;
259
260 eassert (HASH_TABLE_P (cpu_log)); 254 eassert (HASH_TABLE_P (cpu_log));
261 record_backtrace (XHASH_TABLE (cpu_log), count); 255 record_backtrace (XHASH_TABLE (cpu_log), count);
262
263 Vinhibit_quit = oquit;
264 pending_signals = saved_pending_signals;
265 } 256 }
266} 257}
267 258
@@ -515,6 +506,66 @@ malloc_probe (size_t size)
515 record_backtrace (XHASH_TABLE (memory_log), min (size, MOST_POSITIVE_FIXNUM)); 506 record_backtrace (XHASH_TABLE (memory_log), min (size, MOST_POSITIVE_FIXNUM));
516} 507}
517 508
509DEFUN ("function-equal", Ffunction_equal, Sfunction_equal, 2, 2, 0,
510 doc: /* Return non-nil if F1 and F2 come from the same source.
511Used to determine if different closures are just different instances of
512the same lambda expression, or are really unrelated function. */)
513 (Lisp_Object f1, Lisp_Object f2)
514{
515 bool res;
516 if (EQ (f1, f2))
517 res = true;
518 else if (COMPILEDP (f1) && COMPILEDP (f2))
519 res = EQ (AREF (f1, COMPILED_BYTECODE), AREF (f2, COMPILED_BYTECODE));
520 else if (CONSP (f1) && CONSP (f2) && CONSP (XCDR (f1)) && CONSP (XCDR (f2))
521 && EQ (Qclosure, XCAR (f1))
522 && EQ (Qclosure, XCAR (f2)))
523 res = EQ (XCDR (XCDR (f1)), XCDR (XCDR (f2)));
524 else
525 res = false;
526 return res ? Qt : Qnil;
527}
528
529static bool
530cmpfn_profiler (struct hash_table_test *t,
531 Lisp_Object bt1, Lisp_Object bt2)
532{
533 if (VECTORP (bt1) && VECTORP (bt2))
534 {
535 ptrdiff_t i, l = ASIZE (bt1);
536 if (l != ASIZE (bt2))
537 return false;
538 for (i = 0; i < l; i++)
539 if (NILP (Ffunction_equal (AREF (bt1, i), AREF (bt2, i))))
540 return false;
541 return true;
542 }
543 else
544 return EQ (bt1, bt2);
545}
546
547static EMACS_UINT
548hashfn_profiler (struct hash_table_test *ht, Lisp_Object bt)
549{
550 if (VECTORP (bt))
551 {
552 EMACS_UINT hash = 0;
553 ptrdiff_t i, l = ASIZE (bt);
554 for (i = 0; i < l; i++)
555 {
556 Lisp_Object f = AREF (bt, i);
557 EMACS_UINT hash1
558 = (COMPILEDP (f) ? XHASH (AREF (f, COMPILED_BYTECODE))
559 : (CONSP (f) && CONSP (XCDR (f)) && EQ (Qclosure, XCAR (f)))
560 ? XHASH (XCDR (XCDR (f))) : XHASH (f));
561 hash = sxhash_combine (hash, hash1);
562 }
563 return (hash & INTMASK);
564 }
565 else
566 return XHASH (bt);
567}
568
518void 569void
519syms_of_profiler (void) 570syms_of_profiler (void)
520{ 571{
@@ -527,6 +578,16 @@ If the log gets full, some of the least-seen call-stacks will be evicted
527to make room for new entries. */); 578to make room for new entries. */);
528 profiler_log_size = 10000; 579 profiler_log_size = 10000;
529 580
581 DEFSYM (Qprofiler_backtrace_equal, "profiler-backtrace-equal");
582 {
583 struct hash_table_test test
584 = { Qprofiler_backtrace_equal, Qnil, Qnil,
585 cmpfn_profiler, hashfn_profiler };
586 hashtest_profiler = test;
587 }
588
589 defsubr (&Sfunction_equal);
590
530#ifdef PROFILER_CPU_SUPPORT 591#ifdef PROFILER_CPU_SUPPORT
531 profiler_cpu_running = NOT_RUNNING; 592 profiler_cpu_running = NOT_RUNNING;
532 cpu_log = Qnil; 593 cpu_log = Qnil;
diff --git a/src/ralloc.c b/src/ralloc.c
index 11897411930..e5bf76b0e6d 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -327,6 +327,8 @@ relinquish (void)
327 327
328 if ((char *)last_heap->end - (char *)last_heap->bloc_start <= excess) 328 if ((char *)last_heap->end - (char *)last_heap->bloc_start <= excess)
329 { 329 {
330 heap_ptr lh_prev;
331
330 /* This heap should have no blocs in it. If it does, we 332 /* This heap should have no blocs in it. If it does, we
331 cannot return it to the system. */ 333 cannot return it to the system. */
332 if (last_heap->first_bloc != NIL_BLOC 334 if (last_heap->first_bloc != NIL_BLOC
@@ -335,28 +337,26 @@ relinquish (void)
335 337
336 /* Return the last heap, with its header, to the system. */ 338 /* Return the last heap, with its header, to the system. */
337 excess = (char *)last_heap->end - (char *)last_heap->start; 339 excess = (char *)last_heap->end - (char *)last_heap->start;
338 last_heap = last_heap->prev; 340 lh_prev = last_heap->prev;
339 last_heap->next = NIL_HEAP; 341 /* If the system doesn't want that much memory back, leave
342 last_heap unaltered to reflect that. This can occur if
343 break_value is still within the original data segment. */
344 if ((*real_morecore) (- excess) != 0)
345 {
346 last_heap = lh_prev;
347 last_heap->next = NIL_HEAP;
348 }
340 } 349 }
341 else 350 else
342 { 351 {
343 excess = (char *) last_heap->end 352 excess = (char *) last_heap->end
344 - (char *) ROUNDUP ((char *)last_heap->end - excess); 353 - (char *) ROUNDUP ((char *)last_heap->end - excess);
345 last_heap->end = (char *) last_heap->end - excess; 354 /* If the system doesn't want that much memory back, leave
346 } 355 the end of the last heap unchanged to reflect that. This
347 356 can occur if break_value is still within the original
348 if ((*real_morecore) (- excess) == 0) 357 data segment. */
349 { 358 if ((*real_morecore) (- excess) != 0)
350 /* If the system didn't want that much memory back, adjust 359 last_heap->end = (char *) last_heap->end - excess;
351 the end of the last heap to reflect that. This can occur
352 if break_value is still within the original data segment. */
353 last_heap->end = (char *) last_heap->end + excess;
354 /* Make sure that the result of the adjustment is accurate.
355 It should be, for the else clause above; the other case,
356 which returns the entire last heap to the system, seems
357 unlikely to trigger this mode of failure. */
358 if (last_heap->end != (*real_morecore) (0))
359 emacs_abort ();
360 } 360 }
361 } 361 }
362} 362}
diff --git a/src/regex.c b/src/regex.c
index 7443eff3977..1473551e6cc 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -28,7 +28,7 @@
28 rather than at run-time, so that re_match can be reentrant. 28 rather than at run-time, so that re_match can be reentrant.
29*/ 29*/
30 30
31/* AIX requires this to be the first thing in the file. */ 31/* AIX requires this to be the first thing in the file. */
32#if defined _AIX && !defined REGEX_MALLOC 32#if defined _AIX && !defined REGEX_MALLOC
33 #pragma alloca 33 #pragma alloca
34#endif 34#endif
diff --git a/src/termhooks.h b/src/termhooks.h
index 2d97fcdbc1e..b35c927fc53 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -414,14 +414,6 @@ struct terminal
414 int memory_below_frame; /* Terminal remembers lines scrolled 414 int memory_below_frame; /* Terminal remembers lines scrolled
415 off bottom */ 415 off bottom */
416 416
417#if 0 /* These are not used anywhere. */
418 /* EMACS_INT baud_rate; */ /* Output speed in baud */
419 int min_padding_speed; /* Speed below which no padding necessary. */
420 int dont_calculate_costs; /* Nonzero means don't bother computing
421 various cost tables; we won't use them. */
422#endif
423
424
425 /* Window-based redisplay interface for this device (0 for tty 417 /* Window-based redisplay interface for this device (0 for tty
426 devices). */ 418 devices). */
427 struct redisplay_interface *rif; 419 struct redisplay_interface *rif;
@@ -469,10 +461,7 @@ struct terminal
469 Otherwise, set *bar_window to Qnil, and *x and *y to the column and 461 Otherwise, set *bar_window to Qnil, and *x and *y to the column and
470 row of the character cell the mouse is over. 462 row of the character cell the mouse is over.
471 463
472 Set *time to the time the mouse was at the returned position. 464 Set *time to the time the mouse was at the returned position. */
473
474 This should clear mouse_moved until the next motion
475 event arrives. */
476 void (*mouse_position_hook) (struct frame **f, int, 465 void (*mouse_position_hook) (struct frame **f, int,
477 Lisp_Object *bar_window, 466 Lisp_Object *bar_window,
478 enum scroll_bar_part *part, 467 enum scroll_bar_part *part,
@@ -480,11 +469,6 @@ struct terminal
480 Lisp_Object *y, 469 Lisp_Object *y,
481 Time *); 470 Time *);
482 471
483 /* The window system handling code should set this if the mouse has
484 moved since the last call to the mouse_position_hook. Calling that
485 hook should clear this. */
486 int mouse_moved;
487
488 /* When a frame's focus redirection is changed, this hook tells the 472 /* When a frame's focus redirection is changed, this hook tells the
489 window system code to re-decide where to put the highlight. Under 473 window system code to re-decide where to put the highlight. Under
490 X, this means that Emacs lies about where the focus is. */ 474 X, this means that Emacs lies about where the focus is. */
diff --git a/src/terminal.c b/src/terminal.c
index 2c0c60e7345..854ca61f19c 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -360,14 +360,7 @@ If FRAME is nil, the selected frame is used.
360The terminal device is represented by its integer identifier. */) 360The terminal device is represented by its integer identifier. */)
361 (Lisp_Object frame) 361 (Lisp_Object frame)
362{ 362{
363 struct terminal *t; 363 struct terminal *t = FRAME_TERMINAL (decode_live_frame (frame));
364
365 if (NILP (frame))
366 frame = selected_frame;
367
368 CHECK_LIVE_FRAME (frame);
369
370 t = FRAME_TERMINAL (XFRAME (frame));
371 364
372 if (!t) 365 if (!t)
373 return Qnil; 366 return Qnil;
diff --git a/src/w32fns.c b/src/w32fns.c
index 18e29ecaaf5..ed5625e802c 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -264,12 +264,8 @@ have_menus_p (void)
264FRAME_PTR 264FRAME_PTR
265check_x_frame (Lisp_Object frame) 265check_x_frame (Lisp_Object frame)
266{ 266{
267 FRAME_PTR f; 267 struct frame *f = decode_live_frame (frame);
268 268
269 if (NILP (frame))
270 frame = selected_frame;
271 CHECK_LIVE_FRAME (frame);
272 f = XFRAME (frame);
273 if (! FRAME_W32_P (f)) 269 if (! FRAME_W32_P (f))
274 error ("Non-W32 frame used"); 270 error ("Non-W32 frame used");
275 return f; 271 return f;
@@ -308,19 +304,14 @@ check_x_display_info (Lisp_Object frame)
308/* Return the Emacs frame-object corresponding to an w32 window. 304/* Return the Emacs frame-object corresponding to an w32 window.
309 It could be the frame's main window or an icon window. */ 305 It could be the frame's main window or an icon window. */
310 306
311/* This function can be called during GC, so use GC_xxx type test macros. */
312
313struct frame * 307struct frame *
314x_window_to_frame (struct w32_display_info *dpyinfo, HWND wdesc) 308x_window_to_frame (struct w32_display_info *dpyinfo, HWND wdesc)
315{ 309{
316 Lisp_Object tail, frame; 310 Lisp_Object tail, frame;
317 struct frame *f; 311 struct frame *f;
318 312
319 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 313 FOR_EACH_FRAME (tail, frame)
320 { 314 {
321 frame = XCAR (tail);
322 if (!FRAMEP (frame))
323 continue;
324 f = XFRAME (frame); 315 f = XFRAME (frame);
325 if (!FRAME_W32_P (f) || FRAME_W32_DISPLAY_INFO (f) != dpyinfo) 316 if (!FRAME_W32_P (f) || FRAME_W32_DISPLAY_INFO (f) != dpyinfo)
326 continue; 317 continue;
@@ -2089,8 +2080,35 @@ sync_modifiers (void)
2089static int 2080static int
2090modifier_set (int vkey) 2081modifier_set (int vkey)
2091{ 2082{
2092 if (vkey == VK_CAPITAL || vkey == VK_SCROLL) 2083 /* Warning: The fact that VK_NUMLOCK is not treated as the other 2
2093 return (GetKeyState (vkey) & 0x1); 2084 toggle keys is not an omission! If you want to add it, you will
2085 have to make changes in the default sub-case of the WM_KEYDOWN
2086 switch, because if the NUMLOCK modifier is set, the code there
2087 will directly convert any key that looks like an ASCII letter,
2088 and also downcase those that look like upper-case ASCII. */
2089 if (vkey == VK_CAPITAL)
2090 {
2091 if (NILP (Vw32_enable_caps_lock))
2092 return 0;
2093 else
2094 return (GetKeyState (vkey) & 0x1);
2095 }
2096 if (vkey == VK_SCROLL)
2097 {
2098 if (NILP (Vw32_scroll_lock_modifier)
2099 /* w32-scroll-lock-modifier can be any non-nil value that is
2100 not one of the modifiers, in which case it shall be ignored. */
2101 || !( EQ (Vw32_scroll_lock_modifier, Qhyper)
2102 || EQ (Vw32_scroll_lock_modifier, Qsuper)
2103 || EQ (Vw32_scroll_lock_modifier, Qmeta)
2104 || EQ (Vw32_scroll_lock_modifier, Qalt)
2105 || EQ (Vw32_scroll_lock_modifier, Qcontrol)
2106 || EQ (Vw32_scroll_lock_modifier, Qshift)))
2107 return 0;
2108 else
2109 return (GetKeyState (vkey) & 0x1);
2110 }
2111
2094 if (!modifiers_recorded) 2112 if (!modifiers_recorded)
2095 return (GetKeyState (vkey) & 0x8000); 2113 return (GetKeyState (vkey) & 0x8000);
2096 2114
diff --git a/src/w32term.c b/src/w32term.c
index 4cc0b860947..032912c27f4 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3437,16 +3437,11 @@ w32_handle_tool_bar_click (struct frame *f, struct input_event *button_event)
3437static struct scroll_bar * 3437static struct scroll_bar *
3438x_window_to_scroll_bar (Window window_id) 3438x_window_to_scroll_bar (Window window_id)
3439{ 3439{
3440 Lisp_Object tail; 3440 Lisp_Object tail, frame;
3441 3441
3442 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 3442 FOR_EACH_FRAME (tail, frame)
3443 { 3443 {
3444 Lisp_Object frame, bar, condemned; 3444 Lisp_Object bar, condemned;
3445
3446 frame = XCAR (tail);
3447 /* All elements of Vframe_list should be frames. */
3448 if (! FRAMEP (frame))
3449 emacs_abort ();
3450 3445
3451 /* Scan this frame's scroll bar list for a scroll bar with the 3446 /* Scan this frame's scroll bar list for a scroll bar with the
3452 right window ID. */ 3447 right window ID. */
@@ -3626,7 +3621,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
3626 HWND hwnd; 3621 HWND hwnd;
3627 SCROLLINFO si; 3622 SCROLLINFO si;
3628 struct scroll_bar *bar 3623 struct scroll_bar *bar
3629 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); 3624 = XSCROLL_BAR (Fmake_vector (make_number (VECSIZE (struct scroll_bar)), Qnil));
3630 Lisp_Object barobj; 3625 Lisp_Object barobj;
3631 3626
3632 block_input (); 3627 block_input ();
diff --git a/src/w32term.h b/src/w32term.h
index af5b37a1171..72fb8a76e35 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -415,9 +415,8 @@ extern struct w32_output w32term_display;
415 415
416struct scroll_bar { 416struct scroll_bar {
417 417
418 /* These fields are shared by all vectors. */ 418 /* This field is shared by all vectors. */
419 EMACS_INT size_from_Lisp_Vector_struct; 419 struct vectorlike_header header;
420 struct Lisp_Vector *next_from_Lisp_Vector_struct;
421 420
422 /* The window we're a scroll bar for. */ 421 /* The window we're a scroll bar for. */
423 Lisp_Object window; 422 Lisp_Object window;
@@ -460,12 +459,6 @@ struct scroll_bar {
460 Lisp_Object fringe_extended_p; 459 Lisp_Object fringe_extended_p;
461}; 460};
462 461
463/* The number of elements a vector holding a struct scroll_bar needs. */
464#define SCROLL_BAR_VEC_SIZE \
465 ((sizeof (struct scroll_bar) \
466 - sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \
467 / word_size)
468
469/* Turning a lisp vector value into a pointer to a struct scroll_bar. */ 462/* Turning a lisp vector value into a pointer to a struct scroll_bar. */
470#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec)) 463#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
471 464
diff --git a/src/window.c b/src/window.c
index 75a8d42d8d1..9f3474fcd53 100644
--- a/src/window.c
+++ b/src/window.c
@@ -273,7 +273,7 @@ decode_valid_window (register Lisp_Object window)
273/* Build a frequently used 4-integer (X Y W H) list. */ 273/* Build a frequently used 4-integer (X Y W H) list. */
274 274
275static Lisp_Object 275static Lisp_Object
276quad (ptrdiff_t x, ptrdiff_t y, ptrdiff_t w, ptrdiff_t h) 276list4i (EMACS_INT x, EMACS_INT y, EMACS_INT w, EMACS_INT h)
277{ 277{
278 return list4 (make_number (x), make_number (y), 278 return list4 (make_number (x), make_number (y),
279 make_number (w), make_number (h)); 279 make_number (w), make_number (h));
@@ -340,10 +340,7 @@ DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0,
340If FRAME is omitted or nil, it defaults to the selected frame. */) 340If FRAME is omitted or nil, it defaults to the selected frame. */)
341 (Lisp_Object frame) 341 (Lisp_Object frame)
342{ 342{
343 if (NILP (frame)) 343 return FRAME_MINIBUF_WINDOW (decode_live_frame (frame));
344 frame = selected_frame;
345 CHECK_LIVE_FRAME (frame);
346 return FRAME_MINIBUF_WINDOW (XFRAME (frame));
347} 344}
348 345
349DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 346DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
@@ -605,24 +602,29 @@ Return nil if WINDOW has no previous sibling. */)
605 return decode_valid_window (window)->prev; 602 return decode_valid_window (window)->prev;
606} 603}
607 604
608DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 0, 1, 0, 605DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0,
609 doc: /* Return combination limit of window WINDOW. 606 doc: /* Return combination limit of window WINDOW.
610WINDOW must be a valid window and defaults to the selected one.
611If the return value is nil, child windows of WINDOW can be recombined with 607If the return value is nil, child windows of WINDOW can be recombined with
612WINDOW's siblings. A return value of t means that child windows of 608WINDOW's siblings. A return value of t means that child windows of
613WINDOW are never \(re-)combined with WINDOW's siblings. */) 609WINDOW are never \(re-)combined with WINDOW's siblings.
610
611WINDOW must be a valid window. The return value is meaningful for
612internal windows only. */)
614 (Lisp_Object window) 613 (Lisp_Object window)
615{ 614{
616 return decode_valid_window (window)->combination_limit; 615 CHECK_VALID_WINDOW (window);
616 return XWINDOW (window)->combination_limit;
617} 617}
618 618
619DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, 619DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0,
620 doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT. 620 doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT.
621WINDOW must be a valid window and defaults to the selected one.
622If LIMIT is nil, child windows of WINDOW can be recombined with WINDOW's 621If LIMIT is nil, child windows of WINDOW can be recombined with WINDOW's
623siblings. LIMIT t means that child windows of WINDOW are never 622siblings. LIMIT t means that child windows of WINDOW are never
624\(re-)combined with WINDOW's siblings. Other values are reserved for 623\(re-)combined with WINDOW's siblings. Other values are reserved for
625future use. */) 624future use.
625
626WINDOW must be a valid window. Setting the combination limit is
627meaningful for internal windows only. */)
626 (Lisp_Object window, Lisp_Object limit) 628 (Lisp_Object window, Lisp_Object limit)
627{ 629{
628 wset_combination_limit (decode_valid_window (window), limit); 630 wset_combination_limit (decode_valid_window (window), limit);
@@ -882,8 +884,8 @@ header line, and/or mode line. For the edges of just the text area, use
882{ 884{
883 register struct window *w = decode_valid_window (window); 885 register struct window *w = decode_valid_window (window);
884 886
885 return quad (WINDOW_LEFT_EDGE_COL (w), WINDOW_TOP_EDGE_LINE (w), 887 return list4i (WINDOW_LEFT_EDGE_COL (w), WINDOW_TOP_EDGE_LINE (w),
886 WINDOW_RIGHT_EDGE_COL (w), WINDOW_BOTTOM_EDGE_LINE (w)); 888 WINDOW_RIGHT_EDGE_COL (w), WINDOW_BOTTOM_EDGE_LINE (w));
887} 889}
888 890
889DEFUN ("window-pixel-edges", Fwindow_pixel_edges, Swindow_pixel_edges, 0, 1, 0, 891DEFUN ("window-pixel-edges", Fwindow_pixel_edges, Swindow_pixel_edges, 0, 1, 0,
@@ -902,8 +904,8 @@ of just the text area, use `window-inside-pixel-edges'. */)
902{ 904{
903 register struct window *w = decode_valid_window (window); 905 register struct window *w = decode_valid_window (window);
904 906
905 return quad (WINDOW_LEFT_EDGE_X (w), WINDOW_TOP_EDGE_Y (w), 907 return list4i (WINDOW_LEFT_EDGE_X (w), WINDOW_TOP_EDGE_Y (w),
906 WINDOW_RIGHT_EDGE_X (w), WINDOW_BOTTOM_EDGE_Y (w)); 908 WINDOW_RIGHT_EDGE_X (w), WINDOW_BOTTOM_EDGE_Y (w));
907} 909}
908 910
909static void 911static void
@@ -948,10 +950,10 @@ of just the text area, use `window-inside-absolute-pixel-edges'. */)
948 950
949 calc_absolute_offset (w, &add_x, &add_y); 951 calc_absolute_offset (w, &add_x, &add_y);
950 952
951 return quad (WINDOW_LEFT_EDGE_X (w) + add_x, 953 return list4i (WINDOW_LEFT_EDGE_X (w) + add_x,
952 WINDOW_TOP_EDGE_Y (w) + add_y, 954 WINDOW_TOP_EDGE_Y (w) + add_y,
953 WINDOW_RIGHT_EDGE_X (w) + add_x, 955 WINDOW_RIGHT_EDGE_X (w) + add_x,
954 WINDOW_BOTTOM_EDGE_Y (w) + add_y); 956 WINDOW_BOTTOM_EDGE_Y (w) + add_y);
955} 957}
956 958
957DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0, 959DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0,
@@ -970,16 +972,16 @@ display margins, fringes, header line, and/or mode line. */)
970{ 972{
971 register struct window *w = decode_live_window (window); 973 register struct window *w = decode_live_window (window);
972 974
973 return quad (WINDOW_BOX_LEFT_EDGE_COL (w) 975 return list4i ((WINDOW_BOX_LEFT_EDGE_COL (w)
974 + WINDOW_LEFT_MARGIN_COLS (w) 976 + WINDOW_LEFT_MARGIN_COLS (w)
975 + WINDOW_LEFT_FRINGE_COLS (w), 977 + WINDOW_LEFT_FRINGE_COLS (w)),
976 WINDOW_TOP_EDGE_LINE (w) 978 (WINDOW_TOP_EDGE_LINE (w)
977 + WINDOW_HEADER_LINE_LINES (w), 979 + WINDOW_HEADER_LINE_LINES (w)),
978 WINDOW_BOX_RIGHT_EDGE_COL (w) 980 (WINDOW_BOX_RIGHT_EDGE_COL (w)
979 - WINDOW_RIGHT_MARGIN_COLS (w) 981 - WINDOW_RIGHT_MARGIN_COLS (w)
980 - WINDOW_RIGHT_FRINGE_COLS (w), 982 - WINDOW_RIGHT_FRINGE_COLS (w)),
981 WINDOW_BOTTOM_EDGE_LINE (w) 983 (WINDOW_BOTTOM_EDGE_LINE (w)
982 - WINDOW_MODE_LINE_LINES (w)); 984 - WINDOW_MODE_LINE_LINES (w)));
983} 985}
984 986
985DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0, 987DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0,
@@ -997,16 +999,16 @@ display margins, fringes, header line, and/or mode line. */)
997{ 999{
998 register struct window *w = decode_live_window (window); 1000 register struct window *w = decode_live_window (window);
999 1001
1000 return quad (WINDOW_BOX_LEFT_EDGE_X (w) 1002 return list4i ((WINDOW_BOX_LEFT_EDGE_X (w)
1001 + WINDOW_LEFT_MARGIN_WIDTH (w) 1003 + WINDOW_LEFT_MARGIN_WIDTH (w)
1002 + WINDOW_LEFT_FRINGE_WIDTH (w), 1004 + WINDOW_LEFT_FRINGE_WIDTH (w)),
1003 WINDOW_TOP_EDGE_Y (w) 1005 (WINDOW_TOP_EDGE_Y (w)
1004 + WINDOW_HEADER_LINE_HEIGHT (w), 1006 + WINDOW_HEADER_LINE_HEIGHT (w)),
1005 WINDOW_BOX_RIGHT_EDGE_X (w) 1007 (WINDOW_BOX_RIGHT_EDGE_X (w)
1006 - WINDOW_RIGHT_MARGIN_WIDTH (w) 1008 - WINDOW_RIGHT_MARGIN_WIDTH (w)
1007 - WINDOW_RIGHT_FRINGE_WIDTH (w), 1009 - WINDOW_RIGHT_FRINGE_WIDTH (w)),
1008 WINDOW_BOTTOM_EDGE_Y (w) 1010 (WINDOW_BOTTOM_EDGE_Y (w)
1009 - WINDOW_MODE_LINE_HEIGHT (w)); 1011 - WINDOW_MODE_LINE_HEIGHT (w)));
1010} 1012}
1011 1013
1012DEFUN ("window-inside-absolute-pixel-edges", 1014DEFUN ("window-inside-absolute-pixel-edges",
@@ -1029,16 +1031,16 @@ display margins, fringes, header line, and/or mode line. */)
1029 1031
1030 calc_absolute_offset (w, &add_x, &add_y); 1032 calc_absolute_offset (w, &add_x, &add_y);
1031 1033
1032 return quad (WINDOW_BOX_LEFT_EDGE_X (w) 1034 return list4i ((WINDOW_BOX_LEFT_EDGE_X (w)
1033 + WINDOW_LEFT_MARGIN_WIDTH (w) 1035 + WINDOW_LEFT_MARGIN_WIDTH (w)
1034 + WINDOW_LEFT_FRINGE_WIDTH (w) + add_x, 1036 + WINDOW_LEFT_FRINGE_WIDTH (w) + add_x),
1035 WINDOW_TOP_EDGE_Y (w) 1037 (WINDOW_TOP_EDGE_Y (w)
1036 + WINDOW_HEADER_LINE_HEIGHT (w) + add_y, 1038 + WINDOW_HEADER_LINE_HEIGHT (w) + add_y),
1037 WINDOW_BOX_RIGHT_EDGE_X (w) 1039 (WINDOW_BOX_RIGHT_EDGE_X (w)
1038 - WINDOW_RIGHT_MARGIN_WIDTH (w) 1040 - WINDOW_RIGHT_MARGIN_WIDTH (w)
1039 - WINDOW_RIGHT_FRINGE_WIDTH (w) + add_x, 1041 - WINDOW_RIGHT_FRINGE_WIDTH (w) + add_x),
1040 WINDOW_BOTTOM_EDGE_Y (w) 1042 (WINDOW_BOTTOM_EDGE_Y (w)
1041 - WINDOW_MODE_LINE_HEIGHT (w) + add_y); 1043 - WINDOW_MODE_LINE_HEIGHT (w) + add_y));
1042} 1044}
1043 1045
1044/* Test if the character at column X, row Y is within window W. 1046/* Test if the character at column X, row Y is within window W.
@@ -1371,12 +1373,7 @@ The top left corner of the frame is considered to be row 0,
1371column 0. */) 1373column 0. */)
1372 (Lisp_Object x, Lisp_Object y, Lisp_Object frame) 1374 (Lisp_Object x, Lisp_Object y, Lisp_Object frame)
1373{ 1375{
1374 struct frame *f; 1376 struct frame *f = decode_live_frame (frame);
1375
1376 if (NILP (frame))
1377 frame = selected_frame;
1378 CHECK_LIVE_FRAME (frame);
1379 f = XFRAME (frame);
1380 1377
1381 /* Check that arguments are integers or floats. */ 1378 /* Check that arguments are integers or floats. */
1382 CHECK_NUMBER_OR_FLOAT (x); 1379 CHECK_NUMBER_OR_FLOAT (x);
@@ -1624,7 +1621,7 @@ display row, and VPOS is the row number (0-based) containing POS. */)
1624 { 1621 {
1625 Lisp_Object part = Qnil; 1622 Lisp_Object part = Qnil;
1626 if (!fully_p) 1623 if (!fully_p)
1627 part = quad (rtop, rbot, rowh, vpos); 1624 part = list4i (rtop, rbot, rowh, vpos);
1628 in_window = Fcons (make_number (x), 1625 in_window = Fcons (make_number (x),
1629 Fcons (make_number (y), part)); 1626 Fcons (make_number (y), part));
1630 } 1627 }
@@ -1690,17 +1687,18 @@ Return nil if window display is not up-to-date. In that case, use
1690 if (!WINDOW_WANTS_HEADER_LINE_P (w)) 1687 if (!WINDOW_WANTS_HEADER_LINE_P (w))
1691 return Qnil; 1688 return Qnil;
1692 row = MATRIX_HEADER_LINE_ROW (w->current_matrix); 1689 row = MATRIX_HEADER_LINE_ROW (w->current_matrix);
1693 return row->enabled_p ? quad (row->height, 0, 0, 0) : Qnil; 1690 return row->enabled_p ? list4i (row->height, 0, 0, 0) : Qnil;
1694 } 1691 }
1695 1692
1696 if (EQ (line, Qmode_line)) 1693 if (EQ (line, Qmode_line))
1697 { 1694 {
1698 row = MATRIX_MODE_LINE_ROW (w->current_matrix); 1695 row = MATRIX_MODE_LINE_ROW (w->current_matrix);
1699 return (row->enabled_p ? 1696 return (row->enabled_p ?
1700 quad (row->height, 1697 list4i (row->height,
1701 0, /* not accurate */ 1698 0, /* not accurate */
1702 WINDOW_HEADER_LINE_HEIGHT (w) 1699 (WINDOW_HEADER_LINE_HEIGHT (w)
1703 + window_text_bottom_y (w), 0) 1700 + window_text_bottom_y (w)),
1701 0)
1704 : Qnil); 1702 : Qnil);
1705 } 1703 }
1706 1704
@@ -1730,7 +1728,7 @@ Return nil if window display is not up-to-date. In that case, use
1730 1728
1731 found_row: 1729 found_row:
1732 crop = max (0, (row->y + row->height) - max_y); 1730 crop = max (0, (row->y + row->height) - max_y);
1733 return quad (row->height + min (0, row->y) - crop, i, row->y, crop); 1731 return list4i (row->height + min (0, row->y) - crop, i, row->y, crop);
1734} 1732}
1735 1733
1736DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p, 1734DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p,
@@ -2135,10 +2133,10 @@ window_list (void)
2135{ 2133{
2136 if (!CONSP (Vwindow_list)) 2134 if (!CONSP (Vwindow_list))
2137 { 2135 {
2138 Lisp_Object tail; 2136 Lisp_Object tail, frame;
2139 2137
2140 Vwindow_list = Qnil; 2138 Vwindow_list = Qnil;
2141 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 2139 FOR_EACH_FRAME (tail, frame)
2142 { 2140 {
2143 Lisp_Object args[2]; 2141 Lisp_Object args[2];
2144 2142
@@ -2146,7 +2144,7 @@ window_list (void)
2146 new windows at the front of args[1], which means we 2144 new windows at the front of args[1], which means we
2147 have to reverse this list at the end. */ 2145 have to reverse this list at the end. */
2148 args[1] = Qnil; 2146 args[1] = Qnil;
2149 foreach_window (XFRAME (XCAR (tail)), add_window_to_list, &args[1]); 2147 foreach_window (XFRAME (frame), add_window_to_list, &args[1]);
2150 args[0] = Vwindow_list; 2148 args[0] = Vwindow_list;
2151 args[1] = Fnreverse (args[1]); 2149 args[1] = Fnreverse (args[1]);
2152 Vwindow_list = Fnconc (2, args); 2150 Vwindow_list = Fnconc (2, args);
@@ -3109,12 +3107,12 @@ run_window_configuration_change_hook (struct frame *f)
3109} 3107}
3110 3108
3111DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, 3109DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook,
3112 Srun_window_configuration_change_hook, 1, 1, 0, 3110 Srun_window_configuration_change_hook, 0, 1, 0,
3113 doc: /* Run `window-configuration-change-hook' for FRAME. */) 3111 doc: /* Run `window-configuration-change-hook' for FRAME.
3112If FRAME is omitted or nil, it defaults to the selected frame. */)
3114 (Lisp_Object frame) 3113 (Lisp_Object frame)
3115{ 3114{
3116 CHECK_LIVE_FRAME (frame); 3115 run_window_configuration_change_hook (decode_live_frame (frame));
3117 run_window_configuration_change_hook (XFRAME (frame));
3118 return Qnil; 3116 return Qnil;
3119} 3117}
3120 3118
@@ -3641,10 +3639,12 @@ window_resize_apply (struct window *w, int horflag)
3641} 3639}
3642 3640
3643 3641
3644DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 1, 2, 0, 3642DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 0, 2, 0,
3645 doc: /* Apply requested size values for window-tree of FRAME. 3643 doc: /* Apply requested size values for window-tree of FRAME.
3646Optional argument HORIZONTAL omitted or nil means apply requested height 3644If FRAME is omitted or nil, it defaults to the selected frame.
3647values. HORIZONTAL non-nil means apply requested width values. 3645
3646Optional argument HORIZONTAL omitted or nil means apply requested
3647height values. HORIZONTAL non-nil means apply requested width values.
3648 3648
3649This function checks whether the requested values sum up to a valid 3649This function checks whether the requested values sum up to a valid
3650window layout, recursively assigns the new sizes of all child windows 3650window layout, recursively assigns the new sizes of all child windows
@@ -3655,17 +3655,10 @@ Note: This function does not check any of `window-fixed-size-p',
3655be applied on the Elisp level. */) 3655be applied on the Elisp level. */)
3656 (Lisp_Object frame, Lisp_Object horizontal) 3656 (Lisp_Object frame, Lisp_Object horizontal)
3657{ 3657{
3658 struct frame *f; 3658 struct frame *f = decode_live_frame (frame);
3659 struct window *r; 3659 struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
3660 int horflag = !NILP (horizontal); 3660 int horflag = !NILP (horizontal);
3661 3661
3662 if (NILP (frame))
3663 frame = selected_frame;
3664 CHECK_LIVE_FRAME (frame);
3665
3666 f = XFRAME (frame);
3667 r = XWINDOW (FRAME_ROOT_WINDOW (f));
3668
3669 if (!window_resize_check (r, horflag) 3662 if (!window_resize_check (r, horflag)
3670 || ! EQ (r->new_total, 3663 || ! EQ (r->new_total,
3671 (horflag ? r->total_cols : r->total_lines))) 3664 (horflag ? r->total_cols : r->total_lines)))
@@ -3879,9 +3872,10 @@ set correctly. See the code of `split-window' for how this is done. */)
3879 3872
3880 make_parent_window (old, horflag); 3873 make_parent_window (old, horflag);
3881 p = XWINDOW (o->parent); 3874 p = XWINDOW (o->parent);
3882 /* Store t in the new parent's combination_limit slot to avoid 3875 if (EQ (Vwindow_combination_limit, Qt))
3883 that its children get merged into another window. */ 3876 /* Store t in the new parent's combination_limit slot to avoid
3884 wset_combination_limit (p, Qt); 3877 that its children get merged into another window. */
3878 wset_combination_limit (p, Qt);
3885 /* These get applied below. */ 3879 /* These get applied below. */
3886 wset_new_total (p, horflag ? o->total_cols : o->total_lines); 3880 wset_new_total (p, horflag ? o->total_cols : o->total_lines);
3887 wset_new_normal (p, new_normal); 3881 wset_new_normal (p, new_normal);
@@ -6148,12 +6142,7 @@ saved by this function. */)
6148 register int n_windows; 6142 register int n_windows;
6149 register struct save_window_data *data; 6143 register struct save_window_data *data;
6150 register int i; 6144 register int i;
6151 FRAME_PTR f; 6145 struct frame *f = decode_live_frame (frame);
6152
6153 if (NILP (frame))
6154 frame = selected_frame;
6155 CHECK_LIVE_FRAME (frame);
6156 f = XFRAME (frame);
6157 6146
6158 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); 6147 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
6159 data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols, 6148 data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols,
diff --git a/src/xdisp.c b/src/xdisp.c
index 1ff7819f34d..a74628db392 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10769,7 +10769,7 @@ clear_garbaged_frames (void)
10769 { 10769 {
10770 if (f->resized_p) 10770 if (f->resized_p)
10771 { 10771 {
10772 Fredraw_frame (frame); 10772 redraw_frame (f);
10773 f->force_flush_display_p = 1; 10773 f->force_flush_display_p = 1;
10774 } 10774 }
10775 clear_current_matrices (f); 10775 clear_current_matrices (f);
@@ -11096,17 +11096,15 @@ x_consider_frame_title (Lisp_Object frame)
11096 || f->explicit_name) 11096 || f->explicit_name)
11097 { 11097 {
11098 /* Do we have more than one visible frame on this X display? */ 11098 /* Do we have more than one visible frame on this X display? */
11099 Lisp_Object tail; 11099 Lisp_Object tail, other_frame, fmt;
11100 Lisp_Object fmt;
11101 ptrdiff_t title_start; 11100 ptrdiff_t title_start;
11102 char *title; 11101 char *title;
11103 ptrdiff_t len; 11102 ptrdiff_t len;
11104 struct it it; 11103 struct it it;
11105 ptrdiff_t count = SPECPDL_INDEX (); 11104 ptrdiff_t count = SPECPDL_INDEX ();
11106 11105
11107 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 11106 FOR_EACH_FRAME (tail, other_frame)
11108 { 11107 {
11109 Lisp_Object other_frame = XCAR (tail);
11110 struct frame *tf = XFRAME (other_frame); 11108 struct frame *tf = XFRAME (other_frame);
11111 11109
11112 if (tf != f 11110 if (tf != f
@@ -11916,19 +11914,14 @@ tool_bar_lines_needed (struct frame *f, int *n_rows)
11916 11914
11917DEFUN ("tool-bar-lines-needed", Ftool_bar_lines_needed, Stool_bar_lines_needed, 11915DEFUN ("tool-bar-lines-needed", Ftool_bar_lines_needed, Stool_bar_lines_needed,
11918 0, 1, 0, 11916 0, 1, 0,
11919 doc: /* Return the number of lines occupied by the tool bar of FRAME. */) 11917 doc: /* Return the number of lines occupied by the tool bar of FRAME.
11918If FRAME is nil or omitted, use the selected frame. */)
11920 (Lisp_Object frame) 11919 (Lisp_Object frame)
11921{ 11920{
11922 struct frame *f; 11921 struct frame *f = decode_any_frame (frame);
11923 struct window *w; 11922 struct window *w;
11924 int nlines = 0; 11923 int nlines = 0;
11925 11924
11926 if (NILP (frame))
11927 frame = selected_frame;
11928 else
11929 CHECK_FRAME (frame);
11930 f = XFRAME (frame);
11931
11932 if (WINDOWP (f->tool_bar_window) 11925 if (WINDOWP (f->tool_bar_window)
11933 && (w = XWINDOW (f->tool_bar_window), 11926 && (w = XWINDOW (f->tool_bar_window),
11934 WINDOW_TOTAL_LINES (w) > 0)) 11927 WINDOW_TOTAL_LINES (w) > 0))
@@ -14791,13 +14784,18 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14791 if (NUMBERP (aggressive)) 14784 if (NUMBERP (aggressive))
14792 { 14785 {
14793 double float_amount = XFLOATINT (aggressive) * height; 14786 double float_amount = XFLOATINT (aggressive) * height;
14794 amount_to_scroll = float_amount; 14787 int aggressive_scroll = float_amount;
14795 if (amount_to_scroll == 0 && float_amount > 0) 14788 if (aggressive_scroll == 0 && float_amount > 0)
14796 amount_to_scroll = 1; 14789 aggressive_scroll = 1;
14797 /* Don't let point enter the scroll margin near top of 14790 /* Don't let point enter the scroll margin near top of
14798 the window. */ 14791 the window. This could happen if the value of
14799 if (amount_to_scroll > height - 2*this_scroll_margin + dy) 14792 scroll_up_aggressively is too large and there are
14800 amount_to_scroll = height - 2*this_scroll_margin + dy; 14793 non-zero margins, because scroll_up_aggressively
14794 means put point that fraction of window height
14795 _from_the_bottom_margin_. */
14796 if (aggressive_scroll + 2*this_scroll_margin > height)
14797 aggressive_scroll = height - 2*this_scroll_margin;
14798 amount_to_scroll = dy + aggressive_scroll;
14801 } 14799 }
14802 } 14800 }
14803 14801
@@ -14857,7 +14855,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14857 /* Compute the vertical distance from PT to the scroll 14855 /* Compute the vertical distance from PT to the scroll
14858 margin position. Move as far as scroll_max allows, or 14856 margin position. Move as far as scroll_max allows, or
14859 one screenful, or 10 screen lines, whichever is largest. 14857 one screenful, or 10 screen lines, whichever is largest.
14860 Give up if distance is greater than scroll_max. */ 14858 Give up if distance is greater than scroll_max or if we
14859 didn't reach the scroll margin position. */
14861 SET_TEXT_POS (pos, PT, PT_BYTE); 14860 SET_TEXT_POS (pos, PT, PT_BYTE);
14862 start_display (&it, w, pos); 14861 start_display (&it, w, pos);
14863 y0 = it.current_y; 14862 y0 = it.current_y;
@@ -14867,7 +14866,8 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14867 y_to_move, -1, 14866 y_to_move, -1,
14868 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); 14867 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
14869 dy = it.current_y - y0; 14868 dy = it.current_y - y0;
14870 if (dy > scroll_max) 14869 if (dy > scroll_max
14870 || IT_CHARPOS (it) < CHARPOS (scroll_margin_pos))
14871 return SCROLLING_FAILED; 14871 return SCROLLING_FAILED;
14872 14872
14873 /* Compute new window start. */ 14873 /* Compute new window start. */
@@ -14885,15 +14885,16 @@ try_scrolling (Lisp_Object window, int just_this_one_p,
14885 if (NUMBERP (aggressive)) 14885 if (NUMBERP (aggressive))
14886 { 14886 {
14887 double float_amount = XFLOATINT (aggressive) * height; 14887 double float_amount = XFLOATINT (aggressive) * height;
14888 amount_to_scroll = float_amount; 14888 int aggressive_scroll = float_amount;
14889 if (amount_to_scroll == 0 && float_amount > 0) 14889 if (aggressive_scroll == 0 && float_amount > 0)
14890 amount_to_scroll = 1; 14890 aggressive_scroll = 1;
14891 amount_to_scroll -=
14892 this_scroll_margin - dy - FRAME_LINE_HEIGHT (f);
14893 /* Don't let point enter the scroll margin near 14891 /* Don't let point enter the scroll margin near
14894 bottom of the window. */ 14892 bottom of the window, if the value of
14895 if (amount_to_scroll > height - 2*this_scroll_margin + dy) 14893 scroll_down_aggressively happens to be too
14896 amount_to_scroll = height - 2*this_scroll_margin + dy; 14894 large. */
14895 if (aggressive_scroll + 2*this_scroll_margin > height)
14896 aggressive_scroll = height - 2*this_scroll_margin;
14897 amount_to_scroll = dy + aggressive_scroll;
14897 } 14898 }
14898 } 14899 }
14899 14900
@@ -21370,6 +21371,12 @@ decode_mode_spec (struct window *w, register int c, int field_width,
21370 Lisp_Object obj; 21371 Lisp_Object obj;
21371 struct frame *f = XFRAME (WINDOW_FRAME (w)); 21372 struct frame *f = XFRAME (WINDOW_FRAME (w));
21372 char *decode_mode_spec_buf = f->decode_mode_spec_buffer; 21373 char *decode_mode_spec_buf = f->decode_mode_spec_buffer;
21374 /* We are going to use f->decode_mode_spec_buffer as the buffer to
21375 produce strings from numerical values, so limit preposterously
21376 large values of FIELD_WIDTH to avoid overrunning the buffer's
21377 end. The size of the buffer is enough for FRAME_MESSAGE_BUF_SIZE
21378 bytes plus the terminating null. */
21379 int width = min (field_width, FRAME_MESSAGE_BUF_SIZE (f));
21373 struct buffer *b = current_buffer; 21380 struct buffer *b = current_buffer;
21374 21381
21375 obj = Qnil; 21382 obj = Qnil;
@@ -21465,7 +21472,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
21465 { 21472 {
21466 ptrdiff_t col = current_column (); 21473 ptrdiff_t col = current_column ();
21467 wset_column_number_displayed (w, make_number (col)); 21474 wset_column_number_displayed (w, make_number (col));
21468 pint2str (decode_mode_spec_buf, field_width, col); 21475 pint2str (decode_mode_spec_buf, width, col);
21469 return decode_mode_spec_buf; 21476 return decode_mode_spec_buf;
21470 } 21477 }
21471 21478
@@ -21496,14 +21503,14 @@ decode_mode_spec (struct window *w, register int c, int field_width,
21496 case 'i': 21503 case 'i':
21497 { 21504 {
21498 ptrdiff_t size = ZV - BEGV; 21505 ptrdiff_t size = ZV - BEGV;
21499 pint2str (decode_mode_spec_buf, field_width, size); 21506 pint2str (decode_mode_spec_buf, width, size);
21500 return decode_mode_spec_buf; 21507 return decode_mode_spec_buf;
21501 } 21508 }
21502 21509
21503 case 'I': 21510 case 'I':
21504 { 21511 {
21505 ptrdiff_t size = ZV - BEGV; 21512 ptrdiff_t size = ZV - BEGV;
21506 pint2hrstr (decode_mode_spec_buf, field_width, size); 21513 pint2hrstr (decode_mode_spec_buf, width, size);
21507 return decode_mode_spec_buf; 21514 return decode_mode_spec_buf;
21508 } 21515 }
21509 21516
@@ -21610,12 +21617,12 @@ decode_mode_spec (struct window *w, register int c, int field_width,
21610 line_number_displayed = 1; 21617 line_number_displayed = 1;
21611 21618
21612 /* Make the string to show. */ 21619 /* Make the string to show. */
21613 pint2str (decode_mode_spec_buf, field_width, topline + nlines); 21620 pint2str (decode_mode_spec_buf, width, topline + nlines);
21614 return decode_mode_spec_buf; 21621 return decode_mode_spec_buf;
21615 no_value: 21622 no_value:
21616 { 21623 {
21617 char* p = decode_mode_spec_buf; 21624 char* p = decode_mode_spec_buf;
21618 int pad = field_width - 2; 21625 int pad = width - 2;
21619 while (pad-- > 0) 21626 while (pad-- > 0)
21620 *p++ = ' '; 21627 *p++ = ' ';
21621 *p++ = '?'; 21628 *p++ = '?';
@@ -29417,8 +29424,10 @@ start_hourglass (void)
29417 delay = make_emacs_time (DEFAULT_HOURGLASS_DELAY, 0); 29424 delay = make_emacs_time (DEFAULT_HOURGLASS_DELAY, 0);
29418 29425
29419#ifdef HAVE_NTGUI 29426#ifdef HAVE_NTGUI
29420 extern void w32_note_current_window (void); 29427 {
29421 w32_note_current_window (); 29428 extern void w32_note_current_window (void);
29429 w32_note_current_window ();
29430 }
29422#endif /* HAVE_NTGUI */ 29431#endif /* HAVE_NTGUI */
29423 29432
29424 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, 29433 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
diff --git a/src/xfaces.c b/src/xfaces.c
index 221387c4b6d..daf329791c1 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -314,16 +314,10 @@ static Lisp_Object QCfontset;
314Lisp_Object Qnormal; 314Lisp_Object Qnormal;
315Lisp_Object Qbold; 315Lisp_Object Qbold;
316static Lisp_Object Qline, Qwave; 316static Lisp_Object Qline, Qwave;
317static Lisp_Object Qultra_light, Qreverse_oblique, Qreverse_italic;
318Lisp_Object Qextra_light, Qlight; 317Lisp_Object Qextra_light, Qlight;
319Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold; 318Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold;
320Lisp_Object Qoblique; 319Lisp_Object Qoblique;
321Lisp_Object Qitalic; 320Lisp_Object Qitalic;
322static Lisp_Object Qultra_condensed, Qextra_condensed;
323Lisp_Object Qcondensed;
324static Lisp_Object Qsemi_condensed, Qsemi_expanded, Qextra_expanded;
325Lisp_Object Qexpanded;
326static Lisp_Object Qultra_expanded;
327static Lisp_Object Qreleased_button, Qpressed_button; 321static Lisp_Object Qreleased_button, Qpressed_button;
328static Lisp_Object QCstyle, QCcolor, QCline_width; 322static Lisp_Object QCstyle, QCcolor, QCline_width;
329Lisp_Object Qunspecified; /* used in dosfns.c */ 323Lisp_Object Qunspecified; /* used in dosfns.c */
@@ -669,23 +663,6 @@ x_free_gc (struct frame *f, GC gc)
669} 663}
670#endif /* HAVE_NS */ 664#endif /* HAVE_NS */
671 665
672/* If FRAME is nil, return a pointer to the selected frame.
673 Otherwise, check that FRAME is a live frame, and return a pointer
674 to it. NPARAM is the parameter number of FRAME, for
675 CHECK_LIVE_FRAME. This is here because it's a frequent pattern in
676 Lisp function definitions. */
677
678static struct frame *
679frame_or_selected_frame (Lisp_Object frame, int nparam)
680{
681 if (NILP (frame))
682 frame = selected_frame;
683
684 CHECK_LIVE_FRAME (frame);
685 return XFRAME (frame);
686}
687
688
689/*********************************************************************** 666/***********************************************************************
690 Frames and faces 667 Frames and faces
691 ***********************************************************************/ 668 ***********************************************************************/
@@ -1204,15 +1181,9 @@ FRAME specifies the frame and thus the display for interpreting COLOR.
1204If FRAME is nil or omitted, use the selected frame. */) 1181If FRAME is nil or omitted, use the selected frame. */)
1205 (Lisp_Object color, Lisp_Object frame) 1182 (Lisp_Object color, Lisp_Object frame)
1206{ 1183{
1207 struct frame *f;
1208
1209 CHECK_STRING (color); 1184 CHECK_STRING (color);
1210 if (NILP (frame)) 1185 return (face_color_gray_p (decode_any_frame (frame), SSDATA (color))
1211 frame = selected_frame; 1186 ? Qt : Qnil);
1212 else
1213 CHECK_FRAME (frame);
1214 f = XFRAME (frame);
1215 return face_color_gray_p (f, SSDATA (color)) ? Qt : Qnil;
1216} 1187}
1217 1188
1218 1189
@@ -1225,17 +1196,10 @@ If FRAME is nil or omitted, use the selected frame.
1225COLOR must be a valid color name. */) 1196COLOR must be a valid color name. */)
1226 (Lisp_Object color, Lisp_Object frame, Lisp_Object background_p) 1197 (Lisp_Object color, Lisp_Object frame, Lisp_Object background_p)
1227{ 1198{
1228 struct frame *f;
1229
1230 CHECK_STRING (color); 1199 CHECK_STRING (color);
1231 if (NILP (frame)) 1200 return (face_color_supported_p (decode_any_frame (frame),
1232 frame = selected_frame; 1201 SSDATA (color), !NILP (background_p))
1233 else 1202 ? Qt : Qnil);
1234 CHECK_FRAME (frame);
1235 f = XFRAME (frame);
1236 if (face_color_supported_p (f, SSDATA (color), !NILP (background_p)))
1237 return Qt;
1238 return Qnil;
1239} 1203}
1240 1204
1241 1205
@@ -1683,9 +1647,7 @@ the WIDTH times as wide as FACE on FRAME. */)
1683 1647
1684 /* We can't simply call check_x_frame because this function may be 1648 /* We can't simply call check_x_frame because this function may be
1685 called before any frame is created. */ 1649 called before any frame is created. */
1686 if (NILP (frame)) 1650 f = decode_live_frame (frame);
1687 frame = selected_frame;
1688 f = frame_or_selected_frame (frame, 2);
1689 if (! FRAME_WINDOW_P (f)) 1651 if (! FRAME_WINDOW_P (f))
1690 { 1652 {
1691 /* Perhaps we have not yet created any frame. */ 1653 /* Perhaps we have not yet created any frame. */
@@ -1693,6 +1655,8 @@ the WIDTH times as wide as FACE on FRAME. */)
1693 frame = Qnil; 1655 frame = Qnil;
1694 face = Qnil; 1656 face = Qnil;
1695 } 1657 }
1658 else
1659 XSETFRAME (frame, f);
1696 1660
1697 /* Determine the width standard for comparison with the fonts we find. */ 1661 /* Determine the width standard for comparison with the fonts we find. */
1698 1662
@@ -3679,21 +3643,12 @@ frame. If FRAME is t, report on the defaults for face SYMBOL (for new
3679frames). If FRAME is omitted or nil, use the selected frame. */) 3643frames). If FRAME is omitted or nil, use the selected frame. */)
3680 (Lisp_Object symbol, Lisp_Object keyword, Lisp_Object frame) 3644 (Lisp_Object symbol, Lisp_Object keyword, Lisp_Object frame)
3681{ 3645{
3682 Lisp_Object lface, value = Qnil; 3646 struct frame *f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
3647 Lisp_Object lface = lface_from_face_name (f, symbol, 1), value = Qnil;
3683 3648
3684 CHECK_SYMBOL (symbol); 3649 CHECK_SYMBOL (symbol);
3685 CHECK_SYMBOL (keyword); 3650 CHECK_SYMBOL (keyword);
3686 3651
3687 if (EQ (frame, Qt))
3688 lface = lface_from_face_name (NULL, symbol, 1);
3689 else
3690 {
3691 if (NILP (frame))
3692 frame = selected_frame;
3693 CHECK_LIVE_FRAME (frame);
3694 lface = lface_from_face_name (XFRAME (frame), symbol, 1);
3695 }
3696
3697 if (EQ (keyword, QCfamily)) 3652 if (EQ (keyword, QCfamily))
3698 value = LFACE_FAMILY (lface); 3653 value = LFACE_FAMILY (lface);
3699 else if (EQ (keyword, QCfoundry)) 3654 else if (EQ (keyword, QCfoundry))
@@ -3876,7 +3831,7 @@ return the font name used for CHARACTER. */)
3876 } 3831 }
3877 else 3832 else
3878 { 3833 {
3879 struct frame *f = frame_or_selected_frame (frame, 1); 3834 struct frame *f = decode_live_frame (frame);
3880 int face_id = lookup_named_face (f, face, 1); 3835 int face_id = lookup_named_face (f, face, 1);
3881 struct face *fface = FACE_FROM_ID (f, face_id); 3836 struct face *fface = FACE_FROM_ID (f, face_id);
3882 3837
@@ -3963,14 +3918,11 @@ If FRAME is omitted or nil, use the selected frame. */)
3963 struct frame *f; 3918 struct frame *f;
3964 Lisp_Object lface1, lface2; 3919 Lisp_Object lface1, lface2;
3965 3920
3966 if (EQ (frame, Qt)) 3921 /* Don't use check_x_frame here because this function is called
3967 f = NULL; 3922 before X frames exist. At that time, if FRAME is nil,
3968 else 3923 selected_frame will be used which is the frame dumped with
3969 /* Don't use check_x_frame here because this function is called 3924 Emacs. That frame is not an X frame. */
3970 before X frames exist. At that time, if FRAME is nil, 3925 f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
3971 selected_frame will be used which is the frame dumped with
3972 Emacs. That frame is not an X frame. */
3973 f = frame_or_selected_frame (frame, 2);
3974 3926
3975 lface1 = lface_from_face_name (f, face1, 1); 3927 lface1 = lface_from_face_name (f, face1, 1);
3976 lface2 = lface_from_face_name (f, face2, 1); 3928 lface2 = lface_from_face_name (f, face2, 1);
@@ -3988,20 +3940,10 @@ If FRAME is t, report on the defaults for face FACE (for new frames).
3988If FRAME is omitted or nil, use the selected frame. */) 3940If FRAME is omitted or nil, use the selected frame. */)
3989 (Lisp_Object face, Lisp_Object frame) 3941 (Lisp_Object face, Lisp_Object frame)
3990{ 3942{
3991 struct frame *f; 3943 struct frame *f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
3992 Lisp_Object lface; 3944 Lisp_Object lface = lface_from_face_name (f, face, 1);
3993 int i; 3945 int i;
3994 3946
3995 if (NILP (frame))
3996 frame = selected_frame;
3997 CHECK_LIVE_FRAME (frame);
3998 f = XFRAME (frame);
3999
4000 if (EQ (frame, Qt))
4001 lface = lface_from_face_name (NULL, face, 1);
4002 else
4003 lface = lface_from_face_name (f, face, 1);
4004
4005 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) 3947 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
4006 if (!UNSPECIFIEDP (AREF (lface, i))) 3948 if (!UNSPECIFIEDP (AREF (lface, i)))
4007 break; 3949 break;
@@ -4016,8 +3958,7 @@ DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist,
4016For internal use only. */) 3958For internal use only. */)
4017 (Lisp_Object frame) 3959 (Lisp_Object frame)
4018{ 3960{
4019 struct frame *f = frame_or_selected_frame (frame, 0); 3961 return decode_live_frame (frame)->face_alist;
4020 return f->face_alist;
4021} 3962}
4022 3963
4023 3964
@@ -4205,14 +4146,9 @@ or lists of the form (RED GREEN BLUE).
4205If FRAME is unspecified or nil, the current frame is used. */) 4146If FRAME is unspecified or nil, the current frame is used. */)
4206 (Lisp_Object color1, Lisp_Object color2, Lisp_Object frame) 4147 (Lisp_Object color1, Lisp_Object color2, Lisp_Object frame)
4207{ 4148{
4208 struct frame *f; 4149 struct frame *f = decode_live_frame (frame);
4209 XColor cdef1, cdef2; 4150 XColor cdef1, cdef2;
4210 4151
4211 if (NILP (frame))
4212 frame = selected_frame;
4213 CHECK_LIVE_FRAME (frame);
4214 f = XFRAME (frame);
4215
4216 if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1)) 4152 if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1))
4217 && !(STRINGP (color1) && defined_color (f, SSDATA (color1), &cdef1, 0))) 4153 && !(STRINGP (color1) && defined_color (f, SSDATA (color1), &cdef1, 0)))
4218 signal_error ("Invalid color", color1); 4154 signal_error ("Invalid color", color1);
@@ -5076,17 +5012,14 @@ face for italic. */)
5076 else 5012 else
5077 { 5013 {
5078 /* Find any frame on DISPLAY. */ 5014 /* Find any frame on DISPLAY. */
5079 Lisp_Object fl_tail; 5015 Lisp_Object tail;
5080 5016
5081 frame = Qnil; 5017 frame = Qnil;
5082 for (fl_tail = Vframe_list; CONSP (fl_tail); fl_tail = XCDR (fl_tail)) 5018 FOR_EACH_FRAME (tail, frame)
5083 { 5019 if (!NILP (Fequal (Fcdr (Fassq (Qdisplay,
5084 frame = XCAR (fl_tail); 5020 XFRAME (frame)->param_alist)),
5085 if (!NILP (Fequal (Fcdr (Fassq (Qdisplay, 5021 display)))
5086 XFRAME (frame)->param_alist)), 5022 break;
5087 display)))
5088 break;
5089 }
5090 } 5023 }
5091 5024
5092 CHECK_LIVE_FRAME (frame); 5025 CHECK_LIVE_FRAME (frame);
@@ -6509,7 +6442,6 @@ syms_of_xfaces (void)
6509 DEFSYM (Qreleased_button, "released-button"); 6442 DEFSYM (Qreleased_button, "released-button");
6510 DEFSYM (Qpressed_button, "pressed-button"); 6443 DEFSYM (Qpressed_button, "pressed-button");
6511 DEFSYM (Qnormal, "normal"); 6444 DEFSYM (Qnormal, "normal");
6512 DEFSYM (Qultra_light, "ultra-light");
6513 DEFSYM (Qextra_light, "extra-light"); 6445 DEFSYM (Qextra_light, "extra-light");
6514 DEFSYM (Qlight, "light"); 6446 DEFSYM (Qlight, "light");
6515 DEFSYM (Qsemi_light, "semi-light"); 6447 DEFSYM (Qsemi_light, "semi-light");
@@ -6519,16 +6451,6 @@ syms_of_xfaces (void)
6519 DEFSYM (Qultra_bold, "ultra-bold"); 6451 DEFSYM (Qultra_bold, "ultra-bold");
6520 DEFSYM (Qoblique, "oblique"); 6452 DEFSYM (Qoblique, "oblique");
6521 DEFSYM (Qitalic, "italic"); 6453 DEFSYM (Qitalic, "italic");
6522 DEFSYM (Qreverse_oblique, "reverse-oblique");
6523 DEFSYM (Qreverse_italic, "reverse-italic");
6524 DEFSYM (Qultra_condensed, "ultra-condensed");
6525 DEFSYM (Qextra_condensed, "extra-condensed");
6526 DEFSYM (Qcondensed, "condensed");
6527 DEFSYM (Qsemi_condensed, "semi-condensed");
6528 DEFSYM (Qsemi_expanded, "semi-expanded");
6529 DEFSYM (Qexpanded, "expanded");
6530 DEFSYM (Qextra_expanded, "extra-expanded");
6531 DEFSYM (Qultra_expanded, "ultra-expanded");
6532 DEFSYM (Qbackground_color, "background-color"); 6454 DEFSYM (Qbackground_color, "background-color");
6533 DEFSYM (Qforeground_color, "foreground-color"); 6455 DEFSYM (Qforeground_color, "foreground-color");
6534 DEFSYM (Qunspecified, "unspecified"); 6456 DEFSYM (Qunspecified, "unspecified");
diff --git a/src/xfns.c b/src/xfns.c
index aca227385bf..1f98e9fc8c7 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -164,12 +164,8 @@ have_menus_p (void)
164FRAME_PTR 164FRAME_PTR
165check_x_frame (Lisp_Object frame) 165check_x_frame (Lisp_Object frame)
166{ 166{
167 FRAME_PTR f; 167 struct frame *f = decode_live_frame (frame);
168 168
169 if (NILP (frame))
170 frame = selected_frame;
171 CHECK_LIVE_FRAME (frame);
172 f = XFRAME (frame);
173 if (! FRAME_X_P (f)) 169 if (! FRAME_X_P (f))
174 error ("Non-X frame used"); 170 error ("Non-X frame used");
175 return f; 171 return f;
@@ -228,13 +224,11 @@ x_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
228 Lisp_Object tail, frame; 224 Lisp_Object tail, frame;
229 struct frame *f; 225 struct frame *f;
230 226
231 if (wdesc == None) return 0; 227 if (wdesc == None)
228 return NULL;
232 229
233 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 230 FOR_EACH_FRAME (tail, frame)
234 { 231 {
235 frame = XCAR (tail);
236 if (!FRAMEP (frame))
237 continue;
238 f = XFRAME (frame); 232 f = XFRAME (frame);
239 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) 233 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
240 continue; 234 continue;
@@ -274,18 +268,16 @@ struct frame *
274x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc) 268x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
275{ 269{
276 Lisp_Object tail, frame; 270 Lisp_Object tail, frame;
277 struct frame *f, *found; 271 struct frame *f, *found = NULL;
278 struct x_output *x; 272 struct x_output *x;
279 273
280 if (wdesc == None) return NULL; 274 if (wdesc == None)
275 return NULL;
281 276
282 found = NULL; 277 FOR_EACH_FRAME (tail, frame)
283 for (tail = Vframe_list; CONSP (tail) && !found; tail = XCDR (tail))
284 { 278 {
285 frame = XCAR (tail); 279 if (found)
286 if (!FRAMEP (frame)) 280 break;
287 continue;
288
289 f = XFRAME (frame); 281 f = XFRAME (frame);
290 if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo) 282 if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)
291 { 283 {
@@ -329,13 +321,11 @@ x_menubar_window_to_frame (struct x_display_info *dpyinfo, XEvent *event)
329 struct frame *f; 321 struct frame *f;
330 struct x_output *x; 322 struct x_output *x;
331 323
332 if (wdesc == None) return 0; 324 if (wdesc == None)
325 return NULL;
333 326
334 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 327 FOR_EACH_FRAME (tail, frame)
335 { 328 {
336 frame = XCAR (tail);
337 if (!FRAMEP (frame))
338 continue;
339 f = XFRAME (frame); 329 f = XFRAME (frame);
340 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) 330 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
341 continue; 331 continue;
@@ -363,13 +353,11 @@ x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
363 struct frame *f; 353 struct frame *f;
364 struct x_output *x; 354 struct x_output *x;
365 355
366 if (wdesc == None) return 0; 356 if (wdesc == None)
357 return NULL;
367 358
368 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 359 FOR_EACH_FRAME (tail, frame)
369 { 360 {
370 frame = XCAR (tail);
371 if (!FRAMEP (frame))
372 continue;
373 f = XFRAME (frame); 361 f = XFRAME (frame);
374 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) 362 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
375 continue; 363 continue;
@@ -3000,16 +2988,14 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms)
3000DEFUN ("x-wm-set-size-hint", Fx_wm_set_size_hint, Sx_wm_set_size_hint, 2988DEFUN ("x-wm-set-size-hint", Fx_wm_set_size_hint, Sx_wm_set_size_hint,
3001 0, 1, 0, 2989 0, 1, 0,
3002 doc: /* Send the size hints for frame FRAME to the window manager. 2990 doc: /* Send the size hints for frame FRAME to the window manager.
3003If FRAME is nil, use the selected frame. */) 2991If FRAME is omitted or nil, use the selected frame.
2992Signal error if FRAME is not an X frame. */)
3004 (Lisp_Object frame) 2993 (Lisp_Object frame)
3005{ 2994{
3006 struct frame *f; 2995 struct frame *f = check_x_frame (frame);
3007 if (NILP (frame)) 2996
3008 frame = selected_frame;
3009 f = XFRAME (frame);
3010 block_input (); 2997 block_input ();
3011 if (FRAME_X_P (f)) 2998 x_wm_set_size_hint (f, 0, 0);
3012 x_wm_set_size_hint (f, 0, 0);
3013 unblock_input (); 2999 unblock_input ();
3014 return Qnil; 3000 return Qnil;
3015} 3001}
diff --git a/src/xmenu.c b/src/xmenu.c
index 01d932cf8d8..b585df2125b 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -132,11 +132,8 @@ menubar_id_to_frame (LWLIB_ID id)
132 Lisp_Object tail, frame; 132 Lisp_Object tail, frame;
133 FRAME_PTR f; 133 FRAME_PTR f;
134 134
135 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 135 FOR_EACH_FRAME (tail, frame)
136 { 136 {
137 frame = XCAR (tail);
138 if (!FRAMEP (frame))
139 continue;
140 f = XFRAME (frame); 137 f = XFRAME (frame);
141 if (!FRAME_WINDOW_P (f)) 138 if (!FRAME_WINDOW_P (f))
142 continue; 139 continue;
diff --git a/src/xselect.c b/src/xselect.c
index de9386bd7d9..64c64fa0c76 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1940,7 +1940,7 @@ x_handle_selection_notify (XSelectionEvent *event)
1940static struct frame * 1940static struct frame *
1941frame_for_x_selection (Lisp_Object object) 1941frame_for_x_selection (Lisp_Object object)
1942{ 1942{
1943 Lisp_Object tail; 1943 Lisp_Object tail, frame;
1944 struct frame *f; 1944 struct frame *f;
1945 1945
1946 if (NILP (object)) 1946 if (NILP (object))
@@ -1949,9 +1949,9 @@ frame_for_x_selection (Lisp_Object object)
1949 if (FRAME_X_P (f) && FRAME_LIVE_P (f)) 1949 if (FRAME_X_P (f) && FRAME_LIVE_P (f))
1950 return f; 1950 return f;
1951 1951
1952 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 1952 FOR_EACH_FRAME (tail, frame)
1953 { 1953 {
1954 f = XFRAME (XCAR (tail)); 1954 f = XFRAME (frame);
1955 if (FRAME_X_P (f) && FRAME_LIVE_P (f)) 1955 if (FRAME_X_P (f) && FRAME_LIVE_P (f))
1956 return f; 1956 return f;
1957 } 1957 }
@@ -1959,15 +1959,14 @@ frame_for_x_selection (Lisp_Object object)
1959 else if (TERMINALP (object)) 1959 else if (TERMINALP (object))
1960 { 1960 {
1961 struct terminal *t = get_terminal (object, 1); 1961 struct terminal *t = get_terminal (object, 1);
1962
1962 if (t->type == output_x_window) 1963 if (t->type == output_x_window)
1963 { 1964 FOR_EACH_FRAME (tail, frame)
1964 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 1965 {
1965 { 1966 f = XFRAME (frame);
1966 f = XFRAME (XCAR (tail)); 1967 if (FRAME_LIVE_P (f) && f->terminal == t)
1967 if (FRAME_LIVE_P (f) && f->terminal == t) 1968 return f;
1968 return f; 1969 }
1969 }
1970 }
1971 } 1970 }
1972 else if (FRAMEP (object)) 1971 else if (FRAMEP (object))
1973 { 1972 {
diff --git a/src/xterm.c b/src/xterm.c
index 4dd1dee0f75..463d82b4ee2 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1438,7 +1438,7 @@ static struct frame *
1438x_frame_of_widget (Widget widget) 1438x_frame_of_widget (Widget widget)
1439{ 1439{
1440 struct x_display_info *dpyinfo; 1440 struct x_display_info *dpyinfo;
1441 Lisp_Object tail; 1441 Lisp_Object tail, frame;
1442 struct frame *f; 1442 struct frame *f;
1443 1443
1444 dpyinfo = x_display_info_for_display (XtDisplay (widget)); 1444 dpyinfo = x_display_info_for_display (XtDisplay (widget));
@@ -1452,15 +1452,15 @@ x_frame_of_widget (Widget widget)
1452 1452
1453 /* Look for a frame with that top-level widget. Allocate the color 1453 /* Look for a frame with that top-level widget. Allocate the color
1454 on that frame to get the right gamma correction value. */ 1454 on that frame to get the right gamma correction value. */
1455 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 1455 FOR_EACH_FRAME (tail, frame)
1456 if (FRAMEP (XCAR (tail)) 1456 {
1457 && (f = XFRAME (XCAR (tail)), 1457 f = XFRAME (frame);
1458 (FRAME_X_P (f) 1458 if (FRAME_X_P (f)
1459 && f->output_data.nothing != 1 1459 && f->output_data.nothing != 1
1460 && FRAME_X_DISPLAY_INFO (f) == dpyinfo)) 1460 && FRAME_X_DISPLAY_INFO (f) == dpyinfo
1461 && f->output_data.x->widget == widget) 1461 && f->output_data.x->widget == widget)
1462 return f; 1462 return f;
1463 1463 }
1464 emacs_abort (); 1464 emacs_abort ();
1465} 1465}
1466 1466
@@ -4098,20 +4098,15 @@ XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
4098static struct scroll_bar * 4098static struct scroll_bar *
4099x_window_to_scroll_bar (Display *display, Window window_id) 4099x_window_to_scroll_bar (Display *display, Window window_id)
4100{ 4100{
4101 Lisp_Object tail; 4101 Lisp_Object tail, frame;
4102 4102
4103#if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS) 4103#if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)
4104 window_id = (Window) xg_get_scroll_id_for_window (display, window_id); 4104 window_id = (Window) xg_get_scroll_id_for_window (display, window_id);
4105#endif /* USE_GTK && USE_TOOLKIT_SCROLL_BARS */ 4105#endif /* USE_GTK && USE_TOOLKIT_SCROLL_BARS */
4106 4106
4107 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 4107 FOR_EACH_FRAME (tail, frame)
4108 { 4108 {
4109 Lisp_Object frame, bar, condemned; 4109 Lisp_Object bar, condemned;
4110
4111 frame = XCAR (tail);
4112 /* All elements of Vframe_list should be frames. */
4113 if (! FRAMEP (frame))
4114 emacs_abort ();
4115 4110
4116 if (! FRAME_X_P (XFRAME (frame))) 4111 if (! FRAME_X_P (XFRAME (frame)))
4117 continue; 4112 continue;
@@ -4143,20 +4138,16 @@ x_window_to_scroll_bar (Display *display, Window window_id)
4143static Widget 4138static Widget
4144x_window_to_menu_bar (Window window) 4139x_window_to_menu_bar (Window window)
4145{ 4140{
4146 Lisp_Object tail; 4141 Lisp_Object tail, frame;
4147 4142
4148 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 4143 FOR_EACH_FRAME (tail, frame)
4149 { 4144 if (FRAME_X_P (XFRAME (frame)))
4150 if (FRAME_X_P (XFRAME (XCAR (tail)))) 4145 {
4151 { 4146 Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget;
4152 Lisp_Object frame = XCAR (tail);
4153 Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget;
4154
4155 if (menu_bar && xlwmenu_window_p (menu_bar, window))
4156 return menu_bar;
4157 }
4158 }
4159 4147
4148 if (menu_bar && xlwmenu_window_p (menu_bar, window))
4149 return menu_bar;
4150 }
4160 return NULL; 4151 return NULL;
4161} 4152}
4162 4153
@@ -10868,10 +10859,10 @@ default is nil, which is the same as `super'. */);
10868 10859
10869 DEFVAR_LISP ("x-keysym-table", Vx_keysym_table, 10860 DEFVAR_LISP ("x-keysym-table", Vx_keysym_table,
10870 doc: /* Hash table of character codes indexed by X keysym codes. */); 10861 doc: /* Hash table of character codes indexed by X keysym codes. */);
10871 Vx_keysym_table = make_hash_table (Qeql, make_number (900), 10862 Vx_keysym_table = make_hash_table (hashtest_eql, make_number (900),
10872 make_float (DEFAULT_REHASH_SIZE), 10863 make_float (DEFAULT_REHASH_SIZE),
10873 make_float (DEFAULT_REHASH_THRESHOLD), 10864 make_float (DEFAULT_REHASH_THRESHOLD),
10874 Qnil, Qnil, Qnil); 10865 Qnil);
10875} 10866}
10876 10867
10877#endif /* HAVE_X_WINDOWS */ 10868#endif /* HAVE_X_WINDOWS */
diff --git a/src/xterm.h b/src/xterm.h
index 4bc8f9813ed..6ef3d11fe48 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -890,10 +890,8 @@ struct scroll_bar
890 by this structure. */ 890 by this structure. */
891 891
892/* For an event of kind SELECTION_REQUEST_EVENT, 892/* For an event of kind SELECTION_REQUEST_EVENT,
893 this structure really describes the contents. 893 this structure really describes the contents. */
894 **Don't make this struct longer!** 894
895 If it overlaps the frame_or_window field of struct input_event,
896 that will cause GC to crash. */
897struct selection_input_event 895struct selection_input_event
898{ 896{
899 int kind; 897 int kind;
diff --git a/test/ChangeLog b/test/ChangeLog
index 72b44747bac..44c013e9887 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,14 @@
12012-11-13 Dmitry Gutov <dgutov@yandex.ru>
2
3 * automated/ruby-mode-tests.el (ruby-heredoc-font-lock)
4 (ruby-singleton-class-no-heredoc-font-lock)
5 (ruby-add-log-current-method-examples): New tests.
6 (ruby-test-string): Extract from ruby-should-indent-buffer.
7
82012-11-12 Stefan Monnier <monnier@iro.umontreal.ca>
9
10 * automated/advice-tests.el: New tests.
11
12012-10-14 Eli Zaretskii <eliz@gnu.org> 122012-10-14 Eli Zaretskii <eliz@gnu.org>
2 13
3 * automated/compile-tests.el (compile-tests--test-regexps-data): 14 * automated/compile-tests.el (compile-tests--test-regexps-data):
diff --git a/test/automated/advice-tests.el b/test/automated/advice-tests.el
new file mode 100644
index 00000000000..9f9719fdcfc
--- /dev/null
+++ b/test/automated/advice-tests.el
@@ -0,0 +1,73 @@
1;;; advice-tests.el --- Test suite for the new advice thingy.
2
3;; Copyright (C) 2012 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;;; Code:
23
24(defvar advice-tests--data
25 '(((defun sm-test1 (x) (+ x 4))
26 (sm-test1 6) 10)
27 ((advice-add 'sm-test1 :around (lambda (f y) (* (funcall f y) 5)))
28 (sm-test1 6) 50)
29 ((defun sm-test1 (x) (+ x 14))
30 (sm-test1 6) 100)
31 ((null (get 'sm-test1 'defalias-fset-function)) nil)
32 ((advice-remove 'sm-test1 (lambda (f y) (* (funcall f y) 5)))
33 (sm-test1 6) 20)
34 ((null (get 'sm-test1 'defalias-fset-function)) t)
35
36 ((defun sm-test2 (x) (+ x 4))
37 (sm-test2 6) 10)
38 ((defadvice sm-test2 (around sm-test activate)
39 ad-do-it (setq ad-return-value (* ad-return-value 5)))
40 (sm-test2 6) 50)
41 ((ad-deactivate 'sm-test2)
42 (sm-test2 6) 10)
43 ((ad-activate 'sm-test2)
44 (sm-test2 6) 50)
45 ((defun sm-test2 (x) (+ x 14))
46 (sm-test2 6) 100)
47 ((null (get 'sm-test2 'defalias-fset-function)) nil)
48 ((ad-remove-advice 'sm-test2 'around 'sm-test)
49 (sm-test2 6) 100)
50 ((ad-activate 'sm-test2)
51 (sm-test2 6) 20)
52 ((null (get 'sm-test2 'defalias-fset-function)) t)
53
54 ((advice-add 'sm-test3 :around
55 (lambda (f &rest args) `(toto ,(apply f args)))
56 '((name . wrap-with-toto)))
57 (defmacro sm-test3 (x) `(call-test3 ,x))
58 (macroexpand '(sm-test3 56)) (toto (call-test3 56)))
59
60 ))
61
62(ert-deftest advice-tests ()
63 "Test advice code."
64 (with-temp-buffer
65 (dolist (test advice-tests--data)
66 (let ((res (eval `(progn ,@(butlast test)))))
67 (should (equal (car (last test)) res))))))
68
69;; Local Variables:
70;; no-byte-compile: t
71;; End:
72
73;;; advice-tests.el ends here.
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index ba3040577b1..0e41b2ba1e2 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -36,11 +36,13 @@
36 36
37The whitespace before and including \"|\" on each line is removed." 37The whitespace before and including \"|\" on each line is removed."
38 (with-temp-buffer 38 (with-temp-buffer
39 (cl-flet ((fix-indent (s) (replace-regexp-in-string "^[ \t]*|" "" s))) 39 (insert (ruby-test-string content))
40 (insert (fix-indent content)) 40 (ruby-mode)
41 (ruby-mode) 41 (indent-region (point-min) (point-max))
42 (indent-region (point-min) (point-max)) 42 (should (string= (ruby-test-string expected) (buffer-string)))))
43 (should (string= (fix-indent expected) (buffer-string)))))) 43
44(defun ruby-test-string (s &rest args)
45 (apply 'format (replace-regexp-in-string "^[ \t]*|" "" s) args))
44 46
45(defun ruby-assert-state (content &rest values-plist) 47(defun ruby-assert-state (content &rest values-plist)
46 "Assert syntax state values at the end of CONTENT. 48 "Assert syntax state values at the end of CONTENT.
@@ -76,6 +78,14 @@ VALUES-PLIST is a list with alternating index and value elements."
76 (ruby-assert-state "foo <<asd\n" 3 ?\n) 78 (ruby-assert-state "foo <<asd\n" 3 ?\n)
77 (ruby-assert-state "class <<asd\n" 3 nil)) 79 (ruby-assert-state "class <<asd\n" 3 nil))
78 80
81(ert-deftest ruby-heredoc-font-lock ()
82 (let ((s "foo <<eos.gsub('^ *', '')"))
83 (ruby-assert-face s 9 'font-lock-string-face)
84 (ruby-assert-face s 10 nil)))
85
86(ert-deftest ruby-singleton-class-no-heredoc-font-lock ()
87 (ruby-assert-face "class<<a" 8 nil))
88
79(ert-deftest ruby-deep-indent () 89(ert-deftest ruby-deep-indent ()
80 (let ((ruby-deep-arglist nil) 90 (let ((ruby-deep-arglist nil)
81 (ruby-deep-indent-paren '(?\( ?\{ ?\[ ?\] t))) 91 (ruby-deep-indent-paren '(?\( ?\{ ?\[ ?\] t)))
@@ -202,13 +212,13 @@ VALUES-PLIST is a list with alternating index and value elements."
202 | end 212 | end
203 |")) 213 |"))
204 214
205(ert-deftest ruby-move-to-block-stops-at-opening () 215(ert-deftest ruby-move-to-block-stops-at-indentation ()
206 (with-temp-buffer 216 (with-temp-buffer
207 (insert "def f\nend") 217 (insert "def f\nend")
208 (beginning-of-line) 218 (beginning-of-line)
209 (ruby-mode) 219 (ruby-mode)
210 (ruby-move-to-block -1) 220 (ruby-move-to-block -1)
211 (should (looking-at "f$")))) 221 (should (looking-at "^def"))))
212 222
213(ert-deftest ruby-toggle-block-to-do-end () 223(ert-deftest ruby-toggle-block-to-do-end ()
214 (with-temp-buffer 224 (with-temp-buffer
@@ -253,6 +263,26 @@ VALUES-PLIST is a list with alternating index and value elements."
253 (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16 263 (ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16
254 'font-lock-variable-name-face)) 264 'font-lock-variable-name-face))
255 265
266(ert-deftest ruby-add-log-current-method-examples ()
267 (let ((pairs '(("foo" . "#foo")
268 ("C.foo" . ".foo")
269 ("self.foo" . ".foo"))))
270 (loop for (name . value) in pairs
271 do (with-temp-buffer
272 (insert (ruby-test-string
273 "module M
274 | class C
275 | def %s
276 | end
277 | end
278 |end"
279 name))
280 (ruby-mode)
281 (search-backward "def")
282 (forward-line)
283 (should (string= (ruby-add-log-current-method)
284 (format "M::C%s" value)))))))
285
256(provide 'ruby-mode-tests) 286(provide 'ruby-mode-tests)
257 287
258;;; ruby-mode-tests.el ends here 288;;; ruby-mode-tests.el ends here