2023-06-14 18:05:38 +02:00
|
|
|
;;; tab-bar-helpers.el --- Helpers for using tab-bar mode -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Personal helpers and shortcuts to work more effectively with tab-bar mode.
|
|
|
|
|
|
|
|
;;; Code:
|
2022-02-10 23:11:20 +01:00
|
|
|
|
|
|
|
(defun mmk2410/tab-bar-new-tab (name func)
|
2023-06-14 18:05:38 +02:00
|
|
|
"Create new tab using FUNC with name NAME."
|
2022-02-10 23:11:20 +01:00
|
|
|
(when (eq nil tab-bar-mode)
|
|
|
|
(tab-bar-mode))
|
|
|
|
(tab-bar-new-tab)
|
|
|
|
(tab-bar-rename-tab name)
|
2022-02-10 23:18:47 +01:00
|
|
|
(funcall func))
|
2022-02-10 23:11:20 +01:00
|
|
|
|
|
|
|
(defun mmk2410/tab-bar-tab-exists (name)
|
2023-06-14 18:05:38 +02:00
|
|
|
"Check whether a tab named NAME exists."
|
2022-02-10 23:11:20 +01:00
|
|
|
(member name
|
|
|
|
(mapcar #'(lambda (tab) (alist-get 'name tab))
|
|
|
|
(tab-bar-tabs))))
|
|
|
|
|
|
|
|
(defun mmk2410/tab-bar-switch-or-create (name func)
|
2023-06-14 18:05:38 +02:00
|
|
|
"Switch to tab with name NAME or create one using FUNC."
|
2022-02-12 22:51:26 +01:00
|
|
|
(if (mmk2410/tab-bar-tab-exists name)
|
2022-02-10 23:11:20 +01:00
|
|
|
(tab-bar-switch-to-tab name)
|
2022-02-12 22:51:26 +01:00
|
|
|
(mmk2410/tab-bar-new-tab name func)))
|
2022-02-10 23:11:20 +01:00
|
|
|
|
2022-03-30 16:53:26 +02:00
|
|
|
(defun mmk2410/tab-bar-new-named-tab (name)
|
2023-06-14 18:05:38 +02:00
|
|
|
"Create new tab with named NAME."
|
2022-03-30 16:53:26 +02:00
|
|
|
(interactive "sTab Name: ")
|
|
|
|
(tab-bar-new-tab)
|
|
|
|
(tab-bar-rename-tab name))
|
|
|
|
|
2023-06-14 18:05:38 +02:00
|
|
|
(defun mmk2410/tab-bar-run-elfeed ()
|
|
|
|
"Switch to or start elfeed."
|
|
|
|
(interactive)
|
|
|
|
(mmk2410/tab-bar-switch-or-create "RSS" #'elfeed))
|
|
|
|
|
2024-05-28 16:40:09 +02:00
|
|
|
(defun mmk2410/tab-bar-run-pocket-reader ()
|
|
|
|
"Switch to or start pocket reader."
|
|
|
|
(interactive)
|
|
|
|
(mmk2410/tab-bar-switch-or-create "Pocket" #'pocket-reader))
|
|
|
|
|
2022-02-10 23:11:20 +01:00
|
|
|
(defun mmk2410/tab-bar-run-mail ()
|
2023-06-14 18:05:38 +02:00
|
|
|
"Switch to or start mu4e."
|
2022-02-10 23:11:20 +01:00
|
|
|
(interactive)
|
2022-02-10 23:18:47 +01:00
|
|
|
(mmk2410/tab-bar-switch-or-create
|
|
|
|
"Mail"
|
|
|
|
#'(lambda ()
|
|
|
|
(mu4e-context-switch :name "Private")
|
|
|
|
(mu4e))))
|
2022-02-10 23:11:20 +01:00
|
|
|
|
|
|
|
(defun mmk2410/tab-bar-run-irc ()
|
2023-06-14 18:05:38 +02:00
|
|
|
"Switch to or start ERC session."
|
2022-02-10 23:11:20 +01:00
|
|
|
(interactive)
|
2022-02-10 23:18:47 +01:00
|
|
|
(mmk2410/tab-bar-switch-or-create
|
|
|
|
"IRC"
|
|
|
|
#'(lambda ()
|
|
|
|
(mmk2410/erc-connect)
|
|
|
|
(sit-for 1)
|
|
|
|
(switch-to-buffer "Libera.Chat"))))
|
2022-02-10 23:11:20 +01:00
|
|
|
|
|
|
|
(defun mmk2410/tab-bar-run-agenda ()
|
2023-06-14 18:05:38 +02:00
|
|
|
"Switch to or open agenda tab."
|
|
|
|
(interactive)
|
|
|
|
(mmk2410/tab-bar-switch-or-create
|
|
|
|
"Agenda"
|
|
|
|
#'(lambda ()
|
|
|
|
(org-agenda nil "d"))))
|
|
|
|
|
|
|
|
(defun mmk2410/tab-bar-run-agenda-journal ()
|
|
|
|
"Switch to or open agenda+journal tab."
|
2022-02-10 23:11:20 +01:00
|
|
|
(interactive)
|
2022-02-10 23:18:47 +01:00
|
|
|
(mmk2410/tab-bar-switch-or-create
|
|
|
|
"Agenda"
|
|
|
|
#'(lambda ()
|
2023-01-03 16:27:08 +01:00
|
|
|
(org-agenda nil "d")
|
2022-06-23 16:50:28 +02:00
|
|
|
(sit-for 1)
|
|
|
|
(split-window-horizontally)
|
|
|
|
(other-window 1)
|
2022-10-13 20:20:25 +02:00
|
|
|
(org-roam-dailies-goto-today))))
|
2022-02-10 23:11:20 +01:00
|
|
|
|
|
|
|
(defun mmk2410/tab-bar-run-journal ()
|
2023-06-14 18:05:38 +02:00
|
|
|
"Switch to or create org-roam daily journal."
|
2022-02-10 23:11:20 +01:00
|
|
|
(interactive)
|
2022-02-10 23:18:47 +01:00
|
|
|
(mmk2410/tab-bar-switch-or-create
|
|
|
|
"Journal"
|
2022-10-13 20:20:25 +02:00
|
|
|
#'org-roam-dailies-goto-today))
|
2022-02-10 23:11:20 +01:00
|
|
|
|
2022-11-25 17:18:40 +01:00
|
|
|
(defun mmk2410/tab-bar-run-mastodon ()
|
2023-06-14 18:05:38 +02:00
|
|
|
"Switch to or create a tab running mastodon.el."
|
2022-11-25 17:18:40 +01:00
|
|
|
(interactive)
|
|
|
|
(mmk2410/tab-bar-switch-or-create "Mastodon" #'mastodon))
|
|
|
|
|
2023-06-14 18:07:08 +02:00
|
|
|
(defun mmk2410/tab-bar-run-vterm ()
|
|
|
|
"Switch to or create a tab running a shell using vterm."
|
|
|
|
(interactive)
|
|
|
|
(mmk2410/tab-bar-switch-or-create "term" #'vterm))
|
|
|
|
|
2022-03-30 16:54:22 +02:00
|
|
|
(defhydra mmk2410/tab-bar (:color teal :hint nil)
|
|
|
|
"
|
2023-06-14 18:05:38 +02:00
|
|
|
^Apps^ ^Org^ ^Helpers^ ^Misc
|
|
|
|
--^^^^^^---------------------------------------------------------------------------
|
|
|
|
_e_: RSS (Elfeed) _a_: Agenda _RET_: Search _q_: Cancel
|
|
|
|
_m_: Mail _A_: Agenda + Journal _SPC_: New
|
|
|
|
_i_: IRC (erc) _j_: Journal _f_: Previous Tab
|
|
|
|
_M_: Mastodon _Q_: Close Tab
|
2024-05-28 16:40:09 +02:00
|
|
|
_p_: Pocket
|
2023-06-14 18:07:08 +02:00
|
|
|
_t_: vterm
|
2022-11-25 17:19:26 +01:00
|
|
|
|
2022-03-30 16:54:22 +02:00
|
|
|
"
|
2023-06-14 18:05:38 +02:00
|
|
|
;; Apps
|
2022-03-30 16:54:22 +02:00
|
|
|
("e" mmk2410/tab-bar-run-elfeed)
|
|
|
|
("m" mmk2410/tab-bar-run-mail)
|
2023-06-14 18:05:38 +02:00
|
|
|
("i" mmk2410/tab-bar-run-irc)
|
2022-11-25 17:18:40 +01:00
|
|
|
("M" mmk2410/tab-bar-run-mastodon)
|
2024-05-28 16:40:09 +02:00
|
|
|
("p" mmk2410/tab-bar-run-pocket-reader)
|
2023-06-14 18:07:08 +02:00
|
|
|
("t" mmk2410/tab-bar-run-vterm)
|
2023-06-14 18:05:38 +02:00
|
|
|
;; Org
|
|
|
|
("a" mmk2410/tab-bar-run-agenda)
|
|
|
|
("A" mmk2410/tab-bar-run-agenda-journal)
|
|
|
|
("j" mmk2410/tab-bar-run-journal)
|
|
|
|
;; Helpers
|
2022-03-30 16:54:22 +02:00
|
|
|
("RET" tab-bar-select-tab-by-name)
|
|
|
|
("SPC" mmk2410/tab-bar-new-named-tab)
|
|
|
|
("f" tab-bar-switch-to-recent-tab)
|
|
|
|
("Q" tab-bar-close-tab)
|
2023-06-14 18:05:38 +02:00
|
|
|
;; Misc
|
2022-03-30 16:54:22 +02:00
|
|
|
("q" nil))
|
2022-02-10 23:11:20 +01:00
|
|
|
|
2022-02-12 23:06:08 +01:00
|
|
|
(provide 'mmk2410-tab-bar-helpers)
|
2022-10-13 20:20:25 +02:00
|
|
|
;;; mmk2410-tab-bar-helpers.el ends here
|