From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sebastien Vauban" Subject: Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort? Date: Mon, 04 Jun 2012 16:34:51 +0200 Message-ID: <80sjebkuwk.fsf@somewhere.org> References: <804nr9sqcz.fsf@somewhere.org> <80lik3nsim.fsf@somewhere.org> <24826.1338816954@alphaville> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: 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-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hi Nick, Nick Dokos wrote: > Sebastien Vauban wrote: >> "Sebastien Vauban" wrote: >>> These last days, I've observed that, whenever creating a new Org file (= to >>> be precise, when saving it), I'm asked: >>> >>> non-existent agenda file ~/file.txt. [R]emove from list or [A]bort? >>> >>> I'm then forced to answer `R' for the save to be done. >>=20 >> I found the responsible: the call to `dmj/org-remove-redundant-tags'[1] = in >> the `before-save-hook': >>=20 >> #+begin_src emacs-lisp >> ;; make sure that things are clean and always up-to-date >> (add-hook 'before-save-hook >> '(lambda () >> (when (eq major-mode 'org-mode) >> (dmj/org-remove-redundant-tags) >> (org-align-all-tags) >> (org-update-all-dblocks) >> (org-table-iterate-buffer-tables) >> ))) >> #+end_src >>=20 >> Without it, the above problem disappears. >>=20 >> Any idea on how to get that work done (i.e., removing redundant tags when >> saving the file), without bringing the problem back to the scene? > > Did you get a backtrace? I don't think you posted one here. I looked at > the function you fingered and there is nothing in there to raise my > hackles (but maybe I'm blind: it wouldn't be the first time). A > backtrace would be *much* more useful imo. Here is one, as you asked (weeks ago=C2=A0;-(): --8<---------------cut here---------------start------------->8--- Debugger entered: nil (progn (debug) (message "non-existent agenda file %s. [R]emove from list = or [A]bort?" (abbreviate-file-name file)) (let ((r (downcase (read-char-exc= lusive)))) (cond ((equal r 114) (org-remove-file file) (throw (quote nextfi= le) t)) (t (error "Abort"))))) (if (not (file-exists-p file)) (progn (debug) (message "non-existent agen= da file %s. [R]emove from list or [A]bort?" (abbreviate-file-name file)) (l= et ((r (downcase (read-char-exclusive)))) (cond ((equal r 114) (org-remove-= file file) (throw (quote nextfile) t)) (t (error "Abort")))))) (when (not (file-exists-p file)) (debug) (message "non-existent agenda fi= le %s. [R]emove from list or [A]bort?" (abbreviate-file-name file)) (let ((= r (downcase (read-char-exclusive)))) (cond ((equal r 114) (org-remove-file = file) (throw (quote nextfile) t)) (t (error "Abort"))))) org-check-agenda-file("c:/home/sva/Projects/ttttttttttttttt.txt") (if (bufferp file) (set-buffer file) (org-check-agenda-file file) (set-bu= ffer (org-get-agenda-file-buffer file))) (catch (quote nextfile) (if (bufferp file) (set-buffer file) (org-check-a= genda-file file) (set-buffer (org-get-agenda-file-buffer file))) (widen) (s= etq bmp (buffer-modified-p)) (org-refresh-category-properties) (setq org-to= do-keywords-for-agenda (append org-todo-keywords-for-agenda org-todo-keywor= ds-1)) (setq org-done-keywords-for-agenda (append org-done-keywords-for-age= nda org-done-keywords)) (setq org-todo-keyword-alist-for-agenda (append org= -todo-keyword-alist-for-agenda org-todo-key-alist)) (setq org-drawers-for-a= genda (append org-drawers-for-agenda org-drawers)) (setq org-tag-alist-for-= agenda (append org-tag-alist-for-agenda org-tag-alist)) (save-excursion (re= move-text-properties (point-min) (point-max) pall) (when org-agenda-skip-ar= chived-trees (goto-char (point-min)) (while (re-search-forward rea nil t) (= if (org-at-heading-p t) (add-text-properties (point-at-bol) (org-end-of-sub= tree t) pa)))) (goto-char (point-min)) (setq re (format org-heading-keyword= -regexp-format org-comment-string)) (while (re-search-forward re nil t) (ad= d-text-properties (match-beginning 0) (org-end-of-subtree t) pc))) (set-buf= fer-modified-p bmp)) (while (setq file (pop files)) (catch (quote nextfile) (if (bufferp file)= (set-buffer file) (org-check-agenda-file file) (set-buffer (org-get-agenda= -file-buffer file))) (widen) (setq bmp (buffer-modified-p)) (org-refresh-ca= tegory-properties) (setq org-todo-keywords-for-agenda (append org-todo-keyw= ords-for-agenda org-todo-keywords-1)) (setq org-done-keywords-for-agenda (a= ppend org-done-keywords-for-agenda org-done-keywords)) (setq org-todo-keywo= rd-alist-for-agenda (append org-todo-keyword-alist-for-agenda org-todo-key-= alist)) (setq org-drawers-for-agenda (append org-drawers-for-agenda org-dra= wers)) (setq org-tag-alist-for-agenda (append org-tag-alist-for-agenda org-= tag-alist)) (save-excursion (remove-text-properties (point-min) (point-max)= pall) (when org-agenda-skip-archived-trees (goto-char (point-min)) (while = (re-search-forward rea nil t) (if (org-at-heading-p t) (add-text-properties= (point-at-bol) (org-end-of-subtree t) pa)))) (goto-char (point-min)) (setq= re (format org-heading-keyword-regexp-format org-comment-string)) (while (= re-search-forward re nil t) (add-text-properties (match-beginning 0) (org-e= nd-of-subtree t) pc))) (set-buffer-modified-p bmp))) (save-restriction (while (setq file (pop files)) (catch (quote nextfile) = (if (bufferp file) (set-buffer file) (org-check-agenda-file file) (set-buff= er (org-get-agenda-file-buffer file))) (widen) (setq bmp (buffer-modified-p= )) (org-refresh-category-properties) (setq org-todo-keywords-for-agenda (ap= pend org-todo-keywords-for-agenda org-todo-keywords-1)) (setq org-done-keyw= ords-for-agenda (append org-done-keywords-for-agenda org-done-keywords)) (s= etq org-todo-keyword-alist-for-agenda (append org-todo-keyword-alist-for-ag= enda org-todo-key-alist)) (setq org-drawers-for-agenda (append org-drawers-= for-agenda org-drawers)) (setq org-tag-alist-for-agenda (append org-tag-ali= st-for-agenda org-tag-alist)) (save-excursion (remove-text-properties (poin= t-min) (point-max) pall) (when org-agenda-skip-archived-trees (goto-char (p= oint-min)) (while (re-search-forward rea nil t) (if (org-at-heading-p t) (a= dd-text-properties ... ... pa)))) (goto-char (point-min)) (setq re (format = org-heading-keyword-regexp-format org-comment-string)) (while (re-search-fo= rward re nil t) (add-text-properties (match-beginning 0) (org-end-of-subtre= e t) pc))) (set-buffer-modified-p bmp)))) (save-excursion (save-restriction (while (setq file (pop files)) (catch (= quote nextfile) (if (bufferp file) (set-buffer file) (org-check-agenda-file= file) (set-buffer (org-get-agenda-file-buffer file))) (widen) (setq bmp (b= uffer-modified-p)) (org-refresh-category-properties) (setq org-todo-keyword= s-for-agenda (append org-todo-keywords-for-agenda org-todo-keywords-1)) (se= tq org-done-keywords-for-agenda (append org-done-keywords-for-agenda org-do= ne-keywords)) (setq org-todo-keyword-alist-for-agenda (append org-todo-keyw= ord-alist-for-agenda org-todo-key-alist)) (setq org-drawers-for-agenda (app= end org-drawers-for-agenda org-drawers)) (setq org-tag-alist-for-agenda (ap= pend org-tag-alist-for-agenda org-tag-alist)) (save-excursion (remove-text-= properties (point-min) (point-max) pall) (when org-agenda-skip-archived-tre= es (goto-char (point-min)) (while (re-search-forward rea nil t) (if ... ...= ))) (goto-char (point-min)) (setq re (format org-heading-keyword-regexp-for= mat org-comment-string)) (while (re-search-forward re nil t) (add-text-prop= erties (match-beginning 0) (org-end-of-subtree t) pc))) (set-buffer-modifie= d-p bmp))))) (let ((pa (quote (:org-archived t))) (pc (quote (:org-comment t))) (pall = (quote (:org-archived t :org-comment t))) (inhibit-read-only t) (rea (conca= t ":" org-archive-tag ":")) bmp file re) (save-excursion (save-restriction = (while (setq file (pop files)) (catch (quote nextfile) (if (bufferp file) (= set-buffer file) (org-check-agenda-file file) (set-buffer (org-get-agenda-f= ile-buffer file))) (widen) (setq bmp (buffer-modified-p)) (org-refresh-cate= gory-properties) (setq org-todo-keywords-for-agenda (append org-todo-keywor= ds-for-agenda org-todo-keywords-1)) (setq org-done-keywords-for-agenda (app= end org-done-keywords-for-agenda org-done-keywords)) (setq org-todo-keyword= -alist-for-agenda (append org-todo-keyword-alist-for-agenda org-todo-key-al= ist)) (setq org-drawers-for-agenda (append org-drawers-for-agenda org-drawe= rs)) (setq org-tag-alist-for-agenda (append org-tag-alist-for-agenda org-ta= g-alist)) (save-excursion (remove-text-properties (point-min) (point-max) p= all) (when org-agenda-skip-archived-trees (goto-char ...) (while ... ...)) = (goto-char (point-min)) (setq re (format org-heading-keyword-regexp-format = org-comment-string)) (while (re-search-forward re nil t) (add-text-properti= es ... ... pc))) (set-buffer-modified-p bmp))))) (setq org-todo-keywords-fo= r-agenda (org-uniquify org-todo-keywords-for-agenda)) (setq org-todo-keywor= d-alist-for-agenda (org-uniquify org-todo-keyword-alist-for-agenda) org-tag= -alist-for-agenda (org-uniquify org-tag-alist-for-agenda))) org-prepare-agenda-buffers(("c:/home/sva/Projects/ttttttttttttttt.txt")) (progn (org-prepare-agenda-buffers (list (buffer-file-name (current-buffe= r)))) (setq res (org-scan-tags func matcher todo-only start-level))) (if (not scope) (progn (org-prepare-agenda-buffers (list (buffer-file-nam= e (current-buffer)))) (setq res (org-scan-tags func matcher todo-only start= -level))) (cond ((and scope (listp scope) (symbolp (car scope))) (setq scop= e (eval scope))) ((eq scope (quote agenda)) (setq scope (org-agenda-files t= ))) ((eq scope (quote agenda-with-archives)) (setq scope (org-agenda-files = t)) (setq scope (org-add-archive-files scope))) ((eq scope (quote file)) (s= etq scope (list (buffer-file-name)))) ((eq scope (quote file-with-archives)= ) (setq scope (org-add-archive-files (list (buffer-file-name)))))) (org-pre= pare-agenda-buffers scope) (while (setq file (pop scope)) (with-current-buf= fer (org-find-base-buffer-visiting file) (save-excursion (save-restriction = (widen) (goto-char (point-min)) (setq res (append res (org-scan-tags func m= atcher todo-only)))))))) (save-restriction (cond ((eq scope (quote tree)) (org-back-to-heading t) = (org-narrow-to-subtree) (setq scope nil)) ((and (or (eq scope (quote region= )) (eq scope (quote region-start-level))) (org-region-active-p)) (when star= t-level (save-excursion (goto-char (region-beginning)) (unless (org-at-head= ing-p) (outline-next-heading)) (setq start-level (org-current-level)))) (na= rrow-to-region (region-beginning) (save-excursion (goto-char (region-end)) = (unless (and (bolp) (org-at-heading-p)) (outline-next-heading)) (point))) (= setq scope nil))) (if (not scope) (progn (org-prepare-agenda-buffers (list = (buffer-file-name (current-buffer)))) (setq res (org-scan-tags func matcher= todo-only start-level))) (cond ((and scope (listp scope) (symbolp (car sco= pe))) (setq scope (eval scope))) ((eq scope (quote agenda)) (setq scope (or= g-agenda-files t))) ((eq scope (quote agenda-with-archives)) (setq scope (o= rg-agenda-files t)) (setq scope (org-add-archive-files scope))) ((eq scope = (quote file)) (setq scope (list (buffer-file-name)))) ((eq scope (quote fil= e-with-archives)) (setq scope (org-add-archive-files (list (buffer-file-nam= e)))))) (org-prepare-agenda-buffers scope) (while (setq file (pop scope)) (= with-current-buffer (org-find-base-buffer-visiting file) (save-excursion (s= ave-restriction (widen) (goto-char (point-min)) (setq res (append res ...))= )))))) (save-excursion (save-restriction (cond ((eq scope (quote tree)) (org-bac= k-to-heading t) (org-narrow-to-subtree) (setq scope nil)) ((and (or (eq sco= pe (quote region)) (eq scope (quote region-start-level))) (org-region-activ= e-p)) (when start-level (save-excursion (goto-char (region-beginning)) (unl= ess (org-at-heading-p) (outline-next-heading)) (setq start-level (org-curre= nt-level)))) (narrow-to-region (region-beginning) (save-excursion (goto-cha= r (region-end)) (unless (and ... ...) (outline-next-heading)) (point))) (se= tq scope nil))) (if (not scope) (progn (org-prepare-agenda-buffers (list (b= uffer-file-name (current-buffer)))) (setq res (org-scan-tags func matcher t= odo-only start-level))) (cond ((and scope (listp scope) (symbolp (car scope= ))) (setq scope (eval scope))) ((eq scope (quote agenda)) (setq scope (org-= agenda-files t))) ((eq scope (quote agenda-with-archives)) (setq scope (org= -agenda-files t)) (setq scope (org-add-archive-files scope))) ((eq scope (q= uote file)) (setq scope (list (buffer-file-name)))) ((eq scope (quote file-= with-archives)) (setq scope (org-add-archive-files (list ...))))) (org-prep= are-agenda-buffers scope) (while (setq file (pop scope)) (with-current-buff= er (org-find-base-buffer-visiting file) (save-excursion (save-restriction (= widen) (goto-char ...) (setq res ...)))))))) (let* ((org-agenda-archives-mode nil) (org-agenda-skip-archived-trees (me= mq (quote archive) skip)) (org-agenda-skip-comment-trees (memq (quote comme= nt) skip)) (org-agenda-skip-function (car (org-delete-all (quote (comment a= rchive)) skip))) (org-tags-match-list-sublevels t) (start-level (eq scope (= quote region-start-level))) matcher file res org-todo-keywords-for-agenda o= rg-done-keywords-for-agenda org-todo-keyword-alist-for-agenda org-drawers-f= or-agenda org-tag-alist-for-agenda todo-only) (cond ((eq match t) (setq mat= cher t)) ((eq match nil) (setq matcher t)) (t (setq matcher (if match (cdr = (org-make-tags-matcher match)) t)))) (save-excursion (save-restriction (con= d ((eq scope (quote tree)) (org-back-to-heading t) (org-narrow-to-subtree) = (setq scope nil)) ((and (or (eq scope ...) (eq scope ...)) (org-region-acti= ve-p)) (when start-level (save-excursion (goto-char ...) (unless ... ...) (= setq start-level ...))) (narrow-to-region (region-beginning) (save-excursio= n (goto-char ...) (unless ... ...) (point))) (setq scope nil))) (if (not sc= ope) (progn (org-prepare-agenda-buffers (list (buffer-file-name ...))) (set= q res (org-scan-tags func matcher todo-only start-level))) (cond ((and scop= e (listp scope) (symbolp ...)) (setq scope (eval scope))) ((eq scope (quote= agenda)) (setq scope (org-agenda-files t))) ((eq scope (quote agenda-with-= archives)) (setq scope (org-agenda-files t)) (setq scope (org-add-archive-f= iles scope))) ((eq scope (quote file)) (setq scope (list ...))) ((eq scope = (quote file-with-archives)) (setq scope (org-add-archive-files ...)))) (org= -prepare-agenda-buffers scope) (while (setq file (pop scope)) (with-current= -buffer (org-find-base-buffer-visiting file) (save-excursion (save-restrict= ion ... ... ...))))))) res) (if (and (or (eq scope (quote region)) (eq scope (quote region-start-leve= l))) (not (org-region-active-p))) nil (let* ((org-agenda-archives-mode nil)= (org-agenda-skip-archived-trees (memq (quote archive) skip)) (org-agenda-s= kip-comment-trees (memq (quote comment) skip)) (org-agenda-skip-function (c= ar (org-delete-all (quote (comment archive)) skip))) (org-tags-match-list-s= ublevels t) (start-level (eq scope (quote region-start-level))) matcher fil= e res org-todo-keywords-for-agenda org-done-keywords-for-agenda org-todo-ke= yword-alist-for-agenda org-drawers-for-agenda org-tag-alist-for-agenda todo= -only) (cond ((eq match t) (setq matcher t)) ((eq match nil) (setq matcher = t)) (t (setq matcher (if match (cdr (org-make-tags-matcher match)) t)))) (s= ave-excursion (save-restriction (cond ((eq scope (quote tree)) (org-back-to= -heading t) (org-narrow-to-subtree) (setq scope nil)) ((and (or ... ...) (o= rg-region-active-p)) (when start-level (save-excursion ... ... ...)) (narro= w-to-region (region-beginning) (save-excursion ... ... ...)) (setq scope ni= l))) (if (not scope) (progn (org-prepare-agenda-buffers (list ...)) (setq r= es (org-scan-tags func matcher todo-only start-level))) (cond ((and scope .= .. ...) (setq scope ...)) ((eq scope ...) (setq scope ...)) ((eq scope ...)= (setq scope ...) (setq scope ...)) ((eq scope ...) (setq scope ...)) ((eq = scope ...) (setq scope ...))) (org-prepare-agenda-buffers scope) (while (se= tq file (pop scope)) (with-current-buffer (org-find-base-buffer-visiting fi= le) (save-excursion ...)))))) res)) (unless (and (or (eq scope (quote region)) (eq scope (quote region-start-= level))) (not (org-region-active-p))) (let* ((org-agenda-archives-mode nil)= (org-agenda-skip-archived-trees (memq (quote archive) skip)) (org-agenda-s= kip-comment-trees (memq (quote comment) skip)) (org-agenda-skip-function (c= ar (org-delete-all (quote (comment archive)) skip))) (org-tags-match-list-s= ublevels t) (start-level (eq scope (quote region-start-level))) matcher fil= e res org-todo-keywords-for-agenda org-done-keywords-for-agenda org-todo-ke= yword-alist-for-agenda org-drawers-for-agenda org-tag-alist-for-agenda todo= -only) (cond ((eq match t) (setq matcher t)) ((eq match nil) (setq matcher = t)) (t (setq matcher (if match (cdr (org-make-tags-matcher match)) t)))) (s= ave-excursion (save-restriction (cond ((eq scope (quote tree)) (org-back-to= -heading t) (org-narrow-to-subtree) (setq scope nil)) ((and (or ... ...) (o= rg-region-active-p)) (when start-level (save-excursion ... ... ...)) (narro= w-to-region (region-beginning) (save-excursion ... ... ...)) (setq scope ni= l))) (if (not scope) (progn (org-prepare-agenda-buffers (list ...)) (setq r= es (org-scan-tags func matcher todo-only start-level))) (cond ((and scope .= .. ...) (setq scope ...)) ((eq scope ...) (setq scope ...)) ((eq scope ...)= (setq scope ...) (setq scope ...)) ((eq scope ...) (setq scope ...)) ((eq = scope ...) (setq scope ...))) (org-prepare-agenda-buffers scope) (while (se= tq file (pop scope)) (with-current-buffer (org-find-base-buffer-visiting fi= le) (save-excursion ...)))))) res)) org-map-entries((lambda nil (let ((alltags (split-string (or (org-entry-g= et (point) "ALLTAGS") "") ":")) local inherited tag) (dolist (tag alltags) = (if (get-text-property 0 (quote inherited) tag) (push tag inherited) (push = tag local))) (dolist (tag local) (if (member tag inherited) (org-toggle-tag= tag (quote off)))))) t nil) (save-excursion (org-map-entries (quote (lambda nil (let ((alltags (split= -string ... ":")) local inherited tag) (dolist (tag alltags) (if (get-text-= property 0 ... tag) (push tag inherited) (push tag local))) (dolist (tag lo= cal) (if (member tag inherited) (org-toggle-tag tag ...)))))) t nil)) (progn (save-excursion (org-map-entries (quote (lambda nil (let ((alltags= ...) local inherited tag) (dolist (tag alltags) (if ... ... ...)) (dolist = (tag local) (if ... ...))))) t nil))) (if (eq major-mode (quote org-mode)) (progn (save-excursion (org-map-entr= ies (quote (lambda nil (let (... local inherited tag) (dolist ... ...) (dol= ist ... ...)))) t nil)))) (when (eq major-mode (quote org-mode)) (save-excursion (org-map-entries (= quote (lambda nil (let ((alltags ...) local inherited tag) (dolist (tag all= tags) (if ... ... ...)) (dolist (tag local) (if ... ...))))) t nil))) my/org-remove-redundant-tags() (progn (my/org-remove-redundant-tags) (org-align-all-tags) (org-update-al= l-dblocks) (org-table-iterate-buffer-tables)) (if (eq major-mode (quote org-mode)) (progn (my/org-remove-redundant-tags= ) (org-align-all-tags) (org-update-all-dblocks) (org-table-iterate-buffer-t= ables))) (when (eq major-mode (quote org-mode)) (my/org-remove-redundant-tags) (or= g-align-all-tags) (org-update-all-dblocks) (org-table-iterate-buffer-tables= )) (lambda nil (when (eq major-mode (quote org-mode)) (my/org-remove-redunda= nt-tags) (org-align-all-tags) (org-update-all-dblocks) (org-table-iterate-b= uffer-tables)))() run-hooks(before-save-hook) basic-save-buffer() save-buffer(1) call-interactively(save-buffer nil nil) --8<---------------cut here---------------end--------------->8--- Best regards, Seb --=20 Sebastien Vauban