From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Alexander Gerds Subject: Re: org agenda extensions Date: Fri, 11 Jan 2013 21:50:35 +0100 Message-ID: <86vcb3xx44.fsf@biostat.ku.dk> References: <87zk0f1yas.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:48978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtlYu-0004QH-Op for emacs-orgmode@gnu.org; Fri, 11 Jan 2013 15:50:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtlYm-0003zL-Ew for emacs-orgmode@gnu.org; Fri, 11 Jan 2013 15:50:48 -0500 Received: from mail-we0-f176.google.com ([74.125.82.176]:61229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtlYm-0003z8-4v for emacs-orgmode@gnu.org; Fri, 11 Jan 2013 15:50:40 -0500 Received: by mail-we0-f176.google.com with SMTP id r5so1028156wey.7 for ; Fri, 11 Jan 2013 12:50:39 -0800 (PST) In-Reply-To: <87zk0f1yas.fsf@bzg.ath.cx> (Bastien's message of "Fri, 11 Jan 2013 17:26:03 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable sure, here it comes (attached to this mail). to try my example you need to evaluate the file test.el (also attached) and the following expression: (test-overriding-format "~/saved-attachments/test.org") after saving test.org (also attached) in folder ~/saved-attachments/ does this work for you? Bastien writes: > Hi Thomas, > > Thomas Alexander Gerds writes: > >> with the aim to show properties in custom match views, I have been >> experimenting with new variables: >> >> org-agenda-overriding-agenda-format >> org-agenda-property-list >> >> then, tweaking the function org-scan-tags this enables custom format for >> the agenda lines, optionally showing properties (without invoking >> org-columns). >> >> you can test this here > > Thanks for experimenting with this -- could you send your code as a > patch against current maint or master branch? > > That's easier for me to read/check/test... otherwise I'll have a look > later on next week at best. > > Thanks, -- Thomas A. Gerds -- Assoc. Prof. Department of Biostatistics University of Copenhagen, =D8ster Farimagsgade 5, 1014 Copenhagen, Denmark Office: CSS-15.2.07 (Gamle Kommunehospital) tel: 35327914 (sec: 35327901)=20 --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=patch-agenda-overriding-format-org.el Content-Transfer-Encoding: quoted-printable --- org.el 2013-01-11 21:34:28.340999307 +0100 +++ ../../../snps/org.el 2013-01-11 21:42:18.133011339 +0100 @@ -154,6 +154,12 @@ ;; load languages based on value of `org-babel-load-languages' (defvar org-babel-load-languages) =20 +(defvar org-agenda-overriding-agenda-format nil) +(make-variable-buffer-local 'org-agenda-overriding-agenda-format) + +(defvar org-agenda-property-list nil) +(make-variable-buffer-local 'org-agenda-property-list) + ;;;###autoload (defun org-babel-do-load-languages (sym value) "Load the languages defined in `org-babel-load-languages'." @@ -13406,6 +13412,16 @@ (or (not org-agenda-tags-todo-honor-ignore-options) (not (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-ite= m)))))) =20 + ;; extract properties + (if org-agenda-property-list + (setq prop-list + (mapcar + '(lambda (prop) + (cons prop (or (org-entry-get (point) prop 'inherit) + "not set" + ""))) org-agenda-property-list)) + (setq prop-list "")) +=09=20=20=20=20 ;; select this headline (cond ((eq action 'sparse-tree) @@ -13415,15 +13431,22 @@ (match-beginning 1) (match-end 1))) (org-show-context 'tags-tree)) ((eq action 'agenda) - (setq txt (org-agenda-format-item - "" - (concat - (if (eq org-tags-match-list-sublevels 'indented) - (make-string (1- level) ?.) "") - (org-get-heading)) - level category - tags-list) - priority (org-get-priority txt)) + (if org-agenda-overriding-agenda-format + (setq txt (funcall org-agenda-overriding-agenda-format + (org-get-heading 'no-tags 'no-todo) + level + category + tags-list + prop-list)) + (setq txt (org-agenda-format-item + "" + (concat + (if (eq org-tags-match-list-sublevels 'indented) + (make-string (1- level) ?.) "") + (org-get-heading)) + level category + tags-list))) + (setq priority (org-get-priority txt)) (goto-char lspos) (setq marker (org-agenda-new-marker)) (org-add-props txt props --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=test.el Content-Transfer-Encoding: quoted-printable (defun test-overriding-format (&optional file) (interactive "f") (let* ((file (or file (read-file-name "Org file for testing overriding fo= rmat: "))) (org-agenda-custom-commands `(("t" "test" tags "filename=3D{.+}" ((org-agenda-files (quote (,file))) (org-agenda-overriding-header (concat "Test of overriding format: " "\n\n" (test-org-agenda-overriding-format "header" 0 nil nil '(("filename" . "f= ilename") ("birthday" . "birthday"))))) (org-agenda-property-list '("filename" "birthday")) (org-agenda-overriding-agenda-format 'test-org-agenda-overriding-for= mat) (org-agenda-view-columns-initially nil)))))) (push ?t unread-command-events) (call-interactively 'org-agenda))) (defun test-org-agenda-overriding-format (hdr level category tags-list prop= -list) (concat " " (test-trim-string hdr 20) (let ((cprops prop-list) (pstring "")) (while cprops (let ((val (cdr (car cprops)))) (cond ((string=3D (downcase (caar cprops)) "filename") (setq val (file-name-nondirectory (org-link-display-format val))))) (setq pstring (concat pstring " " (test-trim-string val 23)))) (setq cprops (cdr cprops))) pstring) "\t")) (defun test-trim-string (str len) "Trim string STR to a given length by either calling substring or by adding whitespace characters." (let* ((slen (length str)) (diff (- len slen))) (if (> diff 0) (concat str (make-string diff (string-to-char " "))) (substring str 0 len)))) --=-=-= Content-Type: text/x-org Content-Disposition: attachment; filename=test.org ** a test entry :PROPERTIES: :filename: [[bla.txt]] :birthday: <2013-01-11 Fri> :END: ** another test entry :PROPERTIES: :filename: [[blub.txt]] :birthday: <2013-01-11 Fri 8:38> :END: --=-=-=--