From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chetan Newsgroups: gmane.emacs.help Subject: Re: Adding a hook to sql-mode? Date: Mon, 08 Dec 2008 18:14:47 -0800 Organization: Noname Inc. Message-ID: <81zlj6hz6w.fsf@myhost.sbcglobal.net> References: <442a49e1-d94d-4771-9d2d-adff564c7afe@w24g2000prd.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1228790447 27642 80.91.229.12 (9 Dec 2008 02:40:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Dec 2008 02:40:47 +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 Dec 09 03:41:50 2008 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.50) id 1L9sXk-0002Yh-8U for geh-help-gnu-emacs@m.gmane.org; Tue, 09 Dec 2008 03:41:48 +0100 Original-Received: from localhost ([127.0.0.1]:54122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9sWZ-0007Dh-15 for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Dec 2008 21:40:35 -0500 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!flph200.ffdc.sbc.com!prodigy.net!flph199.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!flpi148.ffdc.sbc.com.POSTED!8e1d8614!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Emacs Gnus Cancel-Lock: sha1:0YdxekjDc/LliPK+OFoo38ztnP4= Original-Lines: 37 Original-NNTP-Posting-Host: 76.203.168.126 Original-X-Complaints-To: abuse@prodigy.net Original-X-Trace: flpi148.ffdc.sbc.com 1228788886 ST000 76.203.168.126 (Mon, 08 Dec 2008 21:14:46 EST) Original-NNTP-Posting-Date: Mon, 08 Dec 2008 21:14:46 EST X-UserInfo1: SCSYASFGTRU[RZLYMJNBNFXBWR\HPCTL@XT^OBPLAH[\RSAANVUEAE[YETZPIWWI[FCIZA^NBFXZ_D[BFNTCNVPDTNTKHWXKB@X^B_OCJLPZ@ET_O[G\XSG@E\G[ZKVLBL^CJINM@I_KVIOR\T_M_AW_M[_BWU_HFA_]@A_A^SGFAUDE_DFTMQPFWVW[QPJN Original-Xref: news.stanford.edu gnu.emacs.help:165158 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:60483 Archived-At: "Webb S." writes: > Sorry for the slightly tweaked repost, but I am hoping to fix this > before I forget about it... > > If I open schema.sql I get funky indentation, where emacs changes my > tabs to a mix of spaces etc. I can fix this by running the following > in the eval (alt-:) buffer once I have opened a sql file (say > "schema.sql"): > > (define-key sql-mode-map (kbd "TAB") 'self-insert-command) > (define-key sql-mode-map (kbd "RET") 'newline-and-indent) > (setq-default default-tab-width 4) > > How can I run this as a hook so it always works for sql mode? I tried > the following to no avail: > > (add-hook 'sql-mode-hook > (lambda() > (define-key sql-mode-map (kbd "TAB") 'self-insert-command))) > > By "to no avail" I mean that when I open foo.sql, does its > normal weird behavior of lining up with the end of the first word, > inserting spaces in order to do this (yuck!). Once I run the above > define-key commands from "eval" (alt-:), it behaves how I want, but I > can't get the hook to be installed (I think). > > Thx! Looks like what you are looking for is indent with hard tabs with tab width of 4. The following in the mode hook will do this. (setq indent-tabs-mode t tab-width 4) You don't need to redefine TAB key then.