Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve pair programming setup #410

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
36 changes: 30 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,28 @@

;;; Code:

(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 +69,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