X-Git-Url: https://git.shemshak.org/gitweb.cgi/~bandali/configs/blobdiff_plain/818a4af5b33f5e5e3778cdaa979a1ef4134ab2a1..77de579400044e13acff652f2cc1c761ed10a703:/spacemacs/.emacs.d/private/aminb/packages.el?ds=sidebyside diff --git a/spacemacs/.emacs.d/private/aminb/packages.el b/spacemacs/.emacs.d/private/aminb/packages.el index 7bb09f6..0ff24e0 100644 --- a/spacemacs/.emacs.d/private/aminb/packages.el +++ b/spacemacs/.emacs.d/private/aminb/packages.el @@ -17,15 +17,31 @@ ;;; Code: (defconst aminb-packages - '(crux writeroom-mode znc - ;; mu4e has to be installed manually, - ;; and make sure it's in load-path - (mu4e :location site) - (mu4e-contrib :location site) - smtpmail - ) + '(counsel + creamsody-theme + crux + ;; mu4e has to be installed manually, + ;; and make sure it's in load-path + (mu4e :location site) + smtpmail + writeroom-mode + znc) "The list of Lisp packages required by the aminb layer.") +(defun aminb/post-init-counsel () + (use-package counsel + :defer t + :config + (progn + (spacemacs/set-leader-keys-for-major-mode 'eshell-mode + "," 'counsel-esh-history) + (add-hook 'eshell-mode-hook + '(lambda () (define-key eshell-mode-map + (kbd "M-l") 'counsel-esh-history))) + ))) + +(defun aminb/init-creamsody-theme ()) + (defun aminb/init-crux () (use-package crux :defer t @@ -54,6 +70,38 @@ ;; Restore channel buffers from logs (setq erc-log-insert-log-on-open t) + ;;; (BEGIN) work around log restoration bug + ;; taken from https://www.emacswiki.org/emacs/ErcLogging + + ;; ;;; Original version in the Emacs sources: + ;; (defun erc-log-all-but-server-buffers (buffer) + ;; "Returns t if logging should be enabled in BUFFER. + ;; Returns nil if `erc-server-buffer-p' returns t." + ;; (save-excursion + ;; (save-window-excursion + ;; (set-buffer buffer) + ;; (not (erc-server-buffer-p))))) + + ;; My version: + (defun erc-log-all-but-server-buffers (buffer) + (with-current-buffer buffer + (not (erc-server-buffer-p)))) + ;; + ;; ;;; Anyway, a more direct modification also works fine: + ;; (defun erc-log-all-but-server-buffers (buffer) + ;; (set-buffer buffer) + ;; (not (erc-server-buffer-p))) + ;;; (END) + + (require 'notifications) + (defun erc-global-notify (match-type nick message) + "Notify when a message is recieved." + (notifications-notify + :title nick + :body message + ;; :app-icon (concat spacemacs-assets-directory "spacemacs.svg") + :urgency 'normal)) + (defun vbe:znc-add-server (server port user networks) "Add a server to the list of ZNC servers. We use SSL inconditionaly. Moreover, we don't store the password @@ -136,77 +184,89 @@ erc-modified-channels-alist. Should be executed on window change." ))) (defun aminb/post-init-mu4e () + (setq maildir "~/mail") (use-package mu4e :defer t :config (progn - (setq mu4e-maildir "~/mail" - mu4e-get-mail-command "mbsync -aq" ;; or fetchmail, or ... - mu4e-update-interval 300 ;; update every 5 minutes + (setq mu4e-maildir maildir + mu4e-get-mail-command "true" + mu4e-update-interval 300 mu4e-view-show-addresses t mu4e-headers-include-related t + mu4e-enable-notifications t + mu4e-enable-mode-line t mu4e-compose-signature-auto-include t mu4e-compose-signature (concat "Amin Bandali\n" "\n") - ;; don't keep message buffers around - message-kill-buffer-on-exit t + message-kill-buffer-on-exit t ; don't keep message buffers around mu4e-attachment-dir "~/dls" mu4e-sent-folder "/amin/Sent" mu4e-drafts-folder "/amin/Drafts" mu4e-trash-folder "/amin/Trash" - user-mail-address "amin@aminb.org") - - (defvar my-mu4e-account-alist - '(("amin" - (mu4e-sent-folder "/amin/Sent") - (mu4e-drafts-folder "/amin/Drafts") - (mu4e-trash-folder "/amin/Trash") - (user-mail-address "amin@aminb.org") - (user-full-name "Amin Bandali") - (smtpmail-default-smtp-server "nix.aminb.org") - (smtpmail-local-domain "aminb.org") - (smtpmail-smtp-user "amin@aminb.org") - (smtpmail-smtp-server "nix.aminb.org") - (smtpmail-stream-type 'starttls) - (smtpmail-smtp-service 587)) - ("gmail" - (mu4e-sent-folder "/gmail/[Gmail].Sent Mail") - (mu4e-drafts-folder "/gmail/[Gmail].Drafts") - (mu4e-trash-folder "/gmail/[Gmail].Trash") - (user-mail-address "amin.bandali@gmail.com") - (user-full-name "Amin Bandali") - (smtpmail-default-smtp-server "smtp.gmail.com") - (smtpmail-local-domain "gmail.com") - (smtpmail-smtp-user "amin.bandali@gmail.com") - (smtpmail-smtp-server "smtp.gmail.com") - (smtpmail-stream-type ssl) - (smtpmail-smtp-service 465)))) - - (defun my-mu4e-set-account () - "Set the account for composing a message." - (let* ((account - (if mu4e-compose-parent-message - (let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir))) - (string-match "/\\(.*?\\)/" maildir) - (match-string 1 maildir)) - (completing-read (format "Compose with account: (%s) " - (mapconcat #'(lambda (var) (car var)) - my-mu4e-account-alist "/")) - (mapcar #'(lambda (var) (car var)) my-mu4e-account-alist) - nil t nil nil (caar my-mu4e-account-alist)))) - (account-vars (cdr (assoc account my-mu4e-account-alist)))) - (if account-vars - (mapc #'(lambda (var) - (set (car var) (cadr var))) - account-vars) - (error "No email account found")))) - (add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-account))) + user-full-name "Amin Bandali" + user-mail-address "amin@aminb.org" + mu4e-view-html-plaintext-ratio-heuristic most-positive-fixnum + mu4e-context-policy 'pick-first + mu4e-contexts + (list (make-mu4e-context + :name "Personal" + :enter-func (lambda () (mu4e-message "Switch to the Personal context")) + :match-func (lambda (msg) + (when msg + (s-prefix? "/amin/" (mu4e-message-field msg :maildir)))) + :vars '((user-mail-address . "amin@aminb.org") + (mu4e-sent-folder . "/amin/Sent") + (mu4e-drafts-folder . "/amin/Drafts") + (mu4e-trash-folder . "/amin/Trash") + (mu4e-sent-messages-behavior . sent) + (smtpmail-default-smtp-server . "nix.aminb.org") + (smtpmail-smtp-server . "nix.aminb.org") + (smtpmail-stream-type . starttls) + (smtpmail-smtp-service . 587))) + (make-mu4e-context + :name "BB" + :enter-func (lambda () (mu4e-message "Switch to the BB context")) + :match-func (lambda (msg) + (when msg + (s-prefix? "/gmail/" (mu4e-message-field msg :maildir)))) + :vars '((user-mail-address . "amin.bandali@gmail.com") + (mu4e-sent-folder . "/gmail/Sent") + (mu4e-drafts-folder . "/gmail/Drafts") + (mu4e-trash-folder . "/gmail/Trash") + (mu4e-sent-messages-behavior . delete) + (mu4e-compose-signature . nil) + (smtpmail-default-smtp-server . "smtp.gmail.com") + (smtpmail-smtp-server . "smtp.gmail.com") + (smtpmail-stream-type . starttls) + (smtpmail-smtp-service . 587))) + (make-mu4e-context + :name "GNU" + :enter-func (lambda () (mu4e-message "Switch to the GNU context")) + :match-func (lambda (msg) + (when msg + (s-prefix? "/gnu/" (mu4e-message-field msg :maildir)))) + :vars '((user-mail-address . "aminb@gnu.org") + (mu4e-sent-folder . "/gnu/Sent") + (mu4e-drafts-folder . "/gnu/Drafts") + (mu4e-trash-folder . "/gnu/Trash") + (mu4e-sent-messages-behavior . sent) + (smtpmail-default-smtp-server . "fencepost.gnu.org") + (smtpmail-smtp-server . "fencepost.gnu.org") + (smtpmail-stream-type . starttls) + (smtpmail-smtp-service . 587))))) + (with-eval-after-load 'mu4e-alert + ;; Enable Desktop notifications + (mu4e-alert-set-default-style 'notifications)))) (use-package gnus-dired ;; A special version of the gnus-dired-mail-buffers function - ;; that understands mu4e buffers as well + ;; that understands mu4e buffers as well. + ;; Usage: mark the file(s) in dired and press C-c RET C-a, + ;; then will be asked whether to attach them to an existing + ;; message, or create a new one. :defer t :config (progn @@ -226,18 +286,16 @@ erc-modified-channels-alist. Should be executed on window change." (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)) ) + ;; Exclude the files in maildir from recents + (use-package recentf + :defer t + :config + (add-to-list 'recentf-exclude (expand-file-name maildir))) + (spacemacs/set-leader-keys "am" 'mu4e) ) -(defun aminb/init-mu4e-contrib () - (use-package mu4e-contrib - :defer t - :config - (setq mu4e-html2text-command 'mu4e-shr2text - mu4e-view-html-plaintext-ratio-heuristic 10 - mu4e-view-prefer-html t))) - (defun aminb/init-smtpmail () (use-package smtpmail :defer t @@ -246,6 +304,7 @@ erc-modified-channels-alist. Should be executed on window change." smtpmail-local-domain "aminb.org" smtpmail-smtp-server "nix.aminb.org" smtpmail-stream-type 'starttls - smtpmail-smtp-service 587))) + smtpmail-smtp-service 587 + send-mail-function 'smtpmail-send-it))) ;;; packages.el ends here