Skip to content

Commit

Permalink
add two editor variables to line-numbers
Browse files Browse the repository at this point in the history
this patch adds two editor variables to line-numbers, `line-format` and `current-line-display-function`.  this allows the user to change the width/format of the line numbers and to set the current-line display in relative numbers.

for example :
```
(setf (variable-value 'line-number-format :global) "~2D ")
(setf (variable-value 'current-line-display-function :global) (lambda () 0))
```

now the line-numbers will be narrower and the current-line will always be 0.
  • Loading branch information
SequentialDesign committed Dec 5, 2024
1 parent 16bcd94 commit 4aa462a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/ext/line-numbers.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:use :cl :lem)
(:export :*relative-line*
:line-number-format
:relative-line-numbers-current-line-value
:current-line-display-function
:line-numbers-attribute
:active-line-number-attribute
:line-numbers
Expand All @@ -22,16 +22,15 @@
"Set to desired format, for example, \"~2D \" for a
two-character line-number column.")

(define-editor-variable relative-line-numbers-current-line-value
'(line-number-at-point (current-point))
"Set to desired current-line value when relative line numbers
are active, for example, 0 or \"->\".")
(define-editor-variable current-line-display-function
(lambda () (line-number-at-point (current-point)))
"Set to desired current-line display when relative line numbers are active, for example, (lambda () 0) or (lambda () (string \" ->\")).")

(define-attribute line-numbers-attribute
(t :foreground :base07 :background :base01))
(t :foreground :base07 :background :base01))

(define-attribute active-line-number-attribute
(t :foreground :base07 :background :base01))
(t :foreground :base07 :background :base01))

(define-editor-variable line-numbers nil ""
(lambda (value)
Expand All @@ -57,9 +56,10 @@ With a positive universal argument, use relative line numbers. Also obey the glo
(defun compute-line (buffer point)
(if *relative-line*
(let ((cursor-line (line-number-at-point (buffer-point buffer)))
(line (line-number-at-point point)))
(line (line-number-at-point point))
(current-line-display (funcall (variable-value 'current-line-display-function :default buffer))))
(if (= cursor-line line)
(eval (variable-value'relative-line-numbers-current-line-value :default buffer))
current-line-display
(abs (- cursor-line line))))
(line-number-at-point point)))

Expand Down

0 comments on commit 4aa462a

Please sign in to comment.