I can't make Yasnippets work (normal version).
When I start Emacs it says:
error: Error ~/.emacs.d/plugins/yasnippet-0.6.1c/snippets/ not a directory
I added this to my .emacs file:
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/.emacs.d/plugins/yasnippet-0.6.1c/snippets/")
and my yasnippets files are placed in the following folders:
D:\Program Files\emacs-23.1\site-lisp\plugins\yasnippet-0.6.1c
and the snippets:
D:\Program Files\emacs-23.1\site-lisp\plugins\yasnippet-0.6.1c\snippets
All others plugins work so I'm sure its the right load-path
Help!
Perhaps you could write the whole path, instead of a relative one, like this:
add-to-list 'load-path
"D:/Program Files/emacs-23.1/site-lisp/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "D:/Program Files/emacs-23.1/site-lisp/plugins/yasnippet-0.6.1c/snippets")
Notice the forward slashes, and please make sure that emacs doesn't mind the spaces... Windows is less forgiving than Linux with these kinds of paths. Also, make sure your emacs install reads that dir. Usually, you should put an emacs dir where your .emacs is (in Windows), that makes it more clear. It
Another thing: 1) maybe you're trying your snippet in the wrong mode. Make sure there is a snippet for the mode you're in.
See here as well, lots of info here: GNU Emacs for Windows
Related
I want to solve my “.emacs bankruptcy” issue, and I've gone through
https://help.ubuntu.com/community/EmacsHowto
http://www.emacswiki.org/emacs/DotEmacsBankruptcy
http://www.emacswiki.org/emacs/DotEmacsDotD
http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html
and it is still unclear to me whether the .emacs.d folder is the solution. I.e., whether it will behave just like a normal .d folder, e.g., /etc/profile.d/, where you drop you scripts and they will be picked up by the system auto-magically. Please confirm.
If not, can someone give me a script that does that, or give me a solution please?
Thanks
The essential content of my ~/.emacs file is:
(require 'cl)
(loop for src in (directory-files "~/.emacs.d" 'full-path "[0-9].*\\.el$") do
(let ((byte (concat src "c")))
(when (file-newer-than-file-p src byte)
(byte-compile-file src))
(message "Loading %s.elc" byte)
(load-file byte)))
It loads configuration files from ~/.emacs.d which start with a number. If the source file (extension .el) is newer than the byte-compiled version (extension .elc) then it byte-compiles the source. Afterwards it loads the byte compiled file.
Here's my ~/.emacs:
;; base dirs
(defvar dropbox.d "~/Dropbox/")
(defvar emacs.d (concat dropbox.d "source/site-lisp/"))
;; load path
(add-to-list 'load-path emacs.d)
(defun add-subdirs-to-load-path (dir)
(let ((default-directory dir))
(normal-top-level-add-subdirs-to-load-path)))
(add-subdirs-to-load-path emacs.d)
(load "init")
All my other scripts are loaded by ~/Dropbox/source/site-lisp/init.el
and are themselves located in ~/Dropbox/source/site-lisp.
That's how I have the same config on multiple machines.
And here's how .../site-lisp/hooks.el is loaded from init.el:
(load "hooks")
My init.el is about 100 lines, .emacs about 20 lines.
The rest 8000 lines of scripts are sliced into around 20 files.
~/.emacs.d/ does not work like /etc/profile.d/ or /etc/modules-load.d/ or similar directories, i.e. Emacs does not automatically load any Emacs Lisp file in this directory.
In fact, Emacs explicitly advises against placing Emacs Lisp libraries in ~/.emacs.d/. The byte compiler emits a warning if you add ~/.emacs.d/ to the load-path.
Instead, create a new sub-directory, e.g. ~/.emacs.d/lisp. Add this directory to your load-path explicitly, with the following code in init.el:
(add-to-list 'load-path (locate-user-emacs-file "lisp"))
Then, place your Emacs Lisp files in this directory, e.g. ~/.emacs.d/lisp/foo.el, and load them in your init.el:
(load "foo" nil 'no-message)
The best approach to avoid the dreaded .emacs bankruptcy is to actually avoid large customizations! Most notably, try to avoid any custom functions and commands.
Instead, try to a find an ELPA package that comes closest to what you want, and either try to get used to it, or customize it to your needs. If you don't find any, first try to write your own and distribute it on Github, Marmalade or MELPA.
Don't be afraid of maintaining a package in the public. You'll have to maintain your customization anyway, whether in your init.el or not, so you can just as well let other Emacs users help you with this job.
Adding code to your init.el should be your very last resort!
I receive this message every time I start emacs
Emacs 24.2
Win7 64 and Ubuntu 12.10
yasnippet 0.8.0 installed with package-list
If there is a way to fix it ?
yasnippet doesn't get initialised automatically when installed with elpa, which I find unconventional. You still need to add the yasnippet directory into your load-path.
Here is my set up in my .emacs
;; yasnippet
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(require 'yasnippet)
(setq yas-snippet-dirs '("~/.emacs.d/elpa/yasnippet-0.8.0/snippets" "~/Dropbox/Applications/Customise/emacs/myyassnipets"))
(yas-global-mode 1)
This is the sort of message I would expect to see if you're calling load or load-file in your init.el with a bad path. Look for any uses of those functions and correct the path if you can.
If this is in code you control, you probably want to call (require 'yasnippet) instead of directly loading the file.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Emacs 24 Package System Initialization Problems
I am using Emacs 24. I have the ELPA and Marmalade repos added. Using 'package' I installed 'auto-complete'. I have the following lines added to my init.el:
(require 'auto-complete-config)
(ac-config-default)
When I start Emacs, I get the error
File error: Cannot open load file, auto-complete-config
But then I use
M-x load-file
and load the same ~/.emacs.d/init.el file, it then works fine with the prompt saying
Loading /home/user/.emacs.d/init.el (source)...done
How is the usual loading different from the 'M-x load-file' command? In the start of the init.el file I do the following, is this somehow effecting the package from loading.
(add-to-list 'load-path "~/.emacs.d")
(load "custom_code")
As mentioned in the comment below: The answer by phils to the duplicate question is probably more helpful than this one
This almost certainly means that your init.el file is getting run before the code that sorts out the packages for package.el. The latter code adds the directory with the auto-complete library to your load path.
I'm still using ELPA, rather than package.el. With elpa, there's a snippet that looks like this that gets installed at the bottom of your .emacs.
;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
As the comment suggests, you probably want to put your equivalent package.el initialization code before the stuff that loads init.el.
Finally: I notice you mention adding .emacs.d to your load-path. The Emacs load path is not recursive, so that probably won't do what you need (assuming that your libraries live in subdirectories). Years ago, I wrote this snippet to load up various libraries of elisp code that I'd written. You might find it useful. (Obviously, it'll only work on unixy systems with a shell and a find command. It's reasonably slow, but this seems to be shell-command-to-string, which takes several milliseconds even running "echo hello" or the like)
(defun find-elisp-dirs (dir)
"Find all directories below DIR containing elisp sources, ignoring those"
(split-string
(shell-command-to-string
(format "find %s -iname '*.el' -printf '%%h\\n' | sort -u"
(expand-file-name dir t)))))
I use Emacs as an editor. Of late whenever I use CUDA files (which usually have extensions .cu) I have to manually do M-x c++-mode to turn on syntax highlighting and other yasnippet features.
How do I do I ensure that all .cu files when started in EMACS automatically borrow all the C++ mode features. In other words .cu extension becomes an alias for .cpp extension.
( I know there is a CUDA mode for EMACS, (not inbuilt) but when I installed this mode it does not turn on many of the useful features present in the C++-mode of emacs )
Putting this into your .emacs should do the trick:
(add-to-list 'auto-mode-alist '("\\.cu\\'" . c++-mode))
Just in case people have missed it; there's a slightly more official cuda-mode available: http://www.emacswiki.org/emacs/CudaMode
You need to put it somewhere in your load-path; for example on my Mac, I put the code in $HOME/Library/emacs/cuda-mode.el and added the following lines to my .emacs file.
(add-to-list 'load-path "~/Library/emacs")
(autoload 'cuda-mode "cuda-mode.el")
(add-to-list 'auto-mode-alist '("\\.cu\\'" . cuda-mode))
I'm trying to use slime from CVS (2009-01-05) but keep getting this error:
LOAD: A file with name
/usr/share/common-lisp/source/slime/swank-loader.lisp does not exist
I've stripped my .emacs down to just:
(setq inferior-lisp-program "/usr/bin/clisp")
(add-to-list 'load-path "/home/ssm/lisp/slime/")
(require 'slime)
(slime-setup)
I've deleted my ~/.slime directory, started with 'emacs -q' and eval'd the above code but I keep getting the LOAD error when I run slime (via M-x slime). Any ideas on how to fix this error?
FWIW, I've tried to install slime via apt-get but I keep getting errors there too about cl-swank being broken. That's a whole different story.
Have you purged the slime pkg you installed via apt-get? It looks like emacs is still reading the old site-specific configuration setup by apt-get. Try starting emacs with the -Q option, which prevents loading of site-specific (as well as user specific) customization, and see if the problem still occur.
I agree with huaiyuan that older files may be being picked up.
Try (load-file "/path/to/slime.el") instead of require. (You did remove the .elc files from your old versions, right? emacs will load from .elc files in preference to .el files, even when the .el is newer.)
The next thing to try is M-x customize-variable slime-backend and setting that to the absolute path of swank-loader.lisp. I think that will fix it for sure, but I am not sure why it doesn't work to begin with.
Thanks guys, ~/.emacs:
(setq inferior-lisp-program "<path-to-lisp-compiler>/bin/lisp")
(setq slime-backend "<path-to-slime>/swank-loader.lisp")
(add-to-list 'load-path "<path-to-slime>/")
;;(require 'slime)
(load-file "<path-to-slime>/slime.el")
;;(slime-setup)
(slime-setup '(slime-fancy))
works :)