diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-04-26 10:50:09 -0300 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-04-26 10:50:09 -0300 |
commit | d4aa710a1577e9d00f0ed2afdcfc799719d614a0 (patch) | |
tree | b8a18ed0bcd48a2aa82d8c186606c19bed102cf0 /lisp/erc | |
parent | 6a7a1b0b746d9e07f98183a0abb1298464dd1f29 (diff) | |
download | emacs-d4aa710a1577e9d00f0ed2afdcfc799719d614a0.tar.gz |
Make ERC use completion-at-point
* lisp/erc/erc.el (erc-mode-map): Use completion-at-point.
(erc-mode): Tell completion-at-point to obey erc-complete-functions.
(erc-complete-word-at-point): New function.
(erc-complete-word): Make it obsolete.
* lisp/erc/erc-pcomplete.el (erc-pcompletions-at-point): New function.
(pcomplete): Use it.
* lisp/erc/erc-dcc.el (erc-dcc-chat-mode-map): Use completion-at-point.
(erc-dcc-chat-mode): Tell completion-at-point to obey
erc-complete-functions.
* lisp/erc/erc-button.el (erc-button-next-function): New function extracted from
erc-button-next.
(button, erc-button-next): Use it.
Diffstat (limited to 'lisp/erc')
-rw-r--r-- | lisp/erc/ChangeLog | 15 | ||||
-rw-r--r-- | lisp/erc/erc-button.el | 35 | ||||
-rw-r--r-- | lisp/erc/erc-dcc.el | 5 | ||||
-rw-r--r-- | lisp/erc/erc-pcomplete.el | 10 | ||||
-rw-r--r-- | lisp/erc/erc.el | 14 |
5 files changed, 53 insertions, 26 deletions
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog index 6ff50756f1b..b5b36693dd2 100644 --- a/lisp/erc/ChangeLog +++ b/lisp/erc/ChangeLog @@ -1,3 +1,18 @@ +2011-04-26 Stefan Monnier <monnier@iro.umontreal.ca> + + * erc.el (erc-mode-map): Use completion-at-point. + (erc-mode): Tell completion-at-point to obey erc-complete-functions. + (erc-complete-word-at-point): New function. + (erc-complete-word): Make it obsolete. + * erc-pcomplete.el (erc-pcompletions-at-point): New function. + (pcomplete): Use it. + * erc-dcc.el (erc-dcc-chat-mode-map): Use completion-at-point. + (erc-dcc-chat-mode): Tell completion-at-point to obey + erc-complete-functions. + * erc-button.el (erc-button-next-function): New function extracted from + erc-button-next. + (button, erc-button-next): Use it. + 2011-03-07 Chong Yidong <cyd@stupidchicken.com> * Version 23.3 released. diff --git a/lisp/erc/erc-button.el b/lisp/erc/erc-button.el index 0b11c3bee2d..3a897347dea 100644 --- a/lisp/erc/erc-button.el +++ b/lisp/erc/erc-button.el @@ -53,11 +53,11 @@ "This mode buttonizes all messages according to `erc-button-alist'." ((add-hook 'erc-insert-modify-hook 'erc-button-add-buttons 'append) (add-hook 'erc-send-modify-hook 'erc-button-add-buttons 'append) - (add-hook 'erc-complete-functions 'erc-button-next) + (add-hook 'erc-complete-functions 'erc-button-next-function) (add-hook 'erc-mode-hook 'erc-button-setup)) ((remove-hook 'erc-insert-modify-hook 'erc-button-add-buttons) (remove-hook 'erc-send-modify-hook 'erc-button-add-buttons) - (remove-hook 'erc-complete-functions 'erc-button-next) + (remove-hook 'erc-complete-functions 'erc-button-next-function) (remove-hook 'erc-mode-hook 'erc-button-setup) (when (featurep 'xemacs) (dolist (buffer (erc-buffer-list)) @@ -427,21 +427,28 @@ call it with the value of the `erc-data' text property." (error "Function %S is not bound" fun)) (apply fun data))) +(defun erc-button-next-function () + "Pseudo completion function that actually jumps to the next button. +For use on `completion-at-point-functions'." + (let ((here (point))) + (when (< here (erc-beg-of-input-line)) + (lambda () + (while (and (get-text-property here 'erc-callback) + (not (= here (point-max)))) + (setq here (1+ here))) + (while (and (not (get-text-property here 'erc-callback)) + (not (= here (point-max)))) + (setq here (1+ here))) + (if (< here (point-max)) + (goto-char here) + (error "No next button")) + t)))) + (defun erc-button-next () "Go to the next button in this buffer." (interactive) - (let ((here (point))) - (when (< here (erc-beg-of-input-line)) - (while (and (get-text-property here 'erc-callback) - (not (= here (point-max)))) - (setq here (1+ here))) - (while (and (not (get-text-property here 'erc-callback)) - (not (= here (point-max)))) - (setq here (1+ here))) - (if (< here (point-max)) - (goto-char here) - (error "No next button")) - t))) + (let ((f (erc-button-next-function))) + (if f (funcall f)))) (defun erc-button-previous () "Go to the previous button in this buffer." diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index 88f0fe605f8..19e1801e03c 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -1094,7 +1094,7 @@ Possible values are: ask, auto, ignore." (defvar erc-dcc-chat-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "RET") 'erc-send-current-line) - (define-key map "\t" 'erc-complete-word) + (define-key map "\t" 'completion-at-point) map) "Keymap for `erc-dcc-mode'.") @@ -1102,7 +1102,8 @@ Possible values are: ask, auto, ignore." "Major mode for wasting time via DCC chat." (setq mode-line-process '(":%s") erc-send-input-line-function 'erc-dcc-chat-send-input-line - erc-default-recipients '(dcc))) + erc-default-recipients '(dcc)) + (add-hook 'completion-at-point-functions 'erc-complete-word-at-point nil t)) (defun erc-dcc-chat-send-input-line (recipient line &optional force) "Send LINE to the remote end. diff --git a/lisp/erc/erc-pcomplete.el b/lisp/erc/erc-pcomplete.el index 355770c5dcc..48c260c19fc 100644 --- a/lisp/erc/erc-pcomplete.el +++ b/lisp/erc/erc-pcomplete.el @@ -64,10 +64,16 @@ the most recent speakers are listed first." (define-erc-module pcomplete Completion "In ERC Completion mode, the TAB key does completion whenever possible." ((add-hook 'erc-mode-hook 'pcomplete-erc-setup) - (add-hook 'erc-complete-functions 'erc-pcomplete) + (add-hook 'erc-complete-functions 'erc-pcompletions-at-point) (erc-buffer-list #'pcomplete-erc-setup)) ((remove-hook 'erc-mode-hook 'pcomplete-erc-setup) - (remove-hook 'erc-complete-functions 'erc-pcomplete))) + (remove-hook 'erc-complete-functions 'erc-pcompletions-at-point))) + +(defun erc-pcompletions-at-point () + "ERC completion data from pcomplete. +for use on `completion-at-point-function'." + (when (> (point) (erc-beg-of-input-line)) + (pcomplete-completions-at-point))) (defun erc-pcomplete () "Complete the nick before point." diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 110ee8d1c3f..e2228a43303 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1110,7 +1110,7 @@ which the local user typed." (define-key map "\C-c\C-u" 'erc-kill-input) (define-key map "\C-c\C-x" 'erc-quit-server) (define-key map "\M-\t" 'ispell-complete-word) - (define-key map "\t" 'erc-complete-word) + (define-key map "\t" 'completion-at-point) ;; Suppress `font-lock-fontify-block' key binding since it ;; destroys face properties. @@ -1447,7 +1447,8 @@ Defaults to the server buffer." (set (make-local-variable 'paragraph-separate) (concat "\C-l\\|\\(^" (regexp-quote (erc-prompt)) "\\)")) (set (make-local-variable 'paragraph-start) - (concat "\\(" (regexp-quote (erc-prompt)) "\\)"))) + (concat "\\(" (regexp-quote (erc-prompt)) "\\)")) + (add-hook 'completion-at-point-functions 'erc-complete-word-at-point nil t)) ;; activation @@ -3803,13 +3804,10 @@ This places `point' just after the prompt, or at the beginning of the line." (setq erc-input-ring-index nil)) (kill-line))) -(defun erc-complete-word () - "Complete the word before point. +(defun erc-complete-word-at-point () + (run-hook-with-args-until-success 'erc-complete-functions)) -This function uses `erc-complete-functions'." - (interactive) - (unless (run-hook-with-args-until-success 'erc-complete-functions) - (beep))) +(define-obsolete-function-alias 'erc-complete-word 'completion-at-point "24.1") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; |