From: Tollef Fog Heen Date: Sun, 29 Jun 2008 08:06:31 +0000 (+0200) Subject: Add lisp functions for searching and displaying records X-Git-Tag: 0.1~25 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d64ff96f827638f2a56a7add5f937659f1412b3;p=eweouz Add lisp functions for searching and displaying records --- diff --git a/lisp/eweouz.el b/lisp/eweouz.el new file mode 100644 index 0000000..f5e5a99 --- /dev/null +++ b/lisp/eweouz.el @@ -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 +;;; +;;; 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)))))