emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/gnorb d28a099 005/449: gnorb-bbdb.el: New function gnor


From: Stefan Monnier
Subject: [elpa] externals/gnorb d28a099 005/449: gnorb-bbdb.el: New function gnorb-bbdb-tag-agenda
Date: Fri, 27 Nov 2020 23:14:57 -0500 (EST)

branch: externals/gnorb
commit d28a099ad04edd56a00746018171cd6b3b9b1611
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    gnorb-bbdb.el: New function gnorb-bbdb-tag-agenda
    
    Open Org tag search agendas using tags attached to BBDB records.
---
 README.md          |  9 +++++++++
 lisp/gnorb-bbdb.el | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/README.md b/README.md
index b72cdc9..f785acc 100644
--- a/README.md
+++ b/README.md
@@ -15,3 +15,12 @@ stable releases of those packages, but I'm not promising 
anything.
 Put "gnorb/lisp" in your load path, then either require "gnorb" to
 load everything, or pick bits and pieces: "gnorb-gnus", "gnorb-org",
 or "gnorb-bbdb".
+
+gnorb-bbdb
+----------
+
+Current functions include:
+
+* gnorb-bbdb-tag-agenda: Give BBDB records an org-tag field
+  (customizable), then call this function on the current records(s) to
+  open an Org agenda tags search using those tags.
diff --git a/lisp/gnorb-bbdb.el b/lisp/gnorb-bbdb.el
index ff84370..2db8db3 100644
--- a/lisp/gnorb-bbdb.el
+++ b/lisp/gnorb-bbdb.el
@@ -32,5 +32,45 @@
   :group 'gnorb)
 
 
+(defcustom gnorb-bbdb-org-tag-field 'org-tags
+  "The name (as a symbol) of the field to use for org tags."
+  :group 'gnorb-bbdb
+  :type 'symbol)
+
+(unless (assoc gnorb-bbdb-org-tag-field bbdb-separator-alist)
+  (push `(,gnorb-bbdb-org-tag-field ":" ":") bbdb-separator-alist))
+
+(defun gnorb-bbdb-tag-agenda (records)
+  "Open an Org agenda tags view from the BBDB buffer, using the
+value of the record's org-tags field. A prefix argument limits to
+TODOs only; a \"*\" prefix operates on all currently visible
+records. If you want both, use \"C-u\" before the \"*\"."
+  (interactive (list (bbdb-do-records)))
+  (require 'org-agenda)
+  (unless (and (eq major-mode 'bbdb-mode)
+              (equal (buffer-name) bbdb-buffer-name))
+    (error "Only works in the BBDB buffer"))
+  (setq records (bbdb-record-list records))
+  (let ((tag-string
+        (mapconcat
+         'identity
+         (delete-dups
+          (mapcan (lambda (r)
+                    (bbdb-record-xfield-split r gnorb-bbdb-org-tag-field))
+                  records))
+         "|")))
+    (if tag-string
+       ;; C-u = todos only
+       (if (equal current-prefix-arg '(4))
+           (org-tags-view t tag-string)
+         (org-tags-view nil tag-string))
+      (error "No org-tags field present"))))
+
+;; (eval-after-load "gnorb-bbdb"
+;;   '(progn
+;;      (define-key bbdb-mode-map (kbd "O") 'gnorb-bbdb-tag-agenda)))
+
+
+
 (provide 'gnorb-bbdb)
 ;;; gnorb-bbdb.el ends here



reply via email to

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