From b52b4159dcb8d7f930c4d27ca4bb5433f8de318e Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Sat, 1 Nov 2008 13:48:54 +0100 Subject: [PATCH] Removed filtered text from the exported agenda. --- lisp/ChangeLog | 7 +++- lisp/org-agenda.el | 101 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 75 insertions(+), 33 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 623bdc845..ff170460f 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,4 +1,9 @@ -2008-10-31 Carsten Dominik +2008-11-01 Carsten Dominik + + * org-agenda.el (org-agenda-remove-marked-text): New function. + (org-agenda-mark-filtered-text) + (org-agenda-unmark-filtered-text): New functions. + (org-write-agenda): Remove fltered text. * org.el (org-make-tags-matcher): Give access to TODO "property" without speed penalty. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 8dd31c8e4..563a005a2 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1870,41 +1870,78 @@ higher priority settings." (org-let (if nosettings nil org-agenda-exporter-settings) '(save-excursion (save-window-excursion - (cond - ((string-match "\\.html?\\'" file) - (set-buffer (htmlize-buffer (current-buffer))) - - (when (and org-agenda-export-html-style - (string-match "")) - (insert org-agenda-export-html-style)) - (write-file file) - (kill-buffer (current-buffer)) - (message "HTML written to %s" file)) - ((string-match "\\.ps\\'" file) - (ps-print-buffer-with-faces file) - (message "Postscript written to %s" file)) - ((string-match "\\.ics\\'" file) - (let ((org-agenda-marker-table - (org-create-marker-find-array - (org-agenda-collect-markers))) - (org-icalendar-verify-function 'org-check-agenda-marker-table) - (org-combined-agenda-icalendar-file file)) - (apply 'org-export-icalendar 'combine - (org-agenda-files nil 'ifmode)))) - (t - (let ((bs (buffer-string))) - (find-file file) - (erase-buffer) + (org-agenda-mark-filtered-text) + (let ((bs (copy-sequence (buffer-string))) beg) + (org-agenda-unmark-filtered-text) + (with-temp-buffer (insert bs) - (save-buffer 0) - (kill-buffer (current-buffer)) - (message "Plain text written to %s" file)))))) + (org-agenda-remove-marked-text 'org-filtered) + (while (setq beg (text-property-any (point-min) (point-max) + 'org-filtered t)) + (delete-region + beg (or (next-single-property-change beg 'org-filtered) + (point-max)))) + (cond + ((string-match "\\.html?\\'" file) + (set-buffer (htmlize-buffer (current-buffer))) + + (when (and org-agenda-export-html-style + (string-match "")) + (insert org-agenda-export-html-style)) + (write-file file) + (kill-buffer (current-buffer)) + (message "HTML written to %s" file)) + ((string-match "\\.ps\\'" file) + (ps-print-buffer-with-faces file) + (message "Postscript written to %s" file)) + ((string-match "\\.ics\\'" file) + (let ((org-agenda-marker-table + (org-create-marker-find-array + (org-agenda-collect-markers))) + (org-icalendar-verify-function 'org-check-agenda-marker-table) + (org-combined-agenda-icalendar-file file)) + (apply 'org-export-icalendar 'combine + (org-agenda-files nil 'ifmode)))) + (t + (let ((bs (buffer-string))) + (find-file file) + (erase-buffer) + (insert bs) + (save-buffer 0) + (kill-buffer (current-buffer)) + (message "Plain text written to %s" file)))))))) (set-buffer org-agenda-buffer-name))) +(defun org-agenda-mark-filtered-text () + "Mark all text hidden by filtering with a text property." + (let ((inhibit-read-only t)) + (mapc + (lambda (o) + (when (equal (org-overlay-buffer o) (current-buffer)) + (put-text-property + (org-overlay-start o) (org-overlay-end o) + 'org-filtered t))) + org-agenda-filter-overlays))) + +(defun org-agenda-unmark-filtered-text () + "Remove the filtering text property." + (let ((inhibit-read-only t)) + (remove-text-properties (point-min) (point-max) '(org-filtered t)))) + +(defun org-agenda-remove-marked-text (property &optional value) + "Delete all text marked with VALUE of PROPERTY. +VALUE defaults to t." + (setq value (or value t)) + (while (setq beg (text-property-any (point-min) (point-max) + property value)) + (delete-region + beg (or (next-single-property-change beg 'org-filtered) + (point-max))))) + (defun org-agenda-collect-markers () "Collect the markers pointing to entries in the agenda buffer." (let (m markers) -- 2.11.4.GIT