Function: verb--load-prelude-from-file

verb--load-prelude-from-file is an interactive and natively compiled function defined in verb.el.

Signature

(verb--load-prelude-from-file FILENAME)

Documentation

Load Emacs Lisp or JSON prelude file FILENAME into Verb variables.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/8jnfn8w2mxcxbr2crbklcnija9m0zlkq-emacs-packages-deps/share/emacs/site-lisp/elpa/verb-20260818.1921/verb.el
(defun verb--load-prelude-from-file (filename)
  "Load Emacs Lisp or JSON prelude file FILENAME into Verb variables."
  (interactive)
  (save-excursion
    (let ((file-extension (file-name-extension filename)))
      (when (member file-extension '("gpg" "gz" "z" "7z"))
        (setq file-extension (file-name-extension (file-name-base filename))))
      (cond
       ((string= "el" file-extension) ; file is Emacs Lisp
        (if (or verb-suppress-load-unsecure-prelude-warning
                (yes-or-no-p
                 (concat (format "File %s may contain code " filename)
                         "that may not be safe (see: "
                         "`verb-suppress-load-unsecure-prelude-warning')"
                         "\nLoad it anyways? ")))
            (load-file filename)
          (user-error "Operation cancelled")))
       ((string-match-p "^json.?" file-extension) ; file is JSON(C)
        (let ((file-contents
               (with-temp-buffer
                 (insert-file-contents filename)
                 (set-auto-mode)
                 (goto-char (point-min))
                 ;; If a modern JSON / JavaScript package not
                 ;; installed, then comments cannot be removed or
                 ;; supported. Also, not likely to have JSON comments
                 ;; if this is the case.
                 (when comment-start
                   (comment-kill (count-lines (point-min) (point-max))))
                 (verb--buffer-string-no-properties))))
          (verb--process-json-prelude file-contents)))
       (t (user-error "Unable to determine file type for %s" filename))))))