X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/9aecacd08a93bffb529cee59d74477890ce96f37..a878d0f2c1e1ffd144dbbb455e2bc7fe23845d26:/lisp/erc/erc-pcomplete.el diff --git a/lisp/erc/erc-pcomplete.el b/lisp/erc/erc-pcomplete.el index a5a1bbaaf9..d3cbe8a580 100644 --- a/lisp/erc/erc-pcomplete.el +++ b/lisp/erc/erc-pcomplete.el @@ -1,6 +1,6 @@ ;;; erc-pcomplete.el --- Provides programmable completion for ERC -;; Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +;; Copyright (C) 2002-2004, 2006-2012 Free Software Foundation, Inc. ;; Author: Sacha Chua ;; Keywords: comm, convenience @@ -8,10 +8,10 @@ ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,9 +19,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -50,8 +48,8 @@ "Programmable completion for ERC" :group 'erc) -(defcustom erc-pcomplete-nick-postfix ": " - "*When `pcomplete' is used in the first word after the prompt, +(defcustom erc-pcomplete-nick-postfix ":" + "When `pcomplete' is used in the first word after the prompt, add this string to nicks completed." :group 'erc-pcomplete :type 'string) @@ -66,10 +64,19 @@ 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)) + (or (let ((pcomplete-default-completion-function #'ignore)) + (pcomplete-completions-at-point)) + (let ((c (pcomplete-completions-at-point))) + (if c (nconc c '(:exclusive no))))))) (defun erc-pcomplete () "Complete the nick before point." @@ -89,10 +96,8 @@ the most recent speakers are listed first." t) (set (make-local-variable 'pcomplete-use-paring) nil) - (set (make-local-variable 'pcomplete-suffix-list) - '(? ?:)) (set (make-local-variable 'pcomplete-parse-arguments-function) - 'pcomplete-parse-erc-arguments) + 'pcomplete-erc-parse-arguments) (set (make-local-variable 'pcomplete-command-completion-function) 'pcomplete/erc-mode/complete-command) (set (make-local-variable 'pcomplete-command-name-function) @@ -252,7 +257,7 @@ If optional argument IGNORE-SELF is non-nil, don't return the current nick." (upcase (substring (pcomplete-arg 'first) 1)) "SAY")) -(defun pcomplete-parse-erc-arguments () +(defun pcomplete-erc-parse-arguments () "Returns a list of parsed whitespace-separated arguments. These are the words from the beginning of the line after the prompt up to where point is right now." @@ -281,4 +286,3 @@ up to where point is right now." ;; indent-tabs-mode: nil ;; End: -;; arch-tag: 32a7703b-be87-45a4-82f3-9eed5a628911