| |
 |
Thursday, January 15, 2004 |
Igor Rayak reported a couple of bugs in tsql-indent.el. His email talks about 2 indent problems:
should be :
(SELECT T.pno as pno , T.cost+C.assemblyCost as cost FROM CompositeParts C, (SELECT TM.pno1 as pno , ? as cost FROM TempMadeFrom TM, BaseParts B WHERE TM.pno2=B.pno GROUP BY TM.pno1) T WHERE C.pno=T.pno) UNION (SELECT * FROM BaseParts);
tsql-indent will give you
( SELECT T.pno as pno , T.cost+C.assemblyCost as cost FROM CompositeParts C, ( SELECT TM.pno1 as pno , ? as cost <== FROM TempMadeFrom TM, BaseParts B WHERE TM.pno2=B.pno GROUP BY TM.pno1) T WHERE C.pno=T.pno) <<=== UNION <<=== (SELECT * FROM BaseParts);
or quite better
( SELECT T.pno as pno , T.cost+C.assemblyCost as cost FROM CompositeParts C,( SELECT TM.pno1 as pno , ? as cost FROM TempMadeFrom TM, BaseParts B WHERE TM.pno2=B.pno GROUP BY TM.pno1) T WHERE C.pno=T.pno <<== indent problem )
UNION <<== indent problem (SELECT * FROM BaseParts);
I think we have here 2 indent problem , because WHERE is belong to first select and not to second. and union belongs to first and third select. not to second one.
Unfortunately, I'm not able to dig in and fix these immediately. I'm putting them on the to do list for the code.
9:34:29 AM
|
|
 |
Friday, January 09, 2004 |
Within the last six months, I've started using DBVisualizer
(http://www.minq.se/products/dbvis/) for accessing databases while I'm
coding. It's a great front end for any relational database that
has a JDBC driver. I highly recommend it.
One of the many cool features is that result sets in the product are
displayed in a grid (JTable). You can select values in the grid
and copy them to the clipboard to paste in other applications. I
frequently paste the data into Emacs for use in Java unit tests.
The problem is that the columns of text are not in an array
format. So, I wrote the following Emacs functions to "fix the
data up". After you paste the data into Emacs you can immediately
run one of the interactive fix-up functions. (One of the
thousands of beautiful things about Emacs is that it automatically sets
the region around the pasted text.) This will remove the column
header and produce a comma delimited list of terms suitable for use in
an array.
(defun fixup-dbviz-array (start end replace-string)
"Formats the region for use as an array and replaces the regexp match
with the specified replacement string."
(unwind-protect
(progn
(narrow-to-region start end)
(goto-char (point-min))
(kill-line 't)
(while (re-search-forward "\\(.*?\\)\n" nil t)
(replace-match
replace-string))
(if (re-search-backward "," nil t)
(delete-char 1)))
(widen)))
(defun fixup-dbviz-string-array (start end)
"Formats a column of values that are copy and pasted from DB
Visualizer and formats them for use as a String array"
(interactive "r")
(fixup-dbviz-array start end "\"\1", "))
(defun fixup-dbviz-int-array (start end)
"Formats a column of values that are copy and pasted from DB
Visualizer and formats them for use as a int array"
(interactive "r")
(fixup-dbviz-array start end "\\1, "))
12:38:09 PM
|
|
 |
Thursday, October 30, 2003 |
Have you ever used Emacs Archive mode to open a zip file, edit a file in the zip, and save it back to the zip file automagically? NO?!? You definitely don't know what you're missing.
Today, I wanted to edit 1 file in a WAR file to try out a tweak to the webapp I'm working on. I could have busted the WAR file open, modified the file, and then zipped it (jar) back up. But that all seems so cumbersome.
Instead what I did was use Emacs to open the WAR, find my file, edit its guts, and save it back to the archive. Voila! Ready for deployment.
By default, Emacs will edit zip files (and maybe even jar files), but you don't get support for WAR and EAR out of the box. But wait! Emacs is the world's most extensible editor. Follow the instructions here and add that lisp code to your .emacs file. You'll be in business.
On a related note, check out this Artima thread. Oliver Burn gives the reasons why he uses Emacs over jEdit. Also some good links to helpful extensions.
Finally, if you are using Emacs on a Windows platform and you are using Cygwin, then you may be using "unzip" as a PKZip alternative. If you are, I've found it helpful to make sure that the zip extract command in Archive Zip group has an argument of "-j". This tells Infozip to not extract the file into directories because Archive mode expects the file to be in its temp directory - not a subdirectory of its temp directory.
1:18:52 PM
|
|
 |
Friday, October 10, 2003 |
I just found Bradley O'Hearne's 10 Reasons to Dump Your Java IDE. Not being a big IDE proponent, I felt justified in reading this article. Even if some of the arguments aren't very strong. Check out the counter-point: 10 Reasons (Not) to Dump Your Java IDE.
My latest frustration with IDEs is they almost always contain substandard editors. What they lack in text manipulation, they partly make up for with code completion and source code browsing. However, I spend most of my time manipulating text. Don't you? I would rather have Emacs hippie expansion to complete previously typed tokens than code completion. Much faster, and can be used more often.
On my last two Java projects, I've had Emacs and Eclipse open side-by-side. I like Eclipse for compiling and fixing errors, the debugger, and for running Junit tests. I like Emacs with JDEE and ECB for editing.
10:55:36 PM
|
|
 |
Saturday, September 06, 2003 |
Well, I've switched back to using Emacs Gnus to read my personal
email at home. The reason I switched away before was that W3 was
pretty bad at rendering HTML mail. Over the past few weeks, I've
looked at the mail I'm getting at home, and by and large I get alot of
plain text email. Even the email I get that is HTML, the bulk of it
is plain text embedded in light formatting. Further, I subscribe to
some mailing lists, and reading those things are much better in Gnus
where they are appropriately threaded.
So far, the only HTML email I miss out on is Netflix. W3 renders
it readable, but I can't just click and rate the movie I just watched
any more. Oh well.
What I'd like to find is a way (and I'm sure there is probably
something out there) to view HTML email in a browser. To launch it in
Mozilla. Probably just require some digging.
8:28:28 AM
|
|
 |
Thursday, July 31, 2003 |
Do you have a printer you connect to with a local TCP/IP port instead of as a share off of a server? Wondering how the hell to get Emacs to print to it? I found
this article today that tells you how.
Basically, you create a share to the printer on your machine. You set the printer-name in Emacs to something like //YOURMACHINE/PRINTERSHARE (do I have to tell you to substitute?). Works like a charm.
3:25:01 PM
|
|
 |
Monday, July 28, 2003 |
Today I created a simple Elisp function that will convert the text in a specified region from camel case (e.g. myFunction) to underscore separated format (e.g. my_Function). Glasses mode will do a similar thing in a non-destructive way using overlays. However, this function actually modifies the text.
I used this function to convert between a JDO JOQL filter string and a SQL where clause. The JDO reverse mapping tool we used took SQL table names like "mth_dim" and converted them to Java class names like "mthDim". I had to convert back.
(defun convert-camel-to-underscore (beg end)
"Converts the camel cased text in the specified region into
underscore separated text."
(interactive "r")
(save-excursion
(goto-char end)
(let ((case-fold-search nil)
(end-marker (point-marker)))
(goto-char beg)
(while (re-search-forward "\([a-z]\)\([A-Z]\)"
end-marker t)
(replace-match (concat (match-string 1) "_" (match-string 2)))))))
6:37:19 PM
|
|
Today I stumbled across some Elisp code that will take a list and return a list containing the unique elements from the original. Very handy if you don't want to implement your own. You can find it here
6:26:22 PM
|
|
© Copyright 2004 Tom Pierce.
|
|