Function: cider-repl--history-write

cider-repl--history-write is a byte-compiled function defined in cider-repl.el.

Signature

(cider-repl--history-write FILENAME)

Documentation

Write history to FILENAME.

Currently coding system for writing the contents is hardwired to utf-8-unix.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-repl.el
(defun cider-repl--history-write (filename)
  "Write history to FILENAME.
Currently coding system for writing the contents is hardwired to
utf-8-unix."
  (let* ((end (min (length cider-repl-input-history) cider-repl-history-size))
         ;; newest items are at the beginning of the list, thus 0
         (hist (seq-subseq cider-repl-input-history 0 end)))
    (cond
     ((file-writable-p filename)
      (let ((print-length nil) (print-level nil))
        (with-temp-file filename
          ;; TODO: really set cs for output
          ;; TODO: does cs need to be customizable?
          (insert ";; -*- coding: utf-8-unix -*-\n")
          (insert ";; Automatically written history of CIDER REPL session\n")
          (insert ";; Edit at your own risk\n\n")
          (prin1 (mapcar #'substring-no-properties hist) (current-buffer)))))
     ((not (file-directory-p (file-name-directory filename)))
      (message "Warning: Cannot write history file, directory does not exist: %s"
               (file-name-directory filename)))
     (t
      (error "History file not writable: %s" filename)))))