]> git.eshelyaron.com Git - dotfiles.git/commitdiff
Update Emacs configuration and Brewfile
authorEshel Yaron <me@eshelyaron.com>
Tue, 18 Jul 2023 07:39:46 +0000 (10:39 +0300)
committerEshel Yaron <me@eshelyaron.com>
Tue, 18 Jul 2023 07:40:18 +0000 (10:40 +0300)
.emacs.d/early-init.el
.emacs.d/init.el
Brewfile

index 317d0d4d7d45ffc4fb8b4e40f6f04350222f858f..2e5822eff6b3ea8c8f669e06127665ca97c7135c 100644 (file)
@@ -7,10 +7,9 @@
 (set-scroll-bar-mode nil)
 
 (unless (eq system-type 'darwin)
-  (menu-bar-mode -1))
-
-(setq initial-frame-alist '((fullscreen . fullboth)
-                            (alpha-background . 85)))
+  (menu-bar-mode -1)
+  (setq initial-frame-alist '((fullscreen . fullboth)
+                              (alpha-background . 85))))
 
 (provide 'early-init)
 ;;; early-init.el ends here
index b823f0c1f09082b1a0220a099cafc971c83b4603..e04f149babbac6a94a5d3af3386f5e2bfb7d4b98 100644 (file)
@@ -9,6 +9,9 @@
 
 ;;; 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)))
 
@@ -647,6 +661,60 @@ Interactively, POINT is point and KILL is the prefix argument."
         (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)
@@ -763,6 +831,7 @@ Interactively, POINT is point and KILL is the prefix argument."
   (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)
@@ -790,6 +859,7 @@ Interactively, POINT is point and KILL is the prefix argument."
   (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)
@@ -885,18 +955,19 @@ as the initial input for completion, and return that directory."
     (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)
@@ -1088,13 +1159,25 @@ as the initial input for completion, and return that directory."
     "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)))
 
index 8e6784aa7200374e77637e10ad4547cc3c069731..3dda9cfe9b6f8fef120575f73c78cc6bbd90a6c6 100644 (file)
--- a/Brewfile
+++ b/Brewfile
@@ -40,6 +40,7 @@ brew "texinfo"
 brew "tree-sitter"
 brew "tnftp"
 brew "pandoc"
+brew "mpv"
 cask "font-iosevka"
 cask "font-iosevka-aile"
 cask "font-iosevka-etoile"