From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Galen Boyer Newsgroups: gmane.emacs.help Subject: Re: Is is a major or minor mode? Date: 31 Oct 2002 21:26:35 -0600 Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1036123691 15440 80.91.224.249 (1 Nov 2002 04:08:11 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 1 Nov 2002 04:08:11 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 187T6Q-00040j-00 for ; Fri, 01 Nov 2002 05:08:10 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 187Squ-0000iQ-00; Thu, 31 Oct 2002 22:52:08 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!novia!newscene.com!newscene!novia!novia!sequencer.newscene.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 102 Original-Sender: galenboyer@hotpop.com User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Original-Xref: shelby.stanford.edu gnu.emacs.help:106640 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:3190 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:3190 On 31 Oct 2002, p.lord@russet.org.uk 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? 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.