(eval-when-compile (require 'cl))
(require 'mcharset)
+(require 'static)
+(require 'poem)
-(eval-and-compile
+(eval-when-compile
(autoload 'mime-content-type-parameter "mime-parse")
(autoload 'mime-read-Content-Type "mime-parse"))
+(static-if (fboundp 'string-to-list)
+ (defalias 'gettext-string-to-list 'string-to-list)
+ ;; Rely on `string-to-char-list' emulation is provided in poem.
+ (defalias 'gettext-string-to-list 'string-to-char-list))
+
(defvar gettext-gmo-endian 1234)
(defvar gettext-message-domain-to-catalog-alist nil)
(defvar gettext-default-message-domain "emacs")
(goto-char pos))
(nreverse strings)))
-(defmacro gettext-parse-Content-Type (&optional header)
- (require 'path-util)
- (if (module-installed-p 'mime-parse)
- (list 'with-temp-buffer
- (list 'insert header)
- '(mime-content-type-parameter
- (mime-read-Content-Type)
- "charset"))
- 'gettext-default-mime-charset))
+(defun gettext-parse-Content-Type (&optional header)
+ "Return the MIME charset of PO file."
+ (with-temp-buffer
+ (insert header)
+ (if (require 'mime-parse nil 'noerror)
+ (mime-content-type-parameter (mime-read-Content-Type) "charset")
+ (goto-char (point-min))
+ (if (re-search-forward
+ "^\"Content-Type: *text/plain;[ \t]*charset=\\([^\\]+\\)"
+ nil t)
+ (find-mime-charset-by-charsets
+ (list (buffer-substring (match-beginning 1) (match-end 1))))
+ gettext-default-mime-charset))))
(defun gettext-mapcar* (function &rest args)
"Apply FUNCTION to successive cars of all ARGS.
((string-match "[^ ]* [^ ]* \\([^ ]+\\) \\(.*\\)" rest)
(setq liece-supported-user-mode-alist
(char-list-to-string-alist
- (string-to-char-list (match-string 1 rest)))
+ (liece-string-to-list (match-string 1 rest)))
liece-supported-channel-mode-alist
(char-list-to-string-alist
- (string-to-char-list (match-string 2 rest)))))
+ (liece-string-to-list (match-string 2 rest)))))
(t
(liece-insert-info liece-000-buffer (concat rest "\n"))))))
(defmacro liece-channel-add-mode (mode &optional chnl)
"Add MODE as char to CHNL."
- `(let ((modes (string-to-char-list (or (liece-channel-get-modes ,chnl)
+ `(let ((modes (liece-string-to-list (or (liece-channel-get-modes ,chnl)
""))))
(or (memq ,mode modes)
(push ,mode modes))
(defmacro liece-channel-remove-mode (mode &optional chnl)
"Remove MODE as char to CHNL."
- `(let ((modes (string-to-char-list (or (liece-channel-get-modes ,chnl)
+ `(let ((modes (liece-string-to-list (or (liece-channel-get-modes ,chnl)
""))))
(delq ,mode modes)
(put (intern (or ,chnl liece-current-channel) liece-obarray)
(defalias 'liece-window-height 'window-displayed-height)
(defalias 'liece-window-height 'window-height))
+(static-if (fboundp 'string-to-list)
+ (defalias 'liece-string-to-list 'string-to-list)
+ ;; Rely on `string-to-char-list' emulation is provided in poem.
+ (defalias 'liece-string-to-list 'string-to-char-list))
+
(defalias 'liece-mode-line-buffer-identification 'identity)
(defun liece-suppress-mode-line-format ()
(when (string-match "\\([^ ]*\\) +" str)
(setq mflag (match-string 1 str)
marg (substring str (match-end 0))
- mflags (string-to-char-list mflag))
+ mflags (liece-string-to-list mflag))
(while (string-match "^\\([^ ]*\\) +" marg)
(setq margs (cons (match-string 1 marg) margs)
marg (substring marg (match-end 0))))
(defmacro liece-nick-add-mode (mode &optional nick)
"Add MODE as char to NICK."
`(let* ((n (intern ,nick liece-obarray))
- (modes (string-to-char-list (or (get n 'mode) ""))))
+ (modes (liece-string-to-list (or (get n 'mode) ""))))
(put n 'mode (mapconcat #'char-to-string
(or (memq ,mode modes)
(cons ,mode modes)) ""))))
(defmacro liece-nick-remove-mode (mode &optional nick)
"Remove MODE as char to NICK."
`(let* ((n (intern ,nick liece-obarray))
- (modes (string-to-char-list (or (get n 'mode) ""))))
+ (modes (liece-string-to-list (or (get n 'mode) ""))))
(delq ,mode modes)
(put n 'mode (mapconcat #'char-to-string modes ""))))