From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Dunn Subject: Re: Bug in Sticky Agendas Date: Fri, 05 Jan 2018 18:15:05 -0500 Message-ID: <87incfrj7q.fsf@gnu.org> References: <87shbriot5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXbEI-0003sR-3D for emacs-orgmode@gnu.org; Fri, 05 Jan 2018 18:16:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXbEC-0001cu-Ky for emacs-orgmode@gnu.org; Fri, 05 Jan 2018 18:16:49 -0500 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXbEC-0001cZ-4u for emacs-orgmode@gnu.org; Fri, 05 Jan 2018 18:16:44 -0500 Received: from [2604:6000:1006:8725:afb2:757c:dc05:6d23] (port=50444 helo=escafil) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eXbEB-0005bX-Pd for emacs-orgmode@gnu.org; Fri, 05 Jan 2018 18:16:43 -0500 In-Reply-To: <87shbriot5.fsf@gnu.org> (Ian Dunn's message of "Sat, 30 Dec 2017 22:00:54 -0500") 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" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain >>>>> "Ian" == Ian Dunn writes: Ian> I've got a few tasks that I don't want appearing in the Ian> daily agenda, so I tag them with agenda_exclude and set Ian> org-agenda-skip-function to skip any entries with that tag for Ian> my daily agenda: Ian> (defun id/org-skip-by-tag (&rest tags) (if (not (apply Ian> 'org-entry-has-tags-p tags)) nil (save-excursion Ian> (outline-next-visible-heading 1) (point)))) Ian> (let* ((agenda-skip '(org-agenda-skip-function (lambda nil Ian> (id/org-skip-by-tag "agenda_exclude"))))) (setq Ian> org-agenda-custom-commands `(("d" "Day View" agenda "" Ian> ((org-agenda-span 'day) ,agenda-skip)) ("T" . "Tags View") Ian> ("Tn" "Nightly" tags-todo "nightly&TODO==\"TODO\"")))) Ian> As you can see, I've got a second agenda view for my nightly Ian> checklist. So here's my problem: the skip-function is unset if Ian> I try using the nightly view. I went ahead and looked into this myself. Looks like the issue is that the properties (lprops) are set using symbol properties with org-agenda-redo-command, which is buffer-local. However, according to the elisp manual (at least for the upcoming 26.1 release), symbol properties aren't buffer-local; only the value itself is. Thus, lprops are overridden by a new agenda. I've created the following patch to address this. The symbol property is used as a temporary variable, but the actual lprops are stored as a buffer-local variable to each agenda buffer. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=org.diff diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index a9ebb793b..5226ef486 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2142,6 +2142,7 @@ When nil, `q' will kill the single agenda buffer." (defvar org-agenda-this-buffer-is-sticky nil) (defvar org-agenda-last-indirect-buffer nil "Last buffer loaded by `org-agenda-tree-to-indirect-buffer'.") +(defvar org-agenda-lprops nil) (defconst org-agenda-local-vars '(org-agenda-this-buffer-name @@ -2170,6 +2171,7 @@ When nil, `q' will kill the single agenda buffer." org-agenda-filtered-by-category org-agenda-filter-form org-agenda-cycle-counter + org-agenda-lprops org-agenda-last-prefix-arg) "Variables that must be local in agenda buffers to allow multiple buffers.") @@ -3749,6 +3751,10 @@ FILTER-ALIST is an alist of filters we need to apply when (org-uniquify org-done-keywords-for-agenda)) (setq org-agenda-last-prefix-arg current-prefix-arg) (setq org-agenda-this-buffer-name org-agenda-buffer-name) + ;; Don't set these until we know we're in the agenda buffer, + ;; and we know they're valid. + (setq org-agenda-lprops (or org-agenda-lprops + (get 'org-agenda-redo-command 'org-lprops))) (and name (not org-agenda-name) (setq-local org-agenda-name name))) (setq buffer-read-only nil)))) @@ -7312,7 +7318,7 @@ in the agenda." (cols org-agenda-columns-active) (line (org-current-line)) (window-line (- line (org-current-line (window-start)))) - (lprops (get 'org-agenda-redo-command 'org-lprops)) + (lprops org-agenda-lprops) (redo-cmd (get-text-property p 'org-redo-cmd)) (last-args (get-text-property p 'org-last-args)) (org-agenda-overriding-cmd (get-text-property p 'org-series-cmd)) --=-=-= Content-Type: text/plain -- Ian Dunn --=-=-=--