godotengine / godotengine/emacs-gdscript-mode

gdscript-use-tab-indents does not affect gdformat

Open
#149 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
401
Forks
42
Avg merge
23h 23m
Merged PRs (30d)
1

Description

# 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:

```elisp
(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=` option.
## Examples
### Using tabs
```elisp
(setq gdscript-use-tab-indents t)
```
This configuration will call `gdformat *some-args* *buffer-name*`.
### Using spaces
```elisp
(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`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.