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

gdscript-use-tab-indents does not affect gdformat #149

Open
ksldmitriy opened this issue May 18, 2024 · 0 comments
Open

gdscript-use-tab-indents does not affect gdformat #149

ksldmitriy opened this issue May 18, 2024 · 0 comments

Comments

@ksldmitriy
Copy link

Issue

gdscript-use-tab-indents does not make gdformat use spaces instead of tabs.

Fix

Changes in code

I think i fixed it. Here is my version of gdscript-comint-gdformat--run function:

(defun gdscript-comint-gdformat--run (arguments)
  "Run gdformat in comint mode.

ARGUMENTS are command line arguments for gdformat executable.
When run it will kill existing process if one exists."
  (let ((buffer-name (gdscript-util--get-gdformat-buffer-name))
        (inhibit-read-only t))

    (when (not (executable-find gdscript-gdformat-executable))
      (error "Error: Could not find %s on PATH.  Please customize the gdscript-gdformat-executable variable" gdscript-gdformat-executable))

    (with-current-buffer (get-buffer-create buffer-name)
      (unless (derived-mode-p 'gdformat-mode)
        (gdformat-mode)
        (buffer-disable-undo))
      (erase-buffer)
      (let* ((line-length (list (format "--line-length=%s" gdscript-gdformat-line-length)))
			 (indent-mode-arg (and (not gdscript-use-tab-indents) (list (format "-s %s" gdscript-indent-offset))))
             (buffer (comint-exec (current-buffer) buffer-name gdscript-gdformat-executable nil (append line-length indent-mode-arg arguments))))
        (set-process-sentinel (get-buffer-process buffer) 'gdscript-comint-gdformat--sentinel)
        buffer))))

I added (indent-mode-arg (and (not gdscript-use-tab-indents) (list (format "-s %s" gdscript-indent-offset)))), and then appended it to comint-exec arguments.

Documentation

If gdscript-use-tab-indents is nil, it uses gdscript-indent-offset as a number of desired spaces, utilizing gdformat's -s --use-spaces=<int> option.

Examples

Using tabs

 (setq gdscript-use-tab-indents t)

This configuration will call gdformat *some-args* *buffer-name*.

Using spaces

 (setq gdscript-use-tab-indents nil)
 (setq gdscript-indent-offset 4)

This configuration will call gdformat *some-args* -s 4 *buffer-name*, where 4 is a value of gdscript-indent-offset.

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

1 participant