Skip to content

Commit

Permalink
feat: improve pair programming setup
Browse files Browse the repository at this point in the history
  • Loading branch information
terlar committed Sep 18, 2024
1 parent 42fc025 commit 5fcc3a4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
11 changes: 9 additions & 2 deletions init.org
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
37 changes: 31 additions & 6 deletions lisp/pairable.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

;; Author: Terje Larsen <terlar@gmail.com>
;; 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.
Expand All @@ -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)

Expand All @@ -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."
Expand Down

0 comments on commit 5fcc3a4

Please sign in to comment.