diff --git a/modules/app/twitter/autoload.el b/modules/app/twitter/autoload.el index f845154b3..54267d3d9 100644 --- a/modules/app/twitter/autoload.el +++ b/modules/app/twitter/autoload.el @@ -1,12 +1,32 @@ ;;; app/twitter/autoload.el -*- lexical-binding: t; -*- +;;;###autoload +(defun +twitter-display-buffer (buf) + "A replacement display-buffer command for `twittering-pop-to-buffer-function' +that works with the feature/popup module." + (let ((win (selected-window))) + (display-buffer buf) + ;; This is required because the new window generated by `pop-to-buffer' + ;; may hide the region following the current position. + (twittering-ensure-whole-of-status-is-visible win))) + +;;;###autoload +(defun +twitter-buffer-p (buf) + "Return non-nil if BUF is a `twittering-mode' buffer." + (eq 'twittering-mode (buffer-local-value 'major-mode buf))) + + +;; +;; Commands +;; + ;;;###autoload (defun =twitter () + "Opens a workspace dedicated to `twittering-mode'." (interactive) - (+workspace-switch "*Twitter*" t) - (delete-other-windows) - (condition-case _ex + (condition-case _ (progn + (+workspace/new "*Twitter*") (call-interactively #'twit) (unless (get-buffer (car twittering-initial-timeline-spec-string)) (error "Failed to open twitter")) @@ -14,12 +34,13 @@ (dolist (name (cdr twittering-initial-timeline-spec-string)) (split-window-horizontally) (switch-to-buffer name)) - (balance-windows)) - ('error - (+twitter/quit-all)))) + (balance-windows) + (call-interactively #'+twitter/rerender-all)) + ('error (+twitter/quit-all)))) ;;;###autoload (defun +twitter/quit () + "Close the current `twitter-mode' buffer." (interactive) (when (eq major-mode 'twittering-mode) (twittering-kill-buffer) @@ -27,15 +48,18 @@ ;;;###autoload (defun +twitter/quit-all () + "Close all open `twitter-mode' buffers and the associated workspace, if any." (interactive) - (+workspace/delete "Twitter") - (dolist (buf (doom-buffers-in-mode 'twittering-mode)) - (with-current-buffer buf - (twittering-kill-buffer)))) + (+workspace/delete "*Twitter*") + (dolist (buf (doom-buffers-in-mode 'twittering-mode (buffer-list) t)) + (twittering-kill-buffer buf))) ;;;###autoload (defun +twitter/rerender-all () + "Rerender all `twittering-mode' buffers." (interactive) - (dolist (buf (doom-buffers-in-mode 'twittering-mode)) + (dolist (buf (doom-buffers-in-mode 'twittering-mode (buffer-list) t)) (with-current-buffer buf - (twittering-rerender-timeline-all buf)))) + (twittering-rerender-timeline-all buf) + (setq-local line-spacing 0.2) + (goto-line 0 buf)))) diff --git a/modules/app/twitter/config.el b/modules/app/twitter/config.el index 12385631d..fab0d7ecb 100644 --- a/modules/app/twitter/config.el +++ b/modules/app/twitter/config.el @@ -3,19 +3,47 @@ (def-package! twittering-mode :commands twit :config - (setq twittering-use-master-password t - twittering-icon-mode nil + (setq twittering-private-info-file (expand-file-name "twittering-mode.gpg" doom-etc-dir) + twittering-use-master-password t + twittering-request-confirmation-on-posting t + ;; twittering-icon-mode t ;; twittering-use-icon-storage t ;; twittering-icon-storage-file (concat doom-cache-dir "twittering-mode-icons.gz") ;; twittering-convert-fix-size 12 twittering-timeline-header "" twittering-timeline-footer "" twittering-edit-skeleton 'inherit-any - twittering-status-format - "%RT{%FACE[bold]{RT }}%S (%FACE[bold]{@%s}), %@%r%R:\n%FOLD[ ]{%t %QT{\n+----\n%FOLD[|]{ %S (@%s), %@:\n%FOLD[ ]{%t}}\n+----}}\n " + twittering-status-format "%FACE[font-lock-function-name-face]{ @%s} %FACE[italic]{%@} %FACE[error]{%FIELD-IF-NONZERO[❤ %d]{favorite_count}} %FACE[warning]{%FIELD-IF-NONZERO[↺ %d]{retweet_count}} +%FOLD[ ]{%FILL{%t}%QT{ +%FOLD[ ]{%FACE[font-lock-function-name-face]{@%s}\t%FACE[shadow]{%@} +%FOLD[ ]{%FILL{%t}} +}}} + +%FACE[twitter-divider]{ } +" + ;; twittering-timeline-spec-alias '() twittering-initial-timeline-spec-string '(":home" ":mentions" ":direct_messages")) + (set! :popup "^\\*twittering-edit" nil '((transient) (quit) (select . t) (modeline . minimal))) + + (defface twitter-divider + `((t (:underline (:color ,(doom-darken 'vertical-bar 0.2))))) + "The vertical divider between tweets." + :group 'twittering-mode) + + (add-hook 'doom-real-buffer-functions #'+twitter-buffer-p) + (when (featurep! :feature popup) + (setq twittering-pop-to-buffer-function #'+twitter-display-buffer)) + + (after! solaire-mode + (add-hook 'twittering-mode-hook #'solaire-mode)) + + ;; Custom modeline for twitter buffers + (def-modeline! twitter + (bar matches " %b " selection-info) + ()) + (add-hook! twittering-mode (setq header-line-format (or (doom-modeline 'twitter) mode-line-format) mode-line-format nil)) @@ -24,11 +52,10 @@ [remap twittering-kill-buffer] #'+twitter/quit "Q" #'+twitter/quit-all "o" #'ace-link-addr - "j" #'evil-next-visual-line - "k" #'evil-previous-visual-line "J" #'twittering-goto-next-status - "K" #'twittering-goto-previous-status) - - (def-modeline! twitter - (bar matches " %b " selection-info) - ())) + "K" #'twittering-goto-previous-status + (:when (featurep! :feature evil) + "j" #'evil-next-visual-line + "k" #'evil-previous-visual-line + "h" #'evil-window-left + "l" #'evil-window-right)))