changeset 90320:8a1ee48a8386

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-26 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 119-122) - Update from CVS
author Miles Bader <miles@gnu.org>
date Sun, 26 Feb 2006 07:09:24 +0000
parents c6cf8c705e11 (current diff) e14bc51fc1eb (diff)
children 344d06a17979
files admin/ChangeLog admin/FOR-RELEASE lisp/ChangeLog lisp/ChangeLog.1 lisp/ChangeLog.10 lisp/ido.el lisp/progmodes/cc-align.el lisp/progmodes/cc-awk.el lisp/progmodes/cc-bytecomp.el lisp/progmodes/cc-cmds.el lisp/progmodes/cc-compat.el lisp/progmodes/cc-defs.el lisp/progmodes/cc-engine.el lisp/progmodes/cc-langs.el lisp/progmodes/cc-menus.el lisp/progmodes/cc-mode.el lisp/progmodes/cc-styles.el lisp/progmodes/cc-vars.el lisp/progmodes/etags.el lisp/progmodes/sh-script.el man/ChangeLog man/cc-mode.texi src/ChangeLog src/buffer.c src/eval.c src/fileio.c src/gtkutil.c src/process.c src/xfns.c src/xselect.c src/xterm.c src/xterm.h
diffstat 32 files changed, 637 insertions(+), 375 deletions(-) [+]
line wrap: on
line diff
--- a/admin/ChangeLog	Sun Feb 26 06:32:30 2006 +0000
+++ b/admin/ChangeLog	Sun Feb 26 07:09:24 2006 +0000
@@ -1,3 +1,7 @@
+2006-02-24  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* FOR-RELEASE (BUGS): Add URLs/MIDs.
+
 2006-02-20  Kim F. Storm  <storm@cua.dk>
 
 	* FOR-RELEASE (NEW FEATURES): Completed work on this item:
--- a/admin/FOR-RELEASE	Sun Feb 26 06:32:30 2006 +0000
+++ b/admin/FOR-RELEASE	Sun Feb 26 07:09:24 2006 +0000
@@ -36,10 +36,10 @@
 * BUGS
 
 ** Reiner Steib's 23 Jan 2006 bug report that tool bar icons don't update.
+URL/MID: http://mid.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de
 
 ** Ralf Angeli's 4 Jul 2005 bug report about scroll-preserve-screen-position.
-
-** Martin Rudalics' 30 Jan 2006 bug report about overlays at end of buffer.
+URL/MID: http://mid.gmane.org/877jg6o7k4.fsf@neutrino.iwi.uni-sb.de
 
 ** TCP server processes do not work on Windows.
 
--- a/lisp/ChangeLog	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/ChangeLog	Sun Feb 26 07:09:24 2006 +0000
@@ -1,3 +1,109 @@
+2006-02-26  Kim F. Storm  <storm@cua.dk>
+
+	* ido.el (ido-save-history, ido-load-history): Simplify.  Don't
+	use find-file-noselect to avoid interference from other modes.
+
+2006-02-25  Thien-Thi Nguyen  <ttn@gnu.org>
+
+	* progmodes/sh-script.el (sh-mode): Fix bug: Arrange
+	to use the default shell if filename is not available.
+	Reported by Giorgos Keramidas.
+
+2006-02-25  John Williams  <jrw@pobox.com>  (tiny change)
+
+	* progmodes/etags.el (tags-completion-table): Do completion from
+	all the tables in the current list, as documented in the manual.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* CC Mode Update to 5.31.3.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-mode.el (c-postprocess-file-styles): bind
+	inhibit-read-only to t, around the call to
+	c-remove-any-local-eval-or-mode-variables, so that it works on a
+	RO file.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-awk.el: Correct a typo.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
+	c-hungry-delete-backwards, at the request of RMS.  Leave the old
+	name as an alias.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-mode.el: Correct a typo.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-defs.el: Update the version number to 5.31.3.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-cmds.el (c-electric-brace): Fix clean-up
+	brace-else-brace (error due to mbeg, mend being undefined).
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-mode.el: File Local variables: Solve the problem
+	where both `mode' and c-file-offsets are specified: `mode' will
+	overwrite c-f-o's settings:
+	(c-remove-any-local-eval-or-mode-variables): new function.
+	(c-postprocess-file-styles): call the above new function, within
+	c-tentative-buffer-change, to splat `mode' and `eval' before the
+	second hack-local-variables.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-mode.el:
+	[Supersedes patch to cc-engine.el V 1.45]
+	(c-after-change): Protect the match data with save-match-data.  It
+	was getting corrupted by c-after-change-check-<>-operators.
+
+	* cc-defs.el: [Supersedes patch V1.38]:
+	(top level): Check for a buggy font-lock-compile-keywords ONLY in
+	XEmacs.  GNU Emacs 22 now has a check which would throw an error
+	here.
+
+	* progmodes/cc-awk.el (c-awk-after-change): Protect the match data
+	with save-match-data.  It was being corrupted when Font Lock was
+	not enabled.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-langs.el (c-mode-menu): Add menu items for Electric
+	Mode and Subword Mode.
+
+	* progmodes/cc-engine.el (c-beginning-of-statment-1): Distinguish
+	real labels ("case 1:" or "foo:") from non-labels ("public:").
+	(c-forward-objc-directive): Replace c-forward-token-2 with crude
+	coding; c-f-t-2 doesn't move over a token at EOB.
+
+	* progmodes/cc-defs.el (c-version): Update version number to
+	5.31.2
+
+	* progmodes/cc-cmds.el, cc-mode.el, cc-engine.el
+	(c-update-modeline): Concatenate the minor mode indicators
+	directly onto mode-name, removing c-submode-indicators.
+	Sometimes, c-s-i got separated from the mode name on the mode
+	line.
+
+	* progmodes/cc-cmds.el (c-electric-brace, c-electric-semi&comma,
+	c-electric-colon): Correct doc-strings: "/ln" -> "/la".
+
+2006-02-24  Martin Stjernholm  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-langs.el (c-make-init-lang-vars-fun): Improved the
+	error message when there's an evaluation error to show whether
+	it's loaded from source or not.
+	(c-filter-ops): Made it available at runtime too to work when
+	`c-make-init-lang-vars-fun' needs to evaluate from source.
+
 2006-02-24  Juanma Barranquero  <lekktu@gmail.com>
 
 	* help.el (help): Revert last part of 2006-02-23 change (deletion
@@ -5064,7 +5170,7 @@
 
 2005-11-29  Michael Kifer  <kifer@cs.stonybrook.edu>
 
-	* ediff-wind (ediff-setup-control-frame, ediff-make-wide-display):
+	* ediff-wind.el (ediff-setup-control-frame, ediff-make-wide-display):
 	Preserve user position.
 
 2005-11-28  Luc Teirlinck  <teirllm@auburn.edu>
@@ -5837,13 +5943,13 @@
 
 2005-11-15  Michael Kifer  <kifer@cs.stonybrook.edu>
 
-	* viper-utils (viper-non-word-characters-reformed-vi): Quote `-' in
-	string.
+	* viper-utils.el (viper-non-word-characters-reformed-vi):
+	Quote `-' in string.
 
 	* viper.el (viper-emacs-state-mode-list): Ensure that
 	rcirc-mode buffers come up in Emacs state.
 
-	* ediff-util (ediff-make-temp-file): Use proper file-name-handler
+	* ediff-util.el (ediff-make-temp-file): Use proper file-name-handler
 	operation.
 
 2005-11-15  Dan Nicolaescu  <dann@ics.uci.edu>
--- a/lisp/ChangeLog.1	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/ChangeLog.1	Sun Feb 26 07:09:24 2006 +0000
@@ -1565,7 +1565,7 @@
 	Move rmail-delete-after-output from rmail.el.
 	Flush rmail-mmdf-inbox-list and rmail-make-summary-line-function.
 
-	* mail-utils (mail-strip-quoted-names):
+	* mail-utils.el (mail-strip-quoted-names):
 	Delete leading and trailing whitespace.
 
 1985-10-19  Richard M. Stallman  (rms@mit-prep)
--- a/lisp/ChangeLog.10	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/ChangeLog.10	Sun Feb 26 07:09:24 2006 +0000
@@ -2916,7 +2916,7 @@
 	(comment-valid-prefix-p): Rename from comment-valid-prefix
 	and fix to actually use its argument.
 
-	* tex-mode (tex-mode-syntax-table): ~ is not whitespace.
+	* tex-mode.el (tex-mode-syntax-table): ~ is not whitespace.
 	(tex-guess-mode): Add `renewcommand'.
 	(tex-mode): Move the autoload to get the correct docstring and usage.
 
@@ -6170,7 +6170,7 @@
 
 	Changes from 2002-02-28:
 
-	* antlr-mode: Version 2.2 is released.
+	* antlr-mode.el: Version 2.2 is released.
 
 	* antlr-mode.el (antlr): Moved to SourceForge.net
 
--- a/lisp/ido.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/ido.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1181,25 +1181,19 @@
 (defun ido-save-history ()
   "Save ido history and cache information between sessions."
   (interactive)
-  (if (and ido-last-directory-list ido-save-directory-list-file)
-      (save-excursion
-	(save-window-excursion
-	  (if (find-buffer-visiting ido-save-directory-list-file)
-	      (kill-buffer (find-buffer-visiting ido-save-directory-list-file)))
-	  (if (file-exists-p ido-save-directory-list-file)
-	      (delete-file ido-save-directory-list-file))
-	  (set-buffer (let ((enable-local-variables nil))
-			(find-file-noselect ido-save-directory-list-file t)))
-	  (goto-char (point-min))
-	  (delete-region (point-min) (point-max))
-	  (ido-pp 'ido-last-directory-list)
-	  (ido-pp 'ido-work-directory-list)
-	  (ido-pp 'ido-work-file-list)
-	  (ido-pp 'ido-dir-file-cache "\n\n ")
-	  (insert "\n")
-	  (let ((version-control 'never))
+  (when (and ido-last-directory-list ido-save-directory-list-file)
+    (let ((buf (get-buffer-create " *ido session*"))
+	  (version-control 'never))
+      (unwind-protect
+	  (with-current-buffer buf
+	    (erase-buffer)
+	    (ido-pp 'ido-last-directory-list)
+	    (ido-pp 'ido-work-directory-list)
+	    (ido-pp 'ido-work-file-list)
+	    (ido-pp 'ido-dir-file-cache "\n\n ")
+	    (insert "\n")
 	    (write-file ido-save-directory-list-file nil))
-	  (kill-buffer (current-buffer))))))
+	(kill-buffer buf)))))
 
 (defun ido-load-history (&optional arg)
   "Load ido history and cache information from previous session.
@@ -1209,18 +1203,18 @@
       (let ((file (expand-file-name ido-save-directory-list-file))
 	    buf)
 	(when (file-readable-p file)
-	  (save-excursion
-	    (save-window-excursion
-	      (setq buf (set-buffer (let ((enable-local-variables nil))
-				      (find-file-noselect file))))
-	      (goto-char (point-min))
-	      (condition-case nil
-		  (setq ido-last-directory-list (read (current-buffer))
-			ido-work-directory-list (read (current-buffer))
-			ido-work-file-list (read (current-buffer))
-			ido-dir-file-cache (read (current-buffer)))
-		(error nil))))
-	  (kill-buffer buf))))
+	  (setq buf (get-buffer-create " *ido session*"))
+	  (unwind-protect
+	      (with-current-buffer buf
+		(erase-buffer)
+		(insert-file-contents file)
+		(condition-case nil
+		    (setq ido-last-directory-list (read (current-buffer))
+			  ido-work-directory-list (read (current-buffer))
+			  ido-work-file-list (read (current-buffer))
+			  ido-dir-file-cache (read (current-buffer)))
+		  (error nil)))
+	    (kill-buffer buf)))))
   (ido-wash-history))
 
 (defun ido-wash-history ()
--- a/lisp/progmodes/cc-align.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-align.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-align.el --- custom indentation functions for CC Mode
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
--- a/lisp/progmodes/cc-awk.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-awk.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-awk.el --- AWK specific code within cc-mode.
 
-;; Copyright (C) 1988,94,96,2000, 2001, 2002, 2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1988,94,96,2000, 2001, 2002, 2003, 2004, 2005, 2006 Free
+;; Software Foundation, Inc.
 
 ;; Author: Alan Mackenzie <acm@muc.de> (originally based on awk-mode.el)
 ;; Maintainer: FSF
@@ -804,7 +804,7 @@
 (defun c-awk-end-of-change-region (beg end old-len)
   ;; Find the end of the region which needs to be font-locked after a change.
   ;; This is the end of the logical line on which the change happened, either
-  ;; as it was before the change, or as it is now, which ever is later.
+  ;; as it was before the change, or as it is now, whichever is later.
   ;; N.B. point is left undefined.
   ;;
   ;; This function might do hidden buffer changes.
@@ -822,11 +822,12 @@
   (unless (and (boundp 'font-lock-mode) font-lock-mode)
     (save-restriction
       (save-excursion
-        (setq end (c-awk-end-of-change-region beg end old-len))
-        (c-awk-beginning-of-logical-line beg)
-        (c-save-buffer-state nil ; So that read-only status isn't affected.
+	(save-match-data
+	  (setq end (c-awk-end-of-change-region beg end old-len))
+	  (c-awk-beginning-of-logical-line beg)
+	  (c-save-buffer-state nil  ; So that read-only status isn't affected.
                                         ; (e.g. when first loading the buffer)
-          (c-awk-set-syntax-table-properties end))))))
+	    (c-awk-set-syntax-table-properties end)))))))
 
 ;; ACM 2002/5/25.  When font-locking is invoked by a buffer change, the region
 ;; specified by the font-lock after-change function must be expanded to
--- a/lisp/progmodes/cc-bytecomp.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-bytecomp.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-bytecomp.el --- compile time setup for proper compilation
 
-;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Author:     Martin Stjernholm
 ;; Maintainer: bug-cc-mode@gnu.org
--- a/lisp/progmodes/cc-cmds.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-cmds.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-cmds.el --- user level commands for CC Mode
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
@@ -262,10 +262,17 @@
 			  (boundp 'c-subword-mode)
 			  (symbol-value 'c-subword-mode))
 			 "w"
-		       ""))))
-    (setq c-submode-indicators
+		       "")))
+	(bare-mode-name (if (string-match "\\(^[^/]*\\)/" mode-name)
+			    (substring mode-name (match-beginning 1) (match-end 1))
+			  mode-name)))
+;;     (setq c-submode-indicators
+;; 	  (if (> (length fmt) 1)
+;; 	      fmt))
+    (setq mode-name
 	  (if (> (length fmt) 1)
-	      fmt))
+	      (concat bare-mode-name fmt) 
+	bare-mode-name))
     (force-mode-line-update)))
 
 (defun c-toggle-syntactic-indentation (&optional arg)
@@ -365,9 +372,9 @@
 	    arg
 	    (c-in-literal)))
       (funcall c-backspace-function (prefix-numeric-value arg))
-    (c-hungry-backspace)))
-
-(defun c-hungry-backspace ()
+    (c-hungry-delete-backwards)))
+
+(defun c-hungry-delete-backwards ()
   "Delete the preceding character or all preceding whitespace
 back to the previous non-whitespace character.
 See also \\[c-hungry-delete-forward]."
@@ -378,6 +385,8 @@
 	(delete-region (point) here)
       (funcall c-backspace-function 1))))
 
+(defalias 'c-hungry-backspace 'c-hungry-delete-backwards)
+
 (defun c-electric-delete-forward (arg)
   "Delete the following character or whitespace.
 If `c-hungry-delete-key' is non-nil (indicated by \"/h\" on the mode
@@ -396,7 +405,7 @@
 (defun c-hungry-delete-forward ()
   "Delete the following character or all following whitespace
 up to the next non-whitespace character.
-See also \\[c-hungry-backspace]."
+See also \\[c-hungry-delete-backwards]."
   (interactive)
   (let ((here (point)))
     (c-skip-ws-forward)
@@ -436,7 +445,7 @@
   (if (and (fboundp 'delete-forward-p)
 	   (delete-forward-p))
       (c-hungry-delete-forward)
-    (c-hungry-backspace)))
+    (c-hungry-delete-backwards)))
 
 (defun c-electric-pound (arg)
   "Insert a \"#\".
@@ -648,7 +657,7 @@
 numeric ARG hasn't been supplied, the command performs several electric
 actions:
 
-\(a) If the auto-newline feature is turned on (indicated by \"/ln\" on
+\(a) If the auto-newline feature is turned on (indicated by \"/la\" on
 the mode line) newlines are inserted before and after the brace as
 directed by the settings in `c-hanging-braces-alist'.
 
@@ -752,7 +761,7 @@
 				"{"
 				"\\=")
 			nil t))
-		  (delete-region mbeg mend)
+		  (delete-region (match-beginning 0) (match-end 0))
 		  (insert-and-inherit "} else {"))
 		 ((and (memq 'brace-elseif-brace c-cleanup-list)
 		       (progn
@@ -886,7 +895,7 @@
 numeric ARG hasn't been supplied, the command performs several electric
 actions:
 
-\(a) When the auto-newline feature is turned on (indicated by \"/ln\" on
+\(a) When the auto-newline feature is turned on (indicated by \"/la\" on
 the mode line) a newline might be inserted.  See the variable
 `c-hanging-semi&comma-criteria' for how newline insertion is determined.
 
@@ -958,7 +967,7 @@
 numeric ARG hasn't been supplied, the command performs several electric
 actions:
 
-\(a) If the auto-newline feature is turned on (indicated by \"/ln\" on
+\(a) If the auto-newline feature is turned on (indicated by \"/la\" on
 the mode line) newlines are inserted before and after the colon based on
 the settings in `c-hanging-colons-alist'.
 
--- a/lisp/progmodes/cc-compat.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-compat.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-compat.el --- cc-mode compatibility with c-mode.el confusion
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;	       1994-1999 Barry A. Warsaw
--- a/lisp/progmodes/cc-defs.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-defs.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-defs.el --- compile time definitions for CC Mode
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
@@ -71,10 +71,10 @@
 
 (eval-after-load "font-lock"
   '(if (and (not (featurep 'cc-fix)) ; only load the file once.
+	    (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS
+			       ; to make the call to f-l-c-k throw an error.
             (let (font-lock-keywords)
-              (condition-case nil
-		  (font-lock-compile-keywords '("\\<\\>"))
-		(error nil))
+              (font-lock-compile-keywords '("\\<\\>"))
 	      font-lock-keywords))     ; did the previous call foul this up?
        (load "cc-fix")))
 
@@ -82,19 +82,18 @@
 ;; to ensure correct byte compilation.
 (eval-when-compile
   (if (and (not (featurep 'cc-fix))
+	   (featurep 'xemacs)
 	   (progn
 	     (require 'font-lock)
 	     (let (font-lock-keywords)
-	       (condition-case nil
-		   (font-lock-compile-keywords '("\\<\\>"))
-		 (error nil))
+	       (font-lock-compile-keywords '("\\<\\>"))
 	       font-lock-keywords)))
       (cc-load "cc-fix")))
 
 
 ;;; Variables also used at compile time.
 
-(defconst c-version "5.31"
+(defconst c-version "5.31.3"
   "CC Mode version number.")
 
 (defconst c-version-sym (intern c-version))
@@ -2041,5 +2040,5 @@
 
 (cc-provide 'cc-defs)
 
-;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda
+;;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda
 ;;; cc-defs.el ends here
--- a/lisp/progmodes/cc-engine.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-engine.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-engine.el --- core syntax guessing engine for CC mode
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software Foundation,
+;; Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
@@ -179,8 +179,8 @@
 (make-variable-buffer-local 'c-auto-newline)
 
 ;; Included in the mode line to indicate the active submodes.
-(defvar c-submode-indicators nil)
-(make-variable-buffer-local 'c-submode-indicators)
+;; (defvar c-submode-indicators nil)
+;; (make-variable-buffer-local 'c-submode-indicators)
 
 (defun c-calculate-state (arg prevstate)
   ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If
@@ -525,14 +525,15 @@
 
 Labels are treated as part of the following statements if
 IGNORE-LABELS is non-nil.  (FIXME: Doesn't work if we stop at a known
-statement start keyword.)
-
-Macros are ignored unless point is within one, in which case the
-content of the macro is treated as normal code.  Aside from any normal
-statement starts found in it, stop at the first token of the content
-in the macro, i.e. the expression of an \"#if\" or the start of the
-definition in a \"#define\".  Also stop at start of macros before
-leaving them.
+statement start keyword.)  Otherwise, each label is treated as a
+separate statement.
+
+Macros are ignored \(i.e. skipped over) unless point is within one, in
+which case the content of the macro is treated as normal code.  Aside
+from any normal statement starts found in it, stop at the first token
+of the content in the macro, i.e. the expression of an \"#if\" or the
+start of the definition in a \"#define\".  Also stop at start of
+macros before leaving them.
 
 Return 'label if stopped at a label, 'same if stopped at the beginning
 of the current statement, 'up if stepped to a containing statement,
@@ -547,8 +548,9 @@
 
 NOERROR turns off error logging to `c-parsing-error'.
 
-Normally only ';' is considered to delimit statements, but if
-COMMA-DELIM is non-nil then ',' is treated likewise.
+Normally only ';' and virtual semicolons are considered to delimit
+statements, but if COMMA-DELIM is non-nil then ',' is treated
+as a delimiter too.
 
 Note that this function might do hidden buffer changes.  See the
 comment at the start of cc-engine.el for more info."
@@ -883,6 +885,7 @@
 		      ;; barriers in this round.
 		      (sexp-loop-end-pos pos))
 
+		  ;; The following while goes back one sexp per iteration.
 		  (while
 		      (progn
 			(unless (c-safe (c-backward-sexp) t)
@@ -954,7 +957,7 @@
 			    ;; Like a C "continue".  Analyze the next sexp.
 			    (throw 'loop t)))
 
-			sexp-loop-continue-pos)
+			sexp-loop-continue-pos)	; End of "go back a sexp" loop.
 		    (goto-char sexp-loop-continue-pos)
 		    (setq sexp-loop-end-pos sexp-loop-continue-pos
 			  sexp-loop-continue-pos nil))))
@@ -969,17 +972,26 @@
 	      ;; Handle labels.
 	      (unless (eq ignore-labels t)
 		(when (numberp c-maybe-labelp)
-		  ;; `c-crosses-statement-barrier-p' has found a
-		  ;; colon, so we might be in a label now.
-		  (if after-labels-pos
-		      (if (not last-label-pos)
-			  (setq last-label-pos (or tok start)))
-		    (setq after-labels-pos (or tok start)))
-		  (setq c-maybe-labelp t
-			label-good-pos nil))
-
-		(when (and (not label-good-pos)
-			   (looking-at c-nonlabel-token-key))
+		  ;; `c-crosses-statement-barrier-p' has found a colon, so we
+		  ;; might be in a label now.  Have we got a real label
+		  ;; (including a case label) or something like C++'s "public:"?
+		  (if (or (not (looking-at c-nonlabel-token-key)) ; proper label
+			  (save-excursion ; e.g. "case 'a':" ?
+			    (and (c-safe (c-backward-sexp) t)
+				 (looking-at "\\<case\\>")))) ; FIXME!!! this is
+					; wrong for AWK.  2006/1/14.
+		      (progn
+			(if after-labels-pos ; Have we already encountered a label?
+			    (if (not last-label-pos)
+				(setq last-label-pos (or tok start)))
+			  (setq after-labels-pos (or tok start)))
+			(setq c-maybe-labelp t
+			      label-good-pos nil))
+		    (setq c-maybe-labelp nil))) ; bogus "label"
+
+		(when (and (not label-good-pos)	; i.e. no invalid "label"'s yet
+						; been found.
+			   (looking-at c-nonlabel-token-key)) ; e.g. "while :"
 		  ;; We're in a potential label and it's the first
 		  ;; time we've found something that isn't allowed in
 		  ;; one.
@@ -3993,36 +4005,35 @@
   ;;
   ;; This function might do hidden buffer changes.
 
-  (save-match-data
-    (save-excursion
+  (save-excursion
+    (goto-char beg)
+    (when (or (looking-at "[<>]")
+	      (< (skip-chars-backward "<>") 0))
+
       (goto-char beg)
+      (c-beginning-of-current-token)
+      (when (and (< (point) beg)
+		 (looking-at c-<>-multichar-token-regexp)
+		 (< beg (setq beg (match-end 0))))
+	(while (progn (skip-chars-forward "^<>" beg)
+		      (< (point) beg))
+	  (c-clear-char-property (point) 'syntax-table)
+	  (forward-char))))
+
+    (when (< beg end)
+      (goto-char end)
       (when (or (looking-at "[<>]")
 		(< (skip-chars-backward "<>") 0))
 
-	(goto-char beg)
+	(goto-char end)
 	(c-beginning-of-current-token)
-	(when (and (< (point) beg)
+	(when (and (< (point) end)
 		   (looking-at c-<>-multichar-token-regexp)
-		   (< beg (setq beg (match-end 0))))
-	  (while (progn (skip-chars-forward "^<>" beg)
-			(< (point) beg))
+		   (< end (setq end (match-end 0))))
+	  (while (progn (skip-chars-forward "^<>" end)
+			(< (point) end))
 	    (c-clear-char-property (point) 'syntax-table)
-	    (forward-char))))
-
-      (when (< beg end)
-	(goto-char end)
-	(when (or (looking-at "[<>]")
-		  (< (skip-chars-backward "<>") 0))
-
-	  (goto-char end)
-	  (c-beginning-of-current-token)
-	  (when (and (< (point) end)
-		     (looking-at c-<>-multichar-token-regexp)
-		     (< end (setq end (match-end 0))))
-	    (while (progn (skip-chars-forward "^<>" end)
-			  (< (point) end))
-	      (c-clear-char-property (point) 'syntax-table)
-	      (forward-char))))))))
+	    (forward-char)))))))
 
 ;; Dynamically bound variable that instructs `c-forward-type' to also
 ;; treat possible types (i.e. those that it normally returns 'maybe or
@@ -5991,7 +6002,10 @@
 
 	    ;; Handle the name of the class itself.
 	    (progn
-	      (c-forward-token-2)
+;	      (c-forward-token-2) ; 2006/1/13 This doesn't move if the token's
+;	      at EOB.
+	      (goto-char (match-end 0))
+	      (c-skip-ws-forward)
 	      (c-forward-type))
 
 	    (catch 'break
--- a/lisp/progmodes/cc-langs.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-langs.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-langs.el --- language specific settings for CC Mode
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
@@ -177,7 +177,7 @@
   '(def-edebug-spec c-lang-defvar
      (&define name def-form &optional stringp)))
 
-(eval-when-compile
+(eval-and-compile
   ;; Some helper functions used when building the language constants.
 
   (defun c-filter-ops (ops opgroup-filter op-filter &optional xlate)
@@ -260,10 +260,14 @@
       ("Toggle..."
        ["Syntactic indentation" c-toggle-syntactic-indentation
 	:style toggle :selected c-syntactic-indentation]
-       ["Auto newline" c-toggle-auto-newline
+       ["Electric mode"         c-toggle-electric-state
+	:style toggle :selected c-electric-flag]
+       ["Auto newline"          c-toggle-auto-newline
 	:style toggle :selected c-auto-newline]
-       ["Hungry delete" c-toggle-hungry-state
-	:style toggle :selected c-hungry-delete-key])))
+       ["Hungry delete"         c-toggle-hungry-state
+	:style toggle :selected c-hungry-delete-key]
+       ["Subword mode"          c-subword-mode
+	:style toggle :selected c-subword-mode])))
 
 
 ;;; Syntax tables.
@@ -2826,7 +2830,7 @@
 	 ;; This let sets up the context for `c-mode-var' and similar
 	 ;; that could be in the result from `cl-macroexpand-all'.
 	 (let ((c-buffer-is-cc-mode ',mode)
-	       current-var)
+	       current-var source-eval)
 	   (condition-case err
 
 	       (if (eq c-version-sym ',c-version-sym)
@@ -2852,6 +2856,7 @@
 		 ;;  (put ',mode 'c-has-warned-lang-consts t))
 
 		 (require 'cc-langs)
+		 (setq source-eval t)
 		 (let ((init (cdr c-lang-variable-inits)))
 		   (while init
 		     (setq current-var (caar init))
@@ -2860,8 +2865,14 @@
 
 	     (error
 	      (if current-var
-		  (message "Eval error in the `c-lang-defvar' for `%s': %S"
-			   current-var err)
+		  (message "Eval error in the `c-lang-defvar' for `%s'%s: %S"
+			   current-var
+			   (if source-eval
+			       (format "\
+ (fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
+				       ',mode ,c-version c-version)
+			     "")
+			   err)
 		(signal (car err) (cdr err)))))))
 
     ;; Being evaluated from source.  Always use the dynamic method to
@@ -2881,8 +2892,9 @@
 
 	   (error
 	    (if current-var
-		(message "Eval error in the `c-lang-defvar' for `%s': %S"
-			 current-var err)
+		(message
+		 "Eval error in the `c-lang-defvar' for `%s' (source eval): %S"
+		 current-var err)
 	      (signal (car err) (cdr err)))))))
     ))
 
--- a/lisp/progmodes/cc-menus.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-menus.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-menus.el --- imenu support for CC Mode
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
--- a/lisp/progmodes/cc-mode.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-mode.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-mode.el --- major mode for editing C and similar languages
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -242,9 +242,9 @@
 	(define-key c-mode-base-map (kbd "C-c C-<delete>")
 	  'c-hungry-delete-forward)
 	(define-key c-mode-base-map (kbd "C-c C-<backspace>")
-	  'c-hungry-backspace))
+	  'c-hungry-delete-backwards))
     (define-key c-mode-base-map (kbd "C-c C-<delete>")
-      'c-hungry-backspace)
+      'c-hungry-delete-backwards)
     (define-key c-mode-base-map (kbd "C-c C-<backspace>")
       'c-hungry-delete-forward)))
 
@@ -304,10 +304,11 @@
   ;; `c-electric-backspace'.  The hungry variants are bound to the
   ;; same keys but prefixed with C-c.  This implies that C-c C-d is
   ;; `c-hungry-delete-forward'.  For consistency, we bind not only C-c
-  ;; <backspace> to `c-hungry-backspace' but also C-c C-<backspace>,
-  ;; so that the Ctrl key can be held down during the whole sequence
-  ;; regardless of the direction.  This in turn implies that we bind
-  ;; C-c C-<delete> to `c-hungry-delete-forward', for the same reason.
+  ;; <backspace> to `c-hungry-delete-backwards' but also
+  ;; C-c C-<backspace>, so that the Ctrl key can be held down during
+  ;; the whole sequence regardless of the direction.  This in turn
+  ;; implies that we bind C-c C-<delete> to `c-hungry-delete-forward',
+  ;; for the same reason.
 
   ;; Bind the electric deletion functions to C-d and DEL.  Emacs 21
   ;; automatically maps the [delete] and [backspace] keys to these two
@@ -316,8 +317,8 @@
   (define-key c-mode-base-map "\C-d" 'c-electric-delete-forward)
   (define-key c-mode-base-map "\177" 'c-electric-backspace)
   (define-key c-mode-base-map "\C-c\C-d"     'c-hungry-delete-forward)
-  (define-key c-mode-base-map [?\C-c ?\d]    'c-hungry-backspace)
-  (define-key c-mode-base-map [?\C-c ?\C-\d] 'c-hungry-backspace)
+  (define-key c-mode-base-map [?\C-c ?\d]    'c-hungry-delete-backwards)
+  (define-key c-mode-base-map [?\C-c ?\C-\d] 'c-hungry-delete-backwards)
   (define-key c-mode-base-map [?\C-c deletechar] 'c-hungry-delete-forward) ; C-c <delete> on a tty.
   (define-key c-mode-base-map [?\C-c (control deletechar)] ; C-c C-<delete> on a tty.
     'c-hungry-delete-forward)
@@ -339,8 +340,10 @@
     (define-key c-mode-base-map [backspace] 'c-electric-backspace)
     (define-key c-mode-base-map (kbd "C-c <delete>") 'c-hungry-delete)
     (define-key c-mode-base-map (kbd "C-c C-<delete>") 'c-hungry-delete)
-    (define-key c-mode-base-map (kbd "C-c <backspace>") 'c-hungry-backspace)
-    (define-key c-mode-base-map (kbd "C-c C-<backspace>") 'c-hungry-backspace))
+    (define-key c-mode-base-map (kbd "C-c <backspace>")
+      'c-hungry-delete-backwards)
+    (define-key c-mode-base-map (kbd "C-c C-<backspace>")
+      'c-hungry-delete-backwards))
 
   (define-key c-mode-base-map "#"         'c-electric-pound)
   (define-key c-mode-base-map "{"         'c-electric-brace)
@@ -414,23 +417,24 @@
     ;; with regions outside the current narrowing.  This has been
     ;; observed in Emacs 20.7.
     (save-restriction
-      (widen)
+      (save-match-data		  ; c-recognize-<>-arglists changes match-data
+	(widen)
 
-      (when (> end (point-max))
-	;; Some emacsen might return positions past the end. This has been
-	;; observed in Emacs 20.7 when rereading a buffer changed on disk
-	;; (haven't been able to minimize it, but Emacs 21.3 appears to
-	;; work).
-	(setq end (point-max))
-	(when (> beg end)
-	  (setq beg end)))
+	(when (> end (point-max))
+	  ;; Some emacsen might return positions past the end. This has been
+	  ;; observed in Emacs 20.7 when rereading a buffer changed on disk
+	  ;; (haven't been able to minimize it, but Emacs 21.3 appears to
+	  ;; work).
+	  (setq end (point-max))
+	  (when (> beg end)
+	    (setq beg end)))
 
-      (c-invalidate-sws-region-after beg end)
-      (c-invalidate-state-cache beg)
-      (c-invalidate-find-decl-cache beg)
+	(c-invalidate-sws-region-after beg end)
+	(c-invalidate-state-cache beg)
+	(c-invalidate-find-decl-cache beg)
 
-      (when c-recognize-<>-arglists
-	(c-after-change-check-<>-operators beg end)))))
+	(when c-recognize-<>-arglists
+	  (c-after-change-check-<>-operators beg end))))))
 
 (defun c-basic-common-init (mode default-style)
   "Do the necessary initialization for the syntax handling routines
@@ -550,11 +554,12 @@
   (make-local-variable 'comment-indent-function)
   (setq comment-indent-function 'c-comment-indent)
 
-  ;; Put submode indicators onto minor-mode-alist, but only once.
-  (or (assq 'c-submode-indicators minor-mode-alist)
-      (setq minor-mode-alist
-	    (cons '(c-submode-indicators c-submode-indicators)
-		  minor-mode-alist)))
+;;   ;; Put submode indicators onto minor-mode-alist, but only once.
+;;   (or (assq 'c-submode-indicators minor-mode-alist)
+;;       (setq minor-mode-alist
+;; 	    (cons '(c-submode-indicators c-submode-indicators)
+;; 		  minor-mode-alist)))
+  (c-update-modeline)
 
   ;; Install the functions that ensure that various internal caches
   ;; don't become invalid due to buffer changes.
@@ -629,6 +634,51 @@
       (and (cdr rfn)
 	   (setq require-final-newline mode-require-final-newline)))))
 
+(defun c-remove-any-local-eval-or-mode-variables ()
+  ;; If the buffer specifies `mode' or `eval' in its File Local Variable list
+  ;; or on the first line, remove all occurrences.  See
+  ;; `c-postprocess-file-styles' for justification.  There is no need to save
+  ;; point here, or even bother too much about the buffer contents.
+  ;;
+  ;; Most of the code here is derived from Emacs 21.3's `hack-local-variables'
+  ;; in files.el.
+  (goto-char (point-max))
+  (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move)
+  (let (lv-point (prefix "") (suffix ""))
+    (when (let ((case-fold-search t))
+	    (search-forward "Local Variables:" nil t))
+      (setq lv-point (point))
+      ;; 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)))))
+
+      (while (search-forward-regexp
+	      (concat "^[ \t]*"
+		      (regexp-quote prefix)
+		      "\\(mode\\|eval\\):.*"
+		      (regexp-quote suffix)
+		      "$")
+	      nil t)
+	(beginning-of-line)
+	(kill-line 1)))
+
+    ;; Delete the first line, if we've got one, in case it contains a mode spec.
+    (unless (and lv-point
+		 (progn (goto-char lv-point)
+			(forward-line 0)
+			(bobp)))
+      (goto-char (point-min))
+      (unless (eobp)
+	(kill-line 1)))))
+
 (defun c-postprocess-file-styles ()
   "Function that post processes relevant file local variables in CC Mode.
 Currently, this function simply applies any style and offset settings
@@ -656,12 +706,20 @@
     ;; overwritten this.  So we run `hack-local-variables' again to remedy
     ;; this.  There are no guarantees this will work properly, particularly as
     ;; we have no control over what the other hook functions on
-    ;; `hack-local-variables-hook' would have done, or what any "eval"
-    ;; expression will do when evaluated again.  C'est la vie!  ACM,
-    ;; 2005/11/2.
+    ;; `hack-local-variables-hook' would have done.  We now (2006/2/1) remove
+    ;; any `eval' or `mode' expressions before we evaluate again (see below).
+    ;; ACM, 2005/11/2.
+    ;;
+    ;; Problem (bug reported by Gustav Broberg): if one of the variables is
+    ;; `mode', this will invoke c-mode (etc.) again, setting up the style etc.
+    ;; We prevent this by temporarily removing `mode' from the Local Variables
+    ;; section.
     (if (or c-file-style c-file-offsets)
-	(let ((hack-local-variables-hook nil))
-	  (hack-local-variables)))))
+	(c-tentative-buffer-changes
+	  (let ((hack-local-variables-hook nil))
+	    (c-remove-any-local-eval-or-mode-variables)
+	    (hack-local-variables))
+	  nil))))
 
 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
 
--- a/lisp/progmodes/cc-styles.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-styles.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-styles.el --- support for styles in CC Mode
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
--- a/lisp/progmodes/cc-vars.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/cc-vars.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1,7 +1,7 @@
 ;;; cc-vars.el --- user customization variables for CC Mode
 
-;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software
+;; Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
--- a/lisp/progmodes/etags.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/etags.el	Sun Feb 26 07:09:24 2006 +0000
@@ -746,27 +746,25 @@
 ;; their tags included in the completion table.
 (defun tags-completion-table ()
   (or tags-completion-table
+      ;; No cached value for this buffer.
       (condition-case ()
-	  (prog2
-	   (message "Making tags completion table for %s..." buffer-file-name)
-	   (let ((included (tags-included-tables))
-		 (table (funcall tags-completion-table-function)))
-	     (save-excursion
-	       ;; Iterate over the list of included tables, and combine each
-	       ;; included table's completion obarray to the parent obarray.
-	       (while included
-		 ;; Visit the buffer.
-		 (let ((tags-file-name (car included)))
-		   (visit-tags-table-buffer 'same))
-		 ;; Recurse in that buffer to compute its completion table.
-		 (if (tags-completion-table)
-		     ;; Combine the tables.
-		     (mapatoms (lambda (sym) (intern (symbol-name sym) table))
-			       tags-completion-table))
-		 (setq included (cdr included))))
-	     (setq tags-completion-table table))
-	   (message "Making tags completion table for %s...done"
-		    buffer-file-name))
+	  (let (current-table combined-table)
+	    (message "Making tags completion table for %s..." buffer-file-name)
+	    (save-excursion
+	      ;; Iterate over the current list of tags tables.
+	      (while (visit-tags-table-buffer (and combined-table t))
+		;; Find possible completions in this table.
+		(setq current-table (funcall tags-completion-table-function))
+		;; Merge this buffer's completions into the combined table.
+		(if combined-table
+		    (mapatoms
+		     (lambda (sym) (intern (symbol-name sym) combined-table))
+		     current-table)
+		  (setq combined-table current-table))))
+	    (message "Making tags completion table for %s...done"
+		     buffer-file-name)
+	    ;; Cache the result a buffer-local variable.
+	    (setq tags-completion-table combined-table))
 	(quit (message "Tags completion table construction aborted.")
 	      (setq tags-completion-table nil)))))
 
--- a/lisp/progmodes/sh-script.el	Sun Feb 26 06:32:30 2006 +0000
+++ b/lisp/progmodes/sh-script.el	Sun Feb 26 07:09:24 2006 +0000
@@ -1430,25 +1430,27 @@
   (set (make-local-variable 'parse-sexp-ignore-comments) t)
   ;; Parse or insert magic number for exec, and set all variables depending
   ;; on the shell thus determined.
-  (let ((interpreter
-	 (save-excursion
-	   (goto-char (point-min))
-	   (cond ((looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)")
-		  (match-string 2))
-		 ((and buffer-file-name
-		       (string-match "\\.m?spec\\'" buffer-file-name))
-		  "rpm")))))
-    (unless interpreter
-      (setq interpreter
-	    (cond ((string-match "[.]sh\\>" buffer-file-name)
-		   "sh")
-		  ((string-match "[.]bash\\>" buffer-file-name)
-		   "bash")
-		  ((string-match "[.]ksh\\>" buffer-file-name)
-		   "ksh")
-		  ((string-match "[.]csh\\>" buffer-file-name)
-		   "csh"))))
-    (sh-set-shell (or interpreter sh-shell-file) nil nil))
+  (sh-set-shell
+   (cond ((save-excursion
+            (goto-char (point-min))
+            (looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)"))
+          (match-string 2))
+         ((not buffer-file-name)
+          sh-shell-file)
+         ;; Checks that use `buffer-file-name' follow.
+         ((string-match "\\.m?spec\\'" buffer-file-name)
+          "rpm")
+         ((string-match "[.]sh\\>" buffer-file-name)
+          "sh")
+         ((string-match "[.]bash\\>" buffer-file-name)
+          "bash")
+         ((string-match "[.]ksh\\>" buffer-file-name)
+          "ksh")
+         ((string-match "[.]csh\\>" buffer-file-name)
+          "csh")
+         (t
+          sh-shell-file))
+   nil nil)
   (run-mode-hooks 'sh-mode-hook))
 
 ;;;###autoload
--- a/man/ChangeLog	Sun Feb 26 06:32:30 2006 +0000
+++ b/man/ChangeLog	Sun Feb 26 07:09:24 2006 +0000
@@ -1,3 +1,26 @@
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* cc-mode.texi: Rename c-hungry-backspace to
+	c-hungry-delete-backwards, at the request of RMS.  Leave the old
+	name as an alias.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* cc-mode.texi: Correct the definition of c-beginning-of-defun, to
+	include the function header within the defun.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* cc-mode.texi: Correct two typos.
+
+2006-02-24  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* cc-mode.texi (Comment Commands): State that C-u M-; kills any
+	existing comment.
+	(Electric Keys): Add a justification for electric indentation.
+	(Hungry WS Deletion): Clear up the names and complications of the
+	BACKSPACE and DELETE keys.
+	
 2006-02-23  Juri Linkov  <juri@jurta.org>
 
 	* faq.texi (Common requests): Move `Turning on auto-fill by
@@ -810,6 +833,13 @@
 	prefix keys even when mark is active.  Decribe that RET moves
 	cursor to next corner in rectangle; clarify insert around rectangle.
 
+2005-12-08  Alan Mackenzie <bug-cc-mode@gnu.org>
+
+	* cc-mode.texi: The manual has been extensively revised: the
+	information about using CC Mode has been separated from the larger
+	and more difficult chapters about configuration.  It has been
+	updated for CC Mode 5.31.
+
 2005-12-05  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* pgg.texi (User Commands): Fix description of pgg-verify-region.
--- a/man/cc-mode.texi	Sun Feb 26 06:32:30 2006 +0000
+++ b/man/cc-mode.texi	Sun Feb 26 07:09:24 2006 +0000
@@ -210,7 +210,7 @@
 
 This manual was generated from $Revision$ of $RCSfile$, which can be
 downloaded from
-@url{http://cvs.sf.net/viewcvs.py/cc-mode/cc-mode/cc-mode.texi}.
+@url{http://cvs.savannah.gnu.org/viewcvs/emacs/emacs/man/cc-mode.texi}.
 @end titlepage
 
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -447,7 +447,7 @@
 lists the standard styles that @ccmode{} supplies.
 
 @item
-The next few chapters, describe in detail how to customize the various
+The next few chapters describe in detail how to customize the various
 features of @ccmode{}.
 
 @item
@@ -525,7 +525,7 @@
 be disconcerting until you get used to it.  To disable @dfn{electric
 indentation} in the current buffer, type @kbd{C-c C-l}.  Type the same
 thing to enable it again.  To have electric indentation disabled by
-default, put the following into your @file{.emacs} mode@footnote{There
+default, put the following into your @file{.emacs} file@footnote{There
 is no ``easy customization'' facility for making this change.}:
 
 @example
@@ -836,8 +836,9 @@
 (@pxref{Comments,,, xemacs, XEmacs User's Manual})
 @end ifset
 and the variables below.  Finally, position the point after the
-comment starter.  This is a standard Emacs command, but @ccmode{}
-enhances it a bit with two variables:
+comment starter.  @kbd{C-u M-;} kills any comment on the current line,
+together with any whitespace before it.  This is a standard Emacs
+command, but @ccmode{} enhances it a bit with two variables:
 
 @defopt c-indent-comment-alist
 @vindex indent-comment-alist (c-)
@@ -887,12 +888,14 @@
 @findex end-of-defun (c-)
 @findex beginning-of-defun
 @findex end-of-defun
-Move to the start or end of the current top-level definition, this
-being the outermost brace pair which encloses point.  These functions
-are analogous to the Emacs built-in commands @code{beginning-of-defun}
-and @code{end-of-defun}, except they eliminate the constraint that the
-top-level opening brace of the defun must be in column zero.  See
-@ref{Defuns,,,@emacsman{}, @emacsmantitle{}}, for more information.
+Move to the start or end of the current top-level definition.  This is
+the outermost brace pair which encloses point, together with the
+function header or similar preamble which precedes the opening brace.
+These functions are analogous to the Emacs built-in commands
+@code{beginning-of-defun} and @code{end-of-defun}, except they
+eliminate the constraint that the top-level opening brace of the defun
+must be in column zero.  See @ref{Defuns,,,@emacsman{},
+@emacsmantitle{}}, for more information.
 
 Depending on the coding style you're using, you might prefer these two
 commands to the standard Emacs ones.  If so, consider binding them to
@@ -1220,15 +1223,16 @@
 
 Most punctuation keys provide @dfn{electric} behavior - as well as
 inserting themselves they perform some other action, such as
-reindenting the line.  A few keywords, such as @code{else}, also
-trigger electric action.
+reindenting the line.  This reindentation saves you from having to
+reindent a line manually after typing, say, a @samp{@}}.  A few
+keywords, such as @code{else}, also trigger electric action.
 
 You can inhibit the electric behaviour described here by disabling
-electric minor mode (@pxref{Minor Modes}.)
-
-Common to all of them is that they only behave electrically when used
-in normal code (as contrasted with getting typed in a string literal
-or comment).  Those which cause re-indentation do so only when
+electric minor mode (@pxref{Minor Modes}).
+
+Common to all these keys is that they only behave electrically when
+used in normal code (as contrasted with getting typed in a string
+literal or comment).  Those which cause re-indentation do so only when
 @code{c-syntactic-indentation} has a non-@code{nil} value (which it
 does by default).
 
@@ -1453,8 +1457,6 @@
 @cindex hungry-deletion
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-@kindex C-d
-
 If you want to delete an entire block of whitespace at point, you can
 use @dfn{hungry deletion}.  This deletes all the contiguous whitespace
 either before point or after point in a single operation.
@@ -1468,6 +1470,10 @@
 useful.  In fact, you might find yourself wanting it in @strong{all}
 your editing modes!
 
+Loosely speaking, in what follows, @dfn{@key{DEL}} means ``the
+backspace key'' and @dfn{@key{DELETE}} means ``the forward delete
+key''.  This is discussed in more detail below.
+
 There are two different ways you can use hungry deletion:
 
 @table @asis
@@ -1476,7 +1482,7 @@
 c-toggle-hungry-state}@footnote{Prior to @ccmode{} 5.31, this command
 was bound to @kbd{C-c C-d}.  @kbd{C-c C-d} is now the default binding
 for @code{c-hungry-delete-forward}.} (@pxref{Minor Modes}.)  This
-makes @kbd{@key{DEL}} and @kbd{C-d} do forward and backwards hungry
+makes @kbd{@key{DEL}} and @kbd{C-d} do backwards and forward hungry
 deletion.
 
 @table @asis
@@ -1524,61 +1530,62 @@
 
 @item Using Distinct Bindings
 The other (newer and recommended) way to use hungry deletion is to
-perform @code{c-hungry-backspace} and @code{c-hungry-delete-forward}
-directly through their key sequences rather than using the minor mode
-toggling.
+perform @code{c-hungry-delete-backwards} and
+@code{c-hungry-delete-forward} directly through their key sequences
+rather than using the minor mode toggling.
 
 @table @asis
-@item @kbd{C-c C-@key{Backspace}}, @kbd{C-c DEL}, or @kbd{C-c @key{Backspace}} (@code{c-hungry-backspace})
+@item @kbd{C-c C-@key{DEL}}, or @kbd{C-c @key{DEL}} (@code{c-hungry-delete-backwards})@footnote{This command was formerly known as @code{c-hungry-backspace}.}
 @kindex C-c C-<backspace>
+@kindex C-c <backspace>
+@kindex C-c C-DEL
 @kindex C-c DEL
-@kindex C-c <backspace>
-@findex c-hungry-backspace
-@findex hungry-backspace (c-)
+@findex c-hungry-delete-backwards
+@findex hungry-delete-backwards (c-)
 Delete any amount of whitespace in the backwards direction (regardless
 whether hungry-delete mode is enabled or not).  This command is bound
-to both @kbd{C-c C-@key{Backspace}} and @kbd{C-c @key{Backspace}},
-since the more natural one, @kbd{C-c C-@key{Backspace}}, is sometimes
-difficult to type at a character terminal.
-
-@item @kbd{C-c C-@key{Delete}}, @kbd{C-c C-d}, or @kbd{C-c @key{Delete}} (@code{c-hungry-delete-forward})
-@kindex C-c C-<delete>
+to both @kbd{C-c C-@key{DEL}} and @kbd{C-c @key{DEL}}, since the more
+natural one, @kbd{C-c C-@key{DEL}}, is sometimes difficult to type at
+a character terminal.
+
+@item @kbd{C-c C-d}, @kbd{C-c C-@key{DELETE}}, or @kbd{C-c @key{DELETE}} (@code{c-hungry-delete-forward})
 @kindex C-c C-d
-@kindex C-c <delete>
+@kindex C-c C-<DELETE>
+@kindex C-c <DELETE>
 @findex c-hungry-delete-forward
 @findex hungry-delete-forward (c-)
 Delete any amount of whitespace in the forward direction (regardless
 whether hungry-delete mode is enabled or not).  This command is bound
-to both @kbd{C-c C-@key{Delete}} and @kbd{C-c @key{Delete}} for the
-same reason as for @key{Backspace} above.
+to both @kbd{C-c C-@key{DELETE}} and @kbd{C-c @key{DELETE}} for the
+same reason as for @key{DEL} above.
 @end table
 @end table
 
 @kindex <delete>
 @kindex <backspace>
 
-When we talk about @kbd{DEL}, @kbd{C-d}, @key{Backspace} and
-@key{Delete} above, we actually do so without connecting them to the
-physical keys commonly known as @key{Backspace} and @key{Delete}.  The
-default bindings to those two keys depends on the flavor of (X)Emacs
-you are using.
+When we talk about @kbd{@key{DEL}}, and @kbd{@key{DELETE}} above, we
+actually do so without connecting them to the physical keys commonly
+known as @key{Backspace} and @key{Delete}.  The default bindings to
+those two keys depends on the flavor of (X)Emacs you are using.
 
 @findex c-electric-delete
 @findex electric-delete (c-)
 @findex c-hungry-delete
 @findex hungry-delete (c-)
 @vindex delete-key-deletes-forward
-
 In XEmacs 20.3 and beyond, the @key{Backspace} key is bound to
 @code{c-electric-backspace} and the @key{Delete} key is bound to
 @code{c-electric-delete}.  You control the direction it deletes in by
 setting the variable @code{delete-key-deletes-forward}, a standard
-XEmacs variable.  When this variable is non-@code{nil},
-@code{c-electric-delete} will do forward deletion with
-@code{c-electric-delete-forward}, otherwise it does backward deletion
-with @code{c-electric-backspace}.  Similarly, @kbd{C-c @key{Delete}}
-and @kbd{C-c C-@key{Delete}} are bound to @code{c-hungry-delete} which
-is controlled in the same way by @code{delete-key-deletes-forward}.
+XEmacs variable.
+@c This variable is encapsulated by XEmacs's (defsubst delete-forward-p ...).
+When this variable is non-@code{nil}, @code{c-electric-delete} will do
+forward deletion with @code{c-electric-delete-forward}, otherwise it
+does backward deletion with @code{c-electric-backspace}.  Similarly,
+@kbd{C-c @key{Delete}} and @kbd{C-c C-@key{Delete}} are bound to
+@code{c-hungry-delete} which is controlled in the same way by
+@code{delete-key-deletes-forward}.
 
 @findex normal-erase-is-backspace-mode
 
--- a/src/ChangeLog	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/ChangeLog	Sun Feb 26 07:09:24 2006 +0000
@@ -1,3 +1,47 @@
+2006-02-25  Chong Yidong  <cyd@stupidchicken.com>
+
+	* xterm.h (x_catch_errors) Return value changed to void.
+	(x_uncatch_errors): Unused count argument deleted.
+	
+	* xterm.c (x_catch_errors): Don't use record_unwind_protect, since
+	it can be called in a signal handler.
+	(x_catch_errors_unwind): Function deleted.
+	(x_uncatch_errors): Deallocate last x_error_message_stack struct.
+	(x_check_errors): Call x_uncatch_errors before signalling error.
+
+	(x_load_font, x_term_init, XTmouse_position, handle_one_xevent)
+	(x_connection_closed, x_list_fonts): Use new versions of
+	x_catch_errors and x_uncatch_errors.
+
+	* xselect.c (x_own_selection, x_decline_selection_request)
+	(x_reply_selection_request, x_get_foreign_selection)
+	(Fx_get_atom_name, Fx_send_client_event): Likewise.
+
+	* xfns.c (x_real_positions, x_set_mouse_color, Fx_focus_frame):
+	Likewise.
+
+	* eval.c (record_unwind_protect): Add an assertion.
+
+2006-02-25  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* process.c (Fmake_network_process): Init the process's mark.
+
+2006-02-25  Kim F. Storm  <storm@cua.dk>
+
+	* buffer.c (modify_overlay): Force redisplay if we modify an
+	overlay at the end of the buffer.
+
+2006-02-24  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* gtkutil.c (xg_get_image_for_pixmap): If x_find_image_file returns
+	nil the image file has been removed, in that case use the (cached)
+	pixmap.
+
+2006-02-24  Kenichi Handa  <handa@m17n.org>
+
+	* fileio.c (Finsert_file_contents): When a text is replaced
+	partially, be sure to set point before the inserted characters.
+
 2006-02-23  Zhang Wei  <id.brep@gmail.com>  (tiny change)
 
 	* xfns.c (Fx_file_dialog): Return a decoded file name.
--- a/src/buffer.c	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/buffer.c	Sun Feb 26 07:09:24 2006 +0000
@@ -3665,6 +3665,10 @@
   /* If multiple windows show this buffer, we must do other windows.  */
   else if (buffer_shared > 1)
     windows_or_buffers_changed = 1;
+  /* If we modify an overlay at the end of the buffer, we cannot
+     be sure that window end is still valid.  */
+  else if (end >= ZV && start <= ZV)
+    windows_or_buffers_changed = 1;
 
   ++BUF_OVERLAY_MODIFF (buf);
 }
@@ -4106,6 +4110,7 @@
 	      == OVERLAY_POSITION (OVERLAY_END (overlay))))
 	Fdelete_overlay (overlay);
     }
+
   return value;
 }
 
--- a/src/eval.c	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/eval.c	Sun Feb 26 07:09:24 2006 +0000
@@ -3199,6 +3199,8 @@
      Lisp_Object (*function) P_ ((Lisp_Object));
      Lisp_Object arg;
 {
+  eassert (!handling_signal);
+
   if (specpdl_ptr == specpdl + specpdl_size)
     grow_specpdl ();
   specpdl_ptr->func = function;
--- a/src/fileio.c	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/fileio.c	Sun Feb 26 07:09:24 2006 +0000
@@ -4397,6 +4397,8 @@
 			  same_at_start_charpos, inserted_chars, 0);
       /* Set `inserted' to the number of inserted characters.  */
       inserted = PT - temp;
+      /* Set point before the inserted characters.  */
+      SET_PT_BOTH (temp, same_at_start);
 
       unbind_to (this_count, Qnil);
 
--- a/src/gtkutil.c	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/gtkutil.c	Sun Feb 26 07:09:24 2006 +0000
@@ -327,6 +327,7 @@
      look good in all cases.  */
   Lisp_Object specified_file = Qnil;
   Lisp_Object tail;
+  Lisp_Object file;
   extern Lisp_Object QCfile;
 
   for (tail = XCDR (img->spec);
@@ -335,23 +336,18 @@
     if (EQ (XCAR (tail), QCfile))
       specified_file = XCAR (XCDR (tail));
 
-  if (STRINGP (specified_file))
+  /* We already loaded the image once before calling this
+     function, so this only fails if the image file has been removed.
+     In that case, use the pixmap already loaded.  */
+
+  if (STRINGP (specified_file)
+      && STRINGP (file = x_find_image_file (specified_file)))
     {
-      Lisp_Object file = Qnil;
-      struct gcpro gcpro1;
-      GCPRO1 (file);
-
-      file = x_find_image_file (specified_file);
-      /* We already loaded the image once before calling this
-         function, so this should not fail.  */
-      xassert (STRINGP (file) != 0);
-
       if (! old_widget)
         old_widget = GTK_IMAGE (gtk_image_new_from_file (SSDATA (file)));
       else
         gtk_image_set_from_file (old_widget, SSDATA (file));
 
-      UNGCPRO;
       return GTK_WIDGET (old_widget);
     }
 
--- a/src/process.c	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/process.c	Sun Feb 26 07:09:24 2006 +0000
@@ -1583,7 +1583,7 @@
 #endif
 
   /* Make the process marker point into the process buffer (if any).  */
-  if (!NILP (buffer))
+  if (BUFFERP (buffer))
     set_marker_both (XPROCESS (proc)->mark, buffer,
 		     BUF_ZV (XBUFFER (buffer)),
 		     BUF_ZV_BYTE (XBUFFER (buffer)));
@@ -3356,6 +3356,12 @@
   if (is_server && socktype == SOCK_STREAM)
     p->status = Qlisten;
 
+  /* Make the process marker point into the process buffer (if any).  */
+  if (BUFFERP (buffer))
+    set_marker_both (p->mark, buffer,
+		     BUF_ZV (XBUFFER (buffer)),
+		     BUF_ZV_BYTE (XBUFFER (buffer)));
+
 #ifdef NON_BLOCKING_CONNECT
   if (is_non_blocking_client)
     {
--- a/src/xfns.c	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/xfns.c	Sun Feb 26 07:09:24 2006 +0000
@@ -578,11 +578,9 @@
   int had_errors = 0;
   Window win = f->output_data.x->parent_desc;
 
-  int count;
-
   BLOCK_INPUT;
 
-  count = x_catch_errors (FRAME_X_DISPLAY (f));
+  x_catch_errors (FRAME_X_DISPLAY (f));
 
   if (win == FRAME_X_DISPLAY_INFO (f)->root_window)
     win = FRAME_OUTER_WINDOW (f);
@@ -669,7 +667,7 @@
       had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));
     }
 
-  x_uncatch_errors (FRAME_X_DISPLAY (f), count);
+  x_uncatch_errors (FRAME_X_DISPLAY (f));
 
   UNBLOCK_INPUT;
 
@@ -947,7 +945,6 @@
   Display *dpy = FRAME_X_DISPLAY (f);
   Cursor cursor, nontext_cursor, mode_cursor, hand_cursor;
   Cursor hourglass_cursor, horizontal_drag_cursor;
-  int count;
   unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
   unsigned long mask_color = x->background_pixel;
 
@@ -964,7 +961,7 @@
   BLOCK_INPUT;
 
   /* It's not okay to crash if the user selects a screwy cursor.  */
-  count = x_catch_errors (dpy);
+  x_catch_errors (dpy);
 
   if (!NILP (Vx_pointer_shape))
     {
@@ -1025,7 +1022,7 @@
 
   /* Check and report errors with the above calls.  */
   x_check_errors (dpy, "can't set cursor shape: %s");
-  x_uncatch_errors (dpy, count);
+  x_uncatch_errors (dpy);
 
   {
     XColor fore_color, back_color;
@@ -3425,13 +3422,12 @@
 {
   struct frame *f = check_x_frame (frame);
   Display *dpy = FRAME_X_DISPLAY (f);
-  int count;
 
   BLOCK_INPUT;
-  count = x_catch_errors (dpy);
+  x_catch_errors (dpy);
   XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
 		  RevertToParent, CurrentTime);
-  x_uncatch_errors (dpy, count);
+  x_uncatch_errors (dpy);
   UNBLOCK_INPUT;
 
   return Qnil;
--- a/src/xselect.c	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/xselect.c	Sun Feb 26 07:09:24 2006 +0000
@@ -402,16 +402,15 @@
   Time time = last_event_timestamp;
   Atom selection_atom;
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (sf);
-  int count;
 
   CHECK_SYMBOL (selection_name);
   selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name);
 
   BLOCK_INPUT;
-  count = x_catch_errors (display);
+  x_catch_errors (display);
   XSetSelectionOwner (display, selection_atom, selecting_window, time);
   x_check_errors (display, "Can't set selection: %s");
-  x_uncatch_errors (display, count);
+  x_uncatch_errors (display);
   UNBLOCK_INPUT;
 
   /* Now update the local cache */
@@ -572,7 +571,6 @@
      struct input_event *event;
 {
   XSelectionEvent reply;
-  int count;
 
   reply.type = SelectionNotify;
   reply.display = SELECTION_EVENT_DISPLAY (event);
@@ -585,10 +583,10 @@
   /* The reason for the error may be that the receiver has
      died in the meantime.  Handle that case.  */
   BLOCK_INPUT;
-  count = x_catch_errors (reply.display);
+  x_catch_errors (reply.display);
   XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply);
   XFlush (reply.display);
-  x_uncatch_errors (reply.display, count);
+  x_uncatch_errors (reply.display);
   UNBLOCK_INPUT;
 }
 
@@ -690,7 +688,7 @@
   int format_bytes = format/8;
   int max_bytes = SELECTION_QUANTUM (display);
   struct x_display_info *dpyinfo = x_display_info_for_display (display);
-  int count;
+  int count = SPECPDL_INDEX ();
 
   if (max_bytes > MAX_SELECTION_QUANTUM)
     max_bytes = MAX_SELECTION_QUANTUM;
@@ -707,7 +705,7 @@
 
   /* #### XChangeProperty can generate BadAlloc, and we must handle it! */
   BLOCK_INPUT;
-  count = x_catch_errors (display);
+  x_catch_errors (display);
 
 #ifdef TRACE_SELECTION
   {
@@ -860,7 +858,9 @@
      UNBLOCK to enter the event loop and get possible errors delivered,
      and then BLOCK again because x_uncatch_errors requires it.  */
   BLOCK_INPUT;
-  x_uncatch_errors (display, count);
+
+  unbind_to (count, Qnil);
+  x_uncatch_errors (display);
   UNBLOCK_INPUT;
 }
 
@@ -1392,7 +1392,7 @@
 
   BLOCK_INPUT;
 
-  count = x_catch_errors (display);
+  x_catch_errors (display);
 
   TRACE2 ("Get selection %s, type %s",
 	  XGetAtomName (display, type_atom),
@@ -1409,6 +1409,8 @@
 
   frame = some_frame_on_display (dpyinfo);
 
+  count = SPECPDL_INDEX ();
+
   /* If the display no longer has frames, we can't expect
      to get many more selection requests from it, so don't
      bother trying to queue them.  */
@@ -1430,8 +1432,9 @@
   TRACE1 ("  Got event = %d", !NILP (XCAR (reading_selection_reply)));
 
   BLOCK_INPUT;
+  unbind_to (count, Qnil);
   x_check_errors (display, "Cannot get selection: %s");
-  x_uncatch_errors (display, count);
+  x_uncatch_errors (display);
   UNBLOCK_INPUT;
 
   if (NILP (XCAR (reading_selection_reply)))
@@ -2650,7 +2653,6 @@
   struct frame *f = check_x_frame (frame);
   char *name = 0;
   Lisp_Object ret = Qnil;
-  int count;
   Display *dpy = FRAME_X_DISPLAY (f);
   Atom atom;
 
@@ -2664,14 +2666,14 @@
     error ("Wrong type, value must be number or cons");
 
   BLOCK_INPUT;
-  count = x_catch_errors (dpy);
+  x_catch_errors (dpy);
 
   name = atom ? XGetAtomName (dpy, atom) : "";
 
   if (! x_had_errors_p (dpy))
     ret = make_string (name, strlen (name));
 
-  x_uncatch_errors (dpy, count);
+  x_uncatch_errors (dpy);
 
   if (atom && name) XFree (name);
   if (NILP (ret)) ret = make_string ("", 0);
@@ -2771,7 +2773,6 @@
   Lisp_Object cons;
   int size;
   struct frame *f = check_x_frame (from);
-  int count;
   int to_root;
 
   CHECK_STRING (message_type);
@@ -2841,14 +2842,14 @@
      the destination window.  But if we are sending to the root window,
      there is no such client.  Then we set the event mask to 0xffff.  The
      event then goes to clients selecting for events on the root window.  */
-  count = x_catch_errors (dpyinfo->display);
+  x_catch_errors (dpyinfo->display);
   {
     int propagate = to_root ? False : True;
     unsigned mask = to_root ? 0xffff : 0;
     XSendEvent (dpyinfo->display, wdest, propagate, mask, &event);
     XFlush (dpyinfo->display);
   }
-  x_uncatch_errors (dpyinfo->display, count);
+  x_uncatch_errors (dpyinfo->display);
   UNBLOCK_INPUT;
 
   return Qnil;
--- a/src/xterm.c	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/xterm.c	Sun Feb 26 07:09:24 2006 +0000
@@ -325,8 +325,8 @@
 void x_delete_display P_ ((struct x_display_info *));
 
 static int x_io_error_quitter P_ ((Display *));
-int x_catch_errors P_ ((Display *));
-void x_uncatch_errors P_ ((Display *, int));
+void x_catch_errors P_ ((Display *));
+void x_uncatch_errors P_ ((Display *));
 void x_lower_frame P_ ((struct frame *));
 void x_scroll_bar_clear P_ ((struct frame *));
 int x_had_errors_p P_ ((Display *));
@@ -3799,7 +3799,6 @@
 	Window win, child;
 	int win_x, win_y;
 	int parent_x = 0, parent_y = 0;
-	int count;
 
 	win = root;
 
@@ -3807,7 +3806,7 @@
 	   structure is changing at the same time this function
 	   is running.  So at least we must not crash from them.  */
 
-	count = x_catch_errors (FRAME_X_DISPLAY (*fp));
+	x_catch_errors (FRAME_X_DISPLAY (*fp));
 
 	if (FRAME_X_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame
 	    && FRAME_LIVE_P (last_mouse_frame))
@@ -3876,7 +3875,7 @@
 	if (x_had_errors_p (FRAME_X_DISPLAY (*fp)))
 	  f1 = 0;
 
-	x_uncatch_errors (FRAME_X_DISPLAY (*fp), count);
+	x_uncatch_errors (FRAME_X_DISPLAY (*fp));
 
 	/* If not, is it one of our scroll bars?  */
 	if (! f1)
@@ -5793,7 +5792,7 @@
                     Display *d = event.xclient.display;
                     /* Catch and ignore errors, in case window has been
                        iconified by a window manager such as GWM.  */
-                    int count = x_catch_errors (d);
+                    x_catch_errors (d);
                     XSetInputFocus (d, event.xclient.window,
                                     /* The ICCCM says this is
                                        the only valid choice.  */
@@ -5802,7 +5801,7 @@
                     /* This is needed to detect the error
                        if there is an error.  */
                     XSync (d, False);
-                    x_uncatch_errors (d, count);
+                    x_uncatch_errors (d);
                   }
                 /* Not certain about handling scroll bars here */
 #endif /* 0 */
@@ -7523,7 +7522,11 @@
 #define X_ERROR_MESSAGE_SIZE 200
 
 /* If non-nil, this should be a string.
-   It means catch X errors  and store the error message in this string.  */
+   It means catch X errors  and store the error message in this string.
+
+   The reason we use a stack is that x_catch_error/x_uncatch_error can
+   be called from a signal handler.
+*/
 
 struct x_error_message_stack {
   char string[X_ERROR_MESSAGE_SIZE];
@@ -7560,20 +7563,12 @@
    Calling x_uncatch_errors resumes the normal error handling.  */
 
 void x_check_errors ();
-static Lisp_Object x_catch_errors_unwind ();
-
-int
+
+void
 x_catch_errors (dpy)
      Display *dpy;
 {
-  int count = SPECPDL_INDEX ();
   struct x_error_message_stack *data = xmalloc (sizeof (*data));
-  Lisp_Object dummy;
-#ifdef ENABLE_CHECKING
-  dummy = make_number ((EMACS_INT)dpy + (EMACS_INT)x_error_message);
-#else
-  dummy = Qnil;
-#endif
 
   /* Make sure any errors from previous requests have been dealt with.  */
   XSync (dpy, False);
@@ -7582,21 +7577,19 @@
   data->string[0] = 0;
   data->prev = x_error_message;
   x_error_message = data;
-
-  record_unwind_protect (x_catch_errors_unwind, dummy);
-
-  return count;
-}
-
-/* Unbind the binding that we made to check for X errors.  */
-
-static Lisp_Object
-x_catch_errors_unwind (dummy)
-     Lisp_Object dummy;
-{
-  Display *dpy = x_error_message->dpy;
+}
+
+/* Undo the last x_catch_errors call.
+   DPY should be the display that was passed to x_catch_errors.  */
+
+void
+x_uncatch_errors (dpy)
+     Display *dpy;
+{
   struct x_error_message_stack *tmp;
 
+  eassert (x_error_message && dpy == x_error_message->dpy);
+
   /* The display may have been closed before this function is called.
      Check if it is still open before calling XSync.  */
   if (x_display_info_for_display (dpy) != 0)
@@ -7608,12 +7601,7 @@
 
   tmp = x_error_message;
   x_error_message = x_error_message->prev;
-  free (tmp);
-
-  eassert (EQ (dummy,
-	       make_number ((EMACS_INT)dpy + (EMACS_INT)x_error_message)));
-
-  return Qnil;
+  xfree (tmp);
 }
 
 /* If any X protocol errors have arrived since the last call to
@@ -7629,7 +7617,12 @@
   XSync (dpy, False);
 
   if (x_error_message->string[0])
-    error (format, x_error_message->string);
+    {
+      char string[X_ERROR_MESSAGE_SIZE];
+      bcopy (x_error_message->string, string, X_ERROR_MESSAGE_SIZE);
+      x_uncatch_errors (dpy);
+      error (format, string);
+    }
 }
 
 /* Nonzero if we had any X protocol errors
@@ -7654,19 +7647,6 @@
   x_error_message->string[0] = 0;
 }
 
-/* Stop catching X protocol errors and let them make Emacs die.
-   DPY should be the display that was passed to x_catch_errors.
-   COUNT should be the value that was returned by
-   the corresponding call to x_catch_errors.  */
-
-void
-x_uncatch_errors (dpy, count)
-     Display *dpy;
-     int count;
-{
-  unbind_to (count, Qnil);
-}
-
 #if 0
 static unsigned int x_wire_count;
 x_trace_wire ()
@@ -7723,7 +7703,6 @@
 {
   struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
   Lisp_Object frame, tail;
-  int count;
 
   error_msg = (char *) alloca (strlen (error_message) + 1);
   strcpy (error_msg, error_message);
@@ -7733,7 +7712,7 @@
      below.  Otherwise, we might end up with printing ``can't find per
      display information'' in the recursive call instead of printing
      the original message here.  */
-  count = x_catch_errors (dpy);
+  x_catch_errors (dpy);
 
   /* We have to close the display to inform Xt that it doesn't
      exist anymore.  If we don't, Xt will continue to wait for
@@ -7801,7 +7780,7 @@
   if (dpyinfo)
     x_delete_display (dpyinfo);
 
-  x_uncatch_errors (dpy, count);
+  x_uncatch_errors (dpy);
 
   if (x_display_list == 0)
     {
@@ -9424,7 +9403,6 @@
     = f ? FRAME_X_DISPLAY_INFO (f) : x_display_list;
   Display *dpy = dpyinfo->display;
   int try_XLoadQueryFont = 0;
-  int count;
   int allow_auto_scaled_font = 0;
 
   if (size < 0)
@@ -9464,7 +9442,7 @@
       /* At first, put PATTERN in the cache.  */
 
       BLOCK_INPUT;
-      count = x_catch_errors (dpy);
+      x_catch_errors (dpy);
 
       if (try_XLoadQueryFont)
 	{
@@ -9545,7 +9523,7 @@
 	    }
 	}
 
-      x_uncatch_errors (dpy, count);
+      x_uncatch_errors (dpy);
       UNBLOCK_INPUT;
 
       if (names)
@@ -9636,7 +9614,7 @@
 	      XFontStruct *thisinfo;
 
 	      BLOCK_INPUT;
-	      count = x_catch_errors (dpy);
+	      x_catch_errors (dpy);
 	      thisinfo = XLoadQueryFont (dpy,
 					 SDATA (XCAR (tem)));
 	      if (x_had_errors_p (dpy))
@@ -9646,7 +9624,7 @@
 		  thisinfo = NULL;
 		  x_clear_errors (dpy);
 		}
-	      x_uncatch_errors (dpy, count);
+	      x_uncatch_errors (dpy);
 	      UNBLOCK_INPUT;
 
 	      if (thisinfo)
@@ -9802,7 +9780,6 @@
 {
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
   Lisp_Object font_names;
-  int count;
 
   /* Get a list of all the fonts that match this name.  Once we
      have a list of matching fonts, we compare them against the fonts
@@ -9841,7 +9818,7 @@
       fontname = (char *) SDATA (XCAR (font_names));
 
     BLOCK_INPUT;
-    count = x_catch_errors (FRAME_X_DISPLAY (f));
+    x_catch_errors (FRAME_X_DISPLAY (f));
     font = (XFontStruct *) XLoadQueryFont (FRAME_X_DISPLAY (f), fontname);
     if (x_had_errors_p (FRAME_X_DISPLAY (f)))
       {
@@ -9850,7 +9827,7 @@
 	font = NULL;
 	x_clear_errors (FRAME_X_DISPLAY (f));
       }
-    x_uncatch_errors (FRAME_X_DISPLAY (f), count);
+    x_uncatch_errors (FRAME_X_DISPLAY (f));
     UNBLOCK_INPUT;
     if (!font)
       return NULL;
@@ -10778,7 +10755,6 @@
     Display *dpy = dpyinfo->display;
     XrmValue d, fr, to;
     Font font;
-    int count;
 
     d.addr = (XPointer)&dpy;
     d.size = sizeof (Display *);
@@ -10786,12 +10762,12 @@
     fr.size = sizeof (XtDefaultFont);
     to.size = sizeof (Font *);
     to.addr = (XPointer)&font;
-    count = x_catch_errors (dpy);
+    x_catch_errors (dpy);
     if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL))
       abort ();
     if (x_had_errors_p (dpy) || !XQueryFont (dpy, font))
       XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15");
-    x_uncatch_errors (dpy, count);
+    x_uncatch_errors (dpy);
   }
 #endif
 #endif
--- a/src/xterm.h	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/xterm.h	Sun Feb 26 07:09:24 2006 +0000
@@ -961,9 +961,9 @@
 void x_make_frame_visible P_ ((struct frame *));
 void x_iconify_frame P_ ((struct frame *));
 void x_wm_set_size_hint P_ ((struct frame *, long, int));
-int x_catch_errors P_ ((Display *));
+void x_catch_errors P_ ((Display *));
 int x_had_errors_p P_ ((Display *));
-void x_uncatch_errors P_ ((Display *, int));
+void x_uncatch_errors P_ ((Display *));
 void x_check_errors P_ ((Display *, char *));
 int x_text_icon P_ ((struct frame *, char *));
 int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
@@ -977,10 +977,10 @@
 extern void x_scroll_bar_clear P_ ((struct frame *));
 extern int x_text_icon P_ ((struct frame *, char *));
 extern int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
-extern int x_catch_errors P_ ((Display *));
+extern void x_catch_errors P_ ((Display *));
 extern void x_check_errors P_ ((Display *, char *));
 extern int x_had_errors_p P_ ((Display *));
-extern void x_uncatch_errors P_ ((Display *, int));
+extern void x_uncatch_errors P_ ((Display *));
 extern void x_set_window_size P_ ((struct frame *, int, int, int));
 extern void x_set_mouse_position P_ ((struct frame *, int, int));
 extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int));