Function: allout-write-contents-hook-handler

allout-write-contents-hook-handler is a byte-compiled function defined in allout.el.gz.

Signature

(allout-write-contents-hook-handler)

Documentation

Implement allout-encrypt-unencrypted-on-saves for file writes.

Return nil if all goes smoothly, or else return an informative message if an error is encountered. The message will serve as a non-nil return on write-contents-functions to prevent saving of the buffer while it has decrypted content.

This behavior depends on Emacs versions that implement the write-contents-functions hook.

Source Code

;; Defined in /usr/src/emacs/lisp/allout.el.gz
;;;_   > allout-write-contents-hook-handler ()
(defun allout-write-contents-hook-handler ()
  "Implement `allout-encrypt-unencrypted-on-saves' for file writes.

Return nil if all goes smoothly, or else return an informative
message if an error is encountered.  The message will serve as a
non-nil return on `write-contents-functions' to prevent saving of
the buffer while it has decrypted content.

This behavior depends on Emacs versions that implement the
`write-contents-functions' hook."

  (if (or (not (allout-mode-p))
          (not (boundp 'allout-encrypt-unencrypted-on-saves))
          (not allout-encrypt-unencrypted-on-saves))
      nil
    (if (save-excursion (goto-char (point-min))
                        (allout-next-topic-pending-encryption))
        (progn
          (message "auto-encrypting pending topics")
          (sit-for 0)
          (condition-case failure
              (progn
                (setq allout-after-save-decrypt
                      (allout-encrypt-decrypted))
                ;; aok - return nil:
                nil)
            (error
             ;; whoops - probably some still-decrypted items, return non-nil:
             (let ((text (format (concat "%s contents write inhibited due to"
                                         " encrypted topic encryption error:"
                                         " %s")
                                 (buffer-name (current-buffer))
                                 failure)))
               (message text)(sit-for 2)
               text)))))
    ))