]> err.no Git - eweouz/commitdiff
Add lisp functions for searching and displaying records
authorTollef Fog Heen <tfheen@err.no>
Sun, 29 Jun 2008 08:06:31 +0000 (10:06 +0200)
committerTollef Fog Heen <tfheen@err.no>
Sun, 29 Jun 2008 08:06:31 +0000 (10:06 +0200)
lisp/eweouz.el [new file with mode: 0644]

diff --git a/lisp/eweouz.el b/lisp/eweouz.el
new file mode 100644 (file)
index 0000000..f5e5a99
--- /dev/null
@@ -0,0 +1,53 @@
+;;; -*- Mode:Emacs-Lisp -*-
+
+;;; This file is the core of the eweouz, an interface to the
+;;; evolution-data-server, somewhat similar to BBDB.
+
+;;;  copyright (c) 2008 Tollef Fog Heen <tfheen@err.no>
+;;;
+;;; eweouz is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License version 2 as
+;;; published by the Free Software Foundation.
+;;;
+;;; eweouz is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;; General Public License for more details.
+;;;
+;;;    You should have received a copy of the GNU General Public
+;;;    License along with this program; if not, write to the Free
+;;;    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;;;    Boston, MA 02110-1301 USA.
+;;;
+
+(defconst eweouz-version "0.1")
+(defconst eweouz-buffer-name "*EWEOUZ*")
+
+(defvar eweouz-path "/home/tfheen/src/eds-address/build/src/dump-addressbook")
+
+(defvar eweouz-buffer nil)
+
+;;;###autoload
+(defun eweouz (string)
+  (interactive)
+  "Search all entries for the simple string STRING in all fields"
+  (set-buffer (get-buffer-create eweouz-buffer-name))
+  (widen)
+  (delete-region (point-min) (point-max))
+
+  (with-temp-buffer
+    (call-process eweouz-path nil (current-buffer) t string)
+    (set-text-properties (point-min) (point-max) nil nil)
+    (goto-char (point-min))
+    (message (format "%s" (point)))
+    (while (looking-at-p "\n*BEGIN:VCARD")
+      (let ((m-start (point)))
+       (message (format "%s" (point)))
+       (search-forward-regexp "^END:VCARD")
+       (eweouz-show (vcard-parse-string (buffer-substring m-start (point))))))))
+
+(defun eweouz-show (record)
+  "Display an entry in the current buffer"
+  (save-excursion
+    (set-buffer (get-buffer-create eweouz-buffer-name))
+    (insert (format "%s\n" (vcard-pretty-print record)))))