erbot-cvs
[Top][All Lists]
Advanced

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

[Erbot-cvs] erbot ChangeLog erbim.el


From: Vivek Dasmohapatra
Subject: [Erbot-cvs] erbot ChangeLog erbim.el
Date: Wed, 11 Apr 2007 11:59:27 +0000

CVSROOT:        /sources/erbot
Module name:    erbot
Changes by:     Vivek Dasmohapatra <fledermaus> 07/04/11 11:59:27

Modified files:
        .              : ChangeLog erbim.el 

Log message:
        tweaked unicode character description output, search for characters by 
description as well (with unicode-find)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/erbot/ChangeLog?cvsroot=erbot&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/erbot/erbim.el?cvsroot=erbot&r1=1.6&r2=1.7

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/erbot/erbot/ChangeLog,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- ChangeLog   28 Jan 2007 01:16:58 -0000      1.65
+++ ChangeLog   11 Apr 2007 11:59:27 -0000      1.66
@@ -1,3 +1,12 @@
+2007-04-11  Vivek Dasmohapatra  <address@hidden>
+
+       * erbim.el (fs-unicode-describe): add usage instructions 
+       (erbim-search-by-description): search for unicode characters by 
+       description.
+       (fs-unicode-find): bot-ui wrapper for erbim-search-by-description
+       including usage message.
+       (erbim-name-by-codepoint): changed output format to use #xXXX
+
 2007-01-28  Vivek Dasmohapatra  <address@hidden>
 
        * erbot.el (erbot-join-servers): `erc' takes :keyword style

Index: erbim.el
===================================================================
RCS file: /sources/erbot/erbot/erbim.el,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- erbim.el    10 Apr 2007 11:48:30 -0000      1.6
+++ erbim.el    11 Apr 2007 11:59:27 -0000      1.7
@@ -168,13 +168,45 @@
     (with-current-buffer unidata
       (goto-char (point-min))
       (if (re-search-forward (concat "^" cpstring ";\\([^;]*\\);") nil t)
-          (format "Codepoint %s: %s" cpstring (match-string 1))
-        (format "Unknown character number %s" cpstring) )) ))
+          (format "#x%s: %s" cpstring (match-string 1))
+        (format "Unknown character #x%s" cpstring) )) ))
+
+(defun erbim-search-by-description (pat)
+  (let ( (unidata (find-file-noselect erbim-unidata-file)) 
+         (pattern        nil)
+         (case-fold-search t)
+         (count            0)
+         (limit           10)
+         (found          nil)
+         (char           nil)
+         (cp             nil)
+         (matches        nil))
+    (setq pattern (replace-regexp-in-string "^\\^\\|\\$$" "" pat)
+          pattern 
+          (concat "^\\([0-9A-F]+\\);\\(" (if (eq (aref pat 0) ?^) "" "[^;]*")
+                  pattern
+                  (if (eq (aref pat (1- (length pat))) ?$) "" "[^;]*") "\\);"))
+    (with-current-buffer unidata
+      (goto-char (point-min))
+      (while (re-search-forward pattern nil t)
+        (when (< (setq count (1+ count)) limit)
+          (setq cp    (string-to-int (match-string 1) #x10)
+                char  (or (decode-char 'ucs cp) ?�)
+                found (format "#x%04x (%c): %s" cp char (match-string 2)) 
+                matches   (cons found matches)) )) )
+    (if (< count limit)
+        (mapconcat 'identity (nreverse matches) "\n")
+      (format "Too many matches (%d) for %S" count pat)) ))
+
+(defun fs-unicode-find (&optional pattern)
+  (if pattern (erbim-search-by-description pattern)
+    "Usage: unicode-find <REGEX TO MATCH UNICODE DATA FILE DESCRIPTION>"))
 
 (defun fs-unicode-describe (&optional thing)
-  (cond ((integerp thing) (erbim-name-by-codepoint thing))
+  (cond ((not thing) "Usage: unicode-describe <CODEPOINT-INTEGER | CHARACTER>")
+        ((integerp thing) (erbim-name-by-codepoint thing))
         ((symbolp  thing) (erbim-name-by-character (symbol-name thing)))
-        (key              (erbim-name-by-character thing)) ))
+        (thing            (erbim-name-by-character thing)) ))
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ;; trigger the preprocessing of the rest of the input methods:




reply via email to

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