root/lang/elisp/anything-c-erc/trunk/anything-c-erc.el @ 28807

Revision 28807, 2.9 kB (checked in by imakado, 6 years ago)

nicknameの補完コマンドを追加.@から始まる文字も対象に含めた

Line 
1;;;  -*- coding: utf-8; mode: emacs-lisp; -*-
2;;; anything-c-erc.el --- anything sources for erc.el
3
4;; Author: IMAKADO <ken.imakado@gmail.com>
5;; blog: http://d.hatena.ne.jp/IMAKADO (japanese)
6;; Prefix: anything-c-erc-
7
8;; This file is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation; either version 2, or (at your option)
11;; any later version.
12
13;; This file is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with GNU Emacs; see the file COPYING.  If not, write to the
20;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21;; Boston, MA 02110-1301, USA.
22
23;;; Commentary:
24
25;; Source:
26;; `anything-c-source-erc-iswitchb'
27
28;; Commands:
29;; to call anything with `anything-c-erc-sources'
30;; M-x anything-c-erc
31
32;; to complete Nick name
33;; M-x anything-c-erc-complete-nick
34
35(require 'anything)
36(require 'erc)
37
38
39;;; Advice
40
41(defvar anything-c-erc-nicks nil
42  "list of nicknames. each nickname can be started with \"@\"")
43(make-variable-buffer-local 'anything-c-erc-nicks)
44
45(defadvice erc-channel-receive-names (before anything-c-erc-nick-inc-@ activate)
46  (anything-c-erc-receive-names (ad-get-arg 0)))
47
48(defun anything-c-erc-receive-names (names)
49  (ignore-errors
50    (loop for s in (split-string names)
51          when (and (stringp s)
52                    (not (string-equal "" s)))
53          do (add-to-list 'anything-c-erc-nicks s))))
54
55;;; Sources
56(defvar anything-c-source-erc-iswitchb
57  '((name . "Erc Buffers")
58    (init . (lambda ()
59              (with-current-buffer (anything-candidate-buffer 'global)
60                (let ((los (mapcar 'buffer-name (erc-buffer-list))))
61                  (insert (mapconcat 'identity los "\n"))))))
62    (candidates-in-buffer)
63    (type . buffer)
64    (persistent-action . switch-to-buffer)))
65
66
67(defvar anything-c-source-erc-nicks
68  '((name . "Erc Nicknames")
69    (init . (lambda ()
70              (let ((los (or anything-c-erc-nicks
71                             (pcomplete-erc-nicks))))
72                (with-current-buffer (anything-candidate-buffer 'global)
73                  (insert (mapconcat 'identity los "\n"))))))
74    (candidates-in-buffer)
75    (action . (("Insert" . (lambda (name)
76                             (insert name erc-pcomplete-nick-postfix)))))
77    (persistent-action . switch-to-buffer)))
78
79(defvar anything-c-erc-sources
80  '(anything-c-source-erc-iswitchb
81    anything-c-source-erc-nicks))
82
83;;; Commands
84(defun anything-c-erc ()
85  (interactive)
86  (anything anything-c-erc-sources))
87
88(defun anything-c-erc-complete-nick ()
89  (interactive)
90  (anything '(anything-c-source-erc-nicks)))
91
92(provide 'anything-c-erc)
93;;; anything-c-erc.el ends here
Note: See TracBrowser for help on using the browser.