Cedet completion menu - emacs

I am using emacs24. I would like to get the auto-completion experience that I get in e.g. eclipse. That is:
- on pressing e.g. C-RETURN, to get a menu, which updates on-the-fly as I type the name of the method; I would also like to navigate with the arrows through the choices
- On clicking a completion from the menu, I would like to have something like a tooltip with the documentation of the specific method, if found
semantic-ia-complete-symbol opens a new buffer. semantic-ia-complete-symbol-menu does not come by default with emacs (built-in). Even if it did, it does not update itself on the fly, and I don't have the documentation.

This doesn't answer all your questions, but it is a start:
;; shows a menu by clicking CTRL-RETURN
(global-set-key (kbd "C-<return>") 'auto-complete)
;; allow to navigate the autocompletion menu with <up> and <down>
(setq ac-use-menu-map t)
(define-key ac-menu-map "<down>" 'ac-next)
(define-key ac-menu-map "<up>" 'ac-previous)

Related

How to open files and sub-folders in the same window in emacs?

I would like to open files/sub-folders in the same window which is already established in my emacs(I understand the difference between Emacs frames and windows).
Currently when I jump into Emacs I typically use C-x f in order to navigate to the folder I will be working inside of; once there I can look at the folder and its contents in Dired nicely.
However, when I then try and open a file or a sub-folder within this, by clicking or selecting it through navigating with my keyboard, it then spawns a new window beside my current one, making my screen extremely cluttered when I only wanted one window open.
How canI tell Emacs that when I am navigating in Dired I want new files and folders I move into to be opened in the window I am already working in so that I do not have to keep closing and re-opening random windows?
Apologies if this is a newbie question I am a fairly new emacs user and couldn't find this question posed elsewhere.
Try this:
(with-eval-after-load "dired"
(define-key dired-mode-map (kbd "<mouse-2>") #'dired-mouse-find-file)
(define-key dired-mode-map (kbd "<RET>") #'dired-find-file))
It behaved normally for me when I pressed <RET>, but the mouse click indeed opened another window. I used C-h k to see what the commands were named.

Emacs: How to enable toolbar mode and menubar mode only under a certain mode?

I use Emacs. However, I am not familiar with Lisp although I do know some functional programming, and hence I never really understood how to customize the init.el.
So basically, I want to be able to enable the toolbar mode and menubar mode only if I am in R-mode.
I know that to enable these mode simply requires:
(tool-bar-mode 1) and (menu-bar-mode 1)
but what if I want to do this locally, i.e. enable them only if I am in R-mode.
What should I put in the init.el ?
It's possible with this advice:
(defadvice select-window (after select-window-change-menubar activate)
(let ((yes-or-no
(if (memq major-mode '(r-mode lisp-interaction-mode))
1 -1)))
(menu-bar-mode yes-or-no)
(tool-bar-mode yes-or-no)))
I added two modes to the list for now, lisp-interaction-mode is the
mode of the *scratch* buffer, so that it's easy to test if the
advice works.
It's super-annoying, but kind of cool at the same time. I hope it's
what you want.
The features I describe here are close to what you are asking, but not an exact match. If your real need is to not have the tool bar around all the time when you don't need it, then they might help.
Library Tool-Bar+ provides two possibilities that limit when a tool bar is shown:
tool-bar-here-mode:
Enable the tool bar for specific frames only. Presences or absence of the tool bar is a frame thing, not a window or buffer/mode thing. When present, the actual contents of the tool bar (its icons) are specific to the selected window and its buffer. But whether or not the tool bar is shown has to do with the frame.
You enable showing the tool bar for the selected frame with command tool-bar-here-mode. You can add this to a mode hook, so that when a given mode is enabled so is the tool bar:
(add-hook 'info-mode (lambda () (tool-bar-here-mode 1)))
But that does not turn the mode off when the same frame no longer shows a buffer with that mode. In this regard it does not answer your question exactly.
tool-bar-popup-mode:
Hide the tool bar, and just put a Buttons entry in the menu-bar. When you click it the tool bar pops up for a single tool-bar action. So:
a. Click Buttons - the tool-bar pops up.
b. Click a tool-bar icon to effect its action - then the tool bar is hidden again.
For the toolbar, you can bind it to one of your mouse buttons or a key-sequence. For example, try this in your .emacs file:
(global-set-key [mouse-8] 'tool-bar-here-mode)
(tool-bar-pop-up-mode 1)
Depending on your mouse, you'll need to change 'mouse-8' to reflect the mouse button you wish to bind to. (Hint, click your desired mouse button while Emacs has the focus and you will see a message at the bottom like:
is undefined
Alternatively, you can bind to a key on your keyboard, like for instance:
(global-set-key (kbd "C-.") 'tool-bar-here-mode)
which will bind it to the CTRL-.

how to define a key to toggle viper-mode in Emacs

In Emacs, I want to define the key to enable/disable the viper-mode. When I press the F6, if viper-mode not enabled, then enable it; if viper-mode enabled, then disable it.
Thanks.
(global-set-key [f6] 'toggle-viper-mode)
May pose problems in modes which locally rebind F6. If that happens, see this related question

Emacs Starter Kit on the Mac

I just installed Emacs on my mac from here:
http://emacsformacosx.com/
and that got rid of all the menus. How do I get those menus back?
Look for menu-bar-mode in your ~/.emacs or ~/.emacs.d/init.el file.
You should find...
(menu-bar-mode -1)
If so, remove it. If you don't find it... add the following line.
(menu-bar-mode 1)
and save the file.
If you want to enable or disable the menu in emacs, you can use
M-x menu-bar-mode
and if you want the same with the toolbar you can use
M-x tool-bar-mode
The menu should be enabled "by default" unless stated otherwise in your .emacs file which you can find in emacs using C-x C-f ~/.emacs.

Getting YASnippet and viper-mode to work together in emacs

I use viper-mode in emacs, but I want to use YASnippet as well. However, when I enable viper-mode and try using tab-completion through YASnippet, nothing happens. How do I get the two of them to work together?
Using an Emacs without any customizations (emacs -q), I got the following to work:
(load-file "c:/cygwin/home/Trey/scratch/yasnippet-bundle.el")
M-x viper-mode
(define-key viper-insert-global-user-map (kbd "<tab>") 'yas/expand)
C-x C-f a.cpp
i
main<TAB>
Try that, see if it works (as in, if there's something in your .emacs that's messing things up). Also, check to see what Emacs thinks your TAB key is. On my windows system, the tab key was bound to <tab> and not TAB - try doing M-x describe-key TAB and see what the *Help* buffer translates it to. yasnippet appears to bind to TAB, so I needed the extra binding for <tab> to get things to work.
For more information about how Emacs handles the TAB, read the documentation for function keys.