emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
@ 2012-05-21 11:52 Sebastien Vauban
  2012-05-21 13:26 ` Bastien
  2012-06-04 12:58 ` Sebastien Vauban
  0 siblings, 2 replies; 11+ messages in thread
From: Sebastien Vauban @ 2012-05-21 11:52 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

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.

Do you see that behavior as well?

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  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-06-04 12:58 ` Sebastien Vauban
  1 sibling, 1 reply; 11+ messages in thread
From: Bastien @ 2012-05-21 13:26 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



"Sebastien Vauban"
<wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:

> 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.
>
> Do you see that behavior as well?

Nope.  

Any help on how to reproduce this?  Since which commit do you see this?

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  2012-05-21 13:26 ` Bastien
@ 2012-05-21 15:28   ` François Pinard
  2012-05-21 15:43     ` Nick Dokos
  0 siblings, 1 reply; 11+ messages in thread
From: François Pinard @ 2012-05-21 15:28 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bzg@gnu.org> writes:

> "Sebastien Vauban"
> <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:

>> 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.  Do you see
>> that behavior as well?

> Nope.  Any help on how to reproduce this?  Since which commit do you
> see this?

I'm not fully sure, but I think I saw this diagnostic already.  It was
quite a while ago, and the problem disappeared by upgrading.  Could it be
that, by some operational error, Sebastien is using some old Org code?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  2012-05-21 15:28   ` François Pinard
@ 2012-05-21 15:43     ` Nick Dokos
  2012-05-21 16:05       ` Nick Dokos
  0 siblings, 1 reply; 11+ messages in thread
From: Nick Dokos @ 2012-05-21 15:43 UTC (permalink / raw)
  To: =?utf-8?Q?Fran=C3=A7ois_Pinard?=; +Cc: emacs-orgmode

François Pinard <pinard@iro.umontreal.ca> wrote:

> Bastien <bzg@gnu.org> writes:
> 
> > "Sebastien Vauban"
> > <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
> 
> >> 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.  Do you see
> >> that behavior as well?
> 
> > Nope.  Any help on how to reproduce this?  Since which commit do you
> > see this?
> 
> I'm not fully sure, but I think I saw this diagnostic already.  It was
> quite a while ago, and the problem disappeared by upgrading.  Could it be
> that, by some operational error, Sebastien is using some old Org code?
> 

The message is generated from org-check-agenda-file, so just
edebug-defun this function (C-u M-C-x), try the operation and when (if)
it stops, get a backtrace with ``d''.

Nick

PS. I don't see this bahavior at all.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  2012-05-21 15:43     ` Nick Dokos
@ 2012-05-21 16:05       ` Nick Dokos
  0 siblings, 0 replies; 11+ messages in thread
From: Nick Dokos @ 2012-05-21 16:05 UTC (permalink / raw)
  Cc: =?us-ascii?Q?=3D=3Futf-8=3FQ=3FFran=3DC3=3DA7ois=5FPinard=3F=3D?=,
	emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> wrote:

> François Pinard <pinard@iro.umontreal.ca> wrote:
> 
> > Bastien <bzg@gnu.org> writes:
> > 
> > > "Sebastien Vauban"
> > > <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
> > 
> > >> 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.  Do you see
> > >> that behavior as well?
> > 
> > > Nope.  Any help on how to reproduce this?  Since which commit do you
> > > see this?
> > 
> > I'm not fully sure, but I think I saw this diagnostic already.  It was
> > quite a while ago, and the problem disappeared by upgrading.  Could it be
> > that, by some operational error, Sebastien is using some old Org code?
> > 
> 
> The message is generated from org-check-agenda-file, so just
> edebug-defun this function (C-u M-C-x), try the operation and when (if)
> it stops, get a backtrace with ``d''.
> 

It's better to add a (debug) call before the (message ...) call
instead. That way, existing files will not clutter the chase:

--8<---------------cut here---------------start------------->8---
(defun org-check-agenda-file (file)
  "Make sure FILE exists.  If not, ask user what to do."
  (when (not (file-exists-p file))
    (debug)
    (message "non-existent agenda file %s. [R]emove from list or [A]bort?"
	     (abbreviate-file-name file))
    ...
--8<---------------cut here---------------end--------------->8---

> Nick
> 
> PS. I don't see this bahavior at all.
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  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-06-04 12:58 ` Sebastien Vauban
  2012-06-04 13:35   ` Nick Dokos
  1 sibling, 1 reply; 11+ messages in thread
From: Sebastien Vauban @ 2012-06-04 12:58 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

Thanks a lot Nick, François, Bastien... and Carsten who put me on right
tracks...

"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?

Best regards,
  Seb

[1] See http://orgmode.org/worg/org-hacks.html#sec-1-7-1

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  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
  0 siblings, 2 replies; 11+ messages in thread
From: Nick Dokos @ 2012-06-04 13:35 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Sebastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:

> Hello,
> 
> Thanks a lot Nick, Fran=C3=A7ois, Bastien... and Carsten who put me on right
> tracks...
> 
> "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.

Nick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  2012-06-04 13:35   ` Nick Dokos
@ 2012-06-04 14:29     ` Sylvain Rousseau
  2012-06-04 14:34     ` Sebastien Vauban
  1 sibling, 0 replies; 11+ messages in thread
From: Sylvain Rousseau @ 2012-06-04 14:29 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Sebastien Vauban, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 347 bytes --]

Hi,

i have the same problem. It appears that `org-map-entries' fails if the
file does not yet exist. A solution could be to add to
`dmj/org-remove-redundant-tags' a `file-exists-p' condition but you will
have to save twice to clean the file; another is to patch `org-map-entries'
that should succeed even if the file does not exist...


Sylvain.

[-- Attachment #2: Type: text/html, Size: 387 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  2012-06-04 13:35   ` Nick Dokos
  2012-06-04 14:29     ` Sylvain Rousseau
@ 2012-06-04 14:34     ` Sebastien Vauban
  2012-06-04 16:13       ` Nick Dokos
  1 sibling, 1 reply; 11+ messages in thread
From: Sebastien Vauban @ 2012-06-04 14:34 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  2012-06-04 14:34     ` Sebastien Vauban
@ 2012-06-04 16:13       ` Nick Dokos
  2012-06-04 16:45         ` Sebastien Vauban
  0 siblings, 1 reply; 11+ messages in thread
From: Nick Dokos @ 2012-06-04 16:13 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Sebastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:

>   (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")
>   ...
>   org-prepare-agenda-buffers(("c:/home/sva/Projects/ttttttttttttttt.txt"))
>   ...
>   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)
>   ...
>   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)
> 

org-map-entries calls org-prepare-agenda-buffers like this:

		(org-prepare-agenda-buffers
		 (list (buffer-file-name (current-buffer))))

In turn, this calls org-check-agenda-file() and if the current buffer
has not been written out yet, this pops the question.

So there is a chicken-and-egg problem here, because you added the
function to the before-save hook. Not sure how to resolve it though.

Nick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: non-existent agenda file ~/file.txt. [R]emove from list or [A]bort?
  2012-06-04 16:13       ` Nick Dokos
@ 2012-06-04 16:45         ` Sebastien Vauban
  0 siblings, 0 replies; 11+ messages in thread
From: Sebastien Vauban @ 2012-06-04 16:45 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Nick,

Nick Dokos wrote:
> Sebastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> wrote:
>
>>   (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")
>>   ...
>>   org-prepare-agenda-buffers(("c:/home/sva/Projects/ttttttttttttttt.txt"))
>>   ...
>>   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)
>>   ...
>>   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)
>
> org-map-entries calls org-prepare-agenda-buffers like this:
>
> 		(org-prepare-agenda-buffers
> 		 (list (buffer-file-name (current-buffer))))
>
> In turn, this calls org-check-agenda-file() and if the current buffer
> has not been written out yet, this pops the question.
>
> So there is a chicken-and-egg problem here, because you added the
> function to the before-save hook. Not sure how to resolve it though.

I've opted for the solution proposed by Sylvain (test that the file exists):

#+begin_src emacs-lisp
        (add-hook 'before-save-hook
                  '(lambda ()
                     (when (eq major-mode 'org-mode)
                       (org-align-all-tags)
                       (org-update-all-dblocks)
                       (org-table-iterate-buffer-tables)
                       (when (file-exists-p (buffer-file-name (current-buffer)))
                         (my/org-remove-redundant-tags))
                       )))
#+end_src

Redundant tags is something I won't do as soon as I create a file for the
first time. Hence, I consider this as really "good enough", even if not
perfect.

Thanks for your help!

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-06-04 16:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2012-06-04 16:13       ` Nick Dokos
2012-06-04 16:45         ` Sebastien Vauban

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).