changeset 108430:73ea9db7efc3

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Wed, 10 Mar 2010 15:00:47 +0000
parents c944b55d017d (current diff) 14ff9accfbd3 (diff)
children c8f7c08f4695
files
diffstat 17 files changed, 281 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/admin/ChangeLog	Sun Mar 07 11:51:19 2010 +0000
+++ b/admin/ChangeLog	Wed Mar 10 15:00:47 2010 +0000
@@ -1,3 +1,10 @@
+2010-03-10  Miles Bader  <miles@gnu.org>
+
+	* quick-install-emacs: Use more portable shell syntax.
+
+	* quick-install-emacs: (AVOID): Be more picky about files we avoid
+	installing.
+
 2010-02-14  Juanma Barranquero  <lekktu@gmail.com>
 
 	* quick-install-emacs (PRUNED): Fix typo in message.
--- a/admin/quick-install-emacs	Sun Mar 07 11:51:19 2010 +0000
+++ b/admin/quick-install-emacs	Wed Mar 10 15:00:47 2010 +0000
@@ -31,7 +31,7 @@
 PUBLIC_LIBSRC_BINARIES='b2m emacsclient etags ctags ebrowse'
 PUBLIC_LIBSRC_SCRIPTS='grep-changelog rcs-checkin'
 
-AVOID="CVS -DIC README COPYING ChangeLog ~ [.]orig$ [.]rej$ Makefile makefile stamp-subdir [.]cvsignore [.]arch-ids [{]arch[}] [.][cho]$ make-docfile testfile test-distrib"
+AVOID="CVS -DIC README COPYING ChangeLog ~ [.]orig$ [.]rej$ Makefile$ Makefile.in$ Makefile.c$ makefile$ makefile.w32-in$ stamp-subdir [.]cvsignore [.]arch-ids [{]arch[}] [.][cho]$ make-docfile testfile test-distrib"
 
 # Prune old binaries lying around in the source tree
 PRUNE=no
@@ -120,7 +120,7 @@
 EOF
       exit 0
       ;;
-    -[^-]?*)
+    -[!-]?*)
       # split concatenated single-letter options apart
       FIRST="$1"; shift
       set -- `echo $FIRST | sed 's/-\(.\)\(.*\)/-\1 -\2/'` "$@"
--- a/etc/TODO	Sun Mar 07 11:51:19 2010 +0000
+++ b/etc/TODO	Wed Mar 10 15:00:47 2010 +0000
@@ -12,7 +12,46 @@
 prepared to sign legal papers to transfer the copyright on your work
 to the FSF.
 
-* Simple tasks. These don't require much emacs knowledge, they are
+* Tentative plan for Emacs-24
+
+** Bidi
+** lexbind: I haven't checked the status of the code recently, so
+  I don't know how realistic it is to include it.  But it's been around
+  for a long time, and I trust Miles, so I have hope.
+** concurrency: including it as an "experimental" compile-time option
+  sounds good.  Of course there might still be big questions around
+  "which form of concurrency" we'll want.
+** Overhaul of customize: sounds wonderful.
+** some kind of color-theme: agreed.
+** better support for dynamic embedded graphics: I like this idea (my
+  mpc.el code could use it for the volume widget), tho I wonder if the
+  resulting efficiency will be sufficient.
+** Spread Semantic.
+** Improve the "code snippets" support: consolidate skeleton.el, tempo.el,
+  and expand.el (any other?) and then advertise/use/improve it.
+** Improve VC: yes, there's a lot of work to be done there :-(
+  And most of it could/should make it into Emacs-23.3.
+** package manager.
+
+** Random things that cross my mind right now that I'd like to see (some of
+them from my local hacks), but it's not obvious at all whether they'll
+make it.
+*** multiple inheritance for keymaps (to get rid of the
+  fix_submap_inheritance hack and to more cleanly express the
+  relationship between minibuffer-local-*-map): I've had this locally
+  for a long time, but the details of the semantics is somewhat ... delicate.
+*** prog-mode (a parent-mode, like text-mode).  Could/should provide
+  a better fill-paragraph default that uses syntax-tables to recognize
+  string/comment boundaries.
+*** provide more completion-at-point-functions.  Make existing
+  in-buffer completion use completion-at-point.
+*** "functional" function-key-map that would make it easy to add (and
+  remove) mappings like "FOO-mouse-4 -> FOO-scroll-down",
+  "FOO-tab -> ?\FOO-\t", "uppercase -> lowercase", "[fringe KEY...] ->
+  [KEY]", "H-FOO -> M-FOO", "C-x C-y FOO -> H-FOO", ...
+
+
+* Simple tasks. These don't require much Emacs knowledge, they are
 suitable for anyone from beginners to experts.
 
 ** Convert modes that use view-mode to be derived from special-mode instead.
--- a/lib-src/ChangeLog	Sun Mar 07 11:51:19 2010 +0000
+++ b/lib-src/ChangeLog	Wed Mar 10 15:00:47 2010 +0000
@@ -21,7 +21,7 @@
 
 2009-11-23  Tobias Ringström  <tobias@ringis.se>  (tiny change)
 
-	* etags.c (absolute_filename): Use memove if we have it for
+	* etags.c (absolute_filename): Use memmove if we have it for
 	overlapping copy.
 
 2009-11-04  Dan Nicolaescu  <dann@ics.uci.edu>
--- a/lisp/ChangeLog	Sun Mar 07 11:51:19 2010 +0000
+++ b/lisp/ChangeLog	Wed Mar 10 15:00:47 2010 +0000
@@ -1,3 +1,48 @@
+2010-03-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* vc-git.el (vc-git-revision-table): Include remote branches.
+
+2010-03-10  Kim F. Storm  <storm@cua.dk>
+
+	Animated image API.
+	http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00211.html
+
+	* image.el (image-animate-max-time): New defcustom.
+	(image-animated-types): New defconst.
+	(create-animated-image, image-animate-timer)
+	(image-animate-start, image-animate-stop, image-animate-timeout)
+	(image-animated-p): New functions.
+
+	* image-mode.el (image-toggle-display-image):
+	Replace `create-image' with `create-animated-image'.
+
+2010-03-09  Miles Bader  <Miles Bader <miles@gnu.org>>
+
+	* vc-git.el (vc-git-print-log): Use "tformat:" for shortlog,
+	instead of "format:"; this ensures that the output is
+	newline-terminated.
+
+2010-03-08  Chong Yidong  <cyd@stupidchicken.com>
+
+	* mail/rfc822.el (rfc822-addresses): Use nested catches to ensure
+	that all errors are caught, and that the return value is always a
+	list (Bug#5692).
+
+2010-03-08  Kenichi Handa  <handa@m17n.org>
+
+	* language/misc-lang.el (windows-1256): New coding system.
+	(cp1256): New alias of windows-1256 (bug#5690).
+
+2010-03-07  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* mail/rfc822.el (rfc822-addresses): Move catch clause down around
+	call to rfc822-bad-address.  (Bug#5692)
+
+2010-03-07  Štěpán Němec  <stepnem@gmail.com>  (tiny change)
+
+	* vc-git.el (vc-git-annotate-extract-revision-at-line): Use
+	vc-git-root as default directory for revision path (Bug#5657).
+
 2010-03-06  Chong Yidong  <cyd@stupidchicken.com>
 
 	* calculator.el (calculator): Don't bind split-window-keep-point
@@ -66,7 +111,7 @@
 2010-03-01  Alan Mackenzie  <bug-cc-mode@gnu.org>
 
 	* cc-engine.el (c-remove-stale-state-cache): Take account of when
-	`good-pos' is in the same macro as `here'.  Fixes bug 5649.
+	`good-pos' is in the same macro as `here'.  Fixes bug#5649.
 
 2010-02-28  Katsumi Yamaoka  <yamaoka@jpl.org>
 
@@ -175,8 +220,8 @@
 
 2010-02-20  Kevin Ryde  <user42@zip.com.au>
 
-	* progmodes/compile.el (compilation-error-regexp-alist-alist): In
-	`watcom' anchor regexp to start of line, to avoid slowness
+	* progmodes/compile.el (compilation-error-regexp-alist-alist):
+	In `watcom' anchor regexp to start of line, to avoid slowness
 	(Bug#5599).
 
 2010-02-20  Eli Zaretskii  <eliz@gnu.org>
@@ -241,9 +286,9 @@
 
 2010-02-17  Mark A. Hershberger  <mah@everybody.org>
 
-	* vc-bzr.el: fix typo in Known Bugs section.
-
-	* isearch.el (isearch-update-post-hook): New hook
+	* vc-bzr.el: Fix typo in Known Bugs section.
+
+	* isearch.el (isearch-update-post-hook): New hook.
 	(isearch-update): Use the new hook.
 
 2010-02-16  Michael Albinus  <michael.albinus@gmx.de>
--- a/lisp/image-mode.el	Sun Mar 07 11:51:19 2010 +0000
+++ b/lisp/image-mode.el	Wed Mar 10 15:00:47 2010 +0000
@@ -466,7 +466,7 @@
 			    (buffer-substring-no-properties (point-min) (point-max)))
 			 filename))
 	 (type (image-type file-or-data nil data-p))
-	 (image (create-image file-or-data type data-p))
+	 (image (create-animated-image file-or-data type data-p))
 	 (props
 	  `(display ,image
 		    intangible ,image
--- a/lisp/image.el	Sun Mar 07 11:51:19 2010 +0000
+++ b/lisp/image.el	Wed Mar 10 15:00:47 2010 +0000
@@ -584,7 +584,111 @@
   (declare (doc-string 3))
   `(defvar ,symbol (find-image ',specs) ,doc))
 
+
+;;; Animated image API
 
+(defcustom image-animate-max-time 30
+  "Time in seconds to animate images."
+  :type 'integer
+  :version "22.1"
+  :group 'image)
+
+(defconst image-animated-types '(gif)
+  "List of supported animated image types.")
+
+;;;###autoload
+(defun create-animated-image (file-or-data &optional type data-p &rest props)
+  "Create an animated image.
+FILE-OR-DATA is an image file name or image data.
+Optional TYPE is a symbol describing the image type.  If TYPE is omitted
+or nil, try to determine the image type from its first few bytes
+of image data.  If that doesn't work, and FILE-OR-DATA is a file name,
+use its file extension as image type.
+Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data.
+Optional PROPS are additional image attributes to assign to the image,
+like, e.g. `:mask MASK'.
+Value is the image created, or nil if images of type TYPE are not supported.
+
+Images should not be larger than specified by `max-image-size'."
+  (setq type (image-type file-or-data type data-p))
+  (when (image-type-available-p type)
+    (let* ((animate (memq type image-animated-types))
+	   (image
+	    (append (list 'image :type type (if data-p :data :file) file-or-data)
+		    (if animate '(:index 0 :mask heuristic))
+		    props)))
+      (if animate
+	  (image-animate-start image))
+      image)))
+
+(defun image-animate-timer (image)
+  "Return the animation timer for image IMAGE."
+  ;; See cancel-function-timers
+  (let ((tail timer-list) timer)
+    (while tail
+      (setq timer (car tail)
+	    tail (cdr tail))
+      (if (and (eq (aref timer 5) #'image-animate-timeout)
+	       (consp (aref timer 6))
+	       (eq (car (aref timer 6)) image))
+	  (setq tail nil)
+	(setq timer nil)))
+    timer))
+
+(defun image-animate-start (image &optional max-time)
+  "Start animation of image IMAGE.
+Optional second arg MAX-TIME is number of seconds to animate image,
+or t to animate infinitely."
+  (let ((anim (image-animated-p image))
+	timer tmo)
+    (when anim
+      (if (setq timer (image-animate-timer image))
+	  (setcar (nthcdr 3 (aref timer 6)) max-time)
+	(setq tmo (* (cdr anim) 0.01))
+	(setq max-time (or max-time image-animate-max-time))
+	(run-with-timer tmo nil #'image-animate-timeout
+			image 1 (car anim)
+			(if (numberp max-time)
+			    (- max-time tmo)
+			  max-time))))))
+
+(defun image-animate-stop (image)
+  "Stop animation of image."
+  (let ((timer (image-animate-timer image)))
+    (when timer
+      (cancel-timer timer))))
+
+(defun image-animate-timeout (image ino count time-left)
+  (if (>= ino count)
+      (setq ino 0))
+  (plist-put (cdr image) :index ino)
+  (force-window-update)
+  (let ((anim (image-animated-p image)) tmo)
+    (when anim
+      (setq tmo (* (cdr anim) 0.01))
+      (unless (and (= ino 0) (numberp time-left) (< time-left tmo))
+	(run-with-timer tmo nil #'image-animate-timeout
+			image (1+ ino) count
+			(if (numberp time-left)
+			    (- time-left tmo)
+			  time-left))))))
+
+(defun image-animated-p (image)
+  "Return non-nil if image is animated.
+Actually, return value is a cons (IMAGES . DELAY) where IMAGES
+is the number of sub-images in the animated image, and DELAY
+is the delay in 100ths of a second until the next sub-image
+shall be displayed."
+  (cond
+   ((eq (plist-get (cdr image) :type) 'gif)
+    (let* ((extdata (image-extension-data image))
+	   (images (plist-get extdata 'count))
+	   (anim (plist-get extdata #xF9)))
+      (and (integerp images) (> images 1)
+	   (stringp anim) (>= (length anim) 4)
+	   (cons images (+ (aref anim 1) (* (aref anim 2) 256))))))))
+
+
 (provide 'image)
 
 ;; arch-tag: 8e76a07b-eb48-4f3e-a7a0-1a7ba9f096b3
--- a/lisp/language/misc-lang.el	Sun Mar 07 11:51:19 2010 +0000
+++ b/lisp/language/misc-lang.el	Wed Mar 10 15:00:47 2010 +0000
@@ -50,6 +50,14 @@
   :charset-list '(iso-8859-6)
   :mime-charset 'iso-8859-6)
 
+(define-coding-system 'windows-1256
+  "windows-1256 (Arabic) encoding (MIME: WINDOWS-1256)"
+  :coding-type 'charset
+  :mnemonic ?A
+  :charset-list '(windows-1256)
+  :mime-charset 'windows-1256)
+(define-coding-system-alias 'cp1256 'windows-1256)
+
 (provide 'misc-lang)
 
 ;; arch-tag: 6953585c-1a1a-4c09-be82-a2518afb6074
--- a/lisp/mail/rfc822.el	Sun Mar 07 11:51:19 2010 +0000
+++ b/lisp/mail/rfc822.el	Wed Mar 10 15:00:47 2010 +0000
@@ -290,32 +290,36 @@
               (replace-match "\\1 " t))
 
             (goto-char (point-min))
-            (let ((list ())
-                  tem
-                  ;; This is for rfc822-bad-address.  Give it a non-nil
-                  ;; initial value to prevent rfc822-bad-address from
-                  ;; raising a wrong-type-argument error
-                  (rfc822-address-start (point)))
-              (catch 'address         ; this is for rfc822-bad-address
-                (rfc822-nuke-whitespace)
-                (while (not (eobp))
-                  (setq rfc822-address-start (point))
-                  (setq tem
-                        (cond ((rfc822-looking-at ?\,)
-                               nil)
-                              ((looking-at "[][\000-\037@;:\\.>)]")
-                               (forward-char)
-                               (rfc822-bad-address
-                                (format "Strange character \\%c found"
-                                        (preceding-char))))
-                              (t
-                               (rfc822-addresses-1 t))))
-                  (cond ((null tem))
-                        ((stringp tem)
-                         (setq list (cons tem list)))
-                        (t
-                         (setq list (nconc (nreverse tem) list)))))
-                (nreverse list))))
+	    ;; Give `rfc822-address-start' a non-nil initial value to
+	    ;; prevent `rfc822-bad-address' from raising a
+	    ;; `wrong-type-argument' error.
+            (let* ((rfc822-address-start (point))
+		   list tem
+		   (err
+		    (catch 'address
+		      ;; Note that `rfc822-nuke-whitespace' and
+		      ;; `rfc822-looking-at' can throw.
+		      (rfc822-nuke-whitespace)
+		      (while (not (eobp))
+			(setq rfc822-address-start (point))
+			(setq tem
+			      (cond ((rfc822-looking-at ?\,)
+				     nil)
+				    ((looking-at "[][\000-\037@;:\\.>)]")
+				     (forward-char)
+				     (catch 'address ; For rfc822-bad-address
+				       (rfc822-bad-address
+					(format "Strange character \\%c found"
+						(preceding-char)))))
+				    (t
+				     (rfc822-addresses-1 t))))
+			(cond ((null tem))
+			      ((stringp tem)
+			       (setq list (cons tem list)))
+			      (t
+			       (setq list (nconc (nreverse tem) list)))))
+		      nil)))
+	      (nreverse (append (if err (list err)) list))))
 	(and buf (kill-buffer buf))))))
 
 (provide 'rfc822)
--- a/lisp/net/hmac-def.el	Sun Mar 07 11:51:19 2010 +0000
+++ b/lisp/net/hmac-def.el	Wed Mar 10 15:00:47 2010 +0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1999, 2001, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
-;; Keywords: HMAC, RFC 2104
+;; Keywords: HMAC, RFC-2104
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/net/hmac-md5.el	Sun Mar 07 11:51:19 2010 +0000
+++ b/lisp/net/hmac-md5.el	Wed Mar 10 15:00:47 2010 +0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1999, 2001, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
-;; Keywords: HMAC, RFC 2104, HMAC-MD5, MD5, KEYED-MD5, CRAM-MD5
+;; Keywords: HMAC, RFC-2104, HMAC-MD5, MD5, KEYED-MD5, CRAM-MD5
 
 ;; This file is part of GNU Emacs.
 
--- a/lisp/vc-git.el	Sun Mar 07 11:51:19 2010 +0000
+++ b/lisp/vc-git.el	Wed Mar 10 15:00:47 2010 +0000
@@ -587,7 +587,7 @@
 		'("log" "--no-color")
 		(when shortlog
 		  '("--graph" "--decorate" "--date=short"
-                    "--pretty=format:%d%h  %ad  %s" "--abbrev-commit"))
+                    "--pretty=tformat:%d%h  %ad  %s" "--abbrev-commit"))
 		(when limit (list "-n" (format "%s" limit)))
 		(when start-revision (list start-revision))
 		'("--")))))))
@@ -673,7 +673,8 @@
     (with-temp-buffer
       (vc-git-command t nil nil "for-each-ref" "--format=%(refname)")
       (goto-char (point-min))
-      (while (re-search-forward "^refs/\\(heads\\|tags\\)/\\(.*\\)$" nil t)
+      (while (re-search-forward "^refs/\\(heads\\|tags\\|remotes\\)/\\(.*\\)$"
+                                nil t)
         (push (match-string 2) table)))
     table))
 
@@ -703,7 +704,8 @@
     (when (looking-at "\\([0-9a-f^][0-9a-f]+\\) \\(\\([^(]+\\) \\)?")
       (let ((revision (match-string-no-properties 1)))
 	(if (match-beginning 2)
-	  (cons revision (expand-file-name (match-string-no-properties 3)))
+	    (cons revision (expand-file-name (match-string-no-properties 3)
+					     (vc-git-root default-directory)))
 	  revision)))))
 
 ;;; TAG SYSTEM
--- a/src/ChangeLog	Sun Mar 07 11:51:19 2010 +0000
+++ b/src/ChangeLog	Wed Mar 10 15:00:47 2010 +0000
@@ -1,3 +1,14 @@
+2010-03-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Cleanup setup of gl_state in various parts of the code.
+	* syntax.h (SETUP_BUFFER_SYNTAX_TABLE): New macro.
+	(SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT):
+	* syntax.c (find_defun_start, Fchar_syntax, Fmatching_paren)
+	(skip_chars):
+	* regex.c (regex_compile): Use it.
+	(re_compile_pattern): Don't set gl_state.current_syntax_table since
+	it's now set in regex_compile when/if we need it.
+
 2010-03-05  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	Make it possible to C-g in a tight bytecode loop again (bug#5680).
--- a/src/keyboard.c	Sun Mar 07 11:51:19 2010 +0000
+++ b/src/keyboard.c	Wed Mar 10 15:00:47 2010 +0000
@@ -11235,6 +11235,7 @@
 	  GCPRO4 (saved.object, saved.global_code,
 		  saved.current_syntax_table, saved.old_prop);
 	  Fsignal (Qquit, Qnil);
+	  /* FIXME: AFAIK, `quit' can never return, so this code is dead!  */
 	  gl_state = saved;
 	  UNGCPRO;
 	}
--- a/src/regex.c	Sun Mar 07 11:51:19 2010 +0000
+++ b/src/regex.c	Wed Mar 10 15:00:47 2010 +0000
@@ -3070,7 +3070,7 @@
 			   syntax-table for ASCII chars, while the other chars
 			   will obey syntax-table properties.  It's not ideal,
 			   but it's the way it's been done until now.  */
-			SETUP_SYNTAX_TABLE (BEGV, 0);
+			SETUP_BUFFER_SYNTAX_TABLE ();
 
 			for (ch = 0; ch < 256; ++ch)
 			  {
@@ -4496,7 +4496,7 @@
   anchored_start = (bufp->buffer[0] == begline);
 
 #ifdef emacs
-  gl_state.object = re_match_object;
+  gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */
   {
     int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (startpos));
 
@@ -5099,7 +5099,7 @@
 
 #ifdef emacs
   int charpos;
-  gl_state.object = re_match_object;
+  gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */
   charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (pos));
   SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1);
 #endif
@@ -6504,10 +6504,6 @@
 {
   reg_errcode_t ret;
 
-#ifdef emacs
-  gl_state.current_syntax_table = current_buffer->syntax_table;
-#endif
-
   /* GNU code is written to assume at least RE_NREGS registers will be set
      (and at least one extra will be -1).  */
   bufp->regs_allocated = REGS_UNALLOCATED;
--- a/src/syntax.c	Sun Mar 07 11:51:19 2010 +0000
+++ b/src/syntax.c	Wed Mar 10 15:00:47 2010 +0000
@@ -385,8 +385,7 @@
   /* We optimize syntax-table lookup for rare updates.  Thus we accept
      only those `^\s(' which are good in global _and_ text-property
      syntax-tables.  */
-  gl_state.current_syntax_table = current_buffer->syntax_table;
-  gl_state.use_global = 0;
+  SETUP_BUFFER_SYNTAX_TABLE ();
   while (PT > BEGV)
     {
       int c;
@@ -401,8 +400,7 @@
 	  if (SYNTAX (c) == Sopen)
 	    break;
 	  /* Now fallback to the default value.  */
-	  gl_state.current_syntax_table = current_buffer->syntax_table;
-	  gl_state.use_global = 0;
+	  SETUP_BUFFER_SYNTAX_TABLE ();
 	}
       /* Move to beg of previous line.  */
       scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1);
@@ -860,11 +858,9 @@
      Lisp_Object character;
 {
   int char_int;
-  gl_state.current_syntax_table = current_buffer->syntax_table;
-
-  gl_state.use_global = 0;
   CHECK_NUMBER (character);
   char_int = XINT (character);
+  SETUP_BUFFER_SYNTAX_TABLE ();
   return make_number (syntax_code_spec[(int) SYNTAX (char_int)]);
 }
 
@@ -874,10 +870,9 @@
      Lisp_Object character;
 {
   int char_int, code;
-  gl_state.current_syntax_table = current_buffer->syntax_table;
-  gl_state.use_global = 0;
   CHECK_NUMBER (character);
   char_int = XINT (character);
+  SETUP_BUFFER_SYNTAX_TABLE ();
   code = SYNTAX (char_int);
   if (code == Sopen || code == Sclose)
     return SYNTAX_MATCH (char_int);
@@ -1752,7 +1747,7 @@
        let's initialize it manually.
        We ignore syntax-table text-properties for now, since that's
        what we've done in the past.  */
-    SETUP_SYNTAX_TABLE (BEGV, 0);
+    SETUP_BUFFER_SYNTAX_TABLE ();
     if (forwardp)
       {
 	if (multibyte)
--- a/src/syntax.h	Sun Mar 07 11:51:19 2010 +0000
+++ b/src/syntax.h	Wed Mar 10 15:00:47 2010 +0000
@@ -245,6 +245,14 @@
 	 1)							\
       : 0))
 
+/* This macro sets up the buffer-global syntax table.  */
+#define SETUP_BUFFER_SYNTAX_TABLE()					\
+do									\
+  {									\
+    gl_state.use_global = 0;						\
+    gl_state.current_syntax_table = current_buffer->syntax_table;	\
+  } while (0)
+
 /* This macro should be called with FROM at the start of forward
    search, or after the last position of the backward search.  It
    makes sure that the first char is picked up with correct table, so
@@ -256,12 +264,11 @@
 #define SETUP_SYNTAX_TABLE(FROM, COUNT)					\
 do									\
   {									\
+    SETUP_BUFFER_SYNTAX_TABLE ();					\
     gl_state.b_property = BEGV;						\
     gl_state.e_property = ZV + 1;					\
     gl_state.object = Qnil;						\
-    gl_state.use_global = 0;						\
     gl_state.offset = 0;						\
-    gl_state.current_syntax_table = current_buffer->syntax_table;	\
     if (parse_sexp_lookup_properties)					\
       if ((COUNT) > 0 || (FROM) > BEGV)					\
         update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT),\
@@ -279,6 +286,7 @@
 #define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT)		\
 do									\
   {									\
+    SETUP_BUFFER_SYNTAX_TABLE ();					\
     gl_state.object = (OBJECT);						\
     if (BUFFERP (gl_state.object))					\
       {									\
@@ -305,8 +313,6 @@
 	gl_state.e_property = 1 + SCHARS (gl_state.object);		\
 	gl_state.offset = 0;						\
       }									\
-    gl_state.use_global = 0;						\
-    gl_state.current_syntax_table = current_buffer->syntax_table;	\
     if (parse_sexp_lookup_properties)					\
       update_syntax_table (((FROM) + gl_state.offset			\
 			    + (COUNT > 0 ? 0 :  -1)),			\