summaryrefslogtreecommitdiff
path: root/lisp/net/rcirc.el
diff options
context:
space:
mode:
authorLeo Liu <sdl.web@gmail.com>2011-03-22 19:30:05 +0800
committerLeo Liu <sdl.web@gmail.com>2011-03-22 19:30:05 +0800
commit0b4e93f177fc551b8ef523ab13da7842273abad2 (patch)
tree04dcef077a4ce7e1f9ff79946190fdf0a4cb165c /lisp/net/rcirc.el
parent90346de2b2ad3e071a7f0c3bf0c7a6e7bb5b0ac0 (diff)
downloademacs-0b4e93f177fc551b8ef523ab13da7842273abad2.tar.gz
emacs-0b4e93f177fc551b8ef523ab13da7842273abad2.tar.bz2
emacs-0b4e93f177fc551b8ef523ab13da7842273abad2.zip
Handle the case when re-search-backward errs
because point is not located after rcirc-prompt-end-marker.
Diffstat (limited to 'lisp/net/rcirc.el')
-rw-r--r--lisp/net/rcirc.el36
1 files changed, 21 insertions, 15 deletions
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 71aa0dd22bc..999a6968012 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -828,18 +828,21 @@ The list is updated automatically by `defun-rcirc-command'.")
(defun rcirc-completion-at-point ()
"Function used for `completion-at-point-functions' in `rcirc-mode'."
- (let* ((beg (save-excursion
- (if (re-search-backward " " rcirc-prompt-end-marker t)
- (1+ (point))
- rcirc-prompt-end-marker)))
- (table (if (and (= beg rcirc-prompt-end-marker)
- (eq (char-after beg) ?/))
- (delete-dups
- (nconc
- (sort (copy-sequence rcirc-client-commands) 'string-lessp)
- (sort (copy-sequence rcirc-server-commands) 'string-lessp)))
- (rcirc-channel-nicks (rcirc-buffer-process) rcirc-target))))
- (list beg (point) table)))
+ (and (rcirc-looking-at-input)
+ (let* ((beg (save-excursion
+ (if (re-search-backward " " rcirc-prompt-end-marker t)
+ (1+ (point))
+ rcirc-prompt-end-marker)))
+ (table (if (and (= beg rcirc-prompt-end-marker)
+ (eq (char-after beg) ?/))
+ (delete-dups
+ (nconc (sort (copy-sequence rcirc-client-commands)
+ 'string-lessp)
+ (sort (copy-sequence rcirc-server-commands)
+ 'string-lessp)))
+ (rcirc-channel-nicks (rcirc-buffer-process)
+ rcirc-target))))
+ (list beg (point) table))))
(defvar rcirc-completions nil)
(defvar rcirc-completion-start nil)
@@ -848,6 +851,8 @@ The list is updated automatically by `defun-rcirc-command'.")
"Cycle through completions from list of nicks in channel or IRC commands.
IRC command completion is performed only if '/' is the first input char."
(interactive)
+ (unless (rcirc-looking-at-input)
+ (error "Point not located after rcirc prompt"))
(if (eq last-command this-command)
(setq rcirc-completions
(append (cdr rcirc-completions) (list (car rcirc-completions))))
@@ -855,9 +860,10 @@ IRC command completion is performed only if '/' is the first input char."
(table (rcirc-completion-at-point)))
(setq rcirc-completion-start (car table))
(setq rcirc-completions
- (all-completions (buffer-substring rcirc-completion-start
- (cadr table))
- (nth 2 table)))))
+ (and rcirc-completion-start
+ (all-completions (buffer-substring rcirc-completion-start
+ (cadr table))
+ (nth 2 table))))))
(let ((completion (car rcirc-completions)))
(when completion
(delete-region rcirc-completion-start (point))