Skip to content

Commit

Permalink
tweak(mu4e): open in a dedicated workspace/tab
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jun 12, 2023
1 parent 20785e2 commit 5a04ae8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/me-loaddefs.el
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ This will overwrite the built-in \"gdb-mi\" for this session." t)

;;; Generated autoloads from ../modules/extras/me-mu4e-extras.el

(autoload '+mu4e "../modules/extras/me-mu4e-extras" "\
Start `mu4e' in a dedicated workspace using `tabspaces' or `tab-bar'." t)
(autoload '+mu4e-extras-setup "../modules/extras/me-mu4e-extras")
(register-definition-prefixes "../modules/extras/me-mu4e-extras" '("+mu4e-" "+org-msg-make-signature"))

Expand Down
25 changes: 25 additions & 0 deletions modules/extras/me-mu4e-extras.el
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,31 @@ If SKIP-HEADERS is set, do not show include message headers."
(+save-as-pdf outfile t))))
(mm-destroy-parts parts)))))

(defvar +mu4e-tab-name "*mu4e*"
"The name of the workspace dedicated to `mu4e'.
Set to nil to disable creating the dedicated workspace.")

;;;###autoload
(defun +mu4e ()
"Start `mu4e' in a dedicated workspace using `tabspaces' or `tab-bar'."
(interactive)
(when +mu4e-tab-name
(if (fboundp 'tabspaces-mode)
(tabspaces-switch-or-create-workspace +mu4e-tab-name)
(tab-new)
(tab-rename +mu4e-tab-name)))
(mu4e))

(defun +mu4e-close-workspace-when-stopped-setup ()
(advice-add
'mu4e-quit :after
(defun +mu4e--close-workspace-when-stopped-a ()
(if (fboundp 'tabspaces-mode)
(when-let ((tab-num (seq-position (tabspaces--list-tabspaces) +mu4e-tab-name #'string=)))
(tabspaces-close-workspace (1+ tab-num)))
(when-let ((tab-num (seq-position (tab-bar-tabs) +mu4e-tab-name (lambda (tab name) (string= name (alist-get 'name tab))))))
(tab-close (1+ tab-num)))))))

;;;###autoload
(defun +mu4e-extras-setup ()
(add-hook 'mu4e-compose-mode-hook '+mu4e--auto-bcc-h)
Expand Down
5 changes: 4 additions & 1 deletion modules/me-email.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
(visual-line-mode -1)
(display-line-numbers-mode -1)))
:init
(+map! "om" #'mu4e)
(defcustom +mu4e-auto-start t
"Automatically start `mu4e' in background in `me-daemon'."
:group 'minemacs-mu4e
Expand Down Expand Up @@ -122,6 +121,8 @@
(use-package me-mu4e-extras
:after mu4e
:demand t
:init
(+map! "om" #'+mu4e)
:config
;; Enable MinEmacs's mu4e extra features, including:
;; - Auto BCC the `+mu4e-auto-bcc-address';
Expand All @@ -131,6 +132,8 @@
;; - Add an action to save all the attachements;
;; - Add an action to save the message at point.
(+mu4e-extras-setup)
;; Register an advice to remove the dedicated workspace after quitting `mu4e'
(+mu4e-close-workspace-when-stopped-setup)
;; Redefine bookmarks queries to ignore spams
(+mu4e-extras-ignore-spams-in-bookmarks-setup))

Expand Down

0 comments on commit 5a04ae8

Please sign in to comment.