changeset 83239:025da3ba778e

Merged in changes from CVS trunk. Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-753 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-754 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-755 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-756 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-757 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-81 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-82 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-279
author Karoly Lorentey <lorentey@elte.hu>
date Thu, 06 Jan 2005 15:05:01 +0000
parents 223c12363c0c (current diff) b462b7b828d1 (diff)
children 62cbc3806a41
files admin/FOR-RELEASE lisp/ChangeLog lisp/faces.el lisp/files.el lisp/progmodes/ada-mode.el lisp/progmodes/idlwave.el lisp/progmodes/vhdl-mode.el lisp/simple.el lisp/startup.el lisp/subr.el lisp/vc-rcs.el man/ChangeLog src/buffer.c src/coding.c src/fileio.c src/frame.h src/macterm.c src/window.c src/xdisp.c src/xterm.c src/xterm.h
diffstat 67 files changed, 1368 insertions(+), 742 deletions(-) [+]
line wrap: on
line diff
--- a/admin/FOR-RELEASE	Thu Jan 06 15:00:09 2005 +0000
+++ b/admin/FOR-RELEASE	Thu Jan 06 15:05:01 2005 +0000
@@ -4,8 +4,6 @@
 
 ** Face remapping.
 
-** Let mouse-1 follow links.
-
 ** Make Rmail find the best version of movemail.
 To be done by Sergey Poznyakoff <gray@Mirddin.farlep.net>.
 
@@ -36,6 +34,8 @@
 
 * BUGS
 
+** Incomplete overlay mouse-face highlight bug (Ralf Angeli, Oct 18)
+
 ** Ange-ftp should ignore irrelevant IPv6 errors:
 
 Message-Id: <4121-Tue23Mar2004165249+0100-piet@cs.uu.nl>
--- a/etc/NEWS	Thu Jan 06 15:00:09 2005 +0000
+++ b/etc/NEWS	Thu Jan 06 15:05:01 2005 +0000
@@ -98,10 +98,11 @@
 
 * Changes in Emacs 21.4
 
-** calculator.el now has radix grouping mode.  In this mode a
-separator character is used between every few digits, making it
-easier to indicate byte boundries etc.  See the documentation of
-the `calculator-radix-grouping-mode' custom variable.
+** calculator.el now has radix grouping mode, which is available when
+`calculator-output-radix' is non-nil.  In this mode a separator
+character is used every few digits, making it easier to see byte
+boundries etc.  For more info, see the documentation of the variable
+`calculator-radix-grouping-mode'.
 
 ** You can now follow links by clicking Mouse-1 on the link.
 
@@ -133,6 +134,24 @@
 `mouse-1-click-follows-link'.
 
 +++
+** require-final-newline now has two new possible values:
+
+`visit' means add a newline (as an undoable change) if it's needed
+when visiting the file.
+
+`visit-save' means add a newline (as an undoable change) if it's
+needed when visiting the file, and also add a newline if it's needed
+when saving the file.
+
++++
+** The new option mode-require-final-newline controls how certain
+major modes enable require-final-newline.  Any major mode that's
+designed for a kind of file that should normally end in a newline
+sets require-final-newline based on mode-require-final-newline.
+So you can customize mode-require-final-newline to control what these
+modes do.
+
++++
 ** When the undo information of the current command gets really large
 (beyond the value of `undo-outer-limit'), Emacs asks you whether to
 discard it or keep it.
@@ -1804,12 +1823,15 @@
 bound to keys to get this feature without toggling a mode.
 Contributed by Kevin Ryde.
 
-*** Better control over require-final-newline.
-The variable that controls how to handle a final newline when the
-buffer is saved, require-final-newline, is now customizable on a
-per-mode basis through c-require-final-newline.  The default is to set
-it to t only in languages that mandate a final newline in source files
-(C, C++ and Objective-C).
+*** Better control over require-final-newline.  The variable that
+controls how to handle a final newline when the buffer is saved,
+require-final-newline, is now customizable on a per-mode basis through
+c-require-final-newline.  That is a list of modes, and only those
+modes set require-final-newline.  By default that's C, C++ and
+Objective-C.
+
+The specified modes set require-final-newline based on 
+mode-require-final-newline, as usual.
 
 *** Format change for syntactic context elements.
 The elements in the syntactic context returned by c-guess-basic-syntax
@@ -2156,6 +2178,9 @@
 handles the overlay property `display' specially, preserving it during
 temporary overlay showing in the course of an isearch operation.
 
+** New command `recode-region' decodes the region again by a specified
+coding system.
+
 
 * New modes and packages in Emacs 21.4
 
--- a/lisp/ChangeLog	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/ChangeLog	Thu Jan 06 15:05:01 2005 +0000
@@ -1,3 +1,205 @@
+2004-12-31  Jay Belanger  <belanger@truman.edu>
+
+	* calc/calc-store.el (calcVar-digit, calcVar-oper):  Remove the need
+	for "var-" at the beginning of the minibuffer.
+
+2004-12-31  Richard M. Stallman  <rms@gnu.org>
+
+	* faces.el (read-face-name):
+	Don't treat an attribute spec as a list of faces.
+
+	* simple.el (undo): Use undo-equiv-table to detect
+	unexpected changes since previous undo.
+	(undo-list-saved): Variable deleted.
+	(buffer-disable-undo): Don't alter undo-list-saved.
+
+	* files.el (require-final-newline): Allow `visit' and `visit-save'.
+	(mode-require-final-newline): New option.
+	(after-find-file): Handle require-final-newline with new values.
+	(basic-save-buffer): Handle new values of require-final-newline.
+
+	* progmodes/sh-script.el (sh-require-final-newline):
+	Alist value now controls whether to use mode-require-final-newline.
+	(sh-set-shell): Implement that new meaning.
+
+	* progmodes/cc-vars.el (c-require-final-newline): Fix custom type, doc.
+	* progmodes/cc-mode.el (c-common-init): Use mode-require-final-newline.
+	* progmodes/antlr-mode.el (antlr-mode): Use mode-require-final-newline.
+	Delete old-Emacs compatibility code.
+	(antlr-c-common-init): Function deleted.
+	
+	* net/snmp-mode.el (snmp-common-mode): Use mode-require-final-newline.
+	* progmodes/vhdl-mode.el (vhdl-mode): Use mode-require-final-newline.
+	* progmodes/simula.el (simula-mode): Use mode-require-final-newline.
+	* progmodes/python.el (python-mode): Use mode-require-final-newline.
+	* progmodes/perl-mode.el (perl-mode): Use mode-require-final-newline.
+	* progmodes/modula2.el (modula-2-mode): Use mode-require-final-newline.
+	* progmodes/mixal-mode.el (mixal-mode): Use mode-require-final-newline.
+	* progmodes/idlwave.el (idlwave-mode): Use mode-require-final-newline.
+	* progmodes/icon.el (icon-mode): Use mode-require-final-newline.
+	* progmodes/fortran.el (fortran-mode): Use mode-require-final-newline.
+	* progmodes/f90.el (f90-mode): Use mode-require-final-newline.
+	* progmodes/cperl-mode.el (cperl-mode): Use mode-require-final-newline.
+	* progmodes/cfengine.el (cfengine-mode): Use mode-require-final-newline.
+	* progmodes/ada-mode.el (ada-mode): Use mode-require-final-newline.
+	* textmodes/text-mode.el (text-mode): Use mode-require-final-newline.
+	* textmodes/texinfo.el (texinfo-mode): Use mode-require-final-newline.
+
+2004-12-31  Jay Belanger  <belanger@truman.edu>
+
+	* calc/calc-graph.el (calc-graph-show-dumb): Mention C-cC-c as the
+	way to return to Calc.
+
+	* calc/calc-yank.el (calc-edit-mode): Mention C-cC-c as the way to
+	finish, C-xk as the way to cancel the edit.  Add cancel routine to
+	kill-buffer-hook.
+
+	* calc/calc.el (calc-same-interface, calc-quit): Remove obsolete
+	MacEdit code.
+
+	* calc/calc-prog.el: Remove obsolete MacEdit code.
+	(calc-macro-edit-algebraic, calc-macro-edit-variable)
+	(calc-macro-edit-variable-2, calc-macro-edit-quick-digit): Remove.
+
+2004-12-31  Kenichi Handa  <handa@m17n.org>
+
+	* international/mule.el	(buffer-file-coding-system-explicit):
+	Renamed for explicit-buffer-file-coding-system.
+	(after-insert-file-set-coding): Adjusted for the above change.
+
+	* files.el (revert-buffer): Change
+	explicit-buffer-file-coding-system to
+	buffer-file-coding-system-explicit.
+	(basic-save-buffer-1): Likewise.
+
+2004-12-30  Richard M. Stallman  <rms@gnu.org>
+
+	* textmodes/artist.el (artist-butlast-fn): Var deleted.
+	(artist-butlast, artist-last): Functions deleted.
+	(artist-ellipse-mirror-quadrant): Call last and butlast directly.
+	(artist-compute-key-compl-table): Call remq directly.
+	(artist-remove-nulls): Function deleted.
+	(artist-vaporize-lines, artist-flood-fill): Use push and pop directly.
+	(artist-push, artist-pop): Macro deleted.
+
+2004-12-30  Andreas Leue  <al@sphenon.de>
+
+	* textmodes/artist.el (artist-version): 1.2.6
+	(artist-prev-next-op-alist): New variable.
+	(artist-select-next-op-in-list): New function.
+	(artist-select-prev-op-in-list): New function.
+	(artist-make-prev-next-op-alist): New function.
+	(artist-is-in-op-list-p): New function.
+	(artist-get-first-non-nil-op): New function.
+	(artist-get-last-non-nil-op): New function.
+	(artist-mode-init): Call artist-get-last-non-nil-op to initialize
+ 	artist-prev-next-op-alist.
+	(artist-mode-map): Add binding for C-mouse-4 and C-mouse-5 to
+ 	change drawing operation.
+
+2004-12-30  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* autorevert.el (auto-revert-tail-handler): Put in undo boundaries.
+
+2004-12-31  Masatake YAMATO  <jet@gyve.org>
+
+	* server.el (server-process-filter): Suppress `error', too.
+
+2004-12-30  Jay Belanger  <belanger@truman.edu>
+
+	* calc/calc-store.el (calc-copy-variable):  Fix mistyped variable
+	name.  Change the way a variable is displayed in a message.
+
+	* calc/calc-prog.el (calc-user-define-edit, calc-finish-macro-edit)
+	(calc-user-define-permanent, calc-execute-kbd-macro):
+	Replace old function MacEdit-parse-keys with edmacro-parse-keys.
+
+2004-12-30  Kenichi Handa  <handa@m17n.org>
+
+	* files.el (basic-save-buffer-1): Set
+	explicit-buffer-file-coding-system to last-coding-system-used.
+	(revert-buffer): Pay attention to
+	explicit-buffer-file-coding-system (not buffer-file-coding-system)
+	on bind coding-system-for-read.
+
+	* international/mule.el (explicit-buffer-file-coding-system): New
+	buffer local variable.
+	(after-insert-file-set-coding): Set it to coding-system-for-read.
+
+2004-12-29  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* autorevert.el (auto-revert-tail-mode): Doc fix for defvar.
+
+2004-12-29  Sanghyuk Suh  <han9kin@mac.com>
+
+	* term/mac-win.el (mac-drag-n-drop): Handle drag-n-drop events
+	that include line numbers.
+
+2004-12-29  Milan Zamazal  <pdm@zamazal.org>
+
+	* files.el (hack-local-variables): If no PREFIX, set it to "^".
+	Redundant variable PREFIXLEN removed.
+
+2004-12-28  Matt Hodges  <MPHodges@member.fsf.org>
+
+	* eshell/em-hist.el (eshell-previous-matching-input):
+	Start the deletion from the end of the output.
+
+2004-12-29  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* term/mac-win.el: Require x-dnd.
+	(mac-drag-n-drop): Sync with W32 version.  Use x-dnd.el
+	functions.
+
+2004-12-29  David Kastrup  <dak@gnu.org>
+
+	* international/mule.el (decode-coding-inserted-region): Don't
+	barf if `buffer-undo-list' is already set to `t'.
+
+2004-12-29  Jay Belanger  <belanger@truman.edu>
+
+	* calc/calc-prog.el (calc-user-define-formula): Put default values
+	for function names in prompts.
+	(calc-user-define-permanent, calc-user-define-composition)
+	(calc-user-define-formula): Remove the need for "calcFunc-" in the
+	default input for algebraic functions.
+
+2004-12-29  Thien-Thi Nguyen  <ttn@gnu.org>
+
+	* vc-rcs.el (vc-rcs-annotate-command):
+	Fix omission bug: Call `vc-setup-buffer'.
+
+2004-12-29  Kenichi Handa  <handa@m17n.org>
+
+	* international/mule.el (recode-region): New function.
+
+2004-12-28  Richard M. Stallman  <rms@gnu.org>
+
+	* simple.el (undo-extra-outer-limit): New variable.
+	(undo-outer-limit-truncate): Test and set it.
+
+	* emacs-lisp/lisp.el (mark-sexp, mark-defun): New arg ALLOW-EXTEND
+	enables the feature to extend the existing region.
+
+	* simple.el (mark-word): New arg ALLOW-EXTEND
+	enables the feature to extend the existing region.
+
+	* textmodes/paragraphs.el (mark-paragraph): New arg ALLOW-EXTEND
+	enables the feature to extend the existing region.
+
+	* startup.el (site-run-file): Don't allow setting it with Custom.
+
+	* simple.el (buffer-disable-undo): Fix previous change.
+
+2004-12-27  Masatake YAMATO  <jet@gyve.org>
+
+	* hexl.el (hexlify-buffer): Remove fontification here.
+	Use font lock mechanism instead.
+	(hexl-font-lock-keywords): New font lock kewords.
+	(hexl-mode-old-font-lock-keywords): New variable.
+	(hexl-mode): Store the old font lock keywords.
+	(hexl-mode-exit): Restore the old font lock keywords.
+
 2004-12-27  Richard M. Stallman  <rms@gnu.org>
 
 	* simple.el (undo): Fix previous change.
@@ -19,7 +221,7 @@
 	With --dired output format, detect and distinguish lines
 	that are really error messages.
 	(insert-directory-adj-pos): New function.
-	
+
 	* bookmark.el (bookmark-jump): Nice error if BOOKMARK is nil.
 
 	* battery.el (battery-mode-line-format): Remove initial spaces.
@@ -48,14 +250,14 @@
 	Now takes an arg TYPE to specify looking for a particular
 	type of definition only.
 
-	* emacs-lisp/debug.el (debugger-make-xrefs): 
+	* emacs-lisp/debug.el (debugger-make-xrefs):
 	Call symbol-file with `defun'.
 
-	* emacs-lisp/find-func.el (find-function-noselect): 
+	* emacs-lisp/find-func.el (find-function-noselect):
 	Call symbol-file with `defun'.
 	(find-variable-noselect): Call symbol-file with `defvar'.
 
-	* eshell/esh-cmd.el (eshell-find-alias-function): 
+	* eshell/esh-cmd.el (eshell-find-alias-function):
 	Call symbol-file with `defun'.
 
 	* eshell/esh-test.el (eshell-test-goto-func):
@@ -75,14 +277,14 @@
 	(undo): Set and test it.
 	(buffer-disable-undo): Moved here from buffer.c.
 	Clear out undo-list-saved.
-	
-	* international/mule.el (decode-coding-inserted-region): 
+
+	* international/mule.el (decode-coding-inserted-region):
 	Set buffer-undo-list in a correct and optimal way.
 
 	* progmodes/cperl-mode.el (cperl-find-bad-style): Use with-no-warnings.
 	(cperl-font-lock-unfontify-region-function): No need to save and
 	restore info, since font-lock.el does it for us.
-	
+
 	* ansi-color.el (save-buffer-state): Definition deleted.
 	(ansi-color-unfontify-region): Don't use save-buffer-state.
 
@@ -92,13 +294,13 @@
 
 2004-12-27  Kevin Ryde  <user42@zip.com.au>
 
-        * simple.el (next-matching-history-element): Use same
+	* simple.el (next-matching-history-element): Use same
 	`interactive' form as previous-matching-history-element.
 
-        * ffap.el (ffap-string-at-point-mode-alist): Add "*" to url chars,
+	* ffap.el (ffap-string-at-point-mode-alist): Add "*" to url chars,
         it can appear unencoded and has been seen from yahoo.
 
-2004-12-27  Sergey Poznyakoff <gray@Mirddin.farlep.net>
+2004-12-27  Sergey Poznyakoff <gray@Mirddin.farlep.net>  (tiny change)
 
 	* mail/smtpmail.el (smtpmail-try-auth-methods): Send AUTH CRAM-MD5
 	in upper case.  Reported by Wojciech Polak <polak@gnu.org>.
--- a/lisp/autorevert.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/autorevert.el	Thu Jan 06 15:05:01 2005 +0000
@@ -123,7 +123,8 @@
 
 (defvar auto-revert-tail-mode nil
   "*Non-nil when Auto-Revert Tail Mode is active.
-Never set this variable directly, use the command `auto-revert-mode' instead.")
+Never set this variable directly, use the command
+`auto-revert-tail-mode' instead.")
 (put 'auto-revert-tail-mode 'permanent-local t)
 
 (defvar auto-revert-timer nil
@@ -443,11 +444,13 @@
 	(file buffer-file-name)
 	buffer-file-name)		; ignore that file has changed
     (when (> size auto-revert-tail-pos)
+      (undo-boundary)
       (save-restriction
 	(widen)
 	(save-excursion
 	  (goto-char (point-max))
 	  (insert-file-contents file nil auto-revert-tail-pos size)))
+      (undo-boundary)
       (setq auto-revert-tail-pos size)
       (set-buffer-modified-p modified)))
   (set-visited-file-modtime))
--- a/lisp/calc/calc-graph.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/calc/calc-graph.el	Thu Jan 06 15:05:01 2005 +0000
@@ -955,9 +955,7 @@
 	  (define-key calc-dumb-map "\C-c\C-c" 'exit-recursive-edit)))
     (use-local-map calc-dumb-map)
     (setq truncate-lines t)
-    (message "Type `q'%s to return to Calc"
-	     (if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch)
-		    " or `M-# M-#'" ""))
+    (message "Type `q' or `C-c C-c' to return to Calc")
     (recursive-edit)
     (bury-buffer "*Gnuplot Trail*")))
 
--- a/lisp/calc/calc-prog.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/calc/calc-prog.el	Thu Jan 06 15:05:01 2005 +0000
@@ -170,7 +170,8 @@
 	  (arglist nil)
 	  (is-lambda (and (eq (car-safe form) 'calcFunc-lambda)
 			  (>= (length form) 2)))
-	  odef key keyname cmd cmd-base func calc-user-formula-alist is-symb)
+	  odef key keyname cmd cmd-base cmd-base-default
+          func calc-user-formula-alist is-symb)
      (if is-lambda
 	 (setq arglist (mapcar (function (lambda (x) (nth 1 x)))
 			       (nreverse (cdr (reverse (cdr form)))))
@@ -189,18 +190,25 @@
 			    (char-to-string key)
 			  (format "%03d" key)))
 	   odef (assq key (calc-user-key-map)))
+     (unless keyname
+       (setq keyname (format "%05d" (abs (% (random) 10000)))))
      (while
 	 (progn
-	   (setq cmd (completing-read "Define M-x command name: "
-				      obarray 'commandp nil
-				      (if (and odef (symbolp (cdr odef)))
-					  (symbol-name (cdr odef))
-					"calc-"))
-		 cmd-base (and (string-match "\\`calc-\\(.+\\)\\'" cmd)
-			       (math-match-substring cmd 1))
-		 cmd (and (not (or (string-equal cmd "")
-				   (string-equal cmd "calc-")))
-			  (intern cmd)))
+	   (setq cmd-base-default (concat "User-" keyname))
+           (setq cmd (completing-read 
+                      (concat "Define M-x command name (default: calc-"
+                              cmd-base-default
+                              "): ")
+                      obarray 'commandp nil
+                      (if (and odef (symbolp (cdr odef)))
+                          (symbol-name (cdr odef))
+                        "calc-")))
+           (if (or (string-equal cmd "")
+                   (string-equal cmd "calc-"))
+               (setq cmd (concat "calc-User-" keyname)))
+           (setq cmd-base (and (string-match "\\`calc-\\(.+\\)\\'" cmd)
+			       (math-match-substring cmd 1)))
+           (setq cmd (intern cmd))
 	   (and cmd
 		(fboundp cmd)
 		odef
@@ -210,24 +218,33 @@
 		      (concat "Replace previous definition for "
 			      (symbol-name cmd) "? ")
 		    "That name conflicts with a built-in Emacs function.  Replace this function? "))))))
-     (if (and key (not cmd))
-	 (setq cmd (intern (concat "calc-User-" keyname))))
      (while
 	 (progn
-	   (setq func (completing-read "Define algebraic function name: "
-				       obarray 'fboundp nil
-				       (concat "calcFunc-"
-					       (if cmd-base
-						   (if (string-match
-							"\\`User-.+" cmd-base)
-						       (concat
-							"User"
-							(substring cmd-base 5))
-						     cmd-base)
-						 "")))
-		 func (and (not (or (string-equal func "")
-				    (string-equal func "calcFunc-")))
-			   (intern func)))
+           (setq cmd-base-default     
+                 (if cmd-base
+                     (if (string-match
+                          "\\`User-.+" cmd-base)
+                         (concat
+                          "User"
+                          (substring cmd-base 5))
+                       cmd-base)
+                   (concat "User" keyname)))
+	   (setq func 
+                 (concat "calcFunc-"
+                         (completing-read 
+                          (concat "Define algebraic function name (default: "
+                                  cmd-base-default "): ")
+                          (mapcar (lambda (x) (substring x 9))
+                                  (all-completions "calcFunc-"
+                                                   obarray))
+                          (lambda (x) 
+                            (fboundp 
+                             (intern (concat "calcFunc-" x))))
+                          nil)))
+           (setq func
+                 (if (string-equal func "calcFunc-")
+                     (intern (concat "calcFunc-" cmd-base-default))
+                   (intern func)))
 	   (and func
 		(fboundp func)
 		(not (fboundp cmd))
@@ -238,11 +255,13 @@
 		      (concat "Replace previous definition for "
 			      (symbol-name func) "? ")
 		    "That name conflicts with a built-in Emacs function.  Replace this function? "))))))
+
      (if (not func)
 	 (setq func (intern (concat "calcFunc-User"
 				    (or keyname
 					(and cmd (symbol-name cmd))
 					(format "%05d" (% (random) 10000)))))))
+
      (if is-lambda
 	 (setq calc-user-formula-alist arglist)
        (while
@@ -359,8 +378,15 @@
    (if (eq calc-language 'unform)
        (error "Can't define formats for unformatted mode"))
    (let* ((comp (calc-top 1))
-	  (func (intern (completing-read "Define format for which function: "
-					 obarray 'fboundp nil "calcFunc-")))
+	  (func (intern 
+                 (concat "calcFunc-"
+                         (completing-read "Define format for which function: "
+                                          (mapcar (lambda (x) (substring x 9))
+                                                  (all-completions "calcFunc-"
+                                                                   obarray))
+                                          (lambda (x) 
+                                            (fboundp 
+                                             (intern (concat "calcFunc-" x))))))))
 	  (comps (get func 'math-compose-forms))
 	  entry entry2
 	  (arglist nil)
@@ -696,7 +722,7 @@
 					  (setcar mac new))))))))
 	     (let ((keys (progn (and (fboundp 'edit-kbd-macro)
 				     (edit-kbd-macro nil))
-				(fboundp 'MacEdit-parse-keys))))
+				(fboundp 'edmacro-parse-keys))))
 	       (calc-wrapper
 		(calc-edit-mode (list 'calc-finish-macro-edit
 				      (list 'quote def)
@@ -749,7 +775,7 @@
   (if (and keys (looking-at "\n")) (forward-line 1))
   (let* ((true-str (buffer-substring (point) (point-max)))
 	 (str true-str))
-    (if keys (setq str (MacEdit-parse-keys str)))
+    (if keys (setq str (edmacro-parse-keys str)))
     (if (symbolp (cdr def))
 	(if (stringp (symbol-function (cdr def)))
 	    (fset (cdr def) str)
@@ -761,128 +787,6 @@
 	      (setcar mac str))))
       (setcdr def str))))
 
-;;; The following are hooks into the MacEdit package from macedit.el.
-(put 'calc-execute-extended-command 'MacEdit-print
-     (function (lambda ()
-		 (setq macro-str (concat "\excalc-" macro-str)))))
-
-(put 'calcDigit-start 'MacEdit-print
-     (function (lambda ()
-		 (if calc-algebraic-mode
-		     (calc-macro-edit-algebraic)
-		   (MacEdit-unread-chars key-last)
-		   (let ((str "")
-			 (min-bsp 0)
-			 ch last)
-		     (while (and (setq ch (MacEdit-read-char))
-				 (or (and (>= ch ?0) (<= ch ?9))
-				     (memq ch '(?\. ?e ?\_ ?n ?\: ?\# ?M
-						    ?o ?h ?\@ ?\"))
-				     (and (memq ch '(?\' ?m ?s))
-					  (string-match "[@oh]" str))
-				     (and (or (and (>= ch ?a) (<= ch ?z))
-					      (and (>= ch ?A) (<= ch ?Z)))
-					  (string-match
-					   "^[-+]?\\(1[1-9]\\|[2-9][0-9]\\)#"
-					   str))
-				     (and (memq ch '(?\177 ?\C-h))
-					  (> (length str) 0))
-				     (and (memq ch '(?+ ?-))
-					  (> (length str) 0)
-					  (eq (aref str (1- (length str)))
-					      ?e))))
-		       (if (or (and (>= ch ?0) (<= ch ?9))
-			       (and (or (not (memq ch '(?\177 ?\C-h)))
-					(<= (length str) min-bsp))
-				    (setq min-bsp (1+ (length str)))))
-			   (setq str (concat str (char-to-string ch)))
-			 (setq str (substring str 0 -1))))
-		     (if (memq ch '(32 10 13))
-			 (setq str (concat str (char-to-string ch)))
-		       (MacEdit-unread-chars ch))
-		     (insert "type \"")
-		     (MacEdit-insert-string str)
-		     (insert "\"\n"))))))
-
-(defun calc-macro-edit-algebraic ()
-  (MacEdit-unread-chars key-last)
-  (let ((str "")
-	(min-bsp 0))
-    (while (progn
-	     (MacEdit-lookup-key calc-alg-ent-map)
-	     (or (and (memq key-symbol '(self-insert-command
-					 calcAlg-previous))
-		      (< (length str) 60))
-		 (memq key-symbol
-			    '(backward-delete-char
-			      delete-backward-char
-			      backward-delete-char-untabify))
-		 (eq key-last 9)))
-      (setq macro-str (substring macro-str (length key-str)))
-      (if (or (eq key-symbol 'self-insert-command)
-	      (and (or (not (memq key-symbol '(backward-delete-char
-					       delete-backward-char
-					       backward-delete-char-untabify)))
-		       (<= (length str) min-bsp))
-		   (setq min-bsp (+ (length str) (length key-str)))))
-	  (setq str (concat str key-str))
-	(setq str (substring str 0 -1))))
-    (if (memq key-last '(10 13))
-	(setq str (concat str key-str)
-	      macro-str (substring macro-str (length key-str))))
-    (if (> (length str) 0)
-	(progn
-	  (insert "type \"")
-	  (MacEdit-insert-string str)
-	  (insert "\"\n")))))
-(put 'calc-algebraic-entry 'MacEdit-print 'calc-macro-edit-algebraic)
-(put 'calc-auto-algebraic-entry 'MacEdit-print 'calc-macro-edit-algebraic)
-
-(defun calc-macro-edit-variable (&optional no-cmd)
-  (let ((str "") ch)
-    (or no-cmd (insert (symbol-name key-symbol) "\n"))
-    (if (memq (MacEdit-peek-char) '(?\+ ?\- ?\* ?\/ ?^ ?\|))
-	(setq str (char-to-string (MacEdit-read-char))))
-    (if (and (setq ch (MacEdit-peek-char))
-	     (>= ch ?0) (<= ch ?9))
-	(insert "type \"" str
-		(char-to-string (MacEdit-read-char)) "\"\n")
-      (if (> (length str) 0)
-	  (insert "type \"" str "\"\n"))
-      (MacEdit-read-argument))))
-(put 'calc-store 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-into 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-neg 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-plus 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-minus 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-times 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-div 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-power 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-concat 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-inv 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-decr 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-incr 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-store-exchange 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-unstore 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-recall 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-let 'MacEdit-print 'calc-macro-edit-variable)
-(put 'calc-permanent-variable 'MacEdit-print 'calc-macro-edit-variable)
-
-(defun calc-macro-edit-variable-2 ()
-  (calc-macro-edit-variable)
-  (calc-macro-edit-variable t))
-(put 'calc-copy-variable 'MacEdit-print 'calc-macro-edit-variable-2)
-(put 'calc-declare-variable 'MacEdit-print 'calc-macro-edit-variable-2)
-
-(defun calc-macro-edit-quick-digit ()
-  (insert "type \"" key-str "\"  # " (symbol-name key-symbol) "\n"))
-(put 'calc-store-quick 'MacEdit-print 'calc-macro-edit-quick-digit)
-(put 'calc-store-into-quick 'MacEdit-print 'calc-macro-edit-quick-digit)
-(put 'calc-recall-quick 'MacEdit-print 'calc-macro-edit-quick-digit)
-(put 'calc-select-part 'MacEdit-print 'calc-macro-edit-quick-digit)
-(put 'calc-clean-num 'MacEdit-print 'calc-macro-edit-quick-digit)
-
-
 (defun calc-finish-formula-edit (func)
   (let ((buf (current-buffer))
 	(str (buffer-substring (point) (point-max)))
@@ -952,10 +856,24 @@
 		   (assq (downcase key) (calc-user-key-map))
 		   (and (eq key ?\')
 			(cons nil
+                              (intern
+                               (concat "calcFunc-"
+                                       (completing-read
+                                        (format "Record in %s the algebraic function: "
+                                                calc-settings-file)
+                                        (mapcar (lambda (x) (substring x 9))
+                                                (all-completions "calcFunc-"
+                                                                 obarray))
+                                        (lambda (x) 
+                                          (fboundp 
+                                           (intern (concat "calcFunc-" x))))
+                                        t)))))
+                   (and (eq key ?\M-x)
+			(cons nil
 			      (intern (completing-read
-				       (format "Record in %s the function: "
+				       (format "Record in %s the command: "
 					       calc-settings-file)
-				       obarray 'fboundp nil "calcFunc-"))))
+				       obarray 'fboundp nil "calc-"))))
 		   (error "No command defined for that key"))))
      (set-buffer (find-file-noselect (substitute-in-file-name
 				      calc-settings-file)))
@@ -979,7 +897,7 @@
 		  (vectorp (nth 1 (nth 3 fcmd)))
 		  (progn (and (fboundp 'edit-kbd-macro)
 			      (edit-kbd-macro nil))
-			 (fboundp 'MacEdit-parse-keys))
+			 (fboundp 'edmacro-parse-keys))
 		  (setq q-ok t)
 		  (aset (nth 1 (nth 3 fcmd)) 1 nil))
 	     (insert (setq str (prin1-to-string
@@ -1065,7 +983,7 @@
       (setq mac (or (aref mac 1)
 		    (aset mac 1 (progn (and (fboundp 'edit-kbd-macro)
 					    (edit-kbd-macro nil))
-				       (MacEdit-parse-keys (aref mac 0)))))))
+				       (edmacro-parse-keys (aref mac 0)))))))
   (if (< (prefix-numeric-value arg) 0)
       (execute-kbd-macro mac (- (prefix-numeric-value arg)))
     (if calc-executing-macro
--- a/lisp/calc/calc-store.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/calc/calc-store.el	Thu Jan 06 15:05:01 2005 +0000
@@ -200,7 +200,7 @@
 
 (defun calcVar-digit ()
   (interactive)
-  (if (calc-minibuffer-contains "var-\\'")
+  (if (calc-minibuffer-contains "\\'")
       (if (eq calc-store-opers 0)
 	  (beep)
 	(insert "q")
@@ -210,7 +210,7 @@
 (defun calcVar-oper ()
   (interactive)
   (if (and (eq calc-store-opers t)
-	   (calc-minibuffer-contains "var-\\'"))
+	   (calc-minibuffer-contains "\\'"))
       (progn
 	(erase-buffer)
 	(self-insert-and-exit))
@@ -373,9 +373,10 @@
    (if var1
        (let ((value (calc-var-value var1)))
 	 (or value
-	     (error "No such variable: \"%s\"" (calc-var-name var)))
+	     (error "No such variable: \"%s\"" (calc-var-name var1)))
 	 (or var2 (setq var2 (calc-read-var-name
-			      (format "Copy variable: %s, to: " var1))))
+			      (format "Copy variable: %s, to: " 
+                                      (calc-var-name var1)))))
 	 (if var2
 	     (calc-store-value var2 value ""))))))
 
--- a/lisp/calc/calc-yank.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/calc/calc-yank.el	Thu Jan 06 15:05:01 2005 +0000
@@ -460,16 +460,14 @@
     (make-local-variable 'calc-allow-ret)
     (setq calc-allow-ret allow-ret)
     (erase-buffer)
+    (add-hook 'kill-buffer-hook (lambda () 
+                                  (let ((calc-edit-handler nil))
+                                    (calc-edit-finish t))
+                                  (message "(Cancelled)")) t t)
     (insert (or title title "Calc Edit Mode")
-	    ".  Press "
-	    (if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch)
-		"M-# M-# or C-c C-c"
-	      (if allow-ret "C-c C-c" "RET"))
-	    " to finish, "
-	    (if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch)
-		"M-# x"
-	      "C-x k RET")
-	    " to cancel.\n")))
+	    ".  Press `C-c C-c'"
+            (if allow-ret "" " or RET")
+	    " to finish, `C-x k RET' to cancel.\n")))
 (put 'calc-edit-mode 'mode-class 'special)
 
 (defun calc-show-edit-buffer ()
--- a/lisp/calc/calc.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/calc/calc.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1167,12 +1167,9 @@
       (exit-recursive-edit)
     (if (eq major-mode 'calc-edit-mode)
 	(calc-edit-finish arg)
-      (if (eq major-mode 'MacEdit-mode)
-	  (MacEdit-finish-edit)
-	(if calc-was-keypad-mode
-	    (calc-keypad)
-	  (calc arg calc-full-mode t))))))
-
+      (if calc-was-keypad-mode
+          (calc-keypad)
+        (calc arg calc-full-mode t)))))
 
 (defun calc-quit (&optional non-fatal interactive)
   (interactive "i\np")
@@ -1183,33 +1180,31 @@
       (exit-recursive-edit))
   (if (eq major-mode 'calc-edit-mode)
       (calc-edit-cancel)
-    (if (eq major-mode 'MacEdit-mode)
-	(MacEdit-cancel-edit)
-      (if (and interactive
-	       calc-embedded-info
-	       (eq (current-buffer) (aref calc-embedded-info 0)))
-	  (calc-embedded nil)
-	(unless (eq major-mode 'calc-mode)
-	  (calc-create-buffer))
-	(run-hooks 'calc-end-hook)
-	(setq calc-undo-list nil calc-redo-list nil)
-	(mapcar (function (lambda (v) (set-default v (symbol-value v))))
-		calc-local-var-list)
-	(let ((buf (current-buffer))
-	      (win (get-buffer-window (current-buffer)))
-	      (kbuf (get-buffer "*Calc Keypad*")))
-	  (delete-windows-on (calc-trail-buffer))
-	  (if (and win
-		   (< (window-height win) (1- (frame-height)))
-		   (= (window-width win) (frame-width))  ; avoid calc-keypad
-		   (not (get-buffer-window "*Calc Keypad*")))
-	      (setq calc-window-height (- (window-height win) 2)))
-	  (progn
-	    (delete-windows-on buf)
-	    (delete-windows-on kbuf))
-	  (bury-buffer buf)
-	  (bury-buffer calc-trail-buffer)
-	  (and kbuf (bury-buffer kbuf)))))))
+    (if (and interactive
+             calc-embedded-info
+             (eq (current-buffer) (aref calc-embedded-info 0)))
+        (calc-embedded nil)
+      (unless (eq major-mode 'calc-mode)
+        (calc-create-buffer))
+      (run-hooks 'calc-end-hook)
+      (setq calc-undo-list nil calc-redo-list nil)
+      (mapcar (function (lambda (v) (set-default v (symbol-value v))))
+              calc-local-var-list)
+      (let ((buf (current-buffer))
+            (win (get-buffer-window (current-buffer)))
+            (kbuf (get-buffer "*Calc Keypad*")))
+        (delete-windows-on (calc-trail-buffer))
+        (if (and win
+                 (< (window-height win) (1- (frame-height)))
+                 (= (window-width win) (frame-width))  ; avoid calc-keypad
+                 (not (get-buffer-window "*Calc Keypad*")))
+            (setq calc-window-height (- (window-height win) 2)))
+        (progn
+          (delete-windows-on buf)
+          (delete-windows-on kbuf))
+        (bury-buffer buf)
+        (bury-buffer calc-trail-buffer)
+        (and kbuf (bury-buffer kbuf))))))
 
 ;;;###autoload
 (defun quick-calc ()
--- a/lisp/emacs-lisp/lisp.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/emacs-lisp/lisp.el	Thu Jan 06 15:05:01 2005 +0000
@@ -69,15 +69,17 @@
   (or arg (setq arg 1))
   (forward-sexp (- arg)))
 
-(defun mark-sexp (&optional arg)
+(defun mark-sexp (&optional arg allow-extend)
   "Set mark ARG sexps from point.
 The place mark goes is the same place \\[forward-sexp] would
 move to with the same argument.
-If this command is repeated or mark is active in Transient Mark mode,
+Interactively, if this command is repeated
+or (in Transient Mark mode) if the mark is active, 
 it marks the next ARG sexps after the ones already marked."
-  (interactive "P")
-  (cond ((or (and (eq last-command this-command) (mark t))
-	     (and transient-mark-mode mark-active))
+  (interactive "P\np")
+  (cond ((and allow-extend
+	      (or (and (eq last-command this-command) (mark t))
+		  (and transient-mark-mode mark-active)))
 	 (setq arg (if arg (prefix-numeric-value arg)
 		     (if (< (mark) (point)) -1 1)))
 	 (set-mark
@@ -289,14 +291,17 @@
 		(goto-char (point-min)))))
 	(setq arg (1+ arg))))))
 
-(defun mark-defun ()
+(defun mark-defun (&optional allow-extend)
   "Put mark at end of this defun, point at beginning.
 The defun marked is the one that contains point or follows point.
-If this command is repeated or mark is active in Transient Mark mode,
-it marks more defuns after the ones already marked."
-  (interactive)
-  (cond ((or (and (eq last-command this-command) (mark t))
-	     (and transient-mark-mode mark-active))
+
+Interactively, if this command is repeated
+or (in Transient Mark mode) if the mark is active, 
+it marks the next defun after the ones already marked."
+  (interactive "p")
+  (cond ((and allow-extend
+	      (or (and (eq last-command this-command) (mark t))
+		  (and transient-mark-mode mark-active)))
 	 (set-mark
 	  (save-excursion
 	    (goto-char (mark))
--- a/lisp/eshell/em-hist.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/eshell/em-hist.el	Thu Jan 06 15:05:01 2005 +0000
@@ -840,7 +840,7 @@
       (unless (minibuffer-window-active-p (selected-window))
 	(message "History item: %d" (- (ring-length eshell-history-ring) pos)))
        ;; Can't use kill-region as it sets this-command
-      (delete-region (save-excursion (eshell-bol) (point)) (point))
+      (delete-region eshell-last-output-end (point))
       (insert-and-inherit (eshell-get-history pos)))))
 
 (defun eshell-next-matching-input (regexp arg)
--- a/lisp/faces.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/faces.el	Thu Jan 06 15:05:01 2005 +0000
@@ -854,12 +854,15 @@
 		      (get-char-property (point) 'face)))
 	faces)
     ;; Make a list of the named faces that the `face' property uses.
-    (if (listp faceprop)
+    (if (and (listp faceprop)
+	     ;; Don't treat an attribute spec as a list of faces.
+	     (not (keywordp (car faceprop)))
+	     (not (memq (car faceprop) '(foreground-color background-color))))
 	(dolist (f faceprop)
 	  (if (symbolp f)
 	      (push f faces)))
       (if (symbolp faceprop)
-	  (setq faces (list faceprop))))
+	  (push faceprop faces)))
     ;; If there are none, try to get a face name from the buffer.
     (if (and (null faces)
 	     (memq (intern-soft (thing-at-point 'symbol)) (face-list)))
--- a/lisp/files.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/files.el	Thu Jan 06 15:05:01 2005 +0000
@@ -273,14 +273,40 @@
   :group 'backup)
 
 (defcustom require-final-newline nil
-  "*Value of t says silently ensure a file ends in a newline when it is saved.
-Non-nil but not t says ask user whether to add a newline when there isn't one.
-nil means don't add newlines."
-  :type '(choice (const :tag "Off" nil)
-		 (const :tag "Add" t)
+  "*Whether to add a newline automatically at the end of the file.
+
+A value of t means do this only when the file is about to be saved.
+A value of `visit' means do this right after the file is visited.
+A value of `visit-save' means do it at both of those times.
+Any other non-nil value means ask user whether to add a newline, when saving.
+nil means don't add newlines.
+
+Certain major modes set this locally to the value obtained
+from `mode-require-final-newline'."
+  :type '(choice (const :tag "When visiting" visit)
+		 (const :tag "When saving" t)
+		 (const :tag "When visiting or saving" visit-save)
+		 (const :tag "Never" nil)
 		 (other :tag "Ask" ask))
   :group 'editing-basics)
 
+(defcustom mode-require-final-newline t
+  "*Whether to add a newline at the end of the file, in certain major modes.
+Those modes set `require-final-newline' to this value when you enable them.
+They do so because they are used for files that are supposed
+to end in newlines, and the question is how to arrange that.
+
+A value of t means do this only when the file is about to be saved.
+A value of `visit' means do this right after the file is visited.
+A value of `visit-save' means do it at both of those times.
+Any other non-nil value means ask user whether to add a newline, when saving."
+  :type '(choice (const :tag "When visiting" visit)
+		 (const :tag "When saving" t)
+		 (const :tag "When visiting or saving" visit-save)
+		 (other :tag "Ask" ask))
+  :group 'editing-basics
+  :version "21.4")
+
 (defcustom auto-save-default t
   "*Non-nil says by default do auto-saving of every file-visiting buffer."
   :type 'boolean
@@ -1627,6 +1653,15 @@
     (when (and view-read-only view-mode)
       (view-mode-disable))
     (normal-mode t)
+    ;; If requested, add a newline at the end of the file.
+    (and (memq require-final-newline '(visit visit-save))
+	 (> (point-max) (point-min))
+	 (/= (char-after (1- (point-max))) ?\n)
+	 (not (and (eq selective-display t)
+		   (= (char-after (1- (point-max))) ?\r)))
+	 (save-excursion
+	   (goto-char (point-max))
+	   (insert "\n")))
     (when (and buffer-read-only
 	       view-read-only
 	       (not (eq (get major-mode 'mode-class) 'special)))
@@ -2183,7 +2218,7 @@
 						   buffer-file-name)
 						(concat "buffer "
 							(buffer-name))))))))))
-	  (let (prefix prefixlen suffix beg
+	  (let (prefix suffix beg
 		(enable-local-eval enable-local-eval))
 	    ;; The prefix is what comes before "local variables:" in its line.
 	    ;; The suffix is what comes after "local variables:" in its line.
@@ -2197,8 +2232,7 @@
 		      (buffer-substring (point)
 					(progn (beginning-of-line) (point)))))
 
-	    (if prefix (setq prefixlen (length prefix)
-			     prefix (regexp-quote prefix)))
+	    (setq prefix (if prefix (regexp-quote prefix) "^"))
 	    (if suffix (setq suffix (concat (regexp-quote suffix) "$")))
 	    (forward-line 1)
 	    (let ((startpos (point))
@@ -3195,6 +3229,7 @@
 		   (not (and (eq selective-display t)
 			     (= (char-after (1- (point-max))) ?\r)))
 		   (or (eq require-final-newline t)
+		       (eq require-final-newline 'visit-save)
 		       (and require-final-newline
 			    (y-or-n-p
 			     (format "Buffer %s does not end in newline.  Add one? "
@@ -3239,7 +3274,8 @@
   (if save-buffer-coding-system
       (let ((coding-system-for-write save-buffer-coding-system))
 	(basic-save-buffer-2))
-    (basic-save-buffer-2)))
+    (basic-save-buffer-2))
+  (setq buffer-file-coding-system-explicit last-coding-system-used))
 
 ;; This returns a value (MODES . BACKUPNAME), like backup-buffer.
 (defun basic-save-buffer-2 ()
@@ -3709,11 +3745,11 @@
 			 (unlock-buffer)))
 		   (widen)
 		   (let ((coding-system-for-read
-			  ;; Auto-saved file shoule be read without
-			  ;; any code conversion.
-			  (if auto-save-p 'emacs-mule-unix
+			  ;; Auto-saved file shoule be read by Emacs'
+			  ;; internal coding.
+			  (if auto-save-p 'auto-save-coding
 			    (or coding-system-for-read
-				buffer-file-coding-system))))
+				buffer-file-coding-system-explicit))))
 		     ;; This force after-insert-file-set-coding
 		     ;; (called from insert-file-contents) to set
 		     ;; buffer-file-coding-system to a proper value.
--- a/lisp/gnus/ChangeLog	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/gnus/ChangeLog	Thu Jan 06 15:05:01 2005 +0000
@@ -1,3 +1,10 @@
+2004-12-27  Simon Josefsson  <jas@extundo.com>
+
+	* mm-bodies.el (mm-body-encoding): Don't permit 7-bit to be used
+	when mm-use-ultra-safe-encoding is enabled (e.g., for PGP/MIME)
+	and we have trailing white space.  Reported by Werner Koch
+	<wk@gnupg.org>.
+
 2004-12-17  Kim F. Storm  <storm@cua.dk>
 
 	* gnus-group.el (gnus-group-mode-map): Map follow-link to mouse-face.
--- a/lisp/gnus/mm-bodies.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/gnus/mm-bodies.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1,6 +1,6 @@
 ;;; mm-bodies.el --- Functions for decoding MIME things
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2003
+;; Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
@@ -139,7 +139,8 @@
     (cond
      ((and (not longp)
 	   (not (and mm-use-ultra-safe-encoding
-		     (save-excursion (re-search-forward "^From " nil t))))
+		     (or (save-excursion (re-search-forward " $" nil t))
+			 (save-excursion (re-search-forward "^From " nil t)))))
 	   (eq bits '7bit))
       bits)
      ((and (not mm-use-ultra-safe-encoding)
--- a/lisp/international/mule.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/international/mule.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1727,12 +1727,31 @@
 
 (setq set-auto-coding-function 'set-auto-coding)
 
-(defun after-insert-file-set-coding (inserted)
+;; This variable is set in these two cases:
+;;   (1) A file is read by a coding system specified explicitly.
+;;       after-insert-file-set-coding sets this value to
+;;       coding-system-for-read.
+;;   (2) A buffer is saved.
+;;       After writing, basic-save-buffer-1 sets this value to
+;;       last-coding-system-used.
+;; This variable is used for decoding in revert-buffer.
+(defvar buffer-file-coding-system-explicit nil
+  "The file coding system explicitly specified for the current buffer.
+Internal use only.")
+(make-variable-buffer-local 'buffer-file-coding-system-explicit)
+(put 'buffer-file-coding-system-explicit 'permanent-local t)
+
+(defun after-insert-file-set-coding (inserted &optional visit)
   "Set `buffer-file-coding-system' of current buffer after text is inserted.
 INSERTED is the number of characters that were inserted, as figured
 in the situation before this function.  Return the number of characters
 inserted, as figured in the situation after.  The two numbers can be
-different if the buffer has become unibyte."
+different if the buffer has become unibyte.
+The optional second arg VISIT non-nil means that we are visiting a file."
+  (if (and visit
+	   coding-system-for-read
+	   (not (eq coding-system-for-read 'auto-save-coding)))
+      (setq buffer-file-coding-system-explicit coding-system-for-read))
   (if last-coding-system-used
       (let ((coding-system
 	     (find-new-buffer-file-coding-system last-coding-system-used))
@@ -1893,7 +1912,7 @@
 	  ;; Otherwise, if we can recognize the undo elt for the insertion,
 	  ;; remove it and get ready to replace it later.
 	  ;; In the mean time, turn off undo recording.
-	  (let ((last (car buffer-undo-list))) 
+	  (let ((last (car-safe buffer-undo-list))) 
 	    (if (and (consp last) (eql (car last) from) (eql (cdr last) to))
 		(setq undo-list-saved (cdr buffer-undo-list)
 		      buffer-undo-list t))))
@@ -1924,6 +1943,25 @@
 	      (setq buffer-undo-list
 		    (cons (cons from (point-max)) undo-list-saved))))))))
 
+(defun recode-region (start end new-coding coding)
+  "Re-decode the region (previously decoded by CODING) by NEW-CODING."
+  (interactive
+   (list (region-beginning) (region-end)
+	 (read-coding-system "Text was really in: ")
+	 (let ((coding (or buffer-file-coding-system last-coding-system-used)))
+	   (read-coding-system
+	    (concat "But was interpreted as"
+		    (if coding (format " (default %S): " coding) ": "))
+	    coding))))
+  (or (and new-coding coding)
+      (error "Coding system not specified"))
+  ;; Check it before we encode the region.
+  (check-coding-system new-coding)
+  (save-restriction
+    (narrow-to-region start end)
+    (encode-coding-region (point-min) (point-max) coding)
+    (decode-coding-region (point-min) (point-max) new-coding)))
+
 (defun make-translation-table (&rest args)
   "Make a translation table from arguments.
 A translation table is a char table intended for character
--- a/lisp/net/snmp-mode.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/net/snmp-mode.el	Thu Jan 06 15:05:01 2005 +0000
@@ -356,7 +356,7 @@
 
   ;; Miscellaneous customization
   (make-local-variable 'require-final-newline)
-  (setq require-final-newline t))
+  (setq require-final-newline mode-require-final-newline))
 
 
 ;; SNMPv1 MIB Editing Mode.
--- a/lisp/progmodes/ada-mode.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/ada-mode.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1116,7 +1116,7 @@
   (interactive)
   (kill-all-local-variables)
 
-  (set (make-local-variable 'require-final-newline) t)
+  (set (make-local-variable 'require-final-newline) mode-require-final-newline)
 
   ;;  Set the paragraph delimiters so that one can select a whole block
   ;;  simply with M-h
--- a/lisp/progmodes/antlr-mode.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/antlr-mode.el	Thu Jan 06 15:05:01 2005 +0000
@@ -2529,53 +2529,6 @@
 	  (set (car settings) (eval (cadr settings)))))
       (setq settings (cddr settings)))))
 
-(defun antlr-c-common-init ()
-  "Like `c-basic-common-init' when using cc-mode before v5.30."
-  ;; X/Emacs 20 only
-  (make-local-variable 'paragraph-start)
-  (make-local-variable 'paragraph-separate)
-  (make-local-variable 'paragraph-ignore-fill-prefix)
-  (make-local-variable 'require-final-newline)
-  (make-local-variable 'parse-sexp-ignore-comments)
-  (make-local-variable 'comment-start)
-  (make-local-variable 'comment-multi-line)
-  (make-local-variable 'outline-regexp)
-  (make-local-variable 'outline-level)
-  (make-local-variable 'adaptive-fill-regexp)
-  (make-local-variable 'adaptive-fill-mode)
-  (make-local-variable 'imenu-generic-expression) ;set in the mode functions
-  (and (boundp 'comment-line-break-function)
-       (make-local-variable 'comment-line-break-function))
-  ;; Emacs 19.30 and beyond only, AFAIK
-  (if (boundp 'fill-paragraph-function)
-      (progn
-	(make-local-variable 'fill-paragraph-function)
-	(setq fill-paragraph-function 'c-fill-paragraph)))
-  ;; now set their values
-  (setq paragraph-start (concat page-delimiter "\\|$")
-	paragraph-separate paragraph-start
-	paragraph-ignore-fill-prefix t
-	parse-sexp-ignore-comments t
-	comment-column 32
-	comment-multi-line nil
-	comment-line-break-function 'c-comment-line-break-function
-	adaptive-fill-regexp nil
-	adaptive-fill-mode nil)
-  (c-set-style (or antlr-indent-style "gnu"))
-  (and (boundp 'c-current-comment-prefix) (boundp 'c-comment-prefix-regexp)
-       (setq c-current-comment-prefix
-	     (if (listp c-comment-prefix-regexp)
-		 (cdr-safe (or (assoc major-mode c-comment-prefix-regexp)
-			       (assoc 'other c-comment-prefix-regexp)))
-	       c-comment-prefix-regexp)))
-  ;; we have to do something special for c-offsets-alist so that the
-  ;; buffer local value has its own alist structure.
-  (setq c-offsets-alist (copy-alist c-offsets-alist))
-  ;; setup the comment indent variable in a Emacs version portable way
-  ;; ignore any byte compiler warnings you might get here
-  (make-local-variable 'comment-indent-function)
-  (setq comment-indent-function 'c-comment-indent))
-
 (defun antlr-language-option (search)
   "Find language in `antlr-language-alist' for language option.
 If SEARCH is non-nil, find element for language option.  Otherwise, find
@@ -2643,10 +2596,7 @@
 	   (funcall init-fn)))		; is a function in v5.29
 	(t				; cc-mode upto 5.28
 	 (antlr-c-init-language-vars)))	; do it myself
-  (cond ((fboundp 'c-basic-common-init)	; cc-mode 5.30+
-	 (c-basic-common-init antlr-language (or antlr-indent-style "gnu")))
-	(t
-	 (antlr-c-common-init)))
+  (c-basic-common-init antlr-language (or antlr-indent-style "gnu"))
   (make-local-variable 'outline-regexp)
   (make-local-variable 'outline-level)
   (make-local-variable 'require-final-newline)
@@ -2654,7 +2604,7 @@
   (make-local-variable 'indent-region-function)
   (setq outline-regexp "[^#\n\^M]"
 	outline-level 'c-outline-level)	; TODO: define own
-  (setq require-final-newline t)
+  (setq require-final-newline mode-require-final-newline)
   (setq indent-line-function 'antlr-indent-line
 	indent-region-function nil)	; too lazy
   (setq comment-start "// "
--- a/lisp/progmodes/cc-mode.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/cc-mode.el	Thu Jan 06 15:05:01 2005 +0000
@@ -557,7 +557,8 @@
   (let ((rfn (assq mode c-require-final-newline)))
     (when rfn
       (make-local-variable 'require-final-newline)
-      (setq require-final-newline (cdr rfn)))))
+      (and (cdr rfn)
+	   (setq require-final-newline mode-require-final-newline)))))
 
 (defun c-postprocess-file-styles ()
   "Function that post processes relevant file local variables in CC Mode.
--- a/lisp/progmodes/cc-vars.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/cc-vars.el	Thu Jan 06 15:05:01 2005 +0000
@@ -839,30 +839,28 @@
   '((c-mode    . t)
     (c++-mode  . t)
     (objc-mode . t))
-  "*Controls whether a final newline is ensured when the file is saved.
-The value is an association list that for each language mode specifies
-the value to give to `require-final-newline' at mode initialization;
-see that variable for details about the value.  If a language isn't
-present on the association list, CC Mode won't set
-`require-final-newline' in buffers for that language."
+  "*Controls `require-final-newline' in C-related major modes.
+The value is an association list specifying, for each specific mode,
+whether to override `require-final-newline'.  If the cdr of the element
+is non-nil, that means to use `mode-require-final-newline' instead."
   :type `(set (cons :format "%v"
 		    (const :format "C     " c-mode)
-		    (symbol :format "%v" :value ,require-final-newline))
+		    (const t))
 	      (cons :format "%v"
 		    (const :format "C++   " c++-mode)
-		    (symbol :format "%v" :value ,require-final-newline))
+		    (const t))
 	      (cons :format "%v"
 		    (const :format "ObjC  " objc-mode)
-		    (symbol :format "%v" :value ,require-final-newline))
+		    (const t))
 	      (cons :format "%v"
 		    (const :format "Java  " java-mode)
-		    (symbol :format "%v" :value ,require-final-newline))
+		    (const t))
 	      (cons :format "%v"
 		    (const :format "IDL   " idl-mode)
-		    (symbol :format "%v" :value ,require-final-newline))
+		    (const t))
 	      (cons :format "%v"
 		    (const :format "Pike  " pike-mode)
-		    (symbol :format "%v" :value ,require-final-newline)))
+		    (const t)))
   :group 'c)
 
 (defcustom c-electric-pound-behavior nil
--- a/lisp/progmodes/cfengine.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/cfengine.el	Thu Jan 06 15:05:01 2005 +0000
@@ -222,7 +222,7 @@
   ;; movement.
 
   (set (make-local-variable 'parens-require-spaces) nil)
-  (set (make-local-variable 'require-final-newline) t)
+  (set (make-local-variable 'require-final-newline) mode-require-final-newline)
   (set (make-local-variable 'comment-start)  "# ")
   (set (make-local-variable 'comment-start-skip)
        "\\(\\(?:^\\|[^\\\\\n]\\)\\(?:\\\\\\\\\\)*\\)#+[ \t]*")
--- a/lisp/progmodes/cperl-mode.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/cperl-mode.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1462,7 +1462,7 @@
   (make-local-variable 'indent-line-function)
   (setq indent-line-function 'cperl-indent-line)
   (make-local-variable 'require-final-newline)
-  (setq require-final-newline t)
+  (setq require-final-newline mode-require-final-newline)
   (make-local-variable 'comment-start)
   (setq comment-start "# ")
   (make-local-variable 'comment-end)
--- a/lisp/progmodes/f90.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/f90.el	Thu Jan 06 15:05:01 2005 +0000
@@ -818,7 +818,7 @@
   (use-local-map f90-mode-map)
   (set (make-local-variable 'indent-line-function) 'f90-indent-line)
   (set (make-local-variable 'indent-region-function) 'f90-indent-region)
-  (set (make-local-variable 'require-final-newline) t)
+  (set (make-local-variable 'require-final-newline) mode-require-final-newline)
   (set (make-local-variable 'comment-start) "!")
   (set (make-local-variable 'comment-start-skip) "!+ *")
   (set (make-local-variable 'comment-indent-function) 'f90-comment-indent)
--- a/lisp/progmodes/fortran.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/fortran.el	Thu Jan 06 15:05:01 2005 +0000
@@ -674,7 +674,7 @@
          (let (fortran-blink-matching-if ; avoid blinking delay
                indent-region-function)
            (indent-region start end nil))))
-  (set (make-local-variable 'require-final-newline) t)
+  (set (make-local-variable 'require-final-newline) mode-require-final-newline)
   ;; The syntax tables don't understand the column-0 comment-markers.
   (set (make-local-variable 'comment-use-syntax) nil)
   (set (make-local-variable 'comment-padding) "$$$")
--- a/lisp/progmodes/icon.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/icon.el	Thu Jan 06 15:05:01 2005 +0000
@@ -177,7 +177,7 @@
   (make-local-variable 'indent-line-function)
   (setq indent-line-function 'icon-indent-line)
   (make-local-variable 'require-final-newline)
-  (setq require-final-newline t)
+  (setq require-final-newline mode-require-final-newline)
   (make-local-variable 'comment-start)
   (setq comment-start "# ")
   (make-local-variable 'comment-end)
--- a/lisp/progmodes/idlwave.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/idlwave.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1892,7 +1892,7 @@
   
   (set (make-local-variable 'comment-start-skip) ";+[ \t]*")
   (set (make-local-variable 'comment-start) ";")
-  (set (make-local-variable 'require-final-newline) t)
+  (set (make-local-variable 'require-final-newline) mode-require-final-newline)
   (set (make-local-variable 'abbrev-all-caps) t)
   (set (make-local-variable 'indent-tabs-mode) nil)
   (set (make-local-variable 'completion-ignore-case) t)
--- a/lisp/progmodes/mixal-mode.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/mixal-mode.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1303,8 +1303,9 @@
   (set (make-local-variable 'compile-command) (concat "mixasm -g "
 						      buffer-file-name))
   ;; mixasm will do strange when there is no final newline,
-  ;; let emacs ensure that it is always there
-  (set (make-local-variable 'require-final-newline) t))
+  ;; so let Emacs ensure that it is always there
+  (set (make-local-variable 'require-final-newline)
+       mode-require-final-newline))
 
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.mixal\\'" . mixal-mode))
--- a/lisp/progmodes/modula2.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/modula2.el	Thu Jan 06 15:05:01 2005 +0000
@@ -151,7 +151,7 @@
 ;  (make-local-variable 'indent-line-function)
 ;  (setq indent-line-function 'c-indent-line)
   (make-local-variable 'require-final-newline)
-  (setq require-final-newline t)
+  (setq require-final-newline mode-require-final-newline)
   (make-local-variable 'comment-start)
   (setq comment-start "(* ")
   (make-local-variable 'comment-end)
--- a/lisp/progmodes/perl-mode.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/perl-mode.el	Thu Jan 06 15:05:01 2005 +0000
@@ -476,7 +476,7 @@
   (make-local-variable 'indent-line-function)
   (setq indent-line-function 'perl-indent-line)
   (make-local-variable 'require-final-newline)
-  (setq require-final-newline t)
+  (setq require-final-newline mode-require-final-newline)
   (make-local-variable 'comment-start)
   (setq comment-start "# ")
   (make-local-variable 'comment-end)
--- a/lisp/progmodes/python.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/python.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1712,7 +1712,7 @@
   (set (make-local-variable 'indent-line-function) #'python-indent-line)
   (set (make-local-variable 'paragraph-start) "\\s-*$")
   (set (make-local-variable 'fill-paragraph-function) 'python-fill-paragraph)
-  (set (make-local-variable 'require-final-newline) t)
+  (set (make-local-variable 'require-final-newline) mode-require-final-newline)
   (set (make-local-variable 'add-log-current-defun-function)
        #'python-current-defun)
   ;; Fixme: Generalize to do all blocks?
--- a/lisp/progmodes/sh-script.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/sh-script.el	Thu Jan 06 15:05:01 2005 +0000
@@ -495,10 +495,9 @@
 
 (defcustom sh-require-final-newline
   '((csh . t)
-    (pdksh . t)
-    (rc . require-final-newline)
-    (sh . require-final-newline))
+    (pdksh . t))
   "*Value of `require-final-newline' in Shell-Script mode buffers.
+\(SHELL . t) means use the value of `mode-require-final-newline' for SHELL.
 See `sh-feature'."
   :type '(repeat (cons (symbol :tag "Shell")
 		       (choice (const :tag "require" t)
@@ -1485,8 +1484,8 @@
 	    (executable-set-magic shell (sh-feature sh-shell-arg)
 				  no-query-flag insert-flag)))
   (let ((tem (sh-feature sh-require-final-newline)))
-    (unless (eq tem 'require-final-newline)
-      (setq require-final-newline tem)))
+    (if (eq tem t)
+	(setq require-final-newline mode-require-final-newline)))
   (setq
 	comment-start-skip "#+[\t ]*"
 	local-abbrev-table sh-mode-abbrev-table
--- a/lisp/progmodes/simula.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/simula.el	Thu Jan 06 15:05:01 2005 +0000
@@ -380,7 +380,7 @@
   (make-local-variable 'indent-line-function)
   (setq indent-line-function 'simula-indent-line)
   (make-local-variable 'require-final-newline)
-  (setq require-final-newline t)
+  (setq require-final-newline mode-require-final-newline)
   (make-local-variable 'comment-start)
   (setq comment-start "! ")
   (make-local-variable 'comment-end)
--- a/lisp/progmodes/vhdl-mode.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/progmodes/vhdl-mode.el	Thu Jan 06 15:05:01 2005 +0000
@@ -4557,7 +4557,8 @@
        "\\s-*\\(--+\\s-*$\\|[^ -]\\|$\\)")
   (set (make-local-variable 'paragraph-separate) paragraph-start)
   (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
-  (set (make-local-variable 'require-final-newline) t)
+  (set (make-local-variable 'require-final-newline)
+       mode-require-final-newline)
   (set (make-local-variable 'parse-sexp-ignore-comments) t)
   (set (make-local-variable 'indent-line-function) 'vhdl-indent-line)
   (set (make-local-variable 'comment-start) "--")
--- a/lisp/simple.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/simple.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1234,10 +1234,6 @@
 (defvar undo-no-redo nil
   "If t, `undo' doesn't go through redo entries.")
 
-(defvar undo-list-saved nil
-  "The value of `buffer-undo-list' saved by the last undo command.")
-(make-variable-buffer-local 'undo-list-saved)
-
 (defun undo (&optional arg)
   "Undo some previous changes.
 Repeat this command to undo more changes.
@@ -1266,7 +1262,9 @@
 		 (let ((list buffer-undo-list))
 		   (while (eq (car list) nil)
 		     (setq list (cdr list)))
-		   (eq undo-list-saved list)))
+		   ;; If the last undo record made was made by undo
+		   ;; it shows nothing else happened in between.
+		   (gethash list undo-equiv-table)))
       (setq undo-in-region
 	    (if transient-mark-mode mark-active (and arg (not (numberp arg)))))
       (if undo-in-region
@@ -1320,7 +1318,6 @@
 	(setq prev tail tail (cdr tail))))
     ;; Record what the current undo list says,
     ;; so the next command can tell if the buffer was modified in between.
-    (setq undo-list-saved buffer-undo-list)
     (and modified (not (buffer-modified-p))
 	 (delete-auto-save-file-if-necessary recent-save))))
 
@@ -1328,9 +1325,8 @@
   "Make BUFFER stop keeping undo information.
 No argument or nil as argument means do this for the current buffer."
   (interactive)
-  (with-current-buffer (get-buffer buffer)
-    (setq buffer-undo-list t
-	  undo-list-saved nil)))
+  (with-current-buffer (if buffer (get-buffer buffer) (current-buffer))
+    (setq buffer-undo-list t)))
 
 (defun undo-only (&optional arg)
   "Undo some previous changes.
@@ -1524,17 +1520,33 @@
 	     '(0 . 0)))
     '(0 . 0)))
 
+(defvar undo-extra-outer-limit nil
+  "If non-nil, an extra level of size that's ok in an undo item.
+We don't ask the user about truncating the undo list until the
+current item gets bigger than this amount.")
+(make-variable-buffer-local 'undo-extra-outer-limit)
+
 ;; When the first undo batch in an undo list is longer than undo-outer-limit,
 ;; this function gets called to ask the user what to do.
 ;; Garbage collection is inhibited around the call,
 ;; so it had better not do a lot of consing.
 (setq undo-outer-limit-function 'undo-outer-limit-truncate)
 (defun undo-outer-limit-truncate (size)
-  (if (let (use-dialog-box)
-	(yes-or-no-p (format "Buffer %s undo info is %d bytes long; discard it? "
-			     (buffer-name) size)))
-      (progn (setq buffer-undo-list nil) t)
-    nil))
+  (when (or (null undo-extra-outer-limit)
+	    (> size undo-extra-outer-limit))
+    ;; Don't ask the question again unless it gets even bigger.
+    ;; This applies, in particular, if the user quits from the question.
+    ;; Such a quit quits out of GC, but something else will call GC
+    ;; again momentarily.  It will call this function again,
+    ;; but we don't want to ask the question again.
+    (setq undo-extra-outer-limit (+ size 50000))
+    (if (let (use-dialog-box)
+	  (yes-or-no-p (format "Buffer %s undo info is %d bytes long; discard it? "
+			       (buffer-name) size)))
+	(progn (setq buffer-undo-list nil)
+	       (setq undo-extra-outer-limit nil)
+	       t)
+      nil)))
 
 (defvar shell-command-history nil
   "History list for some commands that read shell commands.")
@@ -3577,15 +3589,17 @@
   (interactive "p")
   (forward-word (- (or arg 1))))
 
-(defun mark-word (&optional arg)
+(defun mark-word (&optional arg allow-extend)
   "Set mark ARG words away from point.
 The place mark goes is the same place \\[forward-word] would
 move to with the same argument.
-If this command is repeated or mark is active in Transient Mark mode,
+Interactively, if this command is repeated
+or (in Transient Mark mode) if the mark is active, 
 it marks the next ARG words after the ones already marked."
-  (interactive "P")
-  (cond ((or (and (eq last-command this-command) (mark t))
-	     (and transient-mark-mode mark-active))
+  (interactive "P\np")
+  (cond ((and allow-extend
+	      (or (and (eq last-command this-command) (mark t))
+		  (and transient-mark-mode mark-active)))
 	 (setq arg (if arg (prefix-numeric-value arg)
 		     (if (< (mark) (point)) -1 1)))
 	 (set-mark
--- a/lisp/startup.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/startup.el	Thu Jan 06 15:05:01 2005 +0000
@@ -236,9 +236,17 @@
 override them.  Users can prevent loading `default.el' with the `-q'
 option or by setting `inhibit-default-init' in their own init files,
 but inhibiting `site-start.el' requires `--no-site-file', which
-is less convenient."
+is less convenient.
+
+This variable is defined for customization so as to make
+it visible in the relevant context.  However, actually customizing it
+is not allowed, since it would not work anyway.  The only way to set
+this variable usefully is to set it during while building and dumping Emacs."
   :type '(choice (const :tag "none" nil) string)
-  :group 'initialization)
+  :group 'initialization
+  :initialize 'custom-initialize-default
+  :set '(lambda (variable value)
+	  (error "Customizing `site-run-file' does not work")))
 
 (defcustom mail-host-address nil
   "*Name of this machine, for purposes of naming users."
--- a/lisp/subr.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/subr.el	Thu Jan 06 15:05:01 2005 +0000
@@ -1022,7 +1022,7 @@
 It can also be nil, if the definition is not associated with any file.
 
 If TYPE is nil, then any kind of definition is acceptable.
-If type is `defun' or `defvar', that specifies function
+If TYPE is `defun' or `defvar', that specifies function
 definition only or variable definition only."
   (if (and (or (null type) (eq type 'defun))
 	   (symbolp symbol) (fboundp symbol)
--- a/lisp/term/mac-win.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/term/mac-win.el	Thu Jan 06 15:05:01 2005 +0000
@@ -76,7 +76,7 @@
 ;;(require 'select)
 (require 'menu-bar)
 (require 'fontset)
-;;(require 'x-dnd)
+(require 'x-dnd)
 
 (defvar x-invocation-args)
 
@@ -1564,29 +1564,32 @@
 (mouse-wheel-mode 1)
 
 (defun mac-drag-n-drop (event)
-  "Edit the files listed in the drag-n-drop event.\n\
+  "Edit the files listed in the drag-n-drop EVENT.
 Switch to a buffer editing the last file dropped."
   (interactive "e")
-  (save-excursion
-    ;; Make sure the drop target has positive co-ords
-    ;; before setting the selected frame - otherwise it
-    ;; won't work.  <skx@tardis.ed.ac.uk>
-    (let* ((window (posn-window (event-start event)))
-	   (coords (posn-x-y (event-start event)))
-	   (x (car coords))
-	   (y (cdr coords)))
-      (if (and (> x 0) (> y 0))
-	  (set-frame-selected-window nil window))
-      (mapcar
-       '(lambda (file)
-	  (find-file
-	   (decode-coding-string
-	    file
-	    (or file-name-coding-system
-		default-file-name-coding-system))))
-       (car (cdr (cdr event)))))
-  (raise-frame)
-  (recenter)))
+  ;; Make sure the drop target has positive co-ords
+  ;; before setting the selected frame - otherwise it
+  ;; won't work.  <skx@tardis.ed.ac.uk>
+  (let* ((window (posn-window (event-start event)))
+	 (coords (posn-x-y (event-start event)))
+	 (x (car coords))
+	 (y (cdr coords)))
+    (if (and (> x 0) (> y 0))
+	(set-frame-selected-window nil window))
+    (mapcar (lambda (file-name)
+	      (if (listp file-name)
+		  (let ((line (car file-name))
+			(start (car (cdr file-name)))
+			(end (car (cdr (cdr file-name)))))
+		    (if (> line 0)
+			(goto-line line)
+		      (if (and (> start 0) (> end 0))
+			  (progn (set-mark start)
+				 (goto-char end)))))
+		(x-dnd-handle-one-url window 'private
+				      (concat "file:" file-name))))
+	    (car (cdr (cdr event)))))
+  (raise-frame))
 
 (global-set-key [drag-n-drop] 'mac-drag-n-drop)
 
--- a/lisp/textmodes/artist.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/textmodes/artist.el	Thu Jan 06 15:05:01 2005 +0000
@@ -5,8 +5,8 @@
 ;; Author:       Tomas Abrahamsson <tab@lysator.liu.se>
 ;; Maintainer:   Tomas Abrahamsson <tab@lysator.liu.se>
 ;; Keywords:     mouse
-;; Version:	 1.2.4
-;; Release-date: 25-Oct-2001
+;; Version:	 1.2.6
+;; Release-date: 6-Aug-2004
 ;; Location:     http://www.lysator.liu.se/~tab/artist/
 
 ;; This file is part of GNU Emacs.
@@ -136,6 +136,14 @@
 
 ;;; ChangeLog:
 
+;; 1.2.6	6-Aug-2004
+;; New:		Coerced with the artist.el that's in Emacs-21.3.
+;;              (minor editorial changes)
+;;
+;; 1.2.5	4-Aug-2004
+;; New:		Added tool selection via the mouse-wheel
+;;		Function provided by Andreas Leue <al@sphenon.de>
+;;
 ;; 1.2.4	25-Oct-2001
 ;; Bugfix:	Some operations (the edit menu) got hidden
 ;; Bugfix:      The first arrow for poly-lines was always pointing
@@ -187,7 +195,7 @@
 
 ;; Variables
 
-(defconst artist-version "1.2.4")
+(defconst artist-version "1.2.6")
 (defconst artist-maintainer-address "tab@lysator.liu.se")
 
 
@@ -471,6 +479,14 @@
 The fill char is used instead, if it is set.")
 (make-variable-buffer-local 'artist-borderless-shapes)
 
+(defvar artist-prev-next-op-alist nil
+  "Assoc list for looking up next and/or previous draw operation.
+The structure is as follows:  (OP . (PREV-OP . NEXT-OP))
+where the elements are as follows:
+* OP is an atom: the KEY-SYMBOL in the `artist-mt' structure
+* PREV-OP and NEXT-OP are strings: the KEYWORD in the `artist-mt' structure
+
+This variable is initialized by the artist-make-prev-next-op-alist function.")
 
 (eval-when-compile
   ;; Make rect available at compile-time
@@ -496,6 +512,8 @@
     (define-key map [S-down-mouse-2] 'artist-mouse-choose-operation)
     (define-key map [down-mouse-3] 'artist-down-mouse-3)
     (define-key map [S-down-mouse-3] 'artist-down-mouse-3)
+    (define-key map [C-mouse-4] 'artist-select-prev-op-in-list)
+    (define-key map [C-mouse-5] 'artist-select-next-op-in-list)
     (define-key map "\r" 'artist-key-set-point) ; return
     (define-key map [up] 'artist-previous-line)
     (define-key map "\C-p" 'artist-previous-line)
@@ -1063,6 +1081,73 @@
   "Retrieve the items component from a graphics operation INFO-PART."
   (elt info-part 1))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; mouse wheel cyclic operation selection
+
+(defun artist-get-last-non-nil-op (op-list &optional last-non-nil)
+  "Find the last non-nil draw operation in OP-LIST.
+Optional LAST-NON-NIL will be returned if OP-LIST is nil."
+  (if op-list
+      (artist-get-last-non-nil-op (cdr op-list)
+				  (or (car (car op-list)) last-non-nil))
+    last-non-nil))
+
+(defun artist-get-first-non-nil-op (op-list)
+  "Find the first non-nil draw operation in OP-LIST."
+  (or (car (car op-list)) (artist-get-first-non-nil-op (cdr op-list))))
+
+(defun artist-is-in-op-list-p (op op-list)
+  "Check whether OP is in OP-LIST."
+  (and op-list
+       (or (and (car (car op-list)) (string= op (car (car op-list))))
+	   (artist-is-in-op-list-p op (cdr op-list)))))
+
+(defun artist-make-prev-next-op-alist (op-list
+				       &optional
+				       last-non-nil-arg first-non-nil-arg
+				       prev-entry prev-op-arg)
+  "Build an assoc-list of OP-LIST.
+The arguments LAST-NON-NIL-ARG, FIRST-NON-NIL-ARG, PREV-ENTRY and
+PREV-OP-ARG are used when invoked recursively during the build-up."
+  (let* ((last-non-nil  (or last-non-nil-arg
+			    (artist-get-last-non-nil-op
+			     artist-key-compl-table)))
+         (first-non-nil (or first-non-nil-arg
+			    (artist-get-first-non-nil-op
+			     artist-key-compl-table)))
+         (prev-op       (or prev-op-arg last-non-nil))
+         (op            (car (car op-list)))
+         (opsym         (artist-mt-get-symbol-from-keyword op))
+         (entry         (cons opsym (cons prev-op nil))))
+    (if (or (and op-list (not op))
+	    (artist-is-in-op-list-p op (cdr op-list)))
+        (artist-make-prev-next-op-alist (cdr op-list)
+					last-non-nil first-non-nil
+					prev-entry prev-op)
+      (if prev-entry (setcdr (cdr prev-entry) op))
+      (if op-list
+          (cons entry (artist-make-prev-next-op-alist
+		       (cdr op-list)
+		       last-non-nil first-non-nil
+		       entry op))
+        (progn (setcdr (cdr prev-entry) first-non-nil) nil)))))
+
+(defun artist-select-next-op-in-list ()
+  "Cyclically select next drawing mode operation."
+  (interactive)
+  (let ((next-op (cdr (cdr (assoc artist-curr-go artist-prev-next-op-alist)))))
+    (artist-select-operation next-op)
+    (message next-op)))
+
+(defun artist-select-prev-op-in-list ()
+  "Cyclically select previous drawing mode operation."
+  (interactive)
+  (let ((prev-op (car (cdr (assoc artist-curr-go artist-prev-next-op-alist)))))
+    (artist-select-operation prev-op)
+    (message prev-op)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
 ;;; ---------------------------------
 ;;; The artist-mode
 ;;; ---------------------------------
@@ -1317,6 +1402,7 @@
   (make-local-variable 'artist-key-draw-how)
   (make-local-variable 'artist-popup-menu-table)
   (make-local-variable 'artist-key-compl-table)
+  (make-local-variable 'artist-prev-next-op-alist)
   (make-local-variable 'artist-rb-save-data)
   (make-local-variable 'artist-arrow-point-1)
   (make-local-variable 'artist-arrow-point-2)
@@ -1326,6 +1412,8 @@
   (setq artist-key-shape nil)
   (setq artist-popup-menu-table (artist-compute-popup-menu-table artist-mt))
   (setq artist-key-compl-table (artist-compute-key-compl-table artist-mt))
+  (setq artist-prev-next-op-alist
+	(artist-make-prev-next-op-alist artist-key-compl-table))
   (setq artist-rb-save-data (make-vector 7 0))
   (setq artist-arrow-point-1 nil)
   (setq artist-arrow-point-2 nil)
@@ -1444,7 +1532,7 @@
   "Compute completion table from MENU-TABLE, suitable for `completing-read'."
   (apply
    'nconc
-   (artist-remove-nulls
+   (remq nil
     (mapcar
      (lambda (element)
        (let ((element-tag (artist-mt-get-tag element)))
@@ -1684,29 +1772,6 @@
   "Call function FN with ARGS iff FN is not nil."
   (list 'if fn (cons 'funcall (cons fn args))))
 
-(defvar artist-butlast-fn 'artist-butlast
-  "The butlast function.")
-
-(if (fboundp 'butlast)
-    (setq artist-butlast-fn 'butlast)
-  (setq artist-butlast-fn 'artist-butlast))
-
-(defun artist-butlast (l)
-  "Return the list L with all elements but the last."
-  (cond ((null l) nil)
-	((null (cdr l)) nil)
-	(t (cons (car l) (artist-butlast (cdr l))))))
-
-
-(defun artist-last (l &optional n)
-  "Return the last link in the list L.
-With optional argument N, returns Nth-to-last link (default 1)."
-  (nth (- (length l) (or n 1)) l))
-
-(defun artist-remove-nulls (l)
-  "Remove nils in list L."
-  (remq nil l))
-
 (defun artist-uniq (l)
   "Remove consecutive duplicates in list L.  Comparison is done with `equal'."
   (cond ((null l) nil)
@@ -1714,16 +1779,6 @@
 	((equal (car l) (car (cdr l))) (artist-uniq (cdr l))) ; first 2 equal
 	(t (cons (car l) (artist-uniq (cdr l)))))) ; first 2 are different
 
-(defmacro artist-push (x stack)
-  "Push element X to a STACK."
-  (list 'setq stack (list 'cons x stack)))
-
-(defmacro artist-pop (stack)
-  "Pop an element from a STACK."
-  (list 'prog1
-	(list 'car stack)
-	(list 'setq stack (list 'cdr stack))))
-
 (defun artist-string-split (str r)
   "Split string STR at occurrences of regexp R, returning a list of strings."
   (let ((res nil)
@@ -3158,14 +3213,14 @@
   "Vaporize lines reachable from point X1, Y1."
   (let ((ep-stack nil))
     (mapcar
-     (lambda (ep) (artist-push ep ep-stack))
+     (lambda (ep) (push ep ep-stack))
      (artist-vap-find-endpoints x1 y1))
     (while (not (null ep-stack))
-      (let* ((vaporize-point (artist-pop ep-stack))
+      (let* ((vaporize-point (pop ep-stack))
 	     (new-endpoints (artist-vaporize-line (car vaporize-point)
 						  (cdr vaporize-point))))
 	(mapcar
-	 (lambda (endpoint) (artist-push endpoint ep-stack))
+	 (lambda (endpoint) (push endpoint ep-stack))
 	 new-endpoints)))))
 
 
@@ -3326,7 +3381,7 @@
     ;; that look like:    \           /  instead we get:   (           )
     ;;                     \         /                      \         /
     ;;                      ---------                        ---------
-    (let ((last-coord  (artist-last point-list)))
+    (let ((last-coord  (last point-list)))
       (if (= (artist-coord-get-new-char last-coord) ?/)
 	  (artist-coord-set-new-char last-coord artist-ellipse-right-char)))
 
@@ -3359,7 +3414,7 @@
 				       (t c)))))
 	   ;; The cdr and butlast below is so we don't draw the middle top
 	   ;; and middle bottom char twice.
-	   (funcall artist-butlast-fn (cdr (reverse right-half)))))
+	   (butlast (cdr (reverse right-half)))))
     (append right-half left-half)))
 
 
@@ -3675,10 +3730,10 @@
     ;; area we are about to fill, or, in other words, don't fill if we
     ;; needn't.
     (if (not (= c artist-fill-char))
-	(artist-push (artist-new-coord x1 y1) stack))
+	(push (artist-new-coord x1 y1) stack))
 
     (while (not (null stack))
-      (let* ((coord (artist-pop stack))
+      (let* ((coord (pop stack))
 	     (x (artist-coord-get-x coord))
 	     (y (artist-coord-get-y coord))
 
@@ -3710,7 +3765,7 @@
 	  (if lines-above
 	      (let ((c-above (artist-get-char-at-xy-conv x (- y 1))))
 		(if (and (= c-above c) (/= c-above last-c-above))
-		    (artist-push (artist-new-coord x (- y 1)) stack))
+		    (push (artist-new-coord x (- y 1)) stack))
 		(setq last-c-above c-above)))
 	  (setq last-x x)
 	  (setq x (- x 1)))
@@ -3724,7 +3779,7 @@
 	  (if lines-below
 	      (let ((c-below (artist-get-char-at-xy-conv x (1+ y))))
 		(if (and (= c-below c) (/= c-below last-c-below))
-		    (artist-push (artist-new-coord x (1+ y)) stack))
+		    (push (artist-new-coord x (1+ y)) stack))
 		(setq last-c-below c-below)))
 	  (setq x (- x 1)))
 
--- a/lisp/textmodes/paragraphs.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/textmodes/paragraphs.el	Thu Jan 06 15:05:01 2005 +0000
@@ -347,7 +347,7 @@
   (or arg (setq arg 1))
   (forward-paragraph (- arg)))
 
-(defun mark-paragraph (&optional arg)
+(defun mark-paragraph (&optional arg allow-extend)
   "Put point at beginning of this paragraph, mark at end.
 The paragraph marked is the one that contains point or follows point.
 
@@ -357,15 +357,16 @@
 If ARG is negative, point is put at end of this paragraph, mark is put
 at beginning of this or a previous paragraph.
 
-If this command is repeated or mark is active in Transient Mark mode,
-it marks the next ARG paragraphs after (or before, if arg is negative)
-the ones already marked."
-  (interactive "p")
+Interactively, if this command is repeated
+or (in Transient Mark mode) if the mark is active, 
+it marks the next ARG paragraphs after the ones already marked."
+  (interactive "p\np")
   (unless arg (setq arg 1))
   (when (zerop arg)
     (error "Cannot mark zero paragraphs"))
-  (cond ((or (and (eq last-command this-command) (mark t))
-	     (and transient-mark-mode mark-active))
+  (cond ((and allow-extend
+	      (or (and (eq last-command this-command) (mark t))
+		  (and transient-mark-mode mark-active)))
 	 (set-mark
 	  (save-excursion
 	    (goto-char (mark))
--- a/lisp/textmodes/texinfo.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/textmodes/texinfo.el	Thu Jan 06 15:05:01 2005 +0000
@@ -581,7 +581,7 @@
 	texinfo-chapter-level-regexp
 	"\\)\\>"))
   (make-local-variable 'require-final-newline)
-  (setq require-final-newline t)
+  (setq require-final-newline mode-require-final-newline)
   (make-local-variable 'indent-tabs-mode)
   (setq indent-tabs-mode nil)
   (make-local-variable 'paragraph-separate)
--- a/lisp/textmodes/text-mode.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/textmodes/text-mode.el	Thu Jan 06 15:05:01 2005 +0000
@@ -68,7 +68,8 @@
 Turning on Text mode runs the normal hook `text-mode-hook'."
   (make-local-variable 'text-mode-variant)
   (setq text-mode-variant t)
-  (set (make-local-variable 'require-final-newline) t)
+  (set (make-local-variable 'require-final-newline)
+       mode-require-final-newline)
   (set (make-local-variable 'indent-line-function) 'indent-relative))
 
 (define-derived-mode paragraph-indent-text-mode text-mode "Parindent"
--- a/lisp/vc-rcs.el	Thu Jan 06 15:00:09 2005 +0000
+++ b/lisp/vc-rcs.el	Thu Jan 06 15:05:01 2005 +0000
@@ -500,6 +500,7 @@
 (defun vc-rcs-annotate-command (file buffer &optional revision)
   "Annotate FILE, inserting the results in BUFFER.
 Optional arg REVISION is a revision to annotate from."
+  (vc-setup-buffer buffer)
   ;; Aside from the "head revision on the trunk", the instructions for
   ;; each revision on the trunk are an ordered list of kill and insert
   ;; commands necessary to go from the chronologically-following
--- a/lispref/ChangeLog	Thu Jan 06 15:00:09 2005 +0000
+++ b/lispref/ChangeLog	Thu Jan 06 15:05:01 2005 +0000
@@ -1,3 +1,22 @@
+2004-12-30  Kim F. Storm  <storm@cua.dk>
+
+	* display.texi (Line Height): Total line-height is now specified
+	in line-height property of form (HEIGHT TOTAL).  Swap (FACE . RATIO)
+	in cons cells.  (nil . RATIO) is relative to actual line height.
+	Use line-height `t' instead of `0' to get minimum height.
+
+2004-12-29  Richard M. Stallman  <rms@gnu.org>
+
+	* os.texi (Timers): Discuss timers vs editing the buffer and undo.
+
+2004-12-28  Richard M. Stallman  <rms@gnu.org>
+
+	* commands.texi (Quitting): Clarify value of with-local-quit.
+
+	* elisp.texi (Top): Fix previous change.
+
+	* loading.texi (Loading): Fix previous change.
+
 2004-12-27  Richard M. Stallman  <rms@gnu.org>
 
 	* Makefile.in (MAKEINFO): Specify --force.
--- a/lispref/commands.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/lispref/commands.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -2605,7 +2605,8 @@
 This macro executes @var{forms} in sequence, but allows quitting, at
 least locally, within @var{body} even if @code{inhibit-quit} was
 non-@code{nil} outside this construct.  It returns the value of the
-last form in @var{forms}.
+last form in @var{forms}, unless exited by quitting, in which case
+it returns @code{nil}.
 
 If @code{inhibit-quit} is @code{nil} on entry to @code{with-local-quit},
 it only executes the @var{forms}, and setting @code{quit-flag} causes
--- a/lispref/display.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/lispref/display.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -1532,12 +1532,21 @@
 @kindex line-height @r{(text property)}
   A newline can have a @code{line-height} text or overlay property
 that controls the total height of the display line ending in that
-newline.  If the property value is zero, the displayed height of the
+newline.
+
+  If the property value is a list @code{(@var{height} @var{total})},
+then @var{height} is used as the actual property value for the
+@code{line-height}, and @var{total} specifies the total displayed
+height of the line, so the line spacing added below the line equals
+the @var{total} height minus the actual line height.  In this case,
+the other ways to specify the line spacing are ignored.
+
+  If the property value is @code{t}, the displayed height of the
 line is exactly what its contents demand; no line-spacing is added.
 This case is useful for tiling small images or image slices without
 adding blank areas between the images.
 
-  If the property value is not zero, it is a height spec.  A height
+  If the property value is not @code{t}, it is a height spec.  A height
 spec stands for a numeric height value; this heigh spec specifies the
 actual line height, @var{line-height}.  There are several ways to
 write a height spec; here's how each of them translates into a numeric
@@ -1549,14 +1558,17 @@
 @item @var{float}
 If the height spec is a float, @var{float}, the numeric height value
 is @var{float} times the frame's default line height.
-@item (@var{ratio} . @var{face})
+@item (@var{face} . @var{ratio})
 If the height spec is a cons of the format shown, the numeric height
 is @var{ratio} times the height of face @var{face}.  @var{ratio} can
-be any type of number.  If @var{face} is @code{t}, it refers to the
-current face.
+be any type of number, or @code{nil} which means a ratio of 1.
+If @var{face} is @code{t}, it refers to the current face.
+@item (@code{nil} . @var{ratio})
+If the height spec is a cons of the format shown, the numeric height
+is @var{ratio} times the height of the contents of the line.
 @end table
 
-  Thus, any valid nonzero property value specifies a height in pixels,
+  Thus, any valid non-@code{t} property value specifies a height in pixels,
 @var{line-height}, one way or another.  If the line contents' height
 is less than @var{line-height}, Emacs adds extra vertical space above
 the line to achieve the total height @var{line-height}.  Otherwise,
@@ -1595,18 +1607,6 @@
 numeric height value specifies the line spacing, rather than the line
 height.
 
-  There is one exception, however: if the @var{line-spacing} value is
-a cons @code{(total . @var{spacing})}, then @var{spacing} itself is
-treated as a heigh spec, and specifies the total displayed height of
-the line, so the line spacing equals the specified amount minus the
-line height.  This differs from using the @code{line-height} property
-because it adds space at the bottom of the line instead of the top.
-
-  If you specify both @code{line-spacing} using @code{total} and
-@code{line-height}, they are not redundant.  First @code{line-height}
-goes to work, adding space above the line contents.  Then
-@code{line-spacing} goes to work, adding space below the contents.
-
 @node Faces
 @section Faces
 @cindex faces
--- a/lispref/elisp.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/lispref/elisp.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -426,7 +426,7 @@
 * Repeated Loading::        Precautions about loading a file twice.
 * Named Features::          Loading a library if it isn't already loaded.
 * Where Defined::           Finding which file defined a certain symbol.
-* Unloading::		      to ``unload'' a library that was loaded.
+* Unloading::		    How to ``unload'' a library that was loaded.
 * Hooks for Loading::	    Providing code to be run when
 			      particular libraries are loaded.
 
--- a/lispref/loading.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/lispref/loading.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -43,7 +43,7 @@
 * Repeated Loading::        Precautions about loading a file twice.
 * Named Features::          Loading a library if it isn't already loaded.
 * Where Defined::           Finding which file defined a certain symbol.
-* Unloading::		      to ``unload'' a library that was loaded.
+* Unloading::		    How to ``unload'' a library that was loaded.
 * Hooks for Loading::	    Providing code to be run when
 			      particular libraries are loaded.
 @end menu
--- a/lispref/os.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/lispref/os.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -1368,6 +1368,11 @@
 timer to call a function that takes substantial time to run is likely
 to be annoying.
 
+  Timer functions should normally not alter the current buffer
+contents, but it may be ok to alter some other buffer that exists for
+special purposes.  A general guideline is that if a buffer has undo
+enabled, timers should not write in it.
+
 @deffn Command run-at-time time repeat function &rest args
 This sets up a timer that calls the function @var{function} with
 arguments @var{args} at time @var{time}.  If @var{repeat} is a number
@@ -1481,6 +1486,11 @@
 input.  Then it becomes idle again, and all the idle timers that are
 set up to repeat will subsequently run another time, one by one.
 
+  It is legitimate for an idle timer to edit the current buffer.  If
+it does, it should explicitly call @code{undo-boundary} once at the
+beginning and once just before exiting, since Emacs won't do that
+automatically for an idle timer.
+
 @defun cancel-timer timer
 Cancel the requested action for @var{timer}, which should be a value
 previously returned by @code{run-at-time} or @code{run-with-idle-timer}.
--- a/man/ChangeLog	Thu Jan 06 15:00:09 2005 +0000
+++ b/man/ChangeLog	Thu Jan 06 15:05:01 2005 +0000
@@ -1,3 +1,20 @@
+2004-12-31  Richard M. Stallman  <rms@gnu.org>
+
+	* dired.texi (Shell Commands in Dired): Delete the ? example.
+
+	* display.texi (Scrolling): Correct scroll-preserve-screen-position.
+
+	* files.texi (Saving): Describe new require-final-newline features
+	and mode-require-final-newline.
+
+2004-12-31  Jay Belanger  <belanger@truman.edu>
+
+	* calc.texi: Mention C-cC-c as the way to finish editing throughout.
+
+2004-12-29  Richard M. Stallman  <rms@gnu.org>
+
+	* custom.texi (File Variables): Clarify previous change.
+
 2004-12-27  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* frames.texi (Dialog Boxes): Mention Gtk+ 2.6 also, as that version is
@@ -16,7 +33,7 @@
 
 2004-12-20  Jay Belanger  <belanger@truman.edu>
 
-	* calc.texi (Types Tutorial): Emphasized that you can't divide by
+	* calc.texi (Types Tutorial): Emphasize that you can't divide by
 	zero.
 
 2004-12-17  Luc Teirlinck  <teirllm@auburn.edu>
--- a/man/calc.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/man/calc.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -2666,7 +2666,7 @@
 scrolling to see them all.  Press @kbd{<} and @kbd{>} to scroll the
 stack window left and right by half its width.  Another way to view
 something large is to press @kbd{`} (back-quote) to edit the top of
-stack in a separate window.  (Press @kbd{M-# M-#} when you are done.)
+stack in a separate window.  (Press @kbd{C-c C-c} when you are done.)
 
 You can enter non-decimal numbers using the @kbd{#} symbol, too.
 Let's see what the hexadecimal number @samp{5FE} looks like in
@@ -5588,8 +5588,8 @@
 @end smallexample
 
 To edit a variable, type @kbd{s e} and the variable name, use regular
-Emacs editing commands as necessary, then type @kbd{M-# M-#} or
-@kbd{C-c C-c} to store the edited value back into the variable.
+Emacs editing commands as necessary, then type @kbd{C-c C-c} to store
+the edited value back into the variable. 
 You can also use @w{@kbd{s e}} to create a new variable if you wish.
 
 Notice that the first time you use each rule, Calc puts up a ``compiling''
@@ -6381,7 +6381,7 @@
 @end smallexample
 
 @noindent
-Press @kbd{M-# M-#} to finish editing and return to the Calculator.
+Press @kbd{C-c C-c} to finish editing and return to the Calculator.
 
 @smallexample
 @group
@@ -11714,7 +11714,13 @@
 Calc also allows apostrophes and @code{#} signs in variable names.
 (The Calc variable @code{foo} corresponds to the Emacs Lisp variable
 @code{var-foo}, but unless you access the variable from within Emacs
-Lisp, you don't need to worry about it.)
+Lisp, you don't need to worry about it.  Variable names in algebraic
+formulas implicitly have @samp{var-} prefixed to their names.  The
+@samp{#} character in variable names used in algebraic formulas
+corresponds to a dash @samp{-} in the Lisp variable name.  If the name
+contains any dashes, the prefix @samp{var-} is @emph{not} automatically
+added.  Thus the two formulas @samp{foo + 1} and @samp{var#foo + 1} both
+refer to the same variable.)
 
 In a command that takes a variable name, you can either type the full
 name of a variable, or type a single digit to use one of the special
@@ -11727,14 +11733,6 @@
 stack, enter its name as an algebraic expression using the apostrophe
 (@key{'}) key.
 
-xxx
-  Variable names in algebraic formulas implicitly have
-@samp{var-} prefixed to their names.  The @samp{#} character in variable
-names used in algebraic formulas corresponds to a dash @samp{-} in the
-Lisp variable name.  If the name contains any dashes, the prefix @samp{var-}
-is @emph{not} automatically added.  Thus the two formulas @samp{foo + 1}
-and @samp{var#foo + 1} both refer to the same variable.
-
 @kindex =
 @pindex calc-evaluate
 @cindex Evaluation of variables in a formula
@@ -11886,10 +11884,10 @@
 need to write @samp{(5%)-2} to get the former interpretation.
 
 @cindex Function call notation
-A function call is, e.g., @samp{sin(1+x)}.  Function names follow the same
-rules as variable names except that the default prefix @samp{calcFunc-} is
-used (instead of @samp{var-}) for the internal Lisp form.
-Most mathematical Calculator commands like
+A function call is, e.g., @samp{sin(1+x)}.  (The Calc algebraic function
+@code{foo} corresponds to the Emacs Lisp function @code{calcFunc-foo},
+but unless you access the function from within Emacs Lisp, you don't
+need to worry about it.)  Most mathematical Calculator commands like
 @code{calc-sin} have function equivalents like @code{sin}.
 If no Lisp function is defined for a function called by a formula, the
 call is left as it is during algebraic manipulation: @samp{f(x+y)} is
@@ -12061,13 +12059,11 @@
 specified number of stack entries at once.  (An argument of zero edits
 the entire stack; a negative argument edits one specific stack entry.)
 
-When you are done editing, press @kbd{M-# M-#} to finish and return
+When you are done editing, press @kbd{C-c C-c} to finish and return
 to Calc.  The @key{RET} and @key{LFD} keys also work to finish most
 sorts of editing, though in some cases Calc leaves @key{RET} with its
 usual meaning (``insert a newline'') if it's a situation where you
-might want to insert new lines into the editing buffer.  The traditional
-Emacs ``finish'' key sequence, @kbd{C-c C-c}, also works to finish
-editing and may be easier to type, depending on your keyboard.
+might want to insert new lines into the editing buffer.
 
 When you finish editing, the Calculator parses the lines of text in
 the @samp{*Calc Edit*} buffer as numbers or formulas, replaces the
@@ -12075,18 +12071,18 @@
 then kills the @samp{*Calc Edit*} buffer.  The original Calculator buffer
 continues to exist during editing, but for best results you should be
 careful not to change it until you have finished the edit.  You can
-also cancel the edit by pressing @kbd{M-# x}.
+also cancel the edit by killing the buffer with @kbd{C-x k}.
 
 The formula is normally reevaluated as it is put onto the stack.
 For example, editing @samp{a + 2} to @samp{3 + 2} and pressing
-@kbd{M-# M-#} will push 5 on the stack.  If you use @key{LFD} to
+@kbd{C-c C-c} will push 5 on the stack.  If you use @key{LFD} to
 finish, Calc will put the result on the stack without evaluating it.
 
-If you give a prefix argument to @kbd{M-# M-#} (or @kbd{C-c C-c}),
+If you give a prefix argument to @kbd{C-c C-c},
 Calc will not kill the @samp{*Calc Edit*} buffer.  You can switch
 back to that buffer and continue editing if you wish.  However, you
 should understand that if you initiated the edit with @kbd{`}, the
-@kbd{M-# M-#} operation will be programmed to replace the top of the
+@kbd{C-c C-c} operation will be programmed to replace the top of the
 stack with the new edited value, and it will do this even if you have
 rearranged the stack in the meanwhile.  This is not so much of a problem
 with other editing commands, though, such as @kbd{s e}
@@ -15266,8 +15262,8 @@
 The @kbd{Z S} (@code{calc-edit-user-syntax}) command edits the
 syntax table for the current language mode.  If you want your
 syntax to work in any language, define it in the Normal language
-mode.  Type @kbd{M-# M-#} to finish editing the syntax table, or
-@kbd{M-# x} to cancel the edit.  The @kbd{m m} command saves all
+mode.  Type @kbd{C-c C-c} to finish editing the syntax table, or
+@kbd{C-x k} to cancel the edit.  The @kbd{m m} command saves all
 the syntax tables along with the other mode settings;
 @pxref{General Mode Commands}.
 
@@ -21811,7 +21807,7 @@
 @xref{Selections with Rewrite Rules}.  The rules are stored in
 the Calc variable @code{DistribRules}.  A convenient way to view
 these rules is to use @kbd{s e} (@code{calc-edit-variable}) which
-displays and edits the stored value of a variable.  Press @kbd{M-# M-#}
+displays and edits the stored value of a variable.  Press @kbd{C-c C-c}
 to return from editing mode; be careful not to make any actual changes
 or else you will affect the behavior of future @kbd{j D} commands!
 
@@ -23587,7 +23583,7 @@
 command to substitute actual values for function calls like @samp{as(3)}.
 
 The @kbd{s G} (@code{calc-edit-GenCount}) command is a convenient
-way to create or edit this variable.  Press @kbd{M-# M-#} to finish.
+way to create or edit this variable.  Press @kbd{C-c C-c} to finish.
 
 If you have not stored a value in @code{GenCount}, or if the value
 in that variable is not a positive integer, the regular
@@ -28091,7 +28087,7 @@
 or simplifying or evaluating the value.  It prompts for the name of
 the variable to edit.  If the variable has no stored value, the
 editing buffer will start out empty.  If the editing buffer is
-empty when you press @kbd{M-# M-#} to finish, the variable will
+empty when you press @kbd{C-c C-c} to finish, the variable will
 be made void.  @xref{Editing Stack Entries}, for a general
 description of editing.
 
@@ -28938,7 +28934,7 @@
 @texline @math{80\times24}
 @infoline 80x24
 characters.  The graph is displayed in
-an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit
+an Emacs ``recursive edit''; type @kbd{q} or @kbd{C-c C-c} to exit
 the recursive edit and return to Calc.  Note that the @code{dumb}
 device is present only in GNUPLOT 3.0 and later versions.
 
@@ -30118,7 +30114,7 @@
 The @kbd{M-# `} (@code{calc-embedded-edit}) command edits the
 embedded formula at the current point as if by @kbd{`} (@code{calc-edit}).
 Embedded mode does not have to be enabled for this to work.  Press
-@kbd{M-# M-#} to finish the edit, or @kbd{M-# x} to cancel.
+@kbd{C-c C-c} to finish the edit, or @kbd{C-x k} to cancel.
 
 @node Assignments in Embedded Mode, Mode Settings in Embedded Mode, More About Embedded Mode, Embedded Mode
 @section Assignments in Embedded Mode
@@ -30742,15 +30738,14 @@
 key could invoke a command, which in turn calls an algebraic function,
 which might have one or more special display formats.  A single @kbd{Z P}
 command will save all of these definitions.
-
-To save a command or function without its key binding (or if there is
-no key binding for the command or function), type @kbd{'} (the apostrophe)
-when prompted for a key.  Then, type the function name, or backspace
-to change the @samp{calcFunc-} prefix to @samp{calc-} and enter a
-command name.  (If the command you give implies a function, the function
-will be saved, and if the function has any display formats, those will
-be saved, but not the other way around:  Saving a function will not save
-any commands or key bindings associated with the function.)
+To save an algebraic function, type @kbd{'} (the apostrophe)
+when prompted for a key, and type the function name.  To save a command
+without its key binding, type @kbd{M-x} and enter a function name.  (The
+@samp{calc-} prefix will automatically be inserted for you.)
+(If the command you give implies a function, the function will be saved,
+and if the function has any display formats, those will be saved, but
+not the other way around:  Saving a function will not save any commands
+or key bindings associated with the function.) 
 
 @kindex Z E
 @pindex calc-user-define-edit
@@ -30836,14 +30831,14 @@
 command to edit the macro.  This command may be found in the
 @file{macedit} package, a copy of which comes with Calc.  It decomposes
 the macro definition into full Emacs command names, like @code{calc-pop}
-and @code{calc-add}.  Type @kbd{M-# M-#} to finish editing and update
-the definition stored on the key, or, to cancel the edit, type
-@kbd{M-# x}.
+and @code{calc-add}.  Type @kbd{C-c C-c} to finish editing and update
+the definition stored on the key, or, to cancel the edit, kill the
+buffer with @kbd{C-x k}.
 
 If you give a negative numeric prefix argument to @kbd{Z E}, the keyboard
 macro is edited in spelled-out keystroke form.  For example, the editing
 buffer might contain the nine characters @w{@samp{1 @key{RET} 2 +}}.  When you press
-@kbd{M-# M-#}, the @code{read-kbd-macro} feature of the @file{macedit}
+@kbd{C-c C-c}, the @code{read-kbd-macro} feature of the @file{macedit}
 package is used to reinterpret these key names.  The
 notations @code{RET}, @code{LFD}, @code{TAB}, @code{SPC}, @code{DEL}, and
 @code{NUL} must be written in all uppercase, as must the prefixes @code{C-}
@@ -31190,9 +31185,11 @@
 @kbd{Z F @key{RET} spam @key{RET}} defines the new command as
 @kbd{M-x calc-spam}, with no keyboard equivalent.
 
-The third prompt is for a function name.  The default is to use the same
-name as the command name but with @samp{calcFunc-} in place of
-@samp{calc-}.  This is the name you will use if you want to enter your
+The third prompt is for an algebraic function name.  The default is to
+use the same name as the command name but without the @samp{calc-}
+prefix.  (If this is of the form @samp{User-m}, the hyphen is removed so
+it won't be taken for a minus sign in algebraic formulas.)
+This is the name you will use if you want to enter your 
 new function in an algebraic formula.  Suppose we enter @kbd{yow @key{RET}}.
 Then the new function can be invoked by pushing two numbers on the
 stack and typing @kbd{z m} or @kbd{x spam}, or by entering the algebraic
@@ -31251,8 +31248,9 @@
 
 The @kbd{Z E} (@code{calc-user-define-edit}) command on a key that has
 been defined by a formula uses a variant of the @code{calc-edit} command
-to edit the defining formula.  Press @kbd{M-# M-#} to finish editing and
-store the new formula back in the definition, or @kbd{M-# x} to
+to edit the defining formula.  Press @kbd{C-c C-c} to finish editing and
+store the new formula back in the definition, or kill the buffer with
+@kbd{C-x k} to
 cancel the edit.  (The argument list and other properties of the
 definition are unchanged; to adjust the argument list, you can use
 @kbd{Z G} to grab the function onto the stack, edit with @kbd{`}, and
@@ -35726,9 +35724,9 @@
 
 @c 30
 @item
-Editing occurs in a separate buffer.  Press @kbd{M-# M-#} (or @kbd{C-c C-c},
-@key{LFD}, or in some cases @key{RET}) to finish the edit, or press
-@kbd{M-# x} to cancel the edit.  The @key{LFD} key prevents evaluation
+Editing occurs in a separate buffer.  Press @kbd{C-c C-c} (or 
+@key{LFD}, or in some cases @key{RET}) to finish the edit, or kill the
+buffer with @kbd{C-x k} to cancel the edit.  The @key{LFD} key prevents evaluation
 of the result of the edit.
 
 @c 31
--- a/man/custom.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/man/custom.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -1042,22 +1042,26 @@
 @end example
 
   Some ``variable names'' have special meanings in a local variables
-list: a value for the variable @code{mode} really sets the major mode,
-and a value for the variable @code{eval} is simply evaluated as an
-expression and the value is ignored.  @code{coding}, @code{unibyte},
-@code{mode} and @code{eval} are not real variables; setting variables
-named @code{coding}, @code{unibyte}, @code{mode} and @code{eval} in any
-other context has no special meaning.  @emph{If @code{mode} is used to
-set a major mode, it should be the first ``variable'' in the list.}
-Otherwise, the entries that precede it in the list of the local
-variables are likely to be ignored, since most modes kill all local
-variables as part of their initialization.
+list.  Specifying the ``variable'' @code{mode} really sets the major
+mode, while any value specified for the ``variable'' @code{eval} is
+simply evaluated as an expression (its value is ignored).  A value for
+@code{coding} specifies the coding system for character code
+conversion of this file, and a value of @code{t} for @code{unibyte}
+says to visit the file in a unibyte buffer.  These four ``variables''
+are not really variables; setting them in any other context has no
+special meaning.
 
-  You can use the @code{mode} ``variable'' to set minor modes as well as
-major modes; in fact, you can use it more than once, first to set the
-major mode and then to set minor modes which are specific to particular
-buffers.  But most minor modes should not be specified in the file in
-any fashion, because they represent user preferences.
+  @emph{If @code{mode} is used to set a major mode, it should be the
+first ``variable'' in the list.}  Otherwise, the entries that precede
+it will usually be ignored, since most modes kill all local variables
+as part of their initialization.
+
+  You can use the @code{mode} ``variable'' to set minor modes as well
+as the major modes; in fact, you can use it more than once, first to
+set the major mode and then to set minor modes which are specific to
+particular buffers.  But most minor modes should not be specified in
+the file at all, regardless of how, because they represent user
+preferences.
 
   For example, you may be tempted to try to turn on Auto Fill mode with
 a local variable list.  That is a mistake.  The choice of Auto Fill mode
--- a/man/dired.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/man/dired.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -700,26 +700,18 @@
 If the command string contains @samp{?} surrounded by whitespace, the
 current file name is substituted for @samp{?}.  You can use @samp{?}
 this way more than once in the command, and each occurrence is
-replaced.  For instance, here is how to uuencode each file, making the
-output file name by appending @samp{.uu} to the input file name:
-
-@example
-uuencode ? ? > ?.uu
-@end example
+replaced.
 @end itemize
 
 To iterate over the file names in a more complicated fashion, use an
-explicit shell loop.  For example, this shell command is another way
-to uuencode each file:
+explicit shell loop.  For example, here is how to uuencode each file,
+making the output file name by appending @samp{.uu} to the input file
+name:
 
 @example
 for file in * ; do uuencode "$file" "$file" >"$file".uu; done
 @end example
 
-@noindent
-This simple example doesn't require a shell loop (you can do it
-with @samp{?}, but it illustrates the technique.
-
 The working directory for the shell command is the top-level directory
 of the Dired buffer.
 
--- a/man/display.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/man/display.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -495,12 +495,14 @@
 @vindex scroll-preserve-screen-position
   Some users like the full-screen scroll commands to keep point at the
 same screen line.  To enable this behavior, set the variable
-@code{scroll-preserve-screen-position} to a non-@code{nil} value.  This
-mode is convenient for browsing through a file by scrolling by
-screenfuls; if you come back to the screen where you started, point goes
-back to the line where it started.  However, this mode is inconvenient
-when you move to the next screen in order to move point to the text
-there.
+@code{scroll-preserve-screen-position} to a non-@code{nil} value.  In
+this mode, when scrolling shifts point off the screen, or into the
+scrolling margins, Emacs moves point to keep the same vertical
+position within the window.  This mode is convenient for browsing
+through a file by scrolling by screenfuls; if you come back to the
+screen where you started, point goes back to the line where it
+started.  However, this mode is inconvenient when you move to the next
+screen in order to move point to the text there.
 
   Another way to do scrolling is with @kbd{C-l} with a numeric argument.
 @kbd{C-l} does not clear the screen when given an argument; it only scrolls
--- a/man/files.texi	Thu Jan 06 15:00:09 2005 +0000
+++ b/man/files.texi	Thu Jan 06 15:05:01 2005 +0000
@@ -464,12 +464,23 @@
 @xref{Interlocking,, Simultaneous Editing}.
 
 @vindex require-final-newline
-  If the value of the variable @code{require-final-newline} is @code{t},
-Emacs silently puts a newline at the end of any file that doesn't
-already end in one, every time a file is saved or written.  If the value
-is @code{nil}, Emacs leaves the end of the file unchanged; if it's
-neither @code{nil} nor @code{t}, Emacs asks you whether to add a
-newline.  The default is @code{nil}.
+  If the value of the variable @code{require-final-newline} is
+@code{t}, Emacs silently puts a newline at the end of any file that
+doesn't already end in one, every time a file is saved or written.  If
+the value is @code{visit}, Emacs adds a newline at the end of any file
+that doesn't have one, just after it visits the file.  (This marks the
+buffer as modified, and you can undo it.)  If the value is
+@code{visit-save}, that means to add newlines both on visiting and on
+saving.  If the value is @code{nil}, Emacs leaves the end of the file
+unchanged; if it's neither @code{nil} nor @code{t}, Emacs asks you
+whether to add a newline.  The default is @code{nil}.
+
+@vindex mode-require-final-newline
+  Many major modes are designed for specific kinds of files that are
+always supposed to end in newlines.  These major modes set the
+variable @code{require-final-newline} according to
+@code{mode-require-final-newline}.  By setting the latter variable,
+you can control how these modes handle final newlines.
 
 @menu
 * Backup::              How Emacs saves the old version of your file.
--- a/src/ChangeLog	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/ChangeLog	Thu Jan 06 15:05:01 2005 +0000
@@ -1,27 +1,131 @@
+2004-12-31  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xterm.c (handle_one_xevent): Clear area in expose event for GTK.
+
+2004-12-31  Richard M. Stallman  <rms@gnu.org>
+
+	* window.c (window_scroll_pixel_based): Only look at
+	Vscroll_preserve_screen_position if the old PT can't be kept.
+	(syms_of_window) <scroll-preserve-screen-position>: Doc fix.
+
+2004-12-30  Kim F. Storm  <storm@cua.dk>
+
+	* xdisp.c (get_line_height_property): New function extracted from
+	original calc_line_height_property.
+	(calc_line_height_property): Rework.  Handle t and (nil . ratio).
+	(x_produce_glyphs): Use them to handle line-height and
+	line-spacing according to new height spec.
+	(Qtotal): Remove.
+	(syms_of_xdisp): Remove intern and staticpro for Qtotal.
+
+2004-12-30  Kenichi Handa  <handa@m17n.org>
+
+	* fileio.c (Finsert_file_contents): Don't use
+	current_buffer->buffer_file_coding_system even if REPLACE is
+	non-nil.  Call Qafter_insert_file_set_coding with the second arg
+	VISIT.
+
+	* fontset.h (struct font_info): New members space_width and
+	average_width.
+
+	* frame.h (struct frame): New member space_width.
+	(FRAME_SPACE_WIDTH): New macro.
+
+	* xterm.h (struct x_display_info): New member Xatom_AVERAGE_WIDTH.
+
+	* xterm.c (x_new_font): Set FRAME_COLUMN_WIDTH to
+	fontp->average_width, not FONT_WIDTH.  Set FRAME_SPACE_WIDTH to
+	fontp-?space_width..
+	(x_load_font): Calculate fontp->space_width and
+	fontp->average_width.
+	(x_term_init): Initialize dpyinfo->Xatom_AVERAGE_WIDTH.
+
+	* xdisp.c (x_produce_glyphs): Calculate tab width by
+	FRAME_SPACE_WIDTH, not FRAME_COLUMN_WIDTH.
+
+2004-12-29  Sanghyuk Suh  <han9kin@mac.com>
+
+	* macterm.c (SelectionRange): Add Xcode position apple event struct.
+	(do_ae_open_documents): Handle Xcode-style file position open
+	events.
+
+2004-12-29  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* buffer.c (syms_of_buffer) <vertical-scroll-bar>: Correct typo.
+
+2004-12-29  Richard M. Stallman  <rms@gnu.org>
+
+	* buffer.c (syms_of_buffer) <vertical-scroll-bar>: Doc fix.
+
+2004-12-29  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* macfns.c (install_window_handler): Modify extern to return OSErr
+	value.
+	(mac_window): Handle return value of install_window_handler.
+
+	* macterm.c (reflect_byte): Remove function.
+	(mac_create_bitmap_from_bitmap_data): Don't call reflect_byte.
+	Lookup table instead.
+	(mac_do_font_lists): Simplify calculation of the longest
+	nonspecial string.
+	(init_mac_drag_n_drop): Remove function	and declaration.
+	(mac_initialize) [TARGET_API_MAC_CARBON]: Don't call
+	init_mac_drag_n_drop.
+	(mac_do_track_drag): New function and declaration.
+	(install_window_handler): Return OSErr value.
+	(install_window_handler) [TARGET_API_MAC_CARBON]: Register
+	handlers for tracking/receiving drag-and-drop items.
+	(do_ae_open_documents): Generate unibyte strings for filenames.
+	(mac_do_receive_drag) [TARGET_API_MAC_CARBON] : Likewise.  Reject
+	only non-filename items.  Set event modifiers.  Set return value.
+
+2004-12-28  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* coding.c (decode_coding): Fix previous change.
+
+2004-12-28  Richard M. Stallman  <rms@gnu.org>
+
+	* xdisp.c (back_to_previous_visible_line_start):
+	Don't call handle_display_prop.
+
+2004-12-28  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* coding.c (decode_coding_XXX, decode_composition_emacs_mule)
+	(decode_coding_emacs_mule, encode_coding_emacs_mule)
+	(decode_coding_iso2022, encode_designation_at_bol)
+	(encode_coding_iso2022, decode_coding_sjis_big5, decode_eol)
+	(decode_coding): Constify arguments and local vars.
+
 2004-12-27  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* xmenu.c (popup_get_selection): Only pop down dialogs
 	on C-g and Escape.
 	(popup_get_selection): Remove parameter down_on_keypress.
-	(create_and_show_popup_menu, create_and_show_dialog): Remove 
+	(create_and_show_popup_menu, create_and_show_dialog): Remove
 	parameter down_on_keypress to popup_get_selection.
 
 2004-12-27  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* dispextern.h: Change HAVE_CARBON to MAC_OS.
 	(struct glyph_string): Likewise.
+
 	* emacs.c (main) [MAC_OS8]: Call mac_term_init instead of
 	mac_initialize.
+
 	* fileio.c (Fnext_read_file_uses_dialog_p, Fread_file_name):
 	Change TARGET_API_MAC_CARBON to HAVE_CARBON.
+
 	* fns.c (vector): Change MAC_OSX to MAC_OS.
+
 	* frame.c (x_set_frame_parameters, x_report_frame_params)
 	(x_set_fullscreen): Remove #ifndef HAVE_CARBON.
 	(x_set_border_width, Vdefault_frame_scroll_bars): Change
 	HAVE_CARBON to MAC_OS.
+
 	* image.c [MAC_OS]: Include sys/stat.h.
 	[MAC_OS && !MAC_OSX]: Include sys/param.h, ImageCompression.h, and
 	QuickTimeComponents.h.
+
 	* mac.c [!MAC_OSX] (mac_wait_next_event): Add extern.
 	[!MAC_OSX] (select): Use mac_wait_next_event.
 	[!MAC_OSX] (run_mac_command): Change EXEC_SUFFIXES to
@@ -40,6 +144,7 @@
 	[MAC_OSX] (sys_select) [SELECT_USE_CFSOCKET]: Use CFSocket and
 	RunLoop for simultaneously monitoring two kinds of inputs, window
 	events and process outputs, without periodically polling.
+
 	* macfns.c (mac_initialized): Remove extern.
 	(stricmp): Put in #if 0.  All callers changed to use xstricmp in
 	xfaces.c.
@@ -65,11 +170,13 @@
 	TARGET_API_MAC_CARBON'.
 	(mac_frame_parm_handlers): Set handlers for Qfullscreen.
 	(syms_of_macfns) [MAC_OSX]: Initialize mac_in_use to 0.
+
 	* macgui.h [!MAC_OSX]: Don't include Controls.h.  Include
 	Windows.h.
 	(Window): Typedef to WindowPtr and move outside `#if
 	TARGET_API_MAC_CARBON'.
 	(XSizeHints): New struct.
+
 	* macterm.c (x_update_begin, x_update_end)
 	[TARGET_API_MAC_CARBON]: Disable screen updates during update of a
 	frame.
@@ -125,12 +232,15 @@
 	Add entries to x_display_list and x_display_name_list.
 	(x_delete_display): New function.
 	(mac_initialize): Don't call mac_initialize_display_info.
-	(syms_of_macterm) [!MAC_OSX]: Don't call Fprovide.	
+	(syms_of_macterm) [!MAC_OSX]: Don't call Fprovide.
+
 	* macterm.h (check_mac): Add extern.
 	(struct mac_output): New member size_hints.
 	(FRAME_SIZE_HINTS): New macro.
 	(mac_unload_font): Add extern.
+
 	* xdisp.c (expose_window, expose_frame): Remove kludges for Mac.
+
 	* xfaces.c (clear_font_table) [MAC_OS]: call mac_unload_font.
 
 2004-12-27  Richard M. Stallman  <rms@gnu.org>
@@ -148,7 +258,7 @@
 	(handle_single_display_spec): Renamed from handle_single_display_prop.
 	Rewritten to be easier to understand.
 
-	* Change in load-history format.  Functions now get (defun . NAME),
+	Change in load-history format.  Functions now get (defun . NAME),
 	and variables get just NAME.
 
 	* data.c (Fdefalias): Use (defun . FN_NAME) in LOADHIST_ATTACH.
@@ -287,7 +397,7 @@
 
 	* sysdep.c (select_alarm): Call SIGNAL_THREAD_CHECK.
 
-	* process.c (send_process_trap, sigchld_handler): Call 
+	* process.c (send_process_trap, sigchld_handler): Call
 	SIGNAL_THREAD_CHECK.
 
 	* data.c (arith_error): Call SIGNAL_THREAD_CHECK.
--- a/src/buffer.c	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/buffer.c	Thu Jan 06 15:05:01 2005 +0000
@@ -5648,7 +5648,9 @@
   DEFVAR_PER_BUFFER ("vertical-scroll-bar", &current_buffer->vertical_scroll_bar_type,
 		     Qnil,
 		     doc: /* *Position of this buffer's vertical scroll bar.
-The value takes effect whenever you display this buffer in a window.
+The value takes effect whenever you tell a window to display this buffer;
+for instance, with `set-window-buffer' or when `display-buffer' displays it.
+
 A value of `left' or `right' means put the vertical scroll bar at that side
 of the window; a value of nil means don't show any vertical scroll bars.
 A value of t (the default) means do whatever the window's frame specifies.  */);
--- a/src/coding.c	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/coding.c	Thu Jan 06 15:05:01 2005 +0000
@@ -147,7 +147,8 @@
 static void
 decode_coding_XXX (coding, source, destination, src_bytes, dst_bytes)
      struct coding_system *coding;
-     unsigned char *source, *destination;
+     const unsigned char *source;
+     unsigned char *destination;
      int src_bytes, dst_bytes;
 {
   ...
@@ -796,12 +797,13 @@
 decode_composition_emacs_mule (coding, src, src_end,
 			       destination, dst_end, dst_bytes)
      struct coding_system *coding;
-     unsigned char *src, *src_end, **destination, *dst_end;
+     const unsigned char *src, *src_end;
+     unsigned char **destination, *dst_end;
      int dst_bytes;
 {
   unsigned char *dst = *destination;
   int method, data_len, nchars;
-  unsigned char *src_base = src++;
+  const unsigned char *src_base = src++;
   /* Store components of composition.  */
   int component[COMPOSITION_DATA_MAX_BUNCH_LENGTH];
   int ncomponent;
@@ -942,23 +944,25 @@
 static void
 decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes)
      struct coding_system *coding;
-     unsigned char *source, *destination;
+     const unsigned char *source;
+     unsigned char *destination;
      int src_bytes, dst_bytes;
 {
-  unsigned char *src = source;
-  unsigned char *src_end = source + src_bytes;
+  const unsigned char *src = source;
+  const unsigned char *src_end = source + src_bytes;
   unsigned char *dst = destination;
   unsigned char *dst_end = destination + dst_bytes;
   /* SRC_BASE remembers the start position in source in each loop.
      The loop will be exited when there's not enough source code, or
      when there's not enough destination area to produce a
      character.  */
-  unsigned char *src_base;
+  const unsigned char *src_base;
 
   coding->produced_char = 0;
   while ((src_base = src) < src_end)
     {
-      unsigned char tmp[MAX_MULTIBYTE_LENGTH], *p;
+      unsigned char tmp[MAX_MULTIBYTE_LENGTH];
+      const unsigned char *p;
       int bytes;
 
       if (*src == '\r')
@@ -1112,14 +1116,15 @@
 static void
 encode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes)
      struct coding_system *coding;
-     unsigned char *source, *destination;
+     const unsigned char *source;
+     unsigned char *destination;
      int src_bytes, dst_bytes;
 {
-  unsigned char *src = source;
-  unsigned char *src_end = source + src_bytes;
+  const unsigned char *src = source;
+  const unsigned char *src_end = source + src_bytes;
   unsigned char *dst = destination;
   unsigned char *dst_end = destination + dst_bytes;
-  unsigned char *src_base;
+  const unsigned char *src_base;
   int c;
   int char_offset;
   int *data;
@@ -1806,11 +1811,12 @@
 static void
 decode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes)
      struct coding_system *coding;
-     unsigned char *source, *destination;
+     const unsigned char *source;
+     unsigned char *destination;
      int src_bytes, dst_bytes;
 {
-  unsigned char *src = source;
-  unsigned char *src_end = source + src_bytes;
+  const unsigned char *src = source;
+  const unsigned char *src_end = source + src_bytes;
   unsigned char *dst = destination;
   unsigned char *dst_end = destination + dst_bytes;
   /* Charsets invoked to graphic plane 0 and 1 respectively.  */
@@ -1821,7 +1827,7 @@
      (within macro ONE_MORE_BYTE), or when there's not enough
      destination area to produce a character (within macro
      EMIT_CHAR).  */
-  unsigned char *src_base;
+  const unsigned char *src_base;
   int c, charset;
   Lisp_Object translation_table;
   Lisp_Object safe_chars;
@@ -2592,7 +2598,8 @@
 encode_designation_at_bol (coding, translation_table, src, src_end, dst)
      struct coding_system *coding;
      Lisp_Object translation_table;
-     unsigned char *src, *src_end, *dst;
+     const unsigned char *src, *src_end;
+     unsigned char *dst;
 {
   int charset, c, found = 0, reg;
   /* Table of charsets to be designated to each graphic register.  */
@@ -2633,11 +2640,12 @@
 static void
 encode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes)
      struct coding_system *coding;
-     unsigned char *source, *destination;
+     const unsigned char *source;
+     unsigned char *destination;
      int src_bytes, dst_bytes;
 {
-  unsigned char *src = source;
-  unsigned char *src_end = source + src_bytes;
+  const unsigned char *src = source;
+  const unsigned char *src_end = source + src_bytes;
   unsigned char *dst = destination;
   unsigned char *dst_end = destination + dst_bytes;
   /* Since the maximum bytes produced by each loop is 20, we subtract 19
@@ -2649,7 +2657,7 @@
      analyze multi-byte codes (within macro ONE_MORE_CHAR), or when
      there's not enough destination area to produce encoded codes
      (within macro EMIT_BYTES).  */
-  unsigned char *src_base;
+  const unsigned char *src_base;
   int c;
   Lisp_Object translation_table;
   Lisp_Object safe_chars;
@@ -3043,12 +3051,13 @@
 decode_coding_sjis_big5 (coding, source, destination,
 			 src_bytes, dst_bytes, sjis_p)
      struct coding_system *coding;
-     unsigned char *source, *destination;
+     const unsigned char *source;
+     unsigned char  *destination;
      int src_bytes, dst_bytes;
      int sjis_p;
 {
-  unsigned char *src = source;
-  unsigned char *src_end = source + src_bytes;
+  const unsigned char *src = source;
+  const unsigned char *src_end = source + src_bytes;
   unsigned char *dst = destination;
   unsigned char *dst_end = destination + dst_bytes;
   /* SRC_BASE remembers the start position in source in each loop.
@@ -3056,7 +3065,7 @@
      (within macro ONE_MORE_BYTE), or when there's not enough
      destination area to produce a character (within macro
      EMIT_CHAR).  */
-  unsigned char *src_base;
+  const unsigned char *src_base;
   Lisp_Object translation_table;
 
   if (NILP (Venable_character_translation))
@@ -3316,12 +3325,13 @@
 static void
 decode_eol (coding, source, destination, src_bytes, dst_bytes)
      struct coding_system *coding;
-     unsigned char *source, *destination;
+     const unsigned char *source;
+     unsigned char *destination;
      int src_bytes, dst_bytes;
 {
-  unsigned char *src = source;
+  const unsigned char *src = source;
   unsigned char *dst = destination;
-  unsigned char *src_end = src + src_bytes;
+  const unsigned char *src_end = src + src_bytes;
   unsigned char *dst_end = dst + dst_bytes;
   Lisp_Object translation_table;
   /* SRC_BASE remembers the start position in source in each loop.
@@ -3329,7 +3339,7 @@
      (within macro ONE_MORE_BYTE), or when there's not enough
      destination area to produce a character (within macro
      EMIT_CHAR).  */
-  unsigned char *src_base;
+  const unsigned char *src_base;
   int c;
 
   translation_table = Qnil;
--- a/src/fileio.c	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/fileio.c	Thu Jan 06 15:05:01 2005 +0000
@@ -3863,10 +3863,6 @@
 
       if (!NILP (Vcoding_system_for_read))
 	val = Vcoding_system_for_read;
-      else if (! NILP (replace))
-	/* In REPLACE mode, we can use the same coding system
-	   that was used to visit the file.  */
-	val = current_buffer->buffer_file_coding_system;
       else
 	{
 	  /* Don't try looking inside a file for a coding system
@@ -4645,7 +4641,8 @@
 
   if (! NILP (Ffboundp (Qafter_insert_file_set_coding)))
     {
-      insval = call1 (Qafter_insert_file_set_coding, make_number (inserted));
+      insval = call2 (Qafter_insert_file_set_coding, make_number (inserted),
+		      visit);
       if (! NILP (insval))
 	{
 	  CHECK_NUMBER (insval);
--- a/src/fontset.h	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/fontset.h	Thu Jan 06 15:05:01 2005 +0000
@@ -56,6 +56,12 @@
      (font->ascent + font->descent).  */
   int height;
 
+  /* Width of the space glyph of the font.  */
+  int space_width;
+
+  /* Average width of glyphs in the font.  */
+  int average_width;
+
   /* 1 iff `vertical-centering-font-regexp' matches this font name.
      In this case, we render characters at vartical center positions
      of lines.  */
--- a/src/frame.h	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/frame.h	Thu Jan 06 15:05:01 2005 +0000
@@ -254,6 +254,9 @@
   /* Canonical X unit.  Width of default font, in pixels.  */
   int column_width;
 
+  /* Widht of space glyph of default font, in pixels.  */
+  int space_width;
+
   /* Canonical Y unit.  Height of a line, in pixels.  */
   int line_height;
 
@@ -822,10 +825,14 @@
 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
 
 /* Canonical x-unit on frame F. 
-   This value currently equals the width of the default font of F.  */
+   This value currently equals the average width of the default font of F.  */
 
 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
 
+/* Space glyph width of the default font of frame F.  */
+
+#define FRAME_SPACE_WIDTH(F) ((F)->space_width)
+
 
 /* Pixel width of areas used to display truncation marks, continuation
    marks, overlay arrows.  This is 0 for terminal frames.  */
--- a/src/macfns.c	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/macfns.c	Thu Jan 06 15:05:01 2005 +0000
@@ -158,7 +158,7 @@
 
 extern Lisp_Object Vwindow_system_version;
 
-#if 0 /* Use xstricmp instead. */
+#if 0 /* Use xstricmp instead.  */
 /* compare two strings ignoring case */
 
 static int
@@ -2261,7 +2261,7 @@
 
 /* Create and set up the Mac window for frame F.  */
 
-extern install_window_handler (WindowPtr);
+extern OSErr install_window_handler (WindowPtr);
 
 static void
 mac_window (f)
@@ -2282,7 +2282,11 @@
   if (FRAME_MAC_WINDOW (f))
     {
       SetWRefCon (FRAME_MAC_WINDOW (f), (long) f->output_data.mac);
-      install_window_handler (FRAME_MAC_WINDOW (f));
+      if (install_window_handler (FRAME_MAC_WINDOW (f)) != noErr)
+	{
+	  DisposeWindow (FRAME_MAC_WINDOW (f));
+	  FRAME_MAC_WINDOW (f) = NULL;
+	}
     }
 #else
   FRAME_MAC_WINDOW (f)
--- a/src/macterm.c	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/macterm.c	Thu Jan 06 15:05:01 2005 +0000
@@ -511,23 +511,6 @@
 }
 
 
-/* XBM bits seem to be backward within bytes compared with how
-   Mac does things.  */
-static unsigned char
-reflect_byte (orig)
-     unsigned char orig;
-{
-  int i;
-  unsigned char reflected = 0x00;
-  for (i = 0; i < 8; i++)
-    {
-      if (orig & (0x01 << i))
-	reflected |= 0x80 >> i;
-    }
-  return reflected;
-}
-
-
 /* Mac replacement for XCreateBitmapFromBitmapData.  */
 
 static void
@@ -536,6 +519,11 @@
      char *bits;
      int w, h;
 {
+  static unsigned char swap_nibble[16]
+    = { 0x0, 0x8, 0x4, 0xc,    /* 0000 1000 0100 1100 */
+	0x2, 0xa, 0x6, 0xe,    /* 0010 1010 0110 1110 */
+	0x1, 0x9, 0x5, 0xd,    /* 0001 1001 0101 1101 */
+	0x3, 0xb, 0x7, 0xf };  /* 0011 1011 0111 1111 */
   int i, j, w1;
   char *p;
 
@@ -547,7 +535,12 @@
     {
       p = bitmap->baseAddr + i * bitmap->rowBytes;
       for (j = 0; j < w1; j++)
-        *p++ = reflect_byte (*bits++);
+	{
+	  /* Bitswap XBM bytes to match how Mac does things.  */
+	  unsigned char c = *bits++;
+	  *p++ = (unsigned char)((swap_nibble[c & 0xf] << 4)
+				 | (swap_nibble[(c>>4) & 0xf]));;
+	}
     }
 
   SetRect (&(bitmap->bounds), 0, 0, w, h);
@@ -6256,7 +6249,7 @@
   char *ptr;
   int scl_val[XLFD_SCL_LAST], *field, *val;
   char *longest_start, *cur_start, *nonspecial;
-  int longest_len, cur_len, exact;
+  int longest_len, exact;
 
   if (font_name_table == NULL)  /* Initialize when first used.  */
     init_font_name_table ();
@@ -6318,7 +6311,7 @@
   *ptr++ = '^';
 
   longest_start = cur_start = ptr;
-  longest_len = cur_len = 0;
+  longest_len = 0;
   exact = 1;
 
   /* Turn pattern into a regexp and do a regexp match.  Also find the
@@ -6327,12 +6320,11 @@
     {
       if (*pattern == '?' || *pattern == '*')
 	{
-	  if (cur_len > longest_len)
+	  if (ptr - cur_start > longest_len)
 	    {
 	      longest_start = cur_start;
-	      longest_len = cur_len;
+	      longest_len = ptr - cur_start;
 	    }
-	  cur_len = 0;
 	  exact = 0;
 
 	  if (*pattern == '?')
@@ -6342,21 +6334,16 @@
 	      *ptr++ = '.';
 	      *ptr++ = '*';
 	    }
+	  cur_start = ptr;
 	}
       else
-	{
-	  if (cur_len == 0)
-	    cur_start = ptr;
-	  cur_len++;
-
-	  *ptr++ = tolower (*pattern);
-	}
-    }
-
-  if (cur_len > longest_len)
+	*ptr++ = tolower (*pattern);
+    }
+
+  if (ptr - cur_start > longest_len)
     {
       longest_start = cur_start;
-      longest_len = cur_len;
+      longest_len = ptr - cur_start;
     }
 
   *ptr = '$';
@@ -7086,7 +7073,7 @@
 
 #if TARGET_API_MAC_CARBON
 /* Drag and Drop */
-static OSErr init_mac_drag_n_drop ();
+static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference);
 static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);
 #endif
 
@@ -7098,7 +7085,7 @@
 static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
 						EventRef, void *);
 #endif
-void install_window_handler (WindowPtr);
+OSErr install_window_handler (WindowPtr);
 
 extern void init_emacs_passwd_dir ();
 extern int emacs_main (int, char **, char **);
@@ -7659,16 +7646,6 @@
   x_real_positions (f, &f->left_pos, &f->top_pos);
 }
 
-#if TARGET_API_MAC_CARBON
-/* Initialize Drag And Drop to allow files to be dropped onto emacs frames */
-static OSErr
-init_mac_drag_n_drop ()
-{
-  OSErr result = InstallReceiveHandler (mac_do_receive_drag, 0L, NULL);
-  return result;
-}
-#endif
-
 /* Intialize AppleEvent dispatcher table for the required events.  */
 void
 init_required_apple_events ()
@@ -7909,10 +7886,11 @@
 #endif	/* USE_CARBON_EVENTS */
 
 
-void
+OSErr
 install_window_handler (window)
      WindowPtr window;
 {
+  OSErr err = noErr;
 #if USE_CARBON_EVENTS
   EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowBoundsChanging}};
   static EventHandlerUPP handle_window_event_UPP = NULL;
@@ -7920,9 +7898,17 @@
   if (handle_window_event_UPP == NULL)
     handle_window_event_UPP = NewEventHandlerUPP (mac_handle_window_event);
 
-  InstallWindowEventHandler (window, handle_window_event_UPP,
-			     GetEventTypeCount (specs), specs, NULL, NULL);
-#endif
+  err = InstallWindowEventHandler (window, handle_window_event_UPP,
+				   GetEventTypeCount (specs), specs,
+				   NULL, NULL);
+#endif
+#if TARGET_API_MAC_CARBON
+  if (err == noErr)
+    err = InstallTrackingHandler (mac_do_track_drag, window, NULL);
+  if (err == noErr)
+    err = InstallReceiveHandler (mac_do_receive_drag, window, NULL);
+#endif
+  return err;
 }
 
 
@@ -7942,6 +7928,17 @@
 /* Called when we receive an AppleEvent with an ID of
    "kAEOpenDocuments".  This routine gets the direct parameter,
    extracts the FSSpecs in it, and puts their names on a list.  */
+#pragma options align=mac68k
+typedef struct SelectionRange {
+  short unused1; // 0 (not used)
+  short lineNum; // line to select (<0 to specify range)
+  long startRange; // start of selection range (if line < 0)
+  long endRange; // end of selection range (if line < 0)
+  long unused2; // 0 (not used)
+  long theDate; // modification date/time
+} SelectionRange;
+#pragma options align=reset
+
 static pascal OSErr
 do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
 {
@@ -7950,11 +7947,19 @@
   AEKeyword keyword;
   DescType actual_type;
   Size actual_size;
+  SelectionRange position;
 
   err = AEGetParamDesc (message, keyDirectObject, typeAEList, &the_desc);
   if (err != noErr)
     goto descriptor_error_exit;
 
+  err = AEGetParamPtr (message, keyAEPosition, typeChar, &actual_type, &position, sizeof(SelectionRange), &actual_size);
+  if (err == noErr)
+    drag_and_drop_file_list = Fcons (list3 (make_number (position.lineNum + 1),
+					    make_number (position.startRange + 1),
+					    make_number (position.endRange + 1)),
+				     drag_and_drop_file_list);
+
   /* Check to see that we got all of the required parameters from the
      event descriptor.  For an 'odoc' event this should just be the
      file list.  */
@@ -8004,8 +8009,11 @@
 					fs.name) &&
 		mac_to_posix_pathname (path_name, unix_path_name, 255))
 #endif
-	      drag_and_drop_file_list = Fcons (build_string (unix_path_name),
-					       drag_and_drop_file_list);
+	      /* x-dnd functions expect undecoded filenames.  */
+	      drag_and_drop_file_list =
+		Fcons (make_unibyte_string (unix_path_name,
+					    strlen (unix_path_name)),
+		       drag_and_drop_file_list);
 	  }
       }
   }
@@ -8022,6 +8030,67 @@
 
 #if TARGET_API_MAC_CARBON
 static pascal OSErr
+mac_do_track_drag (DragTrackingMessage message, WindowPtr window,
+		   void *handlerRefCon, DragReference theDrag)
+{
+  static int can_accept;
+  short items;
+  short index;
+  ItemReference theItem;
+  FlavorFlags theFlags;
+  OSErr result;
+
+  switch (message)
+    {
+    case kDragTrackingEnterHandler:
+      CountDragItems (theDrag, &items);
+      can_accept = 1;
+      for (index = 1; index <= items; index++)
+	{
+	  GetDragItemReferenceNumber (theDrag, index, &theItem);
+	  result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags);
+	  if (result != noErr)
+	    {
+	      can_accept = 0;
+	      break;
+	    }
+	}
+      break;
+
+    case kDragTrackingEnterWindow:
+      if (can_accept)
+	{
+	  RgnHandle hilite_rgn = NewRgn ();
+	  Rect r;
+
+	  GetWindowPortBounds (window, &r);
+	  OffsetRect (&r, -r.left, -r.top);
+	  RectRgn (hilite_rgn, &r);
+	  ShowDragHilite (theDrag, hilite_rgn, true);
+	  DisposeRgn (hilite_rgn);
+	  SetThemeCursor (kThemeCopyArrowCursor);
+	}
+      break;
+
+    case kDragTrackingInWindow:
+      break;
+
+    case kDragTrackingLeaveWindow:
+      if (can_accept)
+	{
+	  HideDragHilite (theDrag);
+	  SetThemeCursor (kThemeArrowCursor);
+	}
+      break;
+
+    case kDragTrackingLeaveHandler:
+      break;
+    }
+
+  return noErr;
+}
+
+static pascal OSErr
 mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
 		     DragReference theDrag)
 {
@@ -8062,11 +8131,14 @@
 				      data.fileSpec.parID, data.fileSpec.name) &&
 	      mac_to_posix_pathname (path_name, unix_path_name, 255))
 #endif
-            drag_and_drop_file_list = Fcons (build_string (unix_path_name),
-					     drag_and_drop_file_list);
+	    /* x-dnd functions expect undecoded filenames.  */
+            drag_and_drop_file_list =
+	      Fcons (make_unibyte_string (unix_path_name,
+					  strlen (unix_path_name)),
+		     drag_and_drop_file_list);
 	}
       else
-	return;
+	continue;
     }
   /* If there are items in the list, construct an event and post it to
      the queue like an interrupt using kbd_buffer_store_event.  */
@@ -8075,12 +8147,14 @@
       struct input_event event;
       Lisp_Object frame;
       struct frame *f = mac_window_to_frame (window);
-      SetPortWindowPort (window);
+      SInt16 modifiers;
+
       GlobalToLocal (&mouse);
+      GetDragModifiers (theDrag, NULL, NULL, &modifiers);
 
       event.kind = DRAG_N_DROP_EVENT;
       event.code = 0;
-      event.modifiers = 0;
+      event.modifiers = mac_to_emacs_modifiers (modifiers);
       event.timestamp = TickCount () * (1000 / 60);
       XSETINT (event.x, mouse.h);
       XSETINT (event.y, mouse.v);
@@ -8095,7 +8169,11 @@
 	GetCurrentProcess (&psn);
 	SetFrontProcess (&psn);
       }
-    }
+
+      return noErr;
+    }
+  else
+    return dragNotAcceptedErr;
 }
 #endif
 
@@ -9581,8 +9659,6 @@
 #if TARGET_API_MAC_CARBON
   init_required_apple_events ();
 
-  init_mac_drag_n_drop ();
-
 #if USE_CARBON_EVENTS
   init_service_handler ();
 
--- a/src/window.c	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/window.c	Thu Jan 06 15:05:01 2005 +0000
@@ -4673,30 +4673,32 @@
      not including the height of the header line if any.  */
   it.current_y = it.vpos = 0;
 
-  /* Preserve the screen position if we should.  */
-  if (preserve_y >= 0)
-    {
-      /* If we have a header line, take account of it.  */
-      if (WINDOW_WANTS_HEADER_LINE_P (w))
-	preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
-
-      move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
-      SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
-    }
-  else
+  /* Move PT out of scroll margins.
+     This code wants current_y to be zero at the window start position
+     even if there is a header line.  */
+  this_scroll_margin = max (0, scroll_margin);
+  this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4);
+  this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
+
+  if (n > 0)
     {
-      /* Move PT out of scroll margins.
-	 This code wants current_y to be zero at the window start position
-	 even if there is a header line.  */
-      this_scroll_margin = max (0, scroll_margin);
-      this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4);
-      this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
-
-      if (n > 0)
+      /* We moved the window start towards ZV, so PT may be now
+	 in the scroll margin at the top.  */
+      move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
+      if (IT_CHARPOS (it) == PT && it.current_y >= this_scroll_margin)
+	/* We found PT at a legitimate height.  Leave it alone.  */
+	;
+      else if (preserve_y >= 0)
 	{
-	  /* We moved the window start towards ZV, so PT may be now
-	     in the scroll margin at the top.  */
-	  move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
+	  /* If we have a header line, take account of it.  */
+	  if (WINDOW_WANTS_HEADER_LINE_P (w))
+	    preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
+
+	  move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
+	  SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
+	}
+      else
+	{
 	  while (it.current_y < this_scroll_margin)
 	    {
 	      int prev = it.current_y;
@@ -4706,22 +4708,44 @@
 	    }
 	  SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
 	}
-      else if (n < 0)
+    }
+  else if (n < 0)
+    {
+      int charpos, bytepos;
+
+      /* Save our position, for the preserve_y case.  */
+      charpos = IT_CHARPOS (it);
+      bytepos = IT_BYTEPOS (it);
+
+      /* We moved the window start towards BEGV, so PT may be now
+	 in the scroll margin at the bottom.  */
+      move_it_to (&it, PT, -1,
+		  it.last_visible_y - this_scroll_margin - 1, -1,
+		  MOVE_TO_POS | MOVE_TO_Y);
+
+      if (IT_CHARPOS (it) == PT)
+	/* We found PT before we found the display margin, so PT is ok.  */
+	;
+      else if (preserve_y >= 0)
 	{
-	  int charpos, bytepos;
-
-	  /* We moved the window start towards BEGV, so PT may be now
-	     in the scroll margin at the bottom.  */
-	  move_it_to (&it, PT, -1,
-		      it.last_visible_y - this_scroll_margin - 1, -1,
-		      MOVE_TO_POS | MOVE_TO_Y);
-
+	  SET_TEXT_POS_FROM_MARKER (start, w->start);
+	  start_display (&it, w, start);
+	  /* If we have a header line, take account of it.  */
+	  if (WINDOW_WANTS_HEADER_LINE_P (w))
+	    preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
+
+	  move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
+	  SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
+	}
+      else
+	{
 	  /* Save our position, in case it's correct.  */
 	  charpos = IT_CHARPOS (it);
 	  bytepos = IT_BYTEPOS (it);
 
 	  /* See if point is on a partially visible line at the end.  */
 	  move_it_by_lines (&it, 1, 1);
+
 	  if (it.current_y > it.last_visible_y)
 	    /* The last line was only partially visible, so back up two
 	       lines to make sure we're on a fully visible line.  */
@@ -6755,7 +6779,9 @@
 
   DEFVAR_LISP ("scroll-preserve-screen-position",
 	       &Vscroll_preserve_screen_position,
-	       doc: /* *Non-nil means scroll commands move point to keep its screen line unchanged.  */);
+	       doc: /* *Non-nil means scroll commands move point to keep its screen line unchanged.
+This is only when it is impossible to keep point fixed and still
+scroll as specified.  */);
   Vscroll_preserve_screen_position = Qnil;
 
   DEFVAR_LISP ("window-configuration-change-hook",
--- a/src/xdisp.c	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/xdisp.c	Thu Jan 06 15:05:01 2005 +0000
@@ -308,7 +308,7 @@
 Lisp_Object Qslice;
 Lisp_Object Qcenter;
 Lisp_Object Qmargin, Qpointer;
-Lisp_Object Qline_height, Qtotal;
+Lisp_Object Qline_height;
 extern Lisp_Object Qheight;
 extern Lisp_Object QCwidth, QCheight, QCascent;
 extern Lisp_Object Qscroll_bar;
@@ -3286,7 +3286,7 @@
 {
   Lisp_Object prop, object;
   struct text_pos *position;
-  /* Nonzero if some property replaces the display of the text itself.  */ 
+  /* Nonzero if some property replaces the display of the text itself.  */
   int display_replaced_p = 0;
 
   if (STRINGP (it->string))
@@ -3451,7 +3451,7 @@
     {
       if (!FRAME_WINDOW_P (it->f))
 	return 0;
-      
+
       it->font_height = XCAR (XCDR (spec));
       if (!NILP (it->font_height))
 	{
@@ -4594,6 +4594,9 @@
 	    visible_p = 0;
 	}
 
+#if 0
+      /* Commenting this out fixes the bug described in
+	 http://www.math.ku.dk/~larsh/emacs/emacs-loops-on-large-images/test-case.txt.  */
       if (visible_p)
 	{
 	  struct it it2 = *it;
@@ -4601,6 +4604,7 @@
 	  if (handle_display_prop (&it2) == HANDLED_RETURN)
 	    visible_p = 0;
 	}
+#endif
 
       /* Back one more newline if the current one is invisible.  */
       if (!visible_p)
@@ -18788,24 +18792,16 @@
   take_vertical_position_into_account (it);
 }
 
-/* Calculate line-height and line-spacing properties.
-   An integer value specifies explicit pixel value.
-   A float value specifies relative value to current face height.
-   A cons (float . face-name) specifies relative value to
-   height of specified face font.
-
-   Returns height in pixels, or nil.  */
+/* Get line-height and line-spacing property at point.
+   If line-height has format (HEIGHT TOTAL), return TOTAL
+   in TOTAL_HEIGHT.  */
 
 static Lisp_Object
-calc_line_height_property (it, prop, font, boff, total)
+get_line_height_property (it, prop)
      struct it *it;
      Lisp_Object prop;
-     XFontStruct *font;
-     int boff, *total;
 {
   Lisp_Object position, val;
-  Lisp_Object face_name = Qnil;
-  int ascent, descent, height, override;
 
   if (STRINGP (it->object))
     position = make_number (IT_STRING_CHARPOS (*it));
@@ -18814,32 +18810,43 @@
   else
     return Qnil;
 
-  val = Fget_char_property (position, prop, it->object);
-
-  if (NILP (val))
-    return val;
-
-  if (total && CONSP (val) && EQ (XCAR (val), Qtotal))
-    {
-      *total = 1;
-      val = XCDR (val);
-    }
-
-  if (INTEGERP (val))
+  return Fget_char_property (position, prop, it->object);
+}
+
+/* Calculate line-height and line-spacing properties.
+   An integer value specifies explicit pixel value.
+   A float value specifies relative value to current face height.
+   A cons (float . face-name) specifies relative value to
+   height of specified face font.
+
+   Returns height in pixels, or nil.  */
+
+
+static Lisp_Object
+calc_line_height_property (it, val, font, boff, override)
+     struct it *it;
+     Lisp_Object val;
+     XFontStruct *font;
+     int boff, override;
+{
+  Lisp_Object face_name = Qnil;
+  int ascent, descent, height;
+
+  if (NILP (val) || INTEGERP (val) || (override && EQ (val, Qt)))
     return val;
 
   if (CONSP (val))
     {
-      face_name = XCDR (val);
-      val = XCAR (val);
-    }
-  else if (SYMBOLP (val))
-    {
-      face_name = val;
-      val = Qnil;
-    }
-
-  override = EQ (prop, Qline_height);
+      face_name = XCAR (val);
+      val = XCDR (val);
+      if (!NUMBERP (val))
+	val = make_number (1);
+      if (NILP (face_name))
+	{
+	  height = it->ascent + it->descent;
+	  goto scale;
+	}
+    }
 
   if (NILP (face_name))
     {
@@ -18882,6 +18889,8 @@
     }
 
   height = ascent + descent;
+
+ scale:
   if (FLOATP (val))
     height = (int)(XFLOAT_DATA (val) * height);
   else if (INTEGERP (val))
@@ -19094,12 +19103,22 @@
 	     increase that height */
 
 	  Lisp_Object height;
+	  Lisp_Object total_height = Qnil;
 
 	  it->override_ascent = -1;
 	  it->pixel_width = 0;
 	  it->nglyphs = 0;
 
-	  height = calc_line_height_property(it, Qline_height, font, boff, 0);
+	  height = get_line_height_property(it, Qline_height);
+	  /* Split (line-height total-height) list */
+	  if (CONSP (height)
+	      && CONSP (XCDR (height))
+	      && NILP (XCDR (XCDR (height))))
+	    {
+	      total_height = XCAR (XCDR (height));
+	      height = XCAR (height);
+	    }
+	  height = calc_line_height_property(it, height, font, boff, 1);
 
 	  if (it->override_ascent >= 0)
 	    {
@@ -19113,7 +19132,7 @@
 	      it->descent = FONT_DESCENT (font) - boff;
 	    }
 
-	  if (EQ (height, make_number(0)))
+	  if (EQ (height, Qt))
 	    {
 	      if (it->descent > it->max_descent)
 		{
@@ -19149,25 +19168,31 @@
 		  && XINT (height) > it->ascent + it->descent)
 		it->ascent = XINT (height) - it->descent;
 
-	      spacing = calc_line_height_property(it, Qline_spacing, font, boff, &total);
+	      if (!NILP (total_height))
+		spacing = calc_line_height_property(it, total_height, font, boff, 0);
+	      else
+		{
+		  spacing = get_line_height_property(it, Qline_spacing);
+		  spacing = calc_line_height_property(it, spacing, font, boff, 0);
+		}
 	      if (INTEGERP (spacing))
 		{
 		  extra_line_spacing = XINT (spacing);
-		  if (total)
+		  if (!NILP (total_height))
 		    extra_line_spacing -= (it->phys_ascent + it->phys_descent);
 		}
 	    }
 	}
       else if (it->char_to_display == '\t')
 	{
-	  int tab_width = it->tab_width * FRAME_COLUMN_WIDTH (it->f);
+	  int tab_width = it->tab_width * FRAME_SPACE_WIDTH (it->f);
 	  int x = it->current_x + it->continuation_lines_width;
 	  int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
 
 	  /* If the distance from the current position to the next tab
-	     stop is less than a canonical character width, use the
+	     stop is less than a space character width, use the
 	     tab stop after that.  */
-	  if (next_tab_x - x < FRAME_COLUMN_WIDTH (it->f))
+	  if (next_tab_x - x < FRAME_SPACE_WIDTH (it->f))
 	    next_tab_x += tab_width;
 
 	  it->pixel_width = next_tab_x - x;
@@ -22172,8 +22197,6 @@
   staticpro (&Qcenter);
   Qline_height = intern ("line-height");
   staticpro (&Qline_height);
-  Qtotal = intern ("total");
-  staticpro (&Qtotal);
   QCalign_to = intern (":align-to");
   staticpro (&QCalign_to);
   QCrelative_width = intern (":relative-width");
--- a/src/xterm.c	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/xterm.c	Thu Jan 06 15:05:01 2005 +0000
@@ -6003,6 +6003,14 @@
         {
           x_check_fullscreen (f);
 
+#ifdef USE_GTK
+          /* This seems to be needed for GTK 2.6.  */
+          x_clear_area (event.xexpose.display,
+                        event.xexpose.window,
+                        event.xexpose.x, event.xexpose.y,
+                        event.xexpose.width, event.xexpose.height,
+                        FALSE);
+#endif
           if (f->async_visible == 0)
             {
               f->async_visible = 1;
@@ -7845,7 +7853,8 @@
   FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
   FRAME_FONTSET (f) = -1;
 
-  FRAME_COLUMN_WIDTH (f) = FONT_WIDTH (FRAME_FONT (f));
+  FRAME_COLUMN_WIDTH (f) = fontp->average_width;
+  FRAME_SPACE_WIDTH (f) = fontp->space_width;
   FRAME_LINE_HEIGHT (f) = FONT_HEIGHT (FRAME_FONT (f));
 
   compute_fringe_widths (f, 1);
@@ -9790,6 +9799,43 @@
     fontp->name = (char *) xmalloc (strlen (fontname) + 1);
     bcopy (fontname, fontp->name, strlen (fontname) + 1);
 
+    if (font->min_bounds.width == font->max_bounds.width)
+      {
+	/* Fixed width font.  */
+	fontp->average_width = fontp->space_width = font->min_bounds.width;
+      }
+    else
+      {
+	XChar2b char2b;
+	XCharStruct *pcm;
+
+	char2b.byte1 = 0x00, char2b.byte2 = 0x20;
+	pcm = x_per_char_metric (font, &char2b, 0);
+	if (pcm)
+	  fontp->space_width = pcm->width;
+	else
+	  fontp->space_width = FONT_WIDTH (font);
+
+	fontp->average_width
+	  = (XGetFontProperty (font, dpyinfo->Xatom_AVERAGE_WIDTH, &value)
+	     ? (long) value / 10 : 0);
+	if (fontp->average_width < 0)
+	  fontp->average_width = - fontp->average_width;
+	if (fontp->average_width == 0)
+	  {
+	    if (pcm)
+	      {
+		int width = pcm->width;
+		for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++)
+		  if ((pcm = x_per_char_metric (font, &char2b, 0)) != NULL)
+		    width += pcm->width;
+		fontp->average_width = width / 95;
+	      }
+	    else
+	      fontp->average_width = FONT_WIDTH (font);
+	  }
+      }
+
     /* Try to get the full name of FONT.  Put it in FULL_NAME.  */
     full_name = 0;
     if (XGetFontProperty (font, XA_FONT, &value))
@@ -10425,6 +10471,8 @@
   /* For properties of font.  */
   dpyinfo->Xatom_PIXEL_SIZE
     = XInternAtom (dpyinfo->display, "PIXEL_SIZE", False);
+  dpyinfo->Xatom_AVERAGE_WIDTH
+    = XInternAtom (dpyinfo->display, "AVERAGE_WIDTH", False);
   dpyinfo->Xatom_MULE_BASELINE_OFFSET
     = XInternAtom (dpyinfo->display, "_MULE_BASELINE_OFFSET", False);
   dpyinfo->Xatom_MULE_RELATIVE_COMPOSE
--- a/src/xterm.h	Thu Jan 06 15:00:09 2005 +0000
+++ b/src/xterm.h	Thu Jan 06 15:05:01 2005 +0000
@@ -317,7 +317,7 @@
 
   /* More atoms for font properties.  The last three are private
      properties, see the comments in src/fontset.h.  */
-  Atom Xatom_PIXEL_SIZE,
+  Atom Xatom_PIXEL_SIZE, Xatom_AVERAGE_WIDTH,
   Xatom_MULE_BASELINE_OFFSET, Xatom_MULE_RELATIVE_COMPOSE,
   Xatom_MULE_DEFAULT_ASCENT;