pine-script-mode icon indicating copy to clipboard operation
pine-script-mode copied to clipboard

How can I prevent adding a TAB if inner block is already aligned, in `pine-script-mode`?

Open avatar-lavventura opened this issue 3 years ago • 0 comments

I am using pine-script-mode with a 4 space TAB. Here is an inner block of an if statement that is already aligned. How can I prevent adding a TAB char (or 4 space chars) when I press TAB?

pine file:

if x == 1
    line1_x = 100
    line2_x = 110

Here when cursor is at the beginning of the line1_x or line2_x lines and I press TAB it adds 4 spaces. Instead, since it is already aligned I want it to do nothing.


basic emacs config file:

(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/"))
(package-initialize)
(fset 'yes-or-no-p 'y-or-n-p)

(use-package pine-script-mode
  :ensure t
  :pin melpa-stable
  :mode (("\\.pine" . pine-script-mode)))

(defun pine-custom-settings ()
  (setq indent-tabs-mode nil)
  (setq tab-width 4))

(defun c/pinescript-indent ()
  "Just do dumb indentation rather than emacs' relative indentation."
  (setq indent-tabs-mode nil)
  (setq tab-width 4)  ; this can be omitted if standard-indent is 4
  (setq indent-line-function 'insert-tab))

(add-to-list 'indent-line-ignored-functions 'insert-tab)
(add-hook 'pine-script-mode-hook 'c/pinescript-indent)

avatar-lavventura avatar Jan 04 '23 11:01 avatar-lavventura