Mercurial > hg > xemacs-beta
comparison lisp/mule/mule-coding.el @ 104:cf808b4c4290 r20-1b4
Import from CVS: tag r20-1b4
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:16:51 +0200 |
parents | a145efe76779 |
children | 8619ce7e4c50 |
comparison
equal
deleted
inserted
replaced
103:30eda07fe280 | 104:cf808b4c4290 |
---|---|
51 "Show the encoding of text in the region. | 51 "Show the encoding of text in the region. |
52 This function is meant to be called interactively; | 52 This function is meant to be called interactively; |
53 from a Lisp program, use `detect-coding-region' instead." | 53 from a Lisp program, use `detect-coding-region' instead." |
54 (interactive "r\nP") | 54 (interactive "r\nP") |
55 (princ (detect-coding-region start end))) | 55 (princ (detect-coding-region start end))) |
56 | |
57 (defmacro with-string-as-buffer-contents (str &rest body) | |
58 "With the contents of the current buffer being STR, run BODY. | |
59 Returns the new contents of the buffer, as modified by BODY. | |
60 The original current buffer is restored afterwards." | |
61 `(let ((curbuf (current-buffer)) | |
62 (tempbuf (get-buffer-create " *string-as-buffer-contents*"))) | |
63 (unwind-protect | |
64 (progn | |
65 (set-buffer tempbuf) | |
66 (buffer-disable-undo (current-buffer)) | |
67 (erase-buffer) | |
68 (insert ,str) | |
69 ,@body | |
70 (buffer-string)) | |
71 (erase-buffer tempbuf) | |
72 (set-buffer curbuf)))) | |
73 | 56 |
74 (defun decode-coding-string (str coding-system) | 57 (defun decode-coding-string (str coding-system) |
75 "Decode the string STR which is encoded in CODING-SYSTEM. | 58 "Decode the string STR which is encoded in CODING-SYSTEM. |
76 Does not modify STR. Returns the decoded string on successful conversion." | 59 Does not modify STR. Returns the decoded string on successful conversion." |
77 (with-string-as-buffer-contents | 60 (with-string-as-buffer-contents |