HowTo Disable indent-tabs-mode
It sounds like this guy is having problems with emacs automatically converting spaces to tabs. I can sympathise – it took me a while to figure out how to disable indent-tabs-mode correctly.
My post also received a comment asking how to add a tabs if you have disabled indent-tabs-mode. If you need a single tab, use C-q <TAB> (quoted-insert)
. Otherwise, if you need to enter many tabs you can enable M-x eval-expression <RET>(setq indent-tabs-mode t)<RET>
or bind tab to (self-insert-command).
Working With Multiple Databases
To much wailing and nashing of teeth, several weeks ago I introduced my emacs db mode. I have made an extension for quickly and easily switching between multiple databases using ido. It also serves as a nice tutorial for adding custom sections to the mode-line.
Always Prompting Before Exiting Emacs
Nilesh has a post about prompting before exiting to avoid accidents. Now, I occasionally want a prompt – I often get a prompt anyway as I have either processes or unsaved buffers. Occasionally I am caught out when I am sketching things out in scratch buffers (with, e.g. C-x b *stuff* <RET>
).
Most functions that are called when emacs is exiting call (save-buffers-kill-emacs)
which has a customizable variable you can set to control if and how emacs prompts when exiting. I like to timeout these type of prompts, just in case I was attempting to exit while the screen was off.
(setq confirm-kill-emacs (lambda (e) (y-or-n-p-with-timeout "Really exit Emacs (automatically exits in 5 secs)? " 5 t)))
Emacs As A Windows Editor?
There was a strange thread in the Joel On Software forums. Someone wanted an alternative to Emacs on Windows with the following features:
- macros
- good windows integration
- syntax highlighting for multiple file types
- free as in beer
Why strange? Well, emacs has all of this and more. Keyboard macros are available with C-x (
and C-x )
or <f3>
<f4>
in more modern versions. In addition, Emacs 23 is extremely good-looking.
Setting cua-mode and recentf will get you most of the way to that authentic windows app experience.
(cua-mode t) (recentf-mode t)
Remember to use the Emacs Win32 build.
Miscellaneous Tips
Here is a mention of the fantastic occur command.
Someone made a brief post (http://rydow.wordpress.com/2009/06/11/emacs-history-between-sessions) about savehist-mode although they couldn’t remember where they had seen the original. Along with many great Emacs hints, it was from Emacs-fu (it was in a comment by valvo).
Thank you for mentioning my posts, Jared. Publishing those small notes lead me to discover valuable info and visit sites as yours, full of emacs gems and references. Keep it up!
You’re welcome nachopp. Thank you for putting these posts up, helping people to learn about emacs.
“This guy” didn’t have any problems with setting up disable-indent-tabs-mode — I hook up a local function setting it with python-mode-hook. However, this setting is not completly reliable. Try hitting “C-q TAB”: you can insert a tab regardless of whether you have indent-tabs-mode set to nil or not (at least with a quite current XEmacs 21.5-b28.
Hi Holger,
I’ve noted the C-q <TAB> workaround for when indent-tabs-mode is set to nil before.
However, in your post you said
(Emphasis mine). Which implies to me that you’re not quite sure how you entered the tabs. Presumably you didn’t do it by quoting them right? If your problem is that you deliberately enter error causing tabs using C-q then I recommend that you simply stop doing that.
Note that the snippet in your post doesn’t work in my emacs. Have you defined set-indent-tabs-mode?