erc-commit
[Top][All Lists]
Advanced

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

[Erc-commit] [commit][master] erc-unmorse: Deal with the morse style tha


From: mwolson
Subject: [Erc-commit] [commit][master] erc-unmorse: Deal with the morse style that has "/ " at end of every letter.
Date: Fri, 18 Jan 2008 23:50:05 -0500

commit 2c14ed8d5a83a45b7626f5e75eef9f4e07d0f1d6
Author: Michael W. Olson <address@hidden>
Date:   Fri Jan 18 23:40:12 2008 -0500

    erc-unmorse: Deal with the morse style that has "/ " at end of every letter.

diff --git a/ChangeLog b/ChangeLog
index 1ffc02f..6eebb17 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-01-19  Michael Olson  <address@hidden>
 
+       * erc-goodies.el (erc-unmorse): Improve regexp for detecting
+       morse.  Deal with the morse style that has "/ " at the end of
+       every letter.
+
        * erc.el (erc-format-network, erc-format-target-and/or-network):
        Use erc-network-name function instead, and check to see whether
        that function is bound.  This fixes an error in process filter for
diff --git a/erc-goodies.el b/erc-goodies.el
index 9612b00..4beedc4 100644
--- a/erc-goodies.el
+++ b/erc-goodies.el
@@ -496,8 +496,19 @@ channel that has weird people talking in morse to each 
other.
 
 See also `unmorse-region'."
   (goto-char (point-min))
-  (when (re-search-forward "[.-]+\\([.-]+[/ ]\\)+[.-]+" nil t)
-    (unmorse-region (match-beginning 0) (match-end 0))))
+  (when (re-search-forward "[.-]+\\([.-]*/? *\\)+[.-]+/?" nil t)
+    (save-restriction
+      (narrow-to-region (match-beginning 0) (match-end 0))
+      ;; Turn " / " into "  "
+      (goto-char (point-min))
+      (while (re-search-forward " / " nil t)
+        (replace-match "  "))
+      ;; Turn "/ " into "/"
+      (goto-char (point-min))
+      (while (re-search-forward "/ " nil t)
+        (replace-match "/"))
+      ;; Unmorse region
+      (unmorse-region (point-min) (point-max)))))
 
 ;;; erc-occur
 (defun erc-occur (string &optional proc)




reply via email to

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