Emacs autocomplete doesn't update C++ suggestions - emacs

I have autocomplete set up for Emacs, and for elisp, it works perfectly fine. I have it set up to use ctags for completion in C++ files and the suggestions appear as expected. However, it doesn't update suggestions as I type. For example, if I type:
vector<string> s;
s.
it suggests 'at'. However, if I add to it so that it looks like:
vector<string> s;
s.push
the suggestion doesn't update and still displays 'at' as the first suggestion, rather than 'push_back'.
I am an Emacs novice and have virtually no elisp knowledge, and was wondering how I can configure autocomplete so that it updates suggestions for C++ as I type.

Related

auto-complete option does not work - Emacs

To use auto-complete option, for writing C syntax, I have written below elisp code in .emacs file.
Here are the files in the directory.
But, amidst the typing of C syntax, I do not see the auto-complete option to select the syntax.
I am expecting the auto-complete option, as shown below, when I type while keyword. In my case, I do not see below behavior.
How do I resolve this?

How to get SLIME to autocomplete symbols from loaded other packages?

I think this used to work out of the box in Emacs 23, but in 24 it doesn't.
So, suppose I have Alexandria package loaded with Quicklisp. If I run (apropos "curry") in the REPL, for example, it finds the function definition, similarly, if I run (describe 'curry) etc. But SLIME refuses to autocomplete (cur| (point is shown by pipe) to anything.
How to tell SLIME where to look for sources / what is it missing?
EDIT:
Also, if I do ,in-packageRETALEXANDRIARET it will autocomplete, but I hoped it would autocomplete for any loaded package w/o me having to specify what package to look in. Or is there no other way?
There is no way that I know of to do this in SLIME. I'm not sure it would be practical to use but it should be feasible to implement this by looking at how completion and apropos are implemented and mix them up in a new function. Bonus points for a customize-var to toggle completion style.
https://github.com/slime/slime

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 a way for Emacs to autocorrect R commands

I'm a relatively new user to R and Emacs and was wondering if Emacs could automatically correct any R commands that i've typed wrong. I know about the alt-/, but I was more thinking along the lines of if i type read.tale, it corrects it to read.table.
Also, I was using emacs the other day and whenever i typed read.table, it showed the usage options (that bit from the help file) in the bottom bit of the window-the minibuffer?. anyway, its not there now, and i don't know what i did to make it go away.
Thanks for your help
Independently of emacs, you can examine your code with the checkUsage function in the codetools package. For example:
> foo <- function(data){
+ read.tale(data,file='temp.txt')
+ }
> checkUsage(foo)
<anonymous>: no visible global function definition for ´read.tale´
Also, you can emacs autocompletion functions (e.g. hippie-expand or dabbrev-expand) to fill in the rest of recently used function and variable names.
If you aint married to emacs, you should give Komodo edit with sciviews-R / sciviews-K a try.
So far it´s the best auto-completion coding I found for R. At least to me the configuration was much easier than emacs, particularly because of binding problems with my exotic (swiss) keyboard. sciviews-R / Komodo
EDIT: I realize this thread is still being read. So in meantinem I got to give it up for RStudio. It has really become THE editor for everyday use for most people. Nice autocompletion, available on all major OS and a really nice context help. Plus some easy export of pdf graphics and much much more. On top R Studio is easy to install – no need to worry how to fire up R from the editor.

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.