Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-06-15 Thread Philipp Haselwarter
thanks, got it working now (with some fiddling).

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


-- 
Philipp Haselwarter



Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-06-15 Thread Carsten Dominik

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 -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






Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-06-13 Thread Matt Lundin
Philipp Haselwarter philipp.haselwar...@gmx.de writes:

 On 2011-05-16 14:08 UT, Matt Lundin m...@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



Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-06-12 Thread Philipp Haselwarter
On 2011-05-16 14:08 UT, Matt Lundin m...@imapmail.org wrote:

ML Leo sdl@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




Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-06-12 Thread Nick Dokos
Philipp Haselwarter philipp.haselwar...@gmx.de wrote:

 On 2011-05-16 14:08 UT, Matt Lundin m...@imapmail.org wrote:
 
 ML Leo sdl@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





Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-05-16 Thread Matt Lundin
Roland Winkler wink...@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



Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-05-16 Thread Roland Winkler
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



Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-05-16 Thread Roland Winkler
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



Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-05-16 Thread Roland Winkler
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



Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-05-16 Thread Matt Lundin
Leo sdl@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



Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-05-15 Thread Matt Lundin
Roland Winkler wink...@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



Re: [O] org-bbdb-anniversaries gives error 'bad sexp'

2011-05-15 Thread Leo
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

;;; 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):
;;
;; -MM-DD{ CLASS-OR-FORMAT-STRING}
;; {\n-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