Skip to content

Commit

Permalink
[emacs] encourage: add package
Browse files Browse the repository at this point in the history
  • Loading branch information
meain committed Sep 1, 2024
1 parent 387b6e3 commit f3e89e4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
49 changes: 49 additions & 0 deletions emacs/.config/emacs/encourage.el
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions emacs/.config/emacs/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit f3e89e4

Please sign in to comment.