Remember: Fix auto-save issues

Carsten Dominik writes:

> On Apr 26, 2009, at 12:08 AM, Samuel Wales wrote:
>
> > I noticed the following regarding
> > org-remember-backup-directory:
> >
> > 1) auto-saving does not save contents
> >    - solution: put (auto-save-mode 1) before or after (not
> >      sure which) the call to org-set-local in the
> >      following lines in org-remember:
> >
> >       # 	  (expand-file-name
> >       # 	   (format-time-string "remember-%Y-%m-%d-%H-%M-%S")
> >       # 	   org-remember-backup-directory))
> >       #     (save-buffer)
> >       #     (org-set-local 'auto-save-visited-file-name t))
> >       #   (when (save-excursion
>
> Done.
>
>
> > 2) save-buffer is called before there are any contents
> >    - this causes files without useful content to stick
> >      around in the dir if the buffer is killed or
> >      something.
> >    - solution: don't save the buffer; let auto-saving do
> >      that work.  will this work?
>
> Usually, the template expansion will have filled in stuff like
> links and initial contents, so I would prefer to keep the
> save-buffer here and let the user deal with the extra files.
>
> > 3) if you have auto-save-file-name-transforms set,
> >    auto-saving is done according to that variable instead
> >    of saving in place.
> >
> > I am now turning that variable off, locally in the remember buffer.
> > Does that fix the problem?
>
> - Carsten
>
> >    - solution: is this an emacs bug?  i am not sure.  the
> >      auto-saving should be done in place, saving in
> >      org-remember-backup-directory and not saving in the
> >      place where the transforms variable tells it to save.
> >      perhaps each user can kludge transforms or perhaps
> >      emacs needs fixing?  i have reached debugging ability
> >      limit.
This commit is contained in:
Carsten Dominik 2009-04-30 15:32:45 +02:00
parent 5f86fd7ae2
commit 47227d087a
2 changed files with 8 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2009-04-30 Carsten Dominik <carsten.dominik@gmail.com>
* org-remember.el (org-remember-apply-template): Improve auto-save
behavior.
2009-04-29 Carsten Dominik <carsten.dominik@gmail.com> 2009-04-29 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-preprocess): Also protect * org-latex.el (org-export-latex-preprocess): Also protect

View File

@ -596,12 +596,14 @@ to be run from that hook to function properly."
(when org-remember-backup-directory (when org-remember-backup-directory
(unless (file-directory-p org-remember-backup-directory) (unless (file-directory-p org-remember-backup-directory)
(make-directory org-remember-backup-directory)) (make-directory org-remember-backup-directory))
(org-set-local 'auto-save-file-name-transforms nil)
(setq buffer-file-name (setq buffer-file-name
(expand-file-name (expand-file-name
(format-time-string "remember-%Y-%m-%d-%H-%M-%S") (format-time-string "remember-%Y-%m-%d-%H-%M-%S")
org-remember-backup-directory)) org-remember-backup-directory))
(save-buffer) (save-buffer)
(org-set-local 'auto-save-visited-file-name t)) (org-set-local 'auto-save-visited-file-name t)
(auto-save-mode 1))
(when (save-excursion (when (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(re-search-forward "%!" nil t)) (re-search-forward "%!" nil t))