# HG changeset patch # User Aidan Kehoe # Date 1210528210 -7200 # Node ID 20c32e48923530d9f7b78a89f925a4c6cb93051b # Parent 4953b7353349ac3293d419461fee6a71cf63c115 Add #'query-coding-clear-highlights. 2008-05-11 Aidan Kehoe * coding.el (query-coding-clear-highlights): New function--clear any face information added by `query-coding-region'. (default-query-coding-region): Use it. diff -r 4953b7353349 -r 20c32e489235 lisp/ChangeLog --- a/lisp/ChangeLog Sat May 03 13:09:06 2008 +0200 +++ b/lisp/ChangeLog Sun May 11 19:50:10 2008 +0200 @@ -1,3 +1,10 @@ +2008-05-11 Aidan Kehoe + + * coding.el (query-coding-clear-highlights): + New function--clear any face information added by + `query-coding-region'. + (default-query-coding-region): Use it. + 2008-04-13 Henry S. Thompson , Mike Sperber * window-xemacs.el (save-window-excursion/mapping, diff -r 4953b7353349 -r 20c32e489235 lisp/coding.el --- 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.