How to set tab behaviour in a custom major mode?

101 Views Asked by At

Currently in the major mode I am writing pressing tab moves the point a certain number of spaces.

What I want to happen is more like how python mode makes it so that tab moves the whole line to the correct indentation.

Does anyone know how this is done?

1

There are 1 best solutions below

0
Stefan On BEST ANSWER

Set indent-line-function appropriately in the major mode function, e.g. with something like

(defun my-mode-indent-line (&optional _arg)
  ...)

(define-derived-mode my-mode prog-mode "MyMode"
  "Have fun with My Mode."
  ...
  (setq-local indent-line-function #'my-mode-indent-line)
  ...)