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

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

Adding a hook to sql-mode?


From: Webb S.
Subject: Adding a hook to sql-mode?
Date: Mon, 8 Dec 2008 16:58:01 -0800 (PST)
User-agent: G2/1.0

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!


reply via email to

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