Attachment 'ij.el'

Download

   1 ;; (C) Copyright 2009, Bernt Marius Johnsen
   2 ;; License: 100% Public Domain
   3 ;; Warranty: None, whatsoever
   4 
   5 
   6 (require 'sql)
   7 
   8 ;; Customization for Derby
   9 
  10 (defcustom sql-java-vm "java"
  11   "Java VM")
  12 
  13 (defcustom sql-ij-classpath "/usr/lib/derbytools.jar:/usr/derby.jar:/usr/lib/derbyclient.jar"
  14   "Ij classpath")
  15 
  16 (defcustom sql-ij-class "org.apache.derby.tools.ij"
  17   "Ij class")
  18 
  19 (defcustom sql-ij-driver "org.apache.derby.jdbc.EmbeddedDriver"
  20   "JDBC driver");
  21 
  22 (defcustom sql-derby-home "/var/tmp/ij"
  23   "Home for Embedded derby databases");
  24 
  25 (defvar sql-mode-derby-font-lock-keywords nil
  26   "Derby SQL keywords used by font-lock.
  27 
  28 This variable is used by `sql-mode' and `sql-interactive-mode'.  The
  29 regular expressions are created during compilation by calling the
  30 function `regexp-opt'.  Therefore, take a look at the source before
  31 you define your own sql-mode-derby-font-lock-keywords.  You may want
  32 to add functions and PL/SQL keywords.")
  33 (if sql-mode-derby-font-lock-keywords
  34     ()
  35   (let ((derby-keywords (eval-when-compile
  36                           (concat "\\b"
  37                                   (regexp-opt '(
  38                                                 ;; Fill in
  39                                                 "index") t) "\\b")))
  40 	(derby-reserved-words (eval-when-compile
  41                                 (concat "\\b"
  42                                         (regexp-opt '(
  43                                                       ;; Fill in
  44                                                       "show") t) "\\b")))
  45 	(derby-types (eval-when-compile
  46                        (concat "\\b"
  47                                (regexp-opt '(
  48                                              ;; Derby Keywords that look like types
  49                                              ;; Derby Reserved Words that look like types
  50                                              "binary" "timestamp") t) "\\b")))
  51 	(derby-builtin-functions (eval-when-compile
  52                                    (concat "\\b"
  53                                            (regexp-opt '(
  54                                                          ;; Misc Derby builtin functions
  55                                                          "unuseddummystring4") t) "\\b"))))
  56     (setq sql-mode-derby-font-lock-keywords
  57 	  (append sql-mode-ansi-font-lock-keywords
  58 		  (list (cons derby-keywords 'font-lock-function-name-face)
  59 			(cons derby-reserved-words 'font-lock-keyword-face)
  60 			;; XEmacs doesn't have font-lock-builtin-face
  61 			(if (string-match "XEmacs\\|Lucid" emacs-version)
  62 			    (cons derby-builtin-functions 'font-lock-preprocessor-face)
  63 			  ;; GNU Emacs 19 doesn't have it either
  64 			  (if (string-match "GNU Emacs 19" emacs-version)
  65 			      (cons derby-builtin-functions 'font-lock-function-name-face)
  66 			    ;; Emacs
  67 			    (cons derby-builtin-functions 'font-lock-builtin-face)))
  68 			(cons derby-types 'font-lock-type-face))))))
  69 
  70 (defun ij ()
  71   "Run Derby ij as an inferior process in buffer *Derby Ij*
  72 
  73 Interpreter used comes from variable `sql-ij-class'.
  74 Java VM comes from variable `sql-java-vm'.
  75 Default JDBC driver comes from `sql-ij-driver'.
  76 Interpreter used comes from variable `sql-ij-class'.
  77 Classpath used comes from variale `sql-ij-classpath'. 
  78 (The default value supports both derby drivers)
  79 
  80 To load another driver, use the 'driver' command.
  81 To connect to a database, use the 'connect' command.
  82 E.g.
  83 
  84 driver 'foo.bar.db.Driver'\;
  85 connect 'jdbc:foobar:mydb'\;
  86 
  87 For embedded Derby, `sql-derby-home' defines where the database
  88 found.
  89 
  90 The buffer is put in sql-interactive-mode, giving commands for sending
  91 input.  See `sql-interactive-mode'.
  92 
  93 To specify a coding system for converting non-ASCII characters in the
  94 input and output to the process, use
  95 \\[universal-coding-system-argument] before \\[sql-derby].  You can
  96 also specify this with \\[set-buffer-process-coding-system] in the SQL
  97 buffer, after you start the process.  The default comes from
  98 `process-coding-system-alist' and `default-process-coding-system'.
  99 
 100 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)"
 101   (interactive)
 102   (let ((ij-login nil)
 103         (ij-db-buffer "Derby ij")
 104         (ij-driver (concat  "-Dij.driver=" sql-ij-driver))
 105         (ij-home (concat  "-Dderby.system.home=" sql-derby-home))
 106         (ij-classpath sql-ij-classpath)
 107         (ij-class sql-ij-class)
 108         (ij-db-comint-buffer nil)) 
 109     (set-buffer 
 110      (make-comint ij-db-buffer sql-java-vm nil 
 111                   ij-driver 
 112                   ij-home 
 113                   "-classpath" ij-classpath ij-class))
 114     (setq sql-prompt-regexp "^ij> ")
 115     (setq sql-prompt-length 4)
 116     (setq sql-buffer (current-buffer))
 117     ;; set sql-mode-font-lock-keywords to something different before
 118     ;; calling sql-interactive-mode.
 119     (setq sql-mode-font-lock-keywords sql-mode-derby-font-lock-keywords)
 120     (sql-interactive-mode)
 121     (message "Login...done")
 122     (pop-to-buffer sql-buffer)))
 123 
 124 (provide 'ij)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.