how to autoload the menu bar in emacs - emacs

I have installed YaSnippet in my emacs. Every time I start emacs, I have to turn on the menu bar manually by M-x menu-bar-mode, how do I load it by default ?
Also strangely the YaSnippet menu shows up the first time the menu bar comes up, however after I move to another buffer and back, I cant see the menu anymore ! How do I get it back without restarting emacs?

The menu bar is loaded by default in emacs. Therefore if you have to turn in on in every buffer it means that you have disabled it in your init file. Remove a line that would say something like (menu-bar-mode 0).

To start menu-bar-mode automatically, just put (menu-bar-mode 1) in your ~/.emacs
I'm afraid your yasnippet problem is outside of my realm of lore :(

Related

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-.

Disable auto-complete's pop-up menu in emacs

How to disable auto-complete's pop-up menu from showing up? I would simply like one simple suggestion much like in googles' suggestions (and also implemented in auto-complete itself).
Strangely it shows this in grey right before the pop up menu, how to make it stay like that?
Adding the following line to your init file should do the trick.
(setq ac-auto-show-menu nil)

Menu bar flashes for a moment when Emacs starts

With (menu-bar-mode 0) in my .emacs-file, Emacs (in a terminal) seems to be starting with the menu bar visible, and then within a fraction of a second, the bar disappears.
Is there a way to make Emacs not show the menu bar at all?
No: Emacs first starts by setting up its "frame" (which includes some initial display), then reads the .emacs file. That's why you see this flashing of the menu-bar. Emacs could read the .emacs first, but if the .emacs outputs any message or signals an error, there'd only be stderr to display it, whereas with the current setup, those messages are displayed in the minibuffer and the error can be caught in the "normal" way.
If you're runinng Linux (and I guess any system where Emacs runs in an X server), you can use X resources to tell Emacs you don't want the menu bar. Just put this in your ~/.Xresources file:
emacs.menuBar: off
These resources are used to customize frames appearance and are therefore read by Emacs at the very beginning.
See also:
Emacs manual: Menu Bars
Emacs manual: Table of Resources
man xrdb(1)

How can I configure emacs to switch to a particular buffer when I click the mouse in it?

I'm using iTerm2 on my mac to ssh into a Linux box and run emacs in the terminal. On a big monitor, I like to split the window to see multiple buffers side-by-side. I'd like to be able to switch to a particular buffer by clicking the mouse in it (rather than doing C-x o).
What seems to be happening is that if I click the mouse anywhere outside the currently active buffer e.g. in the next buffer, on the mode line etc., the click is being interpreted as which is bound to (tmm-menubar-mouse EVENT).
I have disabled the menubar by doing the following in my .emacs_d/init.el:
(menu-bar-mode -1)
This seems to disable the visible display of the menu bar at the top of the window, but the mouse click behavior I described is still happening.
I think what I need is to have the click interpreted as something other than and then bind that to some function that detects which buffer the click happened in and switch to it. But, I don't know how to do that and the searching I've done hasn't yielded any clear answer. Can anyone help?
Alternatively, I looked into using windmove to enable switching between buffers with SHIFT and the arrow keys. I did (windmove-default-keybindings) but emacs then seems to respond to SHIFT left-arrow by inserting "2C" into the buffer and SHIFT-right-arrow by inserting "2D". If anyone has any tips on making this work too, I'd love to hear them.
Thanks
I ran into this problem a while ago, where clicking on column > 95 was interpreted as <menu-bar> <mouse-1>, which invokes tmm-menubar-mouse. It turned out to be a bug:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6594
There hasn't been a formal release since this bug was fixed, but you can get the patch here:
http://bzr.savannah.gnu.org/lh/emacs/emacs-23/revision/100618
If I recall correctly, you should be able to just drop the modified file into your existing emacs installation and byte-compile it (assuming you're running the 23.3.1, the latest release).

How do I keep Emacs org-mode from splitting windows?

I'm a new emacs user using emacs for the awesome org-mode. I have links to all my org files at the top of my pages but everytime I click a link it splits my window, so I only have half of the screen estate available. How do I set it so that emacs does not split the window horizontally but rather opens up a new window for my links?
I'm assuming you mean you want to open the link in a new frame. (Emacs terminology is a bit different from other GUI apps, because Emacs predates X11. What would be called a "window" in other apps is called a "frame" in Emacs, because "window" already had a specific meaning in Emacs, and was used in the names of lots of functions.) What's happening now is that you have a frame containing one window, and Emacs is splitting that window to form two windows.
You need to customize org-link-frame-setup to use find-file-other-frame instead of the default find-file-other-window.
You can do this by typing M-x customize-variable <ENTER> org-link-frame-setup <ENTER>. Click the Value Menu next to find-file-other-window and select find-file-other-frame, then click Save for future sessions.
One option is to tell Emacs to never split windows, which can be done like so:
(setq same-window-regexps '("."))
This will keep your window from splitting, and then you use your regular commands to switch buffers to get back to what you were looking at.
This is as opposed to what it sounds like you were asking for, which was new frames, which IMO doesn't really help if you have limited screen real estate because you're now having to switch frames (graphical windows).