From f3e89e4c6f28767b382e4fd88c8c476c75d2996d Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Sun, 1 Sep 2024 10:16:21 +0530 Subject: [PATCH] [emacs] encourage: add package --- emacs/.config/emacs/encourage.el | 49 ++++++++++++++++++++++++++++++++ emacs/.config/emacs/init.el | 5 ++++ 2 files changed, 54 insertions(+) create mode 100644 emacs/.config/emacs/encourage.el diff --git a/emacs/.config/emacs/encourage.el b/emacs/.config/emacs/encourage.el new file mode 100644 index 00000000..e19a4761 --- /dev/null +++ b/emacs/.config/emacs/encourage.el @@ -0,0 +1,49 @@ +;;; encourage.el --- Add a message to minibuffer every time you save a document + +;;; Commentary: +;; Add a message to minibuffer every time you save a document +;; A simple package which is inspired by a neovim plugin at +;; r-cha/encourage.nvim which itself was inspired by a VSCode plugin +;; at nicollasricas/vscode-encourage which was inspired by Visual +;; Studio plugin Haacked.Encourage. + +;;; Code: +(defgroup encourage nil "Encourage customization group." + :group 'tools) + +(defcustom encourage-encouragements + '("Great job! ✨" + "You're doing great! 💪" + "Keep up the good work! 🌟" + "Well done! 🎉" + "Onward and upward! 🚀" + "You're on fire! 🔥" + "You're a star! ⭐️" + "You're amazing! 🌈" + "That was awesome! 🎈" + "Smart move. 🧠" + "Bravo! 👏" + "Nailed it. 🔨") + "List of encouragements to display in the minibuffer." + :type 'list + :group 'encourage) + +(defun save-message () + "Display a message in the minibuffer every time a document is saved." + (let ((egmt (nth (random (length encourage-encouragements)) + encourage-encouragements))) + (if (and (featurep 'posframe) (fboundp 'posframe-show)) + ;; Shot at top right of frame + (posframe-show "*encourage*" + :string (concat " " egmt " ") + :timeout 2 + :poshandler 'posframe-poshandler-frame-top-right-corner + :background-color "skyblue" + :foreground-color "white" + :poshandler (lambda (_info) pos)) + (message egmt)))) + +(add-hook 'after-save-hook 'save-message) + +(provide 'encourage) +;;; encourage.el ends here diff --git a/emacs/.config/emacs/init.el b/emacs/.config/emacs/init.el index 24a69b11..5788bbe3 100644 --- a/emacs/.config/emacs/init.el +++ b/emacs/.config/emacs/init.el @@ -423,6 +423,11 @@ Pass ORIGINAL and ALTERNATE options." ;; Enable minor-mode manually when required :commands (golden-ratio golden-ratio-mode)) +;; A silly little package to encourage on save +(use-package emacs + :config + (load (concat user-emacs-directory "encourage"))) + ;; Window mappings (not using meain/with-alternate as I need functions) (defun meain/move-swap-right (&optional swap) "Move to window on right or move window to right if SWAP."