emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
Date: Mon, 04 Jun 2012 16:34:51 +0200	[thread overview]
Message-ID: <80sjebkuwk.fsf@somewhere.org> (raw)
In-Reply-To: 24826.1338816954@alphaville

Hi Nick,

Nick Dokos wrote:
> Sebastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> 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

  parent reply	other threads:[~2012-06-04 14:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 11:52 non-existent agenda file ~/file.txt. [R]emove from list or [A]bort? Sebastien Vauban
2012-05-21 13:26 ` Bastien
2012-05-21 15:28   ` François Pinard
2012-05-21 15:43     ` Nick Dokos
2012-05-21 16:05       ` Nick Dokos
2012-06-04 12:58 ` Sebastien Vauban
2012-06-04 13:35   ` Nick Dokos
2012-06-04 14:29     ` Sylvain Rousseau
2012-06-04 14:34     ` Sebastien Vauban [this message]
2012-06-04 16:13       ` Nick Dokos
2012-06-04 16:45         ` Sebastien Vauban

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80sjebkuwk.fsf@somewhere.org \
    --to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).