kkk-linenumbers.el 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ;;; kkk-linenumbers.el --- Line Numbers -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2023 Vinicius Teshima <vini.tes@pm.me>
  3. ;; Author: Vinicius Teshima <vini.tes@pm.me>
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. ;;; Commentary:
  15. ;; Custom global display line number
  16. ;;; Code:
  17. (require 'display-line-numbers)
  18. (defgroup kkk-linenumbers nil
  19. "Custom config for line numbers."
  20. :group 'info)
  21. (defcustom kkk-linenumbers-global-modes t
  22. "This is a copy of `company-global-modes` for `whitespace-mode`."
  23. :type '(choice (const :tag "none" nil)
  24. (const :tag "all" t)
  25. (set :menu-tag "mode specific" :tag "modes"
  26. :value (not)
  27. (const :tag "Except" not)
  28. (repeat :inline t (symbol :tag "mode"))))
  29. :group 'kkk-linenumbers)
  30. (defun kkk-linenumbers-mode--turn-on ()
  31. "Turn on `display-line-numbers-mode'."
  32. (when (and (not (or noninteractive (eq (aref (buffer-name) 0) ?\s)))
  33. (cond ((eq kkk-linenumbers-global-modes t) t)
  34. ((eq (car-safe kkk-linenumbers-global-modes) 'not)
  35. (not (memq major-mode kkk-linenumbers-global-modes)))
  36. (t (memq major-mode kkk-linenumbers-global-modes))))
  37. (display-line-numbers-mode t)))
  38. (defvaralias 'kkk-linenumbers-type 'display-line-numbers-type)
  39. (define-globalized-minor-mode
  40. global-kkk-linenumbers-mode
  41. display-line-numbers-mode
  42. kkk-linenumbers-mode--turn-on)
  43. (provide 'kkk-linenumbers)
  44. ;;; kkk-linenumbers.el ends here