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: Hungry delete for C, C++ and Java? Date: Wed, 21 Apr 2004 00:27:06 +0200 Organization: Island, Linkoping University, Sweden Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <68n36c.q5.ln@acm.acm> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1082500485 25006 80.91.224.253 (20 Apr 2004 22:34:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 20 Apr 2004 22:34:45 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 21 00:34:34 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 1BG3p3-0004rg-00 for ; Wed, 21 Apr 2004 00:34:33 +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 1BG3m6-0001ML-I9 for geh-help-gnu-emacs@m.gmane.org; Tue, 20 Apr 2004 18:31:30 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!newsmi-eu.news.garr.it!NewsITBone-GARR!feed.news.tiscali.de!uio.no!newsfeed1.funet.fi!newsfeeds.funet.fi!newsfeed.sunet.se!news01.sunet.se!news.island.liu.se!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 255 Original-NNTP-Posting-Host: astmatix.ida.liu.se Original-X-Trace: news.island.liu.se 1082500025 26528 130.236.186.15 (20 Apr 2004 22:27:05 GMT) Original-X-Complaints-To: abuse@island.liu.se Original-NNTP-Posting-Date: Tue, 20 Apr 2004 22:27:05 +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:122519 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:17806 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:17806 "Alan Mackenzie" wrote in message news:68n36c.q5.ln@acm.acm... > William Payne wrote on Tue, 20 Apr > 2004 17:35:30 +0200: > > Hello, I am using a CVS version of Emacs (checked out three weeks ago), > > Just to be pedantic, if you checked it out from savannah.gnu.org, it will > be (from the point of view of the CC Mode team) a released version with > version number 5.30 or 5.30.n. If you got it by anonymous CVS from > cc-mode.sourceforge.net, then it will indeed be a "CVS version", and will > be the emerging version 5.31. > > > and I was wondering how I turn on hungry delete per default for C, C++ > > and Java? > > In an appropriate hook function (probably on c-mode-common-hook) include: > > (c-toggle-hungry-state 1) > > [, and as a matter of interest, C-c C-d will execute > `c-toggle-hungry-state' interactively]. and C-d (but not > ) then do hungry deletion. It looks as thought the fine manual > could do with some clarification on this point. > > > / WP > > -- > Alan Mackenzie (Munich, Germany) > Email: aacm@muuc.dee; to decode, wherever there is a repeated letter > (like "aa"), remove half of them (leaving, say, "a"). > Thanks for the reply, Alan. My .emacs file is as follows, where should I put (c-toggle-hungry-state 1)? Under (defun my-c++-mode () (interactive) and (defun my-java-mode () (interactive) ? My .emacs file was created years and years ago by someone else, I wish I understood it better...I am guessing it could be cleaned-up/improved alot. Fyi, I am using CC-Mode 5.30.8. / WP (add-to-list 'load-path "c:/emacs-21.3/cc-mode-5.30.8") (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 '("\\.c$" . my-c++-mode) '("\\.q$" . my-c++-mode) ; equel '("\\.h$" . my-c++-mode) '("\\.cs$" . my-c++-mode) ; C-mode for C* programs '("\\.hs$" . my-c++-mode) ; C-mode for C* headers '("\\.hpp$" . my-c++-mode) '("\\.cpp$" . my-c++-mode) '("\\.lpc$" . my-c++-mode) '("\\.pike$" . my-c++-mode) '("\\.a$" . ada-mode) '("\\.cc$" . my-c++-mode) '("\\.y$" . my-c++-mode) '("\\.el$" . emacs-lisp-mode) '("\\.java$" . my-java-mode) ; So any file beginning with Makefile is opened in Makefile-mode '("\\Makefile" . makefile-mode) ; Maybe use \\Makefile$ ? ) auto-mode-alist ) ) ;; C++-mode. Full (?) control on indentation. (defun my-c++-mode () (interactive) (c++-mode) (setq c-basic-offset 3) ; Indent three columns. (c-toggle-hungry-state 1) (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) (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) (objc-method-intro . -1000) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-call-cont . c-lineup-ObjC-method-call) ))) (defun my-java-mode () (interactive) (java-mode) (require 'jdok) (c-toggle-hungry-state 1) (setq c-basic-offset 3) ; Indent three columns. (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) (func-decl-cont . +) ; 'throws' declarations. (catch-clause . 0) (ansi-funcdecl-cont . +) (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) (brace-entry-open . 0) (statement . 0) (statement-cont . +) ; Strings over multiple lines looks good. (statement-block-intro . +) (statement-case-intro . +) (statement-case-open . 0) (substatement . 0) (substatement-open . 0) (case-label . +) (access-label . -) (label . 2) (do-while-closure . 0) (else-clause . 0) (namespace-open . 0) (namespace-close . 0) (innamespace . 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 . +) (template-args-cont . 0) (cpp-macro . -1000) (cpp-macro-cont . 0) (friend . 0) (extern-lang-open . 0) (extern-lang-close . 0) (inextern-lang . 0) (inlambda . 0) (lambda-intro-cont . 0) (inexpr-statement . 0) (inexpr-class . 0) (objc-method-intro . -1000) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-call-cont . c-lineup-ObjC-method-call) ))) ;; 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 (:italic t :foreground "Green")))) '(font-lock-reference-face ((((class color) (background light)) (:foreground "LightGreen")))) '(font-lock-string-face ((t (:italic 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")))))