changeset 110001:87dd0fd298be

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sun, 22 Aug 2010 22:56:05 +0000
parents 757182d1d4cb (current diff) ce960720ed3f (diff)
children cb10025e02fe
files lisp/vc/add-log.el src/unexcoff.c
diffstat 72 files changed, 971 insertions(+), 1302 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Aug 19 22:47:51 2010 +0000
+++ b/ChangeLog	Sun Aug 22 22:56:05 2010 +0000
@@ -1,3 +1,7 @@
+2010-08-18  Joakim Verona  <joakim@verona.se>
+
+	* Makefile.in, configure.in: Checks for ImageMagick.
+
 2010-08-10  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* configure.in (AC_PREREQ): Require autoconf 2.65.
@@ -139,21 +143,6 @@
 
 	* Makefile.in (install-arch-indep): Delete any old info .gz files first.
 
-2010-06-12 Joakim Verona <joakim@verona.se>
-
-        * image.c: Add support for ImageMagick. When HAVE_IMAGEMAGICK is
-        defined:
-        (imagemagick_image_p): New function to test for ImageMagic img.
-        (imagemagick_load): New function to load ImageMagick img.
-        (imagemagick_load_image): New function, helper for imagemagick_load
-        (imagemagick-types): New function.
-        (Qimagemagick): New Lisp_object.
-	(imagemagick-render-type): New var, decides which renderer to use
-        * image.el:
-        (imagemagick-types-inhibit): New var.
-        (imagemagick-register-types): New function.
-        * config.in, Makefile.in, configure.in
-
 2010-06-11  Glenn Morris  <rgm@gnu.org>
 
 	* configure.in (--without-compress-info): New option.
--- a/admin/unidata/Makefile.in	Thu Aug 19 22:47:51 2010 +0000
+++ b/admin/unidata/Makefile.in	Sun Aug 22 22:56:05 2010 +0000
@@ -21,7 +21,7 @@
 
 EMACS = ../../src/emacs
 DSTDIR = ../../lisp/international
-RUNEMACS = ${EMACS} -Q --multibyte -batch
+RUNEMACS = ${EMACS} -Q -batch
 
 all: ${DSTDIR}/charprop.el ../../src/biditype.h ../../src/bidimirror.h
 
--- a/admin/unidata/makefile.w32-in	Thu Aug 19 22:47:51 2010 +0000
+++ b/admin/unidata/makefile.w32-in	Sun Aug 22 22:56:05 2010 +0000
@@ -27,7 +27,7 @@
 # lisp/subdirs.el is not generated yet when the commands below run.
 EMACSLOADPATH = $(lisp);$(lisp)/international;$(lisp)/emacs-lisp
 # Quote EMACS so it could be a file name with embedded whitespace
-RUNEMACS = "$(EMACS)" -Q --multibyte -batch
+RUNEMACS = "$(EMACS)" -Q -batch
 
 all: $(DSTDIR)/charprop.el ../../src/biditype.h ../../src/bidimirror.h
 
--- a/configure	Thu Aug 19 22:47:51 2010 +0000
+++ b/configure	Sun Aug 22 22:56:05 2010 +0000
@@ -8726,7 +8726,7 @@
   fi
 
 
-$as_echo "#define HAVE_MAGICKEXPORTIMAGEPIXELS 1" >>confdefs.h
+$as_echo "#define HAVE_MAGICKEXPORTIMAGEPIXELS 0" >>confdefs.h
 
 
 
--- a/configure.in	Thu Aug 19 22:47:51 2010 +0000
+++ b/configure.in	Sun Aug 22 22:56:05 2010 +0000
@@ -1852,7 +1852,7 @@
     LIBS="$IMAGEMAGICK_LIBS $LIBS"
   fi
 
-  AC_DEFINE(HAVE_MAGICKEXPORTIMAGEPIXELS, 1, [Define to 1 if MagickExportImagePixels is defined.])
+  AC_DEFINE(HAVE_MAGICKEXPORTIMAGEPIXELS, 0, [Define to 1 if MagickExportImagePixels is defined.])
   AC_CHECK_FUNCS_ONCE(MagickExportImagePixels)
   
 fi
--- a/doc/emacs/ChangeLog	Thu Aug 19 22:47:51 2010 +0000
+++ b/doc/emacs/ChangeLog	Sun Aug 22 22:56:05 2010 +0000
@@ -1,3 +1,7 @@
+2010-08-21  Glenn Morris  <rgm@gnu.org>
+
+	* misc.texi (Amusements): Mention bubbles and animate.
+
 2010-07-31  Eli Zaretskii  <eliz@gnu.org>
 
 	* files.texi (Visiting): Add more index entries for
--- a/doc/emacs/misc.texi	Thu Aug 19 22:47:51 2010 +0000
+++ b/doc/emacs/misc.texi	Sun Aug 22 22:56:05 2010 +0000
@@ -2784,6 +2784,10 @@
   If you want a little more personal involvement, try @kbd{M-x gomoku},
 which plays the game Go Moku with you.
 
+@findex bubbles
+  @kbd{M-x bubbles} is a game in which the object is to remove as many
+bubbles as you can in the smallest number of moves.
+
 @findex blackbox
 @findex mpuz
 @findex 5x5
@@ -2832,6 +2836,11 @@
 @kbd{M-x solitaire} plays a game of solitaire in which you jump pegs
 across other pegs.
 
+@findex animate-birthday-present
+@cindex animate
+The @code{animate} package makes text dance.  For an example, try
+@kbd{M-x animate-birthday-present}.
+
 @findex studlify-region
 @cindex StudlyCaps
 @kbd{M-x studlify-region} studlify-cases the region, producing
--- a/doc/lispref/ChangeLog	Thu Aug 19 22:47:51 2010 +0000
+++ b/doc/lispref/ChangeLog	Sun Aug 22 22:56:05 2010 +0000
@@ -1,3 +1,23 @@
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* nonascii.texi (Text Representations):
+	* loading.texi (Loading Non-ASCII):
+	* compile.texi (Byte Compilation): Don't mention obsolete
+	--unibyte command-line argument.
+
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* modes.texi (Defining Minor Modes): Doc fix (Bug#6880).
+
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* objects.texi (Bool-Vector Type): Minor definition tweak (Bug#6878).
+
+2010-08-20  Eli Zaretskii  <eliz@gnu.org>
+
+	* commands.texi (Misc Events): Add cross-references to where
+	POSITION of a mouse event is described in detail.
+
 2010-08-08  Christoph  <cschol2112@googlemail.com>
 
 	* control.texi (Handling Errors) <error-message-string>: Fix arg name.
--- a/doc/lispref/commands.texi	Thu Aug 19 22:47:51 2010 +0000
+++ b/doc/lispref/commands.texi	Sun Aug 22 22:56:05 2010 +0000
@@ -1616,7 +1616,8 @@
 usual meaning is a kind of scroll or zoom.
 
 The element @var{position} is a list describing the position of the
-event, in the same format as used in a mouse-click event.
+event, in the same format as used in a mouse-click event (@pxref{Click
+Events}).
 
 @vindex mouse-wheel-up-event
 @vindex mouse-wheel-down-event
@@ -1633,9 +1634,10 @@
 dropped onto an Emacs frame.
 
 The element @var{position} is a list describing the position of the
-event, in the same format as used in a mouse-click event, and
-@var{files} is the list of file names that were dragged and dropped.
-The usual way to handle this event is by visiting these files.
+event, in the same format as used in a mouse-click event (@pxref{Click
+Events}), and @var{files} is the list of file names that were dragged
+and dropped.  The usual way to handle this event is by visiting these
+files.
 
 This kind of event is generated, at present, only on some kinds of
 systems.
--- a/doc/lispref/compile.texi	Thu Aug 19 22:47:51 2010 +0000
+++ b/doc/lispref/compile.texi	Sun Aug 22 22:56:05 2010 +0000
@@ -22,12 +22,6 @@
 transportable from machine to machine without recompilation.  It is not,
 however, as fast as true compiled code.
 
-  Compiling a Lisp file with the Emacs byte compiler always reads the
-file as multibyte text, even if Emacs was started with @samp{--unibyte},
-unless the file specifies otherwise.  This is so that compilation gives
-results compatible with running the same file without compilation.
-@xref{Loading Non-ASCII}.
-
   In general, any version of Emacs can run byte-compiled code produced
 by recent earlier versions of Emacs, but the reverse is not true.
 
--- a/doc/lispref/loading.texi	Thu Aug 19 22:47:51 2010 +0000
+++ b/doc/lispref/loading.texi	Sun Aug 22 22:56:05 2010 +0000
@@ -367,13 +367,6 @@
 unibyte text, and its string constants will be unibyte strings.
 @xref{Coding Systems}.
 
-  To make the results more predictable, Emacs always performs decoding
-into the multibyte representation when loading Lisp files, even if it
-was started with the @samp{--unibyte} option.  This means that string
-constants with non-@acronym{ASCII} characters translate into multibyte
-strings.  The only exception is when a particular file specifies no
-decoding.
-
   The reason Emacs is designed this way is so that Lisp programs give
 predictable results, regardless of how Emacs was started.  In addition,
 this enables programs that depend on using multibyte text to work even
--- a/doc/lispref/modes.texi	Thu Aug 19 22:47:51 2010 +0000
+++ b/doc/lispref/modes.texi	Sun Aug 22 22:56:05 2010 +0000
@@ -1411,14 +1411,20 @@
 when the mode is enabled; if it is @code{nil}, the mode is not displayed
 in the mode line.
 
-The optional argument @var{keymap} specifies the keymap for the minor mode.
-It can be a variable name, whose value is the keymap, or it can be an alist
-specifying bindings in this form:
+The optional argument @var{keymap} specifies the keymap for the minor
+mode.  If non-@code{nil}, it should be a variable name (whose value is
+a keymap), a keymap, or an alist of the form
 
 @example
 (@var{key-sequence} . @var{definition})
 @end example
 
+@noindent
+where each @var{key-sequence} and @var{definition} are arguments
+suitable for passing to @code{define-key} (@pxref{Changing Key
+Bindings}).  If @var{keymap} is a keymap or an alist, this also
+defines the variable @code{@var{mode}-map}.
+
 The above three arguments @var{init-value}, @var{lighter}, and
 @var{keymap} can be (partially) omitted when @var{keyword-args} are
 used.  The @var{keyword-args} consist of keywords followed by
--- a/doc/lispref/nonascii.texi	Thu Aug 19 22:47:51 2010 +0000
+++ b/doc/lispref/nonascii.texi	Sun Aug 22 22:56:05 2010 +0000
@@ -102,9 +102,6 @@
 
 You cannot set this variable directly; instead, use the function
 @code{set-buffer-multibyte} to change a buffer's representation.
-
-The @samp{--unibyte} command line option does its job by setting the
-default value to @code{nil} early in startup.
 @end defvar
 
 @defun position-bytes position
--- a/doc/lispref/objects.texi	Thu Aug 19 22:47:51 2010 +0000
+++ b/doc/lispref/objects.texi	Sun Aug 22 22:56:05 2010 +0000
@@ -1189,8 +1189,8 @@
 @node Bool-Vector Type
 @subsection Bool-Vector Type
 
-  A @dfn{bool-vector} is a one-dimensional array of elements that
-must be @code{t} or @code{nil}.
+  A @dfn{bool-vector} is a one-dimensional array whose elements must
+be @code{t} or @code{nil}.
 
   The printed representation of a bool-vector is like a string, except
 that it begins with @samp{#&} followed by the length.  The string
--- a/etc/NEWS	Thu Aug 19 22:47:51 2010 +0000
+++ b/etc/NEWS	Sun Aug 22 22:56:05 2010 +0000
@@ -59,6 +59,10 @@
 
 * Startup Changes in Emacs 24.1
 
+** The --unibyte, --multibyte, --no-multibyte, and --no-unibyte
+command line arguments no longer have any effect.  (They were declared
+obsolete in Emacs 23.)
+
 
 * Changes in Emacs 24.1
 
--- a/leim/ChangeLog	Thu Aug 19 22:47:51 2010 +0000
+++ b/leim/ChangeLog	Sun Aug 22 22:56:05 2010 +0000
@@ -1,3 +1,26 @@
+2010-08-15  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* quail/vntelex.el ("vietnamese-telex"): Doc fix.
+
+	* quail/georgian.el: Remove extra backslashes.
+
+2010-08-14  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* quail/arabic.el: Quote [ and ].
+	* quail/latin-ltx.el: Likewise.
+
+	* quail/greek.el ("greek", "greek-postfix"): Change string to
+	character.
+
+2010-08-13  Kenichi Handa  <handa@m17n.org>
+
+	* quail/greek.el ("greek-postfix"): Add rules for Greek style
+	quotes.
+
+2010-08-09  Kenichi Handa  <handa@m17n.org>
+
+	* quail/greek.el ("greek"): Add rules for Greek style quotes.
+
 2010-05-15  Glenn Morris  <rgm@gnu.org>
 
 	* Makefile.in (install): Remove references to CVS-related files.
--- a/leim/Makefile.in	Thu Aug 19 22:47:51 2010 +0000
+++ b/leim/Makefile.in	Sun Aug 22 22:56:05 2010 +0000
@@ -48,7 +48,7 @@
 
 # How to run Emacs.
 RUN-EMACS = EMACSLOADPATH=$(buildlisppath) LC_ALL=C \
-	${BUILT-EMACS} -batch --no-init-file --no-site-file --multibyte
+	${BUILT-EMACS} -batch --no-init-file --no-site-file
 
 # Subdirectories to be made if ${srcdir} is different from the current
 # directory.
--- a/leim/makefile.w32-in	Thu Aug 19 22:47:51 2010 +0000
+++ b/leim/makefile.w32-in	Sun Aug 22 22:56:05 2010 +0000
@@ -37,7 +37,7 @@
 buildlisppath=$(CURDIR)/$(dot)$(dot)/lisp
 
 # How to run Emacs.
-RUN_EMACS = "$(BUILT_EMACS)" -batch --no-init-file --no-site-file --multibyte
+RUN_EMACS = "$(BUILT_EMACS)" -batch --no-init-file --no-site-file
 
 # Set EMACSLOADPATH correctly (already defined in environment).
 EMACSLOADPATH=$(buildlisppath)
--- a/leim/quail/arabic.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/leim/quail/arabic.el	Sun Aug 22 22:56:05 2010 +0000
@@ -57,8 +57,8 @@
 
  ("A" ?ِ)
  ("S" ?ٍ)
- ("D" ?])
- ("F" ?[)
+ ("D" ?\])
+ ("F" ?\[)
  ("G" ["لأ"])
  ("H" ?أ)
  ("J" ?ـ)
--- a/leim/quail/georgian.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/leim/quail/georgian.el	Sun Aug 22 22:56:05 2010 +0000
@@ -51,7 +51,7 @@
  ("n" ?ნ)
  ("o" ?ო)
  (".p" ?პ)
- ("\+z"	?ჟ)
+ ("+z" ?ჟ)
  ("r" ?რ)
  ("s" ?ს)
  (".t" ?ტ)
@@ -60,14 +60,14 @@
  ("k" ?ქ)
  (".g" ?ღ)
  ("q" ?ყ)
- ("\+s"	?შ)
- ("\+c"	?ჩ)
+ ("+s" ?შ)
+ ("+c" ?ჩ)
  ("c" ?ც)
  ("j" ?ძ)
  (".c" ?წ)
- (".\+c" ?ჭ)
+ (".+c" ?ჭ)
  ("x" ?ხ)
- ("\+j"	?ჯ)
+ ("+j" ?ჯ)
  ("h" ?ჰ)
  ("q1" ?ჴ)
  ("e0" ?ჱ)
--- a/leim/quail/greek.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/leim/quail/greek.el	Sun Aug 22 22:56:05 2010 +0000
@@ -1279,7 +1279,9 @@
  (";:i" ?,F@(B)
  (":;i" ?,F@(B)
  (";:y" ?,F`(B)
- (":;y" ?,F`(B))
+ (":;y" ?,F`(B)
+ (";<" ?$(Q)((B)
+ (";>" ?$(Q)2(B))
 
 (quail-define-package
  "greek-postfix" "GreekPost" ",FX(B" nil
@@ -1419,7 +1421,12 @@
  ("i:;" ?,F@(B)
  ("i;:" ?,F@(B)
  ("y:;" ?,F`(B)
- ("y;:" ?,F`(B))
+ ("y;:" ?,F`(B)
+ ;; These two are asymmetric with ";<" and ";>" in "greek" input
+ ;; method.  But, as the other Latin postfix methods adopt "<<" and
+ ;; ">>", it may be better to follow them.
+ ("<<" ?$(Q)((B)
+ (">>" ?$(Q)2(B))
 
 
 ;; arch-tag: 2a37e042-db1b-4ecf-b755-117775a3c150
--- a/leim/quail/latin-ltx.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/leim/quail/latin-ltx.el	Sun Aug 22 22:56:05 2010 +0000
@@ -653,7 +653,7 @@
  ("\\lambda" ?λ)
  ("\\langle" ?〈)
  ("\\lbrace" ?{)
- ("\\lbrack" ?[)
+ ("\\lbrack" ?\[)
  ("\\lceil" ?⌈)
  ("\\ldots" ?…)
  ("\\le" ?≤)
@@ -788,7 +788,7 @@
  ("\\quad" ? )
  ("\\rangle" ?〉)
  ("\\rbrace" ?})
- ("\\rbrack" ?])
+ ("\\rbrack" ?\])
  ("\\rceil" ?⌉)
  ("\\rfloor" ?⌋)
  ("\\rightarrow" ?→)
--- a/leim/quail/vntelex.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/leim/quail/vntelex.el	Sun Aug 22 22:56:05 2010 +0000
@@ -53,7 +53,7 @@
   acute         s      as -> ,1a(B
   grave         f      af -> ,1`(B
   hook above    r      ar -> ,1d(B
-  tilde         x      ax  -> ,1c(B
+  tilde         x      ax -> ,1c(B
   dot below     j      aj -> ,1U(B
 
   d bar                dd -> ,1p(B
--- a/lisp/ChangeLog	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/ChangeLog	Sun Aug 22 22:56:05 2010 +0000
@@ -1,3 +1,113 @@
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* startup.el (command-line-1): Issue warning for ignored arguments
+	--unibyte, etc (Bug#6886).
+
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs-lisp/easy-mmode.el (define-minor-mode): Doc fix (Bug#6880).
+
+2010-08-22  Leo  <sdl.web@gmail.com>
+
+	Fix buffer-list rename&refresh after after killing a buffer in ido.
+	* lisp/ido.el: Revert Óscar's.
+	(ido-kill-buffer-at-head): Exit the minibuffer with ido-exit=refresh.
+	Remember the buffers at head, rather than their name.
+	* lisp/iswitchb.el (iswitchb-kill-buffer): Re-make the list.
+
+2010-08-22  Kirk Kelsey  <kirk.kelsey@0x4b.net>  (tiny change)
+            Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/make-mode.el (makefile-fill-paragraph): Account for the
+	extra backslash added to each line (bug#6890).
+
+2010-08-22  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* subr.el (read-key): Don't echo keystrokes (bug#6883).
+
+2010-08-22  Glenn Morris  <rgm@gnu.org>
+
+	* menu-bar.el (menu-bar-games-menu): Add landmark.
+
+2010-08-22  Glenn Morris  <rgm@gnu.org>
+
+	* align.el (align-regexp): Make group and spacing arguments
+	use the interactive defaults when non-interactive.  (Bug#6698)
+
+	* mail/rmail.el (rmail-forward): Replace mail-text-start with its
+	expansion, so as not to need sendmail.
+	(mail-text-start): Remove declaration.
+	(rmail-retry-failure): Require sendmail.
+
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* subr.el (read-key): Don't hide the menu-bar entries (bug#6881).
+
+2010-08-22  Michael Albinus  <michael.albinus@gmx.de>
+
+	* progmodes/flymake.el (flymake-start-syntax-check-process):
+	Use `start-file-process' in order to let it run also on remote hosts.
+
+2010-08-22  Kenichi Handa  <handa@m17n.org>
+
+	* files.el: Add `word-wrap' as safe local variable.
+
+2010-08-22  Glenn Morris  <rgm@gnu.org>
+
+	* woman.el (woman-translate): Case matters.  (Bug#6849)
+
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* simple.el (kill-region): Doc fix (Bug#6787).
+
+2010-08-22  Glenn Morris  <rgm@gnu.org>
+
+	* calendar/diary-lib.el (diary-header-line-format):
+	Fit it to the window, not the frame.
+
+2010-08-22  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* subr.el (ignore-errors): Add debug declaration.
+
+2010-08-22  Geoff Gole  <geoffgole@gmail.com>  (tiny change)
+
+	* whitespace.el (whitespace-color-off): Remove post-command-hook
+	locally.
+
+2010-08-21  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* vc/add-log.el (add-log-file-name): Don't get confused by symlinks.
+
+2010-08-21  Chong Yidong  <cyd@stupidchicken.com>
+
+	* cus-edit.el (custom-group-value-create): Add extra newline
+	before end line (Bug#6876).
+
+2010-08-21  Chong Yidong  <cyd@stupidchicken.com>
+
+	* mouse.el (mouse-save-then-kill): Don't save region to kill ring
+	when extending it.  Before killing on the second click, check if
+	the buffer is the correct one.  Doc fix.
+	(mouse-secondary-save-then-kill): Allow usage without first
+	calling mouse-start-secondary, by defaulting to point.  Don't save
+	an empty secondary selection.  Doc fix.
+
+2010-08-21  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* whitespace.el: Fix slow cursor movement (Bug#6172).  Reported by
+	Christoph Groth <cwg@falma.de> and Liu Xin <x_liu@neusoft.com>.
+	New version 13.0.
+	(whitespace-empty-at-bob-regexp, whitespace-empty-at-eob-regexp):
+	Adjust initialization.
+	(whitespace-bob-marker, whitespace-eob-marker)
+	(whitespace-buffer-changed): New vars.
+	(whitespace-cleanup, whitespace-color-on, whitespace-color-off)
+	(whitespace-empty-at-bob-regexp, whitespace-empty-at-eob-regexp)
+	(whitespace-post-command-hook, whitespace-display-char-on):
+	Adjust code.
+	(whitespace-looking-back, whitespace-buffer-changed): New funs.
+	(whitespace-space-regexp, whitespace-tab-regexp): Eliminate funs.
+
 2010-08-19  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* files.el (locate-file-completion-table): Only list the .el and .elc
@@ -38,6 +148,17 @@
 	* emacs-lisp/autoload.el (make-autoload): Preload the macros's
 	declarations that are useful before running the macro.
 
+2010-08-18  Joakim Verona  <joakim@verona.se>
+
+	* image.el (imagemagick-types-inhibit): New variable.
+	(imagemagick-register-types): New function.
+	* image-mode.el (image-transform-properties): New function.
+	(image-transform-set-scale, image-transform-fit-to-height)
+	(image-transform-set-rotation, image-transform-set-resize)
+	(image-transform-fit-to-width, image-transform-fit-to-height):
+	New functions.
+	(image-toggle-display-image): Support image transforms.
+
 2010-08-18  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* image.el (create-animated-image): Don't add heuristic mask to image
@@ -301,7 +422,7 @@
 	(ctext-standard-encodings): New variable.
 	(ctext-non-standard-encodings-table): List only elements for
 	non-standard encodings.
-	(ctext-pre-write-conversion): Adjusted for the above change.
+	(ctext-pre-write-conversion): Adjust for the above change.
 	Check ctext-standard-encodings.
 
 	* international/mule-conf.el (compound-text): Doc fix.
@@ -3190,7 +3311,8 @@
 	* minibuffer.el (tags-completion-at-point-function): New function.
 	(completion-at-point-functions): Use it.
 
-	* cedet/semantic.el (semantic-completion-at-point-function): New function.
+	* cedet/semantic.el (semantic-completion-at-point-function):
+	New function.
 	(semantic-mode): Use semantic-completion-at-point-function for
 	completion-at-point-functions instead.
 
@@ -3240,8 +3362,8 @@
 
 2010-04-28  Chong Yidong  <cyd@stupidchicken.com>
 
-	* progmodes/bug-reference.el (bug-reference-url-format): Revert
-	2010-04-27 change due to security risk.
+	* progmodes/bug-reference.el (bug-reference-url-format):
+	Revert 2010-04-27 change due to security risk.
 
 2010-04-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
@@ -3416,8 +3538,7 @@
 
 	* ido.el (ido-init-completion-maps): For ido-switch-buffer, C-o
 	toggles the use of virtual buffers.
-	(ido-buffer-internal): Guard `ido-use-virtual-buffers' global
-	value.
+	(ido-buffer-internal): Guard `ido-use-virtual-buffers' global value.
 	(ido-toggle-virtual-buffers): New function.
 
 2010-04-21  Juanma Barranquero  <lekktu@gmail.com>
@@ -3994,7 +4115,7 @@
 
 	Enable recentf-mode if using virtual buffers.
 	* ido.el (recentf-list): Declare for byte-compiler.
-	(ido-virtual-buffers): Move up to silence byte-compiler.  Add docstring.
+	(ido-virtual-buffers): Move up to silence byte-compiler. Add docstring.
 	(ido-make-buffer-list): Simplify.
 	(ido-add-virtual-buffers-to-list): Simplify.  Enable recentf-mode.
 
@@ -5505,8 +5626,8 @@
 2010-01-21  Alan Mackenzie  <acm@muc.de>
 
 	Fix a situation where deletion of a cpp construct throws an error.
-	* progmodes/cc-engine.el (c-invalidate-state-cache): Before
-	invoking c-with-all-but-one-cpps-commented-out, check that the
+	* progmodes/cc-engine.el (c-invalidate-state-cache):
+	Before invoking c-with-all-but-one-cpps-commented-out, check that the
 	special cpp construct is still in the buffer.
 	(c-parse-state): Record the special cpp with markers, not numbers.
 
@@ -6233,7 +6354,7 @@
 
 	* ps-print.el (ps-face-attributes): It was not returning the
 	attribute face for faces specified as string.  Reported by harven
-	<harven@free.fr>.
+	<harven@free.fr>.  (Bug#5254)
 	(ps-print-version): New version 7.3.5.
 
 2009-12-18  Ulf Jasper  <ulf.jasper@web.de>
--- a/lisp/Makefile.in	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/Makefile.in	Sun Aug 22 22:56:05 2010 +0000
@@ -33,10 +33,9 @@
 # to use an absolute file name.
 EMACS = ${abs_top_builddir}/src/emacs
 
-# Command line flags for Emacs.  This must include --multibyte,
-# otherwise some files will not compile.
+# Command line flags for Emacs.
 
-EMACSOPT = -batch --no-site-file --multibyte
+EMACSOPT = -batch --no-site-file
 
 # Extra flags to pass to the byte compiler
 BYTE_COMPILE_EXTRA_FLAGS =
--- a/lisp/align.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/align.el	Sun Aug 22 22:56:05 2010 +0000
@@ -1,7 +1,7 @@
 ;;; align.el --- align text to a specific column, by regexp
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Maintainer: FSF
@@ -944,6 +944,8 @@
       (list (concat "\\(\\s-*\\)"
 		    (read-string "Align regexp: "))
 	    1 align-default-spacing nil))))
+  (or group (setq group 1))
+  (or spacing (setq spacing align-default-spacing))
   (let ((rule
 	 (list (list nil (cons 'regexp regexp)
 		     (cons 'group (abs group))
--- a/lisp/calendar/diary-lib.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/calendar/diary-lib.el	Sun Aug 22 22:56:05 2010 +0000
@@ -383,14 +383,14 @@
                      "Some text is hidden - press \"s\" in calendar \
 before edit/copy"
                    "Diary"))
-           ?\s (frame-width)))
+           ?\s (window-width)))
   "Format of the header line displayed by `diary-simple-display'.
 Only used if `diary-header-line-flag' is non-nil."
   :group 'diary
   :type 'sexp
   :initialize 'custom-initialize-default
   :set 'diary-set-header
-  :version "22.1")
+  :version "23.3")                      ; frame-width -> window-width
 
 ;; The first version of this also checked for diary-selective-display
 ;; in the non-fancy case. This was an attempt to distinguish between
--- a/lisp/cus-edit.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/cus-edit.el	Sun Aug 22 22:56:05 2010 +0000
@@ -4097,8 +4097,8 @@
 	     (custom-group-state-update widget)
 	     (progress-reporter-done reporter))
 	   ;; End line
-	   (let ((p (point)))
-	     (insert "\n")
+	   (let ((p (1+ (point))))
+	     (insert "\n\n")
 	     (put-text-property p (1+ p) 'face '(:underline t))
 	     (overlay-put (make-overlay p (1+ p))
 			  'before-string
--- a/lisp/emacs-lisp/easy-mmode.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/emacs-lisp/easy-mmode.el	Sun Aug 22 22:56:05 2010 +0000
@@ -86,25 +86,23 @@
 ;;;###autoload
 (defmacro define-minor-mode (mode doc &optional init-value lighter keymap &rest body)
   "Define a new minor mode MODE.
-This function defines the associated control variable MODE, keymap MODE-map,
-and toggle command MODE.
+This defines the control variable MODE and the toggle command MODE.
+DOC is the documentation for the mode toggle command.
 
-DOC is the documentation for the mode toggle command.
 Optional INIT-VALUE is the initial value of the mode's variable.
 Optional LIGHTER is displayed in the modeline when the mode is on.
-Optional KEYMAP is the default (defvar) keymap bound to the mode keymap.
-  If it is a list, it is passed to `easy-mmode-define-keymap'
-  in order to build a valid keymap.  It's generally better to use
-  a separate MODE-map variable than to use this argument.
-The above three arguments can be skipped if keyword arguments are
-used (see below).
+Optional KEYMAP is the default keymap bound to the mode keymap.
+  If non-nil, it should be a variable name (whose value is a keymap),
+  a keymap, or a list of arguments for `easy-mmode-define-keymap'.
+  If KEYMAP is a keymap or list, this also defines the variable MODE-map.
 
-BODY contains code to execute each time the mode is activated or deactivated.
-  It is executed after toggling the mode,
-  and before running the hook variable `MODE-hook'.
-  Before the actual body code, you can write keyword arguments (alternating
-  keywords and values).  These following keyword arguments are supported (other
-  keywords will be passed to `defcustom' if the minor mode is global):
+BODY contains code to execute each time the mode is enabled or disabled.
+  It is executed after toggling the mode, and before running MODE-hook.
+  Before the actual body code, you can write keyword arguments, i.e.
+  alternating keywords and values.  These following special keywords
+  are supported (other keywords are passed to `defcustom' if the minor
+  mode is global):
+
 :group GROUP	Custom group name to use in all generated `defcustom' forms.
 		Defaults to MODE without the possible trailing \"-mode\".
 		Don't use this default group name unless you have written a
--- a/lisp/files.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/files.el	Sun Aug 22 22:56:05 2010 +0000
@@ -2805,6 +2805,7 @@
 	(no-update-autoloads     . booleanp)
 	(tab-width               . integerp)   ;; C source code
 	(truncate-lines          . booleanp)   ;; C source code
+	(word-wrap               . booleanp) ;; C source code
 	(bidi-display-reordering . booleanp))) ;; C source code
 
 (put 'bidi-paragraph-direction 'safe-local-variable
--- a/lisp/ido.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/ido.el	Sun Aug 22 22:56:05 2010 +0000
@@ -1070,11 +1070,11 @@
 ;; Stores the current list of items that will be searched through.
 ;; The list is ordered, so that the most interesting item comes first,
 ;; although by default, the files visible in the current frame are put
-;; at the end of the list.
-(defvar ido-cur-list nil)
+;; at the end of the list.  Created by `ido-make-item-list'.
+(defvar ido-cur-list)
 
 ;; Stores the choice list for ido-completing-read
-(defvar ido-choice-list nil)
+(defvar ido-choice-list)
 
 ;; Stores the list of items which are ignored when building
 ;; `ido-cur-list'.  It is in no specific order.
@@ -3400,11 +3400,9 @@
     (if ido-temp-list
 	(nconc ido-temp-list ido-current-buffers)
       (setq ido-temp-list ido-current-buffers))
-    (when (and default (buffer-live-p (get-buffer default)))
-      (setq ido-temp-list
-	    (cons default (delete default ido-temp-list))))
-    (if ido-use-virtual-buffers
-	(ido-add-virtual-buffers-to-list))
+    (if default
+        (setq ido-temp-list
+              (cons default (delete default ido-temp-list))))
     (run-hooks 'ido-make-buffer-list-hook)
     ido-temp-list))
 
@@ -3672,7 +3670,6 @@
   ;; Used by `ido-get-buffers-in-frames' to walk through all windows
   (let ((buf (buffer-name (window-buffer win))))
 	(unless (or (member buf ido-bufs-in-frame)
-		    (minibufferp buf)
 		    (member buf ido-ignore-item-temp-list))
 	  ;; Only add buf if it is not already in list.
 	  ;; This prevents same buf in two different windows being
@@ -3913,27 +3910,6 @@
 	      ;;(add-hook 'completion-setup-hook 'completion-setup-function)
 	      (display-completion-list completion-list)))))))
 
-(defun ido-kill-buffer-internal (buf)
-  "Kill buffer BUF and rebuild ido's buffer list if needed."
-  (if (not (kill-buffer buf))
-      ;; buffer couldn't be killed.
-      (setq ido-rescan t)
-    ;; else buffer was killed so remove name from list.
-    (setq ido-cur-list (delq buf ido-cur-list))
-    ;; Some packages, like uniquify.el, may rename buffers when one
-    ;; is killed, so we need to test this condition to avoid using
-    ;; an outdated list of buffer names. We don't want to always
-    ;; rebuild the list of buffers, as this alters the previous
-    ;; buffer order that the user was seeing on the prompt. However,
-    ;; when we rebuild the list, we try to keep the previous second
-    ;; buffer as the first one.
-    (catch 'update
-      (dolist (b ido-cur-list)
-	(unless (get-buffer b)
-	  (setq ido-cur-list (ido-make-buffer-list (cadr ido-matches)))
-	  (setq ido-rescan t)
-	  (throw 'update nil))))))
-
 ;;; KILL CURRENT BUFFER
 (defun ido-kill-buffer-at-head ()
   "Kill the buffer at the head of `ido-matches'.
@@ -3942,15 +3918,26 @@
   (if (not (eobp))
       (delete-region (point) (line-end-position))
     (let ((enable-recursive-minibuffers t)
-	  (buf (ido-name (car ido-matches))))
-      (when buf
-	(ido-kill-buffer-internal buf)
-	;; Check if buffer still exists.
-	(if (get-buffer buf)
-	    ;; buffer couldn't be killed.
+	  (buf (ido-name (car ido-matches)))
+	  (nextbuf (cadr ido-matches)))
+      (when (get-buffer buf)
+	;; If next match names a buffer use the buffer object; buffer
+	;; name may be changed by packages such as uniquify; mindful
+	;; of virtual buffers.
+	(when (and nextbuf (get-buffer nextbuf))
+	  (setq nextbuf (get-buffer nextbuf)))
+	(if (null (kill-buffer buf))
+	    ;; Buffer couldn't be killed.
 	    (setq ido-rescan t)
-	  ;; else buffer was killed so remove name from list.
-	  (setq ido-cur-list (delq buf ido-cur-list)))))))
+	  ;; Else `kill-buffer' succeeds so re-make the buffer list
+	  ;; taking into account packages like uniquify may rename
+	  ;; buffers.
+	  (if (bufferp nextbuf)
+	      (setq nextbuf (buffer-name nextbuf)))
+	  (setq ido-default-item nextbuf
+		ido-text-init ido-text
+		ido-exit 'refresh)
+	  (exit-minibuffer))))))
 
 ;;; DELETE CURRENT FILE
 (defun ido-delete-file-at-head ()
@@ -3988,7 +3975,7 @@
      ((eq method 'kill)
       (if record
 	  (ido-record-command 'kill-buffer buffer))
-      (ido-kill-buffer-internal buffer))
+      (kill-buffer buffer))
 
      ((eq method 'other-window)
       (if record
--- a/lisp/international/mule.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/international/mule.el	Sun Aug 22 22:56:05 2010 +0000
@@ -326,8 +326,7 @@
 	    (with-current-buffer buffer
               ;; So that we don't get completely screwed if the
               ;; file is encoded in some complicated character set,
-              ;; read it with real decoding, as a multibyte buffer,
-              ;; even if this is a --unibyte Emacs session.
+              ;; read it with real decoding, as a multibyte buffer.
               (set-buffer-multibyte t)
 	      ;; Don't let deactivate-mark remain set.
 	      (let (deactivate-mark)
@@ -346,12 +345,7 @@
 	    (eval-buffer buffer nil
 			 ;; This is compatible with what `load' does.
 			 (if purify-flag file fullname)
-			 ;; If this Emacs is running with --unibyte,
-			 ;; convert multibyte strings to unibyte
-			 ;; after reading them.
-;;			 (not (default-value 'enable-multibyte-characters))
-			 nil t
-			 ))
+			 nil t))
 	(let (kill-buffer-hook kill-buffer-query-functions)
 	  (kill-buffer buffer)))
       (do-after-load-evaluation fullname)
--- a/lisp/iswitchb.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/iswitchb.el	Sun Aug 22 22:56:05 2010 +0000
@@ -1027,8 +1027,8 @@
 (defun iswitchb-kill-buffer ()
   "Kill the buffer at the head of `iswitchb-matches'."
   (interactive)
-  (let ( (enable-recursive-minibuffers t)
-	 buf)
+  (let ((enable-recursive-minibuffers t)
+        buf)
 
     (setq buf (car iswitchb-matches))
     ;; check to see if buf is non-nil.
@@ -1042,8 +1042,10 @@
 	  (if (get-buffer buf)
 	      ;; buffer couldn't be killed.
 	      (setq iswitchb-rescan t)
-	    ;; else buffer was killed so remove name from list.
-	    (setq iswitchb-buflist  (delq buf iswitchb-buflist)))))))
+	    ;; Else `kill-buffer' succeeds so re-make the buffer list
+	    ;; taking into account packages like uniquify may rename
+	    ;; buffers
+	    (iswitchb-make-buflist iswitchb-default))))))
 
 ;;; VISIT CHOSEN BUFFER
 (defun iswitchb-visit-buffer (buffer)
--- a/lisp/mail/rmail.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/mail/rmail.el	Sun Aug 22 22:56:05 2010 +0000
@@ -191,8 +191,6 @@
   :group 'rmail-retrieve
   :type '(repeat (directory)))
 
-(declare-function mail-position-on-field "sendmail" (field &optional soft))
-(declare-function mail-text-start "sendmail" ())
 (declare-function rmail-dont-reply-to "mail-utils" (destinations))
 (declare-function rmail-update-summary "rmailsum" (&rest ignore))
 
@@ -1643,8 +1641,6 @@
 (declare-function rmail-summary-mark-deleted "rmailsum" (&optional n undel))
 (declare-function rfc822-addresses "rfc822" (header-text))
 (declare-function mail-abbrev-make-syntax-table "mailabbrev.el" ())
-(declare-function mail-sendmail-delimit-header "sendmail" ())
-(declare-function mail-header-end "sendmail" ())
 
 ;; RLK feature not added in this version:
 ;; argument specifies inbox file or files in various ways.
@@ -3686,7 +3682,8 @@
 	  ;; The mail buffer is now current.
 	  (save-excursion
 	    ;; Insert after header separator--before signature if any.
-	    (goto-char (mail-text-start))
+	    (rfc822-goto-eoh)
+	    (forward-line 1)
 	    (if (or rmail-enable-mime rmail-enable-mime-composing)
 		(funcall rmail-insert-mime-forwarded-message-function
 			 forward-buffer)
@@ -3841,6 +3838,10 @@
 			   (1- (point))
 			 (point-max)))))))
 
+(declare-function mail-sendmail-delimit-header "sendmail" ())
+(declare-function mail-header-end "sendmail" ())
+(declare-function mail-position-on-field "sendmail" (field &optional soft))
+
 (defun rmail-retry-failure ()
   "Edit a mail message which is based on the contents of the current message.
 For a message rejected by the mail system, extract the interesting headers and
@@ -3932,6 +3933,8 @@
 	    (goto-char (point-min))
 	    (if bounce-indent
 		(indent-rigidly (point-min) (point-max) bounce-indent))
+	    ;; FIXME better to replace sendmail functions.
+	    (require 'sendmail)
 	    (mail-sendmail-delimit-header)
 	    (save-restriction
 	      (narrow-to-region (point-min) (mail-header-end))
--- a/lisp/makefile.w32-in	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/makefile.w32-in	Sun Aug 22 22:56:05 2010 +0000
@@ -32,10 +32,9 @@
 
 EMACS = $(THISDIR)/../bin/emacs.exe
 
-# Command line flags for Emacs.  This must include --multibyte,
-# otherwise some files will not compile.
+# Command line flags for Emacs.
 
-EMACSOPT = -batch --no-init-file --no-site-file --multibyte
+EMACSOPT = -batch --no-init-file --no-site-file
 
 # Extra flags to pass to the byte compiler
 BYTE_COMPILE_EXTRA_FLAGS =
--- a/lisp/menu-bar.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/menu-bar.el	Sun Aug 22 22:56:05 2010 +0000
@@ -1272,6 +1272,9 @@
 (define-key menu-bar-games-menu [life]
   `(menu-item ,(purecopy "Life")  life
 	      :help ,(purecopy "Watch how John Conway's cellular automaton evolves")))
+(define-key menu-bar-games-menu [land]
+  `(menu-item ,(purecopy "Landmark") landmark
+	      :help ,(purecopy "Watch a neural-network robot learn landmarks")))
 (define-key menu-bar-games-menu [hanoi]
   `(menu-item ,(purecopy "Towers of Hanoi") hanoi
 	      :help ,(purecopy "Watch Towers-of-Hanoi puzzle solved by Emacs")))
--- a/lisp/mouse.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/mouse.el	Sun Aug 22 22:56:05 2010 +0000
@@ -1297,8 +1297,7 @@
 ;; whenever it was equal to the front of the kill ring, but some
 ;; people found that confusing.
 
-;; A list (TEXT START END), describing the text and position of the last
-;; invocation of mouse-save-then-kill.
+;; The position of the last invocation of `mouse-save-then-kill'.
 (defvar mouse-save-then-kill-posn nil)
 
 (defun mouse-save-then-kill-delete-region (beg end)
@@ -1336,111 +1335,76 @@
   (undo-boundary))
 
 (defun mouse-save-then-kill (click)
-  "Set the region according to CLICK; the second time, kill the region.
-Assuming this command is bound to a mouse button, CLICK is the
-corresponding input event.
+  "Set the region according to CLICK; the second time, kill it.
+CLICK should be a mouse click event.
+
+If the region is inactive, activate it temporarily.  Set mark at
+the original point, and move point to the position of CLICK.
 
-If the region is already active, adjust it.  Normally, this
-happens by moving either point or mark, whichever is closer, to
-the position of CLICK.  But if you have selected words or lines,
-the region is adjusted by moving point or mark to the word or
-line boundary closest to CLICK.
+If the region is already active, adjust it.  Normally, do this by
+moving point or mark, whichever is closer, to CLICK.  But if you
+have selected whole words or lines, move point or mark to the
+word or line boundary closest to CLICK instead.
 
-If the region is inactive, activate it temporarily; set mark at
-the original point, and move click to the position of CLICK.
-
-However, if this command is being called a second time (i.e. the
-value of `last-command' is `mouse-save-then-kill'), kill the
-region instead.  If the text in the region is the same as the
-text in the front of the kill ring, just delete it."
+If this command is called a second consecutive time with the same
+CLICK position, kill the region."
   (interactive "e")
-  (let ((before-scroll
-	 (with-current-buffer (window-buffer (posn-window (event-start click)))
-	   point-before-scroll)))
-    (mouse-minibuffer-check click)
-    (let ((click-posn (posn-point (event-start click)))
-	  ;; Don't let a subsequent kill command append to this one:
-	  ;; prevent setting this-command to kill-region.
-	  (this-command this-command))
-      (if (and (with-current-buffer
-                   (window-buffer (posn-window (event-start click)))
-		 (and (mark t)
-		      (> (mod mouse-selection-click-count 3) 0)
-		      ;; Don't be fooled by a recent click in some other buffer.
-		      (eq mouse-selection-click-count-buffer
-			  (current-buffer)))))
-	  (if (and (eq last-command 'mouse-save-then-kill)
-		   (equal click-posn (nth 2 mouse-save-then-kill-posn)))
-	      ;; If we click this button again without moving it, kill.
-	      (progn
-		;; Call `deactivate-mark' to save the primary selection.
-		(deactivate-mark)
-		(mouse-save-then-kill-delete-region (mark) (point))
-		(setq mouse-selection-click-count 0)
-		(setq mouse-save-then-kill-posn nil))
-	    ;; Find both ends of the object selected by this click.
-	    (let* ((range
-		    (mouse-start-end click-posn click-posn
-				     mouse-selection-click-count)))
-	      ;; Move whichever end is closer to the click.
-	      ;; That's what xterm does, and it seems reasonable.
-	      (if (< (abs (- click-posn (mark t)))
-		     (abs (- click-posn (point))))
-		  (set-mark (car range))
-		(goto-char (nth 1 range)))
-	      ;; We have already put the old region in the kill ring.
-	      ;; Replace it with the extended region.
-	      ;; (It would be annoying to make a separate entry.)
-	      (kill-new (buffer-substring (point) (mark t)) t)
-	      (mouse-set-region-1)
-	      ;; Arrange for a repeated mouse-3 to kill this region.
-	      (setq mouse-save-then-kill-posn
-		    (list (car kill-ring) (point) click-posn))))
+  (mouse-minibuffer-check click)
+  (let* ((posn     (event-start click))
+	 (click-pt (posn-point posn))
+	 (window   (posn-window posn))
+	 (buf      (window-buffer window))
+	 ;; Don't let a subsequent kill command append to this one.
+	 (this-command this-command)
+	 ;; Check if the user has multi-clicked to select words/lines.
+	 (click-count
+	  (if (and (eq mouse-selection-click-count-buffer buf)
+		   (with-current-buffer buf (mark t)))
+	      mouse-selection-click-count
+	    0)))
+    (cond
+     ((not (numberp click-pt)) nil)
+     ;; If the user clicked without moving point, kill the region.
+     ;; This also resets `mouse-selection-click-count'.
+     ((and (eq last-command 'mouse-save-then-kill)
+	   (eq click-pt mouse-save-then-kill-posn)
+	   (eq window (selected-window)))
+      (kill-region (mark t) (point))
+      (setq mouse-selection-click-count 0)
+      (setq mouse-save-then-kill-posn nil))
 
-	(if (and (eq last-command 'mouse-save-then-kill)
-		 mouse-save-then-kill-posn
-		 (eq (car mouse-save-then-kill-posn) (car kill-ring))
-		 (equal (cdr mouse-save-then-kill-posn)
-			(list (point) click-posn)))
-	    ;; If this is the second time we've called
-	    ;; mouse-save-then-kill, delete the text from the buffer.
-	    (progn
-	      ;; Call `deactivate-mark' to save the primary selection.
-	      (deactivate-mark)
-	      (mouse-save-then-kill-delete-region (point) (mark t))
-	      ;; After we kill, another click counts as "the first time".
-	      (setq mouse-save-then-kill-posn nil))
-	  ;; This is not a repetition.
-	  ;; We are adjusting an old selection or creating a new one.
-	  (if (or (and (eq last-command 'mouse-save-then-kill)
-		       mouse-save-then-kill-posn)
-		  (and mark-active transient-mark-mode)
-		  (and (memq last-command
-			     '(mouse-drag-region mouse-set-region))
-		       (or mark-even-if-inactive
-			   (not transient-mark-mode))))
-	      ;; We have a selection or suitable region, so adjust it.
-	      (let* ((posn (event-start click))
-		     (new (posn-point posn)))
-		(select-window (posn-window posn))
-		(if (numberp new)
-		    (progn
-		      ;; Move whichever end of the region is closer to the click.
-		      ;; That is what xterm does, and it seems reasonable.
-		      (if (<= (abs (- new (point))) (abs (- new (mark t))))
-			  (goto-char new)
-			(set-mark new))
-		      (setq deactivate-mark nil)))
-		(kill-new (buffer-substring (point) (mark t)) t))
-	    ;; Set the mark where point is, then move where clicked.
-	    (mouse-set-mark-fast click)
-	    (if before-scroll
-		(goto-char before-scroll))
-	    (exchange-point-and-mark)   ;Why??? --Stef
-	    (kill-new (buffer-substring (point) (mark t))))
-	  (mouse-set-region-1)
-	  (setq mouse-save-then-kill-posn
-		(list (car kill-ring) (point) click-posn)))))))
+     ;; Otherwise, if there is a suitable region, adjust it by moving
+     ;; one end (whichever is closer) to CLICK-PT.
+     ((or (with-current-buffer buf (region-active-p))
+	  (and (eq window (selected-window))
+	       (mark t)
+	       (or (and (eq last-command 'mouse-save-then-kill)
+			mouse-save-then-kill-posn)
+		   (and (memq last-command '(mouse-drag-region
+					     mouse-set-region))
+			(or mark-even-if-inactive
+			    (not transient-mark-mode))))))
+      (select-window window)
+      (let* ((range (mouse-start-end click-pt click-pt click-count)))
+	(if (< (abs (- click-pt (mark t)))
+	       (abs (- click-pt (point))))
+	    (set-mark (car range))
+	  (goto-char (nth 1 range)))
+	(setq deactivate-mark nil)
+	(mouse-set-region-1)
+	;; Arrange for a repeated mouse-3 to kill the region.
+	(setq mouse-save-then-kill-posn click-pt)))
+
+     ;; Otherwise, set the mark where point is and move to CLICK-PT.
+     (t
+      (select-window window)
+      (mouse-set-mark-fast click)
+      (let ((before-scroll (with-current-buffer buf point-before-scroll)))
+	(if before-scroll (goto-char before-scroll)))
+      (exchange-point-and-mark)
+      (mouse-set-region-1)
+      (setq mouse-save-then-kill-posn click-pt)))))
+
 
 (global-set-key [M-mouse-1] 'mouse-start-secondary)
 (global-set-key [M-drag-mouse-1] 'mouse-set-secondary)
@@ -1520,9 +1484,6 @@
 	  ;; of one word or line.
 	  (let ((range (mouse-start-end start-point start-point click-count)))
 	    (set-marker mouse-secondary-start nil)
-            ;; Why the double move?  --Stef
-	    ;; (move-overlay mouse-secondary-overlay 1 1
-	    ;;     	  (window-buffer start-window))
 	    (move-overlay mouse-secondary-overlay (car range) (nth 1 range)
 			  (window-buffer start-window)))
 	;; Single-press: cancel any preexisting secondary selection.
@@ -1616,117 +1577,99 @@
   (delete-overlay mouse-secondary-overlay))
 
 (defun mouse-secondary-save-then-kill (click)
-  "Save text to point in kill ring; the second time, kill the text.
-You must use this in a buffer where you have recently done \\[mouse-start-secondary].
-If the text between where you did \\[mouse-start-secondary] and where
-you use this command matches the text at the front of the kill ring,
-this command deletes the text.
-Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
-which prepares for a second click with this command to delete the text.
+  "Set the secondary selection and save it to the kill ring.
+The second time, kill it.  CLICK should be a mouse click event.
+
+If you have not called `mouse-start-secondary' in the clicked
+buffer, activate the secondary selection and set it between point
+and the click position CLICK.
 
-If you have already made a secondary selection in that buffer,
-this command extends or retracts the selection to where you click.
-If you do this again in a different position, it extends or retracts
-again.  If you do this twice in the same position, it kills the selection."
+Otherwise, adjust the bounds of the secondary selection.
+Normally, do this by moving its beginning or end, whichever is
+closer, to CLICK.  But if you have selected whole words or lines,
+adjust to the word or line boundary closest to CLICK instead.
+
+If this command is called a second consecutive time with the same
+CLICK position, kill the secondary selection."
   (interactive "e")
   (mouse-minibuffer-check click)
-  (let ((posn (event-start click))
-	(click-posn (posn-point (event-start click)))
-	;; Don't let a subsequent kill command append to this one:
-	;; prevent setting this-command to kill-region.
-	(this-command this-command))
-    (or (eq (window-buffer (posn-window posn))
-	    (or (overlay-buffer mouse-secondary-overlay)
-		(if mouse-secondary-start
-		    (marker-buffer mouse-secondary-start))))
-	(error "Wrong buffer"))
-    (with-current-buffer (window-buffer (posn-window posn))
-      (if (> (mod mouse-secondary-click-count 3) 0)
-	  (if (not (and (eq last-command 'mouse-secondary-save-then-kill)
-			(equal click-posn
-			       (car (cdr-safe (cdr-safe mouse-save-then-kill-posn))))))
-	      ;; Find both ends of the object selected by this click.
-	      (let* ((range
-		      (mouse-start-end click-posn click-posn
-				       mouse-secondary-click-count)))
-		;; Move whichever end is closer to the click.
-		;; That's what xterm does, and it seems reasonable.
-		(if (< (abs (- click-posn (overlay-start mouse-secondary-overlay)))
-		       (abs (- click-posn (overlay-end mouse-secondary-overlay))))
-		    (move-overlay mouse-secondary-overlay (car range)
-				  (overlay-end mouse-secondary-overlay))
-		  (move-overlay mouse-secondary-overlay
-				(overlay-start mouse-secondary-overlay)
-				(nth 1 range)))
-		;; We have already put the old region in the kill ring.
-		;; Replace it with the extended region.
-		;; (It would be annoying to make a separate entry.)
-		(kill-new (buffer-substring
-			   (overlay-start mouse-secondary-overlay)
-			   (overlay-end mouse-secondary-overlay)) t)
-		;; Arrange for a repeated mouse-3 to kill this region.
-		(setq mouse-save-then-kill-posn
-		      (list (car kill-ring) (point) click-posn)))
-	    ;; If we click this button again without moving it,
-	    ;; that time kill.
-	    (progn
-	      (mouse-save-then-kill-delete-region
-	       (overlay-start mouse-secondary-overlay)
-	       (overlay-end mouse-secondary-overlay))
-	      (setq mouse-save-then-kill-posn nil)
-	      (setq mouse-secondary-click-count 0)
-	      (delete-overlay mouse-secondary-overlay)))
-	(if (and (eq last-command 'mouse-secondary-save-then-kill)
-		 mouse-save-then-kill-posn
-		 (eq (car mouse-save-then-kill-posn) (car kill-ring))
-		 (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn)))
-	    ;; If this is the second time we've called
-	    ;; mouse-secondary-save-then-kill, delete the text from the buffer.
-	    (progn
-	      (mouse-save-then-kill-delete-region
-	       (overlay-start mouse-secondary-overlay)
-	       (overlay-end mouse-secondary-overlay))
-	      (setq mouse-save-then-kill-posn nil)
-	      (delete-overlay mouse-secondary-overlay))
-	  (if (overlay-start mouse-secondary-overlay)
-	      ;; We have a selection, so adjust it.
-	      (progn
-		(if (numberp click-posn)
-		    (progn
-		      ;; Move whichever end of the region is closer to the click.
-		      ;; That is what xterm does, and it seems reasonable.
-		      (if (< (abs (- click-posn (overlay-start mouse-secondary-overlay)))
-			     (abs (- click-posn (overlay-end mouse-secondary-overlay))))
-			  (move-overlay mouse-secondary-overlay click-posn
-					(overlay-end mouse-secondary-overlay))
-			(move-overlay mouse-secondary-overlay
-				      (overlay-start mouse-secondary-overlay)
-				      click-posn))
-		      (setq deactivate-mark nil)))
-		(if (eq last-command 'mouse-secondary-save-then-kill)
-		    ;; If the front of the kill ring comes from
-		    ;; an immediately previous use of this command,
-		    ;; replace it with the extended region.
-		    ;; (It would be annoying to make a separate entry.)
-		    (kill-new (buffer-substring
-			       (overlay-start mouse-secondary-overlay)
-			       (overlay-end mouse-secondary-overlay)) t)
-		  (let (deactivate-mark)
-		    (copy-region-as-kill (overlay-start mouse-secondary-overlay)
-					 (overlay-end mouse-secondary-overlay)))))
-	    (if mouse-secondary-start
-		;; All we have is one end of a selection,
-		;; so put the other end here.
-		(let ((start (+ 0 mouse-secondary-start)))
-		  (kill-ring-save start click-posn)
-                  (move-overlay mouse-secondary-overlay start click-posn))))
-	  (setq mouse-save-then-kill-posn
-		(list (car kill-ring) (point) click-posn))))
-      (if (overlay-buffer mouse-secondary-overlay)
-	  (x-set-selection 'SECONDARY
-			   (buffer-substring
-			    (overlay-start mouse-secondary-overlay)
-			    (overlay-end mouse-secondary-overlay)))))))
+  (let* ((posn     (event-start click))
+	 (click-pt (posn-point posn))
+	 (window   (posn-window posn))
+	 (buf      (window-buffer window))
+	 ;; Don't let a subsequent kill command append to this one.
+	 (this-command this-command)
+	 ;; Check if the user has multi-clicked to select words/lines.
+	 (click-count
+	  (if (eq (overlay-buffer mouse-secondary-overlay) buf)
+	      mouse-secondary-click-count
+	    0))
+	 (beg (overlay-start mouse-secondary-overlay))
+	 (end (overlay-end mouse-secondary-overlay)))
+
+    (cond
+     ((not (numberp click-pt)) nil)
+
+     ;; If the secondary selection is not active in BUF, activate it.
+     ((not (eq buf (or (overlay-buffer mouse-secondary-overlay)
+		       (if mouse-secondary-start
+			   (marker-buffer mouse-secondary-start)))))
+      (select-window window)
+      (setq mouse-secondary-start (make-marker))
+      (move-marker mouse-secondary-start (point))
+      (move-overlay mouse-secondary-overlay (point) click-pt buf)
+      (kill-ring-save (point) click-pt))
+
+     ;; If the user clicked without moving point, delete the secondary
+     ;; selection.  This also resets `mouse-secondary-click-count'.
+     ((and (eq last-command 'mouse-secondary-save-then-kill)
+	   (eq click-pt mouse-save-then-kill-posn)
+	   (eq window (selected-window)))
+      (mouse-save-then-kill-delete-region beg end)
+      (delete-overlay mouse-secondary-overlay)
+      (setq mouse-secondary-click-count 0)
+      (setq mouse-save-then-kill-posn nil))
+
+     ;; Otherwise, if there is a suitable secondary selection overlay,
+     ;; adjust it by moving one end (whichever is closer) to CLICK-PT.
+     ((and beg (eq buf (overlay-buffer mouse-secondary-overlay)))
+      (let* ((range (mouse-start-end click-pt click-pt click-count)))
+	(if (< (abs (- click-pt beg))
+	       (abs (- click-pt end)))
+	    (move-overlay mouse-secondary-overlay (car range) end)
+	  (move-overlay mouse-secondary-overlay beg (nth 1 range))))
+      (setq deactivate-mark nil)
+      (if (eq last-command 'mouse-secondary-save-then-kill)
+	  ;; If the front of the kill ring comes from an immediately
+	  ;; previous use of this command, replace the entry.
+	  (kill-new
+	   (buffer-substring (overlay-start mouse-secondary-overlay)
+			     (overlay-end mouse-secondary-overlay))
+	   t)
+	(let (deactivate-mark)
+	  (copy-region-as-kill (overlay-start mouse-secondary-overlay)
+			       (overlay-end mouse-secondary-overlay))))
+      (setq mouse-save-then-kill-posn click-pt))
+
+     ;; Otherwise, set the secondary selection overlay.
+     (t
+      (select-window window)
+      (if mouse-secondary-start
+	  ;; All we have is one end of a selection, so put the other
+	  ;; end here.
+	  (let ((start (+ 0 mouse-secondary-start)))
+	    (kill-ring-save start click-pt)
+	    (move-overlay mouse-secondary-overlay start click-pt)))
+      (setq mouse-save-then-kill-posn click-pt))))
+
+  ;; Finally, set the window system's secondary selection.
+  (let (str)
+    (and (overlay-buffer mouse-secondary-overlay)
+	 (setq str (buffer-substring (overlay-start mouse-secondary-overlay)
+				     (overlay-end mouse-secondary-overlay)))
+	 (> (length str) 0)
+	 (x-set-selection 'SECONDARY str))))
+
 
 (defcustom mouse-buffer-menu-maxlen 20
   "Number of buffers in one pane (submenu) of the buffer menu.
@@ -1907,332 +1850,6 @@
     ;; Few buffers--put them all in one pane.
     (list (cons title alist))))
 
-;; These need to be rewritten for the new scroll bar implementation.
-
-;;!! ;; Commands for the scroll bar.
-;;!!
-;;!! (defun mouse-scroll-down (click)
-;;!!   (interactive "@e")
-;;!!   (scroll-down (1+ (cdr (mouse-coords click)))))
-;;!!
-;;!! (defun mouse-scroll-up (click)
-;;!!   (interactive "@e")
-;;!!   (scroll-up (1+ (cdr (mouse-coords click)))))
-;;!!
-;;!! (defun mouse-scroll-down-full ()
-;;!!   (interactive "@")
-;;!!   (scroll-down nil))
-;;!!
-;;!! (defun mouse-scroll-up-full ()
-;;!!   (interactive "@")
-;;!!   (scroll-up nil))
-;;!!
-;;!! (defun mouse-scroll-move-cursor (click)
-;;!!   (interactive "@e")
-;;!!   (move-to-window-line (1+ (cdr (mouse-coords click)))))
-;;!!
-;;!! (defun mouse-scroll-absolute (event)
-;;!!   (interactive "@e")
-;;!!   (let* ((pos (car event))
-;;!! 	 (position (car pos))
-;;!! 	 (length (car (cdr pos))))
-;;!!     (if (<= length 0) (setq length 1))
-;;!!     (let* ((scale-factor (max 1 (/ length (/ 8000000 (buffer-size)))))
-;;!! 	   (newpos (* (/ (* (/ (buffer-size) scale-factor)
-;;!! 			    position)
-;;!! 			 length)
-;;!! 		      scale-factor)))
-;;!!       (goto-char newpos)
-;;!!       (recenter '(4)))))
-;;!!
-;;!! (defun mouse-scroll-left (click)
-;;!!   (interactive "@e")
-;;!!   (scroll-left (1+ (car (mouse-coords click)))))
-;;!!
-;;!! (defun mouse-scroll-right (click)
-;;!!   (interactive "@e")
-;;!!   (scroll-right (1+ (car (mouse-coords click)))))
-;;!!
-;;!! (defun mouse-scroll-left-full ()
-;;!!   (interactive "@")
-;;!!   (scroll-left nil))
-;;!!
-;;!! (defun mouse-scroll-right-full ()
-;;!!   (interactive "@")
-;;!!   (scroll-right nil))
-;;!!
-;;!! (defun mouse-scroll-move-cursor-horizontally (click)
-;;!!   (interactive "@e")
-;;!!   (move-to-column (1+ (car (mouse-coords click)))))
-;;!!
-;;!! (defun mouse-scroll-absolute-horizontally (event)
-;;!!   (interactive "@e")
-;;!!   (let* ((pos (car event))
-;;!! 	 (position (car pos))
-;;!! 	 (length (car (cdr pos))))
-;;!!   (set-window-hscroll (selected-window) 33)))
-;;!!
-;;!! (global-set-key [scroll-bar mouse-1] 'mouse-scroll-up)
-;;!! (global-set-key [scroll-bar mouse-2] 'mouse-scroll-absolute)
-;;!! (global-set-key [scroll-bar mouse-3] 'mouse-scroll-down)
-;;!!
-;;!! (global-set-key [vertical-slider mouse-1] 'mouse-scroll-move-cursor)
-;;!! (global-set-key [vertical-slider mouse-2] 'mouse-scroll-move-cursor)
-;;!! (global-set-key [vertical-slider mouse-3] 'mouse-scroll-move-cursor)
-;;!!
-;;!! (global-set-key [thumbup mouse-1] 'mouse-scroll-up-full)
-;;!! (global-set-key [thumbup mouse-2] 'mouse-scroll-up-full)
-;;!! (global-set-key [thumbup mouse-3] 'mouse-scroll-up-full)
-;;!!
-;;!! (global-set-key [thumbdown mouse-1] 'mouse-scroll-down-full)
-;;!! (global-set-key [thumbdown mouse-2] 'mouse-scroll-down-full)
-;;!! (global-set-key [thumbdown mouse-3] 'mouse-scroll-down-full)
-;;!!
-;;!! (global-set-key [horizontal-scroll-bar mouse-1] 'mouse-scroll-left)
-;;!! (global-set-key [horizontal-scroll-bar mouse-2]
-;;!! 		'mouse-scroll-absolute-horizontally)
-;;!! (global-set-key [horizontal-scroll-bar mouse-3] 'mouse-scroll-right)
-;;!!
-;;!! (global-set-key [horizontal-slider mouse-1]
-;;!! 		'mouse-scroll-move-cursor-horizontally)
-;;!! (global-set-key [horizontal-slider mouse-2]
-;;!! 		'mouse-scroll-move-cursor-horizontally)
-;;!! (global-set-key [horizontal-slider mouse-3]
-;;!! 		'mouse-scroll-move-cursor-horizontally)
-;;!!
-;;!! (global-set-key [thumbleft mouse-1] 'mouse-scroll-left-full)
-;;!! (global-set-key [thumbleft mouse-2] 'mouse-scroll-left-full)
-;;!! (global-set-key [thumbleft mouse-3] 'mouse-scroll-left-full)
-;;!!
-;;!! (global-set-key [thumbright mouse-1] 'mouse-scroll-right-full)
-;;!! (global-set-key [thumbright mouse-2] 'mouse-scroll-right-full)
-;;!! (global-set-key [thumbright mouse-3] 'mouse-scroll-right-full)
-;;!!
-;;!! (global-set-key [horizontal-scroll-bar S-mouse-2]
-;;!! 		'mouse-split-window-horizontally)
-;;!! (global-set-key [mode-line S-mouse-2]
-;;!! 		'mouse-split-window-horizontally)
-;;!! (global-set-key [vertical-scroll-bar S-mouse-2]
-;;!! 		'mouse-split-window)
-
-;;!! ;;;;
-;;!! ;;;; Here are experimental things being tested.  Mouse events
-;;!! ;;;; are of the form:
-;;!! ;;;;	((x y) window screen-part key-sequence timestamp)
-;;!! ;;
-;;!! ;;;;
-;;!! ;;;; Dynamically track mouse coordinates
-;;!! ;;;;
-;;!! ;;
-;;!! ;;(defun track-mouse (event)
-;;!! ;;  "Track the coordinates, absolute and relative, of the mouse."
-;;!! ;;  (interactive "@e")
-;;!! ;;  (while mouse-grabbed
-;;!! ;;    (let* ((pos (read-mouse-position (selected-screen)))
-;;!! ;;	   (abs-x (car pos))
-;;!! ;;	   (abs-y (cdr pos))
-;;!! ;;	   (relative-coordinate (coordinates-in-window-p
-;;!! ;;				 (list (car pos) (cdr pos))
-;;!! ;;				 (selected-window))))
-;;!! ;;      (if (consp relative-coordinate)
-;;!! ;;	  (message "mouse: [%d %d], (%d %d)" abs-x abs-y
-;;!! ;;		   (car relative-coordinate)
-;;!! ;;		   (car (cdr relative-coordinate)))
-;;!! ;;	(message "mouse: [%d %d]" abs-x abs-y)))))
-;;!!
-;;!! ;;
-;;!! ;; Dynamically put a box around the line indicated by point
-;;!! ;;
-;;!! ;;
-;;!! ;;(require 'backquote)
-;;!! ;;
-;;!! ;;(defun mouse-select-buffer-line (event)
-;;!! ;;  (interactive "@e")
-;;!! ;;  (let ((relative-coordinate
-;;!! ;;	 (coordinates-in-window-p (car event) (selected-window)))
-;;!! ;;	(abs-y (car (cdr (car event)))))
-;;!! ;;    (if (consp relative-coordinate)
-;;!! ;;	(progn
-;;!! ;;	  (save-excursion
-;;!! ;;	    (move-to-window-line (car (cdr relative-coordinate)))
-;;!! ;;	    (x-draw-rectangle
-;;!! ;;	     (selected-screen)
-;;!! ;;	     abs-y 0
-;;!! ;;	     (save-excursion
-;;!! ;;		 (move-to-window-line (car (cdr relative-coordinate)))
-;;!! ;;		 (end-of-line)
-;;!! ;;		 (push-mark nil t)
-;;!! ;;		 (beginning-of-line)
-;;!! ;;		 (- (region-end) (region-beginning))) 1))
-;;!! ;;	  (sit-for 1)
-;;!! ;;	  (x-erase-rectangle (selected-screen))))))
-;;!! ;;
-;;!! ;;(defvar last-line-drawn nil)
-;;!! ;;(defvar begin-delim "[^ \t]")
-;;!! ;;(defvar end-delim   "[^ \t]")
-;;!! ;;
-;;!! ;;(defun mouse-boxing (event)
-;;!! ;;  (interactive "@e")
-;;!! ;;  (save-excursion
-;;!! ;;    (let ((screen (selected-screen)))
-;;!! ;;      (while (= (x-mouse-events) 0)
-;;!! ;;	(let* ((pos (read-mouse-position screen))
-;;!! ;;	       (abs-x (car pos))
-;;!! ;;	       (abs-y (cdr pos))
-;;!! ;;	       (relative-coordinate
-;;!! ;;		(coordinates-in-window-p `(,abs-x ,abs-y)
-;;!! ;;					 (selected-window)))
-;;!! ;;	       (begin-reg nil)
-;;!! ;;	       (end-reg nil)
-;;!! ;;	       (end-column nil)
-;;!! ;;	       (begin-column nil))
-;;!! ;;	  (if (and (consp relative-coordinate)
-;;!! ;;		   (or (not last-line-drawn)
-;;!! ;;		       (not (= last-line-drawn abs-y))))
-;;!! ;;	      (progn
-;;!! ;;		(move-to-window-line (car (cdr relative-coordinate)))
-;;!! ;;		(if (= (following-char) 10)
-;;!! ;;		    ()
-;;!! ;;		  (progn
-;;!! ;;		    (setq begin-reg (1- (re-search-forward end-delim)))
-;;!! ;;		    (setq begin-column (1- (current-column)))
-;;!! ;;		    (end-of-line)
-;;!! ;;		    (setq end-reg (1+ (re-search-backward begin-delim)))
-;;!! ;;		    (setq end-column (1+ (current-column)))
-;;!! ;;		    (message "%s" (buffer-substring begin-reg end-reg))
-;;!! ;;		    (x-draw-rectangle screen
-;;!! ;;				      (setq last-line-drawn abs-y)
-;;!! ;;				      begin-column
-;;!! ;;				      (- end-column begin-column) 1))))))))))
-;;!! ;;
-;;!! ;;(defun mouse-erase-box ()
-;;!! ;;  (interactive)
-;;!! ;;  (if last-line-drawn
-;;!! ;;      (progn
-;;!! ;;	(x-erase-rectangle (selected-screen))
-;;!! ;;	(setq last-line-drawn nil))))
-;;!!
-;;!! ;;; (defun test-x-rectangle ()
-;;!! ;;;   (use-local-mouse-map (setq rectangle-test-map (make-sparse-keymap)))
-;;!! ;;;   (define-key rectangle-test-map mouse-motion-button-left 'mouse-boxing)
-;;!! ;;;   (define-key rectangle-test-map mouse-button-left-up 'mouse-erase-box))
-;;!!
-;;!! ;;
-;;!! ;; Here is how to do double clicking in lisp.  About to change.
-;;!! ;;
-;;!!
-;;!! (defvar double-start nil)
-;;!! (defconst double-click-interval 300
-;;!!   "Max ticks between clicks")
-;;!!
-;;!! (defun double-down (event)
-;;!!   (interactive "@e")
-;;!!   (if double-start
-;;!!       (let ((interval (- (nth 4 event) double-start)))
-;;!! 	(if (< interval double-click-interval)
-;;!! 	    (progn
-;;!! 	      (backward-up-list 1)
-;;!! 	      ;;      (message "Interval %d" interval)
-;;!! 	      (sleep-for 1)))
-;;!! 	(setq double-start nil))
-;;!!     (setq double-start (nth 4 event))))
-;;!!
-;;!! (defun double-up (event)
-;;!!   (interactive "@e")
-;;!!   (and double-start
-;;!!        (> (- (nth 4 event ) double-start) double-click-interval)
-;;!!        (setq double-start nil)))
-;;!!
-;;!! ;;; (defun x-test-doubleclick ()
-;;!! ;;;   (use-local-mouse-map (setq doubleclick-test-map (make-sparse-keymap)))
-;;!! ;;;   (define-key doubleclick-test-map mouse-button-left 'double-down)
-;;!! ;;;   (define-key doubleclick-test-map mouse-button-left-up 'double-up))
-;;!!
-;;!! ;;
-;;!! ;; This scrolls while button is depressed.  Use preferable in scroll bar.
-;;!! ;;
-;;!!
-;;!! (defvar scrolled-lines 0)
-;;!! (defconst scroll-speed 1)
-;;!!
-;;!! (defun incr-scroll-down (event)
-;;!!   (interactive "@e")
-;;!!   (setq scrolled-lines 0)
-;;!!   (incremental-scroll scroll-speed))
-;;!!
-;;!! (defun incr-scroll-up (event)
-;;!!   (interactive "@e")
-;;!!   (setq scrolled-lines 0)
-;;!!   (incremental-scroll (- scroll-speed)))
-;;!!
-;;!! (defun incremental-scroll (n)
-;;!!   (while (= (x-mouse-events) 0)
-;;!!     (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
-;;!!     (scroll-down n)
-;;!!     (sit-for 300 t)))
-;;!!
-;;!! (defun incr-scroll-stop (event)
-;;!!   (interactive "@e")
-;;!!   (message "Scrolled %d lines" scrolled-lines)
-;;!!   (setq scrolled-lines 0)
-;;!!   (sleep-for 1))
-;;!!
-;;!! ;;; (defun x-testing-scroll ()
-;;!! ;;;   (let ((scrolling-map (function mouse-vertical-scroll-bar-prefix)))
-;;!! ;;;     (define-key scrolling-map mouse-button-left 'incr-scroll-down)
-;;!! ;;;     (define-key scrolling-map mouse-button-right 'incr-scroll-up)
-;;!! ;;;     (define-key scrolling-map mouse-button-left-up 'incr-scroll-stop)
-;;!! ;;;     (define-key scrolling-map mouse-button-right-up 'incr-scroll-stop)))
-;;!!
-;;!! ;;
-;;!! ;; Some playthings suitable for picture mode?  They need work.
-;;!! ;;
-;;!!
-;;!! (defun mouse-kill-rectangle (event)
-;;!!   "Kill the rectangle between point and the mouse cursor."
-;;!!   (interactive "@e")
-;;!!   (let ((point-save (point)))
-;;!!     (save-excursion
-;;!!       (mouse-set-point event)
-;;!!       (push-mark nil t)
-;;!!       (if (> point-save (point))
-;;!! 	  (kill-rectangle (point) point-save)
-;;!! 	(kill-rectangle point-save (point))))))
-;;!!
-;;!! (defun mouse-open-rectangle (event)
-;;!!   "Kill the rectangle between point and the mouse cursor."
-;;!!   (interactive "@e")
-;;!!   (let ((point-save (point)))
-;;!!     (save-excursion
-;;!!       (mouse-set-point event)
-;;!!       (push-mark nil t)
-;;!!       (if (> point-save (point))
-;;!! 	  (open-rectangle (point) point-save)
-;;!! 	(open-rectangle point-save (point))))))
-;;!!
-;;!! ;; Must be a better way to do this.
-;;!!
-;;!! (defun mouse-multiple-insert (n char)
-;;!!   (while (> n 0)
-;;!!     (insert char)
-;;!!     (setq n (1- n))))
-;;!!
-;;!! ;; What this could do is not finalize until button was released.
-;;!!
-;;!! (defun mouse-move-text (event)
-;;!!   "Move text from point to cursor position, inserting spaces."
-;;!!   (interactive "@e")
-;;!!   (let* ((relative-coordinate
-;;!! 	  (coordinates-in-window-p (car event) (selected-window))))
-;;!!     (if (consp relative-coordinate)
-;;!! 	(cond ((> (current-column) (car relative-coordinate))
-;;!! 	       (delete-char
-;;!! 		(- (car relative-coordinate) (current-column))))
-;;!! 	      ((< (current-column) (car relative-coordinate))
-;;!! 	       (mouse-multiple-insert
-;;!! 		(- (car relative-coordinate) (current-column)) " "))
-;;!! 	      ((= (current-column) (car relative-coordinate)) (ding))))))
-
 (define-obsolete-function-alias
   'mouse-choose-completion 'choose-completion "23.2")
 
@@ -2475,10 +2092,6 @@
                   (mouse-menu-bar-map)
                 (mouse-menu-major-mode-map)))))
 
-
-;; Replaced with dragging mouse-1
-;; (global-set-key [S-mouse-1]	'mouse-set-mark)
-
 ;; Binding mouse-1 to mouse-select-window when on mode-, header-, or
 ;; vertical-line prevents Emacs from signaling an error when the mouse
 ;; button is released after dragging these lines, on non-toolkit
--- a/lisp/progmodes/flymake.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/progmodes/flymake.el	Sun Aug 22 22:56:05 2010 +0000
@@ -1152,7 +1152,8 @@
 	  (when dir
 	    (let ((default-directory dir))
 	      (flymake-log 3 "starting process on dir %s" default-directory)))
-	  (setq process (apply 'start-process "flymake-proc" (current-buffer) cmd args))
+	  (setq process (apply 'start-file-process
+			       "flymake-proc" (current-buffer) cmd args))
 	  (set-process-sentinel process 'flymake-process-sentinel)
 	  (set-process-filter process 'flymake-process-filter)
           (push process flymake-processes)
--- a/lisp/progmodes/make-mode.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/progmodes/make-mode.el	Sun Aug 22 22:56:05 2010 +0000
@@ -1300,7 +1300,9 @@
 	(save-restriction
 	  (narrow-to-region beginning end)
 	  (makefile-backslash-region (point-min) (point-max) t)
-	  (let ((fill-paragraph-function nil))
+	  (let ((fill-paragraph-function nil)
+                ;; Adjust fill-column to allow space for the backslash.
+                (fill-column (- fill-column 1)))
 	    (fill-paragraph nil))
 	  (makefile-backslash-region (point-min) (point-max) nil)
 	  (goto-char (point-max))
@@ -1314,7 +1316,9 @@
       ;; resulting region.
       (save-restriction
 	(narrow-to-region (point) (line-beginning-position 2))
-	(let ((fill-paragraph-function nil))
+	(let ((fill-paragraph-function nil)
+              ;; Adjust fill-column to allow space for the backslash.
+              (fill-column (- fill-column 1)))
 	  (fill-paragraph nil))
 	(makefile-backslash-region (point-min) (point-max) nil))
       ;; Return non-nil to indicate it's been filled.
--- a/lisp/simple.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/simple.el	Sun Aug 22 22:56:05 2010 +0000
@@ -3103,7 +3103,8 @@
 the text, but put the text in the kill ring anyway.  This means that
 you can use the killing commands to copy text from a read-only buffer.
 
-This is the primitive for programs to kill text (as opposed to deleting it).
+Lisp programs should use this function for killing text.
+ (To delete text, use `delete-region'.)
 Supply two arguments, character positions indicating the stretch of text
  to be killed.
 Any command that calls this function is a \"kill command\".
--- a/lisp/startup.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/startup.el	Sun Aug 22 22:56:05 2010 +0000
@@ -785,15 +785,16 @@
                 argi (match-string 1 argi)))
 	(when (string-match "\\`--." orig-argi)
 	  (let ((completion (try-completion argi longopts)))
-	    (if (eq completion t)
-		(setq argi (substring argi 1))
-	      (if (stringp completion)
-		  (let ((elt (assoc completion longopts)))
-		    (or elt
-			(error "Option `%s' is ambiguous" argi))
-		    (setq argi (substring (car elt) 1)))
-		(setq argval nil
-                      argi orig-argi)))))
+	    (cond ((eq completion t)
+		   (setq argi (substring argi 1)))
+		  ((stringp completion)
+		   (let ((elt (assoc completion longopts)))
+		     (unless elt
+		       (error "Option `%s' is ambiguous" argi))
+		     (setq argi (substring (car elt) 1))))
+		  (t
+		   (setq argval nil
+			 argi orig-argi)))))
 	(cond
 	 ;; The --display arg is handled partly in C, partly in Lisp.
 	 ;; When it shows up here, we just put it back to be handled
@@ -2231,6 +2232,11 @@
 		     (move-to-column (1- cl1-column)))
 		   (setq cl1-column 0))
 
+		  ;; These command lines now have no effect.
+		  ((string-match "\\`--?\\(no-\\)?\\(uni\\|multi\\)byte$" argi)
+		   (display-warning 'initialization
+				    (format "Ignoring obsolete arg %s" argi)))
+
 		  ((equal argi "--")
 		   (setq just-files t))
 		  (t
--- a/lisp/subr.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/subr.el	Sun Aug 22 22:56:05 2010 +0000
@@ -219,6 +219,7 @@
 (defmacro ignore-errors (&rest body)
   "Execute BODY; if an error occurs, return nil.
 Otherwise, return result of last form in BODY."
+  (declare (debug t) (indent 0))
   `(condition-case nil (progn ,@body) (error nil)))
 
 ;;;; Basic Lisp functions.
@@ -1818,6 +1819,7 @@
 some sort of escape sequence, the ambiguity is resolved via `read-key-delay'."
   (let ((overriding-terminal-local-map read-key-empty-map)
 	(overriding-local-map nil)
+        (echo-keystrokes 0)
 	(old-global-map (current-global-map))
         (timer (run-with-idle-timer
                 ;; Wait long enough that Emacs has the time to receive and
@@ -1842,7 +1844,12 @@
                       (throw 'read-key keys)))))))
     (unwind-protect
         (progn
-	  (use-global-map read-key-empty-map)
+	  (use-global-map
+           (let ((map (make-sparse-keymap)))
+             ;; Don't hide the menu-bar and tool-bar entries.
+             (define-key map [menu-bar] (lookup-key global-map [menu-bar]))
+             (define-key map [tool-bar] (lookup-key global-map [tool-bar]))
+             map))
 	  (aref	(catch 'read-key (read-key-sequence-vector prompt nil t)) 0))
       (cancel-timer timer)
       (use-global-map old-global-map))))
--- a/lisp/vc/add-log.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/vc/add-log.el	Sun Aug 22 22:56:05 2010 +0000
@@ -755,7 +755,17 @@
     (if add-log-file-name-function
 	(funcall add-log-file-name-function buffer-file)
       (setq buffer-file
-            (file-relative-name buffer-file (file-name-directory log-file)))
+            (let* ((dir (file-name-directory log-file))
+                   (rel (file-relative-name buffer-file dir)))
+              ;; Sometimes with symlinks, the two buffers may have names that
+              ;; appear to belong to different directory trees.  So check the
+              ;; file-truenames, to see if we get a better result.
+              (if (not (string-match "\\`\\.\\./" rel))
+                  rel
+                (let ((new (file-relative-name (file-truename buffer-file)
+                                               (file-truename dir))))
+                  (if (< (length new) (length rel))
+                      new rel)))))
       ;; If we have a backup file, it's presumably because we're
       ;; comparing old and new versions (e.g. for deleted
       ;; functions) and we'll want to use the original name.
--- a/lisp/whitespace.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/whitespace.el	Sun Aug 22 22:56:05 2010 +0000
@@ -6,7 +6,7 @@
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Keywords: data, wp
-;; Version: 12.1
+;; Version: 13.0
 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
 
 ;; This file is part of GNU Emacs.
@@ -812,7 +812,7 @@
   :group 'whitespace)
 
 
-(defcustom whitespace-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)"
+(defcustom whitespace-empty-at-bob-regexp "^\\(\\([ \t]*\n\\)+\\)"
   "Specify regexp for empty lines at beginning of buffer.
 
 If you're using `mule' package, there may be other characters besides:
@@ -827,7 +827,7 @@
   :group 'whitespace)
 
 
-(defcustom whitespace-empty-at-eob-regexp "^\\([ \t\n]+\\)\\'"
+(defcustom whitespace-empty-at-eob-regexp "^\\([ \t\n]+\\)"
   "Specify regexp for empty lines at end of buffer.
 
 If you're using `mule' package, there may be other characters besides:
@@ -1228,6 +1228,19 @@
   "Used to save locally the font-lock refontify state.
 Used by `whitespace-post-command-hook' function (which see).")
 
+(defvar whitespace-bob-marker nil
+  "Used to save locally the bob marker value.
+Used by `whitespace-post-command-hook' function (which see).")
+
+(defvar whitespace-eob-marker nil
+  "Used to save locally the eob marker value.
+Used by `whitespace-post-command-hook' function (which see).")
+
+(defvar whitespace-buffer-changed nil
+  "Used to indicate locally if buffer changed.
+Used by `whitespace-post-command-hook' and `whitespace-buffer-changed'
+functions (which see).")
+
 
 ;;;###autoload
 (defun whitespace-toggle-options (arg)
@@ -1463,10 +1476,10 @@
 	  (let (overwrite-mode)		; enforce no overwrite
 	    (goto-char (point-min))
 	    (when (re-search-forward
-		   whitespace-empty-at-bob-regexp nil t)
+		   (concat "\\`" whitespace-empty-at-bob-regexp) nil t)
 	      (delete-region (match-beginning 1) (match-end 1)))
 	    (when (re-search-forward
-		   whitespace-empty-at-eob-regexp nil t)
+		   (concat whitespace-empty-at-eob-regexp "\\'") nil t)
 	      (delete-region (match-beginning 1) (match-end 1)))))))
     ;; PROBLEM 3: 8 or more SPACEs at bol
     ;; PROBLEM 4: SPACEs before TAB
@@ -2146,8 +2159,15 @@
     (set (make-local-variable 'whitespace-point)
 	 (point))
     (set (make-local-variable 'whitespace-font-lock-refontify)
+	 0)
+    (set (make-local-variable 'whitespace-bob-marker)
+	 (point-min-marker))
+    (set (make-local-variable 'whitespace-eob-marker)
+	 (point-max-marker))
+    (set (make-local-variable 'whitespace-buffer-changed)
 	 nil)
     (add-hook 'post-command-hook #'whitespace-post-command-hook nil t)
+    (add-hook 'before-change-functions #'whitespace-buffer-changed nil t)
     ;; turn off font lock
     (set (make-local-variable 'whitespace-font-lock-mode)
 	 font-lock-mode)
@@ -2158,7 +2178,7 @@
        nil
        (list
 	;; Show SPACEs
-	(list #'whitespace-space-regexp  1 whitespace-space  t)
+	(list whitespace-space-regexp  1 whitespace-space  t)
 	;; Show HARD SPACEs
 	(list whitespace-hspace-regexp 1 whitespace-hspace t))
        t))
@@ -2167,7 +2187,7 @@
        nil
        (list
 	;; Show TABs
-	(list #'whitespace-tab-regexp 1 whitespace-tab t))
+	(list whitespace-tab-regexp 1 whitespace-tab t))
        t))
     (when (memq 'trailing whitespace-active-style)
       (font-lock-add-keywords
@@ -2296,7 +2316,8 @@
   ;; turn off font lock
   (when (whitespace-style-face-p)
     (font-lock-mode 0)
-    (remove-hook 'post-command-hook #'whitespace-post-command-hook)
+    (remove-hook 'post-command-hook #'whitespace-post-command-hook t)
+    (remove-hook 'before-change-functions #'whitespace-buffer-changed t)
     (when whitespace-font-lock
       (setq whitespace-font-lock nil
 	    font-lock-keywords   whitespace-font-lock-keywords))
@@ -2317,37 +2338,128 @@
 (defun whitespace-empty-at-bob-regexp (limit)
   "Match spaces at beginning of buffer which do not contain the point at \
 beginning of buffer."
-  (and (/= whitespace-point 1)
-       (re-search-forward whitespace-empty-at-bob-regexp limit t)))
+  (let ((b (point))
+	r)
+    (cond
+     ;; at bob
+     ((= b 1)
+      (setq r (and (/= whitespace-point 1)
+		   (looking-at whitespace-empty-at-bob-regexp)))
+      (if r
+	  (set-marker whitespace-bob-marker (match-end 1))
+	(set-marker whitespace-bob-marker b)))
+     ;; inside bob empty region
+     ((<= limit whitespace-bob-marker)
+      (setq r (looking-at whitespace-empty-at-bob-regexp))
+      (if r
+	  (when (< (match-end 1) limit)
+	    (set-marker whitespace-bob-marker (match-end 1)))
+	(set-marker whitespace-bob-marker b)))
+     ;; intersection with end of bob empty region
+     ((<= b whitespace-bob-marker)
+      (setq r (looking-at whitespace-empty-at-bob-regexp))
+      (if r
+	  (set-marker whitespace-bob-marker (match-end 1))
+	(set-marker whitespace-bob-marker b)))
+     ;; it is not inside bob empty region
+     (t
+      (setq r nil)))
+    ;; move to end of matching
+    (and r (goto-char (match-end 1)))
+    r))
+
+
+(defsubst whitespace-looking-back (regexp limit)
+  (save-excursion
+    (when (/= 0 (skip-chars-backward " \t\n" limit))
+      (unless (bolp)
+	(forward-line 1))
+      (looking-at regexp))))
 
 
 (defun whitespace-empty-at-eob-regexp (limit)
   "Match spaces at end of buffer which do not contain the point at end of \
 buffer."
-  (and (/= whitespace-point (1+ (buffer-size)))
-       (re-search-forward whitespace-empty-at-eob-regexp limit t)))
-
-
-(defun whitespace-space-regexp (limit)
-  "Match spaces."
-  (setq whitespace-font-lock-refontify t)
-  (re-search-forward whitespace-space-regexp limit t))
-
-
-(defun whitespace-tab-regexp (limit)
-  "Match tabs."
-  (setq whitespace-font-lock-refontify t)
-  (re-search-forward whitespace-tab-regexp limit t))
+  (let ((b (point))
+	(e (1+ (buffer-size)))
+	r)
+    (cond
+     ;; at eob
+     ((= limit e)
+      (when (/= whitespace-point e)
+	(goto-char limit)
+	(setq r (whitespace-looking-back whitespace-empty-at-eob-regexp b)))
+      (if r
+	  (set-marker whitespace-eob-marker (match-beginning 1))
+	(set-marker whitespace-eob-marker limit)
+	(goto-char b)))			; return back to initial position
+     ;; inside eob empty region
+     ((>= b whitespace-eob-marker)
+      (goto-char limit)
+      (setq r (whitespace-looking-back whitespace-empty-at-eob-regexp b))
+      (if r
+	  (when (> (match-beginning 1) b)
+	    (set-marker whitespace-eob-marker (match-beginning 1)))
+	(set-marker whitespace-eob-marker limit)
+	(goto-char b)))			; return back to initial position
+     ;; intersection with beginning of eob empty region
+     ((>= limit whitespace-eob-marker)
+      (goto-char limit)
+      (setq r (whitespace-looking-back whitespace-empty-at-eob-regexp b))
+      (if r
+	  (set-marker whitespace-eob-marker (match-beginning 1))
+	(set-marker whitespace-eob-marker limit)
+	(goto-char b)))			; return back to initial position
+     ;; it is not inside eob empty region
+     (t
+      (setq r nil)))
+    r))
+
+
+(defun whitespace-buffer-changed (beg end)
+  "Set `whitespace-buffer-changed' variable to t."
+  (setq whitespace-buffer-changed t))
 
 
 (defun whitespace-post-command-hook ()
   "Save current point into `whitespace-point' variable.
 Also refontify when necessary."
-  (setq whitespace-point (point))
-  (let ((refontify (or (eolp)			 ; end of line
-		       (= whitespace-point 1)))) ; beginning of buffer
-    (when (or whitespace-font-lock-refontify refontify)
-      (setq whitespace-font-lock-refontify refontify)
+  (setq whitespace-point (point))	; current point position
+  (let ((refontify
+	 (or
+	  ;; it is at end of line ...
+	  (and (eolp)
+	       ;; ... with trailing SPACE or TAB
+	       (or (= (preceding-char) ?\ )
+		   (= (preceding-char) ?\t)))
+	  ;; it is at beginning of buffer (bob)
+	  (= whitespace-point 1)
+	  ;; the buffer was modified and ...
+	  (and whitespace-buffer-changed
+	       (or
+		;; ... or inside bob whitespace region
+		(<= whitespace-point whitespace-bob-marker)
+		;; ... or at bob whitespace region border
+		(and (= whitespace-point (1+ whitespace-bob-marker))
+		     (= (preceding-char) ?\n))))
+	  ;; it is at end of buffer (eob)
+	  (= whitespace-point (1+ (buffer-size)))
+	  ;; the buffer was modified and ...
+	  (and whitespace-buffer-changed
+	       (or
+		;; ... or inside eob whitespace region
+	        (>= whitespace-point whitespace-eob-marker)
+		;; ... or at eob whitespace region border
+		(and (= whitespace-point (1- whitespace-eob-marker))
+		     (= (following-char) ?\n)))))))
+    (when (or refontify (> whitespace-font-lock-refontify 0))
+      (setq whitespace-buffer-changed nil)
+      ;; adjust refontify counter
+      (setq whitespace-font-lock-refontify
+	    (if refontify
+		1
+	      (1- whitespace-font-lock-refontify)))
+      ;; refontify
       (jit-lock-refontify))))
 
 
@@ -2386,11 +2498,11 @@
       (unless whitespace-display-table-was-local
 	(setq whitespace-display-table-was-local t
 	      whitespace-display-table
+	      (copy-sequence buffer-display-table))
+	;; asure `buffer-display-table' is unique
+	;; when two or more windows are visible.
+	(setq buffer-display-table
 	      (copy-sequence buffer-display-table)))
-      ;; asure `buffer-display-table' is unique
-      ;; when two or more windows are visible.
-      (set (make-local-variable 'buffer-display-table)
-	   (copy-sequence buffer-display-table))
       (unless buffer-display-table
 	(setq buffer-display-table (make-display-table)))
       (dolist (entry whitespace-display-mappings)
--- a/lisp/woman.el	Thu Aug 19 22:47:51 2010 +0000
+++ b/lisp/woman.el	Sun Aug 22 22:56:05 2010 +0000
@@ -3388,7 +3388,10 @@
   "Translate up to marker TO.  Do this last of all transformations."
   (if translations
       (let ((matches (car translations))
-	    (alist (cdr translations)))
+	    (alist (cdr translations))
+	    ;; Translations are case-sensitive, eg ".tr ab" does not
+	    ;; affect "A" (bug#6849).
+	    (case-fold-search nil))
 	(while (re-search-forward matches to t)
 	  ;; Done like this to retain text properties and
 	  ;; support translation of special characters:
--- a/msdos/ChangeLog	Thu Aug 19 22:47:51 2010 +0000
+++ b/msdos/ChangeLog	Sun Aug 22 22:56:05 2010 +0000
@@ -1,3 +1,11 @@
+2010-08-20  Eli Zaretskii  <eliz@gnu.org>
+
+	* sed1v2.inp (IMAGEMAGICK_LIBS, IMAGEMAGICK_CFLAGS): Edit to empty.
+
+2010-08-15  Eli Zaretskii  <eliz@gnu.org>
+
+	* mainmake.v2 (version): Update due to change in emacs.c.
+
 2010-08-05  Eli Zaretskii  <eliz@gnu.org>
 
 	* sed1v2.inp (UNEXEC_OBJ): Edit to unexcoff.o, due to renaming of
--- a/msdos/mainmake.v2	Thu Aug 19 22:47:51 2010 +0000
+++ b/msdos/mainmake.v2	Sun Aug 22 22:56:05 2010 +0000
@@ -65,7 +65,7 @@
 top_srcdir := $(subst \,/,$(shell cd))
 
 # Find out which version of Emacs this is.
-version := ${shell sed -n -e '/^const char emacs_version/s/^[^"]*\("[^"]*"\).*/\1/p' src/emacs.c}
+version := ${shell sed -n -e '/^static const char emacs_version/s/^[^"]*\("[^"]*"\).*/\1/p' src/emacs.c}
 
 # Q: Do we need to bootstrap?
 # A: Only if we find admin/admin.el, i.e. we are building out of 
--- a/msdos/sed1v2.inp	Thu Aug 19 22:47:51 2010 +0000
+++ b/msdos/sed1v2.inp	Sun Aug 22 22:56:05 2010 +0000
@@ -88,6 +88,8 @@
 /^CFLAGS_SOUND *=/s/@CFLAGS_SOUND@//
 /^RSVG_LIBS *=/s/@RSVG_LIBS@//
 /^RSVG_CFLAGS *=/s/@RSVG_CFLAGS@//
+/^IMAGEMAGICK_LIBS *=/s/@IMAGEMAGICK_LIBS@//
+/^IMAGEMAGICK_CFLAGS *=/s/@IMAGEMAGICK_CFLAGS@//
 /^WIDGET_OBJ *=/s/@WIDGET_OBJ@//
 /^CYGWIN_OBJ *=/s/@CYGWIN_OBJ@//
 /^MSDOS_OBJ *=/s/= */= dosfns.o msdos.o w16select.o/
--- a/msdos/sedleim.inp	Thu Aug 19 22:47:51 2010 +0000
+++ b/msdos/sedleim.inp	Sun Aug 22 22:56:05 2010 +0000
@@ -34,7 +34,7 @@
 
 /RUN-EMACS *=/,/^$/c\
 export EMACSLOADPATH=${buildlisppath}\
-RUN-EMACS = ${BUILT-EMACS} -batch --no-init-file --no-site-file --multibyte
+RUN-EMACS = ${BUILT-EMACS} -batch --no-init-file --no-site-file
 
 /^	cd ../c\
 	${MAKE} -C ../src ${MFLAGS} emacs
--- a/src/ChangeLog	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/ChangeLog	Sun Aug 22 22:56:05 2010 +0000
@@ -1,3 +1,129 @@
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* emacs.c (main): Remove handling of --unibyte arg (Bug#6886).
+
+2010-08-22  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* eval.c (Flet, Feval, Fapply, apply_lambda): Use SAFE_ALLOCA_LISP
+	instead of SAFE_ALLOCA.
+
+2010-08-22  Chong Yidong  <cyd@stupidchicken.com>
+
+	* eval.c (Flet, Feval, Fapply, apply_lambda): Use SAFE_ALLOCA
+	(Bug#6214).
+
+2010-08-22  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* doc.c (Fsnarf_documentation): Set skip_file only if p[1] is S.
+
+2010-08-22  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* doc.c (Fsnarf_documentation): Initialize skip_file before
+	build-files test.
+
+2010-08-22  Peter O'Gorman <pogma@thewrittenword.com>  (tiny change)
+
+	* s/hpux10-20.h (HAVE_TERMIOS, NO_TERMIO, ORDINARY_LINK): New
+	definitions.
+	(HAVE_TERMIO): Remove.
+
+2010-08-22  Eli Zaretskii  <eliz@gnu.org>
+
+	* deps.mk (sysdep.o, msdos.o): Depend on sysselect.h.
+
+	* sysselect.h [WINDOWSNT]: Don't define the FD_* and select stuff
+	for w32.
+
+	* s/ms-w32.h (HAVE_SYS_TIMEB_H): Don't #undef HAVE_SYS_SELECT_H,
+	it's done in nt/config.nt.
+
+	* makefile.w32-in ($(BLD)/sysdep.$(O)): Depend on sysselect.h.
+
+	* unexcoff.c (report_error, make_hdr, write_segment)
+	(copy_text_and_data, copy_sym, mark_x, adjust_lnnoptrs, unexec):
+	Convert argument lists and prototypes to ANSI C.
+	(make_hdr, write_segment): Remove unused variables.
+	(unexec): Remove commented-out line.  Initialize `new' to shut up
+	compiler warnings.
+
+2010-08-22  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Simplify termio code.
+	All non-MSDOS non-WINDOWSNT platforms define HAVE_TERMIOS, so
+	HAVE_TERMIO code is obsolete.
+	Replace HAVE_TERMIOS conditionals with !DOS_NT.
+	* systty.h: Do not define HAVE_TCATTR.
+	Remove HAVE_TERMIO, HAVE_LTCHARS and HAVE_TCHARS code.
+	Do not define EMACS_HAVE_TTY_PGRP.  Only define
+	EMACS_GET_TTY_PGRP for !DOS_NT.
+	* sysdep.c: Include sysselect.h unconditionally.  Do not include
+	sys/ioctl.h and termios.h, systty.h does it.  Use
+	HAVE_SYS_UTSNAME_H instead of USG as an include guard.
+	(init_baud_rate): Remove HAVE_TERMIO code.
+	(child_setup_tty): Remove HAVE_TERMIO code.
+	(emacs_get_tty, emacs_set_tty): Remove HAVE_TERMIO, HAVE_TCHARS
+	and HAVE_LTCHARS code.  Use !DOS_NT instead of HAVE_TCATTR.
+	(new_ltchars, new_tchars): Remove, unused.
+	(init_sys_modes): Remove HAVE_TERMIO, HAVE_TCHARS and HAVE_LTCHARS
+	code.  Remove special casing for __mips__, it was a no-op.  Remove
+	HAVE_TCATTR conditional, it is implied by HAVE_TERMIOS.
+	(init_sys_modes): Remove HPUX special case.
+	* process.c: Include stdlib.h unconditionally.  Do not include
+	fcntl.h, systty.h does it.  Remove conditional code for
+	HAVE_SERIAL, it is always true.
+	(process_send_signal): Remove HAVE_TERMIOS conditional, it's
+	always true when SIGNALS_VIA_CHARACTERS is true.
+	(Fcontinue_process, Fprocess_send_eof): Simplify conditionals:
+	!WINDOWSNT means HAVE_TERMIOS.
+	(create_process): Remove HAVE_TERMIOS, it's inside a HAVE_PTYS
+	conditional, which is true for all HAVE_TERMIOS systems.
+	* keyboard.c (init_keyboard): Do not use HAVE_TERMIO, use !DOS_NT
+	instead of HAVE_TERMIOS.
+	* emacs.c (shut_down_emacs): Use !defined DOS_NT instead of
+	EMACS_HAVE_TTY_PGRP.
+	* callproc.c (child_setup): Move EMACS_SET_TTY_PGRP use to the
+	non-MSDOS, non-WINDOWSNT code, it's only defined for such systems
+	anyway.
+
+2010-08-21  Eli Zaretskii  <eliz@gnu.org>
+
+	* dispnew.c (buffer_posn_from_coords): Fix off-by-one error in
+	mirroring pixel positions.
+
+2010-08-20  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* alloc.c (malloc_sbrk_used, malloc_sbrk_unused): Remove,
+	write only.
+	(init_alloc_once): Remove writes to malloc_sbrk_unused, and
+	malloc_sbrk_used, nothing uses them.
+
+	* puresize.h: Remove code assuming PNTR_COMPARISON_TYPE is not
+	defined, unconditionally defined in lisp.h.
+
+	* term.c: Do not include <termios.h>, systty.h does it.
+
+	* s/unixware.h (HAVE_TCATTR):
+	* s/aix4-2.h (HAVE_TCATTR): Remove definitions, not needed.
+	systty.h defines it when HAVE_TERMIOS is defined.
+
+2010-08-20  Eli Zaretskii  <eliz@gnu.org>
+
+	* dispnew.c (buffer_posn_from_coords): Fix last change for text
+	terminals: add one-character offset for R2L lines.
+
+	* emacs.c <emacs_version>: Add a comment regarding
+	msdos/mainmake.v2's dependency on the syntax of this declaration.
+
+2010-08-20  Eli Zaretskii  <eliz@gnu.org>
+
+	* dispnew.c (buffer_posn_from_coords): Fix calculation of buffer
+	position for R2L lines by mirroring the pixel position wrt the
+	text are box.  Improve commentary.
+
+2010-08-20  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* image.c (imagemagick_clear_image): Remove debugging output.
+
 2010-08-19  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* cmds.c (Vself_insert_face, Vself_insert_face_command): Remove.
@@ -47,6 +173,17 @@
 	NXSecondaryPboard = SecondarySelection.
 	(syms_of_nsselect): Intern QCLIPBOARD (Bug#6677).
 
+2010-08-18  Joakim Verona  <joakim@verona.se>
+
+	* image.c: Add support for ImageMagick.  When HAVE_IMAGEMAGICK is
+	defined:
+	(imagemagick_image_p): New function to test for ImageMagic image.
+	(imagemagick_load): New function to load ImageMagick image.
+	(imagemagick_load_image): New function, helper for imagemagick_load.
+	(imagemagick-types): New function.
+	(Qimagemagick): New Lisp_object.
+	(imagemagick-render-type): New variable, decides which renderer to use.
+
 2010-08-17  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* gtkutil.c (update_frame_tool_bar): Don't assume TOOL_BAR_ITEM_LABEL
--- a/src/alloc.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/alloc.c	Sun Aug 22 22:56:05 2010 +0000
@@ -214,16 +214,6 @@
 
 int garbage_collection_messages;
 
-#ifndef VIRT_ADDR_VARIES
-extern
-#endif /* VIRT_ADDR_VARIES */
-int malloc_sbrk_used;
-
-#ifndef VIRT_ADDR_VARIES
-extern
-#endif /* VIRT_ADDR_VARIES */
-int malloc_sbrk_unused;
-
 /* Number of live and free conses etc.  */
 
 static int total_conses, total_markers, total_symbols, total_vector_size;
@@ -6178,11 +6168,6 @@
   consing_since_gc = 0;
   gc_cons_threshold = 100000 * sizeof (Lisp_Object);
   gc_relative_threshold = 0;
-
-#ifdef VIRT_ADDR_VARIES
-  malloc_sbrk_unused = 1<<22;	/* A large number */
-  malloc_sbrk_used = 100000;	/* as reasonable as any number */
-#endif /* VIRT_ADDR_VARIES */
 }
 
 void
--- a/src/callproc.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/callproc.c	Sun Aug 22 22:56:05 2010 +0000
@@ -1231,8 +1231,6 @@
 #else
   setpgrp (pid, pid);
 #endif /* USG */
-  /* setpgrp_of_tty is incorrect here; it uses input_fd.  */
-  EMACS_SET_TTY_PGRP (0, &pid);
 
 #ifdef MSDOS
   pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env);
@@ -1251,6 +1249,9 @@
     report_file_error ("Spawning child process", Qnil);
   return cpid;
 #else /* not WINDOWSNT */
+  /* setpgrp_of_tty is incorrect here; it uses input_fd.  */
+  EMACS_SET_TTY_PGRP (0, &pid);
+
   /* execvp does not accept an environment arg so the only way
      to pass this environment is to set environ.  Our caller
      is responsible for restoring the ambient value of environ.  */
--- a/src/deps.mk	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/deps.mk	Sun Aug 22 22:56:05 2010 +0000
@@ -142,7 +142,7 @@
 msdos.o: msdos.c msdos.h dosfns.h systime.h termhooks.h dispextern.h frame.h \
    termopts.h termchar.h character.h coding.h ccl.h disptab.h window.h \
    keyboard.h $(INTERVALS_H) buffer.h commands.h blockinput.h atimer.h \
-   lisp.h $(config_h)
+   lisp.h sysselect.h $(config_h)
 nsfns.o: nsfns.m charset.h nsterm.h nsgui.h frame.h window.h buffer.h \
    dispextern.h fontset.h $(INTERVALS_H) keyboard.h blockinput.h \
    atimer.h systime.h epaths.h termhooks.h coding.h systime.h lisp.h $(config_h)
@@ -176,7 +176,7 @@
 sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \
    process.h dispextern.h termhooks.h termchar.h termopts.h coding.h \
    frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h lisp.h \
-   $(config_h) composite.h
+   $(config_h) composite.h sysselect.h
 term.o: term.c termchar.h termhooks.h termopts.h lisp.h $(config_h) \
    cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \
    xterm.h msdos.h window.h keymap.h blockinput.h atimer.h systime.h \
--- a/src/dispnew.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/dispnew.c	Sun Aug 22 22:56:05 2010 +0000
@@ -5351,9 +5351,15 @@
  ***********************************************************************/
 
 /* Determine what's under window-relative pixel position (*X, *Y).
-   Return the object (string or buffer) that's there.
+   Return the OBJECT (string or buffer) that's there.
    Return in *POS the position in that object.
-   Adjust *X and *Y to character positions.  */
+   Adjust *X and *Y to character positions.
+   Return in *DX and *DY the pixel coordinates of the click,
+   relative to the top left corner of OBJECT, or relative to
+   the top left corner of the character glyph at (*X, *Y)
+   if OBJECT is nil.
+   Return WIDTH and HEIGHT of the object at (*X, *Y), or zero
+   if the coordinates point to an empty area of the display.  */
 
 Lisp_Object
 buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *pos, Lisp_Object *object, int *dx, int *dy, int *width, int *height)
@@ -5366,7 +5372,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
   struct image *img = 0;
 #endif
-  int x0, x1;
+  int x0, x1, to_x;
 
   /* We used to set current_buffer directly here, but that does the
      wrong thing with `face-remapping-alist' (bug#2044).  */
@@ -5377,8 +5383,33 @@
   start_display (&it, w, startp);
 
   x0 = *x - WINDOW_LEFT_MARGIN_WIDTH (w);
-  move_it_to (&it, -1, x0 + it.first_visible_x, *y, -1,
-	      MOVE_TO_X | MOVE_TO_Y);
+
+  /* First, move to the beginning of the row corresponding to *Y.  We
+     need to be in that row to get the correct value of base paragraph
+     direction for the text at (*X, *Y).  */
+  move_it_to (&it, -1, 0, *y, -1, MOVE_TO_X | MOVE_TO_Y);
+
+  /* TO_X is the pixel position that the iterator will compute for the
+     glyph at *X.  We add it.first_visible_x because iterator
+     positions include the hscroll.  */
+  to_x = x0 + it.first_visible_x;
+  if (it.bidi_it.paragraph_dir == R2L)
+    /* For lines in an R2L paragraph, we need to mirror TO_X wrt the
+       text area.  This is because the iterator, even in R2L
+       paragraphs, delivers glyphs as if they started at the left
+       margin of the window.  (When we actually produce glyphs for
+       display, we reverse their order in PRODUCE_GLYPHS, but the
+       iterator doesn't know about that.)  The following line adjusts
+       the pixel position to the iterator geometry, which is what
+       move_it_* routines use.  (The -1 is because in a window whose
+       text-area width is W, the rightmost pixel position is W-1, and
+       it should be mirrored into zero pixel position.)  */
+    to_x = window_box_width (w, TEXT_AREA) - to_x - 1;
+
+  /* Now move horizontally in the row to the glyph under *X.  Second
+     argument is ZV to prevent move_it_in_display_line from matching
+     based on buffer positions.  */
+  move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X);
 
   Fset_buffer (old_current_buffer);
 
--- a/src/doc.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/doc.c	Sun Aug 22 22:56:05 2010 +0000
@@ -285,8 +285,7 @@
 				to - (get_doc_string_buffer + offset));
   else
     {
-      /* Let the data determine whether the string is multibyte,
-	 even if Emacs is running in --unibyte mode.  */
+      /* The data determines whether the string is multibyte.  */
       int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset,
 					    to - (get_doc_string_buffer + offset));
       return make_string_from_bytes (get_doc_string_buffer + offset,
@@ -622,24 +621,28 @@
       p = buf;
       end = buf + (filled < 512 ? filled : filled - 128);
       while (p != end && *p != '\037') p++;
-      /* p points to ^_Ffunctionname\n or ^_Vvarname\n.  */
+      /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n.  */
       if (p != end)
 	{
 	  end = strchr (p, '\n');
 
           /* See if this is a file name, and if it is a file in build-files.  */
-          if (p[1] == 'S' && end - p > 4 && end[-2] == '.'
-              && (end[-1] == 'o' || end[-1] == 'c'))
+          if (p[1] == 'S')
             {
-              int len = end - p - 2;
-              char *fromfile = alloca (len + 1);
-              strncpy (fromfile, &p[2], len);
-              fromfile[len] = 0;
-              if (fromfile[len-1] == 'c')
-                fromfile[len-1] = 'o';
+              skip_file = 0;
+              if (end - p > 4 && end[-2] == '.'
+                  && (end[-1] == 'o' || end[-1] == 'c'))
+                {
+                  int len = end - p - 2;
+                  char *fromfile = alloca (len + 1);
+                  strncpy (fromfile, &p[2], len);
+                  fromfile[len] = 0;
+                  if (fromfile[len-1] == 'c')
+                    fromfile[len-1] = 'o';
 
-	      skip_file = NILP (Fmember (build_string (fromfile),
-					 Vbuild_files));
+                  skip_file = NILP (Fmember (build_string (fromfile),
+                                             Vbuild_files));
+                }
             }
 
 	  sym = oblookup (Vobarray, p + 2,
--- a/src/emacs.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/emacs.c	Sun Aug 22 22:56:05 2010 +0000
@@ -91,6 +91,8 @@
 #endif
 #endif
 
+/* If you change the following line, remember to update
+   msdos/mainmake.v2 which gleans the Emacs version from it!  */
 static const char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc.";
 static const char emacs_version[] = "24.0.50";
 
@@ -1330,68 +1332,6 @@
   init_atimer ();
   running_asynch_code = 0;
 
-  /* Handle --unibyte and the EMACS_UNIBYTE envvar,
-     but not while dumping.  */
-  if (1)
-    {
-      int inhibit_unibyte = 0;
-
-      /* --multibyte overrides EMACS_UNIBYTE.  */
-      if (argmatch (argv, argc, "-no-unibyte", "--no-unibyte", 4, NULL, &skip_args)
-	  || argmatch (argv, argc, "-multibyte", "--multibyte", 4, NULL, &skip_args)
-	  /* Ignore EMACS_UNIBYTE before dumping.  */
-	  || (!initialized && noninteractive))
-	inhibit_unibyte = 1;
-
-      /* --unibyte requests that we set up to do everything with single-byte
-	 buffers and strings.  We need to handle this before calling
-	 init_lread, init_editfns and other places that generate Lisp strings
-	 from text in the environment.  */
-      /* Actually this shouldn't be needed as of 20.4 in a generally
-	 unibyte environment.  As handa says, environment values
-	 aren't now decoded; also existing buffers are now made
-	 unibyte during startup if .emacs sets unibyte.  Tested with
-	 8-bit data in environment variables and /etc/passwd, setting
-	 unibyte and Latin-1 in .emacs. -- Dave Love  */
-      if (argmatch (argv, argc, "-unibyte", "--unibyte", 4, NULL, &skip_args)
-	  || argmatch (argv, argc, "-no-multibyte", "--no-multibyte", 4, NULL, &skip_args)
-	  || (getenv ("EMACS_UNIBYTE") && !inhibit_unibyte))
-	{
-	  Lisp_Object old_log_max;
-	  Lisp_Object symbol, tail;
-
-	  symbol = intern_c_string ("enable-multibyte-characters");
-	  Fset_default (symbol, Qnil);
-
-	  if (initialized)
-	    {
-	      /* Erase pre-dump messages in *Messages* now so no abort.  */
-	      old_log_max = Vmessage_log_max;
-	      XSETFASTINT (Vmessage_log_max, 0);
-	      message_dolog ("", 0, 1, 0);
-	      Vmessage_log_max = old_log_max;
-	    }
-
-	  for (tail = Vbuffer_alist; CONSP (tail);
-	       tail = XCDR (tail))
-	    {
-	      Lisp_Object buffer;
-
-	      buffer = Fcdr (XCAR (tail));
-	      /* Make a multibyte buffer unibyte.  */
-	      if (BUF_Z_BYTE (XBUFFER (buffer)) > BUF_Z (XBUFFER (buffer)))
-		{
-		  struct buffer *current = current_buffer;
-
-		  set_buffer_temp (XBUFFER (buffer));
-		  Fset_buffer_multibyte (Qnil);
-		  set_buffer_temp (current);
-		}
-	    }
-	  message ("Warning: unibyte sessions are obsolete and will disappear");
-	}
-    }
-
   no_loadup
     = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args);
 
@@ -1790,10 +1730,6 @@
   { "-script", "--script", 100, 1 },
   { "-daemon", "--daemon", 99, 0 },
   { "-help", "--help", 90, 0 },
-  { "-no-unibyte", "--no-unibyte", 83, 0 },
-  { "-multibyte", "--multibyte", 82, 0 },
-  { "-unibyte", "--unibyte", 81, 0 },
-  { "-no-multibyte", "--no-multibyte", 80, 0 },
   { "-nl", "--no-loadup", 70, 0 },
   /* -d must come last before the options handled in startup.el.  */
   { "-d", "--display", 60, 1 },
@@ -2094,7 +2030,7 @@
   Vinhibit_redisplay = Qt;
 
   /* If we are controlling the terminal, reset terminal modes.  */
-#ifdef EMACS_HAVE_TTY_PGRP
+#ifndef DOS_NT
   {
     int pgrp = EMACS_GETPGRP (0);
 
--- a/src/eval.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/eval.c	Sun Aug 22 22:56:05 2010 +0000
@@ -1011,12 +1011,13 @@
   int count = SPECPDL_INDEX ();
   register int argnum;
   struct gcpro gcpro1, gcpro2;
+  USE_SAFE_ALLOCA;
 
   varlist = Fcar (args);
 
   /* Make space to hold the values to give the bound variables */
   elt = Flength (varlist);
-  temps = (Lisp_Object *) alloca (XFASTINT (elt) * sizeof (Lisp_Object));
+  SAFE_ALLOCA_LISP (temps, XFASTINT (elt));
 
   /* Compute the values and store them in `temps' */
 
@@ -1049,6 +1050,7 @@
     }
 
   elt = Fprogn (Fcdr (args));
+  SAFE_FREE ();
   return unbind_to (count, elt);
 }
 
@@ -2301,8 +2303,9 @@
 	  /* Pass a vector of evaluated arguments */
 	  Lisp_Object *vals;
 	  register int argnum = 0;
-
-	  vals = (Lisp_Object *) alloca (XINT (numargs) * sizeof (Lisp_Object));
+	  USE_SAFE_ALLOCA;
+
+	  SAFE_ALLOCA_LISP (vals, XINT (numargs));
 
 	  GCPRO3 (args_left, fun, fun);
 	  gcpro3.var = vals;
@@ -2320,6 +2323,7 @@
 
 	  val = (XSUBR (fun)->function.aMANY) (XINT (numargs), vals);
 	  UNGCPRO;
+	  SAFE_FREE ();
 	  goto done;
 	}
 
@@ -2430,8 +2434,9 @@
   register int i, numargs;
   register Lisp_Object spread_arg;
   register Lisp_Object *funcall_args;
-  Lisp_Object fun;
+  Lisp_Object fun, retval;
   struct gcpro gcpro1;
+  USE_SAFE_ALLOCA;
 
   fun = args [0];
   funcall_args = 0;
@@ -2470,8 +2475,7 @@
 	{
 	  /* Avoid making funcall cons up a yet another new vector of arguments
 	     by explicitly supplying nil's for optional values */
-	  funcall_args = (Lisp_Object *) alloca ((1 + XSUBR (fun)->max_args)
-						 * sizeof (Lisp_Object));
+	  SAFE_ALLOCA_LISP (funcall_args, 1 + XSUBR (fun)->max_args);
 	  for (i = numargs; i < XSUBR (fun)->max_args;)
 	    funcall_args[++i] = Qnil;
 	  GCPRO1 (*funcall_args);
@@ -2483,8 +2487,7 @@
      function itself as well as its arguments.  */
   if (!funcall_args)
     {
-      funcall_args = (Lisp_Object *) alloca ((1 + numargs)
-					     * sizeof (Lisp_Object));
+      SAFE_ALLOCA_LISP (funcall_args, 1 + numargs);
       GCPRO1 (*funcall_args);
       gcpro1.nvars = 1 + numargs;
     }
@@ -2500,7 +2503,11 @@
     }
 
   /* By convention, the caller needs to gcpro Ffuncall's args.  */
-  RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args));
+  retval = Ffuncall (gcpro1.nvars, funcall_args);
+  UNGCPRO;
+  SAFE_FREE ();
+
+  return retval;
 }
 
 /* Run hook variables in various ways.  */
@@ -3065,9 +3072,10 @@
   struct gcpro gcpro1, gcpro2, gcpro3;
   register int i;
   register Lisp_Object tem;
+  USE_SAFE_ALLOCA;
 
   numargs = Flength (args);
-  arg_vector = (Lisp_Object *) alloca (XINT (numargs) * sizeof (Lisp_Object));
+  SAFE_ALLOCA_LISP (arg_vector, XINT (numargs));
   args_left = args;
 
   GCPRO3 (*arg_vector, args_left, fun);
@@ -3096,6 +3104,7 @@
     tem = call_debugger (Fcons (Qexit, Fcons (tem, Qnil)));
   /* Don't do it again when we return to eval.  */
   backtrace_list->debug_on_exit = 0;
+  SAFE_FREE ();
   return tem;
 }
 
--- a/src/image.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/image.c	Sun Aug 22 22:56:05 2010 +0000
@@ -7400,7 +7400,6 @@
 imagemagick_clear_image (struct frame *f,
                          struct image *img)
 {
-  printf("clearing imagemagick image\n");
   x_clear_image (f, img);
 }
 
@@ -7485,7 +7484,6 @@
      image.  Interface :index is same as for GIF.  First we "ping" the
      image to see how many sub-images it contains. Pinging is faster
      than loading the image to find out things about it.  */
-  printf("im ping file %s\n", filename);
   image = image_spec_value (img->spec, QCindex, NULL);
   ino = INTEGERP (image) ? XFASTINT (image) : 0;
   ping_wand=NewMagickWand();
@@ -7519,7 +7517,6 @@
 
   if (filename != NULL)
     {
-      printf("im read file %s\n", filename);
       image_info=CloneImageInfo((ImageInfo *) NULL);
       (void) strcpy(image_info->filename, filename);
       image_info -> number_scenes = 1;
@@ -7529,7 +7526,6 @@
       im_image = ReadImage (image_info, exception); 
       CatchException(exception);
 
-      printf("im wand from image\n");   
       image_wand = NewMagickWandFromImage(im_image);
     }
   else
@@ -7565,7 +7561,6 @@
     }  
   if(desired_width != -1 && desired_height != -1)
     {
-      printf("MagickScaleImage %d %d\n", desired_width, desired_height);
       status = MagickScaleImage(image_wand, desired_width, desired_height);
       if (status == MagickFalse) {
         image_error ("Imagemagick scale failed", Qnil, Qnil);
@@ -7592,7 +7587,6 @@
       h=XFASTINT(XCAR(XCDR(crop)));
       x=XFASTINT(XCAR(XCDR(XCDR(crop))));
       y=XFASTINT(XCAR(XCDR(XCDR(XCDR(crop)))));
-      printf("MagickCropImage(image_wand, %d,%d, %d,%d)\n", w, h, x, y);
       MagickCropImage(image_wand, w,h, x,y);
     }
   
@@ -7609,7 +7603,6 @@
       PixelSetColor (background, "#ffffff");/*TODO remove hardcode*/
         
       rotation = extract_float (value);
-      printf ("MagickRotateImage %f\n", rotation);
         
       status = MagickRotateImage (image_wand, background, rotation);
       DestroyPixelWand (background);
@@ -7691,7 +7684,6 @@
       int imagedepth = 24;/*MagickGetImageDepth(image_wand);*/
       char* exportdepth = imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/
       /* Try to create a x pixmap to hold the imagemagick pixmap.  */
-      printf("imagedepth:%d exportdepth:%s\n", imagedepth, exportdepth);
       if (!x_create_x_image_and_pixmap (f, width, height, imagedepth,
                                         &ximg, &img->pixmap)){
         image_error("Imagemagick X bitmap allocation failure", Qnil, Qnil);
@@ -7758,7 +7750,6 @@
  imagemagick_error:
   /* TODO more cleanup.  */
   image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec, Qnil);
-  printf("Imagemagick error, see *Messages*\n");
   return 0;
 }
 
--- a/src/keyboard.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/keyboard.c	Sun Aug 22 22:56:05 2010 +0000
@@ -11506,11 +11506,11 @@
          Emacs on SIGINT when there are no termcap frames on the
          controlling terminal. */
       signal (SIGINT, interrupt_signal);
-#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
+#ifndef DOS_NT
       /* For systems with SysV TERMIO, C-g is set up for both SIGINT and
 	 SIGQUIT and we can't tell which one it will give us.  */
       signal (SIGQUIT, interrupt_signal);
-#endif /* HAVE_TERMIO */
+#endif /* not DOS_NT */
     }
 /* Note SIGIO has been undef'd if FIONREAD is missing.  */
 #ifdef SIGIO
--- a/src/makefile.w32-in	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/makefile.w32-in	Sun Aug 22 22:56:05 2010 +0000
@@ -1357,6 +1357,7 @@
 	$(SRC)/frame.h \
 	$(SRC)/keyboard.h \
 	$(SRC)/process.h \
+	$(SRC)/sysselect.h \
 	$(SRC)/syssignal.h \
 	$(SRC)/systime.h \
 	$(SRC)/systty.h \
--- a/src/process.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/process.c	Sun Aug 22 22:56:05 2010 +0000
@@ -31,9 +31,7 @@
 #ifdef HAVE_INTTYPES_H
 #include <inttypes.h>
 #endif
-#ifdef STDC_HEADERS
 #include <stdlib.h>
-#endif
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -61,9 +59,6 @@
 
 #if defined(HAVE_SYS_IOCTL_H)
 #include <sys/ioctl.h>
-#if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5)
-#include <fcntl.h>
-#endif /* HAVE_PTYS and no O_NDELAY */
 #if defined(HAVE_NET_IF_H)
 #include <net/if.h>
 #endif /* HAVE_NET_IF_H */
@@ -182,16 +177,9 @@
 
 extern const char *get_operating_system_release (void);
 
-/* Serial processes require termios or Windows.  */
-#if defined (HAVE_TERMIOS) || defined (WINDOWSNT)
-#define HAVE_SERIAL
-#endif
-
-#ifdef HAVE_SERIAL
 /* From sysdep.c or w32.c  */
 extern int serial_open (char *port);
 extern void serial_configure (struct Lisp_Process *p, Lisp_Object contact);
-#endif
 
 #ifndef HAVE_H_ERRNO
 extern int h_errno;
@@ -1903,7 +1891,7 @@
 	setpgrp ();
 #endif /* USG */
 #endif /* not HAVE_SETSID */
-#if defined (HAVE_TERMIOS) && defined (LDISC1)
+#if defined (LDISC1)
 	if (pty_flag && xforkin >= 0)
 	  {
 	    struct termios t;
@@ -2569,7 +2557,6 @@
 }
 
 
-#ifdef HAVE_SERIAL
 DEFUN ("serial-process-configure",
        Fserial_process_configure,
        Sserial_process_configure,
@@ -2865,7 +2852,6 @@
   UNGCPRO;
   return proc;
 }
-#endif /* HAVE_SERIAL  */
 
 /* Create a network stream/datagram client/server process.  Treated
    exactly like a normal process when reading and writing.  Primary
@@ -5801,9 +5787,6 @@
       /* If possible, send signals to the entire pgrp
 	 by sending an input character to it.  */
 
-      /* TERMIOS is the latest and bestest, and seems most likely to
-	 work.  If the system has it, use it.  */
-#ifdef HAVE_TERMIOS
       struct termios t;
       cc_t *sig_char = NULL;
 
@@ -5835,65 +5818,6 @@
 	}
       /* If we can't send the signal with a character,
 	 fall through and send it another way.  */
-#else /* ! HAVE_TERMIOS */
-
-      /* On Berkeley descendants, the following IOCTL's retrieve the
-	 current control characters.  */
-#if defined (TIOCGLTC) && defined (TIOCGETC)
-
-      struct tchars c;
-      struct ltchars lc;
-
-      switch (signo)
-	{
-	case SIGINT:
-	  ioctl (p->infd, TIOCGETC, &c);
-	  send_process (proc, &c.t_intrc, 1, Qnil);
-	  return;
-	case SIGQUIT:
-	  ioctl (p->infd, TIOCGETC, &c);
-	  send_process (proc, &c.t_quitc, 1, Qnil);
-	  return;
-#ifdef SIGTSTP
-	case SIGTSTP:
-	  ioctl (p->infd, TIOCGLTC, &lc);
-	  send_process (proc, &lc.t_suspc, 1, Qnil);
-	  return;
-#endif /* ! defined (SIGTSTP) */
-	}
-
-#else /* ! defined (TIOCGLTC) && defined (TIOCGETC) */
-
-      /* On SYSV descendants, the TCGETA ioctl retrieves the current control
-	 characters.  */
-#ifdef TCGETA
-      struct termio t;
-      switch (signo)
-	{
-	case SIGINT:
-	  ioctl (p->infd, TCGETA, &t);
-	  send_process (proc, &t.c_cc[VINTR], 1, Qnil);
-	  return;
-	case SIGQUIT:
-	  ioctl (p->infd, TCGETA, &t);
-	  send_process (proc, &t.c_cc[VQUIT], 1, Qnil);
-	  return;
-#ifdef SIGTSTP
-	case SIGTSTP:
-	  ioctl (p->infd, TCGETA, &t);
-	  send_process (proc, &t.c_cc[VSWTCH], 1, Qnil);
-	  return;
-#endif /* ! defined (SIGTSTP) */
-	}
-#else /* ! defined (TCGETA) */
-      Your configuration files are messed up.
-      /* If your system configuration files define SIGNALS_VIA_CHARACTERS,
-	 you'd better be using one of the alternatives above!  */
-#endif /* ! defined (TCGETA) */
-#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */
-	/* In this case, the code above should alway return.  */
-	abort ();
-#endif /* ! defined HAVE_TERMIOS */
 
       /* The code above may fall through if it can't
 	 handle the signal.  */
@@ -6065,10 +5989,9 @@
 #ifdef WINDOWSNT
 	  if (fd_info[ p->infd ].flags & FILE_SERIAL)
 	    PurgeComm (fd_info[ p->infd ].hnd, PURGE_RXABORT | PURGE_RXCLEAR);
-#endif
-#ifdef HAVE_TERMIOS
+#else /* not WINDOWSNT */
 	  tcflush (p->infd, TCIFLUSH);
-#endif
+#endif /* not WINDOWSNT */
 	}
       p->command = Qnil;
       return process;
@@ -6282,10 +6205,10 @@
     send_process (proc, "\004", 1, Qnil);
   else if (EQ (XPROCESS (proc)->type, Qserial))
     {
-#ifdef HAVE_TERMIOS
+#ifndef WINDOWSNT
       if (tcdrain (XPROCESS (proc)->outfd) != 0)
 	error ("tcdrain() failed: %s", emacs_strerror (errno));
-#endif
+#endif /* not WINDOWSNT */
       /* Do nothing on Windows because writes are blocking.  */
     }
   else
@@ -7672,10 +7595,8 @@
   defsubr (&Slist_processes);
   defsubr (&Sprocess_list);
   defsubr (&Sstart_process);
-#ifdef HAVE_SERIAL
   defsubr (&Sserial_process_configure);
   defsubr (&Smake_serial_process);
-#endif /* HAVE_SERIAL  */
   defsubr (&Sset_network_process_option);
   defsubr (&Smake_network_process);
   defsubr (&Sformat_network_address);
--- a/src/puresize.h	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/puresize.h	Sun Aug 22 22:56:05 2010 +0000
@@ -87,7 +87,6 @@
   && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure)
 
 #else /* not VIRT_ADDR_VARIES */
-#ifdef PNTR_COMPARISON_TYPE
 /* When PNTR_COMPARISON_TYPE is not the default (unsigned int).  */
 
 extern char my_edata[];
@@ -95,14 +94,6 @@
 #define PURE_P(obj) \
   ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) my_edata)
 
-#else /* not VIRT_ADDRESS_VARIES, not PNTR_COMPARISON_TYPE */
-
-extern char my_edata[];
-
-#define PURE_P(obj) \
-  (XPNTR (obj) < (unsigned int) my_edata)
-
-#endif /* PNTR_COMPARISON_TYPE */
 #endif /* VIRT_ADDRESS_VARIES */
 
 /* arch-tag: fd9b0a91-a70e-4729-a75a-6bb4ca1ce14f
--- a/src/s/aix4-2.h	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/s/aix4-2.h	Sun Aug 22 22:56:05 2010 +0000
@@ -55,10 +55,6 @@
 
 /* Special items needed to make Emacs run on this system.  */
 
-/* The following definition seems to be needed in AIX version 3.1.6.8.
-   It may not have been needed in certain earlier versions.  */
-#define HAVE_TCATTR
-
 /* AIX doesn't define this.  */
 #define unix 1
 
--- a/src/s/hpux10-20.h	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/s/hpux10-20.h	Sun Aug 22 22:56:05 2010 +0000
@@ -35,9 +35,10 @@
    if system supports pty's.  'p' means it is /dev/ptym/ptyp0  */
 #define FIRST_PTY_LETTER 'p'
 
-/* Define HAVE_TERMIO if the system provides sysV-style ioctls
-   for terminal control.  */
-#define HAVE_TERMIO
+#define HAVE_TERMIOS
+#define NO_TERMIO
+
+#define ORDINARY_LINK
 
 /* Define HAVE_PTYS if the system supports pty devices.  */
 #define HAVE_PTYS
--- a/src/s/ms-w32.h	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/s/ms-w32.h	Sun Aug 22 22:56:05 2010 +0000
@@ -106,7 +106,6 @@
 #define HAVE_SOUND  1
 #define LISP_FLOAT_TYPE 1
 
-#undef  HAVE_SYS_SELECT_H
 #define HAVE_SYS_TIMEB_H 1
 #define HAVE_SYS_TIME_H 1
 #define HAVE_UNISTD_H 1
--- a/src/s/unixware.h	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/s/unixware.h	Sun Aug 22 22:56:05 2010 +0000
@@ -21,8 +21,6 @@
 
 #include "usg5-4-common.h"
 
-/* fnf@cygnus.com says these exist.  */
-#define HAVE_TCATTR
 /* #define HAVE_GETWD  (appears to be buggy on SVR4.2) */
 #undef HAVE_GETWD
 
--- a/src/sysdep.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/sysdep.c	Sun Aug 22 22:56:05 2010 +0000
@@ -35,15 +35,7 @@
 #endif
 
 #include "lisp.h"
-/* Including stdlib.h isn't necessarily enough to get srandom
-   declared, e.g. without __USE_XOPEN_EXTENDED with glibc 2.  */
-
-/* The w32 build defines select stuff in w32.h, which is included by
-   sys/select.h (included below).   */
-#ifndef WINDOWSNT
 #include "sysselect.h"
-#endif
-
 #include "blockinput.h"
 
 #ifdef WINDOWSNT
@@ -84,17 +76,13 @@
 #include <fcntl.h>
 #endif
 
-#ifndef MSDOS
-#include <sys/ioctl.h>
-#endif
-
 #include "systty.h"
 #include "syswait.h"
 
-#if defined (USG)
+#ifdef HAVE_SYS_UTSNAME_H
 #include <sys/utsname.h>
 #include <memory.h>
-#endif /* USG */
+#endif /* HAVE_SYS_UTSNAME_H */
 
 #include "keyboard.h"
 #include "frame.h"
@@ -149,17 +137,6 @@
     1800, 2400, 4800, 9600, 19200, 38400
   };
 
-#ifdef HAVE_SPEED_T
-#include <termios.h>
-#else
-#if defined (HAVE_LIBNCURSES) && ! defined (NCURSES_OSPEED_T)
-#else
-#if defined (HAVE_TERMIOS_H) && defined (GNU_LINUX)
-#include <termios.h>
-#endif
-#endif
-#endif
-
 int emacs_ospeed;
 
 void croak (char *) NO_RETURN;
@@ -308,32 +285,11 @@
 #ifdef DOS_NT
     emacs_ospeed = 15;
 #else  /* not DOS_NT */
-#ifdef HAVE_TERMIOS
       struct termios sg;
 
       sg.c_cflag = B9600;
       tcgetattr (fd, &sg);
       emacs_ospeed = cfgetospeed (&sg);
-#else /* not TERMIOS */
-#ifdef HAVE_TERMIO
-      struct termio sg;
-
-      sg.c_cflag = B9600;
-#ifdef HAVE_TCATTR
-      tcgetattr (fd, &sg);
-#else
-      ioctl (fd, TCGETA, &sg);
-#endif
-      emacs_ospeed = sg.c_cflag & CBAUD;
-#else /* neither TERMIOS nor TERMIO */
-      struct sgttyb sg;
-
-      sg.sg_ospeed = B9600;
-      if (ioctl (fd, TIOCGETP, &sg) < 0)
-	abort ();
-      emacs_ospeed = sg.sg_ospeed;
-#endif /* not HAVE_TERMIO */
-#endif /* not HAVE_TERMIOS */
 #endif /* not DOS_NT */
     }
 
@@ -417,7 +373,7 @@
 void
 flush_pending_output (int channel)
 {
-#ifdef HAVE_TERMIOS
+#ifndef DOS_NT
   /* If we try this, we get hit with SIGTTIN, because
      the child's tty belongs to the child's pgrp. */
 #else
@@ -447,8 +403,6 @@
   struct emacs_tty s;
 
   EMACS_GET_TTY (out, &s);
-
-#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
   s.main.c_oflag |= OPOST;	/* Enable output postprocessing */
   s.main.c_oflag &= ~ONLCR;	/* Disable map of NL to CR-NL on output */
 #ifdef NLDLY
@@ -526,19 +480,7 @@
   s.main.c_cc[VTIME] = 0;
 #endif
 
-#else /* not HAVE_TERMIO */
-
-  s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE
-		       | CBREAK | TANDEM);
-  s.main.sg_flags |= LPASS8;
-  s.main.sg_erase = 0377;
-  s.main.sg_kill = 0377;
-  s.lmode = LLITOUT | s.lmode;        /* Don't strip 8th bit */
-
-#endif /* not HAVE_TERMIO */
-
   EMACS_SET_TTY (out, &s, 0);
-
 #endif /* not WINDOWSNT */
 }
 #endif	/* MSDOS */
@@ -841,38 +783,11 @@
 emacs_get_tty (int fd, struct emacs_tty *settings)
 {
   /* Retrieve the primary parameters - baud rate, character size, etcetera.  */
-#ifdef HAVE_TCATTR
+#ifndef DOS_NT
   /* We have those nifty POSIX tcmumbleattr functions.  */
   memset (&settings->main, 0, sizeof (settings->main));
   if (tcgetattr (fd, &settings->main) < 0)
     return -1;
-
-#else
-#ifdef HAVE_TERMIO
-  /* The SYSV-style interface?  */
-  if (ioctl (fd, TCGETA, &settings->main) < 0)
-    return -1;
-
-#else
-#ifndef DOS_NT
-  /* I give up - I hope you have the BSD ioctls.  */
-  if (ioctl (fd, TIOCGETP, &settings->main) < 0)
-    return -1;
-#endif /* not DOS_NT */
-#endif
-#endif
-
-  /* Suivant - Do we have to get struct ltchars data?  */
-#ifdef HAVE_LTCHARS
-  if (ioctl (fd, TIOCGLTC, &settings->ltchars) < 0)
-    return -1;
-#endif
-
-  /* How about a struct tchars and a wordful of lmode bits?  */
-#ifdef HAVE_TCHARS
-  if (ioctl (fd, TIOCGETC, &settings->tchars) < 0
-      || ioctl (fd, TIOCLGET, &settings->lmode) < 0)
-    return -1;
 #endif
 
   /* We have survived the tempest.  */
@@ -888,7 +803,7 @@
 emacs_set_tty (int fd, struct emacs_tty *settings, int flushp)
 {
   /* Set the primary parameters - baud rate, character size, etcetera.  */
-#ifdef HAVE_TCATTR
+#ifndef DOS_NT
   int i;
   /* We have those nifty POSIX tcmumbleattr functions.
      William J. Smith <wjs@wiis.wang.com> writes:
@@ -926,34 +841,6 @@
 	else
 	  continue;
       }
-
-#else
-#ifdef HAVE_TERMIO
-  /* The SYSV-style interface?  */
-  if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0)
-    return -1;
-
-#else
-#ifndef DOS_NT
-  /* I give up - I hope you have the BSD ioctls.  */
-  if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0)
-    return -1;
-#endif /* not DOS_NT */
-
-#endif
-#endif
-
-  /* Suivant - Do we have to get struct ltchars data?  */
-#ifdef HAVE_LTCHARS
-  if (ioctl (fd, TIOCSLTC, &settings->ltchars) < 0)
-    return -1;
-#endif
-
-  /* How about a struct tchars and a wordful of lmode bits?  */
-#ifdef HAVE_TCHARS
-  if (ioctl (fd, TIOCSETC, &settings->tchars) < 0
-      || ioctl (fd, TIOCLSET, &settings->lmode) < 0)
-    return -1;
 #endif
 
   /* We have survived the tempest.  */
@@ -976,13 +863,6 @@
 char _sobuf[BUFSIZ];
 #endif
 
-#ifdef HAVE_LTCHARS
-static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1};
-#endif
-#ifdef HAVE_TCHARS
-static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1};
-#endif
-
 /* Initialize the terminal mode on all tty devices that are currently
    open. */
 
@@ -1016,7 +896,7 @@
 
   tty = *tty_out->old_tty;
 
-#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
+#if !defined (DOS_NT)
   XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]);
 
   tty.main.c_iflag |= (IGNBRK);	/* Ignore break condition */
@@ -1088,12 +968,11 @@
 					   of C-z */
 #endif /* VSWTCH */
 
-#if defined (__mips__) || defined (HAVE_TCATTR)
 #ifdef VSUSP
-  tty.main.c_cc[VSUSP] = CDISABLE;	/* Turn off mips handling of C-z.  */
+  tty.main.c_cc[VSUSP] = CDISABLE;	/* Turn off handling of C-z.  */
 #endif /* VSUSP */
 #ifdef V_DSUSP
-  tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y.  */
+  tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off handling of C-y.  */
 #endif /* V_DSUSP */
 #ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP.  */
   tty.main.c_cc[VDSUSP] = CDISABLE;
@@ -1129,7 +1008,6 @@
       tty.main.c_cc[VSTOP] = CDISABLE;
 #endif /* VSTOP */
     }
-#endif /* mips or HAVE_TCATTR */
 
 #ifdef AIX
   tty.main.c_cc[VSTRT] = CDISABLE;
@@ -1152,41 +1030,8 @@
   tty.main.c_iflag &= ~IGNBRK;
   tty.main.c_iflag &= ~BRKINT;
 #endif
-#else /* if not HAVE_TERMIO */
-#ifndef DOS_NT
-  XSETINT (Vtty_erase_char, tty.main.sg_erase);
-  tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
-  if (meta_key)
-    tty.main.sg_flags |= ANYP;
-  tty.main.sg_flags |= interrupt_input ? RAW : CBREAK;
 #endif /* not DOS_NT */
-#endif /* not HAVE_TERMIO */
-
-  /* If going to use CBREAK mode, we must request C-g to interrupt
-     and turn off start and stop chars, etc.  If not going to use
-     CBREAK mode, do this anyway so as to turn off local flow
-     control for user coming over network on 4.2; in this case,
-     only t_stopc and t_startc really matter.  */
-#ifndef HAVE_TERMIO
-#ifdef HAVE_TCHARS
-  /* Note: if not using CBREAK mode, it makes no difference how we
-     set this */
-  tty.tchars = new_tchars;
-  tty.tchars.t_intrc = quit_char;
-  if (tty_out->flow_control)
-    {
-      tty.tchars.t_startc = '\021';
-      tty.tchars.t_stopc = '\023';
-    }
-
-  tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode;
-
-#endif /* HAVE_TCHARS */
-#endif /* not HAVE_TERMIO */
-
-#ifdef HAVE_LTCHARS
-  tty.ltchars = new_ltchars;
-#endif /* HAVE_LTCHARS */
+
 #ifdef MSDOS	/* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */
   if (!tty_out->term_initted)
     internal_terminal_init ();
@@ -1205,7 +1050,7 @@
   if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TIOCSTART, 0);
 #endif
 
-#if defined (HAVE_TERMIOS) || defined (HPUX)
+#if !defined (DOS_NT)
 #ifdef TCOON
   if (!tty_out->flow_control) tcflow (fileno (tty_out->input), TCOON);
 #endif
@@ -2688,7 +2533,7 @@
 }
 #endif /* HAVE_STRSIGNAL */
 
-#ifdef HAVE_TERMIOS
+#ifndef DOS_NT
 /* For make-serial-process  */
 int
 serial_open (char *port)
@@ -2717,9 +2562,6 @@
 
   return fd;
 }
-#endif /* TERMIOS  */
-
-#ifdef HAVE_TERMIOS
 
 #if !defined (HAVE_CFMAKERAW)
 /* Workaround for targets which are missing cfmakeraw.  */
@@ -2906,7 +2748,7 @@
   p->childp = childp2;
 
 }
-#endif /* TERMIOS  */
+#endif /* not DOS_NT  */
 
 /* System depended enumeration of and access to system processes a-la ps(1).  */
 
--- a/src/sysselect.h	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/sysselect.h	Sun Aug 22 22:56:05 2010 +0000
@@ -27,6 +27,10 @@
 #endif
 #endif
 
+/* The w32 build defines select stuff in w32.h, which is included
+   where w32 needs it, but not where sysselect.h is included.  The w32
+   definitions in w32.h are incompatible with the below.  */
+#ifndef WINDOWSNT
 #ifdef FD_SET
 #ifdef FD_SETSIZE
 #define MAXDESC FD_SETSIZE
@@ -44,6 +48,7 @@
 #define FD_ISSET(n, p) (*(p) & (1 << (n)))
 #define FD_ZERO(p) (*(p) = 0)
 #endif /* no FD_SET */
+#endif /* not WINDOWSNT */
 
 #if !defined (HAVE_SELECT)
 #define select sys_select
--- a/src/systty.h	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/systty.h	Sun Aug 22 22:56:05 2010 +0000
@@ -17,34 +17,17 @@
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifdef HAVE_TERMIOS
-#define HAVE_TCATTR
-#endif
-
-
 /* Include the proper files.  */
-#ifdef HAVE_TERMIO
+#ifndef DOS_NT
 #ifndef NO_TERMIO
 #include <termio.h>
 #endif /* not NO_TERMIO */
-#include <fcntl.h>
-#else /* not HAVE_TERMIO */
-#ifdef HAVE_TERMIOS
-#ifndef NO_TERMIO
-#include <termio.h>
-#endif
 #include <termios.h>
 #include <fcntl.h>
-#else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
-#ifndef DOS_NT
-#include <sgtty.h>
 #endif /* not DOS_NT */
-#endif /* not HAVE_TERMIOS */
-#endif /* not HAVE_TERMIO */
 
-#ifdef __GNU_LIBRARY__
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
-#include <termios.h>
 #endif
 
 #ifdef HPUX
@@ -74,17 +57,6 @@
 #undef SIGIO
 #endif
 
-/* On TERMIOS systems, the tcmumbleattr calls take care of these
-   parameters, and it's a bad idea to use them (on AIX, it makes the
-   tty hang for a long time).  */
-#if defined (TIOCGLTC) && !defined (HAVE_TERMIOS)
-#define HAVE_LTCHARS
-#endif
-
-#if defined (TIOCGETC) && !defined (HAVE_TERMIOS)
-#define HAVE_TCHARS
-#endif
-
 
 /* Try to establish the correct character to disable terminal functions
    in a system-independent manner.  Note that USG (at least) define
@@ -111,60 +83,19 @@
 #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size)))
 #endif
 
-#ifdef HAVE_TERMIO
-#ifdef TCOUTQ
-#undef EMACS_OUTQSIZE
-#define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size)))
-#endif
-#endif
-
 
 /* Manipulate a terminal's current process group.  */
 
-/* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current
-   controlling process group.
-
-   EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
+/* EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
    current process group.  Return -1 if there is an error.
 
    EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
    current process group to *PGID.  Return -1 if there is an error.  */
 
-/* HPUX tty process group stuff doesn't work, says the anonymous voice
-   from the past.  */
-#ifndef HPUX
-#ifdef TIOCGPGRP
-#define EMACS_HAVE_TTY_PGRP
-#else
-#ifdef HAVE_TERMIOS
-#define EMACS_HAVE_TTY_PGRP
-#endif /* HAVE_TERMIOS */
-#endif /* TIOCGPGRP */
-#endif /* not HPUX */
-
-#ifdef EMACS_HAVE_TTY_PGRP
-
-#if defined (HAVE_TERMIOS)
-
+#ifndef DOS_NT
 #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd)))
 #define EMACS_SET_TTY_PGRP(fd, pgid) (tcsetpgrp ((fd), *(pgid)))
-
-#else /* not HAVE_TERMIOS */
-#ifdef TIOCSPGRP
-
-#define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid)))
-#define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid)))
-
-#endif /* TIOCSPGRP */
-#endif /* HAVE_TERMIOS */
-
-#else /* not EMACS_SET_TTY_PGRP */
-
-/* Just ignore this for now and hope for the best */
-#define EMACS_GET_TTY_PGRP(fd, pgid) 0
-#define EMACS_SET_TTY_PGRP(fd, pgif) 0
-
-#endif /* not EMACS_SET_TTY_PGRP */
+#endif /* not DOS_NT */
 
 /* EMACS_GETPGRP (arg) returns the process group of the process.  */
 
@@ -207,32 +138,11 @@
 
 /* There is always one of the following elements, so there is no need
    for dummy get and set definitions.  */
-#ifdef HAVE_TCATTR
+#ifndef DOS_NT
   struct termios main;
-#else /* not HAVE_TCATTR */
-#ifdef HAVE_TERMIO
-  struct termio main;
-#else /* not HAVE_TERMIO */
-#ifdef DOS_NT
+#else /* DOS_NT */
   int main;
-#else  /* not DOS_NT */
-  struct sgttyb main;
-#endif /* not DOS_NT */
-#endif /* not HAVE_TERMIO */
-#endif /* not HAVE_TCATTR */
-
-/* If we have TERMIOS, we don't need to do this - they're taken care of
-   by the tc*attr calls.  */
-#ifndef HAVE_TERMIOS
-#ifdef HAVE_LTCHARS
-  struct ltchars ltchars;
-#endif /* HAVE_LTCHARS */
-
-#ifdef HAVE_TCHARS
-  struct tchars tchars;
-  int lmode;
-#endif /* HAVE_TCHARS */
-#endif /* not defined HAVE_TERMIOS */
+#endif /* DOS_NT */
 };
 
 /* Define EMACS_GET_TTY and EMACS_SET_TTY,
@@ -249,7 +159,7 @@
 
 /* Define EMACS_TTY_TABS_OK.  */
 
-#ifdef HAVE_TERMIOS
+#ifndef DOS_NT
 
 #ifdef TABDLY
 #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
@@ -257,21 +167,9 @@
 #define EMACS_TTY_TABS_OK(p) 1
 #endif /* not TABDLY */
 
-#else /* not def HAVE_TERMIOS */
-#ifdef HAVE_TERMIO
-
-#define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
-
-#else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
-
-#ifdef DOS_NT
+#else /* DOS_NT */
 #define EMACS_TTY_TABS_OK(p) 0
-#else /* not DOS_NT */
-#define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS)
-#endif /* not DOS_NT */
-
-#endif /* not def HAVE_TERMIO */
-#endif /* not def HAVE_TERMIOS */
+#endif /* DOS_NT */
 
 /* arch-tag: cf4b90bc-be41-401c-be98-40619178a712
    (do not change this comment) */
--- a/src/term.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/term.c	Sun Aug 22 22:56:05 2010 +0000
@@ -31,9 +31,6 @@
 #include <unistd.h>
 #endif
 
-#if HAVE_TERMIOS_H
-#include <termios.h>		/* For TIOCNOTTY. */
-#endif
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
--- a/src/unexcoff.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/unexcoff.c	Sun Aug 22 22:56:05 2010 +0000
@@ -84,6 +84,7 @@
 #ifdef MSDOS
 #include <fcntl.h>  /* for O_RDONLY, O_RDWR */
 #include <crt0.h>   /* for _crt0_startup_flags and its bits */
+#include <sys/exceptn.h>
 static int save_djgpp_startup_flags;
 #define filehdr external_filehdr
 #define scnhdr external_scnhdr
@@ -128,7 +129,7 @@
 #endif
 
 
-extern char *start_of_data ();		/* Start of initialized data */
+extern char *start_of_data (void);		/* Start of initialized data */
 
 static long block_copy_start;		/* Old executable start point */
 static struct filehdr f_hdr;		/* File header */
@@ -153,10 +154,8 @@
 #include <setjmp.h>
 #include "lisp.h"
 
-static
-report_error (file, fd)
-     char *file;
-     int fd;
+static void
+report_error (const char *file, int fd)
 {
   if (fd)
     close (fd);
@@ -167,20 +166,18 @@
 #define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1
 #define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1
 
-static
-report_error_1 (fd, msg, a1, a2)
-     int fd;
-     char *msg;
-     int a1, a2;
+static void
+report_error_1 (int fd, const char *msg, int a1, int a2)
 {
   close (fd);
   error (msg, a1, a2);
 }
 
-static int make_hdr ();
-static int copy_text_and_data ();
-static int copy_sym ();
-static void mark_x ();
+static int make_hdr (int, int, unsigned, unsigned, unsigned,
+		     const char *, const char *);
+static int copy_text_and_data (int, int);
+static int copy_sym (int, int, const char *, const char *);
+static void mark_x (const char *);
 
 /* ****************************************************************
  * make_hdr
@@ -189,13 +186,9 @@
  * Modify the text and data sizes.
  */
 static int
-make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
-     int new, a_out;
-     unsigned data_start, bss_start, entry_address;
-     char *a_name;
-     char *new_name;
+make_hdr (int new, int a_out, unsigned data_start, unsigned bss_start,
+	  unsigned entry_address, const char *a_name, const char *new_name)
 {
-  int tem;
   auto struct scnhdr f_thdr;		/* Text section header */
   auto struct scnhdr f_dhdr;		/* Data section header */
   auto struct scnhdr f_bhdr;		/* Bss section header */
@@ -363,12 +356,10 @@
 
 }
 
-write_segment (new, ptr, end)
-     int new;
-     register char *ptr, *end;
+void
+write_segment (int new, const char *ptr, const char *end)
 {
   register int i, nwrite, ret;
-  char buf[80];
   /* This is the normal amount to write at once.
      It is the size of block that NFS uses.  */
   int writesize = 1 << 13;
@@ -411,8 +402,7 @@
  * Copy the text and data segments from memory to the new a.out
  */
 static int
-copy_text_and_data (new, a_out)
-     int new, a_out;
+copy_text_and_data (int new, int a_out)
 {
   register char *end;
   register char *ptr;
@@ -456,9 +446,7 @@
  * Copy the relocation information and symbol table from the a.out to the new
  */
 static int
-copy_sym (new, a_out, a_name, new_name)
-     int new, a_out;
-     char *a_name, *new_name;
+copy_sym (int new, int a_out, const char *a_name, const char *new_name)
 {
   char page[1024];
   int n;
@@ -494,8 +482,7 @@
  * After successfully building the new a.out, mark it executable
  */
 static void
-mark_x (name)
-     char *name;
+mark_x (const char *name)
 {
   struct stat sbuf;
   int um;
@@ -535,10 +522,8 @@
    a reasonable size buffer.  But I don't have time to work on such
    things, so I am installing it as submitted to me.  -- RMS.  */
 
-adjust_lnnoptrs (writedesc, readdesc, new_name)
-     int writedesc;
-     int readdesc;
-     char *new_name;
+int
+adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name)
 {
   register int nsyms;
   register int new;
@@ -585,11 +570,11 @@
  *
  * driving logic.
  */
-unexec (new_name, a_name, data_start, bss_start, entry_address)
-     char *new_name, *a_name;
-     unsigned data_start, bss_start, entry_address;
+int
+unexec (const char *new_name, const char *a_name,
+	unsigned data_start, unsigned bss_start, unsigned entry_address)
 {
-  int new, a_out = -1;
+  int new = -1, a_out = -1;
 
   if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
     {
@@ -607,7 +592,6 @@
       )
     {
       close (new);
-      /* unlink (new_name);	    	/* Failed, unlink new a.out */
       return -1;
     }
 
--- a/src/xdisp.c	Thu Aug 19 22:47:51 2010 +0000
+++ b/src/xdisp.c	Sun Aug 22 22:56:05 2010 +0000
@@ -217,7 +217,26 @@
    glyph with suitably computed width.  Both the blanks and the
    stretch glyph are given the face of the background of the line.
    This way, the terminal-specific back-end can still draw the glyphs
-   left to right, even for R2L lines.  */
+   left to right, even for R2L lines.
+
+   Note one important detail mentioned above: that the bidi reordering
+   engine, driven by the iterator, produces characters in R2L rows
+   starting at the character that will be the rightmost on display.
+   As far as the iterator is concerned, the geometry of such rows is
+   still left to right, i.e. the iterator "thinks" the first character
+   is at the leftmost pixel position.  The iterator does not know that
+   PRODUCE_GLYPHS reverses the order of the glyphs that the iterator
+   delivers.  This is important when functions from the the move_it_*
+   family are used to get to certain screen position or to match
+   screen coordinates with buffer coordinates: these functions use the
+   iterator geometry, which is left to right even in R2L paragraphs.
+   This works well with most callers of move_it_*, because they need
+   to get to a specific column, and columns are still numbered in the
+   reading order, i.e. the rightmost character in a R2L paragraph is
+   still column zero.  But some callers do not get well with this; a
+   notable example is mouse clicks that need to find the character
+   that corresponds to certain pixel coordinates.  See
+   buffer_posn_from_coords in dispnew.c for how this is handled.  */
 
 #include <config.h>
 #include <stdio.h>
@@ -10839,7 +10858,7 @@
   enum draw_glyphs_face draw = DRAW_IMAGE_RAISED;
   int mouse_down_p, rc;
 
-  /* Function note_mouse_highlight is called with negative x(y
+  /* Function note_mouse_highlight is called with negative X/Y
      values when mouse moves outside of the frame.  */
   if (x <= 0 || y <= 0)
     {