From f7663559a1697ff8907502ef1f8e7e7452244635 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Thu, 10 Feb 2022 23:11:20 +0100 Subject: [PATCH] Add mmk2410/tab-bar-helper package --- packages/tab-bar-helpers.el | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 packages/tab-bar-helpers.el diff --git a/packages/tab-bar-helpers.el b/packages/tab-bar-helpers.el new file mode 100644 index 0000000..3cbe304 --- /dev/null +++ b/packages/tab-bar-helpers.el @@ -0,0 +1,67 @@ +;; -*- lexical-binding: t; -*- + +(defun mmk2410/tab-bar-new-tab (name func) + (when (eq nil tab-bar-mode) + (tab-bar-mode)) + (tab-bar-new-tab) + (tab-bar-rename-tab name) + (funcall func) + nil) + +(defun mmk2410/tab-bar-tab-exists (name) + (member name + (mapcar #'(lambda (tab) (alist-get 'name tab)) + (tab-bar-tabs)))) + +(defun mmk2410/tab-bar-switch-or-create (name func) + (if (mmk2410/tab-exists name) + (tab-bar-switch-to-tab name) + (mmk2410/new-tab name func))) + +(defun mmk2410/tab-bar-run-elfeed () + (interactive) + (mmk2410/tab-bar-switch-or-create "RSS" #'elfeed)) + +(defun mmk2410/tab-bar-run-mail () + (interactive) + (mmk2410/tab-bar-switch-or-create "Mail" + #'(lambda () + (mu4e-context-switch :name "Private") + (mu4e)))) + +(defun mmk2410/tab-bar-run-irc () + (interactive) + (mmk2410/tab-bar-switch-or-create "IRC" + #'(lambda () + (mmk2410/erc-connect) + (sit-for 1) + (switch-to-buffer "Libera.Chat")))) + +(defun mmk2410/tab-bar-run-agenda () + (interactive) + (mmk2410/tab-bar-switch-or-create "Agenda" + #'(lambda () + (org-agenda nil "a")))) + +(defun mmk2410/tab-bar-run-journal () + (interactive) + (mmk2410/tab-bar-switch-or-create "Journal" #'org-journal-open-current-journal-file)) + +(defun mmk2410/tab-bar-run-projects () + (interactive) + (mmk2410/tab-bar-switch-or-create "Projects" + #'(lambda () + (find-file "~/org/work.projects.org")))) + +(defhydra mmk2410/tab-bar (:color teal) + "My tab-bar helpers" + ("a" mmk2410/tab-bar-run-agenda "Agenda") + ("e" mmk2410/tab-bar-run-elfeed "RSS (Elfeed)") + ("i" mmk2410/tab-bar-run-irc "IRC (erc)") + ("j" mmk2410/tab-bar-run-journal "Journal") + ("m" mmk2410/tab-bar-run-mail "Mail") + ("p" mmk2410/tab-bar-run-projects "Projects")) + +(global-set-key (kbd "C-c f") 'mmk2410/tab-bar/body) + +(provide mmk2410/tab-bar-helpers)