-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelfos-input.el
48 lines (40 loc) · 1.38 KB
/
delfos-input.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
;;; delfos-input.el --- Description -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2023 namespace
;;
;; Author: namespace <src.namespace@gmail.com>
;; Maintainer: namespace <src.namespace@gmail.com>
;;; Commentary:
;; This library provides different ways to capture user input.
;;; Code:
;; TODO audio input
(defvar delfos-input-buffer-keymap
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") 'exit-recursive-edit)
map)
"Keymap for `delfos-input-text'.")
(defun delfos-input-buffer ()
"Capture user input in a temporary buffer"
(interactive)
(let ((input-text nil)
(original-buffer (current-buffer))
(input-buffer (generate-new-buffer "*Delfos Input*")))
(with-current-buffer input-buffer
(org-mode)
(use-local-map delfos-input-buffer-keymap)
(setq-local mode-line-format (concat "Enter text. Press " (key-description (kbd "C-c C-c")) " when done.")))
(split-window-vertically)
(other-window 1)
(switch-to-buffer input-buffer)
(when evil-mode
(evil-emacs-state))
(unwind-protect
(recursive-edit)
(setq input-text (buffer-substring-no-properties (point-min) (point-max)))
(kill-buffer input-buffer)
(delete-window))
input-text))
(defun delfos-input-format-text (input-text)
(replace-regexp-in-string "^\\*" "***" input-text))
(provide 'delfos-input)
;;; delfos-input.el ends here