[Top][All Lists]

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

Re: Is is a major or minor mode?

From: Galen Boyer
Subject: Re: Is is a major or minor mode?
Date: 31 Oct 2002 21:26:35 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

On 31 Oct 2002, wrote:
>>>>>> "Galen" == Galen Boyer <> writes:
>   Galen> I want this to be available in both SQLi and sql-mode buffers
>   Galen> and piggyback on its comint integration.  I was planning to
>   Galen> write a wrapper around the login functionality of sql.el
>   Galen> which would then define the specific variables that the
>   Galen> sql-mode and sqli buffers needed to know about to get at the
>   Galen> *bsh* variables.  I'm just not sure if this is the right plan
>   Galen> to proceed with.  Should I make my own major-mode and steal
>   Galen> liberally from sql.el?
> I think that the answer to this is partly sociological. Is sql.el very
> large? 


> Is it being actively developed? 

I don't think so.  It is part of the base Emacs distribution.  Its
actually quite simple/elegant in its design.  It gives one all the nice
shell functionality for a sql command-line.  Being able to hop between
sql prompts, this alone, is worth learning the mode.  I can't tell you
how many times I've kicked off a sql query that has returned > 1000
rows.  Then, I hit C-[space] C-c C-p C-x n n M-x occur blah.

> If the answer is yes to either of these the code stealing option would
> be much less attractive.
> Incidentally the mode sounds excellent! I'd like a really nice SQL
> mode, with JDBC connectivity. 

Well, I didn't really want to provide a "SQL mode" nor do I really want
to rewrite the command-line interfaces provided by the database vendors
(although, the thought has crossed my mind, and I would bet with eshell,
something nifty about cd'n to a JDBC connection could be concocted and
then all sorts of Emacs magic could make the database experience that
much more enjoyable).  I wanted to provide a metadata layer that allowed
dynamic creation of SQL that was then displayed in a sql-mode or sqli
buffer.  In the sqli buffer, hit enter and it is executed.  In the
sql-mode, it helps you get at your finished code faster.

I do want it to try to be context sensitive.  So, if its in the middle
of a piece of SQL and I ask for a metadata listing, it would gleam
whether point is within the "select" section versus the "from" section
versus the "where" section and then be intelligent about what to bring
back.  But, the most important thing is for the buffer to know what
metadata object it is associated with, how to get at the passwords for
connection creation (maybe through the .authinfo file) and how to
refresh the cache when needed.  

I do think that this kind of thing could then serve up the appropriate
outputs to the speedbar so we could get database "browsing" but I would
need to do something useful with that which would be another years worth
of work (Man, this Emacs thing never ends).  Also, pop-up frames for
choosing different entities would be nice.  Definitely canned queries
should be there, especially analytic type queries: The following query,

    select fld1,fld2,...,fldn, count(*)
    from table
    group by fld1,fld2,...,fldn;

was, really, the entire reason I decided to do this in the first place.
I want this query, as well as others, to be available and prompt with
appropriate object names, for all sql buffers.

If you are a sql user, the following template and abbreviation might be
useful for you:

     "select-count-group-by" ;; template name
     '((p "Table Selected From: " tsf 'NOINSERT)
       (p "Fields To Group On: " fgo 'NOINSERT)
       "SELECT "
       (s fgo)
       ",count(*) " n>
       "from "
       (s tsf) n>
       " group by "
       (s fgo)

    (define-abbrev sql-mode-abbrev-table  "scg" ""

With ejsql, this template will provide appropriate completing-reads from
the JDBC metadata layer.  Actually, my next task will be to make this
template work with the ejsql code.  The completing reads from ejsql have
been tested enough that I can say they work reasonably well, but I still
have lots more to discover with the DatabaseMetaData interface.

But, anyways.  My main focus will be to get the creation of the sql-mode
and sqli buffers to understand how to create their respective metadata
object and how to constantly refer to them.  Understanding how best to
make this happen and play nice with the already established sql.el was
why I posted.

Galen deForest Boyer
Sweet dreams and flying machines in pieces on the ground.

reply via email to

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