commit-womb
[Top][All Lists]
Advanced

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

[Commit-womb] addressbook ChangeLog addressbook.el


From: Jose E. Marchesi
Subject: [Commit-womb] addressbook ChangeLog addressbook.el
Date: Sat, 05 May 2007 19:47:46 +0000

CVSROOT:        /cvsroot/womb
Module name:    addressbook
Changes by:     Jose E. Marchesi <jemarch>      07/05/05 19:47:46

Modified files:
        .              : ChangeLog addressbook.el 

Log message:
        Prototype of summary addressbook and some improvements

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/addressbook/ChangeLog?cvsroot=womb&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/addressbook/addressbook.el?cvsroot=womb&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/womb/addressbook/ChangeLog,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- ChangeLog   5 May 2007 02:39:54 -0000       1.3
+++ ChangeLog   5 May 2007 19:47:46 -0000       1.4
@@ -1,5 +1,8 @@
 2007-05-05  Jose E. Marchesi  <address@hidden>
 
+       * addressbook.el (addrbook-open): New function.
+       (addressbook): Use `addrbook-open'.
+ 
        * README: Added urls to web resources
 
        * addressbook.el (addrbook-get-prop-fields): use

Index: addressbook.el
===================================================================
RCS file: /cvsroot/womb/addressbook/addressbook.el,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- addressbook.el      5 May 2007 00:19:11 -0000       1.2
+++ addressbook.el      5 May 2007 19:47:46 -0000       1.3
@@ -5,7 +5,7 @@
 ;; Maintainer: Jose E. Marchesi
 ;; Keywords: contacts, applications
 
-;; $Id: addressbook.el,v 1.2 2007/05/05 00:19:11 jemarch Exp $
+;; $Id: addressbook.el,v 1.3 2007/05/05 19:47:46 jemarch Exp $
 
 ;; This file is NOT part of GNU Emacs.
 
@@ -97,11 +97,31 @@
   :group 'addrbook)
 
 (defcustom addrbook-summary-format
-  '("fn" "email")
+  '("fn")
   "Fields in summary lines"
   :type 'sexp
   :group 'addrbook)
 
+(defcustom addrbook-summary-max-height
+  8
+  "Maximum height of the summary buffer"
+  :type 'integer
+  :group 'addrbook)
+
+(defface addrbook-summary-card-number
+  '((((min-colors 88) (class color) (background light))
+     :foreground "red1")
+    (((class color) (background light))
+     :foreground "red")
+    (((min-colors 88) (class color) (background dark))
+     :foreground "blue")
+    (((class color) (background dark))
+     :foreground "blue")
+    (t
+     :weight bold))
+  "Face for summary card numbers"
+  :group 'addrbook)
+
 (defface addrbook-properties-group-name
   '((((min-colors 88) (class color) (background light))
      :foreground "red1")
@@ -1063,6 +1083,11 @@
           (setq result (concat result ","))))
     result))
 
+(defun addrbook-open ()
+  "Open the addressbook"
+  (or (addrbook-read-cards)
+      (addrbook-create-card-2)))
+
 ;;;; Commands 
 
 (defun addrbook-send-email ()
@@ -1455,6 +1480,15 @@
               (list 10 
                     (format "%d/%d" card-number total-cards)))))
             
+(defun addrbook-summary-set-mode-line (card-number total-cards)
+  "Update the mdoeline of the current summary buffer"
+  (setq mode-line-buffer-identification
+        (list 24
+              "AddressBook Summary"
+              ": "
+              (list 10 
+                    (format "%d/%d" card-number total-cards)))))
+            
 ;;;; Group/Attribute fast selection
 ;;; Adapted from `org-fast-tag-selection' in org.el by Carsten Dominic
 ;;;
@@ -1633,23 +1667,45 @@
   (delete-other-windows)
   (split-window-vertically)
   (switch-to-buffer addrbook-summary-buffer)
-  (fit-window-to-buffer)
+  (fit-window-to-buffer nil addrbook-summary-max-height)
   (switch-to-buffer-other-window addrbook-buffer))
 
+(defun addrbook-get-create-summary-buffer ()
+  (if (not addrbook-summary-buffer)
+      (save-excursion
+        (setq addrbook-summary-buffer (get-buffer-create 
addrbook-summary-buffer-name))
+        (set-buffer addrbook-summary-buffer)
+        (addrbook-summary-mode)
+        (addrbook-display-summary)))
+  addrbook-summary-buffer)
+
 (defun addrbook-display-summary ()
   (erase-buffer)
   (let (i card attr spec-item)
     (dotimes (i (length addrbook-cards))
-      (insert (number-to-string i) " ")
+      (insert "  ")
+      (insert (propertize (number-to-string i)
+                          'face 'addrbook-summary-card-number) 
+              " ")
+      (insert (make-string (- 4 (length (number-to-string i))) ?\ ))
       (setq card (addrbook-get-card i))
       (dolist (spec-item addrbook-summary-format)
         (setq attr (vcard-get-named-attribute card spec-item))
-        (cond ((equal spec-item "n")
-               (insert (addrbook-get-card-fn nil i)))
+        (cond ((equal spec-item "fn")
+               (insert (propertize (addrbook-get-card-fn nil i)
+                                   'face 'addrbook-attribute-value)))
               (t
-               (insert "foo"))))
+               (insert "fixme"))))
       (insert "\n"))))
       
+(defun addrbook-summary-goto (numcard)
+  (goto-line (+ numcard 1))
+  (forward-char 5)
+  (addrbook-summary-set-mode-line (+ numcard 1) 
+                                  (+ (length addrbook-cards) 1)))
+
+    
+  
 
 ;;;; Modes and launchers
 
@@ -1708,8 +1764,7 @@
   (catch 'exit
     (let ((buffer (get-buffer addrbook-buffer-name)))
       (when (not buffer)
-        (if (and (not (addrbook-read-cards))
-                 (not (addrbook-create-card-2)))
+        (unless (addrbook-open)
             (throw 'exit t))
         (setq buffer (get-buffer-create addrbook-buffer-name))
         (set-buffer buffer)
@@ -1732,9 +1787,19 @@
 (defun addressbook-summary ()
   "Open the addressbook and show the summary window"
   (interactive)
-  (addrbook-create-summary)
-  (addrbook-show-summary))
-    
+  (catch 'exit
+    (let ((buffer (get-buffer addrbook-summary-buffer-name)))
+      (when (not buffer)
+        (unless (addrbook-open)
+          (throw 'exit t))
+        (setq buffer (get-buffer-create addrbook-summary-buffer-name))
+        (set-buffer buffer)
+        (addrbook-summary-mode)
+        (addrbook-display-summary)
+        (addrbook-summary-goto 0))
+      (switch-to-buffer-other-window buffer)
+      (setq buffer-read-only t)
+      (setq addrbook-summary-buffer buffer))))
 
 (provide 'addressbook)
 




reply via email to

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