[ale] C on Linux

Charles Shapiro cshapiro at nubridges.com
Mon Mar 11 09:18:45 EST 2002


Uh, I use emacs to code in C here, although I generally go to the
command line to test and do make(1). On a stock emacs distro, <ctrl>Z
will put emacs in the background, so you can come back to it with fg (in
bash) without reloading it from disk. This works with vi(1) as well.  I
haven't bothered with syntax highlighting, but this .emacs file will
make emacs format C code the way I like. You're welcome to examine and
hack this file as you wish. To make it work, put it in "${HOME}/.emacs"
(that is, the name ".emacs" in your home directory). If syntax
highlighting is your heart's desire, you might wish to check out vim (
http://www.vim.org/ ), which has a loyal -- some would say fanatical --
following.

For myself, I gotta love an editor which has a Towers of Hanoi
simulation (Meta-X-"hanoi"), an adventure game (Meta-X-"dunnet"), and a
psychotherapist simulation (Meta-X-"doctor") buried inside it.

-- CHS

-----Original Message-----
From: Master Wizard [mailto:mainwizard at vei.net]
To: ale at ale.org
Sent: Saturday, March 09, 2002 10:30 AM
To: ALE
Subject: [ale] C on Linux


I am ready to start learning more about Linux and want to get into C on 
Linux. I have several books on C and C++, but they gloss over any 
platform specifics. I have a passing familiarity with vi and have looked

at emacs. I have also looked at some X based IDE's.

I would like to stay away from X as many of my systems are built on 
older (486 and P1) hardware and X does not run well. I think emacs might

be the best choice, but I need to find some help with setting up and 
using it for programming with C. Things like compiling, linking and 
testing from emacs. Syntax highlighting, command completaion or anything

else it supports.

Any good books, websites or other resources for this type of
information?

I have programmed with basic, C, Pascal and perl before and currently do

Java professionally. I am looking to expand my skills and need help with

the environment specifically, not programming in general.

Thanks,
Ed.


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems
should be 
sent to listmaster at ale dot org.



;;; Charles Shapiro 18-Mar-1993
;Make <Ctrl>h behave right. Move help stuff to <Ctrl>^.  These use define-key
;instead of the translate-key command documented in emacs because that allows
;me to bind the <del> key to delete character left 

;(define-key global-map "\C-h" 'delete-backward-char)
;(define-key global-map "\C-^" help-map) 

;Reverse bindings of Ctrl-Y and Ctrl-K to conform better to wordstar commands
(define-key global-map "\C-y"  'kill-line)
(define-key global-map "\C-k"  'yank)

;Make <del> key delete character left (like PC programs..)
(define-key esc-map "[3~" 'delete-char)
;(define-key global-map ""  'delete-char)
;(define-key c-mode-map ""  'delete-char)
;(define-key perl-mode-map "^g" 'delete-char)

;Map <PgUp> and <PgDn> keys -- you must have a custom unix-map.win file and
;vt220 user-defined keys file for these to work. Since I've elected to 
;start my user defined keys off with <Esc>, I have to put the bindings into
;esc-map, not global-map.
(define-key esc-map "[5~" 'scroll-down)
(define-key esc-map "[6~" 'scroll-up)

;Map <Home> and <End> keys -- see comment above re <PgUp> and <PgDn> keys.
(define-key esc-map "[1~" 'beginning-of-line)
(define-key esc-map "[4~" 'end-of-line)
(define-key esc-map "OH" 'beginning-of-line)
(define-key esc-map "OF" 'end-of-line)

;Map <ins> key to overwrite-mode -- like <PgUp>, <PgDn> keys
(define-key esc-map "[2~" 'overwrite-mode)

;Map backward/forward word to Wordstar keystrokes.
(define-key global-map "\C-a" 'backward-word)
(define-key global-map "\C-f" 'forward-word)

;Map <Ctrl>X-g to goto-line 
(define-key ctl-x-map "g" 'goto-line)

;Map <Ctrl>T to kill-word
(define-key global-map "\C-t" 'kill-word)

;Change C formatting to what I like. Turn off indentation relative to previous lines 
; for a few things.
(defun my-c-mode-common-hook ()
;; Customize open brace not to indent. (zero is number of spaces to indent)
(c-set-offset 'substatement-open 0)
;; Customize continued argument lists not to indent.
(c-set-offset 'arglist-cont-nonempty 0)
;; Customize first argument on new line not to indent
(c-set-offset 'arglist-intro 0)
;; Customize comments not to indent
(c-set-offset 'comment-intro 0)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

(setq c-basic-offset 3)  
(setq c-indent-level 3)
(c-set-style "bsd")

;Unbind <esc><esc> command
(global-unset-key "\e\e")

(put 'upcase-region 'disabled nil)
(setq-default indent-tabs-mode `nil)


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.




More information about the Ale mailing list