From c3601eaf2fad5bf0f011eda66b319cc87d5de97c Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 18 Jan 2022 10:30:02 -0600 Subject: Modify org-file-apps after loading org --- init.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.el b/init.el index e03e28f..7ec390f 100644 --- a/init.el +++ b/init.el @@ -490,8 +490,6 @@ "|" "DONE(d!)") (sequence "|" "CANCELED(k!)") (sequence "MEETING(m)"))) - (setf (alist-get "\\.x?html?\\'" org-file-apps nil nil #'equal) - #'+org-open-html) (:bind "RET" #'+org-return-dwim "" #'+org-table-copy-down "C-c C-l" #'+org-insert-link-dwim @@ -505,6 +503,8 @@ ;; (let ((browse-url-browser-function browse-url-secondary-browser-function)) ;; (apply fn r))) (with-eval-after-load 'org + (setf (alist-get "\\.x?html?\\'" org-file-apps nil nil #'equal) + #'+org-open-html) (org-clock-persistence-insinuate) (org-link-set-parameters "tel" :follow #'+org-tel-open)) ;; Extra keywords -- cgit 1.4.1-21-gabe81 From efc08126f7119569112b336f0cd73eefdf9737b5 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 18 Jan 2022 17:18:06 -0600 Subject: Um --- early-init.el | 8 ++--- eshell/history | 23 ++++++++++++++ eshell/lastdir | 5 +++ init.el | 91 +++++++++++++++++++++++++++++++++++++++++++------------ lisp/+elfeed.el | 75 +++++++++++++++++++++++++++++++++++++++++++-- lisp/+eshell.el | 8 ++--- lisp/+org.el | 8 +++-- lisp/+straight.el | 41 +++++++++++++++++++++++++ lisp/+tab-bar.el | 55 +++++++++++++++------------------ lisp/acdw.el | 24 +++++++++++++++ lisp/fibs.el | 37 ++++++++++++++++++++++ 11 files changed, 313 insertions(+), 62 deletions(-) create mode 100644 lisp/+straight.el create mode 100644 lisp/fibs.el diff --git a/early-init.el b/early-init.el index 67b4271..840a649 100644 --- a/early-init.el +++ b/early-init.el @@ -24,13 +24,13 @@ ;;(setq debug-on-error t) (message "Loading early-init.el...") -;; (define-advice load (:before (feature &rest _)) -;; "Message the user when loading a library." -;; (with-temp-message (format "Now loading: '%s'" feature))) +(define-advice load (:before (feature &rest _)) + "Message the user when loading a library." + (with-temp-message (format "Now loading: '%s'" feature))) ;;; Speed up init -;; (setq gc-cons-threshold most-positive-fixnum) +(setq gc-cons-threshold most-positive-fixnum) (add-hook 'emacs-startup-hook (defun emacs-startup@restore-values () diff --git a/eshell/history b/eshell/history index 67689e1..81214c1 100644 --- a/eshell/history +++ b/eshell/history @@ -12,3 +12,26 @@ vterm cat ~/Sync/fonts-debian.txt | sudo xargs apt install cat ~/Sync/fonts-debian.txt | sudo xargs apt install -y alias e='find-file $*' +emacs --debug-init +apt search xfce +sudo apt install bluebird-gtk-theme blackbird-gtk-theme greybird-gtk-theme xfce4-mount-plugin +apt search icons +sudo apt install elementary-xfce-icon-theme +apt search elementary +apt search wingpanel +apt search elementary +cd ~/src +ls +git clone https://github.com/elementary/stylesheet.git elementary-gtk-stylesheet +cd elementary-gtk-stylesheet/ +meson build --prefix=~/.local +meson build --prefix=$HOME/.local +sudo apt install meson ninja sassc +sudo apt install meson sassc +meson build --prefix=$HOME/.local +cd build +ninja install +ninja clean +sudo apt install gimp +(derived-mode-p 'eshell-mode) +echo $PAGER diff --git a/eshell/lastdir b/eshell/lastdir index 1549824..552e2ce 100644 --- a/eshell/lastdir +++ b/eshell/lastdir @@ -9,3 +9,8 @@ /home/case/Sync /home/case /home/case/.emacs.d +/home/case/Sync/emacs/private +/home/case/src +/home/case/src/elementary-gtk-stylesheet +/home/case/src/elementary-gtk-stylesheet/build +~ diff --git a/init.el b/init.el index 7ec390f..f7ce8db 100644 --- a/init.el +++ b/init.el @@ -413,13 +413,13 @@ ;; Brand new for Emacs 28: see https://ruzkuku.com/texts/emacs-mouse.html ;; Actually, look at this as well: https://www.emacswiki.org/emacs/Mouse3 (when (fboundp 'context-menu-mode) - ;; (:option context-menu-functions - ;; '(context-menu-ffap - ;; context-menu-region - ;; context-menu-undo - ;; context-menu-dictionary)) + (:option context-menu-functions + '(context-menu-ffap + context-menu-region + context-menu-undo + context-menu-dictionary)) (context-menu-mode +1)) - (dolist (click '( ; Fix scrolling in the margin + (dolist (click '(;; Fix scrolling in the margin wheel-down double-wheel-down triple-wheel-down wheel-up double-wheel-up triple-wheel-up)) (global-set-key (vector 'right-margin click) 'mwheel-scroll) @@ -624,11 +624,52 @@ (setup time ;; TODO: +display-time-mode with MOAR customizations - (:option display-time-format "%H:%M %a %e" - display-time-default-load-average nil + (:option display-time-default-load-average nil display-time-mail-file :disable) + (with-eval-after-load 'discord + (with-eval-after-load '+tab-bar + (:option display-time-string-forms + '((propertize (format-time-string "%H:%M %a %e" now) + 'face '+tab-bar-extra + 'help-echo (discord-date-string)) + load + (if mail + (concat " " + (propertize + display-time-mail-string + 'display `(when (and display-time-use-mail-icon + (display-graphic-p)) + ,@display-time-mail-icon + ,@(when (and + display-time-mail-face + (memq + (plist-get + (cdr display-time-mail-icon) + :type) + '(pbm xbm))) + (let ((bg (face-attribute + display-time-mail-face + :background))) + (when (stringp bg) + (list :background bg))))) + 'face display-time-mail-face)) + "") + " ")))) + (display-time-mode +1)) +(setup tramp + (el-patch-feature tramp) + (with-eval-after-load 'tramp + (el-patch-defun tramp-debug-buffer-command-completion-p (_symbol buffer) + "A predicate for Tramp interactive commands. +They are completed by \"M-x TAB\" only in Tramp debug buffers." + (with-current-buffer buffer + (el-patch-wrap 2 + (save-restriction + (widen) + (string-equal (buffer-substring 1 10) ";; Emacs:"))))))) + (setup (:straight 0x0) (:option 0x0-default-server 'ttm) (with-eval-after-load 'embark @@ -1013,7 +1054,7 @@ See also `crux-reopen-as-root-mode'." (electric-cursor-mode +1)) (setup (:straight elfeed) - (:also-load +elfeed) + (:require +elfeed) (+define-dir elfeed/ (sync/ "emacs/elfeed/" t)) (:option elfeed-curl-program-name (executable-find "curl") @@ -1044,10 +1085,7 @@ See also `crux-reopen-as-root-mode'." "&" #'+elfeed-show-browse-generic "RET" #'shr-browse-url) (:hook #'reading-mode) - ;; (define-advice elfeed-show-entry (:after (&rest _)) - ;; "Re-flow the entry a short time after showing it." - ;; (run-at-time 0.1 nil #'elfeed-show-refresh)) - )) + (+elfeed-update-async-mode +1))) (setup (:straight elfeed-org) (:also-load +org-capture) @@ -1210,6 +1248,8 @@ See also `crux-reopen-as-root-mode'." (setup (:straight hungry-delete) (:option hungry-delete-chars-to-skip " \t" hungry-delete-join-reluctantly nil) + (+with-ensure-after-init + (add-to-list 'hungry-delete-except-modes 'eshell-mode)) (:bind-into paredit ;; I define these functions here because they really require both packages ;; to make any sense. So, would I put them in `+hungry-delete' or @@ -1295,6 +1335,17 @@ See also `crux-reopen-as-root-mode'." (setf (alist-get 'markdown-mode apheleia-mode-alist) 'markdownfmt) (setf (alist-get 'gfm-mode apheleia-mode-alist) 'markdownfmt)))) +(setup (:straight mastodon) + (:option mastodon-instance-url "https://tiny.tilde.website" + mastodon-client--token-file (.etc "mastodon.plstore") + mastodon-auth-source-file (car auth-sources) + mastodon-tl--enable-proportional-fonts t + mastodon-tl--show-avatars t) + (:hook #'mastodon-async-mode + #'reading-mode + #'hl-line-mode + #'lin-mode)) + (setup (:straight minions) (minions-mode +1)) @@ -1647,13 +1698,6 @@ See also `crux-reopen-as-root-mode'." (sync/ "emacs/snippets" t))) (yas-global-mode +1)) -(setup (:straight zoom-frm)) - -(setup (:straight zzz-to-char) - (:require +zzz-to-char) - (:option zzz-to-char-reach 1024) - (:global "M-z" #'+zzz-to-char)) - (setup (:straight (ytdious :host github :repo "spiderbit/ytdious" :fork (:host github :repo "duckwork/ytdious"))) @@ -1662,3 +1706,10 @@ See also `crux-reopen-as-root-mode'." (concat "https://" +invidious-host) "https://invidious.snopyta.org")) (:bind "y" #'+ytdious-watch)) + +(setup (:straight zoom-frm)) + +(setup (:straight zzz-to-char) + (:require +zzz-to-char) + (:option zzz-to-char-reach (+bytes 1 :kib)) + (:global "M-z" #'+zzz-to-char)) diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el index 9e5f787..ef93347 100644 --- a/lisp/+elfeed.el +++ b/lisp/+elfeed.el @@ -2,8 +2,6 @@ ;;; Code: -(require 'elfeed) - ;; https://karthinks.com/software/lazy-elfeed/ (defun +elfeed-scroll-up-command (&optional arg) "Scroll up or go to next feed item in Elfeed" @@ -31,5 +29,78 @@ (interactive) (elfeed-show-visit t)) +;;; Fetch feeds async +;; https://github.com/skeeto/elfeed/issues/367 + +(defun +elfeed--update-message () + (message "[Elfeed] Update in progress") + 'ignore) + +(defvar +elfeed--update-running nil "Whether an update is currently running.") + +(defun +elfeed-update-command () + (interactive) + (let ((script (expand-file-name "~/.local/bin/elfeed"))) + (message "[Elfeed] Updating in the background.") + (setq +elfeed--update-running t) + (elfeed-db-save) + (advice-add 'elfeed :override #'+elfeed--update-message) + (ignore-errors (kill-buffer "*elfeed-search*")) + (ignore-errors (kill-buffer "*elfeed-log*")) + (elfeed-db-unload) + (unless (file-exists-p script) + (make-directory (file-name-directory script) :parents) + (with-temp-buffer + (insert "(progn\n" + " (load (locate-user-emacs-file \"early-init\"))\n" + " (straight-use-package 'elfeed)\n" + " (require 'elfeed)\n" + " (elfeed)\n" + " (elfeed-update)\n" + " (while (> (elfeed-queue-count-total) 0)\n" + " (sleep-for 5)\n" + " (message \"%s\" (elfeed-queue-count-total))\n" + " (accept-process-output))\n" + " (elfeed-db-save-safe)\n" + " (elfeed-db-gc-safe))") + (write-file script))) + (set-process-sentinel (start-process-shell-command + "Elfeed" nil (concat "emacs --script " script)) + (lambda (a b) + (advice-remove 'elfeed #'+elfeed--update-message) + (setq +elfeed--update-running nil) + (message "[Elfeed] Background update %s." + (string-trim b)))))) + +(defvar +elfeed--update-timer nil "Timer for `elfeed-update-command'.") +(defvar +elfeed--update-first-time 6 "How long to wait for the first time.") +(defvar +elfeed--update-repeat (* 60 15) "How long between updates.") + +(defun +elfeed--cancel-update-timer () + "Cancel `+elfeed--update-timer'." + (unless +elfeed--update-running + (ignore-errors (cancel-timer +elfeed--update-timer)) + (setq +elfeed--update-timer nil))) + +(defun +elfeed--reinstate-update-timer () + "Reinstate `+elfeed--update-timer'." + (setq +elfeed--update-timer + (run-at-time +elfeed--update-first-time + +elfeed--update-repeat + #'+elfeed-update-command))) + +(define-minor-mode +elfeed-update-async-mode + "Minor mode to update elfeed async-style every 15 minutes." + :global t + (if +elfeed-update-async-mode + (progn ; enable + (+elfeed--reinstate-update-timer) + (advice-add 'elfeed :before '+elfeed--cancel-update-timer) + (advice-add 'elfeed-search-quit-window :after '+elfeed--reinstate-update-timer)) + (progn ; disable + (advice-remove 'elfeed '+elfeed--cancel-update-timer) + (advice-remove 'elfeed-search-quit-window '+elfeed--reinstate-update-timer) + (+elfeed--cancel-update-timer)))) + (provide '+elfeed) ;;; +elfeed.el ends here diff --git a/lisp/+eshell.el b/lisp/+eshell.el index 1f8677c..d49358d 100644 --- a/lisp/+eshell.el +++ b/lisp/+eshell.el @@ -91,10 +91,10 @@ something, it's really annoying to work with." ,@forms) (when (featurep 'eshell) `(dolist (buf (buffer-list)) - (with-current-buffer buf - (when (derived-mode-p 'eshell-mode) - (+eshell@setup))))) - '(add-hook 'eshell-mode-hook #'+eshell@setup))) + (with-current-buffer buf + (when (derived-mode-p 'eshell-mode) + (+eshell@setup))))) + (add-hook 'eshell-mode-hook #'+eshell@setup))) (provide '+eshell) ;;; +eshell.el ends here diff --git a/lisp/+org.el b/lisp/+org.el index 5869622..11a816f 100644 --- a/lisp/+org.el +++ b/lisp/+org.el @@ -433,8 +433,12 @@ the deletion might narrow the column." (when (and (memq this-char-type types) (memq prev-char-type types)) (backward-char) (setq type prev-char-type)) ; what the fuckckckckck - (if (memq type types) - (progn (org-open-at-point arg)) + ;; Okay, so this ^ is pretty janky and doesn't /really/ work that well, + ;; especially on DEADLINE (and probably SCHEDULED) lines. However, since + ;; I really just want to open the list of URLs /most of the time/, I'm + ;; fixing it like this instead. + (unless (and (memq type types) + (ignore-errors (org-open-at-point arg))) (while (not (progn (org-back-to-heading) diff --git a/lisp/+straight.el b/lisp/+straight.el new file mode 100644 index 0000000..d00ad9a --- /dev/null +++ b/lisp/+straight.el @@ -0,0 +1,41 @@ +;;; +straight.el --- Straight.el extras -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + +(defun +straight-update-package (package &optional recursive) + "Update PACKAGE using straight. +This pulls, rebuilds, and loads the updated PACKAGE." + (interactive (list (straight--select-package "Update package" + #'straight--installed-p) + current-prefix-arg)) + (+with-message (format "Pulling package `%s'%s" package + (if recursive " and deps" "")) + (funcall (if recursive + #'straight-pull-package-and-deps + #'straight-pull-package) + package + :from-upstream)) + (+with-message (format "Rebuilding package `%s'%s" package + (if recursive " and deps" "")) + (straight-rebuild-package package recursive)) + (+with-message (format "Loading package `%s'%s" package + (if recursive " and deps" "")) + (ignore-errors (load-library (symbol-name package))) + (when recursive + (dolist (dep (straight--get-transitive-dependencies package)) + (ignore-errors (load-library (symbol-name package))))))) + +(defun +straight-update-all (from-upstream) + "Update all installed packages using straight. +This pulls and rebuilds all packages at once. It does not reload +all of them, for reasons that should be obvious. + +With a prefix argument, it also pulls the packages FROM-UPSTREAM." + (interactive "P") + (straight-pull-all from-upstream) + (straight-rebuild-all)) + +(provide '+straight) +;;; +straight.el ends here diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index 2e9198c..b11be2c 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el @@ -22,7 +22,7 @@ `((global menu-item ,(string-trim-right (format-mode-line mode-line-misc-info)) - ignore))) + ignore :help (discord-date-string)))) (defvar +tab-bar-show-original nil "Original value of `tab-bar-show'.") @@ -129,35 +129,30 @@ Used by `tab-bar-format-menu-bar'." ;;; Tab bar format tabs (require 'el-patch) - -(el-patch-defun tab-bar--format-tab (tab i) - (append - (el-patch-remove - `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore))) - (cond - ((eq (car tab) 'current-tab) - `((current-tab - menu-item - ,(funcall tab-bar-tab-name-format-function tab i) - ignore - :help "Current tab"))) - (t - `((,(intern (format "tab-%i" i)) - menu-item - ,(funcall tab-bar-tab-name-format-function tab i) - ,(or - (alist-get 'binding tab) - `(lambda () - (interactive) - (tab-bar-select-tab ,i))) - :help "Click to visit tab")))) - `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) - menu-item "" - ,(or - (alist-get 'close-binding tab) - `(lambda () - (interactive) - (tab-bar-close-tab ,i))))))) +(el-patch-feature tab-bar) +(with-eval-after-load 'tab-bar + (el-patch-defun tab-bar--format-tab (tab i) + "Format TAB using its index I and return the result as a keymap." + (append + (el-patch-remove + `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore))) + (cond + ((eq (car tab) 'current-tab) + `((current-tab + menu-item + ,(funcall tab-bar-tab-name-format-function tab i) + ignore + :help "Current tab"))) + (t + `((,(intern (format "tab-%i" i)) + menu-item + ,(funcall tab-bar-tab-name-format-function tab i) + ,(alist-get 'binding tab) + :help "Click to visit tab")))) + (when (alist-get 'close-binding tab) + `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) + menu-item "" + ,(alist-get 'close-binding tab))))))) ;; Emacs 27 diff --git a/lisp/acdw.el b/lisp/acdw.el index 17741ab..a96e6a7 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -248,5 +248,29 @@ With optional ARG (\\[universal-argument]), just split." (interactive "P") (+split-window-then :below arg)) +(defun +bytes (number unit) + "Convert NUMBER UNITs to bytes. +UNIT can be one of :kb, :mb, :gb, :tb, :pb, :eb, :zb, :yb; :kib, :mib, :gib, +:tib, :pib, :eib, :zib, :yib." + (* number (pcase unit + ;; Base 10 units + (:kb 1000) + (:mb (* 1000 1000)) + (:gb (* 1000 1000 1000)) + (:tb (* 1000 1000 1000 1000)) + (:pb (* 1000 1000 1000 1000 1000)) + (:eb (* 1000 1000 1000 1000 1000 1000)) + (:zb (* 1000 1000 1000 1000 1000 1000 1000)) + (:yb (* 1000 1000 1000 1000 1000 1000 1000 1000)) + ;; Base 2 units + (:kib 1024) + (:mib (* 1024 1024)) + (:gib (* 1024 1024 1024)) + (:tib (* 1024 1024 1024 1024)) + (:pib (* 1024 1024 1024 1024 1024)) + (:eib (* 1024 1024 1024 1024 1024 1024)) + (:zib (* 1024 1024 1024 1024 1024 1024 1024)) + (:yib (* 1024 1024 1024 1024 1024 1024 1024 1024))))) + (provide 'acdw) ;;; acdw.el ends here diff --git a/lisp/fibs.el b/lisp/fibs.el new file mode 100644 index 0000000..545c2a7 --- /dev/null +++ b/lisp/fibs.el @@ -0,0 +1,37 @@ +;;; fibs.el --- Play backgammon with FIBS -*- lexical-binding: t; -*- + +;;; Commentary: + +;; fibs.com is one of the oldest backgammon servers out there, and it's +;; accessible via telnet. This package provides a wrapper to enable you to play +;; backgammon on fibs.com more easily than just opening a telnet session +;; yourself. + +;;; TODO: + +;; - Automatically log in. +;; - Add a `fibs-quit' function to kill the telnet server and buffer. + +;;; Code: + +(require 'telnet) + +(defgroup fibs nil + "Customizations for FIBS, the First Internet Backgammon Server." + :group 'games) + +(defcustom fibs-server "fibs.com" + "The server to connect to FIBS with." + :type 'string) + +(defcustom fibs-port 4321 + "The port to connect to FIBS with." + :type 'number) + +;;;###autoload +(defun fibs () + (interactive) + (telnet fibs-server fibs-port)) + +(provide 'fibs) +;;; fibs.el ends here -- cgit 1.4.1-21-gabe81