After a buffer containing a file has been edited it must be written back to a file on disk, otherwise the modifications will disappear when Jade is exited!
buffer-file-name component of the
buffer).
buffer-file-name
component is used.
The hook write-file-hook is used to try and write the file, if this
fails (i.e. the hook returns nil) the buffer is saved normally.
A backup may be made of the file to be overwritten (see section Making Backups) and the protection-modes of the overwritten file will be preserved if possible.
write-file function when a buffer is
to be saved. If no member of the hook actually writes the buffer to a
file (i.e. the hook returns nil) write-file will do it
itself in a standard way.
The hook function is responsible for creating any required backup file
(use the function backup-file, see section Making Backups) and
resetting the protection-modes of the new file to their original
value.
See the file `gzip.jl' in the Lisp library directory for an example, it uses it to compress certain files automatically.
Remember to make sure that if a member of the hook writes the buffer
it returns a non-nil value!
The following code fragment defines a function which does what the default
action of write-file is,
(defun write-file-default-action (buffer name)
(let
((modes (when (file-exists-p name) (file-modes name))))
(backup-file name)
(when (write-buffer name buffer)
(when modes
(set-file-modes name modes))
t)))
The following commands call the write-file function to write out
a buffer, they also update the various variables containing information
about the state of the buffer. It is normally unnecessary to call
write-file yourself; these commands should suffice.
If the file on disk has been modified since it was read into the buffer the user is asked if they really want to save it (and risk losing a version of the file).
If no modifications have been made to the file since it was last saved it won't be saved again.
Any auto-saved version of the file is deleted.
buffer-file-name is set
to new-name and all the necessary buffer-local variables are
updated.
If an auto-saved version of file-name exists it is deleted.
When called interactively new-name will be prompted for.
t is returned if no unsaved modifications exist in any buffers
(i.e. the user replied `yes' to all files which could be saved).
save-some-buffers then quits Jade (after asking the user if any
unsaved buffers may be discarded).
Go to the first, previous, next, last section, table of contents.