Vim style Omnicomplete for emacs? - 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.

Related

what is this window on emacs?

I saw the window on the screen of many emacs developers. I feel inconvenient to see below prompt or minibuffer. can you tell me the name of package?
I just googling to find answer. However, I couldn't find the name of package.
Looks like vertico.el.
"Vertico provides a performant and minimalistic vertical completion UI based on the default completion system."
https://github.com/minad/vertico
I think you are referring to the floating minibuffer. It is called a posframe from the package of the same name.

What is the correct way to show menu / help screens in Emacs?

When using tools like Org-mode and Magit the mode will sometimes show help menus. For instance, org-mode export will show a nice menu that accept single keys and then executes some command. In Magit, when looking at the status view it will accept tabs to expand the staged and commit areas.
These areas, for both Git and Org, are nicely placed to take up some portion of the emacs frame that is mostly convenient. How does emacs do choose this?
Additionally, these views are read-only, up until the user presses tab in the case of Magit and the status view. Is there a best practice when creating these views which control editing, but allows the mode to edit the file and present alternative text?
Perhaps the answer is take a look at these function A, B, and C. Which is fine, I'm just learning and experimenting on my own.
Magit in particular is not the simplest introduction to popup buffers in Emacs, but it certainly is sophisticated and a good read. Find magit-popup.el on your machine, for example M-x find-function RET magit-popup-mode-setup. To me, that function looks like a good candidate to start reading that file. You can see the macro magit-define-popup in use for example in magit-push-popup in the file magit-remote.el
In the end, it boils down to opening a new buffer in a new window and give it a dedicated major mode which has all the key-bindings.
Another good candidate is the family of temp-buffer-* functions.
Hope, that gives some pointers to start reading.
An easy way to show menus/help screens à la Magit and org-mode is with Hydras:
http://wikemacs.org/wiki/Discoverability#Hydra
https://github.com/abo-abo/hydra/
https://github.com/abo-abo/hydra/wiki
It's a short elisp method to write and it will give you a menu like org-mode. For example:
(defhydra hydra-zoom (global-map "<f2>")
"zoom"
("g" text-scale-increase "in")
("l" text-scale-decrease "out"))
ps: it's not what org-mode and magit use. Magit's system wasn't re-usable until recently and I don't know how it compares with Hydra. A nice feature of Hydras is that you can tell it to not disappear after a keypress, so than you can press many keys in a row.

Notepad++: disable auto-complete in comments

I'm using Notepad++ for C coding.
The auto-complete functionality in NP++ seems really naive. No matter where I am in a file, it always tries to give me a list of auto-complete suggestions (most of which are just random words, rather than function or variable names).
It becomes really annoying when I'm trying to write a long multi-line comment, and I keep having to hit escape at the end of lines because the auto-complete pop-up wants to change what I'm typing.
Is there a way to disable auto-complete inside comments?
Alternatively,
Is there a way to disable keyboard interactions with auto-complete? The time it saves by filling in text for me is negligible compared to the time it saves me from having to go and confirm that I'm spelling function or variable names correctly. So, it would be just about as useful if it always made suggestions, but where the arrow keys and enter interacted with the text, rather than the pop-up.
You can go Settings →Preferences → Auto-Completion and from this point you can set whether you have auto-completion on words, functions or both.
At this point, I don't believe there is a way to disable auto-completion within comments.
A workaround is to turn off auto-completion using Ctrl+Enter for your code, and Ctrl+Space for your comments.

Context-insensitive completion popup in 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).

Better control over Emacs windows

I spend a lot of my time in emacs, and for the most part it's wonderful. But one thing really drives me nuts when I'm deep in it, and that's control over which window various new buffers are opened in. When I do find-file, it always opens in the current window, and this is what I like. But tons of other modes like to split my windows for me, change the layout, and do various other things that annoy me. For example running M-x manual-entry seems to have no rhyme or reason about where it opens the manpage, and various org-mode commands do the same thing, closing windows I want to keep open, etc. I don't like having to redo my layout everytime I want to look at my org agenda or open a manpage.
In short, is there anyway to globally control which windows are used for modes that want to open in a window other than the current one? Can I direct them more easily? Or will I have to hack each mode to act the way I want it to?
Try Winner mode:
http://www.emacswiki.org/emacs/WinnerMode
It provides an undo/redo for changes to the window configuration.
This question has always bugged me too. I found this:
http://www.gnu.org/software/emacs/elisp/html_node/Choosing-Window.html
It looks like you can use (setf pop-up-frames t) to make stuff show up in a new frame.
Also, it looks like you can use display-buffer-function to override the display function (how buffers are chosen.) Of course, you'd have to be good at elisp.