From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "William Payne" Newsgroups: gmane.emacs.help Subject: Re: emacs seems to think tab width is two spaces Date: Thu, 29 Apr 2004 02:24:02 +0200 Organization: Island, Linkoping University, Sweden Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1083200410 27542 80.91.224.253 (29 Apr 2004 01:00:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 29 Apr 2004 01:00:10 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 29 03:00:03 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BIzuE-0008Pq-00 for ; Thu, 29 Apr 2004 03:00:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BIzUR-0002Gw-PW for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Apr 2004 20:33:23 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.sunet.se!news01.sunet.se!news.island.liu.se!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 223 Original-NNTP-Posting-Host: astmatix.ida.liu.se Original-X-Trace: news.island.liu.se 1083198241 15061 130.236.186.15 (29 Apr 2004 00:24:01 GMT) Original-X-Complaints-To: abuse@island.liu.se Original-NNTP-Posting-Date: Thu, 29 Apr 2004 00:24:01 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Original-Xref: shelby.stanford.edu gnu.emacs.help:122814 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:18103 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:18103 "William Payne" wrote in message news:c6phfp$em3$1@news.island.liu.se... > Hello, I use emacs for programming in C and C++. I have been modifying my > .emacs some lately, and now I noticed that emacs seems to think that the tab > width is suddenly two spaces instead of of three...I'm sure it's a simple > error in my .emacs, so I am posting it here: > > (if (eq window-system 'w32) > (progn > (add-to-list 'load-path "c:/emacs-21.3/cc-mode-5.30.8") > (set-face-font 'default > "-raster-Courier-normal-r-normal-normal-16-120-96-96-c-*-iso8859-1") > (w32-send-sys-command ?\xf030) ; Start as maximized. Or use $ > emacs --fullscreen > )) > > (standard-display-european t) > (global-font-lock-mode t) > (setq font-lock-maximum-decoration t) > > (setq scroll-bar-mode-explicit t) > (set-scroll-bar-mode 'right) > > (setq line-number-mode t) ; Show line number in status bar. > (setq column-number-mode t) ; Show column in status bar. > (setq tab-width 3) > (setq case-fold-search t) ; A and a differs in search. > (setq default-case-fold-search nil) ; A and a does not differ in search. > (setq default-major-mode 'text-mode) ; Mode for unknown file type. > (setq blink-matching-paren-distance nil) ; Always show corresponding > parenthesis. > (setq next-line-add-newlines nil) ; Don't add new lines after EOF > (setq inhibit-startup-message t) ; No start-up message > (setq ask-about-buffer-names t) ; Be helpful > (setq completion-auto-help t) ; ...with buffer names. > (setq display-time-day-and-date t) > (setq display-time-24hr-format t) > (display-time) ; Show time formatted as specified above. > (setq-default indent-tabs-mode nil) ; Use spaces, not tabs, for indentation. > > > ;; Pre-selected colors. > (set-background-color "Black") > (set-foreground-color "White") > (set-cursor-color "Cyan") > > ;; Set mode depending on file type. > (setq auto-mode-alist > (append > (list > '("\\Makefile" . makefile-mode) ; Maybe use \\Makefile$ ? > ) > auto-mode-alist > ) > ) > > (defun williams-common-hook () > (c-toggle-hungry-state 1) > (setq c-basic-offset 3) > (add-hook 'c-mode-common-hook 'williams-common-hook)) > > (defun my-c-hook () > (setq c-offsets-alist > '( > (string . +) > (c . c-lineup-C-comments) > (defun-open . 0) > (defun-close . 0) > (defun-block-intro . +) > ;; (class-open . 0) > ;; (class-close . 0) > (inline-open . 0) > (inline-close . 0) > (ansi-funcdecl-cont . +) > ;; (catch-clause . 0) > (knr-argdecl-intro . +) > (knr-argdecl . 0) > (topmost-intro . 0) > (topmost-intro-cont . 0) > (member-init-intro . +) ; Maybe remove for C code? > (member-init-cont . 0) ; Maybe remove for C code? > ;; (inher-intro . +) > ;; (inher-cont . c-lineup-multi-inher) > (block-open . 0) > (block-close . 0) > (brace-list-open . 0) > (brace-list-close . 0) > (brace-list-intro . +) > (brace-list-entry . 0) > (statement . 0) > (statement-cont . +) ; Strings over multiple lines looks > good. > (statement-block-intro . +) > (statement-case-intro . +) > (statement-case-open . 0) > ;; (namespace-open . 0) > ;; (namespace-close . 0) > ;; (innamespace . +) > (substatement . +) > (substatement-open . 0) > (case-label . +) > (access-label . -) ; Maybe remove for C code? > (label . 2) ; Hmm? > (do-while-closure . 0) > (else-clause . 0) > (comment-intro . c-lineup-comment) > (arglist-intro . +) > (arglist-cont . 0) > (arglist-cont-nonempty . c-lineup-arglist) > (arglist-close . +) > ;; (stream-op . c-lineup-streamop) > ;; (inclass . +) > (cpp-macro . -) ;1000) > ;; (friend . 0) > ))) > (add-hook 'c-mode-hook 'my-c-hook) > > (defun williams-c++-hook () > (setq c-offsets-alist > '( > (string . +) > (c . c-lineup-C-comments) > (defun-open . 0) > (defun-close . 0) > (defun-block-intro . +) > (class-open . 0) > (class-close . 0) > (inline-open . 0) > (inline-close . 0) > (ansi-funcdecl-cont . +) > (catch-clause . 0) > ; (knr-argdecl-intro . +) > ; (knr-argdecl . 0) > (topmost-intro . 0) > (topmost-intro-cont . 0) > (member-init-intro . +) > (member-init-cont . 0) > (inher-intro . +) > (inher-cont . c-lineup-multi-inher) > (block-open . 0) > (block-close . 0) > (brace-list-open . 0) > (brace-list-close . 0) > (brace-list-intro . +) > (brace-list-entry . 0) > (statement . 0) > (statement-cont . +) ; Strings over multiple lines looks > good. > (statement-block-intro . +) > (statement-case-intro . +) > (statement-case-open . 0) > (namespace-open . 0) > (namespace-close . 0) > (innamespace . +) > (substatement . +) > (substatement-open . 0) > (case-label . +) > (access-label . -) > (label . 2) ; Hmm? > (do-while-closure . 0) > (else-clause . 0) > (comment-intro . c-lineup-comment) > (arglist-intro . +) > (arglist-cont . 0) > (arglist-cont-nonempty . c-lineup-arglist) > (arglist-close . +) > (stream-op . c-lineup-streamop) > (inclass . +) > (cpp-macro . -1000) > (friend . 0) > ))) > (add-hook 'c++-mode-hook 'williams-c++-hook) > > ;; Change order of CR/LF. Will indent every new line. > (setq foo (global-key-binding "\C-m")) ; Save CR binding. > (global-set-key "\C-m" (global-key-binding "\C-j")) ; Set CR to LF. > (global-set-key "\C-j" foo) ; Set LF to old CR. > > (custom-set-variables) > (custom-set-faces > '(font-lock-comment-face ((t (:foreground "Green")))) > '(font-lock-reference-face ((((class color) (background light)) > (:foreground "LightGreen")))) > '(font-lock-string-face ((t (:foreground "Gray")))) > '(font-lock-keyword-face ((t (:bold t :foreground "Cyan")))) > '(font-lock-constant-face ((t (:foreground "Yellow")))) > '(font-lock-type-face ((t (:bold t :foreground "White")))) > '(font-lock-variable-name-face ((t (:foreground "Yellow")))) > '(font-lock-function-name-face ((t (:foreground "Cyan")))) > '(font-lock-builtin-face ((t (:bold t :foreground "LightGreen"))))) > > Sorry for posting the entire file, lots of it I am sure is not relevant for > the problem but I didn't want to risk leaving anything out that could be the > cause of this problem..If you happen notice improvements I could make to > this file I'd be happy to hear them as well. > > Thanks for any replies > > / WP > > Ok, think I found the problem...I needed to add my common rules to both c-mode and cc-mode, like this: (defun williams-common-hook () (c-toggle-hungry-state 1) (setq c-basic-offset 3)) (add-hook 'c-mode-common-hook 'williams-common-hook) (add-hook 'cc-mode-common-hook 'william-common-hook) before I was just adding it the c-mode (and I was now testing with a c++ source file) / WP