Function: sops--start-creation

sops--start-creation is a natively compiled function defined in sops.el.

Signature

(sops--start-creation FORMAT)

Documentation

Seed buffer with FORMAT's stub and enable sops-mode(var)/sops-mode(fun) in 'creating state.

FORMAT is a sops type name; see sops--example-for for accepted values.

The variable buffer-file-name(var)/buffer-file-name(fun) must already be set (caller has typically just called find-file on a non-existent path). This helper:

  1. Erases the buffer and inserts the matching stub.
  2. Marks the buffer unmodified -- the example is not user edits.
  3. Pre-sets sops--state to 'creating so the sops-mode(var)/sops-mode(fun) enable
     guard skips its filestatus check (the file doesn't exist yet).
  4. Enables sops-mode(var)/sops-mode(fun).

On first successful save, sops--encrypt-and-write will transition sops--state.status from 'creating to 'decrypted.

Source Code

;; Defined in /nix/store/vihl6lkzddv9xrsrsznvqdjq27g2i30p-emacs-packages-deps/share/emacs/site-lisp/elpa/sops-20260920.2121/sops.el
(defun sops--start-creation (format)
  "Seed buffer with FORMAT's stub and enable `sops-mode' in \\='creating state.
FORMAT is a sops type name; see `sops--example-for' for accepted values.

The variable `buffer-file-name' must already be set (caller has typically
just called `find-file' on a non-existent path).  This helper:

  1. Erases the buffer and inserts the matching stub.
  2. Marks the buffer unmodified -- the example is not user edits.
  3. Pre-sets `sops--state' to \\='creating so the `sops-mode' enable
     guard skips its filestatus check (the file doesn't exist yet).
  4. Enables `sops-mode'.

On first successful save, `sops--encrypt-and-write' will transition
`sops--state.status' from \\='creating to \\='decrypted."
  (let ((stub (sops--example-for format)))
    (erase-buffer)
    (insert stub))
  (set-buffer-modified-p nil)
  (setq sops--state (sops-state-create :status 'creating))
  (sops-mode 1))