diff options
| author | Stefan Monnier | 2011-04-20 14:18:34 -0300 |
|---|---|---|
| committer | Stefan Monnier | 2011-04-20 14:18:34 -0300 |
| commit | bed7f14004246c8ade77a48f79f0cc48f2ca74f7 (patch) | |
| tree | 0714be284c1fc3d9452233131597fa3a9a7730da /lisp/erc | |
| parent | b2e59ad27f0e26709d0e89c13d4b58d9b5033851 (diff) | |
| download | emacs-bed7f14004246c8ade77a48f79f0cc48f2ca74f7.tar.gz emacs-bed7f14004246c8ade77a48f79f0cc48f2ca74f7.zip | |
* lisp/obsolete/erc-hecomplete.el: Make obsolete.
* obsolete/: Standardize obsolescence info in the header.
Diffstat (limited to 'lisp/erc')
| -rw-r--r-- | lisp/erc/erc-hecomplete.el | 222 |
1 files changed, 0 insertions, 222 deletions
diff --git a/lisp/erc/erc-hecomplete.el b/lisp/erc/erc-hecomplete.el deleted file mode 100644 index 530c586d24f..00000000000 --- a/lisp/erc/erc-hecomplete.el +++ /dev/null | |||
| @@ -1,222 +0,0 @@ | |||
| 1 | ;;; erc-hecomplete.el --- Provides Nick name completion for ERC | ||
| 2 | |||
| 3 | ;; Copyright (C) 2001-2002, 2004, 2006-2011 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Alex Schroeder <alex@gnu.org> | ||
| 6 | ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcCompletion | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; This file is considered obsolete. It is recommended to use | ||
| 26 | ;; completion from erc-pcomplete instead. | ||
| 27 | |||
| 28 | ;; This file is based on hippie-expand, while the new file is based on | ||
| 29 | ;; pcomplete. | ||
| 30 | |||
| 31 | ;;; Code: | ||
| 32 | |||
| 33 | (require 'erc) | ||
| 34 | (require 'erc-match); for erc-pals | ||
| 35 | (require 'hippie-exp); for the hippie expand stuff | ||
| 36 | |||
| 37 | ;;;###autoload (autoload 'erc-hecomplete-mode "erc-hecomplete" nil t) | ||
| 38 | (define-erc-module hecomplete nil | ||
| 39 | "Complete nick at point." | ||
| 40 | ((add-hook 'erc-complete-functions 'erc-hecomplete)) | ||
| 41 | ((remove-hook 'erc-complete-functions 'erc-hecomplete))) | ||
| 42 | |||
| 43 | (defun erc-hecomplete () | ||
| 44 | "Complete nick at point. | ||
| 45 | See `erc-try-complete-nick' for more technical info. | ||
| 46 | This function is obsolete, use `erc-pcomplete' instead." | ||
| 47 | (interactive) | ||
| 48 | (let ((hippie-expand-try-functions-list '(erc-try-complete-nick))) | ||
| 49 | (hippie-expand nil))) | ||
| 50 | |||
| 51 | (defgroup erc-hecomplete nil | ||
| 52 | "Nick completion. It is recommended to use erc-pcomplete instead." | ||
| 53 | :group 'erc) | ||
| 54 | |||
| 55 | (defcustom erc-nick-completion 'all | ||
| 56 | "Determine how the list of nicks is determined during nick completion. | ||
| 57 | See `erc-complete-nick' for information on how to activate this. | ||
| 58 | |||
| 59 | pals: Use `erc-pals'. | ||
| 60 | all: All channel members. | ||
| 61 | |||
| 62 | You may also provide your own function that returns a list of completions. | ||
| 63 | One example is `erc-nick-completion-exclude-myself', | ||
| 64 | or you may use an arbitrary lisp expression." | ||
| 65 | :type '(choice (const :tag "List of pals" pals) | ||
| 66 | (const :tag "All channel members" all) | ||
| 67 | (const :tag "All channel members except yourself" | ||
| 68 | erc-nick-completion-exclude-myself) | ||
| 69 | (repeat :tag "List" (string :tag "Nick")) | ||
| 70 | function | ||
| 71 | sexp) | ||
| 72 | :group 'erc-hecomplete) | ||
| 73 | |||
| 74 | (defcustom erc-nick-completion-ignore-case t | ||
| 75 | "*Non-nil means don't consider case significant in nick completion. | ||
| 76 | Case will be automatically corrected when non-nil. | ||
| 77 | For instance if you type \"dely TAB\" the word completes and changes to | ||
| 78 | \"delYsid\"." | ||
| 79 | :group 'erc-hecomplete | ||
| 80 | :type 'boolean) | ||
| 81 | |||
| 82 | (defun erc-nick-completion-exclude-myself () | ||
| 83 | "Get a list of all the channel members except you. | ||
| 84 | |||
| 85 | This function returns a list of all the members in the channel, except | ||
| 86 | your own nick. This way if you're named foo and someone is called foobar, | ||
| 87 | typing \"f o TAB\" will directly give you foobar. Use this with | ||
| 88 | `erc-nick-completion'." | ||
| 89 | (remove | ||
| 90 | (erc-current-nick) | ||
| 91 | (erc-get-channel-nickname-list))) | ||
| 92 | |||
| 93 | (defcustom erc-nick-completion-postfix ": " | ||
| 94 | "*When `erc-complete' is used in the first word after the prompt, | ||
| 95 | add this string when a unique expansion was found." | ||
| 96 | :group 'erc-hecomplete | ||
| 97 | :type 'string) | ||
| 98 | |||
| 99 | (defun erc-command-list () | ||
| 100 | "Returns a list of strings of the defined user commands." | ||
| 101 | (let ((case-fold-search nil)) | ||
| 102 | (mapcar (lambda (x) | ||
| 103 | (concat "/" (downcase (substring (symbol-name x) 8)))) | ||
| 104 | (apropos-internal "erc-cmd-[A-Z]+")))) | ||
| 105 | |||
| 106 | (defun erc-try-complete-nick (old) | ||
| 107 | "Complete nick at point. | ||
| 108 | This is a function to put on `hippie-expand-try-functions-list'. | ||
| 109 | Then use \\[hippie-expand] to expand nicks. | ||
| 110 | The type of completion depends on `erc-nick-completion'." | ||
| 111 | (cond ((eq erc-nick-completion 'pals) | ||
| 112 | (try-complete-erc-nick old erc-pals)) | ||
| 113 | ((eq erc-nick-completion 'all) | ||
| 114 | (try-complete-erc-nick old (append | ||
| 115 | (erc-get-channel-nickname-list) | ||
| 116 | (erc-command-list)))) | ||
| 117 | ((functionp erc-nick-completion) | ||
| 118 | (try-complete-erc-nick old (funcall erc-nick-completion))) | ||
| 119 | (t | ||
| 120 | (try-complete-erc-nick old erc-nick-completion)))) | ||
| 121 | |||
| 122 | (defvar try-complete-erc-nick-window-configuration nil | ||
| 123 | "The window configuration for `try-complete-erc-nick'. | ||
| 124 | When called the first time, a window config is stored here, | ||
| 125 | and when completion is done, the window config is restored | ||
| 126 | from here. See `try-complete-erc-nick-restore' and | ||
| 127 | `try-complete-erc-nick'.") | ||
| 128 | |||
| 129 | (defun try-complete-erc-nick-restore () | ||
| 130 | "Restore window configuration." | ||
| 131 | (if (not try-complete-erc-nick-window-configuration) | ||
| 132 | (when (get-buffer "*Completions*") | ||
| 133 | (delete-windows-on "*Completions*")) | ||
| 134 | (set-window-configuration | ||
| 135 | try-complete-erc-nick-window-configuration) | ||
| 136 | (setq try-complete-erc-nick-window-configuration nil))) | ||
| 137 | |||
| 138 | (defun try-complete-erc-nick (old completions) | ||
| 139 | "Try to complete current word depending on `erc-try-complete-nick'. | ||
| 140 | The argument OLD has to be nil the first call of this function, and t | ||
| 141 | for subsequent calls (for further possible completions of the same | ||
| 142 | string). It returns t if a new completion is found, nil otherwise. The | ||
| 143 | second argument COMPLETIONS is a list of completions to use. Actually, | ||
| 144 | it is only used when OLD is nil. It will be copied to `he-expand-list' | ||
| 145 | on the first call. After that, it is no longer used. | ||
| 146 | Window configurations are stored in | ||
| 147 | `try-complete-erc-nick-window-configuration'." | ||
| 148 | (let (expansion | ||
| 149 | final | ||
| 150 | (alist (if (consp (car completions)) | ||
| 151 | completions | ||
| 152 | (mapcar (lambda (s) | ||
| 153 | (if (and (erc-complete-at-prompt) | ||
| 154 | (and (not (= (length s) 0)) | ||
| 155 | (not (eq (elt s 0) ?/)))) | ||
| 156 | (list (concat s erc-nick-completion-postfix)) | ||
| 157 | (list (concat s " ")))) | ||
| 158 | completions))) ; make alist if required | ||
| 159 | (completion-ignore-case erc-nick-completion-ignore-case)) | ||
| 160 | (he-init-string (he-dabbrev-beg) (point)) | ||
| 161 | ;; If there is a string to complete, complete it using alist. | ||
| 162 | ;; expansion is the possible expansion, or t. If expansion is t | ||
| 163 | ;; or if expansion is the "real" thing, we are finished (final is | ||
| 164 | ;; t). Take care -- expansion can also be nil! | ||
| 165 | (unless (string= he-search-string "") | ||
| 166 | (setq expansion (try-completion he-search-string alist) | ||
| 167 | final (or (eq t expansion) | ||
| 168 | (and expansion | ||
| 169 | (eq t (try-completion expansion alist)))))) | ||
| 170 | (cond ((not expansion) | ||
| 171 | ;; There is no expansion at all. | ||
| 172 | (try-complete-erc-nick-restore) | ||
| 173 | (he-reset-string) | ||
| 174 | nil) | ||
| 175 | ((eq t expansion) | ||
| 176 | ;; The user already has the correct expansion. | ||
| 177 | (try-complete-erc-nick-restore) | ||
| 178 | (he-reset-string) | ||
| 179 | t) | ||
| 180 | ((and old (string= expansion he-search-string)) | ||
| 181 | ;; This is the second time around and nothing changed, | ||
| 182 | ;; ie. the user tried to expand something incomplete | ||
| 183 | ;; without making a choice -- hitting TAB twice, for | ||
| 184 | ;; example. | ||
| 185 | (try-complete-erc-nick-restore) | ||
| 186 | (he-reset-string) | ||
| 187 | nil) | ||
| 188 | (final | ||
| 189 | ;; The user has found the correct expansion. | ||
| 190 | (try-complete-erc-nick-restore) | ||
| 191 | (he-substitute-string expansion) | ||
| 192 | t) | ||
| 193 | (t | ||
| 194 | ;; We found something but we are not finished. Show a | ||
| 195 | ;; completions buffer. Substitute what we found and return | ||
| 196 | ;; t. | ||
| 197 | (setq try-complete-erc-nick-window-configuration | ||
| 198 | (current-window-configuration)) | ||
| 199 | (with-output-to-temp-buffer "*Completions*" | ||
| 200 | (display-completion-list (all-completions he-search-string alist))) | ||
| 201 | (he-substitute-string expansion) | ||
| 202 | t)))) | ||
| 203 | |||
| 204 | (defun erc-at-beginning-of-line-p (point &optional bol-func) | ||
| 205 | (save-excursion | ||
| 206 | (funcall (or bol-func | ||
| 207 | 'erc-bol)) | ||
| 208 | (equal point (point)))) | ||
| 209 | |||
| 210 | (defun erc-complete-at-prompt () | ||
| 211 | "Returns t if point is directly after `erc-prompt' when doing completion." | ||
| 212 | (erc-at-beginning-of-line-p (he-dabbrev-beg))) | ||
| 213 | |||
| 214 | (provide 'erc-hecomplete) | ||
| 215 | |||
| 216 | ;;; erc-hecomplete.el ends here | ||
| 217 | ;; | ||
| 218 | ;; Local Variables: | ||
| 219 | ;; indent-tabs-mode: t | ||
| 220 | ;; tab-width: 8 | ||
| 221 | ;; End: | ||
| 222 | |||