unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-commit] emacs/lisp saveplace.el
       [not found] <E1DcJHX-00083Y-00@savannah.gnu.org>
@ 2005-05-30  2:20 ` Karl Fogel
  2005-05-31  4:18   ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Karl Fogel @ 2005-05-30  2:20 UTC (permalink / raw)


"Richard M. Stallman" <rms@gnu.org> writes:
> Log message:
> 	(save-place-alist-to-file): Write the file using write-region.
>
> Index: lisp/saveplace.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/saveplace.el,v
> retrieving revision 1.31
> retrieving revision 1.32
> diff -u -r1.31 -r1.32
> --- lisp/saveplace.el	23 Apr 2005 16:40:24 -0000	1.31
> +++ lisp/saveplace.el	29 May 2005 08:36:26 -0000	1.32
> @@ -222,7 +222,8 @@
>                (t
>                 t))))
>  	(condition-case nil
> -	    (write-file file)
> +	    ;; Don't use write-file; we don't want this buffer to visit it.
> +	    (write-region (point-min) (point-max) file)
>  	  (file-error (message "Can't write %s" file)))
>          (kill-buffer (current-buffer))
>          (message "Saving places to %s...done" file)))))

What were the bad effects of using 'write-file'?

I ask because I'm wondering if the same change should be made to
'bookmark-write-file' in bookmark.el.

In fact, maybe there should be a bigger change to bookmark-write-file.
Instead of using find-file-noselect, it could just work the way
save-place-alist-to-file does: switch to a buffer, clear the buffer,
insert the new data, and write it out to the destination.  That is:

   2005-05-29  Karl Fogel  <kfogel@red-bean.com>

	* bookmark.el

        (bookmark-write-file): Don't visit the destination file, just
        write the data to it using write-region.  This is similar to
        revision 1.32 of saveplace.el, but with an additional change
        to avoid visiting the file in the first place.

   Index: lisp/bookmark.el
   ===================================================================
   RCS file: /cvsroot/emacs/emacs/lisp/bookmark.el,v
   retrieving revision 1.73
   diff -u -r1.73 bookmark.el
   --- lisp/bookmark.el	26 May 2005 12:28:39 -0000	1.73
   +++ lisp/bookmark.el	30 May 2005 02:17:40 -0000
   @@ -1340,12 +1340,11 @@
        (save-window-excursion
          (if (>= baud-rate 9600)
              (message "Saving bookmarks to file %s..." file))
   -      (set-buffer (let ((enable-local-variables nil))
   -                    (find-file-noselect file)))
   +      (set-buffer (get-buffer-create " *Bookmarks*"))
          (goto-char (point-min))
   +      (delete-region (point-min) (point-max))
          (let ((print-length nil)
    	    (print-level nil))
   -	(delete-region (point-min) (point-max))
    	(bookmark-insert-file-format-version-stamp)
    	(pp bookmark-alist (current-buffer))
    	(let ((version-control
   @@ -1356,7 +1355,7 @@
    		(t
    		 t))))
              (condition-case nil
   -              (write-file file)
   +              (write-region file)
                (file-error (message "Can't write %s" file)))
    	  (kill-buffer (current-buffer))
    	  (if (>= baud-rate 9600)
   
   
Does this patch look sane?

-Karl

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

* Re: [Emacs-commit] emacs/lisp saveplace.el
  2005-05-30  2:20 ` [Emacs-commit] emacs/lisp saveplace.el Karl Fogel
@ 2005-05-31  4:18   ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2005-05-31  4:18 UTC (permalink / raw)
  Cc: emacs-devel

    What were the bad effects of using 'write-file'?

It made saveplace act as if the user had visited this file,
so that the next session would restore the place.

    I ask because I'm wondering if the same change should be made to
    'bookmark-write-file' in bookmark.el.

If bookmark.el currently visits the file when reading it,
changing the way it writes the file would not alter the outcome.

    In fact, maybe there should be a bigger change to bookmark-write-file.
    Instead of using find-file-noselect, it could just work the way
    save-place-alist-to-file does: switch to a buffer, clear the buffer,
    insert the new data, and write it out to the destination.  That is:

How often do users visit the bookmark file?  If they do this commonly,
then it is better to visit the file.  If they do this quite rarely,
then could be is better to work like save-place-alist-to-file.

Another alternative, which could be best if you want Emacs to make backups
of the bookmark file in the usual way, is to visit the file normally,
but kill the buffer after saving it, unless the buffer existed previously.

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

end of thread, other threads:[~2005-05-31  4:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <E1DcJHX-00083Y-00@savannah.gnu.org>
2005-05-30  2:20 ` [Emacs-commit] emacs/lisp saveplace.el Karl Fogel
2005-05-31  4:18   ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).