changeset 83476:866effff65a4

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-105 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-106 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-107 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-108 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-109 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-110 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-37 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-516
author Karoly Lorentey <lorentey@elte.hu>
date Tue, 21 Feb 2006 15:57:00 +0000
parents 88cd30b5064d (current diff) 9e57a1e7c532 (diff)
children 3a9507e5aa39
files admin/FOR-RELEASE lisp/ChangeLog lisp/loadup.el lisp/mh-e/ChangeLog lisp/progmodes/gdb-ui.el lisp/url/url-http.el lisp/url/url.el lispref/ChangeLog man/ChangeLog src/Makefile.in src/buffer.c src/fringe.c src/macterm.c src/regex.c src/xfns.c
diffstat 29 files changed, 1110 insertions(+), 445 deletions(-) [+]
line wrap: on
line diff
--- a/admin/ChangeLog	Mon Feb 20 16:35:38 2006 +0000
+++ b/admin/ChangeLog	Tue Feb 21 15:57:00 2006 +0000
@@ -1,3 +1,13 @@
+2006-02-20  Kim F. Storm  <storm@cua.dk>
+
+	* FOR-RELEASE (NEW FEATURES): Completed work on this item:
+	Rework how fringe bitmaps are defined and used.
+	Currently, bitmap usage and bitmap appearence are "mixed-up" in a
+	one-level representation.  It would be cleaner to split the
+	representation into a two-level model where first level maps
+	bitmap usage to a bitmap name, and second level maps bitmap name to
+	a bitmap appearence.
+
 2006-01-27  Chong Yidong  <cyd@stupidchicken.com>
 
 	* FOR-RELEASE: string allocation bugs fixed.
--- a/admin/FOR-RELEASE	Mon Feb 20 16:35:38 2006 +0000
+++ b/admin/FOR-RELEASE	Tue Feb 21 15:57:00 2006 +0000
@@ -33,14 +33,6 @@
 
 * NEW FEATURES
 
-** Rework how fringe bitmaps are defined and used.
-Currently, bitmap usage and bitmap appearence are "mixed-up" in a
-one-level representation.  It would be cleaner to split the
-representation into a two-level model where first level maps
-bitmap usage to a bitmap name, and second level maps bitmap name to
-a bitmap appearence.
-[Assigned to KFS]
-
 * BUGS
 
 ** Reiner Steib's 23 Jan 2006 bug report that tool bar icons don't update.
@@ -56,6 +48,15 @@
 CPU time have been observed on different Window XP configurations.
 Seems to be a problem in sys_select in w32proc.c.
 
+In its current form, it sys_select says the socket is ready, so we
+call server_accept_connection which again calls accept() which returns
+-1 with errno == WSAEWOULDBLOCK (10035) indicating that there is no
+pending connection to accept.
+
+It seems that to fix this, w32 server sockets must use WSAAsyncSelect
++ FD_ACCEPT to request notifications of incoming connections...
+
+
 * DOCUMENTATION
 
 ** Add a node to the Lisp manual describing key sequences from the
--- a/etc/NEWS	Mon Feb 20 16:35:38 2006 +0000
+++ b/etc/NEWS	Tue Feb 21 15:57:00 2006 +0000
@@ -4604,6 +4604,13 @@
 +++
 ** Customizable fringe bitmaps
 
+*** New buffer-local variables `fringe-indicator-alist' and
+`fringe-cursor-alist' maps between logical (internal) fringe indicator
+and cursor symbols and the actual fringe bitmaps to be displayed.
+This decouples the logical meaning of the fringe indicators from the
+physical appearence, as well as allowing different fringe bitmaps to
+be used in different windows showing different buffers.
+
 *** New function `define-fringe-bitmap' can now be used to create new
 fringe bitmaps, as well as change the built-in fringe bitmaps.
 
--- a/lisp/ChangeLog	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/ChangeLog	Tue Feb 21 15:57:00 2006 +0000
@@ -1,3 +1,35 @@
+2006-02-21  Kim F. Storm  <storm@cua.dk>
+
+	* fringe.el: Cleanup as file is now pre-loaded.
+	(fringe-bitmaps): Initialize unconditionally.
+	(fringe-mode, set-fringe-style): Remove autoload cookies.
+
+2006-02-21  Giorgos Keramidas  <keramida@ceid.upatras.gr>  (tiny change)
+
+	* fringe.el (fringe-bitmaps): Rename `horisontal-bar' to
+	`horizontal-bar'.
+	(fringe-cursor-alist): Use `horizontal-bar'.
+
+2006-02-20  Kim F. Storm  <storm@cua.dk>
+
+	* fringe.el (fringe-bitmaps): Update to new bitmap names.
+	(fringe-indicator-alist, fringe-cursor-alist): Initialize.
+
+	* loadup.el: Load "fringe" on window systems.
+
+2006-02-20  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gud.el (gud-speedbar-buttons): Use shadow face for all
+	out of scope components.
+
+	* progmodes/gdb-ui.el (gdb-speedbar-auto-raise): Don't enable by
+	default.
+
+2006-02-20  Chong Yidong  <cyd@stupidchicken.com>
+
+	* custom.el (customize-mark-to-save, customize-mark-as-set): Load
+	the symbol first.
+
 2006-02-20  Juanma Barranquero  <lekktu@gmail.com>
 
 	* buff-menu.el (list-buffers-noselect): Turn also "\n" into a
--- a/lisp/custom.el	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/custom.el	Tue Feb 21 15:57:00 2006 +0000
@@ -653,6 +653,7 @@
 To actually save the value, call `custom-save-all'.
 
 Return non-nil iff the `saved-value' property actually changed."
+  (custom-load-symbol symbol)
   (let* ((get (or (get symbol 'custom-get) 'default-value))
 	 (value (funcall get symbol))
 	 (saved (get symbol 'saved-value))
@@ -681,6 +682,7 @@
 default value.  Otherwise, set it to nil.
 
 Return non-nil iff the `customized-value' property actually changed."
+  (custom-load-symbol symbol)
   (let* ((get (or (get symbol 'custom-get) 'default-value))
 	 (value (funcall get symbol))
 	 (customized (get symbol 'customized-value))
--- a/lisp/fringe.el	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/fringe.el	Tue Feb 21 15:57:00 2006 +0000
@@ -1,4 +1,4 @@
-;;; fringe.el --- change fringes appearance in various ways
+;;; fringe.el --- fringe setup and control
 
 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
@@ -25,8 +25,9 @@
 
 ;;; Commentary:
 
-;; This file contains helpful functions for customizing the appearance
-;; of the fringe.
+;; This file contains code to initialize the built-in fringe bitmaps
+;; as well as helpful functions for customizing the appearance of the
+;; fringe.
 
 ;; The code is influenced by scroll-bar.el and avoid.el.  The author
 ;; gratefully acknowledge comments and suggestions made by Miles
@@ -40,33 +41,53 @@
   :version "22.1"
   :group 'frames)
 
-;; Standard fringe bitmaps
+;; Define the built-in fringe bitmaps and setup default mappings
+
+(when (boundp 'fringe-bitmaps)
+  (let ((bitmaps '(question-mark
+		   left-arrow right-arrow up-arrow down-arrow
+		   left-curly-arrow right-curly-arrow
+		   left-triangle right-triangle
+		   top-left-angle top-right-angle
+		   bottom-left-angle bottom-right-angle
+		   left-bracket right-bracket
+		   filled-rectangle hollow-rectangle
+		   filled-square hollow-square
+		   vertical-bar horizontal-bar
+		   empty-line))
+	(bn 1))
+    (while bitmaps
+      (push (car bitmaps) fringe-bitmaps)
+      (put (car bitmaps) 'fringe bn)
+      (setq bitmaps (cdr bitmaps)
+	    bn (1+ bn))))
+
+  (setq-default fringe-indicator-alist
+		'((truncation . (left-arrow right-arrow))
+		  (continuation . (left-curly-arrow right-curly-arrow))
+		  (overlay-arrow . right-triangle)
+		  (up . up-arrow)
+		  (down . down-arrow)
+		  (top . (top-left-angle top-right-angle))
+		  (bottom . (bottom-left-angle bottom-right-angle
+			     top-right-angle top-left-angle))
+		  (top-bottom . (left-bracket right-bracket
+				 top-right-angle top-left-angle))
+		  (empty-line . empty-line)
+		  (unknown . question-mark)))
+
+  (setq-default fringe-cursor-alist
+		'((box . filled-rectangle)
+		  (hollow . hollow-rectangle)
+		  (bar . vertical-bar)
+		  (hbar . horizontal-bar)
+		  (hollow-small . hollow-square))))
+
 
 (defmacro fringe-bitmap-p (symbol)
   "Return non-nil if SYMBOL is a fringe bitmap."
   `(get ,symbol 'fringe))
 
-(defvar fringe-bitmaps)
-
-(unless (or (not (boundp 'fringe-bitmaps))
-	    (get 'left-truncation 'fringe))
-  (let ((bitmaps '(left-truncation right-truncation
-		   up-arrow down-arrow
-		   continued-line continuation-line
-		   overlay-arrow
-		   top-left-angle top-right-angle
-		   bottom-left-angle bottom-right-angle
-		   left-bracket right-bracket
-		   filled-box-cursor hollow-box-cursor hollow-square
-		   bar-cursor hbar-cursor
-		   empty-line))
-	(bn 2))
-    (while bitmaps
-      (push (car bitmaps) fringe-bitmaps)
-      (put (car bitmaps) 'fringe bn)
-      (setq bitmaps (cdr bitmaps)
-	    bn (1+ bn)))))
-
 
 ;; Control presence of fringes
 
@@ -137,7 +158,6 @@
       ;; Otherwise impose the user-specified value of fringe-mode.
       (custom-initialize-reset symbol value))))
 
-;;;###autoload
 (defcustom fringe-mode nil
   "*Specify appearance of fringes on all frames.
 This variable can be nil (the default) meaning the fringes should have
@@ -195,7 +215,6 @@
 	       nil
 	     0)))))
 
-;;;###autoload
 (defun fringe-mode (&optional mode)
   "Set the default appearance of fringes on all frames.
 
@@ -221,7 +240,6 @@
   (interactive (list (fringe-query-style 'all-frames)))
   (set-fringe-mode mode))
 
-;;;###autoload
 (defun set-fringe-style (&optional mode)
   "Set the default appearance of fringes on the selected frame.
 
--- a/lisp/gnus/ChangeLog	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/gnus/ChangeLog	Tue Feb 21 15:57:00 2006 +0000
@@ -1,3 +1,9 @@
+2006-02-20  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* rfc2047.el (rfc2047-charset-to-coding-system): Don't check the
+	coding system which mm-charset-to-coding-system returns for a
+	given charset is valid.
+
 2006-02-16  Juanma Barranquero  <lekktu@gmail.com>
 
 	* html2text.el (html2text-remove-tag-list):
--- a/lisp/gnus/rfc2047.el	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/gnus/rfc2047.el	Tue Feb 21 15:57:00 2006 +0000
@@ -835,7 +835,7 @@
     (cond ((eq cs 'ascii)
 	   (setq cs (or (mm-charset-to-coding-system mail-parse-charset)
 			'raw-text)))
-	  ((setq cs (mm-coding-system-p cs)))
+	  ((mm-coding-system-p cs))
 	  ((and charset
 		(listp mail-parse-ignored-charsets)
 		(memq 'gnus-unknown mail-parse-ignored-charsets))
--- a/lisp/loadup.el	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/loadup.el	Tue Feb 21 15:57:00 2006 +0000
@@ -173,6 +173,7 @@
 
 (if (fboundp 'x-create-frame)
     (progn
+      (load "fringe")
       (load "image")
       (load "international/fontset")
       (load "dnd")
--- a/lisp/mh-e/ChangeLog	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/mh-e/ChangeLog	Tue Feb 21 15:57:00 2006 +0000
@@ -1,3 +1,11 @@
+2006-02-20  Eric Ding  <ericding@alum.mit.edu>
+
+	* mh-e.el (mh-invisible-header-fields-internal): Added entries
+	"X-Authenticated-Sender:", "X-Barracuda-", "X-EFL-Spamscore",
+	"X-IronPort-AV:", "X-Mail-from:", "X-Mailman-Approved-At:",
+	"X-Resolved-to:", and "X-SA-Exim".  Fixed "X-Bugzilla-" and
+	"X-Roving-" by removing unnecessary "*" at end.
+
 2006-02-19  Bill Wohler  <wohler@newt.com>
 
 	* mh-alias.el (mh-address-mail-regexp)
--- a/lisp/mh-e/mh-e.el	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/mh-e/mh-e.el	Tue Feb 21 15:57:00 2006 +0000
@@ -2303,17 +2303,20 @@
     "X-AntiAbuse:"                      ; cPanel
     "X-Apparently-From:"                ; MS Outlook
     "X-Apparently-To:"           ; Egroups/yahoogroups mailing list manager
+    "X-Authenticated-Sender:"           ; AT&T Message Center (webmail)
     "X-Authentication-Warning:"         ; sendmail
+    "X-Barracuda-"                      ; Barracuda spam scores
     "X-Beenthere:"                      ; Mailman mailing list manager
     "X-Bogosity:"                       ; bogofilter
     "X-BrightmailFiltered:"             ; Brightmail
     "X-Brightmail-Tracker:"             ; Brightmail
-    "X-Bugzilla-*"                      ; Bugzilla
+    "X-Bugzilla-"                       ; Bugzilla
     "X-Complaints-To:"
     "X-ContentStamp:"                   ; NetZero
     "X-Cron-Env:"
     "X-DMCA"
     "X-Delivered"
+    "X-EFL-Spamscore:"                  ; MIT alumni spam filtering
     "X-ELNK-Trace:"                     ; Earthlink mailer
     "X-Envelope-Date:"                  ; GNU mailutils
     "X-Envelope-From:"
@@ -2337,6 +2340,7 @@
     "X-Habeas-SWE-9:"                   ; Spam
     "X-Hashcash:"                       ; hashcash
     "X-Info:"                           ; NTMail
+    "X-IronPort-AV:"                    ; IronPort AV
     "X-Juno-"                           ; Juno
     "X-List-Host:"                      ; Unknown mailing list managers
     "X-List-Subscribe:"                 ; Unknown mailing list managers
@@ -2346,12 +2350,14 @@
     "X-Loop:"                           ; Unknown mailing list managers
     "X-Lumos-SenderID:"                 ; Roving ConstantContact
     "X-MAIL-INFO:"                      ; NetZero
-    "X-MHE-Checksum"                    ; Checksum added during index search
+    "X-MHE-Checksum:"                   ; Checksum added during index search
     "X-MIME-Autoconverted:"             ; sendmail
     "X-MIMETrack:"
     "X-MS-"                             ; MS Outlook
+    "X-Mail-from:"                      ; fastmail.fm
     "X-MailScanner"                     ; ListProc(tm) by CREN
     "X-Mailing-List:"                   ; Unknown mailing list managers
+    "X-Mailman-Approved-At:"            ; Mailman mailing list manager
     "X-Mailman-Version:"                ; Mailman mailing list manager
     "X-Majordomo:"                      ; Majordomo mailing list manager
     "X-Message-Id"
@@ -2380,8 +2386,10 @@
     "X-Received-Date:"
     "X-Received:"
     "X-Request-"
+    "X-Resolved-to:"                    ; fastmail.fm
     "X-Return-Path-Hint:"               ; Roving ConstantContact
-    "X-Roving-*"                        ; Roving ConstantContact
+    "X-Roving-"                         ; Roving ConstantContact
+    "X-SA-Exim-"                        ; Exim SpamAssassin
     "X-SBClass:"                        ; Spam
     "X-SBNote:"                         ; Spam
     "X-SBPass:"                         ; Spam
--- a/lisp/progmodes/gdb-ui.el	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/progmodes/gdb-ui.el	Tue Feb 21 15:57:00 2006 +0000
@@ -542,7 +542,7 @@
 		  (forward-char 2)
 		  (gud-call (concat "until *%a")))))))))
 
-(defcustom gdb-speedbar-auto-raise t
+(defcustom gdb-speedbar-auto-raise nil
   "If non-nil raise speedbar every time display of watch expressions is\
  updated."
   :type 'boolean
--- a/lisp/progmodes/gud.el	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/progmodes/gud.el	Tue Feb 21 15:57:00 2006 +0000
@@ -497,7 +497,7 @@
 		       (if (or parent status 'out-of-scope)
 			 nil 'gdb-edit-value)
 		       nil
-		       (if (and status gdb-show-changed-values)
+		       (if (and (or parent status) gdb-show-changed-values)
 			   'shadow t)
 		       depth)
 		    (speedbar-make-tag-line
@@ -505,7 +505,8 @@
 		     'gdb-speedbar-expand-node varnum
 		     (concat expr "\t" type)
 		     nil nil
-		     (if (and status gdb-show-changed-values) 'shadow t)
+		     (if (and (or parent status) gdb-show-changed-values)
+			 'shadow t)
 		     depth))))
 	      (setq var-list (cdr var-list))))
 	  (setq gdb-force-update nil)))
--- a/lisp/url/ChangeLog	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/url/ChangeLog	Tue Feb 21 15:57:00 2006 +0000
@@ -1,3 +1,13 @@
+2006-02-20  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* url.el (url-redirect-buffer): New var.
+	(url-retrieve-synchronously): Use it to follow redirections.
+
+	* url-http.el: Require `url' rather than try to autoload parts of it.
+	(url-http-find-free-connection): `url-open-stream' needs a real buffer.
+	(url-http-parse-headers): Set `url-redirect-buffer' when following
+	a redirection reply.
+
 2006-01-18  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* url-news.el: Move defvars out of eval-when-compile.
@@ -18,7 +28,7 @@
 	(url-history-save-history): Create parent dir if necessary.
 	(url-history-save-history): Don't write the initialization of
 	url-history-hash-table into the history file.
-	(url-have-visited-url): Simplify since url-history-hash-table is non-nil.
+	(url-have-visited-url): Simplify since url-history-hash-table isn't nil.
 	(url-completion-function): Simplify.
 
 	* url-cookie.el (url-cookie-parse-file): Don't complain of missing file.
--- a/lisp/url/url-http.el	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/url/url-http.el	Tue Feb 21 15:57:00 2006 +0000
@@ -1,6 +1,6 @@
 ;;; url-http.el --- HTTP retrieval routines
 
-;; Copyright (C) 1999, 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001, 2004, 2005, 2006  Free Software Foundation, Inc.
 
 ;; Author: Bill Perry <wmperry@gnu.org>
 ;; Keywords: comm, data, processes
@@ -35,10 +35,8 @@
 (require 'url-cookie)
 (require 'mail-parse)
 (require 'url-auth)
-(autoload 'url-retrieve-synchronously "url")
-(autoload 'url-retrieve "url")
+(require 'url)
 (autoload 'url-cache-create-filename "url-cache")
-(autoload 'url-mark-buffer-as-dead "url")
 
 (defconst url-http-default-port 80 "Default HTTP port.")
 (defconst url-http-asynchronous-p t "HTTP retrievals are asynchronous.")
@@ -57,15 +55,13 @@
 This is only useful when debugging the HTTP subsystem.
 
 Setting this to 1.0 will tell servers not to send chunked encoding,
-and other HTTP/1.1 specific features.
-")
+and other HTTP/1.1 specific features.")
 
 (defvar url-http-attempt-keepalives t
   "Whether to use a single TCP connection multiple times in HTTP.
 This is only useful when debugging the HTTP subsystem.  Setting to
-`nil' will explicitly close the connection to the server after every
-request.
-")
+nil will explicitly close the connection to the server after every
+request.")
 
 ;(eval-when-compile
 ;; These are all macros so that they are hidden from external sight
@@ -119,10 +115,14 @@
 	(url-http-debug "Reusing existing connection: %s:%d" host port)
       (url-http-debug "Contacting host: %s:%d" host port))
     (url-lazy-message "Contacting host: %s:%d" host port)
-    (url-http-mark-connection-as-busy host port
-				      (or found
-					  (url-open-stream host nil host
-							   port)))))
+    (url-http-mark-connection-as-busy
+     host port
+     (or found
+         (let ((buf (generate-new-buffer " *url-http-temp*")))
+           ;; `url-open-stream' needs a buffer in which to do things
+           ;; like authentication.  But we use another buffer afterwards.
+           (unwind-protect (url-open-stream host buf host port)
+             (kill-buffer buf)))))))
 
 ;; Building an HTTP request
 (defun url-http-user-agent-string ()
@@ -346,7 +346,7 @@
 
 (defun url-http-handle-cookies ()
   "Handle all set-cookie / set-cookie2 headers in an HTTP response.
-The buffer must already be narrowed to the headers, so mail-fetch-field will
+The buffer must already be narrowed to the headers, so `mail-fetch-field' will
 work correctly."
   (let ((cookies (mail-fetch-field "Set-Cookie" nil nil t))
 	(cookies2 (mail-fetch-field "Set-Cookie2" nil nil t))
@@ -509,10 +509,17 @@
            (let ((url-request-method url-http-method)
 		 (url-request-data url-http-data)
 		 (url-request-extra-headers url-http-extra-headers))
-	     (url-retrieve redirect-uri url-callback-function
-			   (cons :redirect
-				 (cons redirect-uri
-				       url-callback-arguments)))
+             ;; Put in the current buffer a forwarding pointer to the new
+             ;; destination buffer.
+             ;; FIXME: This is a hack to fix url-retrieve-synchronously
+             ;; without changing the API.  Instead url-retrieve should
+             ;; either simply not return the "destination" buffer, or it
+             ;; should take an optional `dest-buf' argument.
+             (set (make-local-variable 'url-redirect-buffer)
+                  (url-retrieve redirect-uri url-callback-function
+                                (cons :redirect
+                                      (cons redirect-uri
+                                            url-callback-arguments))))
 	     (url-mark-buffer-as-dead (current-buffer))))))
       (4				; Client error
        ;; 400 Bad Request
@@ -1156,7 +1163,7 @@
 
 ;;;###autoload
 (defun url-http-options (url)
-  "Returns a property list describing options available for URL.
+  "Return a property list describing options available for URL.
 This list is retrieved using the `OPTIONS' HTTP method.
 
 Property list members:
@@ -1179,8 +1186,7 @@
   The `Platform For Privacy Protection' description for the resource.
   Currently this is just the raw header contents.  This is likely to
   change once P3P is formally supported by the URL package or
-  Emacs/W3.
-"
+  Emacs/W3."
   (let* ((url-request-method "OPTIONS")
 	 (url-request-data nil)
 	 (buffer (url-retrieve-synchronously url))
--- a/lisp/url/url.el	Mon Feb 20 16:35:38 2006 +0000
+++ b/lisp/url/url.el	Tue Feb 21 15:57:00 2006 +0000
@@ -114,6 +114,13 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Retrieval functions
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defvar url-redirect-buffer nil
+  "New buffer into which the retrieval will take place.
+Sometimes while retrieving a URL, the URL library needs to use another buffer
+than the one returned initially by `url-retrieve'.  In this case, it sets this
+variable in the original buffer as a forwarding pointer.")
+
 ;;;###autoload
 (defun url-retrieve (url callback &optional cbargs)
   "Retrieve URL asynchronously and call CALLBACK with CBARGS when finished.
@@ -189,18 +196,22 @@
 	  (url-debug 'retrieval
 		     "Spinning in url-retrieve-synchronously: %S (%S)"
 		     retrieval-done asynch-buffer)
-	  (if (and proc (memq (process-status proc)
-                              '(closed exit signal failed))
-                   ;; Make sure another process hasn't been started, as can
-                   ;; happen with http redirections.
-		   (eq proc (or (get-buffer-process asynch-buffer) proc)))
-	      ;; FIXME: It's not clear whether url-retrieve's callback is
-	      ;; guaranteed to be called or not.  It seems that url-http
-	      ;; decides sometimes consciously not to call it, so it's not
-	      ;; clear that it's a bug, but even then we need to decide how
-	      ;; url-http can then warn us that the download has completed.
-              ;; In the mean time, we use this here workaround.
-              (setq retrieval-done t)
+          (if (buffer-local-value 'url-redirect-buffer asynch-buffer)
+              (setq proc (get-buffer-process
+                          (setq asynch-buffer
+                                (buffer-local-value 'url-redirect-buffer
+                                                    asynch-buffer))))
+            (if (and proc (memq (process-status proc)
+                                '(closed exit signal failed))
+                     ;; Make sure another process hasn't been started.
+                     (eq proc (or (get-buffer-process asynch-buffer) proc)))
+                ;; FIXME: It's not clear whether url-retrieve's callback is
+                ;; guaranteed to be called or not.  It seems that url-http
+                ;; decides sometimes consciously not to call it, so it's not
+                ;; clear that it's a bug, but even then we need to decide how
+                ;; url-http can then warn us that the download has completed.
+                ;; In the mean time, we use this here workaround.
+                (setq retrieval-done t))
             ;; We used to use `sit-for' here, but in some cases it wouldn't
             ;; work because apparently pending keyboard input would always
             ;; interrupt it before it got a chance to handle process input.
--- a/lispref/ChangeLog	Mon Feb 20 16:35:38 2006 +0000
+++ b/lispref/ChangeLog	Tue Feb 21 15:57:00 2006 +0000
@@ -1,3 +1,22 @@
+2006-02-21  Giorgos Keramidas  <keramida@ceid.upatras.gr>  (tiny change)
+
+	* display.texi (Fringe Indicators, Fringe Cursors): Fix typos.
+
+	* windows.texi (Window Tree): Fix typo.
+
+2006-02-20  Kim F. Storm  <storm@cua.dk>
+
+	* display.texi (Fringe Indicators): New section.
+	Move indicate-empty-lines, indicate-buffer-boundaries, and
+	default-indicate-buffer-boundaries here.
+	Add fringe-indicator-alist and default-fringes-indicator-alist.
+	Add list of logical fringe indicator symbols.
+	Update list of standard bitmap names.
+	(Fringe Cursors): New section.
+	Move overflow-newline-into-fringe here.
+	Add fringe-cursor-alist and default-fringes-cursor-alist.
+	Add list of fringe cursor symbols.
+
 2006-02-20  Juanma Barranquero  <lekktu@gmail.com>
 
 	* commands.texi (Using Interactive): Fix reference to node
--- a/lispref/display.texi	Mon Feb 20 16:35:38 2006 +0000
+++ b/lispref/display.texi	Tue Feb 21 15:57:00 2006 +0000
@@ -2722,7 +2722,9 @@
 
 @menu
 * Fringe Size/Pos::     Specifying where to put the window fringes.
-* Fringe Bitmaps::      Displaying bitmaps in the window fringes.
+* Fringe Indicators::   Displaying indicator icons in the window fringes.
+* Fringe Cursors::      Displaying cursors in the right fringe.
+* Fringe Bitmaps::      Specifying bitmaps for fringe indicators.
 * Customizing Bitmaps:: Specifying your own bitmaps to use in the fringes.
 * Overlay Arrow::       Display of an arrow to indicate position.
 @end menu
@@ -2774,6 +2776,151 @@
 @var{right-width} @var{outside-margins})}.
 @end defun
 
+
+@node Fringe Indicators
+@subsection Fringe Indicators
+@cindex fringe indicators
+@cindex indicators, fringe
+
+  The @dfn{fringe indicators} are tiny icons Emacs displays in the
+window fringe (on a graphic display) to indicate truncated or
+continued lines, buffer boundaries, overlay arrow, etc.
+
+@defopt indicate-empty-lines
+@tindex indicate-empty-lines
+@cindex fringes, and empty line indication
+When this is non-@code{nil}, Emacs displays a special glyph in the
+fringe of each empty line at the end of the buffer, on graphical
+displays.  @xref{Fringes}.  This variable is automatically
+buffer-local in every buffer.
+@end defopt
+
+@defvar indicate-buffer-boundaries
+This buffer-local variable controls how the buffer boundaries and
+window scrolling are indicated in the window fringes.
+
+Emacs can indicate the buffer boundaries---that is, the first and last
+line in the buffer---with angle icons when they appear on the screen.
+In addition, Emacs can display an up-arrow in the fringe to show
+that there is text above the screen, and a down-arrow to show
+there is text below the screen.
+
+There are four kinds of basic values:
+
+@table @asis
+@item @code{nil}
+Don't display the icons.
+@item @code{left}
+Display them in the left fringe.
+@item @code{right}
+Display them in the right fringe.
+@item @var{anything-else}
+Display the icon at the top of the window top in the left fringe, and other
+in the right fringe.
+@end table
+
+If value is a cons @code{(@var{angles} . @var{arrows})}, @var{angles}
+controls the angle icons, and @var{arrows} controls the arrows.  Both
+@var{angles} and @var{arrows} work according to the table above.
+Thus, @code{(t .  right)} places the top angle icon in the left
+fringe, the bottom angle icon in the right fringe, and both arrows in
+the right fringe.
+@end defvar
+
+@defvar default-indicate-buffer-boundaries
+The value of this variable is the default value for
+@code{indicate-buffer-boundaries} in buffers that do not override it.
+@end defvar
+
+@defvar fringe-indicator-alist
+This buffer-local variable specifies the mapping from logical fringe
+indicators to the actual bitmaps displayed in the window fringes.
+
+These symbols identify the logical fringe indicators:
+
+@table @asis
+@item Truncation and continuation line indicators:
+@code{truncation}, @code{continuation}.
+
+@item Buffer position indicators:
+@code{up}, @code{down},
+@code{top}, @code{bottom},
+@code{top-bottom}.
+
+@item Empty line indicator:
+@code{empty-line}.
+
+@item Overlay arrow indicator:
+@code{overlay-arrow}.
+
+@item Unknown bitmap indicator:
+@code{unknown}.
+@end table
+
+  The value is an alist where each element @code{(@var{indicator} . @var{bitmaps})}
+specifies the fringe bitmaps used to display a specific logical
+fringe indicator.
+
+Here, @var{indicator} specifies the logical indicator type, and
+@var{bitmaps} is list of symbols @code{(@var{left} @var{right}
+[@var{left1} @var{right1}])} which specifies the actual bitmap shown
+in the left or right fringe for the logical indicator.
+
+The @var{left} and @var{right} symbols specify the bitmaps shown in
+the left and/or right fringe for the specific indicator.  The
+@var{left1} or @var{right1} bitmaps are used only for the `bottom' and
+`top-bottom indicators when the last (only) line in has no final
+newline.  Alternatively, @var{bitmaps} may be a single symbol which is
+used in both left and right fringes.
+
+When @code{fringe-indicator-alist} has a buffer-local value, and there
+is no bitmap defined for a logical indicator, or the bitmap is
+@code{t}, the corresponding value from the (non-local)
+@code{default-fringes-indicator-alist} is used.
+
+To completely hide a specific indicator, set the bitmap to @code{nil}.
+@end defvar
+
+@defvar default-fringes-indicator-alist
+The value of this variable is the default value for
+@code{fringe-indicator-alist} in buffers that do not override it.
+@end defvar
+
+@table @asis
+@item Standard fringe bitmaps for indicators:
+@code{left-arrow}, @code{right-arrow}, @code{up-arrow}, @code{down-arrow},
+@code{left-curly-arrow}, @code{right-curly-arrow},
+@code{left-triangle}, @code{right-triangle},
+@code{top-left-angle}, @code{ top-right-angle},
+@code{bottom-left-angle}, @code{bottom-right-angle},
+@code{left-bracket}, @code{right-bracket},
+@code{filled-rectangle}, @code{hollow-rectangle},
+@code{filled-square}, @code{hollow-square},
+@code{vertical-bar}, @code{horizontal-bar},
+@code{empty-line},
+@code{question-mark}.
+@end table
+
+@node Fringe Cursors
+@subsection Fringe Cursors
+@cindex fringe cursors
+@cindex cursor, fringe
+
+  When a line is exactly as wide as the window, Emacs displays the
+cursor in the right fringe instead of using two lines.  Different
+bitmaps are used to represent the cursor in the fringe depending on
+the current buffer's cursor type.
+
+@table @asis
+@item Logical cursor types:
+@code{box} , @code{hollow}, @code{bar},
+@code{hbar}, @code{hollow-small}.
+@end table
+
+The @code{hollow-small} type is used instead of @code{hollow} when the
+normal @code{hollow-rectangle} bitmap is too tall to fit on a specific
+display line.
+
 @defvar overflow-newline-into-fringe
 If this is non-@code{nil}, lines exactly as wide as the window (not
 counting the final newline character) are not continued.  Instead,
@@ -2781,16 +2928,44 @@
 fringe.
 @end defvar
 
+@defvar fringe-cursor-alist
+This variable specifies the mapping from logical cursor type to the
+actual fringe bitmaps displayed in the right fringe.  The value is an
+alist where each element @code{(@var{cursor}. @var{bitmap})} specifies
+the fringe bitmaps used to display a specific logical cursor type in
+the fringe.  Here, @var{cursor} specifies the logical cursor type and
+@var{bitmap} is a symbol specifying the fringe bitmap to be displayed
+for that logical cursor type.
+
+When @code{fringe-cursor-alist} has a buffer-local value, and there is
+no bitmap defined for a cursor type, the corresponding value from the
+(non-local) @code{default-fringes-indicator-alist} is used.
+@end defvar
+
+@defvar default-fringes-cursor-alist
+The value of this variable is the default value for
+@code{fringe-cursor-alist} in buffers that do not override it.
+@end defvar
+
+@table @asis
+@item Standard bitmaps for displaying the cursor in right fringe:
+@code{filled-rectangle}, @code{hollow-rectangle},
+@code{filled-square}, @code{hollow-square},
+@code{vertical-bar}, @code{horizontal-bar}.
+@end table
+
+
 @node Fringe Bitmaps
 @subsection Fringe Bitmaps
 @cindex fringe bitmaps
 @cindex bitmaps, fringe
 
-  The @dfn{fringe bitmaps} are tiny icons Emacs displays in the window
-fringe (on a graphic display) to indicate truncated or continued
-lines, buffer boundaries, overlay arrow, etc.  The fringe bitmaps are
-shared by all frames and windows.  You can redefine the built-in
-fringe bitmaps, and you can define new fringe bitmaps.
+  The @dfn{fringe bitmaps} are the actual bitmaps which represent the
+logical fringe indicators for truncated or continued lines, buffer
+boundaries, overlay arrow, etc.  Fringe bitmap symbols have their own
+name space.  The fringe bitmaps are shared by all frames and windows.
+You can redefine the built-in fringe bitmaps, and you can define new
+fringe bitmaps.
 
   The way to display a bitmap in the left or right fringes for a given
 line in a window is by specifying the @code{display} property for one
@@ -2804,32 +2979,6 @@
 the @code{fringe} face, so normally @var{face} need only specify the
 foreground color for the bitmap.
 
-  These symbols identify the standard fringe bitmaps.  Evaluate
-@code{(require 'fringe)} to define them.  Fringe bitmap symbols have
-their own name space.
-
-@table @asis
-@item Truncation and continuation line bitmaps:
-@code{left-truncation}, @code{right-truncation},
-@code{continued-line}, @code{continuation-line}.
-
-@item Buffer indication bitmaps:
-@code{up-arrow}, @code{down-arrow},
-@code{top-left-angle}, @code{top-right-angle},
-@code{bottom-left-angle}, @code{bottom-right-angle},
-@code{left-bracket}, @code{right-bracket}.
-
-@item Empty line indication bitmap:
-@code{empty-line}.
-
-@item Overlay arrow bitmap:
-@code{overlay-arrow}.
-
-@item Bitmaps for displaying the cursor in right fringe:
-@code{filled-box-cursor}, @code{hollow-box-cursor}, @code{hollow-square},
-@code{bar-cursor}, @code{hbar-cursor}.
-@end table
-
 @defun fringe-bitmaps-at-pos &optional pos window
 This function returns the fringe bitmaps of the display line
 containing position @var{pos} in window @var{window}.  The return
@@ -4598,52 +4747,6 @@
 command @code{tab-to-tab-stop}.  @xref{Indent Tabs}.
 @end defopt
 
-@defopt indicate-empty-lines
-@tindex indicate-empty-lines
-@cindex fringes, and empty line indication
-When this is non-@code{nil}, Emacs displays a special glyph in the
-fringe of each empty line at the end of the buffer, on graphical
-displays.  @xref{Fringes}.  This variable is automatically
-buffer-local in every buffer.
-@end defopt
-
-@defvar indicate-buffer-boundaries
-This buffer-local variable controls how the buffer boundaries and
-window scrolling are indicated in the window fringes.
-
-Emacs can indicate the buffer boundaries---that is, the first and last
-line in the buffer---with angle icons when they appear on the screen.
-In addition, Emacs can display an up-arrow in the fringe to show
-that there is text above the screen, and a down-arrow to show
-there is text below the screen.
-
-There are four kinds of basic values:
-
-@table @asis
-@item @code{nil}
-Don't display the icons.
-@item @code{left}
-Display them in the left fringe.
-@item @code{right}
-Display them in the right fringe.
-@item @var{anything-else}
-Display the icon at the top of the window top in the left fringe, and other
-in the right fringe.
-@end table
-
-If value is a cons @code{(@var{angles} . @var{arrows})}, @var{angles}
-controls the angle icons, and @var{arrows} controls the arrows.  Both
-@var{angles} and @var{arrows} work according to the table above.
-Thus, @code{(t .  right)} places the top angle icon in the left
-fringe, the bottom angle icon in the right fringe, and both arrows in
-the right fringe.
-@end defvar
-
-@defvar default-indicate-buffer-boundaries
-The value of this variable is the default value for
-@code{indicate-buffer-boundaries} in buffers that do not override it.
-@end defvar
-
 @node Display Tables
 @section Display Tables
 
--- a/lispref/windows.texi	Mon Feb 20 16:35:38 2006 +0000
+++ b/lispref/windows.texi	Tue Feb 21 15:57:00 2006 +0000
@@ -2196,7 +2196,7 @@
 
 If the root window is not split, @var{root} is the root window itself.
 Otherwise, @var{root} is a list @code{(@var{dir} @var{edges} @var{w1}
-@var{w2} ...)} where @var{dir} is @code{nil} for a horisontal split,
+@var{w2} ...)} where @var{dir} is @code{nil} for a horizontal split,
 and @code{t} for a vertical split, @var{edges} gives the combined size and
 position of the subwindows in the split, and the rest of the elements
 are the subwindows in the split.  Each of the subwindows may again be
--- a/man/ChangeLog	Mon Feb 20 16:35:38 2006 +0000
+++ b/man/ChangeLog	Tue Feb 21 15:57:00 2006 +0000
@@ -1,3 +1,8 @@
+2006-02-21  Nick Roberts  <nickrob@snap.net.nz>
+
+	* building.texi (Watch Expressions): Update and describe
+	gdb-speedbar-auto-raise.
+
 2006-02-19  Richard M. Stallman  <rms@gnu.org>
 
 	* emacs.texi: Use @smallbook.
--- a/man/building.texi	Mon Feb 20 16:35:38 2006 +0000
+++ b/man/building.texi	Tue Feb 21 15:57:00 2006 +0000
@@ -959,7 +959,8 @@
 non-@code{nil} (the default value), Emacs uses
 @code{font-lock-warning-face} to highlight values that have recently
 changed and @code{shadow} face to make variables which have gone out of
-scope less noticeable.
+scope less noticeable.  When a variable goes out of scope you can't
+edit its value.
 
 @vindex gdb-use-colon-colon-notation
   If the variable @code{gdb-use-colon-colon-notation} is
@@ -968,6 +969,12 @@
 for variables defined in compound statements, the default value is
 @code{nil}.
 
+@vindex gdb-speedbar-auto-raise
+To automatically raise the speedbar every time the display of watch
+expressions updates, set @code{gdb-speedbar-auto-raise} to
+non-@code{nil}.  This can be useful if you are debugging with a full
+screen Emacs frame.
+
 @node Other GDB User Interface Buffers
 @subsubsection Other Buffers
 
--- a/src/ChangeLog	Mon Feb 20 16:35:38 2006 +0000
+++ b/src/ChangeLog	Tue Feb 21 15:57:00 2006 +0000
@@ -1,3 +1,83 @@
+2006-02-21  Kim F. Storm  <storm@cua.dk>
+
+	* fringe.c (syms_of_fringe) <fringe-bitmaps>: Doc fix.
+
+2006-02-21  Zhang Wei <brep@newsmth.org>
+
+	* xfns.c (Fx_file_dialog, Motif and GTK): DECODE_FILE before
+	returning it.
+
+2006-02-21  Giorgos Keramidas  <keramida@ceid.upatras.gr>  (tiny change)
+
+	* fringe.c (horizontal_bar_bits): Rename from `horisontal_bar_bits'.
+	(standard_bitmaps): Use it.
+
+2006-02-21  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* macterm.c (mac_draw_string_common): Remove arg MODE.  New arg
+	BG_WIDTH.  All uses changed.  Draw background if BG_WIDTH is not zero.
+	(mac_draw_image_string, mac_draw_image_string_16): New arg BG_WIDTH.
+	[USE_CG_TEXT_DRAWING] (mac_draw_image_string_cg): Rename from
+	mac_draw_string_cg.  New arg BG_WIDTH.  All uses changed.  Draw
+	background if BG_WIDTH is not zero.  Use float constants as
+	divisors instead of double.  Use alloca instead of xmalloc/xfree.
+	(x_draw_glyph_string_background, x_draw_glyph_string_foreground)
+	[!MAC_OS8 || USE_ATSUI]: Background may be drawn using
+	mac_draw_image_string* functions.
+	(XLoadQueryFont) [MAC_OS8 && USE_ATSUI]: Don't adjust heights of
+	some fonts when srcCopy text transfer mode might be used.
+	(mac_begin_clip, mac_end_clip): Check if region is empty.
+	(mac_set_clip_rectangles): When resetting clip region, make it
+	empty instead of disposing of it.
+
+2006-02-20  Kim F. Storm  <storm@cua.dk>
+
+	* Makefile.in: Add fringe.elc to WINDOW_SUPPORT.
+
+	* buffer.h (struct buffer): New members fringe_indicator_alist and
+	fringe_cursor_alist.
+
+	* buffer.c (init_buffer_once): Set dummy default values for
+	fringe-indicator-alist and fringe-cursor-alist.  The proper
+	default values are set by pre-loading fringe.el.
+	(syms_of_buffer): defvar_per_buffer new fringe-indicator-alist and
+	fringe-cursor-alist buffer-local variables and defvar_lisp_nopro
+	corresponding default- variables.
+
+	* fringe.c (enum fringe_bitmap_type): Remove.  Change all uses
+	to use `int'.
+	(NO_FRINGE_BITMAP, UNDEF_FRINGE_BITMAP, MAX_STANDARD_FRINGE_BITMAPS):
+	Define explicitly.
+	(Qtruncation, Qcontinuation, Qempty_line, Qtop_bottom)
+	(Qhollow_small): New variables.
+	(syms_of_fringe): Intern and staticpro them.
+	(question_mark_bits): Rename from unknown_bits.
+	(left_curly_arrow_bits): Rename from continuation_bits.
+	(right_curly_arrow_bits): Rename from continued_bits.
+	(left_triangle_bits): Rename from ov_bits.
+	(right_triangle_bits): Added.
+	(filled_rectangle_bits): Rename from filled_box_cursor_bits.
+	(hollow_rectangle_bits): Rename from hollow_box_cursor_bits.
+	(filled_square_bits): Added.
+	(vertical_bar_bits): Rename from bar_cursor_bits.
+	(horizontal_bar_bits): Rename from hbar_cursor_bits.
+	(empty_line_bits): Rename from zv_bits.
+	(standard_bitmaps): Update to use new names.
+	(draw_fringe_bitmap_1): Make static.
+	(get_logical_cursor_bitmap, get_logical_fringe_bitmap): New functions
+	to map from logical cursors and indicators to physical bitmaps.
+	(draw_fringe_bitmap): Resolve fringe cursor and	overlay-arrow
+	bitmaps using symbol names instead of bitmap numbers.
+	(update_window_fringes): Use logical indicator symbol names
+	instead of bitmap numbers for logical.  Add bitmap cache.
+	(LEFT_FRINGE, RIGHT_FRINGE): New helper macros.
+
+2006-02-20  Chong Yidong  <cyd@stupidchicken.com>
+
+	* regex.c: Revert 2006-02-19 change.
+	(xmalloc, xrealloc): Define these when not linked to Emacs.
+	Redefine malloc -> xmalloc, realloc -> xrealloc as in Emacs case.
+
 2006-02-19  Luc Teirlinck  <teirllm@auburn.edu>
 
 	* regex.c (extend_range_table_work_area): Fix typo.
--- a/src/Makefile.in	Mon Feb 20 16:35:38 2006 +0000
+++ b/src/Makefile.in	Tue Feb 21 15:57:00 2006 +0000
@@ -678,11 +678,11 @@
 
 #ifdef HAVE_WINDOW_SYSTEM
 #ifdef HAVE_X_WINDOWS
-#define WINDOW_SUPPORT ${lispsource}image.elc \
+#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \
  ${lispsource}international/fontset.elc ${lispsource}dnd.elc \
  ${lispsource}tool-bar.elc ${lispsource}mwheel.elc ${lispsource}x-dnd.elc
 #else
-#define WINDOW_SUPPORT ${lispsource}image.elc \
+#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \
  ${lispsource}international/fontset.elc ${lispsource}dnd.elc \
  ${lispsource}tool-bar.elc ${lispsource}mwheel.elc
 #endif
--- a/src/buffer.c	Mon Feb 20 16:35:38 2006 +0000
+++ b/src/buffer.c	Tue Feb 21 15:57:00 2006 +0000
@@ -5023,6 +5023,8 @@
   buffer_defaults.vertical_scroll_bar_type = Qt;
   buffer_defaults.indicate_empty_lines = Qnil;
   buffer_defaults.indicate_buffer_boundaries = Qnil;
+  buffer_defaults.fringe_indicator_alist = Qnil;
+  buffer_defaults.fringe_cursor_alist = Qnil;
   buffer_defaults.scroll_up_aggressively = Qnil;
   buffer_defaults.scroll_down_aggressively = Qnil;
   buffer_defaults.display_time = Qnil;
@@ -5094,6 +5096,8 @@
   XSETFASTINT (buffer_local_flags.vertical_scroll_bar_type, idx); ++idx;
   XSETFASTINT (buffer_local_flags.indicate_empty_lines, idx); ++idx;
   XSETFASTINT (buffer_local_flags.indicate_buffer_boundaries, idx); ++idx;
+  XSETFASTINT (buffer_local_flags.fringe_indicator_alist, idx); ++idx;
+  XSETFASTINT (buffer_local_flags.fringe_cursor_alist, idx); ++idx;
   XSETFASTINT (buffer_local_flags.scroll_up_aggressively, idx); ++idx;
   XSETFASTINT (buffer_local_flags.scroll_down_aggressively, idx); ++idx;
   XSETFASTINT (buffer_local_flags.header_line_format, idx); ++idx;
@@ -5387,6 +5391,16 @@
 		     doc: /* Default value of `indicate-buffer-boundaries' for buffers that don't override it.
 This is the same as (default-value 'indicate-buffer-boundaries).  */);
 
+  DEFVAR_LISP_NOPRO ("default-fringe-indicator-alist",
+		     &buffer_defaults.fringe_indicator_alist,
+		     doc: /* Default value of `fringe-indicator-alist' for buffers that don't override it.
+This is the same as (default-value 'fringe-indicator-alist').  */);
+
+  DEFVAR_LISP_NOPRO ("default-fringe-cursor-alist",
+		     &buffer_defaults.fringe_cursor_alist,
+		     doc: /* Default value of `fringe-cursor-alist' for buffers that don't override it.
+This is the same as (default-value 'fringe-cursor-alist').  */);
+
   DEFVAR_LISP_NOPRO ("default-scroll-up-aggressively",
 		     &buffer_defaults.scroll_up_aggressively,
 		     doc: /* Default value of `scroll-up-aggressively'.
@@ -5732,6 +5746,40 @@
 bitmaps in right fringe.  To show just the angle bitmaps in the left
 fringe, but no arrow bitmaps, use ((top .  left) (bottom . left)).  */);
 
+  DEFVAR_PER_BUFFER ("fringe-indicator-alist",
+		     &current_buffer->fringe_indicator_alist, Qnil,
+		     doc: /* *Mapping from logical to physical fringe indicator bitmaps.
+The value is an alist where each element (INDICATOR . BITMAPS)
+specifies the fringe bitmaps used to display a specific logical
+fringe indicator.
+
+INDICATOR specifies the logical indicator type which is one of the
+following symbols: `truncation' , `continuation', `overlay-arrow',
+`top', `bottom', `up', `down', `one-line', `empty-line', or `unknown'.
+
+BITMAPS is list of symbols (LEFT RIGHT [LEFT1 RIGHT1]) which specifies
+the actual bitmap shown in the left or right fringe for the logical
+indicator.  LEFT and RIGHT are the bitmaps shown in the left and/or
+right fringe for the specific indicator.  The LEFT1 or RIGHT1 bitmaps
+are used only for the `bottom' and `one-line' indicators when the last
+(only) line in has no final newline.  BITMAPS may also be a single
+symbol which is used in both left and right fringes.  */);
+
+  DEFVAR_PER_BUFFER ("fringe-cursor-alist",
+		     &current_buffer->fringe_cursor_alist, Qnil,
+		     doc: /* *Mapping from logical to physical fringe cursor bitmaps.
+The value is an alist where each element (CURSOR . BITMAP)
+specifies the fringe bitmaps used to display a specific logical
+cursor type in the fringe.
+
+CURSOR specifies the logical cursor type which is one of the following
+symbols: `box' , `hollow', `bar', `hbar', or `hollow-small'.  The last
+one is used to show a hollow cursor on narrow lines display lines
+where the normal hollow cursor will not fit.
+
+BITMAP is the corresponding fringe bitmap shown for the logical
+cursor type.  */);
+
   DEFVAR_PER_BUFFER ("scroll-up-aggressively",
 		     &current_buffer->scroll_up_aggressively, Qnil,
 		     doc: /* How far to scroll windows upward.
--- a/src/buffer.h	Mon Feb 20 16:35:38 2006 +0000
+++ b/src/buffer.h	Tue Feb 21 15:57:00 2006 +0000
@@ -739,6 +739,12 @@
   /* Non-nil means indicate buffer boundaries and scrolling.  */
   Lisp_Object indicate_buffer_boundaries;
 
+  /* Logical to physical fringe bitmap mappings.  */
+  Lisp_Object fringe_indicator_alist;
+
+  /* Logical to physical cursor bitmap mappings.  */
+  Lisp_Object fringe_cursor_alist;
+
   /* Time stamp updated each time this buffer is displayed in a window.  */
   Lisp_Object display_time;
 
--- a/src/fringe.c	Mon Feb 20 16:35:38 2006 +0000
+++ b/src/fringe.c	Tue Feb 21 15:57:00 2006 +0000
@@ -50,31 +50,45 @@
 
 Lisp_Object Vfringe_bitmaps;
 
-enum fringe_bitmap_type
-{
-  NO_FRINGE_BITMAP = 0,
-  UNDEF_FRINGE_BITMAP,
-  LEFT_TRUNCATION_BITMAP,
-  RIGHT_TRUNCATION_BITMAP,
-  UP_ARROW_BITMAP,
-  DOWN_ARROW_BITMAP,
-  CONTINUED_LINE_BITMAP,
-  CONTINUATION_LINE_BITMAP,
-  OVERLAY_ARROW_BITMAP,
-  TOP_LEFT_ANGLE_BITMAP,
-  TOP_RIGHT_ANGLE_BITMAP,
-  BOTTOM_LEFT_ANGLE_BITMAP,
-  BOTTOM_RIGHT_ANGLE_BITMAP,
-  LEFT_BRACKET_BITMAP,
-  RIGHT_BRACKET_BITMAP,
-  FILLED_BOX_CURSOR_BITMAP,
-  HOLLOW_BOX_CURSOR_BITMAP,
-  HOLLOW_SQUARE_BITMAP,
-  BAR_CURSOR_BITMAP,
-  HBAR_CURSOR_BITMAP,
-  ZV_LINE_BITMAP,
-  MAX_STANDARD_FRINGE_BITMAPS
-};
+/* Fringe bitmaps are represented in three different ways:
+
+   Logical bitmaps are used internally to denote things like
+   'end-of-buffer', 'left-truncation', 'overlay-arrow', etc.
+
+   Physical bitmaps specify the visual appearence of the bitmap,
+   e.g. 'bottom-left-angle', 'left-arrow', 'left-triangle', etc.
+   User defined bitmaps are physical bitmaps.
+
+   Internally, fringe bitmaps for a specific display row are
+   represented as a simple integer that is used as an index
+   into the table of all defined bitmaps.  This index is stored
+   in the `fringe' property of the physical bitmap symbol.
+
+   Logical bitmaps are mapped to physical bitmaps through the
+   buffer-local `fringe-indicator-alist' variable.
+
+   Each element of this alist is a cons (LOGICAL . PHYSICAL)
+   mapping a logical bitmap to a physical bitmap.
+   PHYSICAL is either a symbol to use in both left and right fringe,
+   or a cons of two symbols (LEFT . RIGHT) denoting different
+   bitmaps to use in left and right fringe.
+
+   LOGICAL is first looked up in the window's buffer's buffer-local
+   value of the fringe-indicator-alist variable, and if not present,
+   in the global value of fringe-indicator-alist.
+
+   If LOGICAL is not present in either alist, or the PHYSICAL value
+   found is nil, no bitmap is shown for the logical bitmap.
+
+   The `left-fringe' and `right-fringe' display properties
+   must specify physical bitmap symbols.
+*/
+
+extern Lisp_Object Qunknown;
+Lisp_Object Qtruncation, Qcontinuation, Qoverlay_arrow;
+Lisp_Object Qempty_line, Qtop_bottom;
+extern Lisp_Object Qbar, Qhbar, Qbox, Qhollow;
+Lisp_Object Qhollow_small;
 
 enum fringe_bitmap_align
 {
@@ -111,7 +125,7 @@
   ...xx...
   ...xx...
 */
-static unsigned short unknown_bits[] = {
+static unsigned short question_mark_bits[] = {
   0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18};
 
 /* An arrow like this: `<-'.  */
@@ -173,6 +187,20 @@
 static unsigned short down_arrow_bits[] = {
    0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18};
 
+/* Marker for continuation lines.  */
+/*
+  ..xxxx..
+  .xxxxx..
+  xx......
+  xxx..x..
+  xxxxxx..
+  .xxxxx..
+  ..xxxx..
+  .xxxxx..
+*/
+static unsigned short left_curly_arrow_bits[] = {
+   0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
+
 /* Marker for continued lines.  */
 /*
   ..xxxx..
@@ -184,22 +212,22 @@
   ..xxxx..
   ..xxxxx.
 */
-static unsigned short continued_bits[] = {
+static unsigned short right_curly_arrow_bits[] = {
    0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
 
-/* Marker for continuation lines.  */
+/* Reverse Overlay arrow bitmap.  A triangular arrow.  */
 /*
-  ..xxxx..
-  .xxxxx..
-  xx......
-  xxx..x..
-  xxxxxx..
-  .xxxxx..
-  ..xxxx..
-  .xxxxx..
+  ......xx
+  ....xxxx
+  ...xxxxx
+  ..xxxxxx
+  ..xxxxxx
+  ...xxxxx
+  ....xxxx
+  ......xx
 */
-static unsigned short continuation_bits[] = {
-   0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
+static unsigned short left_triangle_bits[] = {
+   0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
 
 /* Overlay arrow bitmap.  A triangular arrow.  */
 /*
@@ -212,25 +240,9 @@
   xxxx....
   xx......
 */
-static unsigned short ov_bits[] = {
+static unsigned short right_triangle_bits[] = {
    0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0};
 
-#if 0
-/* Reverse Overlay arrow bitmap.  A triangular arrow.  */
-/*
-  ......xx
-  ....xxxx
-  ...xxxxx
-  ..xxxxxx
-  ..xxxxxx
-  ...xxxxx
-  ....xxxx
-  ......xx
-*/
-static unsigned short rev_ov_bits[] = {
-   0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
-#endif
-
 /* First line bitmap.  An top-left angle.  */
 /*
   xxxxxx..
@@ -335,7 +347,7 @@
   xxxxxxx.
   xxxxxxx.
 */
-static unsigned short filled_box_cursor_bits[] = {
+static unsigned short filled_rectangle_bits[] = {
    0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
 
 /* Hollow box cursor bitmap.  A hollow box; max 13 pixels high.  */
@@ -354,9 +366,33 @@
   x.....x.
   xxxxxxx.
 */
-static unsigned short hollow_box_cursor_bits[] = {
+static unsigned short hollow_rectangle_bits[] = {
    0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe};
 
+/* Hollow square bitmap.  */
+/*
+  .xxxxxx.
+  .x....x.
+  .x....x.
+  .x....x.
+  .x....x.
+  .xxxxxx.
+*/
+static unsigned short hollow_square_bits[] = {
+   0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
+
+/* Filled square bitmap.  */
+/*
+  .xxxxxx.
+  .xxxxxx.
+  .xxxxxx.
+  .xxxxxx.
+  .xxxxxx.
+  .xxxxxx.
+*/
+static unsigned short filled_square_bits[] = {
+   0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e};
+
 /* Bar cursor bitmap.  A vertical bar; max 13 pixels high.  */
 /*
   xx......
@@ -373,15 +409,15 @@
   xx......
   xx......
 */
-static unsigned short bar_cursor_bits[] = {
+static unsigned short vertical_bar_bits[] = {
    0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0};
 
-/* HBar cursor bitmap.  A horisontal bar; 2 pixels high.  */
+/* HBar cursor bitmap.  A horizontal bar; 2 pixels high.  */
 /*
   xxxxxxx.
   xxxxxxx.
 */
-static unsigned short hbar_cursor_bits[] = {
+static unsigned short horizontal_bar_bits[] = {
   0xfe, 0xfe};
 
 
@@ -395,7 +431,7 @@
   ..xxxx..
   ........
 */
-static unsigned short zv_bits[] = {
+static unsigned short empty_line_bits[] = {
   0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
   0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
   0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
@@ -405,48 +441,45 @@
   0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
   0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
 
-/* Hollow square bitmap.  */
-/*
-  .xxxxxx.
-  .x....x.
-  .x....x.
-  .x....x.
-  .x....x.
-  .xxxxxx.
-*/
-static unsigned short hollow_square_bits[] = {
-   0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
-
 
 #define BYTES_PER_BITMAP_ROW  (sizeof (unsigned short))
 #define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW)
 #define FRBITS(bits)  bits, STANDARD_BITMAP_HEIGHT (bits)
 
-struct fringe_bitmap standard_bitmaps[MAX_STANDARD_FRINGE_BITMAPS] =
+/* NOTE:  The order of these bitmaps must match the sequence
+   used in fringe.el to define the corresponding symbols.  */
+
+struct fringe_bitmap standard_bitmaps[] =
 {
   { NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */
-  { FRBITS (unknown_bits),            8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (question_mark_bits),      8, 0, ALIGN_BITMAP_CENTER, 0 },
   { FRBITS (left_arrow_bits),         8, 0, ALIGN_BITMAP_CENTER, 0 },
   { FRBITS (right_arrow_bits),        8, 0, ALIGN_BITMAP_CENTER, 0 },
   { FRBITS (up_arrow_bits),           8, 0, ALIGN_BITMAP_TOP,    0 },
   { FRBITS (down_arrow_bits),         8, 0, ALIGN_BITMAP_BOTTOM, 0 },
-  { FRBITS (continued_bits),          8, 0, ALIGN_BITMAP_CENTER, 0 },
-  { FRBITS (continuation_bits),       8, 0, ALIGN_BITMAP_CENTER, 0 },
-  { FRBITS (ov_bits),                 8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (left_curly_arrow_bits),   8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (right_curly_arrow_bits),  8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (left_triangle_bits),      8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (right_triangle_bits),     8, 0, ALIGN_BITMAP_CENTER, 0 },
   { FRBITS (top_left_angle_bits),     8, 0, ALIGN_BITMAP_TOP,    0 },
   { FRBITS (top_right_angle_bits),    8, 0, ALIGN_BITMAP_TOP,    0 },
   { FRBITS (bottom_left_angle_bits),  8, 0, ALIGN_BITMAP_BOTTOM, 0 },
   { FRBITS (bottom_right_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
   { FRBITS (left_bracket_bits),       8, 0, ALIGN_BITMAP_CENTER, 0 },
   { FRBITS (right_bracket_bits),      8, 0, ALIGN_BITMAP_CENTER, 0 },
-  { FRBITS (filled_box_cursor_bits),  8, 0, ALIGN_BITMAP_CENTER, 0 },
-  { FRBITS (hollow_box_cursor_bits),  8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (filled_rectangle_bits),   8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (hollow_rectangle_bits),   8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (filled_square_bits),      8, 0, ALIGN_BITMAP_CENTER, 0 },
   { FRBITS (hollow_square_bits),      8, 0, ALIGN_BITMAP_CENTER, 0 },
-  { FRBITS (bar_cursor_bits),         8, 0, ALIGN_BITMAP_CENTER, 0 },
-  { FRBITS (hbar_cursor_bits),        8, 0, ALIGN_BITMAP_BOTTOM, 0 },
-  { FRBITS (zv_bits),                 8, 3, ALIGN_BITMAP_TOP,    0 },
+  { FRBITS (vertical_bar_bits),       8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (horizontal_bar_bits),     8, 0, ALIGN_BITMAP_BOTTOM, 0 },
+  { FRBITS (empty_line_bits),         8, 3, ALIGN_BITMAP_TOP,    0 },
 };
 
+#define NO_FRINGE_BITMAP 0
+#define UNDEF_FRINGE_BITMAP 1
+#define MAX_STANDARD_FRINGE_BITMAPS (sizeof(standard_bitmaps)/sizeof(standard_bitmaps[0]))
+
 static struct fringe_bitmap **fringe_bitmaps;
 static Lisp_Object *fringe_faces;
 static int max_fringe_bitmaps;
@@ -517,12 +550,12 @@
    LEFT_P is 1 for left fringe, 0 for right fringe.
 */
 
-void
+static void
 draw_fringe_bitmap_1 (w, row, left_p, overlay, which)
      struct window *w;
      struct glyph_row *row;
      int left_p, overlay;
-     enum fringe_bitmap_type which;
+     int which;
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
   struct draw_fringe_bitmap_params p;
@@ -657,6 +690,134 @@
   FRAME_RIF (f)->draw_fringe_bitmap (w, row, &p);
 }
 
+static int
+get_logical_cursor_bitmap (w, cursor)
+     struct window *w;
+     Lisp_Object cursor;
+{
+  Lisp_Object cmap, bm = Qnil;
+
+  if ((cmap = XBUFFER (w->buffer)->fringe_cursor_alist), !NILP (cmap))
+    {
+      bm = Fassq (cursor, cmap);
+      if (CONSP (bm))
+	{
+	  if ((bm = XCDR (bm)), NILP (bm))
+	    return NO_FRINGE_BITMAP;
+	  return lookup_fringe_bitmap (bm);
+	}
+    }
+  if (EQ (cmap, buffer_defaults.fringe_cursor_alist))
+    return NO_FRINGE_BITMAP;
+  bm = Fassq (cursor, buffer_defaults.fringe_cursor_alist);
+  if (!CONSP (bm) || ((bm = XCDR (bm)), NILP (bm)))
+    return NO_FRINGE_BITMAP;
+  return lookup_fringe_bitmap (bm);
+}
+
+static int
+get_logical_fringe_bitmap (w, bitmap, right_p, partial_p)
+     struct window *w;
+     Lisp_Object bitmap;
+     int right_p, partial_p;
+{
+  Lisp_Object cmap, bm1 = Qnil, bm2 = Qnil, bm;
+  int ln1 = 0, ln2 = 0;
+  int ix1 = right_p;
+  int ix2 = ix1 + (partial_p ? 2 : 0);
+
+  /* Lookup in buffer-local fringe-indicator-alist before global alist.
+
+     Elements are:
+	BITMAP		-- use for all
+	(L R)		-- use for left right (whether partial or not)
+	(L R PL PR)	-- use for left rigth partial-left partial-right
+	If any value in local binding is not present or t, use global value.
+
+     If partial, lookup partial bitmap in default value if not found here.
+     If not partial, or no partial spec is present, use non-partial bitmap.  */
+
+  if ((cmap = XBUFFER (w->buffer)->fringe_indicator_alist), !NILP (cmap))
+    {
+      bm1 = Fassq (bitmap, cmap);
+      if (CONSP (bm1))
+	{
+	  if ((bm1 = XCDR (bm1)), NILP (bm1))
+	    return NO_FRINGE_BITMAP;
+	  if (CONSP (bm1))
+	    {
+	      ln1 = XINT (Flength (bm1));
+	      if (partial_p)
+		{
+		  if (ln1 > ix2)
+		    {
+		      bm = Fnth (make_number (ix2), bm1);
+		      if (!EQ (bm, Qt))
+			goto found;
+		    }
+		}
+	      else
+		{
+		  if (ln1 > ix1)
+		    {
+		      bm = Fnth (make_number (ix1), bm1);
+		      if (!EQ (bm, Qt))
+			goto found;
+		    }
+		}
+	    }
+	  else if ((bm = bm1, !EQ (bm, Qt)))
+	    goto found;
+	}
+    }
+
+  if (!EQ (cmap, buffer_defaults.fringe_indicator_alist)
+      && !NILP (buffer_defaults.fringe_indicator_alist))
+    {
+      bm2 = Fassq (bitmap, buffer_defaults.fringe_indicator_alist);
+      if (CONSP (bm2))
+	{
+	  if ((bm2 = XCDR (bm2)), !NILP (bm2))
+	    {
+	      if (CONSP (bm2))
+		{
+		  ln2 = XINT (Flength (bm2));
+		  if (partial_p)
+		    {
+		      if (ln2 > ix2)
+			{
+			  bm = Fnth (make_number (ix2), bm2);
+			  if (!EQ (bm, Qt))
+			    goto found;
+			}
+		    }
+		}
+	    }
+	}
+    }
+
+  if (ln1 > ix1)
+    {
+      bm = Fnth (make_number (ix1), bm1);
+      if (!EQ (bm, Qt))
+	goto found;
+    }
+
+  if (ln2 > ix1)
+    {
+      bm = Fnth (make_number (ix1), bm2);
+      if (!EQ (bm, Qt))
+	goto found;
+      return NO_FRINGE_BITMAP;
+    }
+  else if ((bm = bm2, NILP (bm)))
+    return NO_FRINGE_BITMAP;
+
+ found:
+  return lookup_fringe_bitmap (bm);
+}
+
+
 void
 draw_fringe_bitmap (w, row, left_p)
      struct window *w;
@@ -667,24 +828,24 @@
 
   if (!left_p && row->cursor_in_fringe_p)
     {
-      int cursor = NO_FRINGE_BITMAP;
+      Lisp_Object cursor = Qnil;
 
       switch (w->phys_cursor_type)
 	{
 	case HOLLOW_BOX_CURSOR:
-	  if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_box_cursor_bits))
-	    cursor = HOLLOW_BOX_CURSOR_BITMAP;
+	  if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_rectangle_bits))
+	    cursor = Qhollow;
 	  else
-	    cursor = HOLLOW_SQUARE_BITMAP;
+	    cursor = Qhollow_small;
 	  break;
 	case FILLED_BOX_CURSOR:
-	  cursor = FILLED_BOX_CURSOR_BITMAP;
+	  cursor = Qbox;
 	  break;
 	case BAR_CURSOR:
-	  cursor = BAR_CURSOR_BITMAP;
+	  cursor = Qbar;
 	  break;
 	case HBAR_CURSOR:
-	  cursor = HBAR_CURSOR_BITMAP;
+	  cursor = Qhbar;
 	  break;
 	case NO_CURSOR:
 	default:
@@ -692,10 +853,14 @@
 	  row->cursor_in_fringe_p = 0;
 	  break;
 	}
-      if (cursor != NO_FRINGE_BITMAP)
+      if (!NILP (cursor))
 	{
-	  draw_fringe_bitmap_1 (w, row, 0, 2, cursor);
-	  overlay = cursor == FILLED_BOX_CURSOR_BITMAP ? 3 : 1;
+	  int bm = get_logical_cursor_bitmap (w, cursor);
+	  if (bm != NO_FRINGE_BITMAP)
+	    {
+	      draw_fringe_bitmap_1 (w, row, 0, 2, bm);
+	      overlay = EQ (cursor, Qbox) ? 3 : 1;
+	    }
 	}
     }
 
@@ -704,7 +869,7 @@
   if (left_p && row->overlay_arrow_bitmap != NO_FRINGE_BITMAP)
     draw_fringe_bitmap_1 (w, row, 1, 1,
 			  (row->overlay_arrow_bitmap < 0
-			   ? OVERLAY_ARROW_BITMAP
+			   ? get_logical_cursor_bitmap (w, Qoverlay_arrow)
 			   : row->overlay_arrow_bitmap));
 }
 
@@ -796,6 +961,8 @@
   Lisp_Object arrow_top = Qnil, arrow_bot = Qnil;
   Lisp_Object empty_pos;
   Lisp_Object ind = Qnil;
+#define MAX_BITMAP_CACHE (8*4)
+  int bitmap_cache[MAX_BITMAP_CACHE];
 
   if (w->pseudo_window_p)
     return 0;
@@ -881,11 +1048,27 @@
   if (!NILP (empty_pos) && !EQ (empty_pos, Qright))
     empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft;
 
+  for (y = 0; y < MAX_BITMAP_CACHE; y++)
+    bitmap_cache[y] = -1;
+
+#define LEFT_FRINGE(cache, which, partial_p)			\
+  (bitmap_cache[cache*4+partial_p] >= 0				\
+   ? bitmap_cache[cache*4+partial_p]				\
+   : (bitmap_cache[cache*4+partial_p] =				\
+      get_logical_fringe_bitmap (w, which, 0, partial_p)))
+
+#define RIGHT_FRINGE(cache, which, partial_p)			\
+  (bitmap_cache[cache*4+2+partial_p] >= 0			\
+   ? bitmap_cache[cache*4+2+partial_p]				\
+   : (bitmap_cache[cache*4+2+partial_p] =			\
+      get_logical_fringe_bitmap (w, which, 1, partial_p)))
+
+
   for (y = 0, rn = 0;
        y < yb && rn < nrows;
        y += row->height, rn++)
     {
-      enum fringe_bitmap_type left, right;
+      int left, right;
       unsigned left_face_id, right_face_id;
 
       row = w->desired_matrix->rows + rn;
@@ -904,23 +1087,21 @@
 	  left_face_id = row->left_user_fringe_face_id;
 	}
       else if (row->truncated_on_left_p)
-	left = LEFT_TRUNCATION_BITMAP;
+	left = LEFT_FRINGE(0, Qtruncation, 0);
       else if (row->indicate_bob_p && EQ (boundary_top, Qleft))
 	left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft))
-		? (row->ends_at_zv_p
-		   ? TOP_RIGHT_ANGLE_BITMAP : LEFT_BRACKET_BITMAP)
-		: TOP_LEFT_ANGLE_BITMAP);
+		? LEFT_FRINGE (1, Qtop_bottom, row->ends_at_zv_p)
+		: LEFT_FRINGE (2, Qtop, 0));
       else if (row->indicate_eob_p && EQ (boundary_bot, Qleft))
-	left = (row->ends_at_zv_p
-		? TOP_RIGHT_ANGLE_BITMAP : BOTTOM_LEFT_ANGLE_BITMAP);
+	left = LEFT_FRINGE (3, Qbottom, row->ends_at_zv_p);
       else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
-	left = CONTINUATION_LINE_BITMAP;
+	left = LEFT_FRINGE (4, Qcontinuation, 0);
       else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft))
-	left = ZV_LINE_BITMAP;
+	left = LEFT_FRINGE (5, Qempty_line, 0);
       else if (row->indicate_top_line_p && EQ (arrow_top, Qleft))
-	left = UP_ARROW_BITMAP;
+	left = LEFT_FRINGE (6, Qup, 0);
       else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qleft))
-	left = DOWN_ARROW_BITMAP;
+	left = LEFT_FRINGE (7, Qdown, 0);
       else
 	left = NO_FRINGE_BITMAP;
 
@@ -933,23 +1114,21 @@
 	  right_face_id = row->right_user_fringe_face_id;
 	}
       else if (row->truncated_on_right_p)
-	right = RIGHT_TRUNCATION_BITMAP;
+	right = RIGHT_FRINGE (0, Qtruncation, 0);
       else if (row->indicate_bob_p && EQ (boundary_top, Qright))
 	right = ((row->indicate_eob_p && EQ (boundary_bot, Qright))
-		 ? (row->ends_at_zv_p
-		    ? TOP_LEFT_ANGLE_BITMAP : RIGHT_BRACKET_BITMAP)
-		 : TOP_RIGHT_ANGLE_BITMAP);
+		 ? RIGHT_FRINGE (1, Qtop_bottom, row->ends_at_zv_p)
+		 : RIGHT_FRINGE (2, Qtop, 0));
       else if (row->indicate_eob_p && EQ (boundary_bot, Qright))
-	right = (row->ends_at_zv_p
-		 ? TOP_LEFT_ANGLE_BITMAP : BOTTOM_RIGHT_ANGLE_BITMAP);
+	right = RIGHT_FRINGE (3, Qbottom, row->ends_at_zv_p);
       else if (row->continued_p)
-	right = CONTINUED_LINE_BITMAP;
+	right = RIGHT_FRINGE (4, Qcontinuation, 0);
       else if (row->indicate_top_line_p && EQ (arrow_top, Qright))
-	right = UP_ARROW_BITMAP;
+	right = RIGHT_FRINGE (6, Qup, 0);
       else if (row->indicate_bottom_line_p && EQ (arrow_bot, Qright))
-	right = DOWN_ARROW_BITMAP;
+	right = RIGHT_FRINGE (7, Qdown, 0);
       else if (row->indicate_empty_line_p && EQ (empty_pos, Qright))
-	right = ZV_LINE_BITMAP;
+	right = RIGHT_FRINGE (5, Qempty_line, 0);
       else
 	right = NO_FRINGE_BITMAP;
 
@@ -1153,7 +1332,7 @@
 
 void
 init_fringe_bitmap (which, fb, once_p)
-     enum fringe_bitmap_type which;
+     int which;
      struct fringe_bitmap *fb;
      int once_p;
 {
@@ -1442,6 +1621,19 @@
 void
 syms_of_fringe ()
 {
+  Qtruncation = intern ("truncation");
+  staticpro (&Qtruncation);
+  Qcontinuation = intern ("continuation");
+  staticpro (&Qcontinuation);
+  Qoverlay_arrow = intern ("overlay-arrow");
+  staticpro (&Qoverlay_arrow);
+  Qempty_line = intern ("empty-line");
+  staticpro (&Qempty_line);
+  Qtop_bottom = intern ("top-bottom");
+  staticpro (&Qtop_bottom);
+  Qhollow_small = intern ("hollow-small");
+  staticpro (&Qhollow_small);
+
   defsubr (&Sdestroy_fringe_bitmap);
   defsubr (&Sdefine_fringe_bitmap);
   defsubr (&Sfringe_bitmaps_at_pos);
@@ -1457,8 +1649,7 @@
   Voverflow_newline_into_fringe = Qt;
 
   DEFVAR_LISP ("fringe-bitmaps", &Vfringe_bitmaps,
-    doc: /* List of fringe bitmap symbols.
-You must (require 'fringe) to use fringe bitmap symbols in your programs." */);
+    doc: /* List of fringe bitmap symbols.  */);
   Vfringe_bitmaps = Qnil;
 }
 
@@ -1479,7 +1670,7 @@
 void
 init_fringe_once ()
 {
-  enum fringe_bitmap_type bt;
+  int bt;
 
   for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
     init_fringe_bitmap(bt, &standard_bitmaps[bt], 1);
@@ -1509,7 +1700,7 @@
 void
 w32_init_fringe ()
 {
-  enum fringe_bitmap_type bt;
+  int bt;
 
   if (!rif)
     return;
--- a/src/macterm.c	Mon Feb 20 16:35:38 2006 +0000
+++ b/src/macterm.c	Tue Feb 21 15:57:00 2006 +0000
@@ -283,7 +283,7 @@
   if (new_region == NULL)
     new_region = NewRgn ();
 
-  if (region)
+  if (region && !EmptyRgn (region))
     {
       GetClip (saved_port_clip_region);
       SectRgn (saved_port_clip_region, region, new_region);
@@ -295,7 +295,7 @@
 mac_end_clip (region)
      RgnHandle region;
 {
-  if (region)
+  if (region && !EmptyRgn (region))
     SetClip (saved_port_clip_region);
 }
 
@@ -682,27 +682,15 @@
 
 
 static void
-mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
+mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, bytes_per_char)
      struct frame *f;
      GC gc;
      int x, y;
      char *buf;
-     int nchars, mode, bytes_per_char;
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
-  UInt32 textFlags, savedFlags;
-  if (mac_use_core_graphics) {
-    textFlags = kQDUseCGTextRendering;
-    savedFlags = SwapQDTextFlags(textFlags);
-  }
-#endif
-
+     int nchars, bg_width, bytes_per_char;
+{
   SetPortWindowPort (FRAME_MAC_WINDOW (f));
 
-  RGBForeColor (GC_FORE_COLOR (gc));
-  if (mode != srcOr)
-    RGBBackColor (GC_BACK_COLOR (gc));
-
 #if USE_ATSUI
   if (GC_FONT (gc)->mac_style)
     {
@@ -724,91 +712,144 @@
 						nchars,
 						GC_FONT (gc)->mac_style,
 						&text_layout);
-      if (err == noErr)
-	{
-#ifdef MAC_OSX
-	  if (!mac_use_core_graphics)
-	    {
-#endif
-	      mac_begin_clip (GC_CLIP_REGION (gc));
-	      MoveTo (x, y);
-	      ATSUDrawText (text_layout,
-			    kATSUFromTextBeginning, kATSUToTextEnd,
-			    kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
-	      mac_end_clip (GC_CLIP_REGION (gc));
+      if (err != noErr)
+	return;
 #ifdef MAC_OSX
-	    }
-	  else
+      if (!mac_use_core_graphics)
+	{
+#endif
+	  mac_begin_clip (GC_CLIP_REGION (gc));
+	  RGBForeColor (GC_FORE_COLOR (gc));
+	  if (bg_width)
 	    {
-	      CGrafPtr port;
-	      CGContextRef context;
-	      float port_height = FRAME_PIXEL_HEIGHT (f);
-	      ATSUAttributeTag tags[] = {kATSUCGContextTag};
-	      ByteCount sizes[] = {sizeof (CGContextRef)};
-	      ATSUAttributeValuePtr values[] = {&context};
-
-	      GetPort (&port);
-	      QDBeginCGContext (port, &context);
+	      Rect r;
+
+	      SetRect (&r, x, y - FONT_BASE (GC_FONT (gc)),
+		       x + bg_width, y + FONT_DESCENT (GC_FONT (gc)));
+	      RGBBackColor (GC_BACK_COLOR (gc));
+	      EraseRect (&r);
+	      RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
+	    }
+	  MoveTo (x, y);
+	  ATSUDrawText (text_layout,
+			kATSUFromTextBeginning, kATSUToTextEnd,
+			kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
+	  mac_end_clip (GC_CLIP_REGION (gc));
+#ifdef MAC_OSX
+	}
+      else
+	{
+	  CGrafPtr port;
+	  CGContextRef context;
+	  float port_height = FRAME_PIXEL_HEIGHT (f);
+	  ATSUAttributeTag tags[] = {kATSUCGContextTag};
+	  ByteCount sizes[] = {sizeof (CGContextRef)};
+	  ATSUAttributeValuePtr values[] = {&context};
+
+	  GetPort (&port);
+	  QDBeginCGContext (port, &context);
+	  if (gc->n_clip_rects || bg_width)
+	    {
+	      CGContextTranslateCTM (context, 0, port_height);
+	      CGContextScaleCTM (context, 1, -1);
 	      if (gc->n_clip_rects)
+		CGContextClipToRects (context, gc->clip_rects,
+				      gc->n_clip_rects);
+	      if (bg_width)
 		{
-		  CGContextTranslateCTM (context, 0, port_height);
-		  CGContextScaleCTM (context, 1, -1);
-		  CGContextClipToRects (context, gc->clip_rects,
-					gc->n_clip_rects);
-		  CGContextScaleCTM (context, 1, -1);
-		  CGContextTranslateCTM (context, 0, -port_height);
+		  CGContextSetRGBFillColor
+		    (context,
+		     RED_FROM_ULONG (gc->xgcv.background) / 255.0f,
+		     GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f,
+		     BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f,
+		     1.0);
+		  CGContextFillRect
+		    (context,
+		     CGRectMake (x, y - FONT_BASE (GC_FONT (gc)),
+				 bg_width, FONT_HEIGHT (GC_FONT (gc))));
 		}
-	      CGContextSetRGBFillColor
-		(context,
-		 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0,
-		 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0,
-		 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0,
-		 1.0);
-	      err = ATSUSetLayoutControls (text_layout,
-					   sizeof (tags) / sizeof (tags[0]),
-					   tags, sizes, values);
-	      if (err == noErr)
-		ATSUDrawText (text_layout,
-			      kATSUFromTextBeginning, kATSUToTextEnd,
-			      Long2Fix (x), Long2Fix (port_height - y));
-	      CGContextSynchronize (context);
-	      QDEndCGContext (port, &context);
+	      CGContextScaleCTM (context, 1, -1);
+	      CGContextTranslateCTM (context, 0, -port_height);
+	    }
+	  CGContextSetRGBFillColor
+	    (context,
+	     RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
+	     GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
+	     BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
+	     1.0);
+	  err = ATSUSetLayoutControls (text_layout,
+				       sizeof (tags) / sizeof (tags[0]),
+				       tags, sizes, values);
+	  if (err == noErr)
+	    ATSUDrawText (text_layout,
+			  kATSUFromTextBeginning, kATSUToTextEnd,
+			  Long2Fix (x), Long2Fix (port_height - y));
+	  CGContextSynchronize (context);
+	  QDEndCGContext (port, &context);
 #if 0
-	      /* This doesn't work on Mac OS X 10.1.  */
-	      ATSUClearLayoutControls (text_layout,
-				       sizeof (tags) / sizeof (tags[0]),
-				       tags);
+	  /* This doesn't work on Mac OS X 10.1.  */
+	  ATSUClearLayoutControls (text_layout,
+				   sizeof (tags) / sizeof (tags[0]), tags);
 #else
-	      ATSUSetLayoutControls (text_layout,
-				     sizeof (tags) / sizeof (tags[0]),
-				     tags, sizes, values);
-#endif
-	    }
+	  ATSUSetLayoutControls (text_layout,
+				 sizeof (tags) / sizeof (tags[0]),
+				 tags, sizes, values);
 #endif
 	}
+#endif	/* MAC_OSX */
     }
   else
-    {
-#endif
-  TextFont (GC_FONT (gc)->mac_fontnum);
-  TextSize (GC_FONT (gc)->mac_fontsize);
-  TextFace (GC_FONT (gc)->mac_fontface);
-  TextMode (mode);
-
-  mac_begin_clip (GC_CLIP_REGION (gc));
-  MoveTo (x, y);
-  DrawText (buf, 0, nchars * bytes_per_char);
-  mac_end_clip (GC_CLIP_REGION (gc));
-#if USE_ATSUI
-    }
-#endif
-
-  if (mode != srcOr)
-    RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
+#endif	/* USE_ATSUI */
+    {
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
-  if (mac_use_core_graphics)
-    SwapQDTextFlags(savedFlags);
-#endif
+      UInt32 savedFlags;
+
+      if (mac_use_core_graphics)
+	savedFlags = SwapQDTextFlags (kQDUseCGTextRendering);
+#endif
+      mac_begin_clip (GC_CLIP_REGION (gc));
+      RGBForeColor (GC_FORE_COLOR (gc));
+#ifdef MAC_OS8
+      if (bg_width)
+	{
+	  RGBBackColor (GC_BACK_COLOR (gc));
+	  TextMode (srcCopy);
+	}
+      else
+	TextMode (srcOr);
+#else
+      /* We prefer not to use srcCopy text transfer mode on Mac OS X
+	 because:
+	 - Screen is double-buffered.  (In srcCopy mode, a text is
+	   drawn into an offscreen graphics world first.  So
+	   performance gain cannot be expected.)
+	 - It lowers rendering quality.
+	 - Some fonts leave garbage on cursor movement.  */
+      if (bg_width)
+	{
+	  Rect r;
+
+	  RGBBackColor (GC_BACK_COLOR (gc));
+	  SetRect (&r, x, y - FONT_BASE (GC_FONT (gc)),
+		   x + bg_width, y + FONT_DESCENT (GC_FONT (gc)));
+	  EraseRect (&r);
+	}
+      TextMode (srcOr);
+#endif
+      TextFont (GC_FONT (gc)->mac_fontnum);
+      TextSize (GC_FONT (gc)->mac_fontsize);
+      TextFace (GC_FONT (gc)->mac_fontface);
+      MoveTo (x, y);
+      DrawText (buf, 0, nchars * bytes_per_char);
+      if (bg_width)
+	RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
+      mac_end_clip (GC_CLIP_REGION (gc));
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
+      if (mac_use_core_graphics)
+	SwapQDTextFlags(savedFlags);
+#endif
+    }
 }
 
 
@@ -822,7 +863,7 @@
      char *buf;
      int nchars;
 {
-  mac_draw_string_common (f, gc, x, y, buf, nchars, srcOr, 1);
+  mac_draw_string_common (f, gc, x, y, buf, nchars, 0, 1);
 }
 
 
@@ -836,35 +877,35 @@
      XChar2b *buf;
      int nchars;
 {
-  mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcOr, 2);
+  mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, 0, 2);
 }
 
 
 /* Mac replacement for XDrawImageString.  */
 
 static void
-mac_draw_image_string (f, gc, x, y, buf, nchars)
+mac_draw_image_string (f, gc, x, y, buf, nchars, bg_width)
      struct frame *f;
      GC gc;
      int x, y;
      char *buf;
-     int nchars;
-{
-  mac_draw_string_common (f, gc, x, y, buf, nchars, srcCopy, 1);
+     int nchars, bg_width;
+{
+  mac_draw_string_common (f, gc, x, y, buf, nchars, bg_width, 1);
 }
 
 
 /* Mac replacement for XDrawString16.  */
 
 static void
-mac_draw_image_string_16 (f, gc, x, y, buf, nchars)
+mac_draw_image_string_16 (f, gc, x, y, buf, nchars, bg_width)
      struct frame *f;
      GC gc;
      int x, y;
      XChar2b *buf;
-     int nchars;
-{
-  mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2);
+     int nchars, bg_width;
+{
+  mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, bg_width, 2);
 }
 
 
@@ -1038,12 +1079,12 @@
 }
 
 static int
-mac_draw_string_cg (f, gc, x, y, buf, nchars)
+mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width)
      struct frame *f;
      GC gc;
      int x, y;
      XChar2b *buf;
-     int nchars;
+     int nchars, bg_width;
 {
   CGrafPtr port;
   float port_height, gx, gy;
@@ -1060,7 +1101,9 @@
   gx = x;
   gy = port_height - y;
   glyphs = (CGGlyph *)buf;
-  advances = xmalloc (sizeof (CGSize) * nchars);
+  advances = alloca (sizeof (CGSize) * nchars);
+  if (advances == NULL)
+    return 0;
   for (i = 0; i < nchars; i++)
     {
       XCharStruct *pcm = mac_per_char_metric (GC_FONT (gc), buf, 0);
@@ -1072,18 +1115,32 @@
     }
 
   QDBeginCGContext (port, &context);
-  if (gc->n_clip_rects)
+  if (gc->n_clip_rects || bg_width)
     {
       CGContextTranslateCTM (context, 0, port_height);
       CGContextScaleCTM (context, 1, -1);
-      CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
+      if (gc->n_clip_rects)
+	CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
+      if (bg_width)
+	{
+	  CGContextSetRGBFillColor
+	    (context,
+	     RED_FROM_ULONG (gc->xgcv.background) / 255.0f,
+	     GREEN_FROM_ULONG (gc->xgcv.background) / 255.0f,
+	     BLUE_FROM_ULONG (gc->xgcv.background) / 255.0f,
+	     1.0);
+	  CGContextFillRect
+	    (context,
+	     CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)),
+			 bg_width, FONT_HEIGHT (GC_FONT (gc))));
+	}
       CGContextScaleCTM (context, 1, -1);
       CGContextTranslateCTM (context, 0, -port_height);
     }
   CGContextSetRGBFillColor (context,
-			    RED_FROM_ULONG (gc->xgcv.foreground) / 255.0,
-			    GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0,
-			    BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0,
+			    RED_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
+			    GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
+			    BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0f,
 			    1.0);
   CGContextSetFont (context, GC_FONT (gc)->cg_font);
   CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize);
@@ -1102,8 +1159,6 @@
   CGContextSynchronize (context);
   QDEndCGContext (port, &context);
 
-  xfree (advances);
-
   return 1;
 }
 #endif
@@ -1375,10 +1430,7 @@
   if (n == 0)
     {
       if (gc->clip_region)
-	{
-	  DisposeRgn (gc->clip_region);
-	  gc->clip_region = NULL;
-	}
+	SetEmptyRgn (gc->clip_region);
     }
   else
     {
@@ -2322,14 +2374,6 @@
 }
 
 
-/* We prefer not to use XDrawImageString (srcCopy text transfer mode)
-   on Mac OS X because:
-   - Screen is double-buffered.  (In srcCopy mode, a text is drawn
-     into an offscreen graphics world first.  So performance gain
-     cannot be expected.)
-   - It lowers rendering quality.
-   - Some fonts leave garbage on cursor movement.  */
-
 /* Draw the background of glyph_string S.  If S->background_filled_p
    is non-zero don't draw it.  FORCE_P non-zero means draw the
    background even if it wouldn't be drawn normally.  This is used
@@ -2361,12 +2405,10 @@
 	}
       else
 #endif
-#if defined (MAC_OS8) && !USE_ATSUI
         if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
 	       || s->font_not_found_p
 	       || s->extends_to_end_of_line_p
 	       || force_p)
-#endif
 	{
 	  x_clear_glyph_string_rect (s, s->x, s->y + box_line_width,
 				     s->background_width,
@@ -2383,7 +2425,7 @@
 x_draw_glyph_string_foreground (s)
      struct glyph_string *s;
 {
-  int i, x;
+  int i, x, bg_width;
 
   /* If first glyph of S has a left box line, start drawing the text
      of S to the right of that box line.  */
@@ -2422,7 +2464,6 @@
 	for (i = 0; i < s->nchars; ++i)
 	  char1b[i] = s->char2b[i].byte2;
 
-#if defined (MAC_OS8) && !USE_ATSUI
       /* Draw text with XDrawString if background has already been
 	 filled.  Otherwise, use XDrawImageString.  (Note that
 	 XDrawImageString is usually faster than XDrawString.)  Always
@@ -2430,38 +2471,27 @@
 	 no chance that characters under a box cursor are invisible.  */
       if (s->for_overlaps
 	  || (s->background_filled_p && s->hl != DRAW_CURSOR))
-#endif
-	{
-	  /* Draw characters with 16-bit or 8-bit functions.  */
-	  if (s->two_byte_p
+	bg_width = 0;		/* Corresponds to XDrawString.  */
+      else
+	bg_width = s->background_width; /* Corresponds to XDrawImageString.  */
+
+      if (s->two_byte_p
 #if USE_ATSUI
-	      || GC_FONT (s->gc)->mac_style
-#endif
-	      )
+	  || GC_FONT (s->gc)->mac_style
+#endif
+	  )
 #if USE_CG_TEXT_DRAWING
-	    if (!s->two_byte_p
-		&& mac_draw_string_cg (s->f, s->gc, x, s->ybase - boff,
-				       s->char2b, s->nchars))
-	      ;
-	    else
-#endif
-	    mac_draw_string_16 (s->f, s->gc, x,	s->ybase - boff,
-				s->char2b, s->nchars);
-	  else
-	    mac_draw_string (s->f, s->gc, x, s->ybase - boff,
-			     char1b, s->nchars);
-	}
-#if defined (MAC_OS8) && !USE_ATSUI
+	if (!s->two_byte_p
+	    && mac_draw_image_string_cg (s->f, s->gc, x, s->ybase - boff,
+					 s->char2b, s->nchars, bg_width))
+	  ;
+	else
+#endif
+	  mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
+				    s->char2b, s->nchars, bg_width);
       else
-	{
-	  if (s->two_byte_p)
-	    mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
-				      s->char2b, s->nchars);
-	  else
-	    mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
-				   char1b, s->nchars);
-	}
-#endif
+	mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
+			       char1b, s->nchars, bg_width);
     }
 }
 
@@ -7837,9 +7867,13 @@
 #if !defined (MAC_OS8) || USE_ATSUI
   /* AppKit and WebKit do some adjustment to the heights of Courier,
      Helvetica, and Times.  This only works on the environments where
-     the XDrawImageString counterpart is never used.  */
-  if (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0
-      || strcmp (family, "times") == 0)
+     srcCopy text transfer mode is never used.  */
+  if (
+#ifdef MAC_OS8			/* implies USE_ATSUI */
+      font->mac_style &&
+#endif
+      (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0
+       || strcmp (family, "times") == 0))
     font->ascent += (font->ascent + font->descent) * .15 + 0.5;
 #endif
 
--- a/src/regex.c	Mon Feb 20 16:35:38 2006 +0000
+++ b/src/regex.c	Tue Feb 21 15:57:00 2006 +0000
@@ -181,6 +181,51 @@
 char *realloc ();
 # endif
 
+/* When used in Emacs's lib-src, we need xmalloc and xrealloc. */
+
+void *
+xmalloc (size)
+     size_t size;
+{
+  register void *val;
+  val = (void *) malloc (size);
+  if (!val && size)
+    {
+      write (2, "virtual memory exhausted\n", 25);
+      exit (1);
+    }
+  return val;
+}
+
+void *
+xrealloc (block, size)
+     void *block;
+     size_t size;
+{
+  register void *val;
+  /* We must call malloc explicitly when BLOCK is 0, since some
+     reallocs don't do this.  */
+  if (! block)
+    val = (void *) malloc (size);
+  else
+    val = (void *) realloc (block, size);
+  if (!val && size)
+    {
+      write (2, "virtual memory exhausted\n", 25);
+      exit (1);
+    }
+  return val;
+}
+
+# ifdef malloc
+#  undef malloc
+# endif
+# define malloc xmalloc
+# ifdef realloc
+#  undef realloc
+# endif
+# define realloc xrealloc
+
 /* When used in Emacs's lib-src, we need to get bzero and bcopy somehow.
    If nothing else has been done, use the method below.  */
 # ifdef INHIBIT_STRING_HEADER
@@ -3609,12 +3654,12 @@
 	if (! fail_stack.stack)
 	  fail_stack.stack
 	    = (fail_stack_elt_t *) malloc (fail_stack.size
-					    * sizeof (fail_stack_elt_t));
+					   * sizeof (fail_stack_elt_t));
 	else
 	  fail_stack.stack
 	    = (fail_stack_elt_t *) realloc (fail_stack.stack,
-					     (fail_stack.size
-					      * sizeof (fail_stack_elt_t)));
+					    (fail_stack.size
+					     * sizeof (fail_stack_elt_t)));
       }
 
     regex_grow_registers (num_regs);
@@ -6300,7 +6345,7 @@
 
       preg->translate
 	= (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
-				       * sizeof (*(RE_TRANSLATE_TYPE)0));
+				      * sizeof (*(RE_TRANSLATE_TYPE)0));
       if (preg->translate == NULL)
 	return (int) REG_ESPACE;
 
--- a/src/xfns.c	Mon Feb 20 16:35:38 2006 +0000
+++ b/src/xfns.c	Tue Feb 21 15:57:00 2006 +0000
@@ -5332,6 +5332,7 @@
   int result;
   struct frame *f = SELECTED_FRAME ();
   Lisp_Object file = Qnil;
+  Lisp_Object decoded_file;
   Widget dialog, text, help;
   Arg al[10];
   int ac = 0;
@@ -5472,7 +5473,9 @@
   if (NILP (file))
     Fsignal (Qquit, Qnil);
 
-  return unbind_to (count, file);
+  decoded_file = DECODE_FILE (file);
+
+  return unbind_to (count, decoded_file);
 }
 
 #endif /* USE_MOTIF */
@@ -5500,6 +5503,7 @@
   FRAME_PTR f = SELECTED_FRAME ();
   char *fn;
   Lisp_Object file = Qnil;
+  Lisp_Object decoded_file;
   int count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
   char *cdef_file;
@@ -5540,7 +5544,9 @@
   if (NILP (file))
     Fsignal (Qquit, Qnil);
 
-  return unbind_to (count, file);
+  decoded_file = DECODE_FILE (file);
+
+  return unbind_to (count, decoded_file);
 }
 
 #endif /* USE_GTK */