Closed hackerb9 closed 1 year ago
This sounds like a good idea. I will have a look and see if I can do something about it. However, as you probably saw, I haven't worked with basic-mode for a while, so it will take me some time to get into it again.
Hopefully it will not take you much time to fix. I have discovered that setting line-number-cols to 1 seems to do exactly what I believe it should do when set to 0.
Well, now it is fixed, maybe. I meant to push the change to branch, but instead I pushed it to master, so now it has been released, I guess. Please try it out!
Thanks! Maybe I'm doing something wrong but it is not working for me.
It appears the basic-newline-and-number does not like it when auto-number is nil. (Or t, for that matter.)
Debugger entered--Lisp error: (wrong-type-argument numberp nil)
int-to-string(nil)
(insert (int-to-string new-line-number))
(let* ((current-line-number (basic-current-line-number)) (next-line-number (s$
basic-newline-and-number()
funcall-interactively(basic-newline-and-number)
call-interactively(basic-newline-and-number nil nil)
command-execute(basic-newline-and-number)
When I (setq basic-auto-number 10)
, I am able to increment numbers if the cursor is on a numbered line, but even then, I get an error if I hit Enter on a blank line.
It looks like the problem is at line no. 497 where two when
s got folded into one. When I add back in the missing (when new-line-number ...
, I stop getting errors. (But see below).
Edit: The nested when syntax is a bit confusing. It may be clearer to leave line 497 alone and instead make line 505 conditional, like so:
(if new-line-number (basic-indent-line))))
Edit 2: Oops. I did say the nested when
s were confusing, right? To avoid that, the correct line to edit is line no. 504, which should look like this:
(if new-line-number (insert (int-to-string new-line-number)))
Oh, bad testing on my side. I will try to fix it as soon as possible. Thanks for the debugging!
Now there should be a fixed version published. Let's hope it works this time. :)
Works perfectly! That will make collaboration much easier.
By the way, the documentation for basic-line-number-cols may need to be updated.
;; You can also customize the number of columns to allocate for line
;; numbers, see variable `basic-line-number-cols'. The default value
;; is 0, which means not using line numbers at all.
;; You can also customize the number of columns to allocate for
;; line numbers using the variable `basic-line-number-cols'. The
;; default value of 0 (no space reserved) is appropriate for
;; programs with no line numbers and for left aligned numbering.
;; Use a positive integer, such as 6, if you prefer right alignment.
(defcustom basic-line-number-cols 0
"*Specifies the number of columns to allocate to line numbers.
This number should include the single space between the line number and
the actual code. Set this variable to 0 if you do not use line numbers."
:type 'integer
:group 'basic)
(defcustom basic-line-number-cols 0
"*Specifies the number of columns to allocate to line numbers.
This number includes the single space between the line number and
the actual code. Leave this variable at 0 if you do not use line
numbers or if you prefer left aligned numbering. A positive value
adds sufficient padding to right align a line number and add a
space afterward. The value 6 is reasonable for older dialects of
BASIC which used at most five digits for line numbers."
:type 'integer
:group 'basic)
(define-derived-mode basic-mode prog-mode "Basic"
"Major mode for editing BASIC code.
Commands:
TAB indents for BASIC code. RET will insert a new line starting
with a fresh line number if line numbers are turned on.
To turn on line numbers, customize variables `basic-auto-number'
and `basic-line-number-cols'.
\\{basic-mode-map}"
(define-derived-mode basic-mode prog-mode "Basic"
"Major mode for editing BASIC code.
Commands:
\\[indent-for-tab-command] indents for BASIC code.
\\[newline] can automatically insert a fresh line number if
`basic-auto-number' is set. (Default is disabled).
Customization:
You can customize the indentation of code blocks, see variable
`basic-indent-offset'. The default value is 4.
Formatting is also affected by the customizable variables
`basic-delete-trailing-whitespace' and `delete-trailing-lines'
(from simple.el).
You can also customize the number of columns to allocate for line
numbers using the variable `basic-line-number-cols'. The default
value of 0, no space reserved, is appropriate for programs with
no line numbers and for left aligned numbering. Use a larger
value if you prefer right aligned numbers. Note that the value
includes the space after the line number, so 6 right aligns
5-digit numbers.
The other line number features can be configured by customizing
the variables `basic-auto-number', `basic-renumber-increment' and
`basic-renumber-unnumbered-lines'.
\\{basic-mode-map}"
Auto-number does not work unless line-number-cols is also set, which is not always desirable.
It is not clear to me why it is required. If I understand correctly, line-number-cols reserves a margin so that line numbers will be right aligned, like so:
Line-number-cols can cause problems when collaborating with people who have not yet accepted Emacs as the one true editor :wink: and who still left-align their line numbers.
It would be nice if auto-number was a separate feature and could be turned on independently without having to even know about line-number-cols. I suggest that if a person has line-number-cols set to the default (0), line numbers should simply be left aligned when auto-number is set. Like so:
Thanks!