diff lisp/coding.el @ 4555:20c32e489235

Add #'query-coding-clear-highlights. 2008-05-11 Aidan Kehoe <kehoea@parhasard.net> * coding.el (query-coding-clear-highlights): New function--clear any face information added by `query-coding-region'. (default-query-coding-region): Use it.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 11 May 2008 19:50:10 +0200
parents 75654496fa0e
children 46ddeaa7c738
line wrap: on
line diff
--- a/lisp/coding.el	Sat May 03 13:09:06 2008 +0200
+++ b/lisp/coding.el	Sun May 11 19:50:10 2008 +0200
@@ -286,6 +286,20 @@
   #s(hash-table test equal data ())
   "A map from list of charsets to `skip-chars-forward' arguments for them.")
 
+(defsubst query-coding-clear-highlights (begin end &optional buffer)
+  "Remove extent faces added by `query-coding-region' between BEGIN and END.
+
+Optional argument BUFFER is the buffer to use, and defaults to the current
+buffer.
+
+The HIGHLIGHTP argument to `query-coding-region' indicates that it should
+display unencodable characters using `query-coding-warning-face'.  After
+this function has been called, this will no longer be the case.  "
+  (map-extents #'(lambda (extent ignored-arg)
+                   (when (eq 'query-coding-warning-face
+                             (extent-face extent))
+                     (delete-extent extent))) buffer begin end))
+
 (defun default-query-coding-region (begin end coding-system
 				    &optional buffer errorp highlightp)
   "The default `query-coding-region' implementation.
@@ -319,10 +333,7 @@
 				safe-charsets "")
 		     default-query-coding-region-safe-charset-skip-chars-map)))
     (when highlightp
-      (map-extents #'(lambda (extent ignored-arg)
-		       (when (eq 'query-coding-warning-face
-				 (extent-face extent))
-			 (delete-extent extent))) buffer begin end))
+      (query-coding-clear-highlights begin end buffer))
     (if (and (zerop (length skip-chars-arg)) (null safe-chars))
 	(progn
 	    ;; Uh-oh, nothing known about this coding system. Fail. 
@@ -384,7 +395,7 @@
 	    (values nil ranges)
 	  (values t nil))))))
 
-(defsubst query-coding-region (start end coding-system &optional buffer
+(defun query-coding-region (start end coding-system &optional buffer
                                errorp highlight)
   "Work out whether CODING-SYSTEM can losslessly encode a region.