Prevent emacs from mixing tabs and spaces? - emacs

Background:
I'm primarily a Javascript developer. Espresso mode rocks.
I work on a team where other people touch my code (and I theirs). Different folks have different preferences for tab width. I like mine at four, a coworker likes his at two.
JSLint complains if you mix tabs and spaces (yes, I realize you can turn it off - but it helps keep me sane).
I'm staring at my buffer in whitespace-mode, and can clearly see that when I newline and tab, it inserts a bunch of tabs and then.. four spaces.
How can I prevent this behavior? The only whitespace before the first visible character of a line should be tabs...

You need to adjust a couple settings in your emacs configuration.
(setq tab-width 4) ;; set your desired tab width
(setq indent-tabs-mode t) ;; use tabs for indentation
You may also need to adjust the indentation offset in your javascript mode so that each indent is a multiple of your tab width (for C-based modes it's called c-basic-offset).

Related

How to hide leading stars in org-mode when in terminal mode

When using org-mode in emacs running in terminal mode (emacs -nw), I cannot hide the leading stars in my headings:
I have seen some similar questions which either:
did not have an answer or
did not have an answer that worked for me
The attached image was after trying the suggested remedies (minus changing my contrast as that leads to other problems).
Is there any way to have these leading starts hidden?

Emacs auto-complete popup menu broken

I'm have reinstalled my emacs and now I'm using emacs v24.3.50 with auto-complete v1.4 and popup.el v0.5. Unfortunately the popup "menu" of auto-complete is kinda broken (see attached screenshot).
The different items are not aligned along a commong vertical line [ignore the black overlay, that stems from CEDET and is probably meant to be placed on the right side next to the popup menu; the problem remains when disabling CEDET, so it is not related).
From what I can tell it looks like the extent of this "shift" between lines depends on how much the length of the strings differs. Also, when selecting a different suggestion using the arrow keys the horizontal shift of the lines changes a little (~few pixels) each time the mark is moved one line up/down.
I have uploaded the part of my .emacs.d/init.el that is used for configuring auto-complete here.
Any suggestions on how to fix this?
It appears you are using a proportional font, which breaks the calculation of the left edge of the overlay.
You can try changing the way auto-complete computes the column:
(setq popup-use-optimized-column-computation nil)
You can also change to a fixed width font.
Note that some other completion systems for Emacs can use tooltips instead of overlays, which would avoid this problem.

How do I fix this random behavior with my Emacs mode line?

I am running Emacs 23.3 on Windows XP. When Emacs is started, the mode line will assume one of these two appearances at random. Needless to say, I prefer the first one. How do I figure out what is going on and how do I make the first one stick?
The images don't show it, but the first one has a GUI type appearance. If I hover over the various bits of text with a mouse, e.g. Help then the text Help turns into a button with shadows etc.
The black mode line appears to be a text mode widget. The only thing that the mouse will change on it is the highlighting.
PS: Thanks JSON!
I vaguely remember this happening years ago depending on whether or not I started Emacs from Remote Desktop. Perhaps there's an issue with color depth?
See if anything has changed your settings to
(set-face-background 'modeline "#000000")
(set-face-foreground 'modeline "#FFFFFF")
(EDIT: Color codes corrected) in any of your .el files.

Do you use Emacs tabbar?

The emacs tabbar.el package adds (buffer)tabs to each window and comes standard with aquamacs and can be added to emacs23 with the emacs-goodies-el package.
Are any of you hardcore emacs users actually using tabbar? I'm sort of used to having tabs, but I would like to know if working without them could be more productive, and if there are other ways besides checking your bufferlist (C-x C-b) to get an overview of your current project files.
As a side note, I really like textmate's project drawer (and tabs), but anything similar in emacs looks just plain hideous.
I've tried using it, but I felt it constraint my workflow rather than improve it. There are a lot of excellent Emacs modes to help with the organization of many buffers and I simply don't feel mapping buffers to tabs is one of those ways.
Just think about the most basic scenario - a lot of tabs. How different programs deal with it - limit the maximum tabs(IntelliJ IDEA); enable tabs bar scrolling(Firefox); infinitely reducing the tabs size(Google Chrome); creating rows of tabs(IntelliJ IDEA)... None of this solutions is that great and by not having tabs in Emacs we have one less problem to worry about. At least this is my subjective opinion - others will most certainly disagree... I personally need nothing more than ido and and iswitchb.
A video of ido in action: http://www.youtube.com/watch?v=lsgPNVIMkIE
Ya, I use tabbar, along with sr-speedbar.
I customize tabbar to show files in specific groups, and mod some keybindings to make navigating the files easier.
FWIW, here's the relevant section from my ~/.emacs:
(require 'tabbar)
; turn on the tabbar
(tabbar-mode t)
; define all tabs to be one of 3 possible groups: “Emacs Buffer”, “Dired”,
;“User Buffer”.
(defun tabbar-buffer-groups ()
"Return the list of group names the current buffer belongs to.
This function is a custom function for tabbar-mode's tabbar-buffer-groups.
This function group all buffers into 3 groups:
Those Dired, those user buffer, and those emacs buffer.
Emacs buffer are those starting with “*”."
(list
(cond
((string-equal "*" (substring (buffer-name) 0 1))
"Emacs Buffer"
)
((eq major-mode 'dired-mode)
"Dired"
)
(t
"User Buffer"
)
)))
(setq tabbar-buffer-groups-function 'tabbar-buffer-groups)
(global-set-key [M-s-left] 'tabbar-backward)
(global-set-key [M-s-right] 'tabbar-forward)
There's lot's of other tips on emacswiki:
http://www.emacswiki.org/emacs/TabBarMode
no.
I use iswitch-b
C-x b "first few letters of buffer", then C-s to rotate to the specific file I want takes me under 2 seconds without me having to move hand to mouse.
No. I could possibly be convinced to try it again with the right customisation, but by default it's pretty useless for me, as I habitually have in excess of 100 buffers open. ibuffer with its filtering and grouping is the best way for managing large numbers of buffers that I've tried.
I like to use speedbar for quick buffer navigation. I have in my .emacs
(speedbar-change-initial-expansion-list "buffers")
(global-set-key [f8] 'speedbar-get-focus)
so when I hit F8, a new frame pops up with a list of open buffers, there you can move point over the buffer you want to select and to activate it. One more F8 goes back to the main frame.
tabs are not reserved for mouse users. look at vim possible workflow: gt to go next tab, or gT to go previous. Say you've one dedicated window for vim: you might easily switch from one buffer to another. Yes, tabs are probably for users with few buffers. if you have hundreds, this won't work.
Quite frankly, you'll find better editors than emacs when speaking of tabs, menus and toolbar. Emacs clearly encourages you to use your keyboard and leave your mouse asleep.
Tabbar or any other tab management tool will have difficulties when you'll have lots of buffers opened. You also don't want to show all your buffers in tabs. Having to remove your hand from the keyboard to grasp the mouse and click on a tab and then remove your hand from the mouse and put it onto the keyboard is clearly a waste of time when a simple keystroke could be used instead.
The best thing you could do to your emacs and to you is to have the following configuration in your .emacs :
(menu-bar-mode -1) ;hide menu-bar
(scroll-bar-mode -1) ;hide scroll-bar
(tool-bar-mode -1) ;hide tool-bar
That will force you to forget the old way of doing things using a mouse (like using tabbar, or menus...), and to use your fingers instead.
Up until now, I haven't tried it, but before I switched back to GNU Emacs from XEmacs, I used the XEmacs tabs very heavily. I found that when I had many source files open, it was one of the fastest ways to jump to the correct file.
Now that I know about tabbar, I am trying it; and so far, I like it.
John
Tabs are really only useful if you use the mouse, and one of the main benefits (to me) of Emacs is that I can avoid the mouse.
So, no, tabbar isn't useful in general.
I did find the tabs useful when I was browsing web pages (using w3m), but I was using the mouse in that case...
Tabbar looks like it is godforsaken
So what about elscreen?
Can be found via http://melpa.milkbox.net/#/elscreen - or installed emacs-elpa (or melpa).
Elscreen is very useful for me.
C-x b<RET> always gives you the last edited buffer. And what do you do with tabs ? Mostly switch back & forth between two files. There you go.

Different headline view with Mac/PC of emacs/orgmode?

I use the same org mode (7.01h) for PC and Mac.
The thing is that for headline, the mac shows only the last * by changing all the pre *'s color to the same as the background, whereas the orgmode in PC shows all the *'s.
I prefer Mac's way.
What makes this difference? How can I show only the last * in the headline?
Set the variable org-hide-leading-stars.
You can either M-x customize-variable org-hide-leading-stars or just (setq 'org-hide-leading-stars) in your .emacs file.
I'm not sure what causes the difference between the two operating systems you use, but you can choose to hide the stars by adding
#+STARTUP: hidestars
to the top of your org file. For more information check the manual page on in-buffer settings