mirror of
https://github.com/godotengine/emacs-gdscript-mode.git
synced 2026-01-03 10:09:25 +03:00
Remove gdscript-indent-guess-indent-offset
The function would guess indents wrong and often find an offset value of 8 instead of 4. It's also getting in the way and adding configuration for little benefit.
This commit is contained in:
@@ -58,19 +58,6 @@
|
||||
:type 'integer
|
||||
:safe 'integerp)
|
||||
|
||||
(defcustom gdscript-indent-guess-indent-offset
|
||||
t "If t, tells GDScript mode to guess `gdscript-indent-offset' value."
|
||||
:type 'boolean
|
||||
:group 'gdscript
|
||||
:safe 'booleanp)
|
||||
|
||||
(defcustom gdscript-indent-guess-indent-offset-verbose
|
||||
t "If t, emit a warning when guessing indentation fails."
|
||||
:version "25.1"
|
||||
:type 'boolean
|
||||
:group 'gdscript
|
||||
:safe 'booleanp)
|
||||
|
||||
(defcustom gdscript-indent-trigger-commands '(indent-for-tab-command yas-expand yas/expand)
|
||||
"Commands that might trigger a `gdscript-indent-line' call."
|
||||
:type '(repeat symbol):group'gdscript)
|
||||
|
||||
@@ -45,45 +45,6 @@
|
||||
The name of the defun should be grouped so it can be retrieved
|
||||
via `match-string'.")
|
||||
|
||||
;;; Indentation
|
||||
(defun gdscript-indent-guess-indent-offset ()
|
||||
"Guess and set `gdscript-indent-offset' for the current buffer."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char (point-min))
|
||||
(let ((block-end))
|
||||
(while (and (not block-end)
|
||||
(re-search-forward
|
||||
(gdscript-rx line-start block-start) nil t))
|
||||
(when (and
|
||||
(not (gdscript-syntax-context-type))
|
||||
(progn
|
||||
(goto-char (line-end-position))
|
||||
(gdscript--util-forward-comment -1)
|
||||
(if (equal (char-before) ?:)
|
||||
t
|
||||
(forward-line 1)
|
||||
(when (gdscript-info-block-continuation-line-p)
|
||||
(while (and (gdscript-info-continuation-line-p)
|
||||
(not (eobp)))
|
||||
(forward-line 1))
|
||||
(gdscript--util-forward-comment -1)
|
||||
(when (equal (char-before) ?:)
|
||||
t)))))
|
||||
(setq block-end (point-marker))))
|
||||
(let ((indentation
|
||||
(when block-end
|
||||
(goto-char block-end)
|
||||
(gdscript--util-forward-comment)
|
||||
(current-indentation))))
|
||||
(if (and indentation (not (zerop indentation)))
|
||||
(set (make-local-variable 'gdscript-indent-offset) indentation)
|
||||
(when gdscript-indent-guess-indent-offset-verbose
|
||||
(message "Can't guess gdscript-indent-offset, using defaults: %s"
|
||||
gdscript-indent-offset))))))))
|
||||
|
||||
(defun gdscript-indent-context ()
|
||||
"Get information about the current indentation context.
|
||||
Context is returned in a cons with the form (STATUS . START).
|
||||
|
||||
@@ -181,10 +181,7 @@ the last command event was a string delimiter."
|
||||
(gdscript-rx (* space) block-start))
|
||||
(setq-local outline-level
|
||||
#'(lambda ()
|
||||
"`outline-level' function for gdscript mode."
|
||||
(1+ (/ (current-indentation) gdscript-indent-offset))))
|
||||
|
||||
(when gdscript-indent-guess-indent-offset
|
||||
"`outline-level' function for gdscript mode."
|
||||
(1+ (/ (current-indentation) gdscript-indent-offset)))))
|
||||
|
||||
(provide 'gdscript-mode)
|
||||
|
||||
@@ -44,7 +44,7 @@ BODY is code to be executed within the temp buffer. Point is
|
||||
always located at the beginning of buffer."
|
||||
(declare (indent 1) (debug t))
|
||||
`(with-temp-buffer
|
||||
(let ((gdscript-indent-guess-indent-offset nil))
|
||||
(let ()
|
||||
(gdscript-mode)
|
||||
(insert ,contents)
|
||||
(goto-char (point-min))
|
||||
|
||||
Reference in New Issue
Block a user