aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-04-26 10:50:09 -0300
committerStefan Monnier2011-04-26 10:50:09 -0300
commitd4aa710a1577e9d00f0ed2afdcfc799719d614a0 (patch)
treeb8a18ed0bcd48a2aa82d8c186606c19bed102cf0
parent6a7a1b0b746d9e07f98183a0abb1298464dd1f29 (diff)
downloademacs-d4aa710a1577e9d00f0ed2afdcfc799719d614a0.tar.gz
emacs-d4aa710a1577e9d00f0ed2afdcfc799719d614a0.zip
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.
-rw-r--r--lisp/erc/ChangeLog15
-rw-r--r--lisp/erc/erc-button.el35
-rw-r--r--lisp/erc/erc-dcc.el5
-rw-r--r--lisp/erc/erc-pcomplete.el10
-rw-r--r--lisp/erc/erc.el14
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 @@
12011-04-26 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * erc.el (erc-mode-map): Use completion-at-point.
4 (erc-mode): Tell completion-at-point to obey erc-complete-functions.
5 (erc-complete-word-at-point): New function.
6 (erc-complete-word): Make it obsolete.
7 * erc-pcomplete.el (erc-pcompletions-at-point): New function.
8 (pcomplete): Use it.
9 * erc-dcc.el (erc-dcc-chat-mode-map): Use completion-at-point.
10 (erc-dcc-chat-mode): Tell completion-at-point to obey
11 erc-complete-functions.
12 * erc-button.el (erc-button-next-function): New function extracted from
13 erc-button-next.
14 (button, erc-button-next): Use it.
15
12011-03-07 Chong Yidong <cyd@stupidchicken.com> 162011-03-07 Chong Yidong <cyd@stupidchicken.com>
2 17
3 * Version 23.3 released. 18 * 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 @@
53 "This mode buttonizes all messages according to `erc-button-alist'." 53 "This mode buttonizes all messages according to `erc-button-alist'."
54 ((add-hook 'erc-insert-modify-hook 'erc-button-add-buttons 'append) 54 ((add-hook 'erc-insert-modify-hook 'erc-button-add-buttons 'append)
55 (add-hook 'erc-send-modify-hook 'erc-button-add-buttons 'append) 55 (add-hook 'erc-send-modify-hook 'erc-button-add-buttons 'append)
56 (add-hook 'erc-complete-functions 'erc-button-next) 56 (add-hook 'erc-complete-functions 'erc-button-next-function)
57 (add-hook 'erc-mode-hook 'erc-button-setup)) 57 (add-hook 'erc-mode-hook 'erc-button-setup))
58 ((remove-hook 'erc-insert-modify-hook 'erc-button-add-buttons) 58 ((remove-hook 'erc-insert-modify-hook 'erc-button-add-buttons)
59 (remove-hook 'erc-send-modify-hook 'erc-button-add-buttons) 59 (remove-hook 'erc-send-modify-hook 'erc-button-add-buttons)
60 (remove-hook 'erc-complete-functions 'erc-button-next) 60 (remove-hook 'erc-complete-functions 'erc-button-next-function)
61 (remove-hook 'erc-mode-hook 'erc-button-setup) 61 (remove-hook 'erc-mode-hook 'erc-button-setup)
62 (when (featurep 'xemacs) 62 (when (featurep 'xemacs)
63 (dolist (buffer (erc-buffer-list)) 63 (dolist (buffer (erc-buffer-list))
@@ -427,21 +427,28 @@ call it with the value of the `erc-data' text property."
427 (error "Function %S is not bound" fun)) 427 (error "Function %S is not bound" fun))
428 (apply fun data))) 428 (apply fun data)))
429 429
430(defun erc-button-next-function ()
431 "Pseudo completion function that actually jumps to the next button.
432For use on `completion-at-point-functions'."
433 (let ((here (point)))
434 (when (< here (erc-beg-of-input-line))
435 (lambda ()
436 (while (and (get-text-property here 'erc-callback)
437 (not (= here (point-max))))
438 (setq here (1+ here)))
439 (while (and (not (get-text-property here 'erc-callback))
440 (not (= here (point-max))))
441 (setq here (1+ here)))
442 (if (< here (point-max))
443 (goto-char here)
444 (error "No next button"))
445 t))))
446
430(defun erc-button-next () 447(defun erc-button-next ()
431 "Go to the next button in this buffer." 448 "Go to the next button in this buffer."
432 (interactive) 449 (interactive)
433 (let ((here (point))) 450 (let ((f (erc-button-next-function)))
434 (when (< here (erc-beg-of-input-line)) 451 (if f (funcall f))))
435 (while (and (get-text-property here 'erc-callback)
436 (not (= here (point-max))))
437 (setq here (1+ here)))
438 (while (and (not (get-text-property here 'erc-callback))
439 (not (= here (point-max))))
440 (setq here (1+ here)))
441 (if (< here (point-max))
442 (goto-char here)
443 (error "No next button"))
444 t)))
445 452
446(defun erc-button-previous () 453(defun erc-button-previous ()
447 "Go to the previous button in this buffer." 454 "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."
1094(defvar erc-dcc-chat-mode-map 1094(defvar erc-dcc-chat-mode-map
1095 (let ((map (make-sparse-keymap))) 1095 (let ((map (make-sparse-keymap)))
1096 (define-key map (kbd "RET") 'erc-send-current-line) 1096 (define-key map (kbd "RET") 'erc-send-current-line)
1097 (define-key map "\t" 'erc-complete-word) 1097 (define-key map "\t" 'completion-at-point)
1098 map) 1098 map)
1099 "Keymap for `erc-dcc-mode'.") 1099 "Keymap for `erc-dcc-mode'.")
1100 1100
@@ -1102,7 +1102,8 @@ Possible values are: ask, auto, ignore."
1102 "Major mode for wasting time via DCC chat." 1102 "Major mode for wasting time via DCC chat."
1103 (setq mode-line-process '(":%s") 1103 (setq mode-line-process '(":%s")
1104 erc-send-input-line-function 'erc-dcc-chat-send-input-line 1104 erc-send-input-line-function 'erc-dcc-chat-send-input-line
1105 erc-default-recipients '(dcc))) 1105 erc-default-recipients '(dcc))
1106 (add-hook 'completion-at-point-functions 'erc-complete-word-at-point nil t))
1106 1107
1107(defun erc-dcc-chat-send-input-line (recipient line &optional force) 1108(defun erc-dcc-chat-send-input-line (recipient line &optional force)
1108 "Send LINE to the remote end. 1109 "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."
64(define-erc-module pcomplete Completion 64(define-erc-module pcomplete Completion
65 "In ERC Completion mode, the TAB key does completion whenever possible." 65 "In ERC Completion mode, the TAB key does completion whenever possible."
66 ((add-hook 'erc-mode-hook 'pcomplete-erc-setup) 66 ((add-hook 'erc-mode-hook 'pcomplete-erc-setup)
67 (add-hook 'erc-complete-functions 'erc-pcomplete) 67 (add-hook 'erc-complete-functions 'erc-pcompletions-at-point)
68 (erc-buffer-list #'pcomplete-erc-setup)) 68 (erc-buffer-list #'pcomplete-erc-setup))
69 ((remove-hook 'erc-mode-hook 'pcomplete-erc-setup) 69 ((remove-hook 'erc-mode-hook 'pcomplete-erc-setup)
70 (remove-hook 'erc-complete-functions 'erc-pcomplete))) 70 (remove-hook 'erc-complete-functions 'erc-pcompletions-at-point)))
71
72(defun erc-pcompletions-at-point ()
73 "ERC completion data from pcomplete.
74for use on `completion-at-point-function'."
75 (when (> (point) (erc-beg-of-input-line))
76 (pcomplete-completions-at-point)))
71 77
72(defun erc-pcomplete () 78(defun erc-pcomplete ()
73 "Complete the nick before point." 79 "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."
1110 (define-key map "\C-c\C-u" 'erc-kill-input) 1110 (define-key map "\C-c\C-u" 'erc-kill-input)
1111 (define-key map "\C-c\C-x" 'erc-quit-server) 1111 (define-key map "\C-c\C-x" 'erc-quit-server)
1112 (define-key map "\M-\t" 'ispell-complete-word) 1112 (define-key map "\M-\t" 'ispell-complete-word)
1113 (define-key map "\t" 'erc-complete-word) 1113 (define-key map "\t" 'completion-at-point)
1114 1114
1115 ;; Suppress `font-lock-fontify-block' key binding since it 1115 ;; Suppress `font-lock-fontify-block' key binding since it
1116 ;; destroys face properties. 1116 ;; destroys face properties.
@@ -1447,7 +1447,8 @@ Defaults to the server buffer."
1447 (set (make-local-variable 'paragraph-separate) 1447 (set (make-local-variable 'paragraph-separate)
1448 (concat "\C-l\\|\\(^" (regexp-quote (erc-prompt)) "\\)")) 1448 (concat "\C-l\\|\\(^" (regexp-quote (erc-prompt)) "\\)"))
1449 (set (make-local-variable 'paragraph-start) 1449 (set (make-local-variable 'paragraph-start)
1450 (concat "\\(" (regexp-quote (erc-prompt)) "\\)"))) 1450 (concat "\\(" (regexp-quote (erc-prompt)) "\\)"))
1451 (add-hook 'completion-at-point-functions 'erc-complete-word-at-point nil t))
1451 1452
1452;; activation 1453;; activation
1453 1454
@@ -3803,13 +3804,10 @@ This places `point' just after the prompt, or at the beginning of the line."
3803 (setq erc-input-ring-index nil)) 3804 (setq erc-input-ring-index nil))
3804 (kill-line))) 3805 (kill-line)))
3805 3806
3806(defun erc-complete-word () 3807(defun erc-complete-word-at-point ()
3807 "Complete the word before point. 3808 (run-hook-with-args-until-success 'erc-complete-functions))
3808 3809
3809This function uses `erc-complete-functions'." 3810(define-obsolete-function-alias 'erc-complete-word 'completion-at-point "24.1")
3810 (interactive)
3811 (unless (run-hook-with-args-until-success 'erc-complete-functions)
3812 (beep)))
3813 3811
3814;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3812;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3815;; 3813;;