* 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.
+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.
"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))
(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."
(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'.")
"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.
(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."
(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.
(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
(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")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;