From 3dd81b2efe906f664c0bca802058e525ed322a87 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 5 Oct 2021 08:32:54 -0500 Subject: Add spongebob-case Studlify is ... too complicated. --- lisp/acdw.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw.el b/lisp/acdw.el index 792b9ef..e013fbc 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -793,6 +793,32 @@ This function is internal. Use `acdw/make-password-fetcher' instead." (insert "šŸ’©") (setq n (1- n))))) +(defun spongebob-case-region (beg end) + "Make region, defined by BEG and END, lOoK lIkE tHiS." + (interactive "*r") + (save-excursion + (let (case) + (goto-char beg) + (while (< (point) end) + (if (looking-at "[[:alpha:]]") + (if (setq case (not case)) + (upcase-region (point) (progn (forward-char 1) (point))) + (downcase-region (point) (progn (forward-char 1) (point)))) + (forward-char 1)))))) + +(defun spongebob-case-word (n) + "Spongebob-case N words forward, beginning at point, moving over." + (interactive "*p") + (spongebob-case-region (point) (progn (forward-word n) (point)))) + +(defun spongebob-case-dwim (arg) + "Spongebob-case words in the region if active, else word at point. +If ARG exists, it's passed to `spongebob-case-word'." + (interactive "*p") + (if (use-region-p) + (spongebob-case-region (region-beginning) (region-end)) + (spongebob-case-word arg))) + ;;; Fat finger solutions (defun acdw/fat-finger-exit (&optional prefix) -- cgit 1.4.1-21-gabe81 From 007be7aa3da6aad2618feec3043ec0e12902b599 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 5 Oct 2021 08:33:16 -0500 Subject: Correct percentage display in modeline --- lisp/acdw-modeline.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index 21068bd..573a964 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el @@ -147,7 +147,7 @@ is, if point < mark." (5 " C%C"))) " ")) (file-percentage-mode - (7 "%p%% ")) + ((-3 "%p") "%% ")) ,(if (region-active-p) (propertize (format "%s%-5d" (if (and (mark) -- cgit 1.4.1-21-gabe81 From 66ecd92944d7d169c0760402f7b8fd0a2f255958 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 5 Oct 2021 14:22:18 -0500 Subject: Change `:straight-if` to `:straight-when` `:straight-when` is a more accurate representation of what it'sĀ doing. IĀ also found out that IĀ could change its indentation, which IĀ did. --- init.el | 124 +++++++++++++++++++++++++++-------------------------- lisp/acdw-setup.el | 3 +- lisp/acdw.el | 2 +- 3 files changed, 66 insertions(+), 63 deletions(-) (limited to 'lisp') diff --git a/init.el b/init.el index 83486c8..32f48fb 100644 --- a/init.el +++ b/init.el @@ -974,18 +974,18 @@ specific to most general, they are these: :repo "willvaughn/emacs-0x0")) (:option 0x0-default-server 'ttm)) -(setup (:straight-if affe - (and (or (executable-find "fd") - (executable-find "find")) - (executable-find "rg"))) +(setup (:straight-when affe + (and (or (executable-find "fd") + (executable-find "find")) + (executable-find "rg"))) ;; Keys are bound in `acdw/sensible-grep' and `acdw/sensible-find' (:option affe-regexp-compiler (defun affe-orderless-regexp-compiler (input _type) (setq input (orderless-pattern-compiler input)) (cons input (lambda (str) (orderless--highlight input str)))))) -(setup (:straight-if ahk-mode - (acdw/system :work))) +(setup (:straight-when ahk-mode + (acdw/system :work))) (setup (:straight alert) (:option alert-default-style (acdw/system @@ -1221,10 +1221,10 @@ specific to most general, they are these: (crux-reopen-as-root-mode +1)) -(setup (:straight-if (define-repeat-map - :host nil - :repo "https://tildegit.org/acdw/define-repeat-map.el") - (acdw/system :home)) +(setup (:straight-when (define-repeat-map + :host nil + :repo "https://tildegit.org/acdw/define-repeat-map.el") + (acdw/system :home)) (require 'define-repeat-map ; just for me (acdw/dir @@ -1448,8 +1448,8 @@ specific to most general, they are these: (add-hook hook #'epithet-rename-buffer))) ;; TODO: look into emms or something related for this -(setup (:straight-if eradio - (executable-find "mpv")) +(setup (:straight-when eradio + (executable-find "mpv")) (:option eradio-player '("mpv" "--no-video" "--no-terminal") eradio-channels `(("KLSU" . @@ -1491,16 +1491,16 @@ specific to most general, they are these: (:hook-into emacs-lisp-mode lisp-interaction-mode)) -(setup (:straight-if exec-path-from-shell - (acdw/system :home)) +(setup (:straight-when exec-path-from-shell + (acdw/system :home)) (when (daemonp) (exec-path-from-shell-initialize))) (setup (:straight expand-region) (:global "C-=" #'er/expand-region)) -(setup (:straight-if fennel-mode - (executable-find "fennel")) +(setup (:straight-when fennel-mode + (executable-find "fennel")) (:autoload (fennel-repl :interactive t)) (:file-match (rx ".fnl" eos))) @@ -1517,8 +1517,8 @@ specific to most general, they are these: (flyspell-correct-move 0 :forward :rapid)))) (:unbind "C-;" "C-," "C-." "C-M-i"))) -(setup (:straight-if forge - (acdw/system :home)) +(setup (:straight-when forge + (acdw/system :home)) ;; make sure to read Info manual with Forge (and Ghub) for setup ;; instructions. (with-eval-after-load 'magit @@ -1531,26 +1531,26 @@ specific to most general, they are these: (:option gcmh-idle-delay 'auto) (gcmh-mode +1)) -(setup (:straight-if geiser - (progn - (defvar acdw/schemes - (let (schemes) - (dolist (scheme '(("scheme" . geiser-chez) ; chez - ("petite" . geiser-chez) ; petite - ("csi" . geiser-chez) ; chicken - ("gsi" . geiser-gambit) - ("gosh" . geiser-gauche) - ("guile" . geiser-guile) - ("kawa" . geiser-kawa) - ("mit-scheme" . geiser-mit) - ("racket" . geiser-racket) - ("stklos" . geiser-stklos))) - (when-let (binary (executable-find (car scheme))) - (push binary schemes) - ;; and install the proper helper package - (straight-use-package (cdr scheme)))) - (nreverse schemes))) - acdw/schemes)) +(setup (:straight-when geiser + (progn + (defvar acdw/schemes + (let (schemes) + (dolist (scheme '(("scheme" . geiser-chez) ; chez + ("petite" . geiser-chez) ; petite + ("csi" . geiser-chez) ; chicken + ("gsi" . geiser-gambit) + ("gosh" . geiser-gauche) + ("guile" . geiser-guile) + ("kawa" . geiser-kawa) + ("mit-scheme" . geiser-mit) + ("racket" . geiser-racket) + ("stklos" . geiser-stklos))) + (when-let (binary (executable-find (car scheme))) + (push binary schemes) + ;; and install the proper helper package + (straight-use-package (cdr scheme)))) + (nreverse schemes))) + acdw/schemes)) (:file-match (rx ".rkt" eos) (rx ".scm" eos))) @@ -1637,8 +1637,8 @@ specific to most general, they are these: (setup (:straight lacarte) (:global "" #'lacarte-execute-menu-command)) -(setup (:straight-if ledger-mode - (executable-find "ledger"))) +(setup (:straight-when ledger-mode + (executable-find "ledger"))) (setup (:straight link-hint) ;; Browse web URLs with a browser with a prefix argument. @@ -2110,10 +2110,10 @@ the default is \"/\"." lisp-interaction-mode scheme-mode)) -(setup (:straight-if (pdf-tools - :host github - :repo "vedang/pdf-tools") - (acdw/system :home)) +(setup (:straight-when (pdf-tools + :host github + :repo "vedang/pdf-tools") + (acdw/system :home)) (:file-match (rx ".pdf" eos)) (pdf-loader-install)) @@ -2200,16 +2200,16 @@ the default is \"/\"." (simple-modeline-mode +1)) -(setup (:straight-if sly - (progn - (defvar acdw/lisps - (let (lisps) - (dolist (lisp '("sbcl" ; TODO: add more lisps - "clisp")) - (when-let (binary (executable-find lisp)) - (push binary lisps))) - (nreverse lisps))) - acdw/lisps)) +(setup (:straight-when sly + (progn + (defvar acdw/lisps + (let (lisps) + (dolist (lisp '("sbcl" ; TODO: add more lisps + "clisp")) + (when-let (binary (executable-find lisp)) + (push binary lisps))) + (nreverse lisps))) + acdw/lisps)) (:also-load sly-autoloads) (:straight clhs) @@ -2289,8 +2289,8 @@ the default is \"/\"." (auto-save-visited-mode -1) (super-save-mode +1)) -(setup (:straight-if systemd - (executable-find "systemd"))) +(setup (:straight-when systemd + (executable-find "systemd"))) (setup (:straight (topsy :host github @@ -2404,8 +2404,8 @@ If used with a numeric prefix argument N, N backticks will be inserted." (setup (:straight visual-regexp) (:global "M-%" #'vr/query-replace)) -(setup (:straight-if vterm - (acdw/system :home)) +(setup (:straight-when vterm + (acdw/system :home)) (:straight (eshell-vterm :host github :repo "iostapyshyn/eshell-vterm")) @@ -2461,11 +2461,13 @@ If used with a numeric prefix argument N, N backticks will be inserted." (setup (:straight xr)) -(setup (:straight-if ytel - (executable-find "mpv")) +(setup (:straight-when ytel + (executable-find "mpv")) + (:also-load acdw-ytel) ;; This might need to be changed depending on whether the instance goes down. (:option ytel-invidious-api-url "https://invidious.snopyta.org") - (:bind "v" #'acdw/ytel-current-video-link + (:hook #'hl-line-mode) + (:bind "v" #'acdw/ytel-watch "w" #'acdw/ytel-copy-link)) (setup (:straight zzz-to-char) diff --git a/lisp/acdw-setup.el b/lisp/acdw-setup.el index eb4d12b..33ab835 100644 --- a/lisp/acdw-setup.el +++ b/lisp/acdw-setup.el @@ -72,7 +72,7 @@ first RECIPE's package." (car recipe) recipe)))) -(setup-define :straight-if +(setup-define :straight-when (lambda (recipe condition) `(if ,condition (straight-use-package ',recipe) @@ -83,6 +83,7 @@ If CONDITION is false, stop evaluating the body. This macro can be used as HEAD, and will replace itself with the RECIPE's package. This macro is not repeatable." :repeatable nil + :indent 1 :shorthand (lambda (sexp) (let ((recipe (cadr sexp))) (if (consp recipe) (car recipe) recipe)))) diff --git a/lisp/acdw.el b/lisp/acdw.el index e013fbc..969b6c8 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -352,7 +352,7 @@ In short, DO NOT USE THIS FUNCTION!!!" (cond ;; Straight forms require some weirdness ((and s1-straight s2-straight) - (let* ((r (rx ":straight" (? "-if") (* space) (? "("))) + (let* ((r (rx ":straight" (? "-when") (* space) (? "("))) (s1 (replace-regexp-in-string r "" s1)) (s2 (replace-regexp-in-string r "" s2))) (string< s1 s2))) -- cgit 1.4.1-21-gabe81 From 3f7a8703edbdc0be14e5dca52dd736d9711c07b7 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 5 Oct 2021 14:23:47 -0500 Subject: Replace ytel with ytdious Better interface --- init.el | 13 +++++++------ lisp/acdw-ytel.el | 44 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 8 deletions(-) (limited to 'lisp') diff --git a/init.el b/init.el index fb6a8c9..4ad55a9 100644 --- a/init.el +++ b/init.el @@ -2470,14 +2470,15 @@ If used with a numeric prefix argument N, N backticks will be inserted." (setup (:straight xr)) -(setup (:straight-when ytel +(setup (:straight-when ytdious (executable-find "mpv")) - (:also-load acdw-ytel) - ;; This might need to be changed depending on whether the instance goes down. - (:option ytel-invidious-api-url "https://invidious.snopyta.org") + (:also-load acdw-ytel) ; so named because I used ytel first + (:option ytdious-invidious-api-url "https://invidious.snopyta.org") (:hook #'hl-line-mode) - (:bind "v" #'acdw/ytel-watch - "w" #'acdw/ytel-copy-link)) + (:global "C-c y" #'ytdious) + (:bind "v" #'acdw/ytdious-watch + "w" #'acdw/ytdious-copy-link + "q" #'acdw/ytdious-quit)) (setup (:straight zzz-to-char) diff --git a/lisp/acdw-ytel.el b/lisp/acdw-ytel.el index 01e6187..276323d 100644 --- a/lisp/acdw-ytel.el +++ b/lisp/acdw-ytel.el @@ -7,12 +7,12 @@ ;;; Code: -(require 'ytel) +(require 'ytel nil t) (defun acdw/ytel-current-video-link () "Get the link of the video at point." (let* ((video (ytel-get-current-video)) - (id (ytel-video-id video))) + (id (ytel-video-id video))) (concat "https://www.youtube.com/watch?v=" id))) (defun acdw/ytel-watch () ; This could possibly use `browse-url'. @@ -31,5 +31,45 @@ (kill-new link) (message "Copied %s to kill-ring" link))) + +;;; YTDIOUS: https://github.com/spiderbit/ytdious +;; a fork of ytel that uses table-view or w/e. looks nicer + +(require 'ytdious nil t) + +(defun acdw/ytdious-current-video-link () + "Get the link of the video at point." + (let* ((video (ytdious-get-current-video)) + (id (ytdious-video-id-fun video))) + (concat "https://www.youtube.com/watch?v=" id))) + +(defun acdw/ytdious-watch () ; This could possibly use `browse-url'. + "Stream video at point in mpv." + (interactive) + (let ((link (acdw/ytdious-current-video-link))) + (start-process "ytdious mpv" nil + "mpv" + link + "--ytdl-format=bestvideo[height<=?720]+bestaudio/best") + (message "Streaming %s..." link))) + +(defun acdw/ytdious-copy-link () + "Copy link of the video at point." + (interactive) + (let ((link (acdw/ytdious-current-video-link))) + (kill-new link) + (message "Copied %s to kill-ring" link))) + +(defun acdw/ytdious-quit () + "Quit ytdious." + ;; This corrects an error with `ytdious-quit' where it doesn't have the right + ;; buffer setup. + (interactive) + (quit-window)) + +;;; Ignore `ytdious-show-image-asyncron' because it's buggy. + +(defalias 'ytdious-show-image-asyncron #'ignore) + (provide 'acdw-ytel) ;;; acdw-ytel.el ends here -- cgit 1.4.1-21-gabe81