diff --git a/init.org b/init.org index 507099f..bc1ec00 100644 --- a/init.org +++ b/init.org @@ -1206,6 +1206,7 @@ Disabled by default. When enabled, only highlight in the selected window. (use-package hl-line :hook (hl-line-mode-hook . hl-line-number-mode) + (global-hl-line-mode-hook . global-hl-line-number-mode) :init (setq hl-line-sticky-flag nil) (setq global-hl-line-sticky-flag nil) @@ -1216,10 +1217,13 @@ Disabled by default. When enabled, only highlight in the selected window. (defvar-local hl-line-number--current-line-remap nil "Face remapping cookie for `line-number-current-line' to `hl-line'.") + (define-global-minor-mode global-hl-line-number-mode hl-line-number-mode hl-line-number-mode + :group 'hl-line) + (define-minor-mode hl-line-number-mode "Toggle highlighting of the current line number." :group 'hl-line - (if hl-line-mode + (if (or global-hl-line-mode hl-line-mode) (setq hl-line-number--current-line-remap (face-remap-add-relative 'line-number-current-line 'hl-line)) (face-remap-remove-relative hl-line-number--current-line-remap) @@ -1668,7 +1672,10 @@ Descriptive buffer names or project relative paths for buffer names. *** pairable #+begin_src emacs-lisp :tangle yes -(use-package pairable :ensure t) +(use-package pairable + :ensure t + :config + (keymap-set toggle-map "p" '("Pair-programming" . pairable-mode))) #+end_src *** readable diff --git a/lisp/pairable.el b/lisp/pairable.el index 6cae528..ddf1726 100644 --- a/lisp/pairable.el +++ b/lisp/pairable.el @@ -5,6 +5,8 @@ ;; Author: Terje Larsen ;; Keywords: faces +;; URL: https://github.com/terlar/emacs-config/blob/main/lisp/pariable.el +;; Package-Requires: ((emacs "29.1")) ;; Version: 0.1 ;; This file is NOT part of GNU Emacs. @@ -29,19 +31,29 @@ ;;; Code: +(require 'cl-lib) +(require 'face-remap) + (defgroup pairable nil "Settings for pair-programming." :group 'faces) ;;;###autoload (defcustom pairable-text-scale 2 - "Scaling factor for text." + "Scaling increment for text. +Will be multiplied with `global-text-scale-adjust--increment-factor'" :type 'number :group 'pairable) ;;;###autoload (defcustom pairable-display-line-numbers t - "Use line-numbers or not." + "Enable line-numbers or not." + :type 'boolean + :group 'pairable) + +;;;###autoload +(defcustom pairable-hl-line t + "Enable highlighting of the current line or not." :type 'boolean :group 'pairable) @@ -58,14 +70,27 @@ In Pariable mode, the text scale is increased, line numbers enabled and various other improvements to optimize for pair-programming." :lighter pairable-lighter + :global t :group 'pairable (if pairable-mode (progn - (global-display-line-numbers-mode 1) - (text-scale-set pairable-text-scale)) + (when pairable-display-line-numbers + (global-display-line-numbers-mode 1)) + (when pairable-hl-line + (global-hl-line-mode 1)) + (when (> pairable-text-scale 0) + (let ((inc (* global-text-scale-adjust--increment-factor pairable-text-scale))) + (setq global-text-scale-adjust--default-height (face-attribute 'default :height)) + (set-face-attribute 'default nil :height (+ global-text-scale-adjust--default-height inc)) + (redisplay 'force)))) (progn - (global-display-line-numbers-mode 0) - (text-scale-increase 0)))) + (when pairable-display-line-numbers + (global-display-line-numbers-mode 0)) + (when pairable-hl-line + (global-hl-line-mode 0)) + (when (> pairable-text-scale 0) + (set-face-attribute 'default nil :height global-text-scale-adjust--default-height) + (redisplay 'force))))) (defun pairable-mode-enable () "Enable `pairable-mode' in the current buffer."