customize emacs sql-mode to execute sql-blocks - emacs

REPL in EMACS is really a great feature I love so much.
but under sql-mode, I encountered quite a few issues.
like:
I would like to use db3( a wrapper of db2 which can recoginze alias ), can I start a db3 shell buffer and make the sql-mode recognize it as the default evaluation buffer?
this is actually more important, when I send a region to the eval buffer, the eval buffer will execute the region by line break, which make my sql-code barely executable. so How would I customize the sql-mode, so that it can execute by block instead of line-break ?
==========I have find solution myself==================
for question 1: customize the sql-db2 is definitely more difficult , which I am still digging out, that envolves more work like writing plugins for emacs
==> the temporary solution is I can still connect to db2 use alias
for question 2: it turns out that db2 do have an option -t to set the termination character , which perfectly solves my question.

==========I have find solution myself==================
for question 1: customize the sql-db2 is definitely more difficult , which I am still digging out, that envolves more work like writing plugins for emacs ==> the temporary solution is I can still connect to db2 use alias
for question 2: it turns out that db2 do have an option -t to set the termination character , which perfectly solves my question.

Related

Execute Commands in the Linux Commandline [Lazarus / Free Pascal]

I have a problem. I want to execute some commands in the Commandline of linux. I tested TProcess (So i am using Lazarus) but now when i am starting the programm, there is nothing, wich the Program do.
Here is my Code:
uses [...], unix, process;
[...]
var LE_Path: TLabeledEdit;
[...]
Pro1:=TProcess.Create(nil);
Pro1.CommandLine:=(('sudo open'+LE_Path.Text));
Pro1.Options := Pro1.Options; //Here i used Options before
Pro1.Execute;
With this Program, i want to open Files with sudo (The Programm is running on the User Interface)
->Sorry for my Bad English; Sorry for fails in the Question: I am using StackOverflow the first time.
I guess the solution was a missing space char?
Change
Pro1.CommandLine:=(('sudo open'+LE_Path.Text));
to
Pro1.CommandLine:=(('sudo open '+LE_Path.Text));
# ----------------------------^--- added this space char.
But if you're a beginner programmer, my other comments are still worth considering:
trying to use sudo in your first bit of code may be adding a whole extra set of problems. SO... Get something easier to work first, maybe
/bin/ls -l /path/to/some/dir/that/has/only/a/few/files.
find out how to print a statement that will be executed. This is the most basic form of debugging and any language should support that.
Your english communicated your problem well enough, and by including sample code and reasonable (not perfect) problem description "we" were able to help you. In general, a good question contains the fewest number of steps to re-create the problem. OR, if you're trying to manipulate data,
a. small sample input,
b. sample output from that same input
c. your "best" code you have tried
d. your current output
e. your thoughts about why it is not working
AND comments to indicate generally other things you have tried.

Emacs calc minibuffer blank face---how to debug?

When running emacs calc, typing a prefix key, say 'm', followed by '?' is supposed to show all mode-related commands in the minibuffer as a kind of quick help facility.
For several years I have noticed that this quit working for me. When I hit the '?' the minibuffer flashes the help for a small fraction of a second, then goes blank. I can sometimes see parts of the help text rendered but ususally it blanks too fast to see it.
This does not happen when I run emacs -Q to skip my init file, so it is something in the init file that is the cuplprit.
My init file is quite large. I would like to put something like '(exit)' in different places in my init file to stop processing the init file and see if I can pin down what is causing the problem.
(1) What is the right way to do this?
(2) Anybody else see this problem with the minibuffer in calc?
Good question. The answer is simple: recursively bisect your init file.
Do that by commenting out 1/2 of it, then 3/4, then 7/8,... This is a binary search, and it is very quick, even though it might not seem that way at first. It is systematic, and essentially blind (thoughtless).
To comment out a block of text, use command comment-region. To uncomment a block of text, use C-u with the same command.
Trust me - in no time at all, you will have identified the culprit code, no matter how big your init file is. And if you load other libraries from your init file, and doing the exercise above shows that the culprit code is in one of those libraries, then do the same thing with (a copy of) that library code: recursively bisect it.
After several hours of trying to narrow down the problem, I found the culprit.
When key-chord-mode is set on in calc, the key help facility displays the symptoms I mentioned above.
Would like to keep key-chord enabled globally and disable it in calc-mode, but turning it off in the calc-mode-hook turns it off for all modes. Any ideas?
Anyway, I am closer to figuring out this long-term irritant.

What am I looking for to debug this elisp?

I have an org-mode file that I'm trying to export to a Beamer LaTeX PDF through XeTeX. It was working fine last night on this machine, and just as well on another machine on which I edited it afterward. Both are running org-mode 8, Emacs 24, same export process (3 runs of XeLaTeX)
When I synced back to this machine and tried to export again, I got the error Wrong block type at a headline named "". I checked all my headlines and gave them all names, but still got the same result.
Thanks to the wonders of indexed searchable FLOSS code, I immediately found the snippet online:
(env-format
(cond ((member environment '("column" "columns")) nil)
((assoc environment
(append org-beamer-environments-extra
org-beamer-environments-default)))
(t (user-error "Wrong block type at a headline named \"%s\""
raw-title))))
I'm not really solid on elisp at all, though, and I don't know most of what's going on here. From this snippet, what would I do to start debugging? (I realize I can start the emacs debugger, but it's not a PKE meter, I can't just wave it around.)
IMHE the best way to figure out what's wrong when you've found the relevant snippet of code is to use Edebug.
You should read the documentation to learn more about it, but basically here is my procedure:
identify the part of the code that crashes
instrument the code with Edebug (C-uC-M-x)
re-execute the code and go step by step to figure out what's going on (n)
If the problem is in another function, jump to it GOTO 2.
Iterate until you've understood the code and find a way to fix it.
Posting this answer just so that the specific solution to the particular problem the error was flagging is understood.
Apparently the version of Beamer I have on the other machine has a "normal" Beamer environment that specifies an otherwise blank, unformatted block. This is not present in this machine's install, or at least org/XeLaTeX don't know about it.
My steps were:
Search for all unnamed headings
Name each of them uniquely
Reproduce the error with the identifying string
Check the block type property against the available type list given in org-beamer-mode
Remove the offending type and replace it with another one
This is great and all, but I don't think it's the "best answer" because it involves no actual understanding of what the emacs interpreter was trying to tell me. If I didn't have a good idea of what was going on generally with the TeX, there's no way it would have worked. Dunno if this technique would impress anybody at an interview ;)

Failed to start SQL Shell (psql) of PostgreSQL 9.3

I'm new to this program and I found a problem when try to log in to start my programming. I get an error as shown in the figure below and stuck here for quite some time and I wonder it was came out with such strange characters. Hopefully could receive some recommendations and solutions over here.
You most likely have an encoding problem.
As you said in chat, your database encoding is UTF-8, while your shell encoding is CP-1252 ("Latin-1").
You need to switch your Terminal to UTF-8 (if thats possible on windows).
But most likely you want to use pgAdmin for your work. As long as you don't have a very specific reason to use the shell, its by far more convenient to use pgAdmin.

Debugging using emacs

GNU Emacs 23.2.1
GCC 4.4.4
I am using gdb-many-windows to debug.
I am just wondering is there anything better?
At the moment I am debugging a linked-list. The list is not that big. However, it would be nice to see all the elements' values. Instead of having to 'print sorted_queue->next->seconds' all the time.
The watch command works ok, if a value changes. However, sometimes its nice to see all the values you want to watch in a separate buffer for easy review.
Everytime I what to see what a value is I have to issue the command print (p) and the name of the variable. Just a lot of typing. One thing Visual Studio is good for is debugging. It would be nice to see Emacs with some of those features.
Many thanks for any advice,
You might like the Data Display Debugger, a.k.a. DDD:
As far as dumping of the data structures is concerned, GDB Python extensions might interest you. Then you could make 'print list' output '5 10 2 4 50' or whatever presentation you like.
You can read introduction to GDB Python scripting here.