diff options
author | Karoly Lorentey <lorentey@elte.hu> | 2006-06-12 07:27:12 +0000 |
---|---|---|
committer | Karoly Lorentey <lorentey@elte.hu> | 2006-06-12 07:27:12 +0000 |
commit | 476e9367ec1f440aa23904b7bc482ea4a3b8041c (patch) | |
tree | 4f7f5a5e9a6668f908834bb6e216c8fa3727d4b3 /lisp/textmodes/po.el | |
parent | a13f8f50d4cc544d3bbfa78568e82ce09e68bded (diff) | |
parent | 6b519504c3297595101628e823e72c91e562ab45 (diff) | |
download | emacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.tar.gz emacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.tar.bz2 emacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.zip |
Merged from emacs@sv.gnu.org.
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-294
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-295
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-296
Update from CVS: admin/FOR-RELEASE: Update refcard section.
* emacs@sv.gnu.org/emacs--devo--0--patch-297
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-298
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-299
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-300
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-301
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-302
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-303
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-304
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-103
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-104
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-570
Diffstat (limited to 'lisp/textmodes/po.el')
-rw-r--r-- | lisp/textmodes/po.el | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lisp/textmodes/po.el b/lisp/textmodes/po.el index 07b9ba1a2b1..eac1cb94105 100644 --- a/lisp/textmodes/po.el +++ b/lisp/textmodes/po.el @@ -41,15 +41,21 @@ Contains canonical charset names that don't correspond to coding systems.") (defun po-find-charset (filename) - "Return PO charset value for FILENAME." + "Return PO charset value for FILENAME. +If FILENAME is a cons, the cdr part is a buffer that already contains +the PO file (but not yet decoded)." (let ((charset-regexp "^\"Content-Type:[ \t]*text/plain;[ \t]*charset=\\(.*\\)\\\\n\"") + (buf (and (consp filename) (cdr filename))) (short-read nil)) + (when buf + (set-buffer buf) + (goto-char (point-min))) ;; Try the first 4096 bytes. In case we cannot find the charset value ;; within the first 4096 bytes (the PO file might start with a long ;; comment) try the next 4096 bytes repeatedly until we'll know for sure ;; we've checked the empty header entry entirely. - (while (not (or short-read (re-search-forward "^msgid" nil t))) + (while (not (or short-read (re-search-forward "^msgid" nil t) buf)) (save-excursion (goto-char (point-max)) (let ((pair (insert-file-contents-literally filename nil @@ -57,7 +63,7 @@ Contains canonical charset names that don't correspond to coding systems.") (1- (+ (point) 4096))))) (setq short-read (< (nth 1 pair) 4096))))) (cond ((re-search-forward charset-regexp nil t) (match-string 1)) - (short-read nil) + ((or short-read buf) nil) ;; We've found the first msgid; maybe, only a part of the msgstr ;; value was loaded. Load the next 1024 bytes; if charset still ;; isn't available, give up. @@ -71,10 +77,13 @@ Contains canonical charset names that don't correspond to coding systems.") (defun po-find-file-coding-system-guts (operation filename) "Return a (DECODING . ENCODING) pair for OPERATION on PO file FILENAME. -Do so according to FILENAME's declared charset." +Do so according to FILENAME's declared charset. +FILENAME may be a cons (NAME . BUFFER). In that case, detect charset +in BUFFER." (and (eq operation 'insert-file-contents) - (file-exists-p filename) + (or (if (consp filename) (buffer-live-p (cdr filename))) + (file-exists-p filename)) (with-temp-buffer (let* ((coding-system-for-read 'no-conversion) (charset (or (po-find-charset filename) "ascii")) |