diff --git a/README.org b/README.org index 2e957b50..75a29add 100644 --- a/README.org +++ b/README.org @@ -2329,6 +2329,19 @@ These two packages created by Prot are interesting to me and may help to make su (add-hook 'imenu-after-jump-hook #'pulsar-recenter-top) (add-hook 'imenu-after-jump-hook #'pulsar-reveal-entry)) #+end_src +*** posframe + +I'm going to find all kinds of uses for posframe +#+begin_src emacs-lisp +(use-package posframe) +#+end_src + +#+begin_src emacs-lisp +(use-package vertico-posframe + :after vertico + :config + (setq vertico-posframe-min-height 10)) +#+end_src ** EWW Builtin webbrowser for emacs. Trying it out as a text only browser for things. @@ -3968,7 +3981,10 @@ Ledger mode :general (general-def 'normal ledger-mode-map "ga" 'ledger-add-transaction - "gr" 'ledger-report)) + "gr" 'ledger-report + "gp" 'ledger-toggle-current + "C-j" 'ledger-navigate-next-xact-or-directive + "C-k" 'ledger-navigate-prev-xact-or-directive)) #+end_src ** MU4E diff --git a/init.el b/init.el index de42137a..4761f87a 100644 --- a/init.el +++ b/init.el @@ -1741,6 +1741,13 @@ Optional BACKEND must be `re-reveal' or a backend derived from it." (add-hook 'imenu-after-jump-hook #'pulsar-recenter-top) (add-hook 'imenu-after-jump-hook #'pulsar-reveal-entry)) +(use-package posframe) + +(use-package vertico-posframe + :after vertico + :config + (setq vertico-posframe-min-height 10)) + (setq home-directory "~/") (defun chris/eww-mpv () "Launch the url in mpv" @@ -2838,7 +2845,10 @@ targets." :general (general-def 'normal ledger-mode-map "ga" 'ledger-add-transaction - "gr" 'ledger-report)) + "gr" 'ledger-report + "gp" 'ledger-toggle-current + "C-j" 'ledger-navigate-next-xact-or-directive + "C-k" 'ledger-navigate-prev-xact-or-directive)) (use-package mu4e ;; :load-path "~/.guix-home/profile/share/emacs/site-lisp/mu4e/" diff --git a/lumina.el b/lumina.el new file mode 100644 index 00000000..c0e9b9de --- /dev/null +++ b/lumina.el @@ -0,0 +1,95 @@ +;;; lumina.el -*- lexical-binding: t; -*- + +(require 'cl-lib) +(require 'request) + +(defvar lumina-db (sqlite-open "~/.local/share/lumina/library-db.sqlite3")) + +(defvar lumina-songs (sqlite-select lumina-db "select * from songs;")) + +(defvar lumina-songs-set (sqlite-select lumina-db "select * from songs;" nil :set)) + +(defvar lumina-buffer) + +(define-derived-mode lumina-mode tabulated-list-mode "lumina:songs" + "A mode for working with the lumina database and updating and adding songs" + (setf tabulated-list-format ['("Title" 10 t) '("Lyrics" 30 nil) '("Author" 10 t) '("CCLI" 7 nil) '("B" 1 nil) '("BT" 10 nil) '("h" 1 nil) '("v" 1 nil) '("f" 10 nil) '("fs" 2 nil)])) + +(defun lumina-get-ids () + "Gets the ids of all songs in the sql result" + (cl-loop for song in lumina-songs + collect (car song))) + +(defun lumina-get-songs () + "Gets the songs from the sql result without the id" + (cl-loop for song in lumina-songs + collect (seq--into-vector (cdr song)))) + +(defun lumina-table () + "creates the list necessary for the tabulated-list-entries table") + +(cl-mapcar #'cons (lumina-get-ids) (lumina-get-songs)) + +(defun lumina () + "Start lumina up" + (interactive) + (setf lumina-buffer (get-buffer-create "*lumina*")) + (with-current-buffer lumina-buffer + (lumina-mode) + (setf tabulated-list-entries (cl-mapcar #'list (lumina-get-ids) (lumina-get-songs))) + (tabulated-list-print t t)) + (switch-to-buffer lumina-buffer)) + +;;Elements are in this order, id, title, lyrics, author, +;;ccli, audio file, verse order, background, background type, +;;halign, valign, font, fontsize + +(defun lumina-select-song () + "Select which song to edit" + (interactive) + (with-current-buffer (get-buffer-create "*lumina*") + (fundamental-mode) + (delete-region (point-min) (point-max)) + (point-min) + (let* ((title (completing-read "Select a song: " (cl-loop for song in lumina-songs + collect (cadr song)))) + (lyrics (cl-loop for song in lumina-songs + when (string= (cadr song) title) + return (caddr song)))) + (insert lyrics) + (setf lumina-current-song title))) + (switch-to-buffer "*lumina*")) + +(defvar lumina-current-song) + +(defun lumina-grab-lyrics () + (with-current-buffer (get-buffer-create "*lumina*") + (buffer-substring-no-properties (point-min) (point-max)))) + +(defvar lumina-lyrics-update-query (concat "update songs set lyrics = \"?" (lumina-grab-lyrics) "\" where title = " lumina-current-song)) + +(defun lumina-update-lyrics () + "Update the lyrics in the db" + (interactive) + (sqlite-execute lumina-db "update songs set lyrics = ? where title = ?" `(,(lumina-grab-lyrics) ,lumina-current-song)) + (setf lumina-songs (sqlite-select lumina-db "select * from songs;"))) + + +(defun lumina-get-lyrics-genius (song) + "retrieve lyrics to a song from genius lyrics" + (let* ((url (concat "https://api.genius.com/search?" "access_token=" "R0Y0ZW50Il9LSh5su3LKfdyfmQRx41NpVvLFJ0VxMo-hQ_4H1OVg_IE0Q-UUoFQx" "&q=" song)) + (songs + (cl-loop for song across + (cdr (cadadr (plz 'get (url-encode-url url) :as #'json-read))) + collect `(,(concat (cdr (elt (elt song 3) 19)) " by " + (cdr (elt (elt (elt song 3) 23) 7)) + " with id " + (number-to-string + (cdr (elt (elt song 3) 7))))))) + (selected-song (completing-read "song? " songs)) + (id (replace-regexp-in-string "[^0-9]" "" selected-song))) + (plz 'get (url-encode-url (concat "https://api.genius.com/songs/" id "?access_token=R0Y0ZW50Il9LSh5su3LKfdyfmQRx41NpVvLFJ0VxMo-hQ_4H1OVg_IE0Q-UUoFQx"))))) + +(cdr (elt (elt (elt (lumina-get-lyrics-genius "Death Was Arrested") 0) 3) 7)) + +(lumina-get-lyrics-genius "Death Was Arrested")