<commit_before>;;;; minibuffer.lisp --- major mode for input

(in-package :next)

(defvar minibuffer-mode-map (make-hash-table :test 'equalp))

(defparameter *minibuffer-input-string* nil
  "A variable to store the current minibuffer input")
(defparameter *minibuffer-completion-callback* nil
  "A variable to store the function upon completion of the minibuffer read")

(defun return-input ()
  (funcall *minibuffer-completion-callback* *minibuffer-input-string*)
  (setf *minibuffer-input-string* nil)
  (update-display))
(define-key minibuffer-mode-map (kbd "Return") #'return-input)

(defun input (callback-function)
  (setf *minibuffer-completion-callback* callback-function))

(defun update-display ()
  (|setHtml| (buffer-view *mini-buffer*) *minibuffer-input-string*))

(defun minibuffer-mode ()
  "Base mode for input"
  (make-mode
   :name "Minibuffer-Mode"
   :keymap minibuffer-mode-map))

(defun printy-text (text)
  (print text))

(defun print-text-read ()
  (input #'printy-text))
(define-key minibuffer-mode-map (kbd "C-a") #'print-text-read)

;; define input keys
(defun insert-a ()
  (setf *minibuffer-input-string* (concatenate 'string *minibuffer-input-string* "a"))
  (update-display))
(define-key minibuffer-mode-map (kbd "a") #'insert-a)

(defun insert-b ()
  (setf *minibuffer-input-string* (concatenate 'string *minibuffer-input-string* "b"))
  (update-display))
(define-key minibuffer-mode-map (kbd "b") #'insert-b)

(defun insert-c ()
  (setf *minibuffer-input-string* (concatenate 'string *minibuffer-input-string* "c"))
  (update-display))
(define-key minibuffer-mode-map (kbd "c") #'insert-c)
<commit_msg>minibuffer input example<commit_after>;;;; minibuffer.lisp --- major mode for input

(in-package :next)

(defvar minibuffer-mode-map (make-hash-table :test 'equalp))

(defparameter *minibuffer-input-string* nil
  "A variable to store the current minibuffer input")
(defparameter *minibuffer-completion-callback* nil
  "A variable to store the function upon completion of the minibuffer read")

(defun return-input ()
  (funcall *minibuffer-completion-callback* *minibuffer-input-string*)
  (setf *minibuffer-input-string* nil)
  (update-display))
(define-key minibuffer-mode-map (kbd "Return") #'return-input)

(defun input (callback-function)
  (setf *minibuffer-completion-callback* callback-function))

(defun update-display ()
  (|setHtml| (buffer-view *mini-buffer*) *minibuffer-input-string*))

(defun minibuffer-mode ()
  "Base mode for input"
  (make-mode
   :name "Minibuffer-Mode"
   :keymap minibuffer-mode-map))

(defun printy-text (text)
  (print text))

(defun print-text-read ()
  (input #'printy-text))
(define-key minibuffer-mode-map (kbd "C-a") #'print-text-read)

;; define input keys
(defun insert-character (character)
  (setf *minibuffer-input-string* (concatenate 'string *minibuffer-input-string* character))
  (update-display))

(defun add-binding (key)
  (define-key minibuffer-mode-map (kbd key)
     #'(lambda () (insert-character key))))

(loop for key in
     (list "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m"
	   "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z")
   do (add-binding key))

;; add bindings for puncuation
(define-key minibuffer-mode-map (kbd "Period") #'(lambda () (insert-character ".")))
(define-key minibuffer-mode-map (kbd "Colon") #'(lambda () (insert-character ":")))
(define-key minibuffer-mode-map (kbd "Slash") #'(lambda () (insert-character "/")))


{'fraction_non_alphanumeric': 0.17067516661837148, 'fraction_numerical': 0.0, 'mean_word_length': 4.743760399334443, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3483486', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1271, 'n_words': 306}