I'm using Emacs to write Java code (but I noticed this happens for other languages as well), and I'm having an issue with the completion. Say I want to import a library:
import java.|
Where | is the cursor. If I invoke the auto completion, it won't show anything.
import java.u|
In the case above, if I invoke auto completion, it works, showing every candidate starting with u.
Is it possible to change this behavior of needing to type the first letter to see the results? It would also be nice to do that for other languages as well.
I read the auto-complete documentation, also tried to study and change the code, but as I'm not familiar with lisp, didn't have any success.
Related
I have some custom completions in my ST3 user directory.
When I start typing, the autocomplete suggestions show up from my completions just fine. However, this gets in the way of completions which are in the buffer.
e.g.
Say I have the word 'prime-squares' in my current file buffer.
Now somewhere else in the file, I start to type 'pri..' and all I see are suggestions from my completions files. And not until I almost type the full word 'prime-square..' does the autocomplete suggestion for 'prime-squares' show up.
Which completely defeats the purpose of autocomplete.
Please note that autocomplete suggestions run out after say typing 'prime-..', and yet the suggestion 'prime-squares' doesn't show up until I've typed some more.
Is there a way to set weights for suggestions?
Or set them up in such a way, that the matching words in the current file always show up first, along with any other suggestions from completions files at the bottom?
As far as I'm aware there's way to weight the order in which the completions in the auto-complete popup are presented. This seems to be confirmed by the section on Completions in the Unofficial Docs, which say:
These are the sources for completions the user can control, in the order they are prioritized:
1. Snippets
2. API-injected completions via on_query_completions()
3. Completions files
Additionally, the following completions are folded into the final list:
4. Words in the buffer
That said, some quick testing seems to indicate that the presence of even a single completion with a trigger that matches words in the buffer stops those words from appearing in the completions list.
As seen here, without any completions both words that start with co and words that start with di will cause words from the buffer to appear in the completions list. Introducing a completion with a trigger that contains the text disjoin stops those matching buffer words from appearing, although the other words still do.
As far as I can see, it's doing that by design, as I haven't been able to determine any setting that may get around that. If that's the case you may need to make a feature request or check if someone has logged this as an issue already, as it may also be a bug.
Admittedly I don't use completions a lot, so there may be some way around this that I'm unaware of.
I'm using IntelliJ idea Community edition (with Scala) and I'm trying to evaluate an expression. I hit Alt-F8 to open it in debug mode and then switch to 'Code Fragment Mode'. However, I'm allowed to only evaluate variables that already exist in memory, and am not allowed to declare new. When I do so, I get- 'Evaluation of variables is not supported'. Is there a plugin that I can use in debug mode to evaluate arbitrary code?
EDIT: So that it's clear, no worksheets are not what I'm looking for. I want to evaluate expressions using variables existing at runtime.
Have you considered using a Scala Worksheet, which is a kind of editor supported REPL. You can create one in your project, import code from your project, execute it and see the results instantly. It wont let you debug to a piece of code though, if that is your primary intention.
It's an old question, but for now there is a good answer:
https://www.jetbrains.com/help/idea/2016.1/evaluating-expressions.html
TL;DR: During debugging, click on a stack frame, and you'll be able to evaluate expressions in the context of that frame: Run|Evaluate Expression, and you can click "Code Fragment Mode" to enter multi-line stuff. IntelliJ autocomplete features would work properly too!
I'm tinkering about switching my IDE to emacs. (I'm still an emacs newbie.)
The problem is that I customized my IDE quite well and I'd regret to leave my helpers behind.
Let me explain:
Shows the current open files/buffers, allows fast switching with a hotkey (C-1, C-2, ...)
Shows the most recent texts on the "clipboard" or inserted by complete (no. 4), text insertable with a hotkey (C-b 1, C-b 2, ...) Last inserted shown in bold, insertable with C-`
The last inserted complete (no. 4) text, insertable with M-`
Autocomplete-ish list, gathered from all open files, regardless of their type with some magical logic. text insertable with a hotkey (M-1, M-2, ...)
I guess emacs has such features, but I'm a visual type I'd like to see what I have available.
Of course actual hotkeys don't matter much, but as you see having all that info visible makes it easy to hit the spot with the least keypresses.
My pain is that there is a plethora of emacs extensions providing various features, checking all seems to take a lifetime.
My question is:
are there any emacs extensions to achieve similar looks and behavour?
as I'm a programmer, which extensions could I take as a base to assemble something like this?
Thanks!
Elaborating a bit more:
I’m a python dev, so most of the code I’m writing is python. Add some HTML JS CSS XML to the picture.
One important thing is that completion needs to work across filetype boundaries, because python / HTML(template) / XML(config) / doctest identifiers are cross-referenced. It’s a huge pain with some IDEs that completion works only for python filetypes.
I have a lot of same named files but in different folders, like init.py, configure.zcml, etc. It seems to be a pain to switch between those by filename.
Better said that’s a list of recently inserted text. To be reused by the fewest keys as possible. Usually when coding I’m reusing the same identifiers/whatever within the same task. So it’s handy to have them listed instead having to retype the starting x chars to get completion again.
Usually best use of this feature is when changing/refactoring code. Like adding one more extra feature and the identifier is needed several times over the place.
TL;DR
Learn keyboard macros. Learn yasnippet.
Autocomplete mode is probably similar to what you have.
Get acquainted with emacs kill-ring before trying to change it, it wants to be your friend. Then you'll know what to look for when you DO want to change it.
Long Version
Shows the current open files/buffers, allows fast switching with a hotkey (C-1, C-2, ...)
You have three options for this.
My personal preference is to have all source files open at all times. So I don't need a visual list of open buffers. Whenever I want to switch to a file I hit C-= (which I've bound to iswitchb-buffer) and type a couple of unique letters. It's common to constantly switch between the same two buffers so I also bound C-backspace to previous-buffer.
Another option I can recommend is tabbar. It's not exactly like your setup, but it displays a list of open buffers (just like webpages in a browser) and it has functions for cycling through the tabs, so it shouldn't be hard to reproduce your C-number key bindings.
You could use speedbar or ecb. They would be the most similar to your current visual configuration, but I'd argue the other options are more efficient.
Shows the most recent texts on the "clipboard" or inserted by complete (no. 4), text insertable with a hotkey (C-b 1, C-b 2, ...) Last inserted shown in bold, insertable with...
I see you've sort of mixed the clipboard with completion history. When it comes to emacs, yasnippet and autocomplete are just so good you're better off going with them for completion (see below).
Emacs clipboard is called the kill-ring. I'm sure you know of C-y and M-y, so you can always recover anything you've cut in the past. Unfortunately, I don't know of any packages that constantly display the kill ring or allow you to yank a specific part of it (though that shouldn't be too hard to write), but at least you know what to search for (kill-ring).
The last inserted complete (no. 4) text, insertable with M-`
I'll be honest, I don't see that much use in this. If you have to repetitively insert text, you should learn keyboard macros. In fact, you should learn keyboard macros anyway, they're the first reason I got hooked to emacs.
Autocomplete-ish list, gathered from all open files, regardless of their type with some magical logic. text insertable with a hotkey (M-1, M-2, ...)
Emacs had many great completion options. In your case, the best one is probably autocomplete-mode. It pops-up completion options (much like your separate completions window), and I think it allows for quick selection of a specific option (like your M-number shortcuts). Also it has several different ways of deciding which completions to offer you (it calls them "sources") and one of them is to gather from all buffers.
In addition to that you have yasnippet, and I couldn't possibly recommend it enough. Seriously. Learning to use it and writing your own snippets will change the way you write code. You'll become a mage whose fingers produce pages of code flowing through your screen in blazing speeds. Use yasnippet!
Once you have it configured, every 3 or 4 keys you press will generate a line (or more) of code for you.
After all that, if you still miss something from your previous editor you'll write it yourself. :-)
Your setup looks exactly like https://github.com/emacsmirror/ecb.
To me at least, since I don't use side-bars:)
You should take a look at the extension speedbar. I have installed this extension, but I rarely use it even for a very large project.
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
I started using SuperTab recently, but I want to use Ctrl-space instead of Tab.
My problem is that I often use Tab to add indentation inside comments, but SuperTab starts completion. I know I can use Ctrl-V Tab, but that's clumsy (especially since I don't use Tab for completion).
I tried adding this in my vimrc...
let g:SuperTabMappingForward = '<c-space>'
let g:SuperTabMappingBackward = '<s-c-space>'
...and that allows me to use C-space, but Tab still does autocomplete. I want to use Tab to insert indentation and never completion.
I'm using SuperTab continued.
I started using SuperTab because I want context-sensitive completion with Eclim (Eclipse + Vim). I set this:
let g:SuperTabDefaultCompletionType = 'context'
And SuperTab switches between text completion and user-defined (eclim) completion (for member functions and variables) as appropriate. If there's a simpler way to do this, then that would be an acceptable solution.
Judging strictly from the documentation, you may be able to get this effect by also setting g:SuperTabMappingTabLiteral to <Tab>.
Edit: I was able to test this in gvim this morning with positive results. Setting this setting in conjunction with the two mentioned in your post allowed me to insert literal tab characters with <Tab> and do completion with <C-space>.
Had the same problem...
After looking in the documentation, it appears that <C-Tab> is what you're looking for.