disable sql-mode autocompletion in emacs - emacs

I'm trying to write my pl/sql code in following way: id_sel then hit TAB or Enter and I've got id_select completion! It works with any ...sel word. I think it is an sql-mode feature. How to disable this?

It's all about abbrev-mode.
abbrev-mode by default uses .abbrev_defs file, that utilizes sql-mode-abbrev-table variable from sql-mode.sql.

Related

emacs makefile-mode for Makefile.include

I use file named Makefile.include as a GNU makefile. I am trying to get emacs use the makefile-mode to use for this file. Alt-X makefile-mode works. Is there a way to tell emacs to use this major mode for this file right after opening automatically?
I tried putting
# _*_ mode: makefile; _*_
in the file but that does not appear to have the right effect. Btw I could not find the list of allowed strings one can use after mode:, so I tried BDSmakefile and some other variations as well.
Thanks.
See this question: Setting auto-mode-alist in emacs, and use the pair ("Makefile\\.include\\'" . makefile-mode).

how to enable shift-arrow for org-timestamp-up and org-timestamp-down in Emacs org-mode?

In Emacs org-mode, how do I instruct org to enable shift→ and shift← for org-timestamp-up and org-timestamp-down?
I have the value of org-support-shift-select set to Everywhere except timestamps and I thought that would do it, but when I shift→, it just highlights my timestamp instead of upping it.
(I'm using Aquamacs on OSX.)
You could add local key bindings, maybe?
Or use shift-up or shift-down?

How to uncomment code block in emacs python-mode?

I just started using python-mode in emacs and I noticed that while the major mode has an option for commenting out a region ((py-comment-region) which is bound (C-c #))there is no option to uncomment the code block which is already commented. I checked all the active keybinds in python-mode and could not find any relevant key. Am I missing something?
I did think of a couple of work arounds like using (delete-rectangular) (bound to C-x r d) to delete the comments.
Another method would be to bind the (comment-or-uncomment-region) to some key and start using that.
But is there any option provided in python-mode itself by default?
Not sure about your setup but I use M-; and it works for me.
How to uncomment code block in emacs python-mode?
Select code, e.g. with Ctrl-Space to mark and cursor over desired code.
Then, meta-semicolon: Meta-;
That's escape then ;s or hold down Alt-;
The same method will also comment code.
Most comment region functions will uncomment a region with C-u comment-region-function
I'm using comment-dwim which is really smart and can be used for both commenting and un-commenting active regions. It works for the python mode as well.
You can find more information in emacs comment commands.

Emacs: Enter commands like in gedit

in gedit it's possible to define so-called "snippets" for simpler input.
For example, there is a snippet while. This means: If you type while -> (-> stands for tab key). And gedit automatically converts it to the following (including correct indentation):
while (condition){
}
In vim (in conjunction with latex-suite) I saw the following: If you type (, vim inserts just a (. If you type ( a second time, vim automatically converts it to \left( \right).
I found abbrev-mode but this mode doesn't place the cursor properly (i.e. between parentheses or inside the while loop).
I managed to create custom emacs keybindings/macros that do just the same (without having to press the tab key), so I know it's possible.
However, is there already and package where you can define such "snippets" without much effort? Or are there even any serious reasons not to use such things?
See yasnippet. It provides snippets for most major languages, and it is easy to add new ones or modify the old ones.
Yes, yasnippet is probably the way to go. But make sure you learn the major mode you're using for your editing - when writing in LaTeX, learn auctex. Major modes can contain functionality that makes some snippets pointless, and do the same thing even better. So instead of using a begin/end-snippet in a LaTeX buffer, try C-c C-e in auctex. Etc :)
Don't forget abbrev-mode.

Is there any way to enable code completion for Perl in vim?

Surprisingly as you get good at vim, you can code even faster than standard IDEs such as Eclipse. But one thing I really miss is code completion, especially for long variable names and functions.
Is there any way to enable code completion for Perl in vim?
Ctrl-P (Get Previous Match) and Ctrl-N (Get Next Match) are kind of pseudo code completion. They basically search the file (Backwards for Ctrl-P, Forwards for Ctrl-N) you are editing (and any open buffers, and if you are using TAGS anything in your TAG file) for words that start with what you are typing and add a drop down list. It works surprisingly well for variables and function names, even if it isn't intellisense. Generally I use Ctrl-P as the variable or function I am looking for is usually behind in the code. Also if you keep the same copy of Vim open, it will search the files you have previously opened.
Vim 7 supports omni completion.
For example, I have this in my vimrc
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
and then, when I press Ctrl-X Ctrl-O in Insert mode, I get a dropdown list of autocomplete possibilities.
Here's an omnicfunc for perl. No idea how well it works though.
Well, Vim's generic completion mechanism is surprisingly good, just using Ctrl-N in insert mode. Also, line completion is very handy, using C-x C-l.
Also check out this vim script for perl.
The standard Ctrl+N and Ctrl+P works even better if you add the following to your ~/.vim/ftplugin/perl.vim file:
set iskeyword+=:
Then it will autocomplete module names, etc.
The .vimrc clip in one of the other answers is slightly wrong. To turn your tab key into an auto-complete key, use this code:
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
You can find this, and tons of other vim tricks in this thread at Perlmonks--which links to even more threads with lots more customizations.
You should look at the SuperTab plugin:
http://www.vim.org/scripts/script.php?script_id=1643
It let's you do completion (either the OmniCompletion or the regular completion) using tab and shift-tab instead of ^N and ^P.
https://github.com/c9s/perlomni.vim
Ctrl+N
This is explained in the Perl Hacks book, along with how to do Package completion. Highly recommended.