Note by Apollia on Nov. 8, 2023: Please join my Patreon if you'd like to support me and my work!

My main personal website is now Apollia.org. I'm still not sure what to do with Astroblahhh.Com, so it's mostly staying as-is for now.





Emacs Lisp Blog Post:

Emacs: How to have tabbing and indentation similar to a more typical text editor
11/16/2015

Post Below
11/16/2015 - Emacs: How to have tabbing and indentation similar to a more typical text editor (Emacs Lisp)

    Hide/Show:


   ▲ Top  ▼ Bottom  △ TOC
Emacs: How to have tabbing and indentation similar to a more typical text editor
Monday, November 16th, 2015
05:34:36 GMT

Emacs Lisp

The Emacs editor has a bunch of default behaviors that were driving me crazy:

(Plus other, less insanity-inducing problems - but those aren't solved in this post.)

And also the automatic indentation in php-mode.


Finally, I figured out how to fix all of that, and make Emacs' tabbing and auto-indenting be more like a typical text editor.

But, I'm pretty new to Emacs, so, there might be side effects or other problems with the below solution I'm not yet aware of. Comments are welcome!

Thanks to everyone on the web who posted useful info and/or code which enabled me to cobble together my current favorite solution.


The only Emacs add-on the below code requires is regtab.el, which makes it possible to indent either one line or entire highlighted regions by pressing tab, and un-indent them by pressing shift-tab.

I put the below code in my ".emacs" settings file. I'm using Emacs 24.5.1.


I had some trouble figuring out how to make php-mode stop doing automatic indent. So, finally, I just resorted to the brute force method of editing php-mode.el's source code.

In php-mode.el, I changed every instance of indent-tabs-mode nil to indent-tabs-mode t, and every instance of tab-width 4 to tab-width 7. (But you can use whatever tab-width number you like).

I don't yet know of a less invasive way to fix it than that. But, that worked.


To stop regtab.el from displaying the text "regtab" in your modeline, you can comment out these lines in regtab.el:

(define-minor-mode regtab-mode "Regular Tabs Minor Mode"
  :lighter " regtab" :keymap regtab-mode-map)

And use this line instead, with "lighter" set to "nil". (It's included in the box of code above, so you can just uncomment it.)


Click this link to display the blog comment thread hosted at the Eryss.Com Forum:

   ▲ Top  ▼ Bottom  △ TOC


    Hide/Show:





Note by Apollia on Nov. 8, 2023: Please join my Patreon if you'd like to support me and my work!

My main personal website is now Apollia.org. I'm still not sure what to do with Astroblahhh.Com, so it's mostly staying as-is for now.