From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nerius Landys Newsgroups: gmane.emacs.help Subject: Re: [emacs] tabs, spaces, and indentation Date: Mon, 11 Oct 2010 13:19:40 -0700 Message-ID: References: <20101009020801.GD4996@srevilak.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=20cf301afcf37e19b504925d149c X-Trace: dough.gmane.org 1286828463 19974 80.91.229.12 (11 Oct 2010 20:21:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 11 Oct 2010 20:21:03 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Steve Revilak Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 11 22:20:59 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P5Orh-0001xQ-0F for geh-help-gnu-emacs@m.gmane.org; Mon, 11 Oct 2010 22:20:57 +0200 Original-Received: from localhost ([127.0.0.1]:37701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5Org-0005GJ-B1 for geh-help-gnu-emacs@m.gmane.org; Mon, 11 Oct 2010 16:20:56 -0400 Original-Received: from [140.186.70.92] (port=44023 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5Oqd-000570-8P for help-gnu-emacs@gnu.org; Mon, 11 Oct 2010 16:20:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5OqT-0006F1-Fn for help-gnu-emacs@gnu.org; Mon, 11 Oct 2010 16:19:51 -0400 Original-Received: from mail-gx0-f169.google.com ([209.85.161.169]:48707) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5OqT-0006Ep-CK for help-gnu-emacs@gnu.org; Mon, 11 Oct 2010 16:19:41 -0400 Original-Received: by gxk24 with SMTP id 24so1817177gxk.0 for ; Mon, 11 Oct 2010 13:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=6nF4ZIKMXdxb4msd4MQLWC4idNr4ka5fsbDzy8lddSg=; b=C+lCgYko3REXLVntMmrvrmBdzUv0ZINm57mfER7TnwlZ4sPzmirJi34es6UyPBGHrr J6Yv6jhtHm+o/AMZhmKf8bVxxUb5/En2kSfBJ4R0UxeD5YZkIASZMSqq/L+8HPYTfhQr MWgDk0hig0M3VNlB9ASxWPxbL6W/4oWMdqCmI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=EEq9KF9ttqk4j6+7JgBJhXxejgnP/Vn8FY1zNZUFeNSlpbMvAvtHqsL3zmK0sG6PMv 7cTS1iDyN4bMOOuklNdY15efk1dlSWmJkMq90eAVUEHIljTItEL/LOmRfMPfc66GnAVj 3uv703wc8+tkwMcgW9BHgzj4bmjQalt9rxNQ8= Original-Received: by 10.42.250.66 with SMTP id mn2mr2141808icb.82.1286828380264; Mon, 11 Oct 2010 13:19:40 -0700 (PDT) Original-Received: by 10.42.166.72 with HTTP; Mon, 11 Oct 2010 13:19:40 -0700 (PDT) In-Reply-To: <20101009020801.GD4996@srevilak.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75105 Archived-At: --20cf301afcf37e19b504925d149c Content-Type: text/plain; charset=ISO-8859-1 > CC-mode gives you a lot of options for controlling indentation. > > M-x Info-goto-node RET (ccmode)Commands RET > > The subsections "Indentation commands", "Minor Modes" and "Electric > keys" will probably be the most relevant for what you're trying to > accomplish. > > For (1) something like > > (setq c-basic-offset 8 > indent-tabs-mode t > c-insert-tab-function 'tab-to-tab-stop) > > (setq c-syntactic-indentation nil) ; maybe, or maybe not this one > > should be close to the behavior you're looking for. > > For (2), try > > (c-toggle-electric-state -1) > > > Thanks a lot for this information. I have taken your tips and done additional online research. I came up with the following .emacs file for this project that has absolutely horrid indentation and use of tabs: (defun my-c-mode-common-hook () (c-toggle-electric-state -1) (define-key c-mode-base-map (kbd "TAB") 'self-insert-command)) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) It almost behaves how I want now. I hit Tab, it creates a tab. It does not start indenting stuff when I type a special character such as a paren or a semicolon. However, there is still one thing needed to make it behave just like Notepad. Let's say my cursor is positioned immediately following a tab character. When I hit Backspace (I believe that causes a function "backward-delete-char" to be called), it converts that tab character into a bunch of spaces, then deletes the last space. I would really like Backspace to just delete the tab character. Is there any way to do this? I suppose I'd have to rebind Backspace to a function other than backward-delete-char, but I'm not sure which function. --20cf301afcf37e19b504925d149c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
CC-mode gives you a lot of options for controlling indentatio= n.

=A0M-x Info-goto-node RET (ccmode)Commands RET

The subsections "Indentation commands", "Minor Modes" a= nd "Electric
keys" will probably be the most relevant for what you're trying to=
accomplish.

For (1) something like

=A0(setq c-basic-offset 8
=A0 =A0 =A0 indent-tabs-mode t
=A0 =A0 =A0 c-insert-tab-function 'tab-to-tab-stop)

=A0(setq c-syntactic-indentation nil) ; maybe, or maybe not this one

should be close to the behavior you're looking for.

For (2), try

=A0(c-toggle-electric-state -1)



Thanks a lot for this information.=A0 I ha= ve taken your tips and done additional online research.=A0 I came up with t= he following .emacs file for this project that has absolutely horrid indent= ation and use of tabs:

=A0 (defun my-c-mode-common-hook ()
=A0 =A0 (c-toggle-electric-state= -1)
=A0 =A0 (define-key c-mode-base-map (kbd "TAB") 'self= -insert-command))
=A0 (add-hook 'c-mode-common-hook 'my-c-mode-c= ommon-hook)


It almost behaves how I want now.=A0 I hit Tab, it creates a tab.= =A0 It does not start indenting stuff when I type a special character such = as a paren or a semicolon.=A0 However, there is still one thing needed to m= ake it behave just like Notepad.=A0 Let's say my cursor is positioned i= mmediately following a tab character.=A0 When I hit Backspace (I believe th= at causes a function "backward-delete-char" to be called), it con= verts that tab character into a bunch of spaces, then deletes the last spac= e.=A0 I would really like Backspace to just delete the tab character.=A0 Is= there any way to do this?=A0 I suppose I'd have to rebind Backspace to= a function other than backward-delete-char, but I'm not sure which fun= ction.
--20cf301afcf37e19b504925d149c--