Emacs Starter Kit on the Mac - emacs

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.

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.

Ergoemacs C-x and C-c Shortcuts, and Apple Cmd shortcuts

For ergoemacs, what are the C-x and C-c shortcuts re-mapped to?
There doesn't seem to be a page to help people transition from regular emacs to ergoemacs mode. They just have a keyboard picture with everything in it, without any information on C-x and C-c.
Also for Apple keyboards, when it says Ctrl/Cmd, does that mean either can be used? It doesn't look like it. It seems that OS X Cmd shortcuts are taking precedence over the ergoemacs ones. Until Ctrl/Cmd means something else?
Ctrl-c is copy and Ctrl-x is cut.
According to ErgoEmacs Documentation, the keybindings C-c and C-y are respectively associated with native <copy> and <paste> functionality using emacs kill-ring-save and yank commands.
The traditional C-k and C-y methods of line pulling / yanking used in GNU Emacs and XEmacs are left behind in an attempt to "[make it] so you don't have to change your mindset when you switch in and out of emacs". We can expect many features of ergoemacs to be intuitive to the sort of end-users who have never been religiously bound to a text editor.
In current version of ergoemacs-mode, by default C-x and C-c are same as GNU Emacs's.
in older version of ergoemacs-mode, the gnu emacs's C-x and C-c are simply left intact. ergoemacs-mode just turn on cua-mode.

how to autoload the menu bar in 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 :(

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.

How do I see the list of open files within Emacs? Or browse a directory within Emacs?

Most text editors have a navigation pane that lets you see all the files you currently have open. Or a pane that lets you browse a file directory.
How do I do this in Emacs?
Try Ctrl-x followed by Ctrl-b (in Emacs terminology C-x C-b) to list buffers.
C-x C-b will open the *Buffer List* buffer. In that buffer, you can navigate with the usual keys C-p, C-n, up-arrow, down-arrow, etc.
Browsing a directory is as simple as editing a file. Just open the directory instead of the file. On my Linux machine, C-x C-f /tmp ENTER opens a directory while C-x C-f /tmp/myfile ENTER opens a file.
C-x d accesses the directory editor. C-x C-f will do it as well if you give it a directory instead of a file.
There's also ibuffer-mode, which lets you deal with your open buffers in a very similar fashion to Dired: http://www.emacswiki.org/cgi-bin/wiki/IbufferMode
It's included with recent versions of Emacs, so you may not have to download it separately: try M-x ibuffer first.
M-x speedbar (speedbar website) will pop up an emacs frame that lists the contents of the current directory depending on the buffer you're in. The frame is small and stays out of the way so you can always glance at it while you're editing files. It also can filter this display based on file type using the variable speedbar-supported-extension-expressions. To see all the speedbar options, type M-x customize-group RET speedbar RET.
If you are interested in seeing a tree like structure for your directories, sources, methods etc try using emacs code browser http://ecb.sourceforge.net/.
C-x b TAB will give you an auto complete with all open buffers. Alternatively, click on the Buffers menu item if you are in a windowed version (not sure if there is a terminal equivalent of that).
EDIT: Also C-x C-f will let you open a file, and you can use TAB for autocomplete, then TAB again to view files/directories in that current directory (assuming the first tab did not autocomplete something).
When browsing directories with diredit, consider using a instead of RET to change directory.
Otherwise, each new directory is visited in a new buffer, which will clutter up you buffer list pretty quickly.
M-x shell opens a shell where you can browse directories
If you are just looking for files and not for any other buffers, look a the file-history.el
https://github.com/akicho8/file-history
I just discovered neotree package which displays the tree of all files from a root directory. Visiting the files in the neotree buffer opens them of switches to the buffer if already opened.
neotree can be installed either by
M-x package-install Ret neotree
or from its gitbub repository.
You could try the sidebar package
I often need to find another file in the "current directory", ie. the directory of the file I'm editing.
To quickly open this directory in diredit, I use:
C-x C-f C-j
You can also try http://code.google.com/p/emacs-nav/
Also, if you want to get rid of the list of open buffers, type C-x 1.