emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Tassilo Horn <tassilo@member.fsf.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: Help debugging a problem when saving org-agenda files with C-x s
Date: Sat, 16 May 2009 17:14:18 +0200	[thread overview]
Message-ID: <515DB452-F8AD-4DD3-AD35-018F29398093@gmail.com> (raw)
In-Reply-To: <87hbznh6ip.fsf@thinkpad.tsdh.de>


On May 14, 2009, at 8:41 PM, Tassilo Horn wrote:

> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> Did you restart Emacs?  My idea was that the first time you call  
>> this,
>> you change the file name of a buffer, and the second time the problem
>> happens.
>
> First, I only evaled my function anew, but now I tried with a new  
> emacs
> instance and the error is still the same.
>
> But now I can see what happens (but I don't have a solution right  
> now):
>
> - `C-x s' saves the modified org buffer (I checked that the changes
>   are saved to disk)
>
> - my function is triggered cause it's in `after-save-hook' buffer
>   locally

Calling such functions recursively is never a good idea, even if
it is accidental recursion in this case.

You could and should turn off your hook function in after-safe-hook
for the duration of your command.  On common way to do this is to
make it dependent on a variable and bind this variable dynamically
while you run the hook function


Like

(defvar do-my-hook t)

...

(defun th-org-update-agenda-file (&optional force)
(interactive)
(when (and do-my-hook
            (eq major-mode 'org-mode)
            (member buffer-file-name org-agenda-files))
   (save-excursion
     (save-window-excursion
       (let ((do-my-hook nil)
	     (file "/tmp/org-agenda.txt"))
         (org-agenda-list)
         (org-write-agenda file))))))


HTH

- Carsten



>
> - somehow the buffer associated with the saved org file uni.org is
>   erased and org tries to insert an agendo into this buffer (only one
>   propertized line)
>
>          Week-agenda (W20):
>
>   and the major mode is now `org-agenda-mode', which results in the
>   error I posted when org tries to create the agenda page.
>
> Bye,
> Tassilo
> -- 
> [Emacs] is written in Lisp, which is the only computer language that  
> is
> beautiful.  -- Neal Stephenson, _In the Beginning was the Command  
> Line_

      reply	other threads:[~2009-05-16 17:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-13  6:12 Help debugging a problem when saving org-agenda files with C-x s Tassilo Horn
2009-05-13  8:55 ` Tassilo Horn
2009-05-14 14:17 ` Carsten Dominik
2009-05-14 16:43   ` Tassilo Horn
2009-05-14 17:28     ` Carsten Dominik
2009-05-14 18:41       ` Tassilo Horn
2009-05-16 15:14         ` Carsten Dominik [this message]

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=515DB452-F8AD-4DD3-AD35-018F29398093@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tassilo@member.fsf.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).