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

add two editor variables to line-numbers, line-number-format and current-line-value #1684

Conversation

SequentialDesign
Copy link
Contributor

with these editor variables, the user can customize line-format and current-line value. for example :

(setf (variable-value 'line-number-format :global) "~2D ")
(setf (variable-value 'relative-line-numbers-current-line-value :global) 0)

this will make the line numbers narrow and make the current line show up as '0' in the line-number column

…ent-line-value

with these editor variables, the user can customize line-format and current-line value. for example :

```
(setf (variable-value 'line-number-format :global) "~2D ")
(setf (variable-value 'relative-line-numbers-current-line-value :global) 0)
 ```

this will make the line numbers narrow and make the current line show up as '0' in the line-number column
Comment on lines 25 to 27
(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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to make this a function rather than eval.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before that, it seems like the API that specifies this behavior from the outside is not a good idea.

@@ -15,7 +17,15 @@
(defvar *previous-relative-line* nil)

(defvar *initialized* nil)
(defvar *line-number-format* nil)

(define-editor-variable line-number-format "~6D "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good.

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.
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.
@SequentialDesign
Copy link
Contributor Author

sorry for the poor style, purely bad habits. and thank you for the patience

i have changed it for the variable to be assigned inside the let with funcall and modified the name of the variable so that it's clear that it must be a function

@SequentialDesign
Copy link
Contributor Author

and sorry about changing the attribute style indentations. i yanked in the file from outside, and LEM did it automatically. it was unintentional.

two-character line-number column.")

(define-editor-variable current-line-display-function
(lambda () (line-number-at-point (current-point)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compute-line holds the point variable.
Wouldn't it be better to take that as an argument?
It seems to me that using what is passed as an argument is a better style than thinking about what position the current-point is actually in.

#'line-number-at-point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, i think i see what you mean. the thing is i want to be able to set the value to 0 or ->, etc. so i'm guessing you mean make a variable like custom-current-line-indicator and set it to nil, and if it is defined, then compute-line will call that. otherwise, show the current line number.

that does make sense. am i understanding that correctly ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I understand your intention.

add two editor variables to line-numbers, `line-format` and `custom-current-line`. they allow the user to set the line format and choose a custom current line if they want.

for example :

`(setf (variable-value 'line-number-format :global) "~2D ")`

for a narrow line-number column. and

`(setf (variable-value 'custom-current-line :global) "->")`

for a current-line indicator of `->`
@SequentialDesign
Copy link
Contributor Author

alright, i think it's much better now. custom-current-line is set to nil, and that will show absolute line. if custom-current-line is set, then it will show its value

add two editor variables to line-numbers, `line-format` and `custom-current-line`. they allow the user to set the line format and choose a custom current line if they want.

for example :

`(setf (variable-value 'line-number-format :global) "~2D ")`

for a narrow line-number column. and

`(setf (variable-value 'custom-current-line :global) "->")`

for a current-line indicator of `->`
…nt-line-value

add two editor variables to line-numbers, `line-format` and `custom-current-line`. they allow the user to set the line format and choose a custom current line if they want.

for example :

`(setf (variable-value 'line-number-format :global) "~2D ")`

for a narrow line-number column. and

`(setf (variable-value 'custom-current-line :global) "->")`

for a current-line indicator of `->`
@SequentialDesign
Copy link
Contributor Author

one more change. i put everything in the let to make it cleaner and proper

@cxxxr
Copy link
Member

cxxxr commented Dec 6, 2024

Thank you for the PR, I will merge it.

@cxxxr cxxxr merged commit 8b822cd into lem-project:main Dec 6, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants