This commit is contained in:
Jeffrey Serio 2023-10-13 17:26:17 -05:00
parent e3106c1e70
commit d88b5ba312
2 changed files with 209 additions and 80 deletions

207
config.el
View File

@ -128,13 +128,13 @@ Version 2015-08-22"
(kill-new (buffer-string))
(delete-region (point-min) (point-max)))))
;; open URL in Firefox
(defun browse-host-firefox (url &rest ignored)
"Browse URL with the host's Firefox using distrobox-exec."
;; open URL in Firefox/LibreWolf
(defun browse-host-web (url &rest ignored)
"Browse URL with Firefox/LibreWolf"
(interactive "sURL: ")
(shell-command (concat "firefox " url)))
(shell-command (concat "librewolf " url)))
(setq browse-url-browser-function 'browse-host-firefox)
(setq browse-url-browser-function 'browse-host-web)
;; after copy Ctrl+c in Linux X11, you can paste by `yank' in emacs
(setq select-enable-clipboard t)
@ -231,8 +231,9 @@ If point was already at that position, move point to beginning of line."
;; org-mode tags
(setq org-tag-alist (quote (("@archiving" .?a)
("@calendar" .?d)
("@calendar" .?t)
("@config" . ?c)
("@devel" . ?d)
("@errand" . ?e)
("@fedora" . ?f)
("@homelab" . ?l)
@ -457,45 +458,32 @@ If point was already at that position, move point to beginning of line."
(setq centaur-tabs-buffer-show-groups t)
(defun centaur-tabs-buffer-groups ()
"`centaur-tabs-buffer-groups' control buffers' group rules.
Group centaur-tabs with mode if buffer is derived from `eshell-mode'
`emacs-lisp-mode' `dired-mode' `org-mode' `magit-mode'
All buffer names starting with * will group to \"Emacs\".
Other buffer groups by `centaur-tabs-get-group-name' wit project name."
(list
(defun my-centaur-tabs-buffer-groups ()
"Create centaur-tabs groups."
(cond
((or (string-equal "*" (substring (buffer-name) 0 1))
(memq major-mode '(magit-process-mode
magit-status-mode
magit-diff-mode
magit-log-mode
magit-file-mode
magit-blob-mode
magit-blame-mode
)))
"Emacs")
((derived-mode-p 'prog-mode)
"Editing")
((derived-mode-p 'dired-mode)
"Dired")
((memq major-mode '(helpful-mode
help-mode))
"Help")
((string-equal "*" (substring (buffer-name) 0 1))
'("Emacs"))
((eq major-mode 'erc-mode)
'("ERC"))
((memq major-mode '(org-mode
org-agenda-clockreport-mode
org-src-mode
org-agenda-mode
org-beamer-mode
org-indent-mode
org-bullets-mode
org-agenda-log-mode
diary-mode
org-roam-mode))
"OrgMode")
(t
(centaur-tabs-get-group-name (current-buffer))))))
'("OrgMode"))
((memq major-mode '(dired-mode))
'("Dired"))
((memq major-mode '(helpful-mode
help-mode))
'("Help"))
((memq major-mode '(vterm-mode))
'("VTerm"))))
(setq centaur-tabs-buffer-groups-function 'my-centaur-tabs-buffer-groups)
;; prevent access to specified buffers
(defun centaur-tabs-hide-tab (x)
@ -512,6 +500,7 @@ Other buffer groups by `centaur-tabs-get-group-name' wit project name."
(string-prefix-p "*tramp" name)
(string-prefix-p "*help" name)
(string-prefix-p "*Help" name)
(string-prefix-p "*vterminal" name)
;; Buffer is not a magit buffer.
(and (string-prefix-p "magit" name)
@ -524,7 +513,147 @@ Other buffer groups by `centaur-tabs-get-group-name' wit project name."
(setq elfeed-protocol-enabled-protocols '(fever))
(elfeed-protocol-enable)
(setq elfeed-protocol-fever-update-unread-only t)
(setq elfeed-feeds (list
(list "fever+https://hyperreal@rss.hyperreal.coffee"
:api-url "https://rss.hyperreal.coffee/api/fever.php"
:password (shell-command-output-string "pass show freshrss/hyperreal"))))
(setq elfeed-protocol-feeds '(("fever+https://admin@rss.hyperreal.coffee"
:api-url "https://rss.hyperreal.coffee/fever/"
:password (shell-command-output-string "pass show miniflux/admin"))))
;; ;; elpher
(setq elpher-certificate-directory "~/sync/elpher/certs")
(setq elpher-default-url-type "gemini")
;;;; vterm
(setq vterm-kill-buffer-on-exit t)
(setq vterm-always-compile-module t)
(setq multi-vterm-buffer-name "localhost")
(defun hyperreal/create-mvterm-buffer ()
"Create new multi-vterm buffer and rename it to localhost<i>
and switch to it."
(interactive)
(let ((index 1)
(buffer-name "localhost"))
;; Find the next available index number
(while (get-buffer (format "%s<%d>" buffer-name index))
(setq index (1+ index)))
(multi-vterm)
(setq mvterm-buffer-name (format "%s<%d>" buffer-name index))
(rename-buffer mvterm-buffer-name)
(message "Created and started: %s" mvterm-buffer-name)
(switch-to-buffer mvterm-buffer-name)))
(defun hyperreal/setup-mvterm ()
"Create a set of vterm buffers for my terminal setup."
(interactive)
(require 'vterm)
(let ((buffer-command-pairs '(("journald" . "sudo journalctl -f")
("htop" . "htop")
("nexus" . "autossh -M 0 jas@nexus.local")
("apocrypha" . "autossh -M 0 jas@apocrypha.local")
("rockpro64" . "autossh -M 0 dietpi@rockpro64.local")
("orangepi5" . "autossh -M 0 dietpi@orangepi5.local"))))
(dolist (pair buffer-command-pairs)
(let ((buffer-name (car pair))
(command (cdr pair)))
;; Check if buffer exists
(unless (get-buffer buffer-name)
(multi-vterm)
(rename-buffer buffer-name)
;; Send the command to the vterm buffer
(vterm-send-string command)
(vterm-send-return)
(message "Created and started: %s" buffer-name))))
;; Create and switch to default buffer
(hyperreal/create-mvterm-buffer)
(centaur-tabs-mode)))
(defun hyperreal/kill-all-vterms ()
"Kill all vterm buffers (do not ask for confirmation)."
(interactive)
(let ((kill-buffer-query-functions nil))
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(when (eq major-mode 'vterm-mode)
(kill-buffer buffer)))))
(message "All vterm buffers killed."))
;;;; ERC
(setq erc-timestamp-format "[%H:%M:%S] ")
(setq erc-insert-timestamp-function 'erc-insert-timestamp-left)
(setq erc-fill-prefix " ")
(setq erc-fill-function 'erc-fill-static)
(setq erc-hide-list '("JOIN" "PART" "QUIT"))
(defun tilde-chat ()
"Connect to irc.tilde.chat."
(interactive)
(setq erc-email-userid "hyperreal/irc.tilde.chat")
(erc-tls :server "chat.sr.ht"
:port 6697
:nick "hyperreal"
:password (shell-command-output-string "pass show chat.sr.ht/hyperreal")
:full-name "Jeffrey Serio")
(centaur-tabs-mode))
(defun libera-chat ()
"Connect to irc.libera.chat."
(interactive)
(setq erc-email-userid "hyperreal/irc.libera.chat")
(erc-tls :server "chat.sr.ht"
:port 6697
:nick "hyperreal"
:password (shell-command-output-string "pass show chat.sr.ht/hyperreal")
:full-name "Jeffrey Serio")
(centaur-tabs-mode))
;; nickcolor funcs lifted from EmacsWiki
(defmacro unpack-color (color red green blue &rest body)
`(let ((,red (car ,color))
(,green (car (cdr ,color)))
(,blue (car (cdr (cdr ,color)))))
,@body))
(defun rgb-to-html (color)
(unpack-color color red green blue
(concat "#" (format "%02x%02x%02x" red green blue))))
(defun hexcolor-luminance (color)
(unpack-color color red green blue
(floor (+ (* 0.299 red) (* 0.587 green) (* 0.114 blue)))))
(defun invert-color (color)
(unpack-color color red green blue
`(,(- 255 red) ,(- 255 green) ,(- 255 blue))))
(defun erc-get-color-for-nick (nick dark)
(let* ((hash (md5 (downcase nick)))
(red (mod (string-to-number (substring hash 0 10) 16) 256))
(blue (mod (string-to-number (substring hash 10 20) 16) 256))
(green (mod (string-to-number (substring hash 20 30) 16) 256))
(color `(,red ,green ,blue)))
(rgb-to-html (if (if dark (< (hexcolor-luminance color) 85)
(> (hexcolor-luminance color) 170))
(invert-color color)
color))))
(defun erc-highlight-nicknames ()
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\\w+" nil t)
(let* ((bounds (bounds-of-thing-at-point 'symbol))
(nick (buffer-substring-no-properties (car bounds) (cdr bounds))))
(when (erc-get-server-user nick)
(put-text-property
(car bounds) (cdr bounds) 'face
(cons 'foreground-color (erc-get-color-for-nick nick 't))))))))
(add-hook 'erc-insert-modify-hook 'erc-highlight-nicknames)
;; set the column width based on window width
(add-hook 'window-configuration-change-hook
#'(lambda ()
(setq erc-fill-column (- (window-width) 2))))

View File

@ -5,11 +5,10 @@
;; on the command line, then restart Emacs for the changes to take effect -- or
;; use 'M-x doom/reload'.
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;(package! some-package)
(package! artbollocks-mode :recipe
(:host nil :repo "https://github.com/sachac/artbollocks-mode"))
;(package! some-package)
(package! artbollocks-mode
:recipe (:host github :repo "sachac/artbollocks-mode"))
(package! autothemer)
(package! catppuccin-theme)
(package! elfeed)
@ -27,6 +26,7 @@
(package! just-mode)
(package! justl)
(package! license-templates)
(package! multi-vterm)
(package! nov)
(package! org-roam)
(package! org-superstar)