From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Steve Revilak Newsgroups: gmane.emacs.help Subject: Re: [emacs] tabs, spaces, and indentation Date: Mon, 11 Oct 2010 21:42:56 -0400 Message-ID: <20101012014256.GA3714@srevilak.net> References: <20101009020801.GD4996@srevilak.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tThc/1wpZn/ma/RB" X-Trace: dough.gmane.org 1286847817 24918 80.91.229.12 (12 Oct 2010 01:43:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 12 Oct 2010 01:43:37 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 12 03:43:36 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 1P5Ttt-0001GP-2W for geh-help-gnu-emacs@m.gmane.org; Tue, 12 Oct 2010 03:43:33 +0200 Original-Received: from localhost ([127.0.0.1]:45529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5Tts-00089c-55 for geh-help-gnu-emacs@m.gmane.org; Mon, 11 Oct 2010 21:43:32 -0400 Original-Received: from [140.186.70.92] (port=33238 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5TtS-00089V-VD for help-gnu-emacs@gnu.org; Mon, 11 Oct 2010 21:43:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5TtR-0008RC-MD for help-gnu-emacs@gnu.org; Mon, 11 Oct 2010 21:43:06 -0400 Original-Received: from mail1.sea5.speakeasy.net ([69.17.117.39]:35298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5TtR-0008Qw-Es for help-gnu-emacs@gnu.org; Mon, 11 Oct 2010 21:43:05 -0400 Original-Received: (qmail 8515 invoked from network); 12 Oct 2010 01:43:03 -0000 Original-Received: from pool-96-233-98-194.bstnma.fios.verizon.net (HELO srevilak.net) (srevilak@[96.233.98.194]) (envelope-sender ) by mail1.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 12 Oct 2010 01:43:03 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:75108 Archived-At: --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline >From: Nerius Landys >> 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) Nerius, That's great. I'm glad I was able to give you a starting point. >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. In C-mode, "C-h k DEL" tells me that DEL calls c-electric-backspace, which in turn calls the function bound to c-backspace-function. For me, c-backspace-function is bound to backward-delete-char-untabify, which will convert a tab into a series of spaces. Maybe (setq c-backspace-function 'backward-delete-char) is what you're looking for. Steve --tThc/1wpZn/ma/RB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) iEYEARECAAYFAkyzvSAACgkQX7YJI4BuyDQp0QCfUCtuu7E9OaKuR63DRi6uPyr7 ptEAn2sGofWl6NtCZ3aFSE4Wp5nftEIS =tJ5H -----END PGP SIGNATURE----- --tThc/1wpZn/ma/RB--