;;; Code:
+(when (eq system-type 'darwin)
+ (setq default-frame-alist '((fullscreen . fullboth))))
+
(defvar esy/init-step-times nil)
(defmacro esy/init-step (name _doc &rest body)
;; (load-theme 'modus-vivendi)
(require 'ef-themes)
+ (defvar esy/ef-themes-ring (make-ring 16))
+
+ (defun esy/ef-themes-load-previous ()
+ (interactive)
+ (when (< 0 (ring-length esy/ef-themes-ring))
+ (let ((theme (ring-remove esy/ef-themes-ring 0)))
+ (message "Loaded `%s'" theme)
+ (ef-themes--load-theme theme))))
+
(defun esy/ef-themes-load-random ()
(interactive)
- (let* ((themes (seq-filter
- (lambda (theme)
- (not (equal theme (ef-themes--current-theme))))
+ (let* ((theme (ef-themes--current-theme))
+ (themes (seq-filter
+ (lambda (other-theme)
+ (not (equal other-theme theme)))
'(
ef-autumn
ef-bio
(n (random (length themes)))
(pick (nth n themes))
(loaded (if (null pick) (car themes) pick)))
+ (ring-insert esy/ef-themes-ring theme)
(ef-themes--load-theme loaded)
(message "Loaded `%s'" loaded)))
(message path))
path))
+ (defun esy/transcribe ()
+ (interactive)
+ (message "Recording...")
+ (let ((process
+ (start-process "ffmpeg" nil "ffmpeg"
+ "-f" "avfoundation"
+ "-i" "1:0"
+ "-ar" "16000"
+ "-y"
+ "/tmp/foo.wav")))
+ (set-transient-map
+ (make-sparse-keymap) nil
+ (lambda ()
+ (message "Stopping recording")
+ (interrupt-process process)
+ (accept-process-output process 1 nil t)
+ (message "Transcribing...")
+ (message
+ (string-trim-right
+ (string-trim-left
+ (with-temp-buffer
+ (call-process "whisper"
+ nil '(t nil) nil
+ "-m"
+ "/Users/eshelyaron/checkouts/whisper.cpp/models/ggml-base.en.bin"
+ "--no-timestamps" "-f" "/tmp/foo.wav")
+ (goto-char (point-min))
+ (while (search-forward "[BLANK_AUDIO]" nil t)
+ (replace-match "" nil t))
+ (buffer-string))))))
+ "Recording... Press any key to stop")))
+
+ (defun esy/record (timeout)
+ (interactive "p")
+ (message "Recording...")
+ (call-process "ffmpeg"
+ nil nil nil
+ "-f" "avfoundation"
+ "-i" "1:0" "-t"
+ (number-to-string (max timeout 2))
+ "-ar" "16000" "-y" "/tmp/foo.wav")
+ (openai-chat (string-trim-right
+ (string-trim-left
+ (with-temp-buffer
+ (call-process "whisper"
+ nil '(t nil) nil
+ "-m"
+ "/Users/eshelyaron/checkouts/whisper.cpp/models/ggml-base.en.bin"
+ "--no-timestamps" "-f" "/tmp/foo.wav")
+ (goto-char (point-min))
+ (while (search-forward "[BLANK_AUDIO]" nil t)
+ (replace-match "" nil t))
+ (buffer-string))))))
+
(defun esy/bump (tag-prefix)
(interactive (list "v"))
(require 'lisp-mnt)
(keymap-global-set "C-c O" #'openai-chat)
(keymap-global-set "C-c E" #'elfeed)
(keymap-global-set "C-c T" #'esy/ttyper)
+ (keymap-global-set "C-c R" #'esy/record)
(keymap-global-set "C-c G" #'gnus)
(keymap-global-set "C-c M" #'mastodon)
(keymap-global-set "C-c F" #'esy/find-init-file)
(keymap-global-set "\"" #'insert-pair)
(keymap-global-set "<f5>" #'esy/ef-themes-load-random)
(keymap-global-set "s-]" #'esy/ef-themes-load-random)
+ (keymap-global-set "s-[" #'esy/ef-themes-load-previous)
(keymap-set ctl-x-map "b" #'consult-buffer)
(keymap-set ctl-x-4-map "b" #'consult-buffer-other-window)
(defun esy/update-sql-connection-alist ()
(interactive)
(auth-source-forget-all-cached)
- (setq sql-connection-alist (mapcar (lambda (source)
- (pcase (split-string (plist-get source :host)
- (rx "^"))
- (`(,con ,db ,host)
- (list (intern con)
- (list 'sql-product ''postgres)
- (list 'sql-user (plist-get source :user))
- (list 'sql-port (string-to-number (plist-get source :port)))
- (list 'sql-password (funcall (plist-get source :secret)))
- (list 'sql-server host)
- (list 'sql-database db)))))
- (auth-source-search :port 5432 :max 10))))
+ (setq sql-connection-alist (delete nil
+ (mapcar (lambda (source)
+ (pcase (split-string (plist-get source :host)
+ (rx "^"))
+ (`(,con ,db ,host)
+ (list (intern con)
+ (list 'sql-product ''postgres)
+ (list 'sql-user (plist-get source :user))
+ (list 'sql-port (string-to-number (plist-get source :port)))
+ (list 'sql-password (funcall (plist-get source :secret)))
+ (list 'sql-server host)
+ (list 'sql-database db)))))
+ (auth-source-search :port 5432 :max 10)))))
(esy/update-sql-connection-alist)
(add-hook 'sql-interactive-mode-hook #'toggle-truncate-lines)
(add-hook 'sql-interactive-mode-hook #'abbrev-mode)
"P" #'emms-previous
"S" #'emms-stop
"b" #'emms-seek-backward
- "f" #'emms-seek-forward
+ "f" #'emms-seek-fofrward
"k" #'emms-seek
"m" #'emms-show
"p" #'emms-pause
"s" #'emms-start
"t" #'emms-seek-to)
+ (dolist (command '(emms-start
+ emms-stop
+ emms-next
+ emms-previous
+ emms-pause
+ emms-seek
+ emms-seek-to
+ emms-seek-forward
+ emms-seek-backward
+ emms-show))
+ (put command 'repeat-map 'esy/emms-map))
+
(with-eval-after-load 'emms
(emms-minimalistic)))