erc-commit
[Top][All Lists]
Advanced

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

[Erc-commit] [commit][emacs22] Deal with IRC names that could be regexps


From: mwolson
Subject: [Erc-commit] [commit][emacs22] Deal with IRC names that could be regexps in /ignore, /unignore.
Date: Sun, 14 Oct 2007 00:48:29 -0400

commit 8b170bebf35cf2cca3331d068670528f0e7831fa
Author: Michael Olson <address@hidden>
Date:   Mon Sep 11 01:48:19 2006 +0000

    Deal with IRC names that could be regexps in /ignore, /unignore.
    
    2006-09-10  Eric Hanchrow  <address@hidden>
    
        * erc.el (erc-cmd-IGNORE): Prompt user if this might be a regexp
        instead of a single user.
    
    2006-09-10  Michael Olson  <address@hidden>
    
        * erc.el (erc-member-ignore-case): Coding style tweak.
        (erc-cmd-UNIGNORE): Quote the user before comparison.  If we don't
        find the user listed verbatim, try to match them against the list
        using string-match.  In this case, prompt as to whether the regexp
        should be removed.
        (erc-ignored-user-p): Remove CL-ism.
    git-archimport-id: address@hidden/erc--main--0--patch-51

diff --git a/CREDITS b/CREDITS
index 9e8e910..d50680e 100644
--- a/CREDITS
+++ b/CREDITS
@@ -134,6 +134,10 @@ Aravind Gottipati <address@hidden>:
 Mark Plaksin (happy AT mcplaksin DOT org):
   * Made a last-keystroke method for erc-autoaway.el.
 
+Eric Hanchrow <address@hidden>:
+  * Implemented check of /ignore argument to see whether it was a
+    regexp or a normal string (4 lines changed).
+
 ----
 
 P.S.: Many people contributed small bits to ERC whose names I probably
diff --git a/ChangeLog b/ChangeLog
index 2f878e4..da17a54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,20 @@
+2006-09-10  Eric Hanchrow  <address@hidden>
+
+       * erc.el (erc-cmd-IGNORE): Prompt user if this might be a regexp
+       instead of a single user.
+
 2006-09-10  Michael Olson  <address@hidden>
 
        * erc.el (erc-generate-new-buffer-name): If this is a server
        buffer and a process exists already, create a new buffer.
        (erc-open): If the IRC session was continued, restore the old
        point.  Thanks to Stephan Stahl for the report.
+       (erc-member-ignore-case): Coding style tweak.
+       (erc-cmd-UNIGNORE): Quote the user before comparison.  If we don't
+       find the user listed verbatim, try to match them against the list
+       using string-match.  In this case, prompt as to whether the regexp
+       should be removed.
+       (erc-ignored-user-p): Remove CL-ism.
 
        * erc-autoaway.el (erc-autoaway-possibly-set-away): Check to see
        whether we are already away.
diff --git a/erc.el b/erc.el
index ff0a128..bfafba3 100644
--- a/erc.el
+++ b/erc.el
@@ -1571,7 +1571,8 @@ All strings are compared according to IRC protocol case 
rules, see
   (catch 'result
     (while list
       (if (string= string (erc-downcase (car list)))
-         (throw 'result list) (setq list (cdr list))))))
+         (throw 'result list)
+       (setq list (cdr list))))))
 
 (defmacro erc-with-buffer (spec &rest body)
   "Execute BODY in the buffer associated with SPEC.
@@ -2561,7 +2562,11 @@ therefore has to contain the command itself as well."
   "Ignore USER.  This should be a regexp matching address@hidden
 If no USER argument is specified, list the contents of `erc-ignore-list'."
   (if user
-      (progn
+      (let ((quoted (regexp-quote user)))
+       (when (and (not (string= user quoted))
+                  (y-or-n-p (format "Use regexp-quoted form (%s) instead? "
+                                    quoted)))
+         (setq user quoted))
        (erc-display-line
         (erc-make-notice (format "Now ignoring %s" user))
         'active)
@@ -2578,16 +2583,22 @@ If no USER argument is specified, list the contents of 
`erc-ignore-list'."
 (defun erc-cmd-UNIGNORE (user)
   "Remove the user specified in USER from the ignore list."
   (let ((ignored-nick (car (erc-with-server-buffer
-                            (erc-member-ignore-case user erc-ignore-list)))))
-    (if (null ignored-nick)
+                            (erc-member-ignore-case (regexp-quote user)
+                                                    erc-ignore-list)))))
+    (unless ignored-nick
+      (if (setq ignored-nick (erc-ignored-user-p user))
+         (unless (y-or-n-p (format "Remove this regexp (%s)? "
+                                   ignored-nick))
+           (setq ignored-nick nil))
        (erc-display-line
         (erc-make-notice (format "%s is not currently ignored!" user))
-        'active)
+        'active)))
+    (when ignored-nick
       (erc-display-line
        (erc-make-notice (format "No longer ignoring %s" user))
-       'active))
-    (erc-with-server-buffer
-      (setq erc-ignore-list (delete ignored-nick erc-ignore-list))))
+       'active)
+      (erc-with-server-buffer
+       (setq erc-ignore-list (delete ignored-nick erc-ignore-list)))))
   t)
 
 (defun erc-cmd-CLEAR ()
@@ -5091,10 +5102,10 @@ The previous default target of QUERY type gets removed"
 Takes a full SPEC of a user in the form \"address@hidden", and
 matches against all the regexp's in `erc-ignore-list'.  If any
 match, returns that regexp."
-  (dolist (ignored (erc-with-server-buffer erc-ignore-list))
-    (if (string-match ignored spec)
-       ;; We have `require'd cl, so we can return from the block named nil
-       (return ignored))))
+  (catch 'found
+    (dolist (ignored (erc-with-server-buffer erc-ignore-list))
+      (if (string-match ignored spec)
+         (throw 'found ignored)))))
 
 (defun erc-ignored-reply-p (msg tgt proc)
   ;; FIXME: this docstring needs fixing -- Lawrence 2004-01-08




reply via email to

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