changeset 89995:58db929d96c6

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-50 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-587 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-588 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-589 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-590 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-593 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-39 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-40 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-41 Update from CVS
author Miles Bader <miles@gnu.org>
date Mon, 04 Oct 2004 01:04:18 +0000
parents 298e7fb11b61 (current diff) 8d5af2441eda (diff)
children d13df8a735d7
files lisp/ChangeLog lisp/edmacro.el lisp/gnus/ChangeLog lisp/gnus/gnus-sum.el lisp/gnus/mailcap.el lisp/indent.el lisp/kmacro.el lisp/newcomment.el lisp/progmodes/cc-langs.el lisp/term.el lisp/textmodes/tex-mode.el src/ChangeLog src/fileio.c
diffstat 13 files changed, 305 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/ChangeLog	Mon Oct 04 01:04:18 2004 +0000
@@ -1,7 +1,58 @@
+2004-10-03  Stefan  <monnier@iro.umontreal.ca>
+
+	* textmodes/tex-mode.el (tex-dvi-view-command): Use `yap' on w32.
+	(tex-font-lock-keywords-1): Add url and nolinkurl for args with `_'.
+	(latex-block-args-alist): Add minipage and picture.
+	(latex-block-body-alist): Use reftex-label if enabled.
+	(latex-insert-block): Don't insert a \n if not necessary.
+	(tex-compile-commands): Make sure dvips doesn't send to printer.
+	(tex-compile-default): Handle the case where no executable is found.
+	(latex-noindent-environments): New var.
+	(latex-find-indent): Use it.  Take an empty line as an arg-breaker.
+	If tex-indent-allhanging is non-nil, make sure we only align for macros
+	at beginning of line.
+
+2004-10-03  Daniel Pfeiffer  <occitan@esperanto.org>
+
+	* newcomment.el (comment-beginning): Doc fix and don't choke on
+	unset `comment-end-skip' when at beginning of comment.
+
+2004-10-02  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* term.el (term-adjust-current-row-cache): Don't allow the current
+	row to become negative.
+	(term-emulate-terminal): Fix insert mode. Handle tab insertion at
+	the end of the line. Fix scroll down. Add comments.
+	(term-handle-ansi-escape): Don't exceed terminal width when moving
+	right.
+	(term-scroll-region): Move the cursor after setting the scroll region.
+
+2004-10-01  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* indent.el (set-left-margin, set-right-margin): Rename `lm' arg
+	to `width' for consistency with docstring.  Doc fix.
+
+2004-10-01  Martin Stjernholm  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-langs.el: Load cl here since cc-defs doesn't do it.
+	This is necessary for derived modes.
+
+2004-09-30  Kim F. Storm  <storm@cua.dk>
+
+	* kmacro.el (kmacro-lambda-form, kmacro-extract-lambda): Add.
+	(kmacro-bind-to-key, kmacro-name-last-macro): Use kmacro-lambda-form.
+
+	* edmacro.el: Require kmacro to use the new kmacro-lambda-form and
+	kmacro-extract-lambda functions.
+	(edit-kbd-macro): Handle kmacro lambda forms.
+	Include counter and counter format in edit buffer.
+	(edmacro-finish-edit): Get counter and format from edit buffer and
+	update kmacro bindings when found.
+
 2004-09-29  Luc Teirlinck  <teirllm@auburn.edu>
 
-	* textmodes/paragraphs.el (forward-paragraph): Avoid
-	args-out-of-range error when point winds up at the beginning of
+	* textmodes/paragraphs.el (forward-paragraph):
+	Avoid args-out-of-range error when point winds up at the beginning of
 	the buffer and hard newlines are enabled.
 
 	* newcomment.el (comment-multi-line): Doc fix.
--- a/lisp/edmacro.el	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/edmacro.el	Mon Oct 04 01:04:18 2004 +0000
@@ -73,6 +73,8 @@
 (eval-when-compile
  (require 'cl))
 
+(require 'kmacro)
+
 ;;; The user-level commands for editing macros.
 
 ;;;###autoload
@@ -101,7 +103,8 @@
   (interactive "kKeyboard macro to edit (C-x e, M-x, C-h l, or keys): \nP")
   (when keys
     (let ((cmd (if (arrayp keys) (key-binding keys) keys))
-	  (mac nil))
+	  (mac nil) (mac-counter nil) (mac-format nil)
+	  kmacro)
       (cond (store-hook
 	     (setq mac keys)
 	     (setq cmd nil))
@@ -112,14 +115,17 @@
 		 (y-or-n-p "No keyboard macro defined.  Create one? ")
 		 (keyboard-quit))
 	     (setq mac (or last-kbd-macro ""))
+	     (setq keys nil)
 	     (setq cmd 'last-kbd-macro))
 	    ((eq cmd 'execute-extended-command)
 	     (setq cmd (read-command "Name of keyboard macro to edit: "))
 	     (if (string-equal cmd "")
 		 (error "No command name given"))
+	     (setq keys nil)
 	     (setq mac (symbol-function cmd)))
 	    ((memq cmd '(view-lossage electric-view-lossage))
 	     (setq mac (recent-keys))
+	     (setq keys nil)
 	     (setq cmd 'last-kbd-macro))
 	    ((null cmd)
 	     (error "Key sequence %s is not defined" (key-description keys)))
@@ -128,6 +134,10 @@
 	    (t
 	     (setq mac cmd)
 	     (setq cmd nil)))
+      (when (setq kmacro (kmacro-extract-lambda mac))
+	(setq mac (car kmacro)
+	      mac-counter (nth 1 kmacro)
+	      mac-format (nth 2 kmacro)))
       (unless (arrayp mac)
 	(error "Key sequence %s is not a keyboard macro"
 	       (key-description keys)))
@@ -153,11 +163,15 @@
 	(insert ";; Original keys: " fmt "\n")
 	(unless store-hook
 	  (insert "\nCommand: " (if cmd (symbol-name cmd) "none") "\n")
-	  (let ((keys (where-is-internal (or cmd mac) '(keymap))))
-	    (if keys
-		(while keys
-		  (insert "Key: " (edmacro-format-keys (pop keys) 1) "\n"))
-	      (insert "Key: none\n"))))
+	  (let ((gkeys (where-is-internal (or cmd mac) '(keymap))))
+	    (if (and keys (not (member keys gkeys)))
+		(setq gkeys (cons keys gkeys)))
+	    (if gkeys
+		(while gkeys
+		  (insert "Key: " (edmacro-format-keys (pop gkeys) 1) "\n"))
+	      (insert "Key: none\n")))
+	  (when (and mac-counter mac-format)
+	    (insert (format "Counter: %d\nFormat: \"%s\"\n" mac-counter mac-format))))
 	(insert "\nMacro:\n\n")
 	(save-excursion
 	  (insert fmtv "\n"))
@@ -217,6 +231,7 @@
      "This command is valid only in buffers created by `edit-kbd-macro'"))
   (run-hooks 'edmacro-finish-hook)
   (let ((cmd nil) (keys nil) (no-keys nil)
+	(mac-counter nil) (mac-format nil) (kmacro nil)
 	(top (point-min)))
     (goto-char top)
     (let ((case-fold-search nil))
@@ -231,6 +246,7 @@
 			(setq cmd (and (not (equal str "none"))
 				       (intern str)))
 			(and (fboundp cmd) (not (arrayp (symbol-function cmd)))
+			     (not (setq kmacro (get cmd 'kmacro)))
 			     (not (y-or-n-p
 				   (format "Command %s is already defined; %s"
 					   cmd "proceed? ")))
@@ -248,6 +264,7 @@
 			  (push key keys)
 			  (let ((b (key-binding key)))
 			    (and b (commandp b) (not (arrayp b))
+				 (not (kmacro-extract-lambda b))
 				 (or (not (fboundp b))
 				     (not (arrayp (symbol-function b))))
 				 (not (y-or-n-p
@@ -256,6 +273,22 @@
 					       "proceed? ")))
 				 (keyboard-quit))))))
 		    t)
+		   ((looking-at "Counter:[ \t]*\\([^ \t\n]*\\)[ \t]*$")
+		    (when edmacro-store-hook
+		      (error "\"Counter\" line not allowed in this context"))
+		    (let ((str (buffer-substring (match-beginning 1)
+						 (match-end 1))))
+		      (unless (equal str "")
+			(setq mac-counter (string-to-int str))))
+		    t)
+		   ((looking-at "Format:[ \t]*\"\\([^\n]*\\)\"[ \t]*$")
+		    (when edmacro-store-hook
+		      (error "\"Format\" line not allowed in this context"))
+		    (let ((str (buffer-substring (match-beginning 1)
+						 (match-end 1))))
+		      (unless (equal str "")
+			(setq mac-format str)))
+		    t)
 		   ((looking-at "Macro:[ \t\n]*")
 		    (goto-char (match-end 0))
 		    nil)
@@ -285,7 +318,10 @@
 	    (when cmd
 	      (if (= (length mac) 0)
 		  (fmakunbound cmd)
-		(fset cmd mac)))
+		(fset cmd
+		      (if (and mac-counter mac-format)
+			  (kmacro-lambda-form mac mac-counter mac-format)
+			mac))))
 	    (if no-keys
 		(when cmd
 		  (loop for key in (where-is-internal cmd '(keymap)) do
@@ -294,7 +330,11 @@
 		(if (= (length mac) 0)
 		    (loop for key in keys do (global-unset-key key))
 		  (loop for key in keys do
-			(global-set-key key (or cmd mac)))))))))
+			(global-set-key key
+					(or cmd
+					    (if (and mac-counter mac-format)
+						(kmacro-lambda-form mac mac-counter mac-format)
+					      mac))))))))))
       (kill-buffer buf)
       (when (buffer-name obuf)
 	(switch-to-buffer obuf))
--- a/lisp/gnus/ChangeLog	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/gnus/ChangeLog	Mon Oct 04 01:04:18 2004 +0000
@@ -1,3 +1,13 @@
+2004-10-01  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-sum.el (gnus-summary-toggle-header): Make it work even if
+	there's no visible header.
+
+2004-10-01  Simon Josefsson  <jas@extundo.com>
+
+	* mailcap.el (mailcap-mime-data): Add pdf.  Remove non-free
+	acroread.
+
 2004-09-29  Jesper Harder  <harder@ifa.au.dk>
 
 	* gnus.el (gnus-method-to-server): Oops, move it don't delete it.
--- a/lisp/gnus/gnus-sum.el	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/gnus/gnus-sum.el	Mon Oct 04 01:04:18 2004 +0000
@@ -8732,7 +8732,8 @@
 	     (inhibit-point-motion-hooks t)
 	     (hidden (if (numberp arg)
 			 (>= arg 0)
-		       (gnus-article-hidden-text-p 'headers)))
+		       (or (not (looking-at "[^ \t\n]+:"))
+			   (gnus-article-hidden-text-p 'headers))))
 	     s e)
 	(delete-region (point-min) (point-max))
 	(with-current-buffer gnus-original-article-buffer
--- a/lisp/gnus/mailcap.el	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/gnus/mailcap.el	Mon Oct 04 01:04:18 2004 +0000
@@ -1,5 +1,5 @@
 ;;; mailcap.el --- MIME media types configuration
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
 ;;       Free Software Foundation, Inc.
 
 ;; Author: William M. Perry <wmperry@aventail.com>
@@ -135,23 +135,21 @@
       (non-viewer . t)
       (type   . "application/zip")
       ("copiousoutput"))
-     ;; Prefer free viewers.
      ("pdf"
       (viewer . "gv -safer %s")
       (type . "application/pdf")
       (test . window-system)
       ("print" . ,(concat "pdf2ps %s - | " mailcap-print-command)))
      ("pdf"
-      (viewer . "xpdf %s")
+      (viewer . "gpdf %s")
       (type . "application/pdf")
       ("print" . ,(concat "pdftops %s - | " mailcap-print-command))
       (test . (eq window-system 'x)))
      ("pdf"
-      (viewer . "acroread %s")
-      (type   . "application/pdf")
-      ("print" . ,(concat "cat %s | acroread -toPostScript | "
-			  mailcap-print-command))
-      (test . window-system))
+      (viewer . "xpdf %s")
+      (type . "application/pdf")
+      ("print" . ,(concat "pdftops %s - | " mailcap-print-command))
+      (test . (eq window-system 'x)))
      ("pdf"
       (viewer . ,(concat "pdftotext %s -"))
       (type   . "application/pdf")
--- a/lisp/indent.el	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/indent.el	Mon Oct 04 01:04:18 2004 +0000
@@ -1,6 +1,6 @@
 ;;; indent.el --- indentation commands for Emacs
 
-;; Copyright (C) 1985, 1995, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1995, 2001, 2004 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 
@@ -198,11 +198,14 @@
       (forward-line 1))
     (move-marker to nil)))
 
-(defun set-left-margin (from to lm)
+(defun set-left-margin (from to width)
   "Set the left margin of the region to WIDTH.
-If `auto-fill-mode' is active, re-fill the region to fit the new margin."
+If `auto-fill-mode' is active, re-fill the region to fit the new margin.
+
+Interactively, WIDTH is the prefix argument, if specified.
+Without prefix argument, the command prompts for WIDTH."
   (interactive "r\nNSet left margin to column: ")
-  (if (interactive-p) (setq lm (prefix-numeric-value lm)))
+  (if (interactive-p) (setq width (prefix-numeric-value width)))
   (save-excursion
     ;; If inside indentation, start from BOL.
     (goto-char from)
@@ -214,21 +217,24 @@
     (setq to (point-marker)))
   ;; Delete margin indentation first, but keep paragraph indentation.
   (delete-to-left-margin from to)
-  (put-text-property from to 'left-margin lm)
-  (indent-rigidly from to lm)
+  (put-text-property from to 'left-margin width)
+  (indent-rigidly from to width)
   (if auto-fill-function (save-excursion (fill-region from to nil t t)))
   (move-marker to nil))
 
-(defun set-right-margin (from to lm)
+(defun set-right-margin (from to width)
   "Set the right margin of the region to WIDTH.
-If `auto-fill-mode' is active, re-fill the region to fit the new margin."
+If `auto-fill-mode' is active, re-fill the region to fit the new margin.
+
+Interactively, WIDTH is the prefix argument, if specified.
+Without prefix argument, the command prompts for WIDTH."
   (interactive "r\nNSet right margin to width: ")
-  (if (interactive-p) (setq lm (prefix-numeric-value lm)))
+  (if (interactive-p) (setq width (prefix-numeric-value width)))
   (save-excursion
     (goto-char from)
     (skip-chars-backward " \t")
     (if (bolp) (setq from (point))))
-  (put-text-property from to 'right-margin lm)
+  (put-text-property from to 'right-margin width)
   (if auto-fill-function (save-excursion (fill-region from to nil t t))))
 
 (defun alter-text-property (from to prop func &optional object)
--- a/lisp/kmacro.el	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/kmacro.el	Mon Oct 04 01:04:18 2004 +0000
@@ -740,6 +740,30 @@
 ;; letters and digits, provided that we inhibit the keymap while
 ;; executing the macro later on (but that's controversial...)
 
+(defun kmacro-lambda-form (mac &optional counter format)
+  "Create lambda form for macro bound to symbol or key."
+  (if counter
+      (setq mac (list mac counter format)))
+  `(lambda (&optional arg)
+     "Keyboard macro."
+     (interactive "p")
+     (kmacro-exec-ring-item ',mac arg)))
+
+(defun kmacro-extract-lambda (mac)
+  "Extract kmacro from a kmacro lambda form."
+  (and (consp mac)
+       (eq (car mac) 'lambda)
+       (setq mac (assoc 'kmacro-exec-ring-item mac))
+       (consp (cdr mac))
+       (consp (car (cdr mac)))
+       (consp (cdr (car (cdr mac))))
+       (setq mac (car (cdr (car (cdr mac)))))
+       (listp mac)
+       (= (length mac) 3)
+       (arrayp (car mac))
+       mac))
+
+
 (defun kmacro-bind-to-key (arg)
   "When not defining or executing a macro, offer to bind last macro to a key.
 The key sequences [C-x C-k 0] through [C-x C-k 9] and [C-x C-k A]
@@ -775,10 +799,7 @@
 					  (format-kbd-macro key-seq)
 					  cmd))))
 	(define-key global-map key-seq
-	  `(lambda (&optional arg)
-	     "Keyboard macro."
-	     (interactive "p")
-	     (kmacro-exec-ring-item ',(kmacro-ring-head) arg)))
+	  (kmacro-lambda-form (kmacro-ring-head)))
 	(message "Keyboard macro bound to %s" (format-kbd-macro key-seq))))))
 
 
@@ -798,11 +819,7 @@
 	      symbol))
   (if (string-equal symbol "")
       (error "No command name given"))
-  (fset symbol
-	`(lambda (&optional arg)
-	   "Keyboard macro."
-	   (interactive "p")
-	   (kmacro-exec-ring-item ',(kmacro-ring-head) arg)))
+  (fset symbol (kmacro-lambda-form (kmacro-ring-head)))
   (put symbol 'kmacro t))
 
 
--- a/lisp/newcomment.el	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/newcomment.el	Mon Oct 04 01:04:18 2004 +0000
@@ -423,7 +423,7 @@
 (defun comment-beginning ()
   "Find the beginning of the enclosing comment.
 Returns nil if not inside a comment, else moves point and returns
-the same as `comment-search-forward'."
+the same as `comment-search-backward'."
   ;; HACK ATTACK!
   ;; We should really test `in-string-p' but that can be expensive.
   (unless (eq (get-text-property (point) 'face) 'font-lock-string-face)
@@ -435,7 +435,7 @@
 	      (and
 	       ;; For modes where comment-start and comment-end are the same,
 	       ;; the search above may have found a `ce' rather than a `cs'.
-	       (or (not (looking-at comment-end-skip))
+	       (or (if comment-end-skip (not (looking-at comment-end-skip)))
 		   ;; Maybe font-lock knows that it's a `cs'?
 		   (eq (get-text-property (match-end 0) 'face)
 		       'font-lock-comment-face)
--- a/lisp/progmodes/cc-langs.el	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/progmodes/cc-langs.el	Mon Oct 04 01:04:18 2004 +0000
@@ -124,6 +124,9 @@
 (cc-require 'cc-defs)
 (cc-require 'cc-vars)
 
+;; This file is not always loaded.  See note above.
+(cc-external-require 'cl)
+
 
 ;;; Setup for the `c-lang-defvar' system.
 
--- a/lisp/term.el	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/term.el	Mon Oct 04 01:04:18 2004 +0000
@@ -2586,8 +2586,9 @@
 		   (- (term-vertical-motion -9999))))))))
 
 (defun term-adjust-current-row-cache (delta)
-  (if term-current-row
-      (setq term-current-row (+ term-current-row delta))))
+  (when term-current-row
+    (setq term-current-row 
+	  (max 0 (+ term-current-row delta)))))
 
 (defun term-terminal-pos ()
   (save-excursion ;    save-restriction
@@ -2762,7 +2763,17 @@
 			    (when (not (or (eobp) term-insert-mode))
 			      (setq pos (point))
 			      (term-move-columns columns)
-			      (delete-region pos (point))))
+			      (delete-region pos (point)))
+			    ;; In insert if the if the current line
+			    ;; has become too long it needs to be
+			    ;; chopped off.
+			    (when term-insert-mode 
+			      (setq pos (point))
+			      (end-of-line)
+			      (when (> (current-column) term-width)
+				(delete-region (- (point) (- (current-column) term-width)) 
+					       (point)))
+			      (goto-char pos)))
 			  (setq term-current-column nil)
 
 			  (put-text-property old-point (point)
@@ -2776,12 +2787,21 @@
 			  (setq i (1- funny)))
 			 ((and (setq term-terminal-state 0)
 			       (eq char ?\^I)) ; TAB (terminfo: ht)
-			  ;; FIXME:  Does not handle line wrap!
 			  (setq count (term-current-column))
-			  (setq count (+ count 8 (- (mod count 8))))
-			  (if (< (move-to-column count nil) count)
-			      (term-insert-char char 1))
-			  (setq term-current-column count))
+			  ;; The line cannot exceed term-width. TAB at
+			  ;; the end of a line should not cause wrapping.
+			  (setq count (min term-width 
+					   (+ count 8 (- (mod count 8)))))
+			  (if (> term-width count)
+			    (progn
+			      (term-move-columns 
+			       (- count (term-current-column)))
+			      (setq term-current-column count))
+			    (when (> term-width (term-current-column))
+			      (term-move-columns 
+			       (1- (- term-width (term-current-column)))))
+			    (when (= term-width (term-current-column))
+			      (term-move-columns -1))))
 			 ((eq char ?\r)
 			  ;; Optimize CRLF at end of buffer:
 			  (cond ((and (< (setq temp (1+ i)) str-length)
@@ -2849,8 +2869,14 @@
 			  (term-handle-deferred-scroll)
 			  (term-down 1 t)
 			  (setq term-terminal-state 0))
-			 ((eq char ?M) ;; scroll reversed
-			  (term-insert-lines 1)
+			 ;; ((eq char ?E) ;; (terminfo: nw), not used for
+			 ;; 	       ;; now, but this is a working
+			 ;; 	       ;; implementation
+			 ;;  (term-down 1)
+			 ;;  (term-goto term-current-row 0)
+			 ;;  (setq term-terminal-state 0))
+			 ((eq char ?M) ;; scroll reversed (terminfo: ri)
+			  (term-down -1)
 			  (setq term-terminal-state 0))
 			 ((eq char ?7) ;; Save cursor (terminfo: sc)
 			  (term-handle-deferred-scroll)
@@ -2863,6 +2889,13 @@
 			      (term-goto (car term-saved-cursor)
 					 (cdr term-saved-cursor)))
 			  (setq term-terminal-state 0))
+			 ;; The \E#8 reset sequence for xterm. We
+			 ;; probably don't need to handle it, but this
+			 ;; is the code to parse it.
+			 ;; ((eq char ?#)
+			 ;;  (when (eq (aref str (1+ i)) ?8)
+			 ;;    (setq i (1+ i))
+			 ;;    (setq term-terminal-state 0)))
 			 ((setq term-terminal-state 0))))
 		  ((eq term-terminal-state 3) ; Seen Esc [
 		   (cond ((and (>= char ?0) (<= char ?9))
@@ -3119,7 +3152,10 @@
 
 (defun term-handle-ansi-escape (proc char)
   (cond
-   ((eq char ?H) ; cursor motion
+   ((or (eq char ?H)  ; cursor motion (terminfo: cup)
+	;; (eq char ?f) ; xterm seems to handle this sequence too, not
+	;; needed for now
+	) 
     (if (<= term-terminal-parameter 0)
 	(setq term-terminal-parameter 1))
     (if (<= term-terminal-previous-parameter 0)
@@ -3131,17 +3167,21 @@
     (term-goto
      (1- term-terminal-previous-parameter)
      (1- term-terminal-parameter)))
-   ;; \E[A - cursor up (terminfo: cuu1)
+   ;; \E[A - cursor up (terminfo: cuu, cuu1)
    ((eq char ?A)
     (term-handle-deferred-scroll)
     (term-down (- (max 1 term-terminal-parameter)) t))
-   ;; \E[B - cursor down
+   ;; \E[B - cursor down (terminfo: cud)
    ((eq char ?B)
     (term-down (max 1 term-terminal-parameter) t))
-   ;; \E[C - cursor right
+   ;; \E[C - cursor right (terminfo: cuf)
    ((eq char ?C)
-    (term-move-columns (max 1 term-terminal-parameter)))
-   ;; \E[D - cursor left
+    (term-move-columns 
+     (max 1 
+	  (if (>= (+ term-terminal-parameter (term-current-column)) term-width)
+	      (- term-width (term-current-column)  1)
+	    term-terminal-parameter))))
+   ;; \E[D - cursor left (terminfo: cub)
    ((eq char ?D)
     (term-move-columns (- (max 1 term-terminal-parameter))))
    ;; \E[J - clear to end of screen (terminfo: ed, clear)
@@ -3199,7 +3239,7 @@
 				 (1+ (term-current-row))
 				 (1+ (term-horizontal-column)))))
    ;; \E[r - Set scrolling region
-   ((eq char ?r)
+   ((eq char ?r) ;; (terminfo: csr)
     (term-scroll-region
      (1- term-terminal-previous-parameter)
      term-terminal-parameter))
@@ -3221,7 +3261,10 @@
   (setq term-scroll-with-delete
 	(or (term-using-alternate-sub-buffer)
 	    (not (and (= term-scroll-start 0)
-		      (= term-scroll-end term-height))))))
+		      (= term-scroll-end term-height)))))
+  (term-move-columns (- (term-current-column)))
+  (term-goto 
+   term-scroll-start (term-current-column)))
 
 ;; (defun term-switch-to-alternate-sub-buffer (set)
 ;;   ;; If asked to switch to (from) the alternate sub-buffer, and already (not)
@@ -3599,8 +3642,8 @@
 	      (end-region (if (eq kind 1) (point) (point-max))))
 	   (delete-region start-region end-region)
 	   (term-unwrap-line)
-	   (if (eq kind 1)
-	       (term-insert-char ?\n row))
+	   (when (eq kind 1)
+	     (term-insert-char ?\n row))
 	   (setq term-current-column nil)
 	   (setq term-current-row nil)
 	   (term-goto row col)))))
--- a/lisp/textmodes/tex-mode.el	Fri Oct 01 08:18:00 2004 +0000
+++ b/lisp/textmodes/tex-mode.el	Mon Oct 04 01:04:18 2004 +0000
@@ -1,7 +1,7 @@
 ;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands -*- coding: utf-8 -*-
 
-;; Copyright (C) 1985,86,89,92,94,95,96,97,98,1999,2002,03,2004
-;;       Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1989, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
+;;   2002, 2003, 2004  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: tex
@@ -196,7 +196,11 @@
   :group 'tex-view)
 
 ;;;###autoload
-(defcustom tex-dvi-view-command '(if (eq window-system 'x) "xdvi" "dvi2tty * | cat -s")
+(defcustom tex-dvi-view-command
+  '(cond
+    ((eq window-system 'x) "xdvi")
+    ((eq window-system 'w32) "yap") 
+    (t "dvi2tty * | cat -s"))
   "*Command used by \\[tex-view] to display a `.dvi' file.
 If it is a string, that specifies the command directly.
 If this string contains an asterisk (`*'), that is replaced by the file name;
@@ -453,7 +457,8 @@
 		      '("input" "include" "includeonly" "bibliography"
 			"epsfig" "psfig" "epsf" "nofiles" "usepackage"
 			"documentstyle" "documentclass" "verbatiminput"
-			"includegraphics" "includegraphics*")
+			"includegraphics" "includegraphics*"
+			"url" "nolinkurl")
 		      t))
 	   ;; Miscellany.
 	   (slash "\\\\")
@@ -771,8 +776,10 @@
 				    "part" "chapter" "newcommand"
 				    "renewcommand") 'words)
 		      "\\|NeedsTeXFormat{LaTeX")))
-		  (if (looking-at
-		       "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}")
+		  (if (and (looking-at
+			    "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}")
+			   ;; SliTeX is almost never used any more nowadays.
+			   (tex-executable-exists-p slitex-run-command))
 		      'slitex-mode
 		    'latex-mode)
 		'plain-tex-mode))))
@@ -1219,8 +1226,13 @@
 (defvar latex-block-default "enumerate")
 
 (defvar latex-block-args-alist
-  '(("array" nil ?\{ (skeleton-read "[options]: ") ?\})
-    ("tabular" nil ?\{ (skeleton-read "[options]: ") ?\}))
+  '(("array" nil ?\{ (skeleton-read "Format: ") ?\})
+    ("tabular" nil ?\{ (skeleton-read "Format: ") ?\})
+    ("minipage" nil ?\{ (skeleton-read "Size: ") ?\})
+    ("picture" nil ?\( (skeleton-read "SizeX,SizeY: ") ?\))
+    ;; FIXME: This is right for Prosper, but not for seminar.
+    ;; ("slide" nil ?\{ (skeleton-read "Title: ") ?\})
+    )
   "Skeleton element to use for arguments to particular environments.
 Every element of the list has the form (NAME . SKEL-ELEM) where NAME is
 the name of the environment and SKEL-ELEM is an element to use in
@@ -1229,8 +1241,11 @@
 (defvar latex-block-body-alist
   '(("enumerate" nil '(latex-insert-item) > _)
     ("itemize" nil '(latex-insert-item) > _)
-    ("table" nil "\\caption{" > - "}" > \n _)
-    ("figure" nil  > _ \n "\\caption{" > _ "}" >))
+    ("table" nil "\\caption{" > (skeleton-read "Caption: ") "}" > \n
+     '(if (and (boundp 'reftex-mode) reftex-mode) (reftex-label "table"))
+     \n _)
+    ("figure" nil  > _ \n "\\caption{" > (skeleton-read "Caption: ") "}" > \n
+     '(if (and (boundp 'reftex-mode) reftex-mode) (reftex-label "table"))))
   "Skeleton element to use for the body of particular environments.
 Every element of the list has the form (NAME . SKEL-ELEM) where NAME is
 the name of the environment and SKEL-ELEM is an element to use in
@@ -1254,7 +1269,8 @@
     choice)
   \n "\\begin{" str "}"
   (cdr (assoc str latex-block-args-alist))
-  > \n (or (cdr (assoc str latex-block-body-alist)) '(nil > _)) \n
+  > \n (or (cdr (assoc str latex-block-body-alist)) '(nil > _))
+  (unless (bolp) '\n)
   "\\end{" str "}" > \n)
 
 (define-skeleton latex-insert-item
@@ -1598,7 +1614,7 @@
     ("texindex %r.??")
     ("dvipdfm %r" "%r.dvi" "%r.pdf")
     ("dvipdf %r" "%r.dvi" "%r.pdf")
-    ("dvips %r" "%r.dvi" "%r.ps")
+    ("dvips -o %r.ps %r" "%r.dvi" "%r.ps")
     ("ps2pdf %r.ps" "%r.ps" "%r.pdf")
     ("gv %r.ps &" "%r.ps")
     ("gv %r.pdf &" "%r.pdf")
@@ -1767,7 +1783,7 @@
 	(not (tex-uptodate-p (format-spec out fspec)))))))
 
 (defun tex-compile-default (fspec)
-  "Guess a default command given the format-spec FSPEC."
+  "Guess a default command given the `format-spec' FSPEC."
   ;; TODO: Learn to do latex+dvips!
   (let ((cmds nil)
 	(unchanged-in nil))
@@ -1777,6 +1793,9 @@
 	(if (tex-command-active-p cmd fspec)
 	    (push cmd cmds)
 	  (push (nth 1 cmd) unchanged-in))))
+    ;; If no command seems to be applicable, arbitrarily pick the first one.
+    (unless cmds
+      (setq cmds (list (car tex-compile-commands))))
     ;; Remove those commands whose input was considered stable for
     ;; some other command (typically if (t . "%.pdf") is inactive
     ;; then we're using pdflatex and the fact that the dvi file
@@ -2261,6 +2280,7 @@
 (defvar tex-indent-basic 2)
 (defvar tex-indent-item tex-indent-basic)
 (defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>")
+(defvar latex-noindent-environments '("document"))
 
 (defvar tex-latex-indent-syntax-table
   (let ((st (make-syntax-table tex-mode-syntax-table)))
@@ -2311,7 +2331,6 @@
 	      (latex-find-indent 'virtual))))
      ;; Default (maybe an argument)
      (let ((pos (point))
-	   (char (char-after))
 	   ;; Outdent \item if necessary.
 	   (indent (if (looking-at tex-indent-item-re) (- tex-indent-item) 0))
 	   up-list-pos)
@@ -2329,6 +2348,17 @@
 	 ;; Have to indent relative to the open-paren.
 	 (goto-char up-list-pos)
 	 (if (and (not tex-indent-allhanging)
+		  (save-excursion
+		    ;; Make sure we're an argument to a macro and
+		    ;; that the macro is at the beginning of a line.
+		    (condition-case nil
+			(progn
+			  (while (eq (char-syntax (char-after)) ?\()
+			    (forward-sexp -1))
+			  (and (eq (char-syntax (char-after)) ?/)
+			       (progn (skip-chars-backward " \t&")
+				      (bolp))))
+		      (scan-error nil)))
 		  (> pos (progn (latex-down-list)
 				(forward-comment (point-max))
 				(point))))
@@ -2336,18 +2366,24 @@
 	     (current-column)
 	   ;; We're the first element after a hanging brace.
 	   (goto-char up-list-pos)
-	   (+ indent tex-indent-basic (latex-find-indent 'virtual))))
+	   (+ (if (and (looking-at "\\\\begin *{\\([^\n}]+\\)")
+		       (member (match-string 1)
+			       latex-noindent-environments))
+		  0 tex-indent-basic)
+	      indent (latex-find-indent 'virtual))))
 	;; We're now at the "beginning" of a line.
 	((not (and (not virtual) (eq (char-after) ?\\)))
 	 ;; Nothing particular here: just keep the same indentation.
 	 (+ indent (current-column)))
 	;; We're now looking at a macro call.
-	  ((looking-at tex-indent-item-re)
-	   ;; Indenting relative to an item, have to re-add the outdenting.
+	((looking-at tex-indent-item-re)
+	 ;; Indenting relative to an item, have to re-add the outdenting.
 	 (+ indent (current-column) tex-indent-item))
 	(t
 	 (let ((col (current-column)))
-	   (if (or (null char) (not (eq (char-syntax char) ?\()))
+	   (if (or (not (eq (char-syntax (or (char-after pos) ?\ )) ?\())
+		   ;; Can't be an arg if there's an empty line inbetween.
+		   (save-excursion (re-search-forward "^[ \t]*$" pos t)))
 	       ;; If the first char was not an open-paren, there's
 	       ;; a risk that this is really not an argument to the
 	       ;; macro at all.
@@ -2422,5 +2458,5 @@
 
 (provide 'tex-mode)
 
-;;; arch-tag: c0a680b1-63aa-4547-84b9-4193c29c0080
+;; arch-tag: c0a680b1-63aa-4547-84b9-4193c29c0080
 ;;; tex-mode.el ends here
--- a/src/ChangeLog	Fri Oct 01 08:18:00 2004 +0000
+++ b/src/ChangeLog	Mon Oct 04 01:04:18 2004 +0000
@@ -1,3 +1,21 @@
+2004-10-03  Michael Albinus  <michael.albinus@gmx.de>
+
+	* fileio.c (auto_save_1) Call Ffile_modes for remote files.
+
+2004-09-30  Kenichi Handa  <handa@m17n.org>
+
+	* process.c (send_process): Free composition data.
+
+	* fileio.c (Finsert_file_contents): Free composition data.
+
+	* coding.c (code_convert_region): Don't skip ASCIIs if there are
+	compositions to encode.
+	(encode_coding_string): Likewise.  Free composition data.
+
+2004-09-30  Florian Weimer <fw@deneb.enyo.de>	(tiny change)
+
+	* coding.c (code_convert_region): Free composition data.
+
 2004-09-29  Kim F. Storm  <storm@cua.dk>
 
 	* fringe.c: Remove limit on number of bitmaps.
--- a/src/fileio.c	Fri Oct 01 08:18:00 2004 +0000
+++ b/src/fileio.c	Mon Oct 04 01:04:18 2004 +0000
@@ -5634,6 +5634,9 @@
       && stat (SDATA (current_buffer->filename), &st) >= 0)
     /* But make sure we can overwrite it later!  */
     auto_save_mode_bits = st.st_mode | 0600;
+  else if (! NILP (current_buffer->filename))
+    /* Remote files don't cooperate with stat.  */
+    auto_save_mode_bits = XINT (Ffile_modes (current_buffer->filename)) | 0600;
   else
     auto_save_mode_bits = 0666;