changeset 90071:f6b4d0ebf147

Merge from emacs--cvs-trunk--0
author Miles Bader <miles@gnu.org>
date Sun, 02 Jan 2005 09:21:32 +0000
parents 95879cc1ed20 (current diff) abe8e399a00c (diff)
children cb67264d6096
files lisp/ChangeLog lisp/calc/calc-prog.el lisp/calc/calc-store.el lisp/calc/calc-yank.el lisp/cus-face.el lisp/dired.el lisp/faces.el lisp/files.el lisp/gnus/imap.el lisp/image.el lisp/replace.el lisp/ses.el lispref/ChangeLog lispref/display.texi lispref/os.texi man/ChangeLog man/calc.texi man/custom.texi man/emacs.texi man/killing.texi src/ChangeLog src/dispextern.h src/xdisp.c
diffstat 24 files changed, 655 insertions(+), 426 deletions(-) [+]
line wrap: on
line diff
--- a/admin/FOR-RELEASE	Sun Jan 02 09:13:19 2005 +0000
+++ b/admin/FOR-RELEASE	Sun Jan 02 09:21:32 2005 +0000
@@ -62,12 +62,6 @@
 I think in the near future we will see more of this problem, so it might be
 time to make anfe-ftp more intelligent.
 
-** Mailabbrev should quote addresses to correspond to RFC 822.
-See http://article.gmane.org/gmane.emacs.devel/27585
-
-** The '@' character should not expand addresses in mailabbrev
-See http://article.gmane.org/gmane.emacs.devel/27585
-
 ** Bug in url-http-parse-headers, reported in
 From: Vivek Dasmohapatra <vivek@zeus.com>
 Date: Tue, 28 Sep 2004 16:13:13 +0100
--- a/lisp/ChangeLog	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/ChangeLog	Sun Jan 02 09:21:32 2005 +0000
@@ -1,3 +1,46 @@
+2005-01-01  Jay Belanger  <belanger@truman.edu>
+
+	* calc-yank.el (calc-edit-mode): Change default header.
+
+	* calc-store.el (calc-edit-variable): Change title to match new
+	header.
+
+	* calc/calc-prog.el (calc-edit-user-syntax): Change title to edit
+	mode to match new header.
+	(calc-user-define-edit): Change titles to include names of commands.
+	(calc-finish-macro-edit): Remove.
+	(calc-edit-macro-repeats, calc-edit-macro-adjust-buffer)
+	(calc-edit-macro-command, calc-edit-macro-command-type)
+	(calc-edit-macro-combine-alg-ent, calc-edit-macro-combine-ext-command)
+	(calc-edit-macro-combine-var-name, calc-edit-macro-combine-digits)
+	(calc-edit-format-macro-buffer, calc-edit-macro-pre-finish-edit)
+	(calc-edit-macro-finish-edit): New functions.
+	(calc-user-define-edit): Use new functions to edit named calc macros.
+
+2005-01-01  Stefan  <monnier@iro.umontreal.ca>
+
+	* files.el (hack-local-variables): Cleanup prefix/suffix matching.
+
+	* ses.el (copy-region-as-kill): Deactivate mark.
+
+2005-01-01  Richard M. Stallman  <rms@gnu.org>
+
+	* replace.el (occur-1): If the output buffer is also an input,
+	don't kill it, rename it.
+
+	* faces.el (set-face-background, set-face-foreground): Doc fix.
+
+	* cus-face.el (custom-face-attributes): Fix :help-echo strings
+	for :foreground and :background.
+
+	* dired.el (dired-view-command-alist): Variable deleted.
+	(dired-view-file, dired-mouse-find-file-other-window):
+	Delete the code to use it.
+
+2005-01-01  Kim F. Storm  <storm@cua.dk>
+
+	* image.el (insert-sliced-image): Use t for line-height property.
+
 2004-12-31  Jay Belanger  <belanger@truman.edu>
 
 	* calc/calc-store.el (calcVar-digit, calcVar-oper):  Remove the need
@@ -27,7 +70,7 @@
 	* 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.
@@ -64,12 +107,11 @@
 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.
+	Rename for explicit-buffer-file-coding-system.
+	(after-insert-file-set-coding): Adjust 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>
@@ -93,9 +135,9 @@
 	(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-prev-next-op-alist.
 	(artist-mode-map): Add binding for C-mouse-4 and C-mouse-5 to
- 	change drawing operation.
+	change drawing operation.
 
 2004-12-30  Luc Teirlinck  <teirllm@auburn.edu>
 
@@ -107,8 +149,8 @@
 
 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-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):
@@ -116,14 +158,14 @@
 
 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.
+	* 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.
+	* 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>
@@ -148,13 +190,12 @@
 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.
+	(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'.
+	* 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>
 
@@ -207,8 +248,8 @@
 2004-12-27  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* term/mac-win.el: Sync with x-win.el.  Rearrange the contents.
-	Call mac-clear-font-name-table if invoked on Mac OS 8/9.  Call
-	x-open-connection on Mac OS X.
+	Call mac-clear-font-name-table if invoked on Mac OS 8/9.
+	Call x-open-connection on Mac OS X.
 
 2004-12-27  Richard M. Stallman  <rms@gnu.org>
 
@@ -275,7 +316,7 @@
 
 	* simple.el (undo-list-saved): New variable (buffer-local).
 	(undo): Set and test it.
-	(buffer-disable-undo): Moved here from buffer.c.
+	(buffer-disable-undo): Move here from buffer.c.
 	Clear out undo-list-saved.
 
 	* international/mule.el (decode-coding-inserted-region):
@@ -298,7 +339,7 @@
 	`interactive' form as previous-matching-history-element.
 
 	* ffap.el (ffap-string-at-point-mode-alist): Add "*" to url chars,
-        it can appear unencoded and has been seen from yahoo.
+	it can appear unencoded and has been seen from yahoo.
 
 2004-12-27  Sergey Poznyakoff <gray@Mirddin.farlep.net>  (tiny change)
 
@@ -307,8 +348,8 @@
 
 2004-12-27  Kenichi Handa  <handa@m17n.org>
 
-	* international/utf-8.el (utf-translate-cjk-load-tables): Bind
-	coding-system-for-read to nil while loading subst-*.
+	* international/utf-8.el (utf-translate-cjk-load-tables):
+	Bind coding-system-for-read to nil while loading subst-*.
 
 2004-12-26  Jay Belanger  <belanger@truman.edu>
 
@@ -365,8 +406,8 @@
 
 2004-12-21  Markus Rost  <rost@ias.edu>
 
-	* calendar/diary-lib.el (mark-diary-entries): Set
-	mark-diary-entries-in-calendar only after checking for diary-file.
+	* calendar/diary-lib.el (mark-diary-entries):
+	Set mark-diary-entries-in-calendar only after checking for diary-file.
 
 2004-12-21  Richard M. Stallman  <rms@gnu.org>
 
@@ -389,32 +430,29 @@
 	(calculator-string-to-number): New function, mostly moved and
 	updated code from calculator-curnum-value.
 	(calculator-curnum-value): Use it.
-	(calculator-paste): Use it, and update grabbing the
-	current-kill.
+	(calculator-paste): Use it, and update grabbing the current-kill.
 	(calculator-rotate-displayer)
 	(calculator-rotate-displayer-back): Toggle digit grouping when
 	in radix mode, use calculator-message.
-	(calculator-displayer-prev, calculator-displayer-next): Change
-	digit group size when in radix mode.
-	(calculator-number-to-string): Renamed from
+	(calculator-displayer-prev, calculator-displayer-next):
+	Change digit group size when in radix mode.
+	(calculator-number-to-string): Rename from
 	calculator-num-to-string.  Now deals with digit grouping in
 	radix mode.
-	(calculator-update-display, calculator-put-value): Use the new
-	name.
+	(calculator-update-display, calculator-put-value): Use the new name.
 	(calculator-fact): Return a floating point number.
 	(calculator-mode): Doc fix.
 
 2004-12-20  Glenn Morris  <gmorris@ast.cam.ac.uk>
 
 	* calendar/calendar.el (view-other-diary-entries): Add autoload.
-	* calendar/diary-lib.el (view-other-diary-entries): Use
-	current-prefix-arg in interactive spec.
+	* calendar/diary-lib.el (view-other-diary-entries):
+	Use current-prefix-arg in interactive spec.
 
 2004-12-19  Jay Belanger  <belanger@truman.edu>
 
 	* calc/calc-aent.el (calcAlg-blank-matching-open):
-	Temporarily adjust the syntax of both delimiters of half-open
-	intervals.
+	Temporarily adjust the syntax of both delimiters of half-open intervals.
 
 2004-12-19  Kim F. Storm  <storm@cua.dk>
 
@@ -524,7 +562,7 @@
 2004-12-16  Juri Linkov  <juri@jurta.org>
 
 	* help.el (function-called-at-point):
-	* help-fns.el (variable-at-point): As a last resort try striping
+	* help-fns.el (variable-at-point): As a last resort try stripping
 	non-word prefixes and suffixes.
 
 	* descr-text.el (describe-property-list): Don't treat syntax-table
@@ -615,13 +653,13 @@
 	* simple.el (inhibit-mark-movement): Remove defvar.
 	(beginning-of-buffer, end-of-buffer): Don't use it.
 
-	* emacs-lisp/lisp.el (beginning-of-defun, end-of-defun): Don't
-	use inhibit-mark-movement.
+	* emacs-lisp/lisp.el (beginning-of-defun, end-of-defun):
+	Don't use inhibit-mark-movement.
 
 	* emulation/cua-base.el (cua--preserve-mark-commands): Remove.
 	(cua--undo-push-mark): Remove.
-	(cua--pre-command-handler, cua--post-command-handler): Don't
-	fiddle with inhibit-mark-movement.
+	(cua--pre-command-handler, cua--post-command-handler):
+	Don't fiddle with inhibit-mark-movement.
 
 2004-12-14  Juri Linkov  <juri@jurta.org>
 
@@ -633,8 +671,7 @@
 
 2004-12-13  Juri Linkov  <juri@jurta.org>
 
-	* simple.el (next-error-buffer-p, next-error-find-buffer):
-	Doc fix.
+	* simple.el (next-error-buffer-p, next-error-find-buffer): Doc fix.
 
 	* mail/supercite.el (sc-cite-frame-alist): Doc fix.
 	(sc-cite-region, sc-uncite-region, sc-recite-region):
--- a/lisp/calc/calc-prog.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/calc/calc-prog.el	Sun Jan 02 09:21:32 2005 +0000
@@ -474,7 +474,7 @@
    (let ((lang calc-language))
      (calc-edit-mode (list 'calc-finish-user-syntax-edit (list 'quote lang))
 		     t
-		     (format "Editing %s-Mode Syntax Table"
+		     (format "Editing %s-Mode Syntax Table. "
 			     (cond ((null lang) "Normal")
 				   ((eq lang 'tex) "TeX")
 				   (t (capitalize (symbol-name lang))))))
@@ -660,7 +660,6 @@
 				 (list '\? (list (car last)) '("$$"))))))))
     part))
 
-
 (defun calc-user-define-invocation ()
   (interactive)
   (or last-kbd-macro
@@ -668,9 +667,8 @@
   (setq calc-invocation-macro last-kbd-macro)
   (message "Use `M-# Z' to invoke this macro"))
 
-
-(defun calc-user-define-edit (prefix)
-  (interactive "P")  ; but no calc-wrapper!
+(defun calc-user-define-edit ()
+  (interactive)  ; but no calc-wrapper!
   (message "Edit definition of command: z-")
   (let* ((key (read-char))
 	 (def (or (assq key (calc-user-key-map))
@@ -678,116 +676,278 @@
 		  (assq (downcase key) (calc-user-key-map))
 		  (error "No command defined for that key")))
 	 (cmd (cdr def)))
-    (if (symbolp cmd)
-	(setq cmd (symbol-function cmd)))
+    (when (symbolp cmd)
+      (setq cmdname (symbol-name cmd))
+      (setq cmd (symbol-function cmd)))
     (cond ((or (stringp cmd)
 	       (and (consp cmd)
 		    (eq (car-safe (nth 3 cmd)) 'calc-execute-kbd-macro)))
-	   (if (and (>= (prefix-numeric-value prefix) 0)
-		    (fboundp 'edit-kbd-macro)
-		    (symbolp (cdr def))
-		    (eq major-mode 'calc-mode))
-	       (progn
-		 (if (and (< (window-width) (frame-width))
-			  calc-display-trail)
-		     (let ((win (get-buffer-window (calc-trail-buffer))))
-		       (if win
-			   (delete-window win))))
-		 (edit-kbd-macro (cdr def) prefix nil
-				 (function
-				  (lambda (x)
-				    (and calc-display-trail
-					 (calc-wrapper
-					  (calc-trail-display 1 t)))))
-				 (function
-				  (lambda (cmd)
-				    (if (stringp (symbol-function cmd))
-					(symbol-function cmd)
-				      (let ((mac (nth 1 (nth 3 (symbol-function
-								cmd)))))
-					(if (vectorp mac)
-					    (aref mac 1)
-					  mac)))))
-				 (function
-				  (lambda (new cmd)
-				    (if (stringp (symbol-function cmd))
-					(fset cmd new)
-				      (let ((mac (cdr (nth 3 (symbol-function
-							      cmd)))))
-					(if (vectorp (car mac))
-					    (progn
-					      (aset (car mac) 0
-						    (key-description new))
-					      (aset (car mac) 1 new))
-					  (setcar mac new))))))))
-	     (let ((keys (progn (and (fboundp 'edit-kbd-macro)
-				     (edit-kbd-macro nil))
-				(fboundp 'edmacro-parse-keys))))
-	       (calc-wrapper
-		(calc-edit-mode (list 'calc-finish-macro-edit
-				      (list 'quote def)
-				      keys)
-				t)
-		(if keys
-		    (let (top
-			  (fill-column 70)
-			  (fill-prefix nil))
-		      (insert "Notations: RET, SPC, TAB, DEL, LFD, NUL"
-			      ", C-xxx, M-xxx.\n\n")
-		      (setq top (point))
-		      (insert (if (stringp cmd)
-				  (key-description cmd)
-				(if (vectorp (nth 1 (nth 3 cmd)))
-				    (aref (nth 1 (nth 3 cmd)) 0)
-				  (key-description (nth 1 (nth 3 cmd)))))
-			      "\n")
-		      (if (>= (prog2 (forward-char -1)
-				     (current-column)
-				     (forward-char 1))
-			      (frame-width))
-			  (fill-region top (point))))
-		  (insert "Press C-q to quote control characters like RET"
-			  " and TAB.\n"
-			  (if (stringp cmd)
-			      cmd
-			    (if (vectorp (nth 1 (nth 3 cmd)))
-				(aref (nth 1 (nth 3 cmd)) 1)
-			      (nth 1 (nth 3 cmd)))))))
-	       (calc-show-edit-buffer)
-	       (forward-line (if keys 2 1)))))
+           (let* ((mac (elt (nth 1 (nth 3 cmd)) 1))
+                  (str (edmacro-format-keys mac t))
+                  (macbeg)
+                  (kys (nth 3 (nth 3 cmd))))
+             (calc-edit-mode 
+              (list 'calc-edit-macro-finish-edit cmdname kys)
+              t (format "Editing keyboard macro (%s, bound to %s).\n" 
+                        cmdname kys))
+             (goto-char (point-max))
+             (insert "Original keys: " (elt (nth 1 (nth 3 cmd)) 0)  "\n" )
+             (setq macbeg (point))
+             (insert str "\n")
+             (calc-edit-format-macro-buffer)
+             (calc-show-edit-buffer)
+             (goto-char (point-min))
+             (search-forward "Original")
+             (forward-line 2)))
 	  (t (let* ((func (calc-stack-command-p cmd))
 		    (defn (and func
 			       (symbolp func)
-			       (get func 'calc-user-defn))))
+			       (get func 'calc-user-defn)))
+                    (kys (concat "z" (char-to-string (car def))))
+                    (intcmd (symbol-name (cdr def)))
+                    (algcmd (substring (symbol-name func) 9)))
 	       (if (and defn (calc-valid-formula-func func))
 		   (progn
 		     (calc-wrapper
-		      (calc-edit-mode (list 'calc-finish-formula-edit
-					    (list 'quote func)))
+		      (calc-edit-mode 
+                       (list 'calc-finish-formula-edit (list 'quote func))
+                       nil
+                       (format "Editing formula (%s, %s, bound to %s).\n"
+                               intcmd algcmd kys))
 		      (insert (math-showing-full-precision
 			       (math-format-nice-expr defn (frame-width)))
 			      "\n"))
-		     (calc-show-edit-buffer))
+		     (calc-show-edit-buffer)
+                     (goto-char (point-min))
+                     (forward-line 2))
 		 (error "That command's definition cannot be edited")))))))
 
-(defun calc-finish-macro-edit (def keys)
+;; Formatting the macro buffer
+
+(defun calc-edit-macro-repeats ()
+  (goto-char (point-min))
+  (while
+      (re-search-forward "^\\([0-9]+\\)\\*" nil t)
+    (setq num (string-to-int (match-string 1)))
+    (setq line (buffer-substring (point) (line-end-position)))
+    (goto-char (line-beginning-position))
+    (kill-line 1)
+    (while (> num 0)
+      (insert line "\n")
+      (setq num (1- num)))))
+
+(defun calc-edit-macro-adjust-buffer ()
+  (calc-edit-macro-repeats)
+  (goto-char (point-min))
+  (while (re-search-forward "^RET$" nil t)
+    (delete-char 1))
+  (goto-char (point-min))
+  (while (and (re-search-forward "^$" nil t)
+              (not (= (point) (point-max))))
+    (delete-char 1)))
+
+(defun calc-edit-macro-command ()
+  "Return the command on the current line in a Calc macro editing buffer."
+  (let ((beg (line-beginning-position))
+        (end (save-excursion
+               (if (search-forward ";;" (line-end-position) 1)
+                   (forward-char -2))
+               (skip-chars-backward " \t")
+               (point))))
+    (buffer-substring beg end)))
+
+(defun calc-edit-macro-command-type ()
+  "Return the type of command on the current line in a Calc macro editing buffer."
+  (let ((beg (save-excursion
+               (if (search-forward ";;" (line-end-position) t)
+                   (progn
+                     (skip-chars-forward " \t")
+                     (point)))))
+        (end (save-excursion
+               (goto-char (line-end-position))
+               (skip-chars-backward " \t")
+               (point))))
+    (if beg
+        (buffer-substring beg end)
+      "")))
+
+(defun calc-edit-macro-combine-alg-ent ()
+  "Put an entire algebraic entry on a single line."
+  (let ((line (calc-edit-macro-command))
+        (type (calc-edit-macro-command-type))
+        curline
+        match)
+    (goto-char (line-beginning-position))
+    (kill-line 1)
+    (setq curline (calc-edit-macro-command))
+    (while (and curline
+                (not (string-equal "RET" curline))
+                (not (setq match (string-match "<return>" curline))))
+      (setq line (concat line curline))
+      (kill-line 1)
+      (setq curline (calc-edit-macro-command)))
+    (when match
+      (kill-line 1)
+      (setq line (concat line (substring curline 0 match))))
+    (setq line (replace-regexp-in-string "SPC" " SPC " 
+                  (replace-regexp-in-string " " "" line)))
+    (insert line "\t\t\t")
+    (if (> (current-column) 24)
+        (delete-char -1))
+    (insert ";; " type "\n")
+    (if match
+        (insert "RET\t\t\t;; calc-enter\n"))))
+
+(defun calc-edit-macro-combine-ext-command ()
+  "Put an entire extended command on a single line."
+  (let ((cmdbeg (calc-edit-macro-command))
+        (line "")
+        (type (calc-edit-macro-command-type))
+        curline
+        match)
+    (goto-char (line-beginning-position))
+    (kill-line 1)
+    (setq curline (calc-edit-macro-command))
+    (while (and curline
+                (not (string-equal "RET" curline))
+                (not (setq match (string-match "<return>" curline))))
+      (setq line (concat line curline))
+      (kill-line 1)
+      (setq curline (calc-edit-macro-command)))
+    (when match 
+      (kill-line 1)
+      (setq line (concat line (substring curline 0 match))))
+    (setq line (replace-regexp-in-string " " "" line))
+    (insert cmdbeg " " line "\t\t\t")
+    (if (> (current-column) 24)
+        (delete-char -1))
+    (insert ";; " type "\n")
+    (if match
+        (insert "RET\t\t\t;; calc-enter\n"))))
+
+(defun calc-edit-macro-combine-var-name ()
+  "Put an entire variable name on a single line."
+  (let ((line (calc-edit-macro-command))
+        curline
+        match)
+    (goto-char (line-beginning-position))
+    (kill-line 1)
+    (if (member line '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
+          (insert line "\t\t\t;; calc quick variable\n")
+      (setq curline (calc-edit-macro-command))
+      (while (and curline
+                  (not (string-equal "RET" curline))
+                  (not (setq match (string-match "<return>" curline))))
+        (setq line (concat line curline))
+        (kill-line 1)
+        (setq curline (calc-edit-macro-command)))
+      (when match 
+        (kill-line 1)
+        (setq line (concat line (substring curline 0 match))))
+      (setq line (replace-regexp-in-string " " "" line))
+      (insert line "\t\t\t")
+      (if (> (current-column) 24)
+          (delete-char -1))
+      (insert ";; calc variable\n")
+      (if match
+          (insert "RET\t\t\t;; calc-enter\n")))))
+
+(defun calc-edit-macro-combine-digits ()
+  "Put an entire sequence of digits on a single line."
+  (let ((line (calc-edit-macro-command))
+        curline)
+    (goto-char (line-beginning-position))
+    (kill-line 1)
+    (while (string-equal (calc-edit-macro-command-type) "calcDigit-start")
+      (setq line (concat line (calc-edit-macro-command)))
+      (kill-line 1))
+    (insert line "\t\t\t")
+    (if (> (current-column) 24)
+        (delete-char -1))
+    (insert ";; calc digits\n")))
+
+(defun calc-edit-format-macro-buffer ()
+  "Rewrite the Calc macro editing buffer."
+  (calc-edit-macro-adjust-buffer)
+  (goto-char (point-min))
+  (search-forward "Original keys:")
   (forward-line 1)
-  (if (and keys (looking-at "\n")) (forward-line 1))
-  (let* ((true-str (buffer-substring (point) (point-max)))
-	 (str true-str))
-    (if keys (setq str (edmacro-parse-keys str)))
-    (if (symbolp (cdr def))
-	(if (stringp (symbol-function (cdr def)))
-	    (fset (cdr def) str)
-	  (let ((mac (cdr (nth 3 (symbol-function (cdr def))))))
-	    (if (vectorp (car mac))
-		(progn
-		  (aset (car mac) 0 (if keys true-str (key-description str)))
-		  (aset (car mac) 1 str))
-	      (setcar mac str))))
-      (setcdr def str))))
+  (insert "\n")
+  (skip-chars-forward " \t\n")
+  (let ((type (calc-edit-macro-command-type)))
+    (while (not (string-equal type ""))
+      (cond
+       ((or
+         (string-equal type "calc-algebraic-entry")
+         (string-equal type "calc-auto-algebraic-entry"))
+        (calc-edit-macro-combine-alg-ent))
+       ((string-equal type "calc-execute-extended-command")
+        (calc-edit-macro-combine-ext-command))
+       ((string-equal type "calcDigit-start")
+        (calc-edit-macro-combine-digits))
+       ((or
+         (string-equal type "calc-store")
+         (string-equal type "calc-store-into")
+         (string-equal type "calc-store-neg")
+         (string-equal type "calc-store-plus")
+         (string-equal type "calc-store-minus")
+         (string-equal type "calc-store-div")
+         (string-equal type "calc-store-times")
+         (string-equal type "calc-store-power")
+         (string-equal type "calc-store-concat")
+         (string-equal type "calc-store-inv")
+         (string-equal type "calc-store-dec")
+         (string-equal type "calc-store-incr")
+         (string-equal type "calc-store-exchange")
+         (string-equal type "calc-unstore")
+         (string-equal type "calc-recall")
+         (string-equal type "calc-let")
+         (string-equal type "calc-permanent-variable"))
+        (forward-line 1)
+        (calc-edit-macro-combine-var-name))
+       ((or
+         (string-equal type "calc-copy-variable")
+         (string-equal type "calc-declare-variable"))
+        (forward-line 1)
+        (calc-edit-macro-combine-var-name)
+        (calc-edit-macro-combine-var-name))
+       (t (forward-line 1)))
+      (setq type (calc-edit-macro-command-type))))
+  (goto-char (point-min)))
+
+;; Finish editing the macro
+
+(defun calc-edit-macro-pre-finish-edit ()
+  (goto-char (point-min))
+  (while (re-search-forward "\\(^\\| \\)RET\\($\\|\t\\| \\)" nil t)
+    (search-backward "RET")
+    (delete-char 3)
+    (insert "<return>")))
+
+(defun calc-edit-macro-finish-edit (cmdname key)
+  "Finish editing a Calc macro.
+Redefine the corresponding command."
+  (interactive)
+  (let ((cmd (intern cmdname)))
+    (calc-edit-macro-pre-finish-edit)
+    (goto-char (point-max))
+    (re-search-backward "^Original keys:")
+    (forward-line 1)
+    (let* ((str (buffer-substring (point) (point-max)))
+           (mac (edmacro-parse-keys str t)))
+      (if (= (length mac) 0)
+          (fmakunbound cmd)
+        (fset cmd
+              (list 'lambda '(arg)
+                    '(interactive "P")
+                    (list 'calc-execute-kbd-macro
+                          (vector (key-description mac)
+                                  mac)
+                          'arg key)))))))
 
 (defun calc-finish-formula-edit (func)
+  (goto-char (point-min))
+  (forward-line 2)
   (let ((buf (current-buffer))
 	(str (buffer-substring (point) (point-max)))
 	(start (point))
--- a/lisp/calc/calc-store.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/calc/calc-store.el	Sun Jan 02 09:21:32 2005 +0000
@@ -397,7 +397,7 @@
 	 (setq calc-last-edited-variable var)
 	 (calc-edit-mode (list 'calc-finish-stack-edit (list 'quote var))
 			 t
-			 (concat "Editing " (calc-var-name var)))
+			 (concat "Editing variable `" (calc-var-name var) "'. "))
 	 (and value
 	      (insert (math-format-nice-expr value (frame-width)) "\n")))))
   (calc-show-edit-buffer))
--- a/lisp/calc/calc-yank.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/calc/calc-yank.el	Sun Jan 02 09:21:32 2005 +0000
@@ -464,8 +464,8 @@
                                   (let ((calc-edit-handler nil))
                                     (calc-edit-finish t))
                                   (message "(Cancelled)")) t t)
-    (insert (or title title "Calc Edit Mode")
-	    ".  Press `C-c C-c'"
+    (insert (or title title "Calc Edit Mode. ")
+	    "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)
--- a/lisp/cus-face.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/cus-face.el	Sun Jan 02 09:21:32 2005 +0000
@@ -195,11 +195,11 @@
 
     (:foreground
      (color :tag "Foreground"
-	    :help-echo "Set foreground color."))
+	    :help-echo "Set foreground color (name or #RRGGBB hex spec)."))
 
     (:background
      (color :tag "Background"
-	    :help-echo "Set background color."))
+	    :help-echo "Set background color (name or #RRGGBB hex spec)."))
 
     (:stipple
      (choice :tag "Stipple"
--- a/lisp/dired.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/dired.el	Sun Jan 02 09:21:32 2005 +0000
@@ -200,22 +200,6 @@
 ;; Note this can't simply be run inside function `dired-ls' as the hook
 ;; functions probably depend on the dired-subdir-alist to be OK.
 
-;; Fixme: This should use mailcap.
-(defcustom dired-view-command-alist
-  '(("\\.\\(ps\\|ps_pages\\|eps\\)\\'" . "gv %s")
-    ("\\.pdf\\'" . "xpdf %s")
-    ;; ("\\.pod\\'" . "perldoc %s")
-    ("\\.\\(jpe?g\\|gif\\|png\\)\\'" . "eog %s")
-    ("\\.dvi\\'" . "xdvi %s"))
-  "Alist specifying how to view special types of files.
-Each element has the form (REGEXP . SHELL-COMMAND).
-When the file name matches REGEXP, `dired-view-file'
-invokes SHELL-COMMAND to view the file, processing it through `format'.
-Use `%s' in SHELL-COMMAND to specify where to put the file name."
-  :group 'dired
-  :type '(alist :key-type regexp :value-type string)
-  :version "21.4")
-
 ;; Internal variables
 
 (defvar dired-marker-char ?*		; the answer is 42
@@ -1666,41 +1650,20 @@
 	    (progn
 	      (select-window window)
 	      (dired-other-window file)))
-      (let (cmd)
-	;; Look for some other way to view a certain file.
-	(dolist (elt dired-view-command-alist)
-	  (if (string-match (car elt) file)
-	      (setq cmd (cdr elt))))
-	(if cmd
-	    (call-process shell-file-name nil 0 nil
-			  "-c"
-			  (concat (format cmd (shell-quote-argument file))
-				  " &"))
-	  (select-window window)
-	  (find-file-other-window (file-name-sans-versions file t)))))))
+      (select-window window)
+      (find-file-other-window (file-name-sans-versions file t)))))
 
 (defun dired-view-file ()
   "In Dired, examine a file in view mode, returning to dired when done.
 When file is a directory, show it in this buffer if it is inserted.
-Some kinds of files are displayed using external viewer programs;
-see `dired-view-command-alist'.  Otherwise, display it in another buffer."
+Otherwise, display it in another buffer."
   (interactive)
   (let ((file (dired-get-file-for-visit)))
     (if (file-directory-p file)
 	(or (and (cdr dired-subdir-alist)
 		 (dired-goto-subdir file))
 	    (dired file))
-      (let (cmd)
-	;; Look for some other way to view a certain file.
-	(dolist (elt dired-view-command-alist)
-	  (if (string-match (car elt) file)
-	      (setq cmd (cdr elt))))
-	(if cmd
-	    (call-process shell-file-name nil 0 nil
-			  "-c"
-			  (concat (format cmd (shell-quote-argument file))
-				  " &"))
-	  (view-file file))))))
+      (view-file file))))
 
 (defun dired-find-file-other-window ()
   "In Dired, visit this file or directory in another window."
--- a/lisp/faces.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/faces.el	Sun Jan 02 09:21:32 2005 +0000
@@ -730,7 +730,9 @@
 (defun set-face-background (face color &optional frame)
   "Change the background color of face FACE to COLOR (a string).
 FRAME nil or not specified means change face on all frames.
-When called interactively, prompt for the face and color."
+COLOR can be a system-defined color name (see `list-colors-display')
+or a hex spec of the form #RRGGBB.
+When called interactively, prompts for the face and color."
   (interactive (read-face-and-attribute :background))
   (set-face-attribute face frame :background (or color 'unspecified)))
 
@@ -738,7 +740,9 @@
 (defun set-face-foreground (face color &optional frame)
   "Change the foreground color of face FACE to COLOR (a string).
 FRAME nil or not specified means change face on all frames.
-When called interactively, prompt for the face and color."
+COLOR can be a system-defined color name (see `list-colors-display')
+or a hex spec of the form #RRGGBB.
+When called interactively, prompts for the face and color."
   (interactive (read-face-and-attribute :foreground))
   (set-face-attribute face frame :foreground (or color 'unspecified)))
 
--- a/lisp/files.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/files.el	Sun Jan 02 09:21:32 2005 +0000
@@ -1,7 +1,7 @@
 ;;; files.el --- file input and output commands for Emacs
 
-;; Copyright (C) 1985,86,87,92,93,94,95,96,97,98,99,2000,01,02,03,2004
-;;;   Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+;;   1999, 2000, 2001, 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 
@@ -2218,31 +2218,27 @@
 						   buffer-file-name)
 						(concat "buffer "
 							(buffer-name))))))))))
-	  (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.
-	    (skip-chars-forward " \t")
-	    (or (eolp)
-		(setq suffix (buffer-substring (point)
-					       (progn (end-of-line) (point)))))
-	    (goto-char (match-beginning 0))
-	    (or (bolp)
-		(setq prefix
-		      (buffer-substring (point)
-					(progn (beginning-of-line) (point)))))
-
-	    (setq prefix (if prefix (regexp-quote prefix) "^"))
-	    (if suffix (setq suffix (concat (regexp-quote suffix) "$")))
+	  (skip-chars-forward " \t")
+	  (let ((enable-local-eval enable-local-eval)
+		;; suffix is what comes after "local variables:" in its line.
+		(suffix
+		 (concat
+		  (regexp-quote (buffer-substring (point) (line-end-position)))
+		  "$"))
+		;; prefix is what comes before "local variables:" in its line.
+		(prefix
+		 (concat "^" (regexp-quote
+			      (buffer-substring (line-beginning-position)
+						(match-beginning 0)))))
+		beg)
+
 	    (forward-line 1)
 	    (let ((startpos (point))
 		  endpos
 		  (thisbuf (current-buffer)))
 	      (save-excursion
 		(if (not (re-search-forward
-			  (concat (or prefix "")
-				  "[ \t]*End:[ \t]*"
-				  (or suffix ""))
+			  (concat prefix "[ \t]*End:[ \t]*" suffix)
 			  nil t))
 		    (error "Local variables list is not properly terminated"))
 		(beginning-of-line)
@@ -2251,20 +2247,17 @@
 	      (with-temp-buffer
 		(insert-buffer-substring thisbuf startpos endpos)
 		(goto-char (point-min))
-		(subst-char-in-region (point) (point-max)
-				      ?\^m ?\n)
+		(subst-char-in-region (point) (point-max) ?\^m ?\n)
 		(while (not (eobp))
-		  ;; Discard the prefix, if any.
-		  (if prefix
-		      (if (looking-at prefix)
-			  (delete-region (point) (match-end 0))
-			(error "Local variables entry is missing the prefix")))
+		  ;; Discard the prefix.
+		  (if (looking-at prefix)
+		      (delete-region (point) (match-end 0))
+		    (error "Local variables entry is missing the prefix"))
 		  (end-of-line)
-		  ;; Discard the suffix, if any.
-		  (if suffix
-		      (if (looking-back suffix)
-			  (delete-region (match-beginning 0) (point))
-			(error "Local variables entry is missing the suffix")))
+		  ;; Discard the suffix.
+		  (if (looking-back suffix)
+		      (delete-region (match-beginning 0) (point))
+		    (error "Local variables entry is missing the suffix"))
 		  (forward-line 1))
 		(goto-char (point-min))
 
--- a/lisp/gnus/imap.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/gnus/imap.el	Sun Jan 02 09:21:32 2005 +0000
@@ -1,5 +1,5 @@
 ;;; imap.el --- imap library
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <jas@pdc.kth.se>
@@ -69,7 +69,7 @@
 ;; imap-message-append,               imap-envelope-from
 ;; imap-body-lines
 ;;
-;; It is my hope that theese commands should be pretty self
+;; It is my hope that these commands should be pretty self
 ;; explanatory for someone that know IMAP.  All functions have
 ;; additional documentation on how to invoke them.
 ;;
@@ -325,7 +325,7 @@
 (defvar imap-error nil
   "Error codes from the last command.")
 
-;; Internal constants.  Change theese and die.
+;; Internal constants.  Change these and die.
 
 (defconst imap-default-port 143)
 (defconst imap-default-ssl-port 993)
@@ -1456,7 +1456,7 @@
 (defun imap-fetch (uids props &optional receive nouidfetch buffer)
   "Fetch properties PROPS from message set UIDS from server in BUFFER.
 UIDS can be a string, number or a list of numbers.  If RECEIVE
-is non-nil return theese properties."
+is non-nil return these properties."
   (with-current-buffer (or buffer (current-buffer))
     (when (imap-ok-p (imap-send-command-wait
 		      (format "%sFETCH %s %s" (if nouidfetch "" "UID ")
--- a/lisp/image.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/image.el	Sun Jan 02 09:21:32 2005 +0000
@@ -263,7 +263,7 @@
 	  (setq x (+ x dx))))
       (setq x 0.0
 	    y (+ y dy))
-      (insert (propertize "\n" 'line-height 0)))))
+      (insert (propertize "\n" 'line-height t)))))
 
 
 
--- a/lisp/replace.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/replace.el	Sun Jan 02 09:21:32 2005 +0000
@@ -736,9 +736,12 @@
   (interactive "p")
   ;; we need to run occur-find-match from within the Occur buffer
   (with-current-buffer
+      ;; Choose the buffer and make it current.
       (if (next-error-buffer-p (current-buffer))
 	  (current-buffer)
-	(next-error-find-buffer nil nil (lambda() (eq major-mode 'occur-mode))))
+	(next-error-find-buffer nil nil
+				(lambda ()
+				  (eq major-mode 'occur-mode))))
 
     (goto-char (cond (reset (point-min))
 		     ((< argp 0) (line-beginning-position))
@@ -918,17 +921,20 @@
 (defun occur-1 (regexp nlines bufs &optional buf-name)
   (unless buf-name
     (setq buf-name "*Occur*"))
-  (let ((occur-buf (get-buffer-create buf-name))
-	(made-temp-buf nil)
+  (let (occur-buf
 	(active-bufs (delq nil (mapcar #'(lambda (buf)
 					   (when (buffer-live-p buf) buf))
 				       bufs))))
     ;; Handle the case where one of the buffers we're searching is the
-    ;; *Occur* buffer itself.
-    (when (memq occur-buf bufs)
-      (setq occur-buf (with-current-buffer occur-buf
-			(clone-buffer "*Occur-temp*"))
-	    made-temp-buf t))
+    ;; output buffer.  Just rename it.
+    (when (member buf-name (mapcar 'buffer-name active-bufs))
+      (with-current-buffer (get-buffer buf-name)
+	(rename-uniquely)))
+
+    ;; Now find or create the output buffer.
+    ;; If we just renamed that buffer, we will make a new one here.
+    (setq occur-buf (get-buffer-create buf-name))
+
     (with-current-buffer occur-buf
       (setq buffer-read-only nil)
       (occur-mode)
@@ -948,12 +954,6 @@
 		   (if (zerop count) "no" (format "%d" count))
 		   (if (= count 1) "" "es")
 		   regexp))
-	;; If we had to make a temporary buffer, make it the *Occur*
-	;; buffer now.
-	(when made-temp-buf
-	  (with-current-buffer (get-buffer buf-name)
-	    (kill-buffer (current-buffer)))
-	  (rename-buffer buf-name))
 	(setq occur-revert-arguments (list regexp nlines bufs)
 	      buffer-read-only t)
 	(if (> count 0)
@@ -1258,6 +1258,27 @@
   (replace-match newtext fixedcase literal)
   noedit)
 
+(defcustom query-replace-highlight t
+  "*Non-nil means to highlight matches during query replacement."
+  :type 'boolean
+  :group 'matching)
+
+(defcustom query-replace-lazy-highlight t
+  "*Controls the lazy-highlighting during query replacements.
+When non-nil, all text in the buffer matching the current match
+is highlighted lazily using isearch lazy highlighting (see
+`isearch-lazy-highlight-initial-delay' and
+`isearch-lazy-highlight-interval')."
+  :type 'boolean
+  :group 'matching
+  :version "21.4")
+
+(defface query-replace
+  '((t (:inherit isearch)))
+  "Face for highlighting query replacement matches."
+  :group 'matching
+  :version "21.4")
+
 (defun perform-replace (from-string replacements
 		        query-flag regexp-flag delimited-flag
 			&optional repeat-count map start end)
@@ -1601,27 +1622,6 @@
 		 (if (= replace-count 1) "" "s")))
     (and keep-going stack)))
 
-(defcustom query-replace-highlight t
-  "*Non-nil means to highlight matches during query replacement."
-  :type 'boolean
-  :group 'matching)
-
-(defcustom query-replace-lazy-highlight t
-  "*Controls the lazy-highlighting during query replacements.
-When non-nil, all text in the buffer matching the current match
-is highlighted lazily using isearch lazy highlighting (see
-`isearch-lazy-highlight-initial-delay' and
-`isearch-lazy-highlight-interval')."
-  :type 'boolean
-  :group 'matching
-  :version "21.4")
-
-(defface query-replace
-  '((t (:inherit isearch)))
-  "Face for highlighting query replacement matches."
-  :group 'matching
-  :version "21.4")
-
 (defvar replace-overlay nil)
 
 (defun replace-highlight (beg end)
@@ -1638,7 +1638,7 @@
   (when replace-overlay
     (delete-overlay replace-overlay))
   (when query-replace-lazy-highlight
-    (isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup)
+    (isearch-lazy-highlight-cleanup lazy-highlight-cleanup)
     (setq isearch-lazy-highlight-last-string nil)))
 
 ;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4
--- a/lisp/ses.el	Sun Jan 02 09:13:19 2005 +0000
+++ b/lisp/ses.el	Sun Jan 02 09:21:32 2005 +0000
@@ -1,6 +1,6 @@
 ;;; ses.el -- Simple Emacs Spreadsheet  -*- coding: utf-8 -*-
 
-;; Copyright (C) 2002,03,04  Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
 
 ;; Author: Jonathan Yavner <jyavner@member.fsf.org>
 ;; Maintainer: Jonathan Yavner <jyavner@member.fsf.org>
@@ -2331,7 +2331,10 @@
 		(eq (get-text-property beg 'read-only) 'ses)
 		(eq (get-text-property (1- end) 'read-only) 'ses)))
       ad-do-it ;Normal copy-region-as-kill
-    (kill-new (ses-copy-region beg end))))
+    (kill-new (ses-copy-region beg end))
+    (if transient-mark-mode
+	(setq deactivate-mark t))
+    nil))
 
 (defun ses-copy-region (beg end)
   "Treat the region as rectangular.  Convert the intangible attributes to
--- a/lispref/ChangeLog	Sun Jan 02 09:13:19 2005 +0000
+++ b/lispref/ChangeLog	Sun Jan 02 09:21:32 2005 +0000
@@ -1,3 +1,15 @@
+2005-01-01  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* display.texi (Face Attributes): Correct xref to renamed node.
+
+2005-01-01  Richard M. Stallman  <rms@gnu.org>
+
+	* display.texi (Face Attributes): Describe hex color specs.
+
+2004-12-31  Richard M. Stallman  <rms@gnu.org>
+
+	* os.texi (Timers): Update previous change.
+
 2004-12-30  Kim F. Storm  <storm@cua.dk>
 
 	* display.texi (Line Height): Total line-height is now specified
--- a/lispref/display.texi	Sun Jan 02 09:13:19 2005 +0000
+++ b/lispref/display.texi	Sun Jan 02 09:21:32 2005 +0000
@@ -1636,7 +1636,7 @@
 * Defining Faces::      How to define a face with @code{defface}.
 * Face Attributes::     What is in a face?
 * Attribute Functions::  Functions to examine and set face attributes.
-* Merging Faces::       How Emacs combines the faces specified for a character.
+* Displaying Faces::     How Emacs combines the faces specified for a character.
 * Font Selection::      Finding the best available font for a face.
 * Face Functions::      How to define and examine faces.
 * Auto Faces::          Hook for automatic face assignment.
@@ -1890,7 +1890,7 @@
 attributes}.  This table lists all the face attributes, and what they
 mean.  Note that in general, more than one face can be specified for a
 given piece of text; when that happens, the attributes of all the faces
-are merged to specify how to display the text.  @xref{Merging Faces}.
+are merged to specify how to display the text.  @xref{Displaying Faces}.
 
   In Emacs 21, any attribute in a face can have the value
 @code{unspecified}.  This means the face doesn't specify that attribute.
@@ -1941,10 +1941,14 @@
 the terminal supports the feature.
 
 @item :foreground
-Foreground color, a string.
+Foreground color, a string.  The value can be a system-defined color
+name, or a hexadecimal color specification of the form
+@samp{#@var{rr}@var{gg}@var{bb}}.  (@samp{#000000} is black,
+@samp{#ff0000} is red, @samp{#00ff00} is green, @samp{#0000ff} is
+blue, and @samp{#ffffff} is white.)
 
 @item :background
-Background color, a string.
+Background color, a string, like the foreground color.
 
 @item :inverse-video
 Whether or not characters should be displayed in inverse video.  The
@@ -2265,8 +2269,8 @@
 This function returns the @code{:inverse-video} attribute of face @var{face}.
 @end defun
 
-@node Merging Faces
-@subsection Merging Faces for Display
+@node Displaying Faces
+@subsection Displaying Faces
 
   Here are the ways to specify which faces to use for display of text:
 
--- a/lispref/os.texi	Sun Jan 02 09:13:19 2005 +0000
+++ b/lispref/os.texi	Sun Jan 02 09:21:32 2005 +0000
@@ -1368,10 +1368,10 @@
 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.
+  It is usually a bad idea for timer functions to alter buffer
+contents.  When they do, they usually should call @code{undo-boundary}
+both before and after changing the buffer, to separate the timer's
+changes from user commands' changes.
 
 @deffn Command run-at-time time repeat function &rest args
 This sets up a timer that calls the function @var{function} with
@@ -1486,11 +1486,6 @@
 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	Sun Jan 02 09:13:19 2005 +0000
+++ b/man/ChangeLog	Sun Jan 02 09:21:32 2005 +0000
@@ -1,3 +1,26 @@
+2005-01-01  Jay Belanger  <belanger@truman.edu>
+
+	* calc.texi (Programming Tutorial): Changed description of how to
+	edit keyboard macros to match current behavior.
+
+2005-01-01  Andreas Schwab  <schwab@suse.de>
+
+	* killing.texi (Graphical Kill): Move up under node Killing,
+	change @section to @subsection.
+
+2005-01-01  Richard M. Stallman  <rms@gnu.org>
+
+	* custom.texi (Face Customization): Mention hex color specs.
+
+	* emacs.texi (Top): Update Killing submenu.
+
+	* killing.texi (Killing): Reorganize section.
+	No more TeX-only text; put the node command at start of chapter.
+	But the first section heading is used only in TeX.
+	Rewrite the text to read better in this mode.
+	(Graphical Kill): New subnode gets some of the text that
+	used to be in the first section.
+
 2004-12-31  Richard M. Stallman  <rms@gnu.org>
 
 	* dired.texi (Shell Commands in Dired): Delete the ? example.
--- a/man/calc.texi	Sun Jan 02 09:13:19 2005 +0000
+++ b/man/calc.texi	Sun Jan 02 09:21:32 2005 +0000
@@ -6333,51 +6333,52 @@
 
 @smallexample
 @group
-1:  3                   1:  3           Keyboard Macro Editor.
-    .                       .           Original keys: 1 @key{RET} 2 +
-
-                                        type "1\r"
-                                        type "2"
-                                        calc-plus
+1:  3                   1:  3           Calc Macro Edit Mode.
+    .                       .           Original keys: 1 <return> 2 +
+
+                                        1                          ;; calc digits
+                                        RET                        ;; calc-enter
+                                        2                          ;; calc digits
+                                        +                          ;; calc-plus
 
 C-x ( 1 @key{RET} 2 + C-x )    Z K h @key{RET}      Z E h
 @end group
 @end smallexample
 
 @noindent
-This shows the screen display assuming you have the @file{macedit}
-keyboard macro editing package installed, which is usually the case
-since a copy of @file{macedit} comes bundled with Calc.
-
 A keyboard macro is stored as a pure keystroke sequence.  The
-@file{macedit} package (invoked by @kbd{Z E}) scans along the
+@file{edmacro} package (invoked by @kbd{Z E}) scans along the
 macro and tries to decode it back into human-readable steps.
-If a key or keys are simply shorthand for some command with a
-@kbd{M-x} name, that name is shown.  Anything that doesn't correspond
-to a @kbd{M-x} command is written as a @samp{type} command.
+Descriptions of the keystrokes are given as comments, which begin with
+@samp{;;}, and which are ignored when the edited macro is saved.
+Spaces and line breaks are also ignored when the edited macro is saved.
+To enter a space into the macro, type @code{SPC}.  All the special
+characters @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-} and @code{M-}.
 
 Let's edit in a new definition, for computing harmonic numbers.
-First, erase the three lines of the old definition.  Then, type
+First, erase the four lines of the old definition.  Then, type
 in the new definition (or use Emacs @kbd{M-w} and @kbd{C-y} commands
-to copy it from this page of the Info file; you can skip typing
-the comments that begin with @samp{#}).
-
-@smallexample
-calc-kbd-push         # Save local values (Z `)
-type "0"              # Push a zero
-calc-store-into       # Store it in variable 1
-type "1"
-type "1"              # Initial value for loop
-calc-roll-down        # This is the @key{TAB} key; swap initial & final
-calc-kbd-for          # Begin "for" loop...
-calc-inv              #   Take reciprocal
-calc-store-plus       #   Add to accumulator
-type "1"
-type "1"              #   Loop step is 1
-calc-kbd-end-for      # End "for" loop
-calc-recall           # Now recall final accumulated value
-type "1"
-calc-kbd-pop          # Restore values (Z ')
+to copy it from this page of the Info file; you can of course skip
+typing the comments, which begin with @samp{;;}).
+
+@smallexample
+Z`                      ;; calc-kbd-push     (Save local values)
+0                       ;; calc digits       (Push a zero onto the stack)
+st                      ;; calc-store-into   (Store it in the following variable)
+1                       ;; calc quick variable  (Quick variable q1)
+1                       ;; calc digits       (Initial value for the loop) 
+TAB                     ;; calc-roll-down    (Swap initial and final)
+Z(                      ;; calc-kbd-for      (Begin the "for" loop)
+&                       ;; calc-inv          (Take the reciprocal)
+s+                      ;; calc-store-plus   (Add to the following variable)
+1                       ;; calc quick variable  (Quick variable q1)
+1                       ;; calc digits       (The loop step is 1)
+Z)                      ;; calc-kbd-end-for  (End the "for" loop)
+sr                      ;; calc-recall       (Recall the final accumulated value)
+1                       ;; calc quick variable (Quick variable q1)
+Z'                      ;; calc-kbd-pop      (Restore values)
 @end smallexample
 
 @noindent
@@ -6392,15 +6393,12 @@
 @end group
 @end smallexample
 
-If you don't know how to write a particular command in @file{macedit}
-format, you can always write it as keystrokes in a @code{type} command.
-There is also a @code{keys} command which interprets the rest of the
-line as standard Emacs keystroke names.  In fact, @file{macedit} defines
-a handy @code{read-kbd-macro} command which reads the current region
-of the current buffer as a sequence of keystroke names, and defines that
-sequence on the @kbd{X} (and @kbd{C-x e}) key.  Because this is so
-useful, Calc puts this command on the @kbd{M-# m} key.  Try reading in
-this macro in the following form:  Press @kbd{C-@@} (or @kbd{C-@key{SPC}}) at
+The @file{edmacro} package defines a handy @code{read-kbd-macro} command
+which reads the current region of the current buffer as a sequence of
+keystroke names, and defines that sequence on the @kbd{X} 
+(and @kbd{C-x e}) key.  Because this is so useful, Calc puts this
+command on the @kbd{M-# m} key.  Try reading in this macro in the
+following form:  Press @kbd{C-@@} (or @kbd{C-@key{SPC}}) at 
 one end of the text below, then type @kbd{M-# m} at the other.
 
 @example
@@ -30827,33 +30825,19 @@
 
 @cindex Keyboard macros, editing
 The @kbd{Z E} (@code{calc-user-define-edit}) command on a key that has
-been defined by a keyboard macro tries to use the @code{edit-kbd-macro}
-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{C-c C-c} to finish editing and update
+been defined by a keyboard macro tries to use the @code{edmacro} package
+edit the macro.  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{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-}
-and @code{M-}.  Spaces and line breaks are ignored.  Other characters are
+The special characters @code{RET}, @code{LFD}, @code{TAB}, @code{SPC},
+@code{DEL}, and @code{NUL} must be entered as these three character
+sequences, written in all uppercase, as must the prefixes @code{C-} and
+@code{M-}.  Spaces and line breaks are ignored.  Other characters are
 copied verbatim into the keyboard macro.  Basically, the notation is the
 same as is used in all of this manual's examples, except that the manual
-takes some liberties with spaces:  When we say @kbd{' [1 2 3] @key{RET}}, we take
-it for granted that it is clear we really mean @kbd{' [1 @key{SPC} 2 @key{SPC} 3] @key{RET}},
-which is what @code{read-kbd-macro} wants to see.
-
-If @file{macedit} is not available, @kbd{Z E} edits the keyboard macro
-in ``raw'' form; the editing buffer simply contains characters like
-@samp{1^M2+} (here @samp{^M} represents the carriage-return character).
-Editing in this mode, you will have to use @kbd{C-q} to enter new
-control characters into the buffer.
+takes some liberties with spaces: When we say @kbd{' [1 2 3] @key{RET}},
+we take it for granted that it is clear we really mean 
+@kbd{' [1 @key{SPC} 2 @key{SPC} 3] @key{RET}}.
 
 @kindex M-# m
 @pindex read-kbd-macro
@@ -30861,7 +30845,6 @@
 of spelled-out keystrokes and defines it as the current keyboard macro.
 It is a convenient way to define a keyboard macro that has been stored
 in a file, or to define a macro without executing it at the same time.
-The @kbd{M-# m} command works only if @file{macedit} is present.
 
 @node Conditionals in Macros, Loops in Macros, Naming Keyboard Macros, Keyboard Macros
 @subsection Conditionals in Keyboard Macros
--- a/man/custom.texi	Sun Jan 02 09:13:19 2005 +0000
+++ b/man/custom.texi	Sun Jan 02 09:21:32 2005 +0000
@@ -566,10 +566,15 @@
 attribute by invoking that field.  When the attribute is enabled, you
 can change the attribute value in the usual ways.
 
-  On a black-and-white display, the colors you can use for the
-background are @samp{black}, @samp{white}, @samp{gray}, @samp{gray1},
-and @samp{gray3}.  Emacs supports these shades of gray by using
-background stipple patterns instead of a color.
+  For the colors, you can specify a color name (use @kbd{M-x
+list-colors-display}) for a list of them) or a hexadecimal color
+specification of the form @samp{#@var{rr}@var{gg}@var{bb}}.
+(@samp{#000000} is black, @samp{#ff0000} is red, @samp{#00ff00} is
+green, @samp{#0000ff} is blue, and @samp{#ffffff} is white.)  On a
+black-and-white display, the colors you can use for the background are
+@samp{black}, @samp{white}, @samp{gray}, @samp{gray1}, and
+@samp{gray3}.  Emacs supports these shades of gray by using background
+stipple patterns instead of a color.
 
   Setting, saving and resetting a face work like the same operations for
 options (@pxref{Changing an Option}).
--- a/man/emacs.texi	Sun Jan 02 09:13:19 2005 +0000
+++ b/man/emacs.texi	Sun Jan 02 09:21:32 2005 +0000
@@ -278,13 +278,15 @@
 * Mark Ring::		Previous mark positions saved so you can go back there.
 * Global Mark Ring::	Previous mark positions in various buffers.
 
-Deletion and Killing
+Killing
 
 * Deletion::		Commands for deleting small amounts of text and
 			  blank areas.
 * Killing by Lines::	How to kill entire lines of text at one time.
 * Other Kill Commands:: Commands to kill large regions of text and
 			  syntactic units such as words and sentences.
+* Graphical Kill::      The kill ring on graphical terminals:
+                          yanking between applications.
 
 Yanking
 
--- a/man/killing.texi	Sun Jan 02 09:13:19 2005 +0000
+++ b/man/killing.texi	Sun Jan 02 09:21:32 2005 +0000
@@ -2,48 +2,47 @@
 @c Copyright (C) 1985,86,87,93,94,95,97,2000,2001,2004
 @c   Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
-@iftex
+
+@node Killing, Yanking, Mark, Top
 @chapter Killing and Moving Text
 
-  @dfn{Killing} means erasing text and copying it into the @dfn{kill
-ring}, from which it can be retrieved by @dfn{yanking} it.  Some systems
-use the terms ``cutting'' and ``pasting'' for these operations.
-
-  The most common way of moving or copying text within Emacs is to kill it
-and later yank it elsewhere in one or more places.  This is very safe
-because Emacs remembers several recent kills, not just the last one.  It
-is versatile, because the many commands for killing syntactic units can
-also be used for moving those units.  But there are other ways of
-copying text for special purposes.
-
-  On terminals that support multiple windows for multiple applications,
-the kill commands also provide a way to select text for other applications
-to copy, and the Emacs yank commands can access selections made by
-other programs.
-
-  Emacs has only one kill ring for all buffers, so you can kill text in
-one buffer and yank it in another buffer.
-
-@end iftex
-
 @ifnottex
 @raisesections
 @end ifnottex
 
-@node Killing, Yanking, Mark, Top
+  @dfn{Killing} means erasing text and copying it into the @dfn{kill
+ring}, from which you can bring it back into the buffer by
+@dfn{yanking} it.  (Some systems use the terms ``cutting'' and
+``pasting'' for these operations.)  This is the most common way of
+moving or copying text within Emacs.  Killing and yanking is very safe
+because Emacs remembers several recent kills, not just the last one.
+It is versatile, because the many commands for killing syntactic units
+can also be used for moving those units.  But there are other ways of
+copying text for special purposes.
+
+@iftex
 @section Deletion and Killing
+@end iftex
 
 @cindex killing text
 @cindex cutting text
 @cindex deletion
-  Most commands which erase text from the buffer save it in the @dfn{kill
-ring} so that you can move or copy it to other parts of the buffer.
-These commands are known as @dfn{kill} commands.  The rest of the
-commands that erase text do not save it in the kill ring; they are known
-as @dfn{delete} commands.  (This distinction is made only for erasure of
-text in the buffer.)  If you do a kill or delete command by mistake, you
-can use the @kbd{C-x u} (@code{undo}) command to undo it
-(@pxref{Undo}).
+  Most commands which erase text from the buffer save it in the kill
+ring.  These commands are known as @dfn{kill} commands.  The commands
+that erase text but do not save it in the kill ring are known as
+@dfn{delete} commands.  The @kbd{C-x u} (@code{undo}) command
+(@pxref{Undo}) can undo both kill and delete commands; the importance
+of the kill ring is that you can also yank the text in a different
+place or places.  Emacs has only one kill ring for all buffers, so you
+can kill text in one buffer and yank it in another buffer.
+
+  The delete commands include @kbd{C-d} (@code{delete-char}) and
+@key{DEL} (@code{delete-backward-char}), which delete only one
+character at a time, and those commands that delete only spaces or
+newlines.  Commands that can erase significant amounts of nontrivial
+data generally do a kill operation instead.  The commands' names and
+individual descriptions use the words @samp{kill} and @samp{delete} to
+say which kind of operation they perform.
 
 @vindex kill-read-only-ok
 @cindex read-only text, killing
@@ -52,34 +51,10 @@
 copy read-only text into the kill ring, without actually changing it.
 Therefore, the kill commands work specially in a read-only buffer:
 they move over text, and copy it to the kill ring, without actually
-deleting it from the buffer.  Normally, Emacs beeps and prints an
-error message when this happens.  But if you set the variable
-@code{kill-read-only-ok} to a non-@code{nil} value, it just prints a
-message in the echo area, telling you what is happening.
-
-  The delete commands include @kbd{C-d} (@code{delete-char}) and
-@key{DEL} (@code{delete-backward-char}), which delete only one
-character at a time, and those commands that delete only spaces or
-newlines.  Commands that can destroy significant amounts of nontrivial
-data generally do a kill operation instead.  The commands' names and
-individual descriptions use the words @samp{kill} and @samp{delete} to
-say which kind of operation they perform.
-
-  On window systems, the most recent kill done in Emacs is also the
-primary selection, if it is more recent than any selection you made in
-another program.  This means that the paste commands of other window
-applications copy the text that you killed in Emacs.
-
-@cindex Delete Selection mode
-@cindex mode, Delete Selection
-@findex delete-selection-mode
-  Many window systems follow the convention that insertion while text
-is selected deletes the selected text.  You can make Emacs behave this
-way by enabling Delete Selection mode, with @kbd{M-x
-delete-selection-mode}, or using Custom.  Another effect of this mode
-is that @key{DEL}, @kbd{C-d} and some other keys, when a selection
-exists, will kill the whole selection.  It also enables Transient Mark
-mode (@pxref{Transient Mark}).
+deleting it from the buffer.  Normally, kill commands beep and display
+an error message when this happens.  But if you set the variable
+@code{kill-read-only-ok} to a non-@code{nil} value, they just print a
+message in the echo area to explain why the text has not been erased.
 
 @menu
 * Deletion::            Commands for deleting small amounts of text and
@@ -87,6 +62,8 @@
 * Killing by Lines::    How to kill entire lines of text at one time.
 * Other Kill Commands:: Commands to kill large regions of text and
                           syntactic units such as words and sentences.
+* Graphical Kill::      The kill ring on graphical terminals:
+                          yanking between applications.
 @end menu
 
 @need 1500
@@ -270,6 +247,27 @@
 they copy in this way, so that successive kill commands build up a
 single kill ring entry as usual.
 
+@node Graphical Kill
+@subsection Killing on Graphical Terminals
+
+  On multi-window terminals, the most recent kill done in Emacs is
+also the primary selection, if it is more recent than any selection
+you made in another program.  This means that the paste commands of
+other applications with separate windows copy the text that you killed
+in Emacs.  In addition, Emacs yank commands treat other applications'
+selections as part of the kill ring, so you can yank them into Emacs.
+
+@cindex Delete Selection mode
+@cindex mode, Delete Selection
+@findex delete-selection-mode
+  Many window systems follow the convention that insertion while text
+is selected deletes the selected text.  You can make Emacs behave this
+way by enabling Delete Selection mode, with @kbd{M-x
+delete-selection-mode}, or using Custom.  Another effect of this mode
+is that @key{DEL}, @kbd{C-d} and some other keys, when a selection
+exists, will kill the whole selection.  It also enables Transient Mark
+mode (@pxref{Transient Mark}).
+
 @node Yanking, Accumulating Text, Killing, Top
 @section Yanking
 @cindex moving text
--- a/src/ChangeLog	Sun Jan 02 09:13:19 2005 +0000
+++ b/src/ChangeLog	Sun Jan 02 09:21:32 2005 +0000
@@ -4,6 +4,19 @@
 
 2004-12-31  Richard M. Stallman  <rms@gnu.org>
 
+	* xdisp.c (setup_for_ellipsis, get_next_display_element):
+	Set it->ellipsis_p to 1 or 0.
+	(display_line): Record whether row ends in mid-ellipsis.
+	(set_cursor_from_row): If ends in ellipsis. find start of it.
+	(cursor_row_p): If PT's at the end of the ellipsis the row
+	ends within, don't display cursor on this row.
+
+	* dispextern.h (struct it): New element ellipsis_p.
+	(struct glyph_row): New element ends_in_ellipsis_p.
+
+	* xdisp.c (BUFFER_POS_REACHED_P): We haven't reached the specified
+	position if we're reading from something other than the buffer.
+
 	* 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.
--- a/src/dispextern.h	Sun Jan 02 09:13:19 2005 +0000
+++ b/src/dispextern.h	Sun Jan 02 09:21:32 2005 +0000
@@ -817,6 +817,9 @@
   /* 1 means this row currently shows the cursor in the right fringe.  */
   unsigned cursor_in_fringe_p : 1;
 
+  /* 1 means the last glyph in the row is part of an ellipsis.  */
+  unsigned ends_in_ellipsis_p : 1;
+
   /* Non-zero means display a bitmap on X frames indicating that this
      the first line of the buffer.  */
   unsigned indicate_bob_p : 1;
@@ -1819,6 +1822,10 @@
      Don't handle some `display' properties in these strings.  */
   unsigned string_from_display_prop_p : 1;
 
+  /* When METHOD == next_element_from_display_vector,
+     this is 1 if we're doing an ellipsis.  Otherwise meaningless.  */
+  unsigned ellipsis_p : 1;
+
   /* Display table in effect or null for none.  */
   struct Lisp_Char_Table *dp;
 
--- a/src/xdisp.c	Sun Jan 02 09:13:19 2005 +0000
+++ b/src/xdisp.c	Sun Jan 02 09:21:32 2005 +0000
@@ -3273,6 +3273,7 @@
      IT's face is restored in set_iterator_to_next.  */
   it->saved_face_id = it->face_id;
   it->method = next_element_from_display_vector;
+  it->ellipsis_p = 1;
 }
 
 
@@ -5008,6 +5009,7 @@
 		  it->current.dpvec_index = 0;
 		  it->saved_face_id = it->face_id;
 		  it->method = next_element_from_display_vector;
+		  it->ellipsis_p = 0;
 		}
 	      else
 		{
@@ -5159,6 +5161,7 @@
 	      it->current.dpvec_index = 0;
 	      it->saved_face_id = it->face_id;
 	      it->method = next_element_from_display_vector;
+	      it->ellipsis_p = 0;
 	      goto get_next;
 	    }
 	}
@@ -5804,10 +5807,11 @@
   saved_glyph_row = it->glyph_row;
   it->glyph_row = NULL;
 
-#define BUFFER_POS_REACHED_P()			    \
-  ((op & MOVE_TO_POS) != 0			    \
-   && BUFFERP (it->object)			    \
-   && IT_CHARPOS (*it) >= to_charpos)
+#define BUFFER_POS_REACHED_P()			\
+  ((op & MOVE_TO_POS) != 0			\
+   && BUFFERP (it->object)			\
+   && IT_CHARPOS (*it) >= to_charpos		\
+   && it->method == next_element_from_buffer)
 
   while (1)
     {
@@ -10914,6 +10918,18 @@
       glyph = cursor;
       x = cursor_x;
     }
+  else if (row->ends_in_ellipsis_p && glyph == end)
+    {
+      /* Scan back over the ellipsis glyphs, decrementing positions.  */
+      while (glyph > row->glyphs[TEXT_AREA]
+	     && (glyph - 1)->charpos == last_pos)
+	glyph--, x -= glyph->pixel_width;
+      /* That loop always goes one position too far,
+	 including the glyph before the ellipsis.
+	 So scan forward over that one.  */
+      x += glyph->pixel_width;
+      glyph++;
+    }
   else if (string_start
 	   && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
     {
@@ -14715,10 +14731,22 @@
       /* If the row ends with a newline from a string, we don't want
 	 the cursor there (if the row is continued it doesn't end in a
 	 newline).  */
-      if (CHARPOS (row->end.string_pos) >= 0
-	  || MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))
+      if (CHARPOS (row->end.string_pos) >= 0)
 	cursor_row_p = row->continued_p;
-
+      else if (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))
+	{
+	  /* If the row ends in middle of a real character,
+	     and the line is continued, we want the cursor here.
+	     That's because MATRIX_ROW_END_CHARPOS would equal
+	     PT if PT is before the character.  */
+	  if (!row->ends_in_ellipsis_p)
+	    cursor_row_p = row->continued_p;
+	  else
+	  /* If the row ends in an ellipsis, then
+	     MATRIX_ROW_END_CHARPOS will equal point after the invisible text.
+	     We want that position to be displayed after the ellipsis.  */
+	    cursor_row_p = 0;
+	}
       /* If the row ends at ZV, display the cursor at the end of that
 	 row instead of at the start of the row below.  */
       else if (row->ends_at_zv_p)
@@ -15195,6 +15223,11 @@
   /* Remember the position at which this line ends.  */
   row->end = it->current;
 
+  /* Record whether this row ends inside an ellipsis.  */
+  row->ends_in_ellipsis_p
+    = (it->method == next_element_from_display_vector
+       && it->ellipsis_p);
+
   /* Save fringe bitmaps in this row.  */
   row->left_user_fringe_bitmap = it->left_user_fringe_bitmap;
   row->left_user_fringe_face_id = it->left_user_fringe_face_id;