unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Galen Boyer <galenboyer@hotpop.com>
Subject: Re: Is is a major or minor mode?
Date: 31 Oct 2002 21:26:35 -0600	[thread overview]
Message-ID: <u1y65yf0b.fsf@hotpop.com> (raw)
In-Reply-To: vf65viyenu.fsf@rpc71.cs.man.ac.uk

On 31 Oct 2002, p.lord@russet.org.uk wrote:
> 
>>>>>> "Galen" == Galen Boyer <galenboyer@hotpop.com> 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? 

No.

> 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:

    (tempo-define-template
     "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" ""
                'tempo-template-select-count-group-by)

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.

  parent reply	other threads:[~2002-11-01  3:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-31  2:19 Is is a major or minor mode? Galen Boyer
2002-10-31 12:29 ` Phillip Lord
2002-10-31 17:22   ` Kevin Rodgers
2002-11-01  3:26   ` Galen Boyer [this message]
2002-11-03 23:36     ` Tim Cross
2002-11-04  4:17       ` Galen Boyer
2002-11-04 22:51         ` Tim Cross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=u1y65yf0b.fsf@hotpop.com \
    --to=galenboyer@hotpop.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).