diff options
Diffstat (limited to 'meen.el')
-rw-r--r-- | meen.el | 90 |
1 files changed, 90 insertions, 0 deletions
@@ -0,0 +1,90 @@ +;;; meen.el --- Hide clocks replacing them with fish -*- lexical-binding: t -*- + +;; Hide clocks replacing them with fish +;; Copyright (C) 2022 Arun Isaac +;; +;; Author: Arun Isaac <arunisaac@systemreboot.net> +;; Version: 0.1.0 +;; Homepage: https://git.systemreboot.net/meen +;; Package-Requires: ((emacs "25.1")) + +;; This file is part of meen. + +;; meen is free software: you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; meen is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +;; License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with meen. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: +;; +;; meen is a minor mode to hide clocks replacing them with fish icons. +;; It is useful to escape the tyranny of the clock and live a life not +;; knowing the precise artificial time. +;; +;; Usage: +;; +;; Toggle meen mode in all buffers using M-x global-meen-mode. Or, +;; toggle meen mode in the current buffer using M-x meen-mode. +;; +;; Clocks will be replaced by Unicode fish icons. You will need a font +;; that supports the Unicode fish icon. If you would rather use some +;; other character, customize `meen-char'. + +;;; Code: + +(defcustom meen-regexp + (rx (repeat 1 2 digit) ":" (= 2 digit) (optional ":" (= 2 digit))) + "Regexp matching clocks to hide.") + +(defcustom meen-regexp-group + 0 + "Regexp group in `meen-regexp' to hide.") + +(defcustom meen-char + ?🐟 + "Character to hide clock with.") + +(defun meen-compose () + "Compose matching region in the current buffer." + (compose-region (match-beginning meen-regexp-group) + (match-end meen-regexp-group) + meen-char)) + +;;;###autoload +(define-minor-mode meen-mode + "Meen mode." + :lighter " meen" + (let ((keywords `((,meen-regexp + (,meen-regexp-group + (meen-compose)))))) + (if meen-mode + ;; Enable mode. + (font-lock-add-keywords nil keywords) + ;; Disable mode. + (font-lock-remove-keywords nil keywords) + (with-silent-modifications + (remove-text-properties (point-min) + (point-max) + '(composition nil)))) + (font-lock-flush))) + +(defun meen-turn-on () + "Enable `meen-mode' in the current buffer if it is not already." + (unless meen-mode + (meen-mode))) + +;;;###autoload +(define-globalized-minor-mode global-meen-mode + meen-mode meen-turn-on) + +(provide 'meen) + +;;; meen.el ends here |