[Top][All Lists]
[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 18:45:34 +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:
>
>> (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