diff --git a/src/ext/line-numbers.lisp b/src/ext/line-numbers.lisp index ed011fc9b..f0c25f905 100644 --- a/src/ext/line-numbers.lisp +++ b/src/ext/line-numbers.lisp @@ -1,6 +1,8 @@ (defpackage :lem/line-numbers (:use :cl :lem) (:export :*relative-line* + :line-number-format + :custom-current-line :line-numbers-attribute :active-line-number-attribute :line-numbers @@ -15,13 +17,21 @@ (defvar *previous-relative-line* nil) (defvar *initialized* nil) -(defvar *line-number-format* nil) + +(define-editor-variable line-number-format "~6D " + "Set to desired format, for example, \"~2D \" for a +two-character line-number column and a margin of one space.") + +(define-editor-variable custom-current-line nil + "Set to desired current-line value when relative line +numbers are active, for example, \"->\". NIL will make +the absolute value of the current line display.") (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) @@ -46,16 +56,19 @@ 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))) + (let ((cursor-line (line-number-at-point (buffer-point buffer))) + (line (line-number-at-point point)) + (custom-line (variable-value 'custom-current-line :default buffer))) (if (= cursor-line line) - line + (if custom-line + custom-line + line) (abs (- cursor-line line)))) (line-number-at-point point))) (defmethod lem-core:compute-left-display-area-content ((mode line-numbers-mode) buffer point) (when (buffer-filename (point-buffer point)) - (let* ((string (format nil "~6D " (compute-line buffer point))) + (let* ((string (format nil (variable-value 'line-number-format :default buffer) (compute-line buffer point))) (attribute (if (eq (compute-line buffer point) (compute-line buffer (buffer-point buffer))) `((0 ,(length string) active-line-number-attribute))