;;; kkk-whitespace.el --- Custom Whitespace Mode -*- lexical-binding: t; -*- ;; Copyright (C) 2023 Vinicius Teshima ;; Author: Vinicius Teshima ;; This program 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. ;; This program 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 this program. If not, see . ;;; Commentary: ;; Adding custom global mode for whitespace mode ;;; Code: (defgroup kkk-whitespace nil "Custom config for whitespace." :group 'info) (defcustom kkk-whitespace-global-modes t "This is a copy of `company-global-modes` for `whitespace-mode`." :type '(choice (const :tag "none" nil) (const :tag "all" t) (set :menu-tag "mode specific" :tag "modes" :value (not) (const :tag "Except" not) (repeat :inline t (symbol :tag "mode")))) :group 'kkk-whitespace) (defun kkk-whitespace-mode--turn-on () "Turn on `whitespace-mode` on the current buffer. Using `whitespace-global-modes` as a filter." (when (and (not (or noninteractive (eq (aref (buffer-name) 0) ?\s))) (cond ((eq kkk-whitespace-global-modes t) t) ((eq (car-safe kkk-whitespace-global-modes) 'not) (not (memq major-mode kkk-whitespace-global-modes))) (t (memq major-mode kkk-whitespace-global-modes)))) (whitespace-mode t))) (define-globalized-minor-mode global-kkk-whitespace-mode whitespace-mode kkk-whitespace-mode--turn-on) (provide 'kkk-whitespace) ;;; kkk-whitespace.el ends here