📝 (tab-bar-helpers) Add documentation to functions and file
This commit is contained in:
parent
5ab6ebb1cc
commit
8747cda157
1 changed files with 42 additions and 23 deletions
|
@ -1,6 +1,12 @@
|
||||||
;;; tab-bar-helpers.el -*- lexical-binding: t; -*-
|
;;; 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:
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-new-tab (name func)
|
(defun mmk2410/tab-bar-new-tab (name func)
|
||||||
|
"Create new tab using FUNC with name NAME."
|
||||||
(when (eq nil tab-bar-mode)
|
(when (eq nil tab-bar-mode)
|
||||||
(tab-bar-mode))
|
(tab-bar-mode))
|
||||||
(tab-bar-new-tab)
|
(tab-bar-new-tab)
|
||||||
|
@ -8,25 +14,30 @@
|
||||||
(funcall func))
|
(funcall func))
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-tab-exists (name)
|
(defun mmk2410/tab-bar-tab-exists (name)
|
||||||
|
"Check whether a tab named NAME exists."
|
||||||
(member name
|
(member name
|
||||||
(mapcar #'(lambda (tab) (alist-get 'name tab))
|
(mapcar #'(lambda (tab) (alist-get 'name tab))
|
||||||
(tab-bar-tabs))))
|
(tab-bar-tabs))))
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-switch-or-create (name func)
|
(defun mmk2410/tab-bar-switch-or-create (name func)
|
||||||
|
"Switch to tab with name NAME or create one using FUNC."
|
||||||
(if (mmk2410/tab-bar-tab-exists name)
|
(if (mmk2410/tab-bar-tab-exists name)
|
||||||
(tab-bar-switch-to-tab name)
|
(tab-bar-switch-to-tab name)
|
||||||
(mmk2410/tab-bar-new-tab name func)))
|
(mmk2410/tab-bar-new-tab name func)))
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-run-elfeed ()
|
|
||||||
(interactive)
|
|
||||||
(mmk2410/tab-bar-switch-or-create "RSS" #'elfeed))
|
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-new-named-tab (name)
|
(defun mmk2410/tab-bar-new-named-tab (name)
|
||||||
|
"Create new tab with named NAME."
|
||||||
(interactive "sTab Name: ")
|
(interactive "sTab Name: ")
|
||||||
(tab-bar-new-tab)
|
(tab-bar-new-tab)
|
||||||
(tab-bar-rename-tab name))
|
(tab-bar-rename-tab name))
|
||||||
|
|
||||||
|
(defun mmk2410/tab-bar-run-elfeed ()
|
||||||
|
"Switch to or start elfeed."
|
||||||
|
(interactive)
|
||||||
|
(mmk2410/tab-bar-switch-or-create "RSS" #'elfeed))
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-run-mail ()
|
(defun mmk2410/tab-bar-run-mail ()
|
||||||
|
"Switch to or start mu4e."
|
||||||
(interactive)
|
(interactive)
|
||||||
(mmk2410/tab-bar-switch-or-create
|
(mmk2410/tab-bar-switch-or-create
|
||||||
"Mail"
|
"Mail"
|
||||||
|
@ -35,6 +46,7 @@
|
||||||
(mu4e))))
|
(mu4e))))
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-run-irc ()
|
(defun mmk2410/tab-bar-run-irc ()
|
||||||
|
"Switch to or start ERC session."
|
||||||
(interactive)
|
(interactive)
|
||||||
(mmk2410/tab-bar-switch-or-create
|
(mmk2410/tab-bar-switch-or-create
|
||||||
"IRC"
|
"IRC"
|
||||||
|
@ -44,6 +56,15 @@
|
||||||
(switch-to-buffer "Libera.Chat"))))
|
(switch-to-buffer "Libera.Chat"))))
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-run-agenda ()
|
(defun mmk2410/tab-bar-run-agenda ()
|
||||||
|
"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."
|
||||||
(interactive)
|
(interactive)
|
||||||
(mmk2410/tab-bar-switch-or-create
|
(mmk2410/tab-bar-switch-or-create
|
||||||
"Agenda"
|
"Agenda"
|
||||||
|
@ -55,44 +76,42 @@
|
||||||
(org-roam-dailies-goto-today))))
|
(org-roam-dailies-goto-today))))
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-run-journal ()
|
(defun mmk2410/tab-bar-run-journal ()
|
||||||
|
"Switch to or create org-roam daily journal."
|
||||||
(interactive)
|
(interactive)
|
||||||
(mmk2410/tab-bar-switch-or-create
|
(mmk2410/tab-bar-switch-or-create
|
||||||
"Journal"
|
"Journal"
|
||||||
#'org-roam-dailies-goto-today))
|
#'org-roam-dailies-goto-today))
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-run-projects ()
|
|
||||||
(interactive)
|
|
||||||
(mmk2410/tab-bar-switch-or-create
|
|
||||||
"Projects"
|
|
||||||
#'(lambda ()
|
|
||||||
(find-file "~/org/projects.org"))))
|
|
||||||
|
|
||||||
(defun mmk2410/tab-bar-run-mastodon ()
|
(defun mmk2410/tab-bar-run-mastodon ()
|
||||||
"Switch or create a tab running mastodon.el."
|
"Switch to or create a tab running mastodon.el."
|
||||||
(interactive)
|
(interactive)
|
||||||
(mmk2410/tab-bar-switch-or-create "Mastodon" #'mastodon))
|
(mmk2410/tab-bar-switch-or-create "Mastodon" #'mastodon))
|
||||||
|
|
||||||
(defhydra mmk2410/tab-bar (:color teal :hint nil)
|
(defhydra mmk2410/tab-bar (:color teal :hint nil)
|
||||||
"
|
"
|
||||||
^Apps^ ^Org^ ^Helpers^ ^Misc
|
^Apps^ ^Org^ ^Helpers^ ^Misc
|
||||||
--^^^^^^-----------------------------------------------------------------
|
--^^^^^^---------------------------------------------------------------------------
|
||||||
_e_: RSS (Elfeed) _a_: Agenda _RET_: Search _q_: Cancel
|
_e_: RSS (Elfeed) _a_: Agenda _RET_: Search _q_: Cancel
|
||||||
_m_: Mail _j_: Journal _SPC_: New
|
_m_: Mail _A_: Agenda + Journal _SPC_: New
|
||||||
_i_: IRC (erc) _p_: Projects _f_: Previous Tab
|
_i_: IRC (erc) _j_: Journal _f_: Previous Tab
|
||||||
_M_: Mastodon _Q_: Close Tab
|
_M_: Mastodon _Q_: Close Tab
|
||||||
|
|
||||||
"
|
"
|
||||||
("a" mmk2410/tab-bar-run-agenda)
|
;; Apps
|
||||||
("e" mmk2410/tab-bar-run-elfeed)
|
("e" mmk2410/tab-bar-run-elfeed)
|
||||||
("i" mmk2410/tab-bar-run-irc)
|
|
||||||
("j" mmk2410/tab-bar-run-journal)
|
|
||||||
("m" mmk2410/tab-bar-run-mail)
|
("m" mmk2410/tab-bar-run-mail)
|
||||||
("p" mmk2410/tab-bar-run-projects)
|
("i" mmk2410/tab-bar-run-irc)
|
||||||
("M" mmk2410/tab-bar-run-mastodon)
|
("M" mmk2410/tab-bar-run-mastodon)
|
||||||
|
;; Org
|
||||||
|
("a" mmk2410/tab-bar-run-agenda)
|
||||||
|
("A" mmk2410/tab-bar-run-agenda-journal)
|
||||||
|
("j" mmk2410/tab-bar-run-journal)
|
||||||
|
;; Helpers
|
||||||
("RET" tab-bar-select-tab-by-name)
|
("RET" tab-bar-select-tab-by-name)
|
||||||
("SPC" mmk2410/tab-bar-new-named-tab)
|
("SPC" mmk2410/tab-bar-new-named-tab)
|
||||||
("f" tab-bar-switch-to-recent-tab)
|
("f" tab-bar-switch-to-recent-tab)
|
||||||
("Q" tab-bar-close-tab)
|
("Q" tab-bar-close-tab)
|
||||||
|
;; Misc
|
||||||
("q" nil))
|
("q" nil))
|
||||||
|
|
||||||
(provide 'mmk2410-tab-bar-helpers)
|
(provide 'mmk2410-tab-bar-helpers)
|
||||||
|
|
Loading…
Reference in a new issue