diff options
| author | Lars Magne Ingebrigtsen | 2010-11-05 15:17:46 +0100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2010-11-05 15:17:46 +0100 |
| commit | 5c0c0f77b0b3af28653a6a8e798f69d132425c0e (patch) | |
| tree | 6c484c9782fc9a92497fc9674fb2b6f4bf56adb1 | |
| parent | e06918d22b68821e7c1aa8148622232f106fbfc5 (diff) | |
| download | emacs-5c0c0f77b0b3af28653a6a8e798f69d132425c0e.tar.gz emacs-5c0c0f77b0b3af28653a6a8e798f69d132425c0e.zip | |
Decode utf-8 strings in mixed environments by default.
Done via the new `erc-coding-system-precedence' variable.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/erc/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/erc/erc-backend.el | 19 |
3 files changed, 28 insertions, 1 deletions
| @@ -303,6 +303,11 @@ successful NickServ identification, or after `erc-autojoin-delay' | |||
| 303 | seconds. The default value, 'ident, means to autojoin immediately | 303 | seconds. The default value, 'ident, means to autojoin immediately |
| 304 | after connecting. | 304 | after connecting. |
| 305 | 305 | ||
| 306 | *** New variable `erc-coding-system-precedence': If we use `undecided' | ||
| 307 | as the server coding system, this variable will then be consulted. | ||
| 308 | The default is to decode strings that can be decoded as utf-8 as | ||
| 309 | utf-8, and do the normal `undecided' decoding for the rest. | ||
| 310 | |||
| 306 | ** In ido-mode, C-v is no longer bound to ido-toggle-vc. | 311 | ** In ido-mode, C-v is no longer bound to ido-toggle-vc. |
| 307 | The reason is that this interferes with cua-mode. | 312 | The reason is that this interferes with cua-mode. |
| 308 | 313 | ||
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog index 49f039c51b9..1f27dbdb7f7 100644 --- a/lisp/erc/ChangeLog +++ b/lisp/erc/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-11-05 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * erc-backend.el (erc-coding-system-precedence): New variable. | ||
| 4 | (erc-decode-string-from-target): Use it. | ||
| 5 | |||
| 1 | 2010-10-24 Julien Danjou <julien@danjou.info> | 6 | 2010-10-24 Julien Danjou <julien@danjou.info> |
| 2 | 7 | ||
| 3 | * erc-backend.el (erc-server-JOIN): Set the correct target list on join. | 8 | * erc-backend.el (erc-server-JOIN): Set the correct target list on join. |
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 46e9d6c8c2c..3bc56989f4f 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el | |||
| @@ -324,6 +324,13 @@ Good luck." | |||
| 324 | :type 'integer | 324 | :type 'integer |
| 325 | :group 'erc-server) | 325 | :group 'erc-server) |
| 326 | 326 | ||
| 327 | (defcustom erc-coding-system-precedence '(utf-8 undecided) | ||
| 328 | "List of coding systems to be preferred when receiving a string from the server. | ||
| 329 | This will only be consulted if the coding system in | ||
| 330 | `erc-server-coding-system' is `undecided'." | ||
| 331 | :group 'erc-server | ||
| 332 | :type '(repeat coding-system)) | ||
| 333 | |||
| 327 | (defcustom erc-server-coding-system (if (and (fboundp 'coding-system-p) | 334 | (defcustom erc-server-coding-system (if (and (fboundp 'coding-system-p) |
| 328 | (coding-system-p 'undecided) | 335 | (coding-system-p 'undecided) |
| 329 | (coding-system-p 'utf-8)) | 336 | (coding-system-p 'utf-8)) |
| @@ -334,7 +341,9 @@ This is either a coding system, a cons, a function, or nil. | |||
| 334 | 341 | ||
| 335 | If a cons, the encoding system for outgoing text is in the car | 342 | If a cons, the encoding system for outgoing text is in the car |
| 336 | and the decoding system for incoming text is in the cdr. The most | 343 | and the decoding system for incoming text is in the cdr. The most |
| 337 | interesting use for this is to put `undecided' in the cdr. | 344 | interesting use for this is to put `undecided' in the cdr. This |
| 345 | means that `erc-coding-system-precedence' will be consulted, and the | ||
| 346 | first match there will be used. | ||
| 338 | 347 | ||
| 339 | If a function, it is called with the argument `target' and should | 348 | If a function, it is called with the argument `target' and should |
| 340 | return a coding system or a cons as described above. | 349 | return a coding system or a cons as described above. |
| @@ -705,6 +714,14 @@ This is indicated by `erc-encoding-coding-alist', defaulting to the value of | |||
| 705 | (let ((coding (erc-coding-system-for-target target))) | 714 | (let ((coding (erc-coding-system-for-target target))) |
| 706 | (when (consp coding) | 715 | (when (consp coding) |
| 707 | (setq coding (cdr coding))) | 716 | (setq coding (cdr coding))) |
| 717 | (when (eq coding 'undecided) | ||
| 718 | (let ((codings (detect-coding-string str)) | ||
| 719 | (precedence erc-coding-system-precedence)) | ||
| 720 | (while (and precedence | ||
| 721 | (not (memq (car precedence) codings))) | ||
| 722 | (pop precedence)) | ||
| 723 | (when precedence | ||
| 724 | (setq coding (car precedence))))) | ||
| 708 | (erc-decode-coding-string str coding))) | 725 | (erc-decode-coding-string str coding))) |
| 709 | 726 | ||
| 710 | ;; proposed name, not used by anything yet | 727 | ;; proposed name, not used by anything yet |