I want to detect if selection made was activated and bind appropriate code for indent-region or ifselection mode was not activate - other code.
2 Answers
indent-for-tab-command - is default command that choose between indent-according-to-mode and indent-region automatically.
- indent-according-to-mode - indentation for one line
- indent-region - it indent region with indent-according-to-mode.
full code:
(defun indent-or-complete ()
(interactive)
(if (looking-at "\\_>")
(progn
(expand-abbrev)
(company-complete-common)
)
;; (indent-according-to-mode)
(indent-for-tab-command)
))
You don't have to do anything to get this behavior. This is how emacs behaves out of the box.
-
FWIW, I don't think this answers the question, which is how to invoke some "other code" if the region isn't active. But it does answer the question as expressed in the title. IOW, the question isn't clear.– DrewSep 3 at 22:21
TAB
. The body asks how to indent the region if active and invoke some "other code" if it's inactive. Two different questions.