X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fecomplete.el;h=1a851e933fdc5493d2860d558e27ddd6009729cc;hb=ea10b1df0ae97e205c6d258248136f5f35edfa96;hp=e9eef9d5affe906963634e0bc12372f5293153a5;hpb=078537773c499837ba0b0253c449cc1564eaea47;p=gnus diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el index e9eef9d5a..1a851e933 100644 --- a/lisp/ecomplete.el +++ b/lisp/ecomplete.el @@ -29,7 +29,7 @@ (require 'cl)) (defgroup ecomplete nil - "Suppression of duplicate articles." + "Electric completion of email addresses and the like." :group 'mail) (defcustom ecomplete-database-file "~/.ecompleterc" @@ -37,15 +37,22 @@ :group 'ecomplete :type 'file) +(defcustom ecomplete-database-file-coding-system 'iso-2022-7bit + "Coding system used for writing the ecomplete database file." + :type '(repeat (symbol :tag "Coding system")) + :group 'ecomplete) + ;;; Internal variables. (defvar ecomplete-database nil) +;;;###autoload (defun ecomplete-setup () (when (file-exists-p ecomplete-database-file) (with-temp-buffer - (insert-file-contents ecomplete-database-file) - (setq ecomplete-database (read (current-buffer)))))) + (let ((coding-system-for-read ecomplete-database-file-coding-system)) + (insert-file-contents ecomplete-database-file) + (setq ecomplete-database (read (current-buffer))))))) (defun ecomplete-add-item (type key text) (let ((elems (assq type ecomplete-database)) @@ -63,16 +70,18 @@ (defun ecomplete-save () (with-temp-buffer - (insert "(") - (loop for (type . elems) in ecomplete-database - do - (insert (format "(%s\n" type)) - (dolist (entry elems) - (prin1 entry (current-buffer)) - (insert "\n")) - (insert ")\n")) - (insert ")") - (write-region (point-min) (point-max) ecomplete-database-file nil 'silent))) + (let ((coding-system-for-write ecomplete-database-file-coding-system)) + (insert "(") + (loop for (type . elems) in ecomplete-database + do + (insert (format "(%s\n" type)) + (dolist (entry elems) + (prin1 entry (current-buffer)) + (insert "\n")) + (insert ")\n")) + (insert ")") + (write-region (point-min) (point-max) + ecomplete-database-file nil 'silent)))) (defun ecomplete-get-matches (type match) (let* ((elems (cdr (assq type ecomplete-database))) @@ -101,21 +110,22 @@ (let* ((matches (ecomplete-get-matches type word)) (line 0) (max-lines (when matches (- (length (split-string matches "\n")) 2))) + (message-log-max nil) command highlight) (if (not matches) (progn (message "No ecomplete matches") nil) - (setq highlight (ecomplete-highlight-match-line matches line)) (if (not choose) (progn - (message highlight) + (message matches) nil) + (setq highlight (ecomplete-highlight-match-line matches line)) (while (not (memq (setq command (read-event highlight)) '(? return))) (cond - ((eq command (aref (kbd "M-n") 0)) + ((eq command ?\M-n) (setq line (min (1+ line) max-lines))) - ((eq command (aref (kbd "M-p") 0)) + ((eq command ?\M-p) (setq line (max (1- line) 0)))) (setq highlight (ecomplete-highlight-match-line matches line))) (when (eq command 'return)