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

Unexpected handling of tabs #118

Open
bentxt opened this issue Jan 10, 2022 · 2 comments
Open

Unexpected handling of tabs #118

bentxt opened this issue Jan 10, 2022 · 2 comments

Comments

@bentxt
Copy link

bentxt commented Jan 10, 2022

Hi
I like using parinfer but in this case something goes wrong. Since I cannot figure out what the problem is, I had to disable parinfer completely, because otherwise it messes up existing code like:

(define (read-file name)
  (call-with-input-file name
    (lambda (port)
      (letrec ((recur (lambda ()
			(let ((expr (read port)))
			  (if (eof-object? expr)
			      '()
			      (cons expr (recur)))))))
	(recur)))))

which parinfer transforms to:


(define (read-file name)
  (call-with-input-file name
    (lambda (port)
      (letrec ((recur (lambda ()))))
      			(let ((expr (read port)))
      			  (if (eof-object? expr)
      			      '()
      			      (cons expr (recur))))))
  	(recur))

@bentxt
Copy link
Author

bentxt commented Jan 10, 2022

I think by reformating the source code I prevent the unwanted transformation:

(define (read-file name)
   (call-with-input-file name
      (lambda (port)
         (letrec 
            ((recur 
               (lambda () 
                  (let ((expr (read port)))
                     (if (eof-object? expr)
                        '()
                        (cons expr (recur)))))))
           (recur)))))

I somehow possible I would prefer the source code in its original form

@eraserhd
Copy link
Owner

Hi! It looks like there are tabs in the original, and neither the original parinfer implementation, nor this one, supports them well (they both replace the tabs with exactly two spaces regardless of where the tab is aligned). If I replace the tabs with spaces, I get the result you want.

I think that fixing this would require specifying tab widths, and adding real tab logic based on input column.

Related: #86

@eraserhd eraserhd changed the title unwanted transformation with letrec Unexpected handling of tabs Jan 12, 2022
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

No branches or pull requests

2 participants