help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding a hook to sql-mode?


From: Chetan
Subject: Re: Adding a hook to sql-mode?
Date: Mon, 08 Dec 2008 18:14:47 -0800
User-agent: Emacs Gnus

"Webb S." <webb.sprague@gmail.com> 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, <tab> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]