dot-emacs/packages/mmk2410-tab-bar-helpers.el

96 lines
2.4 KiB
EmacsLisp
Raw Normal View History

2022-02-10 23:18:47 +01:00
;;; tab-bar-helpers.el -*- lexical-binding: t; -*-
2022-02-10 23:11:20 +01:00
(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)
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)
(member name
(mapcar #'(lambda (tab) (alist-get 'name tab))
(tab-bar-tabs))))
(defun mmk2410/tab-bar-switch-or-create (name 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
(defun mmk2410/tab-bar-run-elfeed ()
(interactive)
(mmk2410/tab-bar-switch-or-create "RSS" #'elfeed))
(defun mmk2410/tab-bar-new-named-tab (name)
(interactive "sTab Name: ")
(tab-bar-new-tab)
(tab-bar-rename-tab name))
2022-02-10 23:11:20 +01:00
(defun mmk2410/tab-bar-run-mail ()
(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 ()
(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 ()
(interactive)
2022-02-10 23:18:47 +01:00
(mmk2410/tab-bar-switch-or-create
"Agenda"
#'(lambda ()
(org-agenda nil "c")
(sit-for 1)
(split-window-horizontally)
(other-window 1)
(org-journal-open-current-journal-file))))
2022-02-10 23:11:20 +01:00
(defun mmk2410/tab-bar-run-journal ()
(interactive)
2022-02-10 23:18:47 +01:00
(mmk2410/tab-bar-switch-or-create
"Journal"
#'org-journal-open-current-journal-file))
2022-02-10 23:11:20 +01:00
(defun mmk2410/tab-bar-run-projects ()
(interactive)
2022-02-10 23:18:47 +01:00
(mmk2410/tab-bar-switch-or-create
"Projects"
#'(lambda ()
(find-file "~/org/projects.org"))))
2022-02-10 23:11:20 +01:00
(defhydra mmk2410/tab-bar (:color teal :hint nil)
"
^Apps^ ^Helpers^ ^Misc
--^^^^^^---------------------------------------------
_a_: Agenda _RET_: Search _q_: Cancel
_e_: RSS (Elfeed) _SPC_: New
_i_: IRC (erc) _f_: Previous
_j_: Journal _Q_: Close
_m_: Mail
_p_: Projects
"
("a" mmk2410/tab-bar-run-agenda)
("e" mmk2410/tab-bar-run-elfeed)
("i" mmk2410/tab-bar-run-irc)
("j" mmk2410/tab-bar-run-journal)
("m" mmk2410/tab-bar-run-mail)
("p" mmk2410/tab-bar-run-projects)
("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)
("q" nil))
2022-02-10 23:11:20 +01:00
2022-02-12 23:06:08 +01:00
(provide 'mmk2410-tab-bar-helpers)
2022-02-10 23:18:47 +01:00
;;; tab-bar-helpers.el ends here