Emacs – Powerfull Editor for *inx Systems


Some Emacs tweaks for Programmers


Add the needed line in your  ~/.emacs file

(custom-set-variables
‘(mouse-avoidance-mode (quote banish) nil (avoid))
‘(column-number-mode t)
‘(scroll-bar-mode nil)
‘(show-paren-mode t)
‘(tool-bar-mode nil)
‘(menu-bar-mode nil)
‘(transient-mark-mode t))

1. Moves the cursor away while typing
2. shows column number
3. removes scroll bar
4. removes toolbar
5. show-paren-mode allows one to see matching pairs of parentheses
6. removes menu bar
7. standard selection-highlighting behavior of other editors

Set the startup position and frame size

(set-frame-position (selected-frame) 0 0)
(set-frame-size (selected-frame) 80 51)


Enable the font color h color highlighting

(setq font-lock-mode 1)

Below removes the bell sound and then produces the flash at the command space and at the top.
(setq visible-bell 1)

Below line completely removes bells or any flash

(setq ring-bell-function ‘ignore)

The following lines says that to switch between buffers when key is pressed
(global-set-key [(f7)] ‘next-buffer)
(global-set-key [(f8)] ‘previous-buffer)
(global-set-key [(control tab)] ‘bury-buffer)

Remove tool and scroll bars
(tool-bar-mode -1)
(scroll-bar-mode -1)

Changing the start up frame size of emacs
Use the below command to change the startup window size.

emacs22-gtk -geometry height x width

example
emacs22-gtk -geometry 80×51

Linux Coding style for Emacs.
That’s ok, we all do. You’ve probably been told by your long-time unix user helper that “GNU emacs” automatically formats the C sources for you, and you’ve noticed that yes, it does do that, but the defaults it uses are less than desirable (in fact, they are worse than random typing – a infinite number of monkeys typing into GNU emacs would never make a good program).

So, you can either get rid of GNU emacs, or change it to use saner values. To do the latter, you can stick the following in your .emacs file:

(defun linux-c-mode ()
“C mode with adjusted defaults for use with the Linux kernel.”
(interactive)
(c-mode)
(setq c-indent-level 8 )
(setq c-brace-imaginary-offset 0 )
(setq c-brace-offset -8 )
(setq c-argdecl-indent 8 )
(setq c-label-offset -8 )
(setq c-continued-statement-offset 8 )
(setq indent-tabs-mode nil )
(setq tab-width 8 ))

(setq c-default-style “linux-c-mode”
c-basic-offset 8 )

This will define the M-x linux-c-mode command. When hacking on a module, if you put the string -*- linux-c -*- somewhere on the first two lines, this mode will be automatically invoked. Also, you may want to add

Leave a comment