emacs-gdscript-mode icon indicating copy to clipboard operation
emacs-gdscript-mode copied to clipboard

gdscript-use-tab-indents does not affect gdformat

Open ksldmitriy opened this issue 1 year ago • 1 comments

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.

ksldmitriy avatar May 18 '24 11:05 ksldmitriy

Confirming this is still broken.

davehayes avatar Sep 10 '25 19:09 davehayes