Context-insensitive completion popup in Emacs? - emacs

I'm experimenting with the transition from Vim to Emacs, and one of Vim's features that I really miss is the context-insensitve completion popup (CTRL-n and CTRL-p). For example, in the buffer below, if I were to type he then CTRL-n, I would get a popup:
How can I get a similar context-insensitive completion menu in Emacs?
Note: I specifically want context-insensitive because it's often helpful to make references across different contexts (for example, reference a Python class from Restructured Text documentation) — something context-sensitive "omnicomplete" doesn't do.
Additionally, I know that M-/ will trigger auto-completion, but it only cycles through matches; I want a popup list showing matches.

Auto Complete Mode should do what you're looking for.
It's generally not triggered by a hotkey, but something like:
(setq ac-auto-start nil)
(global-set-key "\M-/" 'auto-complete)
should do what you want.

Auto Complete Mode shows a dropdown menu with matches: http://cx4a.org/software/auto-complete/manual.html#Basic_Usage
You can install it via the Marmalade repository: http://marmalade-repo.org/, follow the instructions to setup Marmalade, then M-x package-install auto-complete. You'll have to activate auto-complete-mode, then while typing anything it will show you matches (you can also force it by pressing TAB, by default).

Related

TODO Tool window in Emacs?

I'm looking for a functionality like:
the TODO tool window of IntelliJ IDEA (see https://www.jetbrains.com/help/idea/todo-example.html) or
the Tasks list of Eclipse (see https://dzone.com/articles/to-do-lists-with-eclipse-tasks-view).
And I'd like that window to be opened automatically (if not empty) when opening any file or, at least, to have a message in the echo area stating that there are some TODO/FIXME items in the file I'm currently opening.
So far, I did not find any matching package, only things (like fic-ext-mode) that would highlight TODO and FIXME in comments for common programming languages, but no more.
Is there something else, closer to what I'm looking for? I'm certainly not the first one looking for such a feature in our favorite editor ;-)
hl-todo has hl-todo-occur, which opens an occur buffer of all the keywords it's configured to highlight in the current buffer. You should be able to add it to a major mode hook like so:
(add-hook 'prog-mode-hook #'hl-todo-occur)
But this doesn't work. I think it's because hl-todo-mode is activated in prog-mode-hook, and it isn't ready yet. I don't have time to track this down right now.
If you use magit, I just saw a new package magit-todos. I haven't tried it, but it looks pretty nice.
Not aware of an existing module. It would be nice to have one. If you can write, use elisp and M-x Highlight-regexp and M-x occur and then write a hook to open occur window when you open a file. May be a macro will do for this too. You can do more with elisp, such as make occur window renamed as TODO-window and parse the entries to convert into org-mode table to sort entries while preserving the clicking etc.

Autocompletion from the keyboard in Emacs CEDET/semantic

Looking a the different methods for completion in CEDET semantic (fresh version from the Bazaar repository), I see I have the following options (keyboard bindings as suggested by Alex Ott in his config file)
C-c ? (semantic-ia-complete-symbol)
C-return (semantic-ia-complete-symbol-menu)
C-c , l (semantic-analyze-possible-completions)
However, none of them seem to give me the option to choose between the possible completions conveniently using the keyboard.
For example, (semantic-ia-complete-symbol-menu) opens a menu where I can choose between the different options, but as far as I can tell it requires me to use the mouse (I tried C-n, C-p, M-n, M-p to navigate the menu with no success).
On the other hand (semantic-ia-complete-symbol) opens another buffer with the options. I can also use the mouse to choose the desired autocompletion, but I would like to use the keyboard instead.
Also, in previous versions of CEDET, there was a variable (semantic-complete-inline-analyzer-displayor-class) that allowed me to choose between several options for autocompletion (e.g. (semantic-displayor-ghost), or a more elegant overlay as a tooltip), but this variable does not seem to exist anymore.
In case it matters, I work mostly with C++ files.
Update:
The only method that seems to allow me to cycle through autocompletions is C-c , space (semantic-complete-analyze-inline), where I can use TAB to autocomplete, but it doesn't show a menu of possible autocompletions that I can choose from.
In new versions of CEDET it's recommended to use auto-complete or similar packages. You can add ac-semantic to ac-sources, and then auto-complete will use Semantic as source of data for completions. The new version of Emacs/CEDET articles, mentions this setup & shows necessary code. Please try it

How to set single click to enter directory in emacs speedbar?

I've got speedbar set up and working, but I want to change it so a single click (Mouse-1) will allow me to go inside a directory. I've already googled around and looked at the relevant docs:
The mouse bindings are:
Mouse-1
Move cursor to that location.
Mouse-2
Double-Mouse-1
Activate the current button. Double-Mouse-1 is called a double click on
other platforms, and is useful for windows users with two button mice.
So, basically I've been trying to find how to map Mouse-1 to the function currently bound to Mouse-2, but only inside the speedbar frame. The closest I've found to something to do that is an ecb setting:
(setq ecb-primary-secondary-mouse-buttons 'mouse-1--C-mouse-1)
but I'm not using ecb, I'm just using speedbar. Maybe there's some other way to do it?
Adding this line to `speedbar-file-key-map' should do the trick:
(define-key map (kbd "<down-mouse-1>") 'dframe-click)
If you don't want to edit speedbar.el directly, you can use e.g. a hook.

Vim style Omnicomplete for emacs?

I've found several code completion elisp packages for emacs that do code completion, but most bind to a key such as M-/ to toggle completion. Is there something similar to Vim's omnicomplete where you can set it to automatically pop up a list of autocompletion options where you can either navigate through them, or just keep typing.
See screenshot for example:
I think company mode would best fit your description. Have a look at it.
There are a number, all a little different:
predictivemode
pabbrev
completionui
autocomplete
They all have their drawbacks and advantages.
The emacs wiki has a page for all the completion packages.
Can you? Sure. Reset a timer on post-command-hook. If it goes off (because you are sitting at your screen not typing), pop-up the thing.
It seems easier to tell your computer what to do (by pressing keys) rather than having it wait for your to stop typing for a while, however. Bind completion to something like the "menu key", and you won't even have to chord.

make emacs semantic auto complete tip "always on"

I have just installed cedet (CVS version) and I am now playing with in emacs and my C++ source code.
Regarding the auto complete, I can invoke the tool tip and the menu from their semantic-ia-complete-* commands.
Does anyone know how I can make the auto complete tip appear automatically without my having to invoke a command (semantic-ia-complete-tip)? Is this even possible?
From CEDET website:
Automatically starting inline completion in idle time
M-x global-semantic-idle-completions-mode
This is a minor mode which runs
semantic-complete-analyze-inline-idle
during idle time. Instead of trying to
complete the symbol immediately, it
will just display the possible
completions, and underline the current
symbol the cursor is on.
In practice this means that the possible completions will appear whenever you stop typing and the cursor is under a symbol where completions are possible.
To use it, just put
(global-semantic-idle-completions-mode)
to your .emacs after loading the CEDET.