Weird generated files from Emacs - emacs

I find that there are a lot of files like the one below generated by Emacs. What are those files ? And is there anyone that I can put them in one place and stop hanging around in the project ?
app/helpers/#application_helper.rb#
Thanks

These files are automatically saved versions of files edited by Emacs. You can tell Emacs to put all auto-save files and all backup files (those ending on ~) in one place by adding this to your .emacs or .emacs.d/init.el file:
(setq backup-directory-alist
`((".*" . ,(expand-file-name
(concat user-emacs-directory "backups"))))
(setq auto-save-file-name-transforms
`((".*" ,(expand-file-name
(concat user-emacs-directory "backups") t)))
This will set the directory to be ~/.emacs.d/backups/. Another common thing to do is setting the directory to the temp directory:
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
Alternatively, you could completely disable auto-saving but this is not recommended.
EDIT: I just found this related question with lots of advice on how to configure this behaviour: How do I control how Emacs makes backup files?

Related

How to configure erlang mode in emacs?

OK, I create a .emacs file in the path where I install erlang.
(setq load-path (cons "/usr/lib64/erlang/lib/tools-2.7.1/emacs"
load-path))
(setq erlang-root-dir "/usr/lib64/erlang")
(setq exec-path (cons "/usr/lib64/erlang/bin" exec-path))
(require 'erlang-start)
/usr/lib64 is the folder where I installed erlang. But it doesn't work. On the other hand I use this command:
yum install emacs-erlang.
Then /usr/share/emacs/site-emacs/sit-start.d will have a file named erlang-init.el. And the content in this file is:
(setq load-path (cons "/usr/share/emacs/site-lisp/erlang" load-path))
(setq erlang-root-dir "/usr/lib/erlang")
(setq exec-path (cons "/usr/lib/erlang/bin" exec-path))
(require 'erlang-start)
By this way, emacs can work in erlang-mode.
I feel it is strange, because I feel the erlang-init.el is wrong but the .emacs is right.
But why in fact .emacs can't work rightly?
My OS is fedora 21 and emacs version is 24.4
OK, I create a .emacs file in the path where I install erlang.
That's not going to do anything unless that path happens to be your $HOME directory.
Emacs loads ~/.emacs -- not any file by that name in any arbitrary directory you happen to put it in. (How would Emacs know it was there?!)
The package-managed file is no doubt being loaded because your system's emacs package has configured a site-start.el file which loads libraries in /usr/share/emacs/site-emacs/sit-start.d/
See: C-hig (emacs) Init File RET

Is this a proper Emacs (24.3.2) lisp style to load user .el files from .emacs?

I have several .el files within my "~/.emacs.d" directory and I added the following lines to my .emacs file to load them at startup:
(let ((base "~/.emacs.d/")
(files '("user.el" "erlang.el" "sbcl-slime.el"))
(bfload (lambda (file) (load (expand-file-name (concat base file))))))
(mapcar bfload files))
It works, but is this proper Emacs Lisp style? How can this be improved, please?
First, don't put your .el files directly into ~/.emacs.d (Emacs puts various files in there, and they're not expected to be Elisp packages). You can put them into ~/.emacs.d/pkgs for example, instead.
How 'bout:
(dolist (file '("user.el" "erlang.el" "sbcl-slime.el"))
(load (expand-file-name file "~/.emacs.d/pkgs"))
You can mix Stefan's excellent suggestions of moving those files to a separate directory with init-loader https://github.com/emacs-jp/init-loader
You will have a couple of extra perks (auto byte-compiling the files) and you won't need to maintain the file list (just move/create a file in that directory).
Based on Stefan's example, I only add a file-exists-p:
(dolist (file '("user.el" "erlang.el" "sbcl-slime.el"))
(let ((f (expand-file-name file "~/.emacs.d/pkgs")))
(if (file-exists-p f)
(load f))))
I think, this is the version I will use.

Plugin in Emacs

I'm trying to install lua-mode into emacs for windows but nothing seems to be working. I've set my HOME environment variable. I've added init.el and lua-mode.el to the HOME\.emacs.d directory. Then I've added the following code to init.el:
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
(add-hook 'lua-mode-hook 'turn-on-font-lock)
Nothing is working when I start up emacs and load a .lua file. The major mode is always set to fundamental and there are no other options to change to. What can I do to get this working?
It's possible that your init.el is never read, because you also have a .emacs file (or .emacs.el) in your $HOME directory. You can choose between those three alternatives for Emacs' init file, but only one of them will be read. Traditionally, that's .emacs but some operating systems have problems with that filename syntax.
Also, make sure that you placed init.el in your actual home directory, not a directory called "HOME" or something.
See here for further details on Emacs init files and here for more info on home directories.
If you're not keen on using the init.el variant, here are instruction that should make lua-mode work for you using .emacs:
Start a new Emacs
Type C-x C-f ~/.emacs <ENTER> (C-x means press CTRL, hold it, press x, release - same for C-f)
Insert the following lines:
(add-to-list 'load-path "/path/to/lua-mode-dir")
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
(add-hook 'lua-mode-hook 'turn-on-font-lock)
Type C-x C-s to save the buffer to file
Type C-x C-c to close Emacs
Note that in step 3 you have to adjust "/path/to/lua-mode-dir" with the actual path to the directory where you saved the file lua-mode.el on your hard disk.
maybe you need something like (require 'lua-mode) or something like that? Also make sure that the lua-mode file is in a directory in your load-path variable. Something like this before anything else:
(add-to-list 'load-path "/home/dervin/.emacs.d/site-lisp/")
or wherever, and then the require-
The lines look OK. This can depend on a number of things:
The init.el file is not loaded at startup. In face, this is a non-standard name when it comes to Emacs. Emacs tries to load the files ~/.emacs, ~/emacs.el, and ~/.emacs.d/init.el in order, and will load the first one found. To verify that you file has loaded, you could add (message "Loading my init.el") inside it and check the *Messages* buffer.
The directory where you stored the file lua-mode.el is not in the load path. In fact, the ~/.emacs.d directory is not part of the standard load path.

Problem installing Auto-Complete plugin in Emacs

I downloaded Auto-Complete from here: http://github.com/m2ym/auto-complete/downloads, I placed all the files from the .zip file in my load-path (C:\...Application Data\.emacs.d\plugins\auto-complete-1.0), and added the following to my .emacs:
;; load auto complete
(add-to-list 'load-path "~/.emacs.d/plugins/auto-complete-1.0")
(require 'auto-complete)
(global-auto-complete-mode t)
but an error message shows up:
.emacs:53:1:Error: Cannot open load file: auto-complete
I use a trailing '/' with directory names (as per file-name-as-directory). e.g.:
(add-to-list 'load-path (file-name-as-directory
(expand-file-name "~/.emacs.d/plugins/auto-complete-1.0")))
I rather doubt that's actually an issue, though.
Are your permissions appropriate for those files and directories?
Are you sure that ~ really expands to C:\...Application Data? Do C-x d ~ RET to be sure.

Emacs: Where to put the psvn.el file?

I am totally new to emacs and is starting to learn how to use it effectively.
The first thing I wanna use is the svn mode.
I downloaded psvn.el and put it in the ~/.emacs.d directory
Then following the instruction in the comment part of the psvn.el file, I put this line
(require 'psvn)
Into the .emacs file
This is my current .emacs file
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(inhibit-startup-screen t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(require 'psvn)
Now when I starts emacs, I got this error message:
An error has occurred while loading `/home/akong/.emacs':
File error: "Cannot open load file", "psvn"
To ensure normal operation, you should investigate the cause
of the error in your initialization file and remove it. Start
Emacs with the `--debug-init' option to view a complete error
backtrace
Did I put the psvn.el in a wrong location?
I am using cygwin + WinXP
This is because Emacs cannot find any file providing psvn on its load-path.
In your shell:
mkdir -p ~/.emacs.d # Make the directory unless it exists
mv /some/path/psvn.el ~/.emacs.d/ # Move psvn.el into that directory
In your Emacs init file (often ~/.emacs):
(add-to-list 'load-path "~/.emacs.d") ; Add this directory to Emacs' load path
(require 'psvn) ; Load psvn
EDIT: I just realized that you are on Windows XP. I'm not sure how Cygwin will handle all of this, but the procedure is pretty much the same outside of Cygwin, just remember that ~ is %APPDATA% on Windows XP, so .emacs.d and .emacs should both be in that directory.
I guess you have problem finding your home directory on Windows? Try C-x d ~ RETURN (run dired on your home directory) to see where you home directory is, then do what the other answers say: put psvn.el in .emacs.d and add ~/.emacs.d in your load-path
First thing you're going to want to do is add .emacs.d to your load path so it knows where to look. Generally most people store .el plugins in ~/.emacs.d/site-lisp so i do this:
;; >>> Configure Load Path <<< ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq emacs-config-path "~/.emacs.d/")
(setq base-lisp-path "~/.emacs.d/site-lisp/")
(setq site-lisp-path (concat emacs-config-path "/site-lisp"))
(defun add-path (p)
(add-to-list 'load-path (concat base-lisp-path p)))
;; I should really just do this recursively.
(add-path "")
;; (add-path "some-nested-folder")
Now (require 'psvn) should work out fine.