From 30b71fe4417535caaf6c336290483d4d4811d60b Mon Sep 17 00:00:00 2001 From: MitchMarq42 Date: Wed, 27 Jul 2022 07:09:43 -0800 Subject: [PATCH] maybe fix linum-relative? --- lisp/mitch-packages.el | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lisp/mitch-packages.el b/lisp/mitch-packages.el index 17cb343..1a22d7b 100644 --- a/lisp/mitch-packages.el +++ b/lisp/mitch-packages.el @@ -233,27 +233,27 @@ targets." (use-package embark-consult :after (embark consult)) -;; WORKING: Relative line numbers with stuff +;; SORTA WORKING: Relative line numbers with stuff (use-package linum-relative :diminish :init (require 'cl-lib) (require 'linum-relative) (setq linum-relative-current-symbol "") - (defvar total-lines (count-lines (point-min) (point-max))) - (defvar total-width 4) - ;; (defun mitch/get-total-width () - ;; (+ 2 (round (log total-lines 10)))) + (defun mitch/get-total-width () + "set up linum relative variables per buffer." + (let ((total-lines (count-lines (point-min) (point-max)))) + (setq-local total-width (ceiling (log total-lines 10))))) + ;; (defvar total-width 4) (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 line-number))) - (- total-width symbol-width))) + (- (mitch/get-total-width) symbol-width))) (defun mitch/right-pad (line-number) "Pad the line number to the right." - (let* ( - (spacing (- total-width (mitch/symbol-width line-number))) + (let* ((spacing (- (mitch/get-total-width) (mitch/symbol-width line-number))) (spacer (make-string spacing (string-to-char " ")))) (format (concat "%s" spacer) line-number))) (defun mitch/left-pad (line-number) @@ -276,6 +276,8 @@ targets." (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) :custom (linum-relative-current-symbol "") ) @@ -732,7 +734,8 @@ targets." ))) (use-package magit - :commands magit) + :commands magit + :hook (magit-mode . turn-off-line-numbers)) (use-package hyperbole :diminish @@ -754,7 +757,6 @@ targets." :config (add-hook 'Info-mode-hook #'info-variable-pitch-mode)) - ;; (use-package empv ;; :straight ;; (:type git :host github