Update personal tab bar abstractions

This also fixes a couple of bugs, most notably, the new Mastodon
interface changes.
This commit is contained in:
Howard Abrams 2025-10-03 12:31:51 -07:00
parent 0cbcc59c27
commit bc1b7a1c35
5 changed files with 58 additions and 75 deletions

View file

@ -8,6 +8,15 @@ A literate programming file for bootstraping my Emacs Configuration.
#+begin_src emacs-lisp :exports none #+begin_src emacs-lisp :exports none
;;; bootstrap.el --- file for bootstraping my Emacs Configuration ;;; bootstrap.el --- file for bootstraping my Emacs Configuration
;; ;;
;; ██████████
;; ░░███░░░░░█
;; ░███ █ ░ █████████████ ██████ ██████ █████
;; ░██████ ░░███░░███░░███ ░░░░░███ ███░░███ ███░░
;; ░███░░█ ░███ ░███ ░███ ███████ ░███ ░░░ ░░█████
;; ░███ ░ █ ░███ ░███ ░███ ███░░███ ░███ ███ ░░░░███
;; ██████████ █████░███ █████░░████████░░██████ ██████
;; ░░░░░░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░
;; © 2021-2023 Howard X. Abrams ;; © 2021-2023 Howard X. Abrams
;; Licensed under a Creative Commons Attribution 4.0 International License. ;; Licensed under a Creative Commons Attribution 4.0 International License.
;; See http://creativecommons.org/licenses/by/4.0/ ;; See http://creativecommons.org/licenses/by/4.0/
@ -220,8 +229,7 @@ The following /defines/ the rest of my org-mode literate files, that I load late
"ha-org-publishing.org" "ha-org-publishing.org"
"ha-email.org" "ha-email.org"
"ha-aux-apps.org")) "ha-aux-apps.org"))
;; "ha-dashboard.org" "ha-dashboard.org"))
))
"List of org files that complete the hamacs project.") "List of org files that complete the hamacs project.")
#+end_src #+end_src

View file

@ -55,33 +55,33 @@ I would like a dedicate perspective to Mastodon, and I would like a leader key s
:config :config
(major-mode-hydra-define mastodon-mode nil (major-mode-hydra-define mastodon-mode nil
("Timelines" ("Timelines"
(("u" mastodon-tl--update "update") (("u" mastodon-tl-update "update")
("F" mastodon-tl--get-federated-timeline "Federated") ("F" mastodon-tl-get-federated-timeline "Federated")
("H" mastodon-tl--get-home-timeline "Home") ("H" mastodon-tl-get-home-timeline "Home")
("L" mastodon-tl--get-local-timeline "Local") ("L" mastodon-tl-get-local-timeline "Local")
("T" mastodon-tl--get-tag-timeline "Hashtag")) ("T" mastodon-tl-get-tag-timeline "Hashtag"))
"Specials" "Specials"
(("M" mastodon-notifications--get-mentions "Mentions") (("M" mastodon-notifications--get-mentions "Mentions")
("N" mastodon-notifications-get "Notifications") ("N" mastodon-notifications-get "Notifications")
("A" mastodon-tl--followed-tags-timeline "All Tags") ("A" mastodon-tl-followed-tags-timeline "All Tags")
("S" mastodon-profile--view-bookmarks "Saved bookmarks") ("S" mastodon-profile-view-bookmarks "Saved bookmarks")
("O" mastodon-profile--my-profile "My Profile")) ("O" mastodon-profile-my-profile "My Profile"))
"Post" "Post"
(("c" mastodon-toot "Compose toot") (("c" mastodon-toot "Compose toot")
("e" mastodon-toot--edit-toot-at-point "Edit toot") ("e" mastodon-toot-edit-toot-at-point "Edit toot")
("t" mastodon-tl--thread "Read thread") ("t" mastodon-tl-thread "Read thread")
("r" mastodon-toot--reply "Reply") ("r" mastodon-toot-reply "Reply")
("m" mastodon-tl--dm-user "Direct Msg") ("m" mastodon-tl-dm-user "Direct Msg")
("d" mastodon-toot--delete-toot "Delete")) ("d" mastodon-toot-delete-toot "Delete"))
"Toot" "Toot"
(("f" mastodon-toot--toggle-favourite "Favorite") (("f" mastodon-toot-toggle-favourite "Favorite")
("b" mastodon-toot--toggle-boost "Boost") ("b" mastodon-toot-toggle-boost "Boost")
("s" mastodon-toot--toggle-bookmark "Save") ("s" mastodon-toot-toggle-bookmark "Save")
("y" mastodon-toot--copy-toot-url "Copy URL") ("y" mastodon-toot-copy-toot-url "Copy URL")
("Y" mastodon-toot--copy-toot-text "Copy text")) ("Y" mastodon-toot-copy-toot-text "Copy text"))
"Navigation" "Navigation"
(("n" mastodon-tl--next-tab-item "next" :color pink) (("n" mastodon-tl-next-tab-item "next" :color pink)
("p" mastodon-tl--previous-tab-item "previous" :color pink) ("p" mastodon-tl-previous-tab-item "previous" :color pink)
("," ha-mastodon-scroll-or-more "...more" :color pink)))))) ("," ha-mastodon-scroll-or-more "...more" :color pink))))))
#+end_src #+end_src

View file

@ -990,44 +990,6 @@ New workspace is a tab with a specific name that opens up a specific buffer or a
((bufferp bff) (switch-to-buffer bff))))) ((bufferp bff) (switch-to-buffer bff)))))
#+end_src #+end_src
With a new tab group for a directory or probably a project, lets see if we can load the most useful files.
#+begin_src emacs-lisp
(defun ha-tab-bar-new-default ()
"Given a new perspective, display some buffer windows.
The choice of files to display depends on a combination of READMEs and
most recently viewed files in the project. This function assumes the
variable `default-directory' contains the root of the project."
(cl-flet ((one-win (file) (find-file file))
(two-win (left right)
(find-file right)
(split-window-right)
(find-file left))
(in-project (file)
(string-match (rx bos (literal default-directory))
(expand-file-name file))))
(let* ((recent-files (seq-filter #'in-project recentf-list))
(recent (car recent-files))
(readme-org (expand-file-name "README.org"))
(readme-md (expand-file-name "README.md")))
(cond
;; ORG + recent
((and (file-exists-p recent) (file-exists-p readme-org))
(two-win readme-org recent))
;; MD + recent
((and (file-exists-p recent) (file-exists-p readme-md))
(two-win readme-md recent))
;; recent-only
((file-exists-p recent)
(one-win recent))
;; ORG only
((file-exists-p readme-org)
(one-win readme-org))
;; MD only
((file-exists-p readme-md)
(one-win readme-md))))))
#+end_src
Create a new tab associated with a project: Create a new tab associated with a project:
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -1038,8 +1000,7 @@ Create a new tab associated with a project:
(let ((name (project-name (project-current nil project-dir))) (let ((name (project-name (project-current nil project-dir)))
(default-directory project-dir)) (default-directory project-dir))
(ha-tab-bar-new name) (ha-tab-bar-new name)
(project-switch-project project-dir) (project-switch-project project-dir)))
(ha-tab-bar-new-default)))
#+end_src #+end_src
If we close a tab that is a project, we want to close all the buffers associated with it. I wouldnt do this if it wasnt so easy to re-create them: If we close a tab that is a project, we want to close all the buffers associated with it. I wouldnt do this if it wasnt so easy to re-create them:
@ -1086,7 +1047,7 @@ And some shortcut keys from the =general= project:
I want to quickly jump, by the number shown on the tab, to that grouping. The following two functions create leader sequences with the name of the tab group: I want to quickly jump, by the number shown on the tab, to that grouping. The following two functions create leader sequences with the name of the tab group:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun ha-tab-update-names () (defun ha-tab-bar-update-names ()
"Create normal-mode keybindings for the tab groupings. "Create normal-mode keybindings for the tab groupings.
This creates `SPC TAB 1' to jump to the first tab, etc." This creates `SPC TAB 1' to jump to the first tab, etc."
;; Remove all previously created keybindings: ;; Remove all previously created keybindings:
@ -1095,9 +1056,9 @@ I want to quickly jump, by the number shown on the tab, to that grouping. The fo
(general-nmap :prefix "SPC" (format "<tab> %d" indx) nil))) (general-nmap :prefix "SPC" (format "<tab> %d" indx) nil)))
;; Loop through the existing tabs, create keys for each: ;; Loop through the existing tabs, create keys for each:
(seq-do-indexed 'ha-tab-update-tab-keybinding (tab-bar-tabs))) (seq-do-indexed 'ha-tab-bar-update-tab-keybinding (tab-bar-tabs)))
(defun ha-tab-update-tab-keybinding (tab-deets indx) (defun ha-tab-bar-update-tab-keybinding (tab-deets indx)
"Create a keybinding to jump to tab described by TAB-DEETS. "Create a keybinding to jump to tab described by TAB-DEETS.
The key sequence, `SPC' `TAB' then INDX." The key sequence, `SPC' `TAB' then INDX."
(let ((name (alist-get 'name tab-deets))) (let ((name (alist-get 'name tab-deets)))
@ -1107,14 +1068,14 @@ I want to quickly jump, by the number shown on the tab, to that grouping. The fo
(lambda () (interactive) (tab-bar-select-tab ,(1+ indx))))))) (lambda () (interactive) (tab-bar-select-tab ,(1+ indx)))))))
#+END_SRC #+END_SRC
Any time I create or delete a new tab, we can call =ha-tab-update-names=: Any time I create or delete a new tab, we can call =ha-tab-bar-update-names=:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(advice-add #'tab-bar-new-tab :after #'ha-tab-update-names) (advice-add #'tab-bar-new-tab :after #'ha-tab-bar-update-names)
(advice-add #'tab-bar-close-tab :after #'ha-tab-update-names) (advice-add #'tab-bar-close-tab :after #'ha-tab-bar-update-names)
(advice-add #'tab-bar-close-other-tabs :after #'ha-tab-update-names) (advice-add #'tab-bar-close-other-tabs :after #'ha-tab-bar-update-names)
(add-hook desktop-after-read-hook #'ha-tab-update-names) (add-hook desktop-after-read-hook #'ha-tab-bar-update-names)
#+END_SRC #+END_SRC
* Pretty Good Encryption * Pretty Good Encryption
@ -1143,12 +1104,8 @@ Also, as [[https://www.bytedude.com/gpg-in-emacs/][bytedude]] mentions, I need t
;; Make sure we prompt in the minibuffer for the password: ;; Make sure we prompt in the minibuffer for the password:
(epg-pinentry-mode 'loopback) (epg-pinentry-mode 'loopback)
;; I trust my Emacs session, so I don't bother expiring my pass: ;; I trust my Emacs session, so I don't bother expiring my pass:
(auth-source-cache-expiry nil)) (auth-source-cache-expiry nil)
#+end_src
Need to make sure that Emacs will handle the prompts, and turn it on:
#+begin_src emacs-lisp
(use-package epa-file
:config :config
(setenv "GPG_AGENT_INFO" nil) (setenv "GPG_AGENT_INFO" nil)
(epa-file-enable)) (epa-file-enable))

View file

@ -173,6 +173,7 @@ The [[https://github.com/emacs-dashboard/emacs-dashboard][emacs-dashboard]] proj
;; :hook (dashboard-after-initialize . ha-dashboard) ;; :hook (dashboard-after-initialize . ha-dashboard)
:config :config
(tab-bar-switch-to-tab "main")
(dashboard-setup-startup-hook)) (dashboard-setup-startup-hook))
#+end_src #+end_src

View file

@ -23,6 +23,15 @@ gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys 066DAFCB81E42C40
cat > "$HAMACS_DEST/early-init.el" <<EOF cat > "$HAMACS_DEST/early-init.el" <<EOF
;;; early-init.el --- Hamacs Early Init -*- lexical-binding: t; -*- ;;; early-init.el --- Hamacs Early Init -*- lexical-binding: t; -*-
;; ;;
;; ▄████████ ▄▄▄▄███▄▄▄▄ ▄████████ ▄████████ ▄████████
;; ███ ███ ▄██▀▀▀███▀▀▀██▄ ███ ███ ███ ███ ███ ███
;; ███ █▀ ███ ███ ███ ███ ███ ███ █▀ ███ █▀
;; ▄███▄▄▄ ███ ███ ███ ███ ███ ███ ███
;; ▀▀███▀▀▀ ███ ███ ███▀███████████ ███ ▀███████████
;; ███ █▄ ███ ███ ███ ███ ███ ███ █▄ ███
;; ███ ███ ███ ███ ███ ███ ███ ███ ███ ▄█ ███
;; ██████████ ▀█ ███ █▀ ███ █▀ ████████▀ ▄████████▀
;;
;;; Commentary: ;;; Commentary:
;; ;;
;; This is my early Emacs configuration file. See init.el for the real ;; This is my early Emacs configuration file. See init.el for the real
@ -69,6 +78,14 @@ echo "Created $HAMACS_DEST/early-init.el"
cat > "$HAMACS_DEST/init.el" <<EOF cat > "$HAMACS_DEST/init.el" <<EOF
;;; init.el --- Hamacs Init -*- lexical-binding: t; -*- ;;; init.el --- Hamacs Init -*- lexical-binding: t; -*-
;; ;;
;; :::::::::: :::: :::: ::: :::::::: ::::::::
;; :+: +:+:+: :+:+:+ :+: :+: :+: :+: :+: :+:
;; +:+ +:+ +:+:+ +:+ +:+ +:+ +:+ +:+
;; +#++:++# +#+ +:+ +#+ +#++:++#++: +#+ +#++:++#++
;; +#+ +#+ +#+ +#+ +#+ +#+ +#+
;; #+# #+# #+# #+# #+# #+# #+# #+# #+#
;; ########## ### ### ### ### ######## ########
;;
;;; Commentary: ;;; Commentary:
;; ;;
;; This is my Emacs Bootloader. Simply put, I initialize the package ;; This is my Emacs Bootloader. Simply put, I initialize the package