emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r103712: Handle the case when re-sear


From: Leo Liu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103712: Handle the case when re-search-backward errs
Date: Tue, 22 Mar 2011 19:30:05 +0800
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103712
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Tue 2011-03-22 19:30:05 +0800
message:
  Handle the case when re-search-backward errs
  
  because point is not located after rcirc-prompt-end-marker.
modified:
  lisp/ChangeLog
  lisp/net/rcirc.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-03-22 00:30:23 +0000
+++ b/lisp/ChangeLog    2011-03-22 11:30:05 +0000
@@ -1,3 +1,10 @@
+2011-03-22  Leo Liu  <address@hidden>
+
+       * net/rcirc.el (rcirc-completion-at-point): Return nil if point is
+       located before rcirc-prompt-end-marker.
+       (rcirc-complete): Error if point is not after rcirc prompt.
+       Handle the case when table is nil.
+
 2011-03-22  Chong Yidong  <address@hidden>
 
        * custom.el (custom--inhibit-theme-enable): Make it affect only

=== modified file 'lisp/net/rcirc.el'
--- a/lisp/net/rcirc.el 2011-03-09 10:45:19 +0000
+++ b/lisp/net/rcirc.el 2011-03-22 11:30:05 +0000
@@ -828,18 +828,21 @@
 
 (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 @@
   "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 @@
          (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))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]