;;; custom-ui-config.el -*- lexical-binding: t; -*- ;; Copyright (C) 2023 ;; SPDX-License-Identifier: MIT ;; Author: System Crafters Community ;;; Commentary: ;; User interface customizations. Examples are icons, line numbers, ;; and how help buffers are displayed. ;; This package provides a basic, customized appearance for ;; Emacs. Specifically, it uses: Helpful to customize the information ;; and visual display of help buffers, such as that created by M-x ;; `describe-function'; All-the-icons, to provide font-based icons ;; (rather than raster or vector images); and includes some Emacs Lisp ;; demonstrations. ;;  Run `all-the-icons-install-fonts' to ensure the fonts necessary ;; for ALL THE ICONS are available on your system. You must run this ;; function if the "stop" icon at the beginning of this paragraph is ;; not displayed properly (it appears as a box with some numbers ;; and/or letters inside it). ;; Read the documentation for `all-the-icons'; on Windows, ;; `all-the-icons-install-fonts' only downloads fonts, they must be ;; installed manually. This is necessary if icons are not displaying ;; properly. ;;; Code: ;;;; Help Buffers ;; Make `describe-*' screens more helpful (when (require 'helpful nil :noerror) (keymap-set helpful-mode-map " " #'helpful-update) (keymap-global-set " " #'helpful-command) (keymap-global-set " " #'helpful-callable) (keymap-global-set " " #'helpful-key) (keymap-global-set " " #'helpful-symbol) (keymap-global-set " " #'helpful-variable) (keymap-global-set "C-h F" #'helpful-function)) ;; Bind extra `describe-*' commands (keymap-global-set "C-h K" #'describe-keymap) ;;;; Line Numbers (defcustom custom-ui-line-numbers-enabled-modes '(conf-mode prog-mode) "Modes which should display line numbers." :type 'list :group 'crafted-ui) (defcustom custom-ui-line-numbers-disabled-modes '(org-mode) "Modes which should not display line numbers. Modes derived from the modes defined in `custom-ui-line-number-enabled-modes', but should not display line numbers." :type 'list :group 'crafted-ui) (defun custom-ui--enable-line-numbers-mode () "Turn on line numbers mode. Used as hook for modes which should display line numbers." (display-line-numbers-mode 1)) (defun custom-ui--disable-line-numbers-mode () "Turn off line numbers mode. Used as hook for modes which should not display line numebrs." (display-line-numbers-mode -1)) (defun custom-ui--update-line-numbers-display () "Update configuration for line numbers display." (if custom-ui-display-line-numbers (progn (dolist (mode custom-ui-line-numbers-enabled-modes) (add-hook (intern (format "%s-hook" mode)) #'custom-ui--enable-line-numbers-mode)) (dolist (mode custom-ui-line-numbers-disabled-modes) (add-hook (intern (format "%s-hook" mode)) #'custom-ui--disable-line-numbers-mode)) (setq-default display-line-numbers-grow-only t display-line-numbers-type t display-line-numbers-width 2)) (progn (dolist (mode custom-ui-line-numbers-enabled-modes) (remove-hook (intern (format "%s-hook" mode)) #'custom-ui--enable-line-numbers-mode)) (dolist (mode custom-ui-line-numbers-disabled-modes) (remove-hook (intern (format "%s-hook" mode)) #'custom-ui--disable-line-numbers-mode))))) (defcustom custom-ui-display-line-numbers nil "Whether line numbers should be enabled." :type 'boolean :group 'crafted-ui :set (lambda (sym val) (set-default sym val) (custom-ui--update-line-numbers-display))) ;; add visual pulse when changing focus, like beacon but built-in ;; from from https://karthinks.com/software/batteries-included-with-emacs/ (defun pulse-line (&rest _) "Pulse the current line." (pulse-momentary-highlight-one-line (point))) (dolist (command '(scroll-up-command scroll-down-command recenter-top-bottom other-window)) (advice-add command :after #'pulse-line)) (provide 'custom-ui-config) ;;; custom-ui-config.el ends here