Add crafted-early-init, remove some other crafted modules

Fork crafted-ui-config to custom-ui-config to remove dependency on demos
This commit is contained in:
Evie Litherland-Smith 2023-10-25 15:47:35 +01:00
parent b4fb72cb1e
commit 78752637d3
4 changed files with 142 additions and 6 deletions

12
home/emacs/early-init.el Normal file
View file

@ -0,0 +1,12 @@
;;; early-init.el --- Emacs early initialization for Crafted Emacs (optional) -*- lexical-binding: t; -*-
;;; Commentary:
;;
;;; Code:
;; Configures `package.el'
;; (load "~/crafted-emacs/modules/crafted-early-init-config")
(load (expand-file-name "crafted-emacs/modules/crafted-early-init-config" user-emacs-directory))
(provide 'early-init)
;;; early-init.el ends here

View file

@ -23,18 +23,16 @@
(require 'crafted-defaults-config) (require 'crafted-defaults-config)
(require 'crafted-ide-config) (require 'crafted-ide-config)
(require 'crafted-org-config) (require 'crafted-org-config)
(require 'crafted-speedbar-config)
(require 'crafted-startup-config)
(require 'crafted-ui-config)
(require 'crafted-workspaces-packages) (require 'crafted-workspaces-packages)
(require 'crafted-writing-packages) (require 'crafted-writing-packages)
(require 'custom-email-config) (require 'custom-email-config)
(require 'custom-feed-config) (require 'custom-feed-config)
(require 'custom-ide-config) (require 'custom-ide-config)
(require 'custom-org-config)
(require 'custom-ligatures-config) (require 'custom-ligatures-config)
(require 'custom-org-config)
(require 'custom-project-config) (require 'custom-project-config)
(require 'custom-ui-config)
;;; Optional configuration ;;; Optional configuration
@ -50,8 +48,8 @@
fill-column 80) fill-column 80)
;; Theme settings ;; Theme settings
(setq use-dialog-box nil (customize-set-variable 'crafted-startup-inhibit-splash t)
crafted-startup-inhibit-splash t) (setq use-dialog-box nil)
(tool-bar-mode -1) (tool-bar-mode -1)
(scroll-bar-mode -1) (scroll-bar-mode -1)
(load-theme 'doom-tokyo-night t) (load-theme 'doom-tokyo-night t)

View file

@ -0,0 +1,7 @@
(setq ntfy-server "https://ntfy.xenia.me.uk"
ntfy-topic "UhrNGphnSKCpCnk8"
ntfy-header "Notification from emacs"
ntfy-tags "purple_circle,loudspeaker")
(require 'ntfy)
(provide 'custom-ntfy-config)

View file

@ -0,0 +1,119 @@
;;; 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 "<remap> <revert-buffer>" #'helpful-update)
(keymap-global-set "<remap> <describe-command>" #'helpful-command)
(keymap-global-set "<remap> <describe-function>" #'helpful-callable)
(keymap-global-set "<remap> <describe-key>" #'helpful-key)
(keymap-global-set "<remap> <describe-symbol>" #'helpful-symbol)
(keymap-global-set "<remap> <describe-variable>" #'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