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

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.

Related

Emacs default saving directory criterion

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?

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.

saving perspectives when an emacs session is saved

I have been using perspectives package in emacs (from Nathan Weizenbaum, https://github.com/nex3/perspective-el). I save my emacs session on exit so that it saves the existing buffers and loads them up on next start. The line added in .emacs file to achieve this is : (desktop-save-mode 1). But it doesn't save perspectives, so that all the saved buffers open under a single perspective, when emacs is started. Is there any implementation that will achieve the saving of perspectives between emacs sessions?
desktop-save-mode is provided by package desktop which comes with emacs, it is not provided by perspective.el. Desktop mode can save and restore your buffers (with emacs 24.4 it can also save your windows and frames) but does not provide 'named window configurations'. Perhaps you can use bookmarks+ for this as #Drew suggests but I have never tried it.
The package perspectives does not provide a way save and load perspectives. See this issue. As an alternative I would like to suggest you the package workgroups2, it similar to perpective.el (it calls perspectives workgroups) and provides that feature you want.
This might be an alternative for you, depending on what you are looking for:
Starting with Emacs 24.4 (which will be released soon, and for which development snapshots are available), when you save an Emacs desktop (see desktop-save-mode and Bookmark+ desktop bookmarks), you can optionally save frame, window, and buffer states. Restoring a desktop then restores these as well (as far as possible).

How can I run a function periodically in a specific mode?

I am writing a report in LaTeX, and am using Emacs for development. Having to periodically compile manually is somewhat annoying. Is there a way to have Emacs automatically compile periodically whenever the current buffer is a LaTeX buffer?
flymake is built into Emacs, and is the classic way to do such things.
See its user-manual at: C-hig (flymake) RET
flycheck is a more recent project, with the stated aim of being "flymake done right".
Running arbitrary processes (e.g. compilation) periodically is what these libraries are all about, so either one of them suits your use-case.

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.