On Friday, October 25, 2002 at 15:51:57, Robert Fenk wrote:
[...]
> > I haven't found out how (again, short of hacking the layout
> > functions) to get back the blank line which used to be between
> > each multi-line record in the BBDB buffer. Could this be
> > implemented as yet another layout option?
>
> This should be a quick one ...
And I could not resist to also do some of the other stuff,
i.e. inheritance, filters, ... ;/
Please test it! If I get positive feedback it might be committed ...
Index: bbdb.el
===================================================================
RCS file: /cvsroot/bbdb/bbdb/lisp/bbdb.el,v
retrieving revision 1.193
diff -b -c -r1.193 bbdb.el
*** bbdb.el 14 Aug 2002 19:00:58 -0000 1.193
--- bbdb.el 25 Oct 2002 15:03:56 -0000
***************
*** 1187,1219 ****
(name-end . 24)
(toggle . t))
(multi-line (omit . (creation-date timestamp))
! (toggle . t))
(full-multi-line))
"*An alist describing each display layout.
The format of an element is (LAYOUT-NAME OPTION-ALIST).
By default there are three different layout types used by BBDB, which are
! `one-line', `multi-line' and `full-multi-line' (showing all fields of a
! record). `full-multi-line' has the same options as `multi-line'.
OPTION-ALIST specifies the options for the layout. Valid options are:
------- Availability --------
Format one-line multi-line default if unset
------------------------------------------------------------------------------
! (toggle . BOOL) + + nil
(order . FIELD-LIST) + + '(phones ...)
(omit . FIELD-LIST) + + nil
(name-end . INTEGER) + - 40
(indentation . INTEGER) - + 14
- toggle: controls if this layout is included when toggeling the display layout
- order: defines a user specific order for the fields, where `t' is a place
holder for all remaining fields
- omit: is a list of fields which should not be displayed or `t' to exclude all
fields except those listed in the order option
- name-end: sets the column where the name should end in one-line layout.
! - indentation: sets the level of indentation for multi-line display."
:group 'bbdb
:type
`(repeat
--- 1187,1237 ----
(name-end . 24)
(toggle . t))
(multi-line (omit . (creation-date timestamp))
! (toggle . t)
! (newline . t))
! (pop-up-multi-line)
(full-multi-line))
"*An alist describing each display layout.
The format of an element is (LAYOUT-NAME OPTION-ALIST).
By default there are three different layout types used by BBDB, which are
! `one-line', `multi-line', `pop-up-multi-line' (used for pop-ups) and
! `full-multi-line' (showing all fields of a record).
!
! `pop-up-multi-line' and `full-multi-line' have the same options
! as `multi-line'.
OPTION-ALIST specifies the options for the layout. Valid options are:
------- Availability --------
Format one-line multi-line default if unset
------------------------------------------------------------------------------
! (parent . FILTER) + + nil
! (toggle . BOOLEAN) + + nil
(order . FIELD-LIST) + + '(phones ...)
(omit . FIELD-LIST) + + nil
(name-end . INTEGER) + - 40
(indentation . INTEGER) - + 14
+ (newline . BOOLEAN) - + nil
+ (phones-filter . FILTER) + + nil
+ (addresses-filter . FILTER) + + nil
+
+ FILTER is a regexp or a function returning a boolean and called with two
+ arguments, the RECORD and the phone/address.
+ - parent: options not present in the current layout will be inherited from
+ PARENT layout.
- toggle: controls if this layout is included when toggeling the display layout
- order: defines a user specific order for the fields, where `t' is a place
holder for all remaining fields
- omit: is a list of fields which should not be displayed or `t' to exclude all
fields except those listed in the order option
- name-end: sets the column where the name should end in one-line layout.
! - indentation: sets the level of indentation for multi-line display.
! - newline: appends a newline to the formated record in multi-line layout.
! - phones-filter: only the phones matching filter will be displayed.
! - addresses-filter: only the addresses matching filter will be displayed.
! "
:group 'bbdb
:type
`(repeat
***************
*** 1226,1233 ****
(set :tag "Properties"
(cons :tag "Order"
(const :tag "List of fields to order by" order)
! (repeat (choice (const phone)
! (const address)
(const net)
(const AKA)
(const notes)
--- 1244,1251 ----
(set :tag "Properties"
(cons :tag "Order"
(const :tag "List of fields to order by" order)
! (repeat (choice (const phones)
! (const addresses)
(const net)
(const AKA)
(const notes)
***************
*** 1237,1244 ****
:value (omit . nil)
(cons :tag "List of fields to omit"
(const :tag "Fields not to display" omit)
! (repeat (choice (const phone)
! (const address)
(const net)
(const AKA)
(const notes)
--- 1255,1262 ----
:value (omit . nil)
(cons :tag "List of fields to omit"
(const :tag "Fields not to display" omit)
! (repeat (choice (const phones)
! (const addresses)
(const net)
(const AKA)
(const notes)
***************
*** 1254,1259 ****
--- 1272,1281 ----
(const :tag "The column where the name should end in one-line
layout"
name-end)
(number :tag "Column"))
+ (cons :tag "Insert a newline at the end of a mult-line layout."
+ :value (newline . t)
+ (const newline)
+ (boolean))
(cons :tag "Toggle"
(const :tag "The layout is included when toggling display
layout" toggle)
boolean)))))
***************
*** 1275,1287 ****
(symbol)))
(defun bbdb-display-layout-get-option (layout option)
(let ((layout-spec (if (listp layout)
layout
(assoc layout bbdb-display-layout-alist)))
option-value)
! (and layout-spec
! (setq option-value (assoc option layout-spec))
! (cdr option-value))))
(defcustom bbdb-address-formatting-alist
'((bbdb-address-is-continental . bbdb-format-address-continental)
--- 1297,1342 ----
(symbol)))
(defun bbdb-display-layout-get-option (layout option)
+ "Return the CDR if OPTION is present in LAYOUT, otherwise nil."
(let ((layout-spec (if (listp layout)
layout
(assoc layout bbdb-display-layout-alist)))
+ parent
option-value)
! (if layout-spec
! (if (setq option-value (assoc option layout-spec))
! (cdr option-value)
! (if (and (not (boundp 'bbdb-display-layout-get-option-no-cycles))
! (setq parent (assoc 'parent layout-spec)))
! (let ((bbdb-display-layout-get-option-no-cycles t))
! (eval bbdb-display-layout-get-option-no-cycles)
! (bbdb-display-layout-get-option (cdr parent) option)))))))
!
! (defun bbdb-record-phones-filtered (filter record)
! "Return only the phones satisfying FILTER."
! (let ((phones (bbdb-record-phones record))
! rest p)
! (if (not filter)
! phones
! (while phones
! (setq p (car phones) phones (cdr phones))
! (if (or (and (stringp filter) (string-match filter (aref p 0)))
! (and (functionp filter) (funcall filter record p)))
! (setq rest (cons p rest))))
! rest)))
!
! (defun bbdb-record-addresses-filtered (filter record)
! "Return only the addresses satisfying FILTER."
! (let ((addresses (bbdb-record-addresses record))
! rest p)
! (if (not filter)
! addresses
! (while addresses
! (setq p (car addresses) addresses (cdr addresses))
! (if (or (and (stringp filter) (string-match filter (aref p 0)))
! (and (functionp filter) (funcall filter record p)))
! (setq rest (cons p rest))))
! rest)))
(defcustom bbdb-address-formatting-alist
'((bbdb-address-is-continental . bbdb-format-address-continental)
***************
*** 1473,1486 ****
(indent-to name-end))
;; rest of the fields
! (let (start field contentfun formatfun values value)
(while field-list
(setq field (car field-list)
contentfun (intern (concat "bbdb-record-"
! (symbol-name field))))
(if (fboundp contentfun)
(setq values (eval (list contentfun record)))
! (setq values (bbdb-record-getprop record field)))
(when values
(if (not (listp values)) (setq values (list values)))
(setq formatfun (intern (format "bbdb-format-record-%s-%s"
--- 1528,1550 ----
(indent-to name-end))
;; rest of the fields
! (let (start field
! contentfun contentfun-filtered filter
! formatfun values value)
(while field-list
(setq field (car field-list)
contentfun (intern (concat "bbdb-record-"
! (symbol-name field)))
! filter (bbdb-display-layout-get-option
! layout (intern (format "%s-filter" field)))
! contentfun-filtered (intern (format "bbdb-record-%s-filtered"
! field)))
! (if (and filter (fboundp contentfun-filtered))
! (setq values (funcall contentfun-filtered filter record))
(if (fboundp contentfun)
(setq values (eval (list contentfun record)))
! (setq values (bbdb-record-getprop record field))))
!
(when values
(if (not (listp values)) (setq values (list values)))
(setq formatfun (intern (format "bbdb-format-record-%s-%s"
***************
*** 1528,1534 ****
start (point))
(cond ((eq field 'phones)
! (let ((phones (bbdb-record-phones record))
loc phone)
(while phones
(setq phone (car phones)
--- 1592,1601 ----
start (point))
(cond ((eq field 'phones)
! (let ((phones (bbdb-record-phones-filtered
! (bbdb-display-layout-get-option
! layout 'phones-filter)
! record))
loc phone)
(while phones
(setq phone (car phones)
***************
*** 1545,1551 ****
(setq phones (cdr phones))))
(setq start nil))
((eq field 'addresses)
! (let ((addrs (bbdb-record-addresses record))
loc addr)
(while addrs
(setq addr (car addrs)
--- 1612,1621 ----
(setq phones (cdr phones))))
(setq start nil))
((eq field 'addresses)
! (let ((addrs (bbdb-record-addresses-filtered
! (bbdb-display-layout-get-option
! layout 'addresses-filter)
! record))
loc addr)
(while addrs
(setq addr (car addrs)
***************
*** 1602,1609 ****
(insert "\n"))
(put-text-property start (point) 'bbdb-field
(list 'property note))))
! )
! (setq field-list (cdr field-list)))))
(defalias 'bbdb-format-record-layout-full-multi-line
'bbdb-format-record-layout-multi-line)
--- 1672,1682 ----
(insert "\n"))
(put-text-property start (point) 'bbdb-field
(list 'property note))))
! ) ;; end of cond
! (setq field-list (cdr field-list)))
!
! (if (bbdb-display-layout-get-option layout 'newline)
! (insert "\n"))))
(defalias 'bbdb-format-record-layout-full-multi-line
'bbdb-format-record-layout-multi-line)
***************
*** 1938,1947 ****
'(and (boundp sym) (symbol-value sym))))))
(defmacro bbdb-remhash (name record &optional ht)
! (list 'let (list (list 's (list 'intern-soft name
! (or ht '(bbdb-hashtable)))))
! (list 'and 's (list 'set 's (list 'bbdb-remove! record
! (list 'symbol-value 's))))))
(defsubst bbdb-search-intertwingle (name net)
"Find bbdb records matching NAME and NET.
--- 2011,2017 ----
'(and (boundp sym) (symbol-value sym))))))
(defmacro bbdb-remhash (name record &optional ht)
! (list 'unintern name (or ht '(bbdb-hashtable))))
(defsubst bbdb-search-intertwingle (name net)
"Find bbdb records matching NAME and NET.
-------------------------------------------------------
This sf.net email is sponsored by: Influence the future
of Java(TM) technology. Join the Java Community
Process(SM) (JCP(SM)) program now.
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
_______________________________________________
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/