From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Clock-in in agenda makes some headings with links disappear Date: Wed, 21 May 2014 17:35:23 +0200 Message-ID: <87ioozkuv8.fsf@bzg.ath.cx> References: <87egzw24es.fsf@algol.ziiuu.com> <87zjijtn1q.fsf@bzg.ath.cx> <87vbt6l98n.fsf@algol.ziiuu.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn8YT-0001bY-Dp for emacs-orgmode@gnu.org; Wed, 21 May 2014 11:35:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wn8YB-0008DN-6b for emacs-orgmode@gnu.org; Wed, 21 May 2014 11:35:44 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:63987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wn8YA-0008D9-Sh for emacs-orgmode@gnu.org; Wed, 21 May 2014 11:35:27 -0400 Received: by mail-wi0-f177.google.com with SMTP id f8so2934179wiw.16 for ; Wed, 21 May 2014 08:35:25 -0700 (PDT) In-Reply-To: <87vbt6l98n.fsf@algol.ziiuu.com> (Thomas Morgan's message of "Thu, 15 May 2014 22:59:04 -0400") 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: Thomas Morgan Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi Thomas, Thomas Morgan writes: > Here is a recipe for what might be another manifestation > of this bug. Thanks for this new report -- can you apply this patch against maint and see if it works correctly? Not only for the bug at stake, but all kind of agenda filtering, rescheduling, clocking, etc. The tests are pretty weak for the agenda (my bad), and this is quite a significant rewrite, using text properties instead of overlays for agenda filtering. Thanks in advance! --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=org-use-properties-for-agenda-filtering.patch diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index fe32202..c1a2e1b 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2092,11 +2092,8 @@ When nil, `q' will kill the single agenda buffer." org-agenda-info org-agenda-pre-window-conf org-agenda-columns-active - org-agenda-tag-filter-overlays org-agenda-tag-filter - org-agenda-cat-filter-overlays org-agenda-category-filter - org-agenda-re-filter-overlays org-agenda-regexp-filter org-agenda-markers org-agenda-last-search-view-search-was-boolean @@ -3324,19 +3321,12 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write." (org-let (if nosettings nil org-agenda-exporter-settings) '(save-excursion (save-window-excursion - (org-agenda-mark-filtered-text) (let ((bs (copy-sequence (buffer-string))) beg content) - (org-agenda-unmark-filtered-text) (with-temp-buffer (rename-buffer org-agenda-write-buffer-name t) (set-buffer-modified-p nil) (insert bs) (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)))) (run-hooks 'org-agenda-before-write-hook) (cond ((org-bound-and-true-p org-mobile-creating-agendas) @@ -3402,28 +3392,6 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write." org-agenda-buffer-name))) (when open (org-open-file file))) -(defvar org-agenda-tag-filter-overlays nil) -(defvar org-agenda-cat-filter-overlays nil) -(defvar org-agenda-re-filter-overlays nil) - -(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 (overlay-buffer o) (current-buffer)) - (put-text-property - (overlay-start o) (overlay-end o) - 'org-filtered t))) - (append org-agenda-tag-filter-overlays - org-agenda-cat-filter-overlays - org-agenda-re-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." @@ -3432,7 +3400,7 @@ VALUE defaults to t." (while (setq beg (text-property-any (point-min) (point-max) property value)) (delete-region - beg (or (next-single-property-change beg 'org-filtered) + beg (or (next-single-property-change beg property) (point-max)))))) (defun org-agenda-add-entry-text () @@ -7400,7 +7368,8 @@ With two prefix arguments, remove the regexp filters." (when org-agenda-category-filter (org-agenda-filter-show-all-cat)) (when org-agenda-regexp-filter - (org-agenda-filter-show-all-re))) + (org-agenda-filter-show-all-re)) + (org-agenda-finalize)) (defun org-agenda-filter-by-tag (strip &optional char narrow) "Keep only those lines in the agenda buffer that have a specific tag. @@ -7672,50 +7641,31 @@ When NO-OPERATOR is non-nil, do not add the + operator to returned tags." (defun org-agenda-filter-hide-line (type) "Hide lines with TYPE in the agenda buffer." (let* ((b (max (point-min) (1- (point-at-bol)))) - (e (point-at-eol)) - (ov (make-overlay b e))) - (overlay-put ov 'invisible t) - (overlay-put ov 'intangible t) - (overlay-put ov 'type type) - (cond ((eq type 'tag) (push ov org-agenda-tag-filter-overlays)) - ((eq type 'category) (push ov org-agenda-cat-filter-overlays)) - ((eq type 'regexp) (push ov org-agenda-re-filter-overlays))))) - -(defun org-agenda-fix-tags-filter-overlays-at (&optional pos) - (setq pos (or pos (point))) - (save-excursion - (dolist (ov (overlays-at pos)) - (when (and (overlay-get ov 'invisible) - (eq (overlay-get ov 'type) 'tag)) - (goto-char pos) - (if (< (overlay-start ov) (point-at-eol)) - (move-overlay ov (point-at-eol) - (overlay-end ov))))))) + (e (point-at-eol))) + (let ((inhibit-read-only t)) + (add-text-properties + b e `(invisible t org-filtered t org-filter-type ,type))))) -(defun org-agenda-filter-show-all-tag nil - "Remove tag filter overlays from the agenda buffer." - (mapc 'delete-overlay org-agenda-tag-filter-overlays) - (setq org-agenda-tag-filter-overlays nil - org-agenda-tag-filter nil - org-agenda-filter-form nil) +(defun org-agenda-remove-filter (type) + (interactive) + "Remove filter of type TYPE from the agenda buffer." + (goto-char (point-min)) + (let ((inhibit-read-only t) pos) + (while (setq pos (text-property-any (point) (point-max) 'org-filter-type type)) + (goto-char pos) + (remove-text-properties + (point) (next-single-property-change (point) 'org-filter-type) + `(invisible t org-filter-type ,type)))) + (set (intern (format "org-agenda-%s-filter" (intern-soft type))) nil) + (setq org-agenda-filter-form nil) (org-agenda-set-mode-name)) +(defun org-agenda-filter-show-all-tag nil + (org-agenda-remove-filter 'tag)) (defun org-agenda-filter-show-all-re nil - "Remove regexp filter overlays from the agenda buffer." - (mapc 'delete-overlay org-agenda-re-filter-overlays) - (setq org-agenda-re-filter-overlays nil - org-agenda-regexp-filter nil - org-agenda-filter-form nil) - (org-agenda-set-mode-name)) - + (org-agenda-remove-filter 'regexp)) (defun org-agenda-filter-show-all-cat nil - "Remove category filter overlays from the agenda buffer." - (mapc 'delete-overlay org-agenda-cat-filter-overlays) - (setq org-agenda-cat-filter-overlays nil - org-agenda-filtered-by-category nil - org-agenda-category-filter nil - org-agenda-filter-form nil) - (org-agenda-set-mode-name)) + (org-agenda-remove-filter 'category)) (defun org-agenda-manipulate-query-add () "Manipulate the query by adding a search term with positive selection. @@ -9180,8 +9130,6 @@ Called with a universal prefix arg, show the priority instead of setting it." (when (equal marker (org-get-at-bol 'org-marker)) (remove-text-properties (point-at-bol) (point-at-eol) '(display)) (org-move-to-column (- (window-width) (length stamp)) t) - - (org-agenda-fix-tags-filter-overlays-at (point)) (if (featurep 'xemacs) ;; Use `duplicable' property to trigger undo recording (let ((ex (make-extent nil nil)) --=-=-= Content-Type: text/plain -- Bastien --=-=-=--