0

I want to detect if selection made was activated and bind appropriate code for indent-region or ifselection mode was not activate - other code.

1
  • The question isn't clear. The title asks to just indent the region with TAB. The body asks how to indent the region if active and invoke some "other code" if it's inactive. Two different questions.
    – Drew
    Sep 3 at 22:23

2 Answers 2

0

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)

      ))
0

You don't have to do anything to get this behavior. This is how emacs behaves out of the box.

1
  • 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.
    – Drew
    Sep 3 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.