From eae0d246e686d3a01a6db6f8e91660bd7d0d5eef Mon Sep 17 00:00:00 2001 From: MitchMarq42 Date: Tue, 11 Oct 2022 10:45:16 -0800 Subject: [PATCH] Separate linum-relative mods into a real fork. See the URL in commit. --- lisp/mitch-packages.el | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/lisp/mitch-packages.el b/lisp/mitch-packages.el index 9814b5c..0653073 100644 --- a/lisp/mitch-packages.el +++ b/lisp/mitch-packages.el @@ -283,50 +283,14 @@ targets." ;; SORTA WORKING: Relative line numbers with stuff (use-package linum-relative + :straight (:type git + :host "https://git.mitchmarq42.xyz/mitch/linum-relative-justify.el") :diminish + :custom (linum-relative-current-symbol "") :init (require 'cl-lib) (require 'linum-relative) - (setq linum-relative-current-symbol "") - (defun display-line-numbers-equalize () - "Equalize The width. Taken from https://emacs.stackexchange.com/questions/55165/uneven-line-numbers-with-display-line-numbers/55166#55166" - (setq display-line-numbers-width - (1+ (length (number-to-string (line-number-at-pos (point-max))))))) (add-hook 'prog-mode-hook #'display-line-numbers-equalize) - (defun mitch/symbol-width (symbol) - (+ 1 (floor (log symbol 10)))) - (defun mitch/linum-get-left-pad (symbol) - "Get the number of spaces to add before the current relative line number." - (let* ((symbol-width (mitch/symbol-width symbol))) - (- display-line-numbers-width symbol-width))) - (defun mitch/right-pad (line-number) - "Pad the line number to the right." - (let* ((spacing (- (display-line-numbers-equalize) - (mitch/symbol-width line-number))) - (spacer (make-string spacing (string-to-char " ")))) - (format (concat "%s" spacer) line-number))) - (defun mitch/left-pad (line-number) - "Pad the line number to the left." - (let ((spacing - (make-string (mitch/linum-get-left-pad line-number) - (string-to-char " ")))) - (format (concat spacing "%s") line-number))) - (defun linum-relative (line-number) - (let* ((diff1 (abs (- line-number linum-relative-last-pos))) - (diff (if (cl-minusp diff1) - diff1 - (+ diff1 linum-relative-plusp-offset))) - (current-p (= diff linum-relative-plusp-offset)) - (current-symbol (if (and linum-relative-current-symbol current-p) - (if (string= "" linum-relative-current-symbol) - (mitch/right-pad line-number) - linum-relative-current-symbol) - (mitch/left-pad diff))) - (face (if current-p 'linum-relative-current-face 'linum))) - (propertize (format linum-relative-format current-symbol) 'face face))) - ;; (linum-relative-global-mode 1) - ;; (mitch/linum-rel-setup) - ;; (linum-relative 282) (add-hook 'prog-mode-hook #'linum-relative-mode) (add-hook 'minibuffer-exit-hook #'linum-relative-on) :custom