emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] non-existent agenda file ~/file.txt. [R]emove from list or [A]bo


From: Sebastien Vauban
Subject: Re: [O] non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
Date: Mon, 04 Jun 2012 16:34:51 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.0.97 (windows-nt)

Hi Nick,

Nick Dokos wrote:
> Sebastien Vauban <address@hidden> 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.
>> 
>> I found the responsible: the call to `dmj/org-remove-redundant-tags'[1] in
>> the `before-save-hook':
>> 
>> #+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
>> 
>> Without it, the above problem disappears.
>> 
>> 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 ;-():

--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-exclusive)))) (cond ((equal r 114) (org-remove-file file) (throw 
(quote nextfile) t)) (t (error "Abort")))))
  (if (not (file-exists-p file)) (progn (debug) (message "non-existent agenda 
file %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"))))))
  (when (not (file-exists-p file)) (debug) (message "non-existent agenda file 
%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-buffer 
(org-get-agenda-file-buffer file)))
  (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-category-properties) (setq 
org-todo-keywords-for-agenda (append org-todo-keywords-for-agenda 
org-todo-keywords-1)) (setq org-done-keywords-for-agenda (append 
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-alist)) (setq org-drawers-for-agenda (append 
org-drawers-for-agenda org-drawers)) (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-end-of-subtree t) pc))) (set-buffer-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-category-properties) (setq org-todo-keywords-for-agenda (append 
org-todo-keywords-for-agenda org-todo-keywords-1)) (setq 
org-done-keywords-for-agenda (append 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-alist)) (setq 
org-drawers-for-agenda (append org-drawers-for-agenda org-drawers)) (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-end-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-buffer 
(org-get-agenda-file-buffer file))) (widen) (setq bmp (buffer-modified-p)) 
(org-refresh-category-properties) (setq org-todo-keywords-for-agenda (append 
org-todo-keywords-for-agenda org-todo-keywords-1)) (setq 
org-done-keywords-for-agenda (append 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-alist)) (setq 
org-drawers-for-agenda (append org-drawers-for-agenda org-drawers)) (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 ... 
... 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-end-of-subtree 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 
(buffer-modified-p)) (org-refresh-category-properties) (setq 
org-todo-keywords-for-agenda (append org-todo-keywords-for-agenda 
org-todo-keywords-1)) (setq org-done-keywords-for-agenda (append 
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-alist)) (setq org-drawers-for-agenda (append 
org-drawers-for-agenda org-drawers)) (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 ... ...))) (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-end-of-subtree t) pc))) (set-buffer-modified-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 (concat 
":" 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-file-buffer 
file))) (widen) (setq bmp (buffer-modified-p)) 
(org-refresh-category-properties) (setq org-todo-keywords-for-agenda (append 
org-todo-keywords-for-agenda org-todo-keywords-1)) (setq 
org-done-keywords-for-agenda (append 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-alist)) (setq 
org-drawers-for-agenda (append org-drawers-for-agenda org-drawers)) (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 ...) (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-properties 
... ... pc))) (set-buffer-modified-p bmp))))) (setq 
org-todo-keywords-for-agenda (org-uniquify org-todo-keywords-for-agenda)) (setq 
org-todo-keyword-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-buffer)))) (setq res (org-scan-tags func matcher todo-only 
start-level)))
  (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 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 (quote file)) (setq 
scope (list (buffer-file-name)))) ((eq scope (quote file-with-archives)) (setq 
scope (org-add-archive-files (list (buffer-file-name)))))) 
(org-prepare-agenda-buffers scope) (while (setq file (pop scope)) 
(with-current-buffer (org-find-base-buffer-visiting file) (save-excursion 
(save-restriction (widen) (goto-char (point-min)) (setq res (append res 
(org-scan-tags func matcher 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 start-level 
(save-excursion (goto-char (region-beginning)) (unless (org-at-heading-p) 
(outline-next-heading)) (setq start-level (org-current-level)))) 
(narrow-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 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 
(quote file)) (setq scope (list (buffer-file-name)))) ((eq scope (quote 
file-with-archives)) (setq scope (org-add-archive-files (list 
(buffer-file-name)))))) (org-prepare-agenda-buffers scope) (while (setq file 
(pop scope)) (with-current-buffer (org-find-base-buffer-visiting file) 
(save-excursion (save-restriction (widen) (goto-char (point-min)) (setq res 
(append res ...))))))))
  (save-excursion (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 start-level (save-excursion (goto-char 
(region-beginning)) (unless (org-at-heading-p) (outline-next-heading)) (setq 
start-level (org-current-level)))) (narrow-to-region (region-beginning) 
(save-excursion (goto-char (region-end)) (unless (and ... ...) 
(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 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 (quote file)) (setq scope (list 
(buffer-file-name)))) ((eq scope (quote file-with-archives)) (setq scope 
(org-add-archive-files (list ...))))) (org-prepare-agenda-buffers scope) (while 
(setq file (pop scope)) (with-current-buffer (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 (memq 
(quote archive) skip)) (org-agenda-skip-comment-trees (memq (quote comment) 
skip)) (org-agenda-skip-function (car (org-delete-all (quote (comment archive)) 
skip))) (org-tags-match-list-sublevels t) (start-level (eq scope (quote 
region-start-level))) matcher file res org-todo-keywords-for-agenda 
org-done-keywords-for-agenda org-todo-keyword-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)))) (save-excursion (save-restriction 
(cond ((eq scope (quote tree)) (org-back-to-heading t) (org-narrow-to-subtree) 
(setq scope nil)) ((and (or (eq scope ...) (eq scope ...)) 
(org-region-active-p)) (when start-level (save-excursion (goto-char ...) 
(unless ... ...) (setq start-level ...))) (narrow-to-region (region-beginning) 
(save-excursion (goto-char ...) (unless ... ...) (point))) (setq scope nil))) 
(if (not scope) (progn (org-prepare-agenda-buffers (list (buffer-file-name 
...))) (setq res (org-scan-tags func matcher todo-only start-level))) (cond 
((and scope (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-files 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-restriction ... ... ...))))))) res)
  (if (and (or (eq scope (quote region)) (eq scope (quote region-start-level))) 
(not (org-region-active-p))) nil (let* ((org-agenda-archives-mode nil) 
(org-agenda-skip-archived-trees (memq (quote archive) skip)) 
(org-agenda-skip-comment-trees (memq (quote comment) skip)) 
(org-agenda-skip-function (car (org-delete-all (quote (comment archive)) 
skip))) (org-tags-match-list-sublevels t) (start-level (eq scope (quote 
region-start-level))) matcher file res org-todo-keywords-for-agenda 
org-done-keywords-for-agenda org-todo-keyword-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)))) (save-excursion (save-restriction 
(cond ((eq scope (quote tree)) (org-back-to-heading t) (org-narrow-to-subtree) 
(setq scope nil)) ((and (or ... ...) (org-region-active-p)) (when start-level 
(save-excursion ... ... ...)) (narrow-to-region (region-beginning) 
(save-excursion ... ... ...)) (setq scope nil))) (if (not scope) (progn 
(org-prepare-agenda-buffers (list ...)) (setq res (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 (setq file (pop scope)) 
(with-current-buffer (org-find-base-buffer-visiting file) (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-skip-comment-trees (memq (quote comment) skip)) 
(org-agenda-skip-function (car (org-delete-all (quote (comment archive)) 
skip))) (org-tags-match-list-sublevels t) (start-level (eq scope (quote 
region-start-level))) matcher file res org-todo-keywords-for-agenda 
org-done-keywords-for-agenda org-todo-keyword-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)))) (save-excursion (save-restriction 
(cond ((eq scope (quote tree)) (org-back-to-heading t) (org-narrow-to-subtree) 
(setq scope nil)) ((and (or ... ...) (org-region-active-p)) (when start-level 
(save-excursion ... ... ...)) (narrow-to-region (region-beginning) 
(save-excursion ... ... ...)) (setq scope nil))) (if (not scope) (progn 
(org-prepare-agenda-buffers (list ...)) (setq res (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 (setq file (pop scope)) 
(with-current-buffer (org-find-base-buffer-visiting file) (save-excursion 
...)))))) res))
  org-map-entries((lambda nil (let ((alltags (split-string (or (org-entry-get 
(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 local) (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-entries 
(quote (lambda nil (let (... local inherited tag) (dolist ... ...) (dolist ... 
...)))) t nil))))
  (when (eq major-mode (quote org-mode)) (save-excursion (org-map-entries 
(quote (lambda nil (let ((alltags ...) local inherited tag) (dolist (tag 
alltags) (if ... ... ...)) (dolist (tag local) (if ... ...))))) t nil)))
  my/org-remove-redundant-tags()
  (progn (my/org-remove-redundant-tags) (org-align-all-tags) 
(org-update-all-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-tables)))
  (when (eq major-mode (quote org-mode)) (my/org-remove-redundant-tags) 
(org-align-all-tags) (org-update-all-dblocks) (org-table-iterate-buffer-tables))
  (lambda nil (when (eq major-mode (quote org-mode)) 
(my/org-remove-redundant-tags) (org-align-all-tags) (org-update-all-dblocks) 
(org-table-iterate-buffer-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

-- 
Sebastien Vauban




reply via email to

[Prev in Thread] Current Thread [Next in Thread]