0

Launching emacs with the -Q option (default settings) shows TAB being correctly bound to indent-for-tab-command. If I launch emacs without the -Q, TAB is always being bound to forward-button which is absolutely not what I want.

I've commented everything out of my ~/.emacs file and the problem is still persisting. What could be changing the TAB key behavior?

  • Could it be that your new Emacs is some older version? – Stefan Dec 2 '16 at 2:33
  • Check the key binding for TAB using e.g. C-h k TAB. By default this will tell you that (in Emacs 25 at least) TAB is bound to indent-for-tab-command, which would allow you to select the region and indent. If it is bound to something else you'll need to sort out where in your configuration that is happening. You can try starting Emacs with the -Q option (which skips your personal confiugration) to confirm the default behavior. – glucas Dec 2 '16 at 16:10
  • @glucas thanks for that suggestion, turns out the default assignment is correct, but for whatever reason, if I do not launch with the -Q option, TAB ends up being bound to forward-button! I've since commented out everything from my ~/.emacs file and it still gets bound to forward-button, where else could this be set? I'll update the question – Jon Dec 2 '16 at 17:36
  • How about if you run emacs with -q (vs. -Q)? That skips your init file but loads other things like site-lisp files, which might be changing things. You can also try fixing the binding in your .emacs with (global-set-key (kbd "TAB") 'indent-for-tab-command). – glucas Dec 2 '16 at 17:51
  • Also note that tab does get bound to forward-button by default in some modes such as help-mode. – glucas Dec 2 '16 at 18:02
1

As suggested in the comments, you can check the binding of the TAB key using C-h k TAB. Try starting emacs with -Q and -q to help narrow down where the binding might be set.

With -Q Emacs skips all local init files so you'll get the default behavior. Tab should be bound to indent-for-tab-command. With -q Emacs skips your personal init file but will still load any site files.

Refer to the Emacs manual for details about what files are loaded at startup. There may be site-start.el or default.el files on your load path that are changing things. You'll want to check the load path (C-h v load-path) to see where such files might be found -- typically there is a site-lisp directory in your Emacs installation directory.

0

Not sure what you experienced before or are expecting now, but you can do either of these things to indent the selected text (region):

  • C-M-\ (indent-region): Indent the region text either according to the current mode or using the function that is the value of variable indent-region-function. (Use C-f indent-region for more details.)

  • C-x TAB (indent-rigidly): Indent the region text a fixed amount. With no prefix arg, you can repeat and back up using the left and right arrows. With a numeric prefix arg, indent that many chars (negative means reduce indentation).

If those keys do not seem to be bound as described then take a look at your init file, and adjust it accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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