X-Git-Url: https://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-identity.el;h=d86c09cff3373fd241292cc79bde43d6ae215853;hp=f7a48cb6bb94cba05065643f10cbaf9421114148;hb=c25472a32afa906719ebb03c81bbc2f0d34d6abf;hpb=2dfe0101ccd973cb006b0038e5225ef6bf201943 diff --git a/lisp/riece-identity.el b/lisp/riece-identity.el index f7a48cb..d86c09c 100644 --- a/lisp/riece-identity.el +++ b/lisp/riece-identity.el @@ -26,19 +26,22 @@ (require 'riece-globals) (require 'riece-coding) -(require 'riece-compat) ;riece-set-case-syntax-pair (defvar riece-abbrev-identity-string-function nil) (defvar riece-expand-identity-string-function nil) -(defvar riece-identity-prefix-case-table - (let ((table (riece-copy-case-table (standard-case-table)))) - (riece-set-case-syntax-pair ?\[ ?{ table) - (riece-set-case-syntax-pair ?\] ?} table) - (riece-set-case-syntax-pair ?\\ ?| table) - (riece-set-case-syntax-pair ?~ ?^ table) - table)) - +(defconst riece-identity-prefix-case-pair-alist + '((?\[ . ?{) + (?\] . ?}) + (?\\ . ?|) + (?~ . ?^)) + "An alist used to canonicalize identity-prefix. +RFC2812, 2.2 \"Character codes\" says: + Because of IRC's Scandinavian origin, the characters {}|^ are + considered to be the lower case equivalents of the characters []\~, + respectively. This is a critical issue when determining the + equivalence of two nicknames or channel names.") + (defun riece-identity-prefix (identity) "Return the component sans its server from IDENTITY." (aref identity 0)) @@ -61,20 +64,16 @@ (riece-identity-server ident2)))) (defun riece-identity-canonicalize-prefix (prefix) - "Canonicalize identity PREFIX. -This function downcases PREFIX with Scandinavian alphabet rule. - -RFC2812, 2.2 \"Character codes\" says: - Because of IRC's Scandinavian origin, the characters {}|^ are - considered to be the lower case equivalents of the characters []\~, - respectively. This is a critical issue when determining the - equivalence of two nicknames or channel names." - (let ((old-table (current-case-table))) - (unwind-protect - (progn - (set-case-table riece-identity-prefix-case-table) - (downcase prefix)) - (set-case-table old-table)))) + "Canonicalize identity PREFIX." + (let ((i 0) + c) + (setq prefix (downcase prefix)) + (while (< i (length prefix)) + (if (setq c (cdr (assq (aref prefix i) + riece-identity-prefix-case-pair-alist))) + (aset prefix i c)) + (setq i (1+ i))) + prefix)) (defun riece-identity-equal-no-server (prefix1 prefix2) "Return t, if IDENT1 and IDENT2 is equal without server part." @@ -139,7 +138,13 @@ will be added." (riece-identity-server identity))))) (if riece-abbrev-identity-string-function (setq string (funcall riece-abbrev-identity-string-function string))) - (put-text-property 0 (length string) 'riece-identity identity string) + (riece-put-text-property-nonsticky 0 (length string) + 'riece-identity identity + string) + (if prefix-only + (riece-put-text-property-nonsticky 0 (length string) + 'riece-format-identity-prefix-only t + string)) string)) (defun riece-parse-identity (string) @@ -157,7 +162,8 @@ The string will be expanded by (defun riece-completing-read-identity (prompt channels &optional predicate require-match - initial history default) + initial history default + no-server) "Read an identity object in the minibuffer, with completion. PROMPT is a string to prompt with; normally it ends in a colon and a space. CHANNELS is a list of identity objects. @@ -166,7 +172,7 @@ The rest of arguments are the same as `completing-read'." (completing-read prompt (mapcar (lambda (channel) - (list (riece-format-identity channel))) + (list (riece-format-identity channel no-server))) (delq nil (copy-sequence (or channels riece-current-channels)))) predicate require-match initial history default))