emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: org-bbdb-anniversaries gives error 'bad sexp'
       [not found] <87wrht82iw.fsf@gmx.co.uk>
@ 2011-05-15 16:02 ` Roland Winkler
  2011-05-15 16:13   ` Roland Winkler
  2011-05-15 16:58   ` Matt Lundin
  0 siblings, 2 replies; 16+ messages in thread
From: Roland Winkler @ 2011-05-15 16:02 UTC (permalink / raw)
  To: Johnny; +Cc: emacs-orgmode, bbdb-info

On Sat May 14 2011 Johnny wrote:
> I have set up an org-agenda that includes anniversaries in the agenda
> view from the bbdb database, but this breaks with bbdb 3.02 giving the
> error 'bad sexp'. 
> 
> I set up the agenda file using (from org-mode 6.33x info section 10.3.1):
> 
> * Anniversaries
> :PROPERTIES:
> :CATEGORY: Anniv
> :END
> %%(org-bbdb-anniversaries)
> 
> Any ideas?

I need to say that I do not know how org-mode interfaces with BBDB.
I am CC'ing this email also to emacs-orgmode@gnu.org.

If org-mode is set up to work with BBDB v2.x, (most likely) this
does not work with BBDB v3. Defining aliases for the old BBDB
functions in terms of the new ones would work only in a few cases.
Of course, this depends first of all on how org-mode is supposed to
work with BBDB.

Yet we are trying to make the new BBDB part of GNU Emacs. So it
would be great if org-mode could be updated to provide (also) an
interface for the new BBDB.

While I'd like to declare soon that BBDB v3 has reached a beta
stage, it was probably good if someone familiar with org-mode's
interface to BBDB could take a look into this so that we could try
to make sure that the new BBDB can work with org-mode as smoothly as
possible. (Various add-ons for BBDB v2 had to go through some pain
to work as intended by advicing BBDB functions and things like that.
With BBDB v3 I tried to clean up and simplify these things; and
various add-ons for BBDB v2 are already incorporated into v3 in one
or the other way. It would probably be good if the needs of org-mode
could be incorporated into the new BBDB before we declare that BBDB
v3 has reached a beta stage.)

Roland

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-05-15 16:02 ` org-bbdb-anniversaries gives error 'bad sexp' Roland Winkler
@ 2011-05-15 16:13   ` Roland Winkler
  2011-05-15 16:58   ` Matt Lundin
  1 sibling, 0 replies; 16+ messages in thread
From: Roland Winkler @ 2011-05-15 16:13 UTC (permalink / raw)
  To: Johnny, emacs-orgmode, bbdb-info

On Sun May 15 2011 Roland Winkler wrote:
> It would probably be good if the needs of org-mode could be
> incorporated into the new BBDB before we declare that BBDB v3 has
> reached a beta stage.)

I forgot to say:

It is an item on the todo list for BBDB v3 to provide a more complete
list for how things have changed from BBDB v2 to v3.

Roland

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-05-15 16:02 ` org-bbdb-anniversaries gives error 'bad sexp' Roland Winkler
  2011-05-15 16:13   ` Roland Winkler
@ 2011-05-15 16:58   ` Matt Lundin
  2011-05-15 17:35     ` Roland Winkler
  2011-05-15 18:18     ` Leo
  1 sibling, 2 replies; 16+ messages in thread
From: Matt Lundin @ 2011-05-15 16:58 UTC (permalink / raw)
  To: Roland Winkler; +Cc: emacs-orgmode, bbdb-info, Johnny

"Roland Winkler" <winkler@gnu.org> writes:

> On Sat May 14 2011 Johnny wrote:
>> I have set up an org-agenda that includes anniversaries in the agenda
>> view from the bbdb database, but this breaks with bbdb 3.02 giving the
>> error 'bad sexp'.
>>
>> I set up the agenda file using (from org-mode 6.33x info section 10.3.1):
>>
>> * Anniversaries
>> :PROPERTIES:
>> :CATEGORY: Anniv
>> :END
>> %%(org-bbdb-anniversaries)
>>
>> Any ideas?
>
> I need to say that I do not know how org-mode interfaces with BBDB.
> I am CC'ing this email also to emacs-orgmode@gnu.org.
>
> If org-mode is set up to work with BBDB v2.x, (most likely) this
> does not work with BBDB v3. Defining aliases for the old BBDB
> functions in terms of the new ones would work only in a few cases.
> Of course, this depends first of all on how org-mode is supposed to
> work with BBDB.

I'd be happy to take this on. AFAICT, there are three functions in
org-bbdb that no longer exist in bbdb v3.

bbdb-name
bbdb-company
bbdb-record-getprop

The first two can easily be defaliased to bbdb-search-organization and
bbdb-search-name. (For a while, we should probably support bbdb v2 and
v3 simultaneously.)

What is the new name of bbdb-record-getprop (the function that retrieves
the value of a given label in a record)? My best guess is
bbdb-record-note, but I want to confirm this.

The other major change that breaks compatibility is the order of the
parameters in bbdb-split. It has been reversed in the new bbdb: i.e.,
one used to call (bbdb-split string separator), whereas now one must
call (bbdb-split separator string). Is there a compelling reason to
change this order in the new bbdb?

Best,
Matt

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-05-15 16:58   ` Matt Lundin
@ 2011-05-15 17:35     ` Roland Winkler
  2011-05-16 14:03       ` Matt Lundin
  2011-05-15 18:18     ` Leo
  1 sibling, 1 reply; 16+ messages in thread
From: Roland Winkler @ 2011-05-15 17:35 UTC (permalink / raw)
  To: Matt Lundin; +Cc: emacs-orgmode, bbdb-info

On Sun May 15 2011 Matt Lundin wrote:
> I'd be happy to take this on. AFAICT, there are three functions in
> org-bbdb that no longer exist in bbdb v3.
> 
> bbdb-name
> bbdb-company
> bbdb-record-getprop
> 
> The first two can easily be defaliased to bbdb-search-organization and
> bbdb-search-name. (For a while, we should probably support bbdb v2 and
> v3 simultaneously.)

Things might be a bit more subtle. The new organization field is
a list, not a single string.

> What is the new name of bbdb-record-getprop (the function that
> retrieves the value of a given label in a record)? My best guess
> is bbdb-record-note, but I want to confirm this.

That's mostly true. bbdb-record-getprop also retrieved the company field.

> The other major change that breaks compatibility is the order of the
> parameters in bbdb-split. It has been reversed in the new bbdb: i.e.,
> one used to call (bbdb-split string separator), whereas now one must
> call (bbdb-split separator string). Is there a compelling reason to
> change this order in the new bbdb?

The change is not only with respect to the order of arguments that
could be reverted in BBDB v3. More importantly, I tried to get rid
of hard-coded separators. Most often the separator arg is now the
name of the field that is split. Then the actual separator is looked
up in bbdb-separator-alist. While I do not know yet a good strategy
for the upgrade of org-mode's BBDB interface, I'd find it
unfortunate if such a feature was lost in org-mode to preserve
backward compatibility.

Roland

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-05-15 16:58   ` Matt Lundin
  2011-05-15 17:35     ` Roland Winkler
@ 2011-05-15 18:18     ` Leo
  2011-05-16 14:08       ` Matt Lundin
  1 sibling, 1 reply; 16+ messages in thread
From: Leo @ 2011-05-15 18:18 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: bbdb-info

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

On 2011-05-16 00:58 +0800, Matt Lundin wrote:
> I'd be happy to take this on. AFAICT, there are three functions in
> org-bbdb that no longer exist in bbdb v3.

If you want you can build on top of my version. The anniversaries is
still broken since I don't use BBDB-anniv.el. The rest works well for
the past few weeks.

Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-bbdb.el --]
[-- Type: text/x-org, Size: 14482 bytes --]

;;; org-bbdb.el --- Support for links to BBDB entries from within Org-mode

;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
;;   Free Software Foundation, Inc.

;; Author: Carsten Dominik <carsten at orgmode dot org>,
;;         Thomas Baumann <thomas dot baumann at ch dot tum dot de>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
;; Version: 7.5
;;
;; This file is part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs 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 GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:

;; This file implements links to BBDB database entries from within Org-mode.
;; Org-mode loads this module by default - if this is not what you want,
;; configure the variable `org-modules'.

;; It also implements an interface (based on Ivar Rummelhoff's
;; bbdb-anniv.el) for those org-mode users, who do not use the diary
;; but who do want to include the anniversaries stored in the BBDB
;; into the org-agenda.  If you already include the `diary' into the
;; agenda, you might want to prefer to include the anniversaries in
;; the diary using bbdb-anniv.el.
;;
;; Put the following in /somewhere/at/home/diary.org and make sure
;; that this file is in `org-agenda-files`
;;
;; %%(org-bbdb-anniversaries)
;;
;; For example my diary.org looks like:
;; * Anniversaries
;; #+CATEGORY: Anniv
;; %%(org-bbdb-anniversaries)
;;
;;
;; To add an anniversary to a BBDB record, press `C-o' in the record.
;; You will be prompted for the field name, in this case it must be
;; "anniversary".  If this is the first time you are using this field,
;; you need to confirm that it should be created.
;;
;; The format of an anniversary field stored in BBDB is the following
;; (items in {} are optional):
;;
;;     YYYY-MM-DD{ CLASS-OR-FORMAT-STRING}
;;     {\nYYYY-MM-DD CLASS-OR-FORMAT-STRING}...
;;
;; CLASS-OR-FORMAT-STRING is one of two things:
;;
;;  - an identifier for a class of anniversaries (eg. birthday or
;;    wedding) from `org-bbdb-anniversary-format-alist' which then
;;    defines the format string for this class
;;  - the (format) string displayed in the diary.
;;
;; You can enter multiple anniversaries for a single BBDB record by
;; separating them with a newline character.  At the BBDB prompt for
;; the field value, type `C-q C-j' to enter a newline between two
;; anniversaries.
;;
;; If you omit the CLASS-OR-FORMAT-STRING entirely, it defaults to the
;; value of `org-bbdb-default-anniversary-format' ("birthday" by
;; default).
;;
;; The substitutions in the format string are (in order):
;;  - the name of the record containing this anniversary
;;  - the number of years
;;  - an ordinal suffix (st, nd, rd, th) for the year
;;
;; See the documentation of `org-bbdb-anniversary-format-alist' for
;; further options.
;;
;; Example
;;
;;       1973-06-22
;;       20??-??-?? wedding
;;       1998-03-12 %s created bbdb-anniv.el %d years ago
;;
;; From Org's agenda, you can use `C-c C-o' to jump to the BBDB
;; link from which the entry at point originates.
;;
;;; Code:

(require 'org)
(eval-when-compile
  (require 'cl))

;; Declare external functions and variables

(declare-function bbdb "ext:bbdb-com" (regexp &optional layout))
(declare-function bbdb-search-organization "ext:bbdb-com"
		  (regexp &optional layout))
(declare-function bbdb-current-record "ext:bbdb" (&optional full))
(declare-function bbdb-search-name "ext:bbdb-com" (regexp &optional layout))
(declare-function bbdb-record-name "ext:bbdb-com" (record))
(declare-function bbdb-record-organization "ext:bbdb-com" (record))
(declare-function bbdb-record-note-split "ext:bbdb" (record label))
(declare-function bbdb-split "ext:bbdb" (separator string))
(declare-function bbdb-string-trim "ext:bbdb" (string))
(declare-function bbdb-records "ext:bbdb")
(declare-function bbdb-completing-read-record "ext:bbdb-com"
		  (prompt &optional omit-records))
(declare-function diary-ordinal-suffix "diary-lib" (n))

(defvar bbdb-buffer-name)
(defvar date)   ;; dynamically scoped from Org

;; Customization

(defgroup org-bbdb-anniversaries nil
  "Customizations for including anniversaries from BBDB into Agenda."
  :group 'org-bbdb)

(defcustom org-bbdb-default-anniversary-format "birthday"
  "Default anniversary class."
  :type  'string
  :group 'org-bbdb-anniversaries
  :require 'bbdb)

(defcustom org-bbdb-anniversary-format-alist
  '(("birthday" lambda
     (name years suffix)
     (concat "Birthday: [[bbdb:" name "][" name " ("
	     (format "%s" years)        ; handles numbers as well as strings
	     suffix ")]]"))
    ("wedding" lambda
     (name years suffix)
     (concat "[[bbdb:" name "][" name "'s "
	     (format "%s" years)
	     suffix " wedding anniversary]]")))
  "How different types of anniversaries should be formatted.
An alist of elements (STRING . FORMAT) where STRING is the name of an
anniversary class and format is either:
1) A format string with the following substitutions (in order):
    * the name of the record containing this anniversary
    * the number of years
    * an ordinal suffix (st, nd, rd, th) for the year

2) A function to be called with three arguments: NAME YEARS SUFFIX
   (string int string) returning a string for the diary or nil.

3) An Emacs Lisp form that should evaluate to a string (or nil) in the
   scope of variables NAME, YEARS and SUFFIX (among others)."
  :type 'sexp
  :group 'org-bbdb-anniversaries
  :require 'bbdb)

(defcustom org-bbdb-anniversary-field 'anniversary
  "The BBDB field which contains anniversaries.
The anniversaries are stored in the following format

YYYY-MM-DD Class-or-Format-String

where class is one of the customized classes for anniversaries;
birthday and wedding are predefined.  Format-String can take three
substitutions 1) the name of the record containing this
anniversary, 2) the number of years, and 3) an ordinal suffix for
the year.

Multiple anniversaries can be separated by \\n."
  :type    'symbol
  :group   'org-bbdb-anniversaries
  :require 'bbdb)

(defcustom org-bbdb-extract-date-fun 'org-bbdb-anniv-extract-date
  "How to retrieve `month date year' from the anniversary field.

Customize if you have already filled your BBDB with dates
different from YYYY-MM-DD.  The function must return a list (month
date year)."
  :type 'function
  :group 'org-bbdb-anniversaries
  :require 'bbdb)


;; Install the link type
(org-add-link-type "bbdb" 'org-bbdb-open 'org-bbdb-export)
(add-hook 'org-store-link-functions 'org-bbdb-store-link)

;; Implementation
(defun org-bbdb-store-link ()
  "Store a link to a BBDB database entry."
  (when (eq major-mode 'bbdb-mode)
    ;; This is BBDB, we make this link!
    (let* ((name (bbdb-record-name (bbdb-current-record)))
	   (organization (apply #'bbdb-concat 'organization
				(bbdb-record-organization (bbdb-current-record))))
	   (link (org-make-link "bbdb:" name)))
      (org-store-link-props :type "bbdb" :name name :organization organization
			    :link link :description name)
      link)))

(defun org-bbdb-export (path desc format)
  "Create the export version of a BBDB link specified by PATH or DESC.
If exporting to either HTML or LaTeX FORMAT the link will be
italicized, in all other cases it is left unchanged."
  (when (string= desc (format "bbdb:%s" path))
    (setq desc path))
  (cond
   ((eq format 'html) (format "<i>%s</i>" desc))
   ((eq format 'latex) (format "\\textit{%s}" desc))
   (t desc)))

(defun org-bbdb-open (name)
  "Follow a BBDB link to NAME."
  (require 'bbdb)
  (let ((inhibit-redisplay (not debug-on-error))
	(bbdb-electric nil))
    (catch 'exit
      ;; Exact match on name
      (bbdb-search-name (concat "\\`" name "\\'") nil)
      (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil))
      ;; Exact match on name
      (bbdb-search-organization (concat "\\`" name "\\'") nil)
      (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil))
      ;; Partial match on name
      (bbdb-search-name name nil)
      (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil))
      ;; Partial match on company
      (bbdb-search-organization name nil)
      (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil))
      ;; General match including network address and notes
      (bbdb name nil)
      (when (= 0 (buffer-size (get-buffer bbdb-buffer-name)))
	(delete-window (get-buffer-window bbdb-buffer-name))
	(error "No matching BBDB record")))))

(defun org-bbdb-anniv-extract-date (time-str)
  "Convert YYYY-MM-DD to (month date year).
Argument TIME-STR is the value retrieved from BBDB.  If YYYY- is omitted
it will be considered unknown."
  (multiple-value-bind (a b c) (values-list (bbdb-split "-" time-str))
    (if (eq c nil)
        (list (string-to-number a)
              (string-to-number b)
              nil)
      (list (string-to-number b)
            (string-to-number c)
            (string-to-number a)))))

(defun org-bbdb-anniv-split (str)
  "Split multiple entries in the BBDB anniversary field.
Argument STR is the anniversary field in BBDB."
  (let ((pos (string-match "[ \t]" str)))
    (if pos (list (substring str 0 pos)
		  (bbdb-string-trim (substring str pos)))
      (list str nil))))

(defvar org-bbdb-anniv-hash nil
  "A hash holding anniversaries extracted from BBDB.
The hash table is created on first use.")

(defvar org-bbdb-updated-p t
  "This is non-nil if BBDB has been updated since we last built the hash.")

(defun org-bbdb-make-anniv-hash ()
  "Create a hash with anniversaries extracted from BBDB, for fast access.
The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."

  (let (split tmp annivs)
    (clrhash org-bbdb-anniv-hash)
    (dolist (rec (bbdb-records))
      (when (setq annivs (bbdb-record-note-split
			  rec org-bbdb-anniversary-field))
	(while annivs
          (setq split (org-bbdb-anniv-split (pop annivs)))
          (multiple-value-bind (m d y)
              (values-list (funcall org-bbdb-extract-date-fun (car split)))
            (setq tmp (gethash (list m d) org-bbdb-anniv-hash))
            (puthash (list m d) (cons (list y
                                            (bbdb-record-name rec)
                                            (cadr split))
                                      tmp)
                     org-bbdb-anniv-hash))))))
  (setq org-bbdb-updated-p nil))

(defun org-bbdb-updated (rec)
  "Record the fact that BBDB has been updated.
This is used by Org to re-create the anniversary hash table."
  (setq org-bbdb-updated-p t))

(add-hook 'bbdb-after-change-hook 'org-bbdb-updated)

;;;###autoload
(defun org-bbdb-anniversaries()
  "Extract anniversaries from BBDB for display in the agenda."
  (require 'bbdb)
  (require 'diary-lib)
  (unless (hash-table-p org-bbdb-anniv-hash)
    (setq org-bbdb-anniv-hash
	  (make-hash-table :test 'equal :size 366)))

  (when (or org-bbdb-updated-p
            (= 0 (hash-table-count org-bbdb-anniv-hash)))
    (org-bbdb-make-anniv-hash))

  (let* ((m (car date))    ; month
         (d (nth 1 date))  ; day
         (y (nth 2 date))  ; year
         (annivs (gethash (list m d) org-bbdb-anniv-hash))
         (text ())
         rec recs)

    ;; we don't want to miss people born on Feb. 29th
    (when (and (= m 3) (= d 1)
               (not (null (gethash (list 2 29) org-bbdb-anniv-hash)))
               (not (calendar-leap-year-p y)))
      (setq recs (gethash (list 2 29) org-bbdb-anniv-hash))
      (while (setq rec (pop recs))
        (push rec annivs)))

    (when annivs
      (while (setq rec (pop annivs))
        (when rec
          (let* ((class (or (nth 2 rec)
                            org-bbdb-default-anniversary-format))
                 (form (or (cdr (assoc-string
				 class org-bbdb-anniversary-format-alist t))
                           class))	; (as format string)
                 (name (nth 1 rec))
                 (years (if (eq (car rec) nil)
                            "unknown"
                          (- y (car rec))))
                 (suffix (if (eq (car rec) nil)
                             ""
                           (diary-ordinal-suffix years)))
                 (tmp (cond
                       ((functionp form)
                        (funcall form name years suffix))
                       ((listp form) (eval form))
                       (t (format form name years suffix)))))
	    (org-add-props tmp nil 'org-bbdb-name name)
            (if text
                (setq text (append text (list tmp)))
              (setq text (list tmp)))))
        ))
    text))

(defun org-bbdb-complete-link ()
  "Read a bbdb link with name completion."
  (require 'bbdb-com)
  (concat "bbdb:"
	  (bbdb-record-name (car (bbdb-completing-read-record "Name: ")))))

(defun org-bbdb-anniv-export-ical ()
  "Extract anniversaries from BBDB and convert them to icalendar format."
  (require 'bbdb)
  (require 'diary-lib)
  (unless (hash-table-p org-bbdb-anniv-hash)
    (setq org-bbdb-anniv-hash
	  (make-hash-table :test 'equal :size 366)))
  (when (or org-bbdb-updated-p
	    (= 0 (hash-table-count org-bbdb-anniv-hash)))
    (org-bbdb-make-anniv-hash))
  (maphash 'org-bbdb-format-vevent org-bbdb-anniv-hash))

(defun org-bbdb-format-vevent (key recs)
  (let (rec categ)
    (while (setq rec (pop recs))
      (setq categ (or (nth 2 rec) org-bbdb-default-anniversary-format))
      (princ (format "BEGIN:VEVENT
UID: ANNIV-%4i%02i%02i-%s
DTSTART:%4i%02i%02i
SUMMARY:%s
DESCRIPTION:%s
CATEGORIES:%s
RRULE:FREQ=YEARLY
END:VEVENT\n"
		     (nth 0 rec) (nth 0 key) (nth 1 key)
		     (mapconcat 'identity
				(org-split-string (nth 1 rec) "[^a-zA-Z0-90]+")
				"-")
		     (nth 0 rec) (nth 0 key) (nth 1 key)
		     (nth 1 rec)
		     (concat (capitalize categ) " " (nth 1 rec))
		     categ)))))

(provide 'org-bbdb)

;; arch-tag: 9e4f275d-d080-48c1-b040-62247f66b5c2

;;; org-bbdb.el ends here

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: diff --]
[-- Type: text/x-diff, Size: 7368 bytes --]

commit e263d6604efde8b1c1853f72c781d01571667b62
Author: Leo <sdl.web@gmail.com>
Date:   Thu Apr 21 20:04:46 2011 +0800

    Fix org-bbdb.el for BBDB 3.x
---
 doc/org.texi         |    2 +-
 lisp/org-bbdb.el     |   61 ++++++++++++++++++++++++-------------------------
 lisp/org-capture.el  |    2 +-
 lisp/org-remember.el |    2 +-
 4 files changed, 33 insertions(+), 34 deletions(-)

	Modified doc/org.texi
diff --git a/doc/org.texi b/doc/org.texi
index 844de6da..d891a205 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6493,7 +6493,7 @@ similar way.}:
 @smallexample
 Link type          |  Available keywords
 -------------------+----------------------------------------------
-bbdb                    |  %:name %:company
+bbdb                    |  %:name %:organization
 irc                     |  %:server %:port %:nick
 vm, wl, mh, mew, rmail  |  %:type %:subject %:message-id
                         |  %:from %:fromname %:fromaddress
	Modified lisp/org-bbdb.el
diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el
index b772f442..0f5ed8d9 100644
--- a/lisp/org-bbdb.el
+++ b/lisp/org-bbdb.el
@@ -101,23 +101,22 @@ (eval-when-compile
 
 ;; Declare external functions and variables
 
-(declare-function bbdb "ext:bbdb-com" (string elidep))
-(declare-function bbdb-company "ext:bbdb-com" (string elidep))
-(declare-function bbdb-current-record "ext:bbdb-com"
-		  (&optional planning-on-modifying))
-(declare-function bbdb-name "ext:bbdb-com" (string elidep))
+(declare-function bbdb "ext:bbdb-com" (regexp &optional layout))
+(declare-function bbdb-search-organization "ext:bbdb-com"
+		  (regexp &optional layout))
+(declare-function bbdb-current-record "ext:bbdb" (&optional full))
+(declare-function bbdb-search-name "ext:bbdb-com" (regexp &optional layout))
+(declare-function bbdb-record-name "ext:bbdb-com" (record))
+(declare-function bbdb-record-organization "ext:bbdb-com" (record))
+(declare-function bbdb-record-note-split "ext:bbdb" (record label))
+(declare-function bbdb-split "ext:bbdb" (separator string))
+(declare-function bbdb-string-trim "ext:bbdb" (string))
+(declare-function bbdb-records "ext:bbdb")
 (declare-function bbdb-completing-read-record "ext:bbdb-com"
 		  (prompt &optional omit-records))
-(declare-function bbdb-record-getprop "ext:bbdb" (record property))
-(declare-function bbdb-record-name "ext:bbdb" (record))
-(declare-function bbdb-records "ext:bbdb"
-          (&optional dont-check-disk already-in-db-buffer))
-(declare-function bbdb-split "ext:bbdb" (string separators))
-(declare-function bbdb-string-trim "ext:bbdb" (string))
-
-(declare-function calendar-leap-year-p "calendar" (year))
 (declare-function diary-ordinal-suffix "diary-lib" (n))
 
+(defvar bbdb-buffer-name)
 (defvar date)   ;; dynamically scoped from Org
 
 ;; Customization
@@ -198,9 +197,10 @@ (defun org-bbdb-store-link ()
   (when (eq major-mode 'bbdb-mode)
     ;; This is BBDB, we make this link!
     (let* ((name (bbdb-record-name (bbdb-current-record)))
-	   (company (bbdb-record-getprop (bbdb-current-record) 'company))
+	   (organization (apply #'bbdb-concat 'organization
+				(bbdb-record-organization (bbdb-current-record))))
 	   (link (org-make-link "bbdb:" name)))
-      (org-store-link-props :type "bbdb" :name name :company company
+      (org-store-link-props :type "bbdb" :name name :organization organization
 			    :link link :description name)
       link)))
 
@@ -219,31 +219,31 @@ (defun org-bbdb-open (name)
   "Follow a BBDB link to NAME."
   (require 'bbdb)
   (let ((inhibit-redisplay (not debug-on-error))
-	(bbdb-electric-p nil))
+	(bbdb-electric nil))
     (catch 'exit
       ;; Exact match on name
-      (bbdb-name (concat "\\`" name "\\'") nil)
-      (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+      (bbdb-search-name (concat "\\`" name "\\'") nil)
+      (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil))
       ;; Exact match on name
-      (bbdb-company (concat "\\`" name "\\'") nil)
-      (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+      (bbdb-search-organization (concat "\\`" name "\\'") nil)
+      (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil))
       ;; Partial match on name
-      (bbdb-name name nil)
-      (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+      (bbdb-search-name name nil)
+      (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil))
       ;; Partial match on company
-      (bbdb-company name nil)
-      (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
+      (bbdb-search-organization name nil)
+      (if (< 0 (buffer-size (get-buffer bbdb-buffer-name))) (throw 'exit nil))
       ;; General match including network address and notes
       (bbdb name nil)
-      (when (= 0 (buffer-size (get-buffer "*BBDB*")))
-	(delete-window (get-buffer-window "*BBDB*"))
+      (when (= 0 (buffer-size (get-buffer bbdb-buffer-name)))
+	(delete-window (get-buffer-window bbdb-buffer-name))
 	(error "No matching BBDB record")))))
 
 (defun org-bbdb-anniv-extract-date (time-str)
   "Convert YYYY-MM-DD to (month date year).
 Argument TIME-STR is the value retrieved from BBDB.  If YYYY- is omitted
 it will be considered unknown."
-  (multiple-value-bind (a b c) (values-list (bbdb-split time-str "-"))
+  (multiple-value-bind (a b c) (values-list (bbdb-split "-" time-str))
     (if (eq c nil)
         (list (string-to-number a)
               (string-to-number b)
@@ -274,10 +274,9 @@ (defun org-bbdb-make-anniv-hash ()
   (let (split tmp annivs)
     (clrhash org-bbdb-anniv-hash)
     (dolist (rec (bbdb-records))
-      (when (setq annivs (bbdb-record-getprop
-                          rec org-bbdb-anniversary-field))
-        (setq annivs (bbdb-split annivs "\n"))
-        (while annivs
+      (when (setq annivs (bbdb-record-note-split
+			  rec org-bbdb-anniversary-field))
+	(while annivs
           (setq split (org-bbdb-anniv-split (pop annivs)))
           (multiple-value-bind (m d y)
               (values-list (funcall org-bbdb-extract-date-fun (car split)))
	Modified lisp/org-capture.el
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 3327080e..4f89455a 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -245,7 +245,7 @@ (defcustom org-capture-templates nil
 
 Link type               |  Available information
 ------------------------+------------------------------------------------------
-bbdb                    |  %:type %:name %:company
+bbdb                    |  %:type %:name %:organization
 vm, wl, mh, mew, rmail  |  %:type %:subject %:message-id
                         |  %:from %:fromname %:fromaddress
                         |  %:to   %:toname   %:toaddress
	Modified lisp/org-remember.el
diff --git a/lisp/org-remember.el b/lisp/org-remember.el
index cf2d4543..21bd751b 100644
--- a/lisp/org-remember.el
+++ b/lisp/org-remember.el
@@ -162,7 +162,7 @@ (defcustom org-remember-templates nil
 
 Link type          |  Available information
 -------------------+------------------------------------------------------
-bbdb               |  %:type %:name %:company
+bbdb               |  %:type %:name %:organization
 vm, wl, mh, rmail  |  %:type %:subject %:message-id
                    |  %:from %:fromname %:fromaddress
                    |  %:to   %:toname   %:toaddress


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-05-15 17:35     ` Roland Winkler
@ 2011-05-16 14:03       ` Matt Lundin
  0 siblings, 0 replies; 16+ messages in thread
From: Matt Lundin @ 2011-05-16 14:03 UTC (permalink / raw)
  To: Roland Winkler; +Cc: emacs-orgmode, bbdb-info

"Roland Winkler" <winkler@gnu.org> writes:

> On Sun May 15 2011 Matt Lundin wrote:
>> I'd be happy to take this on. AFAICT, there are three functions in
>> org-bbdb that no longer exist in bbdb v3.
>> 
>> bbdb-name
>> bbdb-company
>> bbdb-record-getprop
>> 
>> The first two can easily be defaliased to bbdb-search-organization and
>> bbdb-search-name. (For a while, we should probably support bbdb v2 and
>> v3 simultaneously.)
>
> Things might be a bit more subtle. The new organization field is
> a list, not a single string.

Thanks. That's good to know. AFAICT, bbdb-search-organization already
accommodates for this fact. That is, if you give it a regexp, it will
return all records matching the regexp in the organization field. Since
org-bbdb calls bbdb-company with a string as an argument, wouldn't a
defalias be sufficient for the time being?

>> The other major change that breaks compatibility is the order of the
>> parameters in bbdb-split. It has been reversed in the new bbdb: i.e.,
>> one used to call (bbdb-split string separator), whereas now one must
>> call (bbdb-split separator string). Is there a compelling reason to
>> change this order in the new bbdb?
>
> The change is not only with respect to the order of arguments that
> could be reverted in BBDB v3. More importantly, I tried to get rid
> of hard-coded separators. Most often the separator arg is now the
> name of the field that is split. Then the actual separator is looked
> up in bbdb-separator-alist. While I do not know yet a good strategy
> for the upgrade of org-mode's BBDB interface, I'd find it
> unfortunate if such a feature was lost in org-mode to preserve
> backward compatibility.

Thanks for the explanation. For the time being, I'll add a workaround to
accommodate both versions.

Best,
Matt

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-05-15 18:18     ` Leo
@ 2011-05-16 14:08       ` Matt Lundin
  2011-06-12 23:36         ` Philipp Haselwarter
  0 siblings, 1 reply; 16+ messages in thread
From: Matt Lundin @ 2011-05-16 14:08 UTC (permalink / raw)
  To: Leo; +Cc: emacs-orgmode, bbdb-info

Leo <sdl.web@gmail.com> writes:

> On 2011-05-16 00:58 +0800, Matt Lundin wrote:
>> I'd be happy to take this on. AFAICT, there are three functions in
>> org-bbdb that no longer exist in bbdb v3.
>
> If you want you can build on top of my version. The anniversaries is
> still broken since I don't use BBDB-anniv.el. The rest works well for
> the past few weeks.

Thanks Leo! This is very helpful.

I have anniversaries working in my own setup, so between the two sets of
modifications, I should be able to provide a full set of fixes. More
soon...

Best,
Matt

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-05-16 14:08       ` Matt Lundin
@ 2011-06-12 23:36         ` Philipp Haselwarter
  2011-06-13  4:40           ` Nick Dokos
  2011-06-13 12:27           ` Matt Lundin
  0 siblings, 2 replies; 16+ messages in thread
From: Philipp Haselwarter @ 2011-06-12 23:36 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: bbdb-info

On 2011-05-16 14:08 UT, Matt Lundin <mdl@imapmail.org> wrote:

ML> Leo <sdl.web@gmail.com> writes:

>> On 2011-05-16 00:58 +0800, Matt Lundin wrote:
>>> I'd be happy to take this on.AFAICT, there are three functions in
>>> org-bbdb that no longer exist in bbdb v3.
>> 
>> If you want you can build on top of my version.The anniversaries is
>> still broken since I don't use BBDB-anniv.el.The rest works well for
>> the past few weeks.

ML> Thanks Leo!This is very helpful.

ML> I have anniversaries working in my own setup, so between the two
ML> sets of modifications, I should be able to provide a full set of
ML> fixes.More soon...

ML> Best, Matt

Hi Matt,

Would you mind sharing the working bits of your setup?
I just tried %%(org-bbdb-anniversaries) and got a
Bad sexp at line […]

thanks for the effort!

-- 
Philipp Haselwarter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-06-12 23:36         ` Philipp Haselwarter
@ 2011-06-13  4:40           ` Nick Dokos
  2011-06-13 12:27           ` Matt Lundin
  1 sibling, 0 replies; 16+ messages in thread
From: Nick Dokos @ 2011-06-13  4:40 UTC (permalink / raw)
  To: Philipp Haselwarter; +Cc: nicholas.dokos, emacs-orgmode, bbdb-info

Philipp Haselwarter <philipp.haselwarter@gmx.de> wrote:

> On 2011-05-16 14:08 UT, Matt Lundin <mdl@imapmail.org> wrote:
> 
> ML> Leo <sdl.web@gmail.com> writes:
> 
> >> On 2011-05-16 00:58 +0800, Matt Lundin wrote:
> >>> I'd be happy to take this on.AFAICT, there are three functions in
> >>> org-bbdb that no longer exist in bbdb v3.
> >> 
> >> If you want you can build on top of my version.The anniversaries is
> >> still broken since I don't use BBDB-anniv.el.The rest works well for
> >> the past few weeks.
> 
> ML> Thanks Leo!This is very helpful.
> 
> ML> I have anniversaries working in my own setup, so between the two
> ML> sets of modifications, I should be able to provide a full set of
> ML> fixes.More soon...
> 
> ML> Best, Matt
> 
> Hi Matt,
> 
> Would you mind sharing the working bits of your setup?
> I just tried %%(org-bbdb-anniversaries) and got a
> Bad sexp at line […]
> 
> thanks for the effort!
> 

I haven't tried bbdb-3.0 yet - I'm still on "bbdb-2.36 devo",
so I can't help with 3.0 problems. But if you want to debug
it a bit, then the following method should give you some idea
of what's going wrong.

Switch to the *scratch* buffer and evaluate the following:

(setq debug-on-error t)
(setq date '(6 13 2011))   ; you can set the date to different things
                           ; in order to pick up different anniversaries etc.
(org-bbdb-anniversaries)

I hope this gives you a backtrace but it may be that the error is caught
(in order to produce the "Bad diary sexp at ..." message) and I'm not
sure whether a backtrace is produced in this case, but it's still worth
trying I think.  In any case, check the *Messages* buffer as well.

HTH,
Nick

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-06-12 23:36         ` Philipp Haselwarter
  2011-06-13  4:40           ` Nick Dokos
@ 2011-06-13 12:27           ` Matt Lundin
  2011-06-13 16:15             ` Philipp Haselwarter
  1 sibling, 1 reply; 16+ messages in thread
From: Matt Lundin @ 2011-06-13 12:27 UTC (permalink / raw)
  To: Philipp Haselwarter; +Cc: emacs-orgmode, bbdb-info

Philipp Haselwarter <philipp.haselwarter@gmx.de> writes:

> On 2011-05-16 14:08 UT, Matt Lundin <mdl@imapmail.org> wrote:
>
> ML> I have anniversaries working in my own setup, so between the two
> ML> sets of modifications, I should be able to provide a full set of
> ML> fixes.More soon...
>
> Would you mind sharing the working bits of your setup?
> I just tried %%(org-bbdb-anniversaries) and got a
> Bad sexp at line […]
>
> thanks for the effort!

Certainly. These are the temporary workarounds I'm using to get org-bbdb
to work with the new bbdb:

--8<---------------cut here---------------start------------->8---
(defalias 'bbdb-company 'bbdb-search-organization)
(defalias 'bbdb-name 'bbdb-search-name)

(defun bbdb-record-getprop (record label)
  (and (eq label 'company)
       (setq label 'organization))
  (if (memq label '(name degree organization address phone mail aka))
      (funcall
       (intern
	(concat "bbdb-record-" (symbol-name label)))
       record)
    (bbdb-record-note record label)))

(defadvice bbdb-split (around my-bbdb-split activate)
  (when (or (string= string "\n") (string= string "-"))
    (let ((sep string))
      (setq string separator
	    separator sep)
      ad-do-it)))
--8<---------------cut here---------------end--------------->8---

Other work has prevented me from updating org-bbdb.el yet, but I will
get to it as soon as I can.

Best,
Matt

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-06-13 12:27           ` Matt Lundin
@ 2011-06-13 16:15             ` Philipp Haselwarter
  2011-06-15 14:32               ` Carsten Dominik
  0 siblings, 1 reply; 16+ messages in thread
From: Philipp Haselwarter @ 2011-06-13 16:15 UTC (permalink / raw)
  To: Matt Lundin; +Cc: emacs-orgmode, bbdb-info

thanks, got it working now (with some fiddling).

looks like `calendar-date-style' is not honored /at all/, if you don't
use YYYY-MM-DD format (as stated in the org-bbdb.el header, admittedly),
it just blows up in your face :)


-- 
Philipp Haselwarter

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: org-bbdb-anniversaries gives error 'bad sexp'
  2011-06-13 16:15             ` Philipp Haselwarter
@ 2011-06-15 14:32               ` Carsten Dominik
  2011-06-15 19:13                 ` [bug] Problem with insert anniversary agenda function (was Re: org-bbdb-anniversaries gives error 'bad sexp') Eric S Fraga
  0 siblings, 1 reply; 16+ messages in thread
From: Carsten Dominik @ 2011-06-15 14:32 UTC (permalink / raw)
  To: Philipp Haselwarter; +Cc: Matt Lundin, emacs-orgmode, bbdb-info


On Jun 13, 2011, at 6:15 PM, Philipp Haselwarter wrote:

> thanks, got it working now (with some fiddling).
> 
> looks like `calendar-date-style' is not honored /at all/, if you don't
> use YYYY-MM-DD format (as stated in the org-bbdb.el header, admittedly),
> it just blows up in your face :)

While I think the org-bbdb code could be made more forgiving,
I strongly feel that calendar-date-style is an evil variable,
especially if it is applied to input.  One should never rely on it.

my 5c.

- Carsten

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug] Problem with insert anniversary agenda function (was Re: org-bbdb-anniversaries gives error 'bad sexp')
  2011-06-15 14:32               ` Carsten Dominik
@ 2011-06-15 19:13                 ` Eric S Fraga
  2011-06-16  8:04                   ` [patch] " Eric S Fraga
  0 siblings, 1 reply; 16+ messages in thread
From: Eric S Fraga @ 2011-06-15 19:13 UTC (permalink / raw)
  To: Carsten Dominik
  Cc: Matt Lundin, emacs-orgmode, bbdb-info, Philipp Haselwarter

Carsten Dominik <carsten.dominik@gmail.com> writes:

> On Jun 13, 2011, at 6:15 PM, Philipp Haselwarter wrote:
>
>> thanks, got it working now (with some fiddling).
>> 
>> looks like `calendar-date-style' is not honored /at all/, if you don't
>> use YYYY-MM-DD format (as stated in the org-bbdb.el header, admittedly),
>> it just blows up in your face :)
>
> While I think the org-bbdb code could be made more forgiving,
> I strongly feel that calendar-date-style is an evil variable,
> especially if it is applied to input.  One should never rely on it.
>
> my 5c.
>
> - Carsten

Although I am likely to agree with you on this, any interactions with
Emacs's diary requires working with it.  

This reminds me of a problem with the insert anniversary function in the
default agenda view ("i a").  This function ignores the
calendar-date-style and inserts dates in the american style, which of
course means that diary entries are quietly ignored if you have
calendar-date-style set to anything other than 'american...

Not a big deal...  I don't use anniversaries *that* often!

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.391.gfaccb.dirty)

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [patch] Problem with insert anniversary agenda function (was Re: org-bbdb-anniversaries gives error 'bad sexp')
  2011-06-15 19:13                 ` [bug] Problem with insert anniversary agenda function (was Re: org-bbdb-anniversaries gives error 'bad sexp') Eric S Fraga
@ 2011-06-16  8:04                   ` Eric S Fraga
  2011-06-16 12:41                     ` Carsten Dominik
  0 siblings, 1 reply; 16+ messages in thread
From: Eric S Fraga @ 2011-06-16  8:04 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> On Jun 13, 2011, at 6:15 PM, Philipp Haselwarter wrote:
>>
>>> thanks, got it working now (with some fiddling).
>>> 
>>> looks like `calendar-date-style' is not honored /at all/, if you don't
>>> use YYYY-MM-DD format (as stated in the org-bbdb.el header, admittedly),
>>> it just blows up in your face :)
>>
>> While I think the org-bbdb code could be made more forgiving,
>> I strongly feel that calendar-date-style is an evil variable,
>> especially if it is applied to input.  One should never rely on it.
>>
>> my 5c.
>>
>> - Carsten
>
> Although I am likely to agree with you on this, any interactions with
> Emacs's diary requires working with it.  
>
> This reminds me of a problem with the insert anniversary function in the
> default agenda view ("i a").  This function ignores the
> calendar-date-style and inserts dates in the american style, which of
> course means that diary entries are quietly ignored if you have
> calendar-date-style set to anything other than 'american...
>
> Not a big deal...  I don't use anniversaries *that* often!

I've made a simple change (attached) to org-agenda.el which at least
considers the 'iso date style as well as european.  Might not be fancy
lisp code but I think it works?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: have insert anniversary in agenda view allow for ISO calendar dates --]
[-- Type: text/x-patch, Size: 905 bytes --]

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 991a94a..0d074a7 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7770,11 +7770,12 @@ the resulting entry will not be shown.  When TEXT is empty, switch to
       (insert "\n")
       (require 'diary-lib)
       (let ((calendar-date-display-form
-	     (if (if (boundp 'calendar-date-style)
-		     (eq calendar-date-style 'european)
-		   (with-no-warnings ;; european-calendar-style is obsolete as of version 23.1
-		     (org-bound-and-true-p european-calendar-style))) ; Emacs 22
-		 '(day " " month " " year)
+	     (if (boundp 'calendar-date-style)
+		 (if (eq calendar-date-style 'european)
+		     '(day " " month " " year)
+		   (if (eq calendar-date-style 'iso)
+		       '(year " " month " " day)
+		     '(month " " day " " year)))
 	       '(month " " day " " year))))
 
 	(insert (format "%%%%(diary-anniversary %s) %s"

[-- Attachment #3: Type: text/plain, Size: 268 bytes --]


I know I should be formatting this appropriately etc but I'm still not
very comfortable with git...  too much to do, so little time.  sorry.

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.399.g01eb.dirty)

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [patch] Problem with insert anniversary agenda function (was Re: org-bbdb-anniversaries gives error 'bad sexp')
  2011-06-16  8:04                   ` [patch] " Eric S Fraga
@ 2011-06-16 12:41                     ` Carsten Dominik
  2011-06-20  7:41                       ` Eric S Fraga
  0 siblings, 1 reply; 16+ messages in thread
From: Carsten Dominik @ 2011-06-16 12:41 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode


On Jun 16, 2011, at 10:04 AM, Eric S Fraga wrote:

> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> 
>> Carsten Dominik <carsten.dominik@gmail.com> writes:
>> 
>>> On Jun 13, 2011, at 6:15 PM, Philipp Haselwarter wrote:
>>> 
>>>> thanks, got it working now (with some fiddling).
>>>> 
>>>> looks like `calendar-date-style' is not honored /at all/, if you don't
>>>> use YYYY-MM-DD format (as stated in the org-bbdb.el header, admittedly),
>>>> it just blows up in your face :)
>>> 
>>> While I think the org-bbdb code could be made more forgiving,
>>> I strongly feel that calendar-date-style is an evil variable,
>>> especially if it is applied to input.  One should never rely on it.
>>> 
>>> my 5c.
>>> 
>>> - Carsten
>> 
>> Although I am likely to agree with you on this, any interactions with
>> Emacs's diary requires working with it.  
>> 
>> This reminds me of a problem with the insert anniversary function in the
>> default agenda view ("i a").  This function ignores the
>> calendar-date-style and inserts dates in the american style, which of
>> course means that diary entries are quietly ignored if you have
>> calendar-date-style set to anything other than 'american...
>> 
>> Not a big deal...  I don't use anniversaries *that* often!
> 
> I've made a simple change (attached) to org-agenda.el which at least
> considers the 'iso date style as well as european.  Might not be fancy
> lisp code but I think it works?
> 
> <org-agenda-consider-iso-dates.patch>
> I know I should be formatting this appropriately etc but I'm still not
> very comfortable with git...  too much to do, so little time.  sorry.

Thanks for the patch!  Indeed, there was a bug here which always forced
one particular date style even though the code was supposed to do the
right thing.  Thanks!

However, instead of applying your patch, I thought that maybe I
should put my foot where my mouth is and remove these dependencies
altogether.

So I have just introduced a few functions org-anniversary, org-cyclic
and a few more which are just like their diary-* cousins, but with a
stable (ISO) order of arguments.  Ahhhhh, I like this *much* better.
`i a' in the agenda will now also use org-anniversary, not diary-anniversary.

For users of org-diary-class, there is a new function org-class which works
the same as org-diary-class, but with stable argument ordering.

- Carsten

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [patch] Problem with insert anniversary agenda function (was Re: org-bbdb-anniversaries gives error 'bad sexp')
  2011-06-16 12:41                     ` Carsten Dominik
@ 2011-06-20  7:41                       ` Eric S Fraga
  0 siblings, 0 replies; 16+ messages in thread
From: Eric S Fraga @ 2011-06-20  7:41 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

[...]

> Thanks for the patch!  Indeed, there was a bug here which always forced
> one particular date style even though the code was supposed to do the
> right thing.  Thanks!
>
> However, instead of applying your patch, I thought that maybe I
> should put my foot where my mouth is and remove these dependencies
> altogether.
>
> So I have just introduced a few functions org-anniversary, org-cyclic
> and a few more which are just like their diary-* cousins, but with a
> stable (ISO) order of arguments.  Ahhhhh, I like this *much* better.
> `i a' in the agenda will now also use org-anniversary, not diary-anniversary.
>
> For users of org-diary-class, there is a new function org-class which works
> the same as org-diary-class, but with stable argument ordering.
>
> - Carsten

Carsten,

many thanks for this.  The org-anniversary, at the very least, seems to
work perfectly.  It's nice not to have to worry about date orders!

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.409.g4f3a3)

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-06-20  8:39 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <87wrht82iw.fsf@gmx.co.uk>
2011-05-15 16:02 ` org-bbdb-anniversaries gives error 'bad sexp' Roland Winkler
2011-05-15 16:13   ` Roland Winkler
2011-05-15 16:58   ` Matt Lundin
2011-05-15 17:35     ` Roland Winkler
2011-05-16 14:03       ` Matt Lundin
2011-05-15 18:18     ` Leo
2011-05-16 14:08       ` Matt Lundin
2011-06-12 23:36         ` Philipp Haselwarter
2011-06-13  4:40           ` Nick Dokos
2011-06-13 12:27           ` Matt Lundin
2011-06-13 16:15             ` Philipp Haselwarter
2011-06-15 14:32               ` Carsten Dominik
2011-06-15 19:13                 ` [bug] Problem with insert anniversary agenda function (was Re: org-bbdb-anniversaries gives error 'bad sexp') Eric S Fraga
2011-06-16  8:04                   ` [patch] " Eric S Fraga
2011-06-16 12:41                     ` Carsten Dominik
2011-06-20  7:41                       ` Eric S Fraga

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).