Emacs default saving directory criterion - emacs

My question isn't about configuring emacs. It is about understanding its default behavior, since I'm new to it.
I've noticed that when I save a file with C-x C-s sometimes it saves
the file on my root user directory (~). However, sometimes emacs
writes my files under /Applications/Emacs.app/Contents/Resources/info/.
This is very troublesome, cause I can't reach that directory from within
the Finder for whatever reason (in \applications is only the emacs app, I can't reach its subdirectories).
It is also very troublesome to open within emacs itself since I have to click Open File from its GUI in order to land on the aforementioned directory.
Why does Emacs sometimes saves on root and sometimes on \application?
May it be because of the mode in which I C-x C-s?

Related

Emacs prevent backups in the form `#<filename>#`

I like to write some Java code to test out the new lisp features that I program. When I do this I open a new buffer and then usually restart emacs. When I C-x C-c, emacs wants me to save the file, and if I do not it generates a backup of the form #<filename>#. How can I stop this from happening, without disabling the backup of the form <filename>~?
Those are not backup files; they are auto-save files. If you do not want Emacs to auto-save buffers then customize option auto-save-default to nil.
See the Emacs manual, node Auto Save Control.

How do I store a persistent history?

Im fairly new to Emacs (I'm using emacs now since 1 month) and migrated from vim. One "feature" of vim I really miss in Emacs, is the persistent history.
When I am starting vim I can easily open files I recently had open via the command history. But in Emacs when im in dired (or executing commands via M-x) and then pressing M-p I can only browse through the sessions history, and cannot open i.e. files I had opened in a previous session. So, now my question: Is it possible to store the Emacs-history persistent on my system, that when I re-open Emacs I can access my complete history?
(Btw. my Emacs Version is 24.3.1)
Thanks in regards,
Niklas
You can put (savehist-mode 1) in your .emacs to save your minibuffer history over several sessions. (You will need to restart for this to work)
For M-x specifically, look at the SMex package. It enhances M-x with a history, flex matching, better ordering, etc.

Load semanticdb tags in emacs without revisiting file

This section of the emacs manual states that revisiting a file is the default way to load tags from the semanticdb, but (in the second paragraph) that it's possible to access the tag information without opening that file again. Does it require another program hooking into the API mentioned or are there built-in settings? I thought maybe the search-throttle setting would do it, but doesn't seem to help. If it does require another program, does such an app exist?
For example, if I open foo.cpp and foo.h, I can use semantic-analyze-proto-impl-toggle to jump back and forth between definition/implementation. When I close emacs, I can investigate the contents of ~/.emacs.d/semanticdb/ and ensure the tags from foo.cpp were saved.
Then, open foo.h in a new emacs session and try to jump to the implementation of a definition. Until I open foo.cpp in a buffer, I'll get the "Could not find suitable implementation" message.
I want it to work right away. If the file isn't opened I think emacs should just load it into a new buffer and take me there!

Issue With Desktop Save Mode Not Saving

Recently I have been having an issue with desktop save mode where it will not actually save my desktop. In the echo bar it says "Error while saving the desktop..." After typing no it says "Opening output file: no such file or directory, then gives the location to the path of the file". After saving a .emacs.desktop file then restarting emacs I noticed that it is saving the buffer locations in that file but is not loading that file. Thanks. Also I am not sure what has caused this to happen as it was working a couple weeks backs and nothing has changed that should make a difference.
The only thing i have in my .emacs for the desktop mode is
(desktop-save-mode 1)
Looking at the code for desktop.el here, it looks like the error is bubbling up from desktop-kill, which runs when you exit Emacs. The first thing I'd try is to check that the directory where it tries to save the desktop is sane.
Looking at the code in desktop-kill, it only tries to do anything if the variable desktop-dirname is non-nil. But that only gets set when you run M-x desktop-save for the first time: are you sure that it's set to something sensible? To check its value quickly, you can type M-: desktop-dirname RET and it should appear as a string in the message area.
If the directory is something sensible (the directory exists and you can write to it...), then I'm not sure. You'll probably have to give more information to get a solution, and it's not really clear that it's an ideal question for StackOverflow.
i should hazard that you get this error by creating a shortcut in the windows start manual via clicking addpm.exe in the ...\emacs-version\bin\ folder.
you can further modify the shortcut. go to its property->shortcut tab, you will find that the Target has value like ...\emacs-version\bin\runemacs.exe, while Start in is void. try to fill Start in with the corresponding folder ...\emacs-version\bin (actually most directories would be fine, just don't leave it blank), then everything is fine. still, the machanism behind this remains unclear to me.
or you could always creat your own shortcut manually, only make sure that the target is runemacs.exe, not any other exe file.

Change the initial directory on emacs, and also some tips for a starter

How can I change the initial directory on emacs? I started using it today and there are a lot of things to learn!
Right now I'm using M-X cd and then I change the directory that I use for C-x C-f, but in a daily work I'm going to heavily use one particular directory so I need to make the change permanent.
Also if you have some tips for a starter it will be nice.
To set a default directory, simply put
(cd "/default/path/")
in your ~/.emacs file.
Emacs has a steep learning curve, but with constant use the most common commands will soon become second nature. As you discover more, emacs may become your favorite text editor, file manager, and email reader :)
To learn emacs, I'd start by pressing C-h t to start plowing through the excellent tutorial. Have a pad of paper beside you and write down the commands as you learn them. You'll use the crib sheet at first, but after a while, as I mentioned before, your fingers will learn the key combinations without your brain conciously intervening.
Good luck and have fun!
Default directory is determined by:
(setq default-directory "~/")
in this case, set to the users home dir, but it could be somewhere else.
If this variable is not set, the initial load point for find-file will be the directory where the emacs executable lives.
EDIT: on windows, a global HOME environment variable can be defined (HOME=c:\path\to\user\home\directory), ensuring that Emacs translates ~ to the correct value. This makes the Emacs settings usable across platforms.
Start up emacs only after changing to that "initial directory", effectively setting the current directory for emacs.
This is a solution specific to Windows.
Create a shortcut to emacs.exe" called GNU Emacs
Open Properties on the GNU Emacs shortcut
Set Start in to %USERPROFILE%\Documents
This solution works for multi-user workstations whether they are on or off Active Directory.
This shortcut will start Emacs in the current user's Documents folder.
Print out the Gnu Emacs Reference card and keep it by the desk.