Function: tutorial--save-tutorial-to
tutorial--save-tutorial-to is a byte-compiled function defined in
tutorial.el.gz.
Signature
(tutorial--save-tutorial-to SAVED-FILE)
Documentation
Save the tutorial buffer to SAVED-FILE.
See tutorial--save-tutorial for more information.
Source Code
;; Defined in /usr/src/emacs/lisp/tutorial.el.gz
(defun tutorial--save-tutorial-to (saved-file)
"Save the tutorial buffer to SAVED-FILE.
See `tutorial--save-tutorial' for more information."
;; Anything to save?
(when (or (buffer-modified-p)
(< 1 (point)))
(let ((tutorial-dir (tutorial--saved-dir))
save-err)
;; The tutorial is saved in a subdirectory in the user home
;; directory. Create this subdirectory first.
(unless (file-directory-p tutorial-dir)
(condition-case err
(make-directory tutorial-dir nil)
(error (setq save-err t)
(warn "Could not create directory %s: %s" tutorial-dir
(error-message-string err)))))
;; Make sure we have that directory.
(if (file-directory-p tutorial-dir)
(let ((tut-point (if (= 0 tutorial--point-after-chkeys)
;; No info about changed keys is
;; displayed.
(point)
(if (< (point) tutorial--point-after-chkeys)
(- (point))
(- (point) tutorial--point-after-chkeys))))
(old-point (point))
;; Use a special undo list so that we easily can undo
;; the changes we make to the tutorial buffer. This is
;; currently not needed since we now delete the buffer
;; after saving, but kept for possible future use of
;; this function.
buffer-undo-list
(inhibit-read-only t))
;; Delete the area displaying info about changed keys.
;; (when (< 0 tutorial--point-after-chkeys)
;; (delete-region tutorial--point-before-chkeys
;; tutorial--point-after-chkeys))
;; Delete the remarks:
(tutorial--remove-remarks)
;; Put the value of point first in the buffer so it will
;; be saved with the tutorial.
(goto-char (point-min))
(insert (number-to-string tut-point)
"\n"
(number-to-string (marker-position
tutorial--point-before-chkeys))
"\n")
(condition-case err
(write-region nil nil saved-file)
(error (setq save-err t)
(warn "Could not save tutorial to %s: %s"
saved-file
(error-message-string err))))
;; An error is raised here?? Is this a bug?
(ignore-errors (undo-only))
;; Restore point
(goto-char old-point)
(if save-err
(message "Could not save tutorial state.")
(message "Saved tutorial state.")))
(message "Can't save tutorial: %s is not a directory"
tutorial-dir)))))