Fold name without date for emacs package installation - emacs

I noticed that when I install a package for emacs, it is usually installed in a fold with a dated name, as an indicator for its version
e.g.
~/emacs.d/plugins/yasnippet-20130218.2229...
that is super ugly, when i try to update it, what emacs does is: uninstall the one with older date and install the one with newer date.it also cause very much inconvenience for configurations. e.g., i have to setup the path for my snippet as:
(setq yas/snippet-dirs "~/emacs.d/plugins/yasnippet-20130218.2229/snippets")
that means everytime i upgrade my yasnippet, i have to change my configuration....
is there a way to install package without dated fold name? and the version information is saved in smarter way?
thanks!

Not sure you can avoid the versioning on the folder names. That seems to be used by package.el for dependencies.
For your setup, you could work around it with something like
(setq yas/snippet-dirs
(concat (file-name-as-directory
(car (directory-files package-user-dir t "yasnippet")))
"snippets"))

Related

Is there a way to display the version numbers for each package I have installed into my emacs?

The question pretty much says it all. I wish to know which version I have installed. If I look at the directories in my elpa folder I just see a date.
The value in the directory name next to the package name is the version of the package. If you are seeing dates, then you have installed packages from a package repository which uses dates as versions. (That would probably be melpa.)
If you want something different, you will need to use a package repository with a saner version policy. melpa-stable is an option.
List all packages available:
M-x package-list-packages
Although you can only filter by keyword, you could use this workaround to list only installed packages:
(defun installed-packages ()
(interactive)
(list-packages t)
(read-only-mode -1)
(delete-non-matching-lines " installed ")
(read-only-mode 1))

emacs el-get does not load packages

Using Emacs 24.3 on OS X, I have setup el-get as described. I am able to install, remove, and init packages using the el-get-* commands.
However, none of the packages ever actually load. The simple example I use is for the package 'ascii-table'. I do the following:
M-x el-get-install ascii-table
M-x el-get-init ascii-table
But when I do
M-x ascii-table
Emacs says it is not found. If I explicitly eval the ascii-table.el file that was downloaded by el-get, it works as expected.
Is there something I must do, after installing a package, to actually use the package? Or do I still need to put the necessary load-file or whatever in my init.el file to load the packages?
It sounds like, from the el-get documentation, that there was nothing else that needed to be done.
You can instruct el-get to require features from a package by adding the property features to the package's recipe file. From the documentation (do C-hvel-get-sourcesRET)
:features
List of features el-get will `require' for you.
For your particular case do M-xel-get-find-recipe-fileRETascii-tableRET, this open ascii-table's recipe file for you, then add the following to the recipe
:features (ascii-table)
The full recipe will be
(:name ascii-table
:auto-generated t
:type emacswiki
:description "simple ASCII table"
:website "https://raw.github.com/emacsmirror/emacswiki.org/master/ascii-table.el"
:features (ascii-table))
My advice would be not edit the original recipe but keep this in your personal recipes folder to avoid any conflicts when updating el-get.
That said you can always manually load a package, see #Drew's comment
Is el-get supposed to load libraries? I doubt it.
To load a library, put (require 'FEATURE-NAME) in your init file, where FEATURE is the feature provided by the library. If it does not provide any feature, then use the file name instead (between " chars).

How to install gtk-cffi in Windows?

gtk-cffi is a Lisp binding of GTK+3. I'm trying to install it on Windows.
At first I tried Quicklisp but it didn't have it (there is gtk-cffi-utils, but it didn't help at all). I want to install it from scratch but I don't know what to do...
Is there anybody who can give me some advice?
Looking at the page for gtk-cffi, I see that it depends on:
CFFI
Alexandria
Iterate
cl-cairo2
I believe these are all available through quicklisp, so I am going to assume that you can get all of them.
Looks like for gtk-cffi there are no official releases, and you have to pull it from CVS. So if you were to checkout the gtk-cffi repository to some directory, say "c:/gtk-cffi", it should be possible for you to start up lisp, make sure that ASDF can load quicklisp systems (including the above dependencies), do:
(push "c:/gtk-cffi/" asdf:*central-registry*) ;; change the pathname as needed, but be sure to end with "/"
(asdf:load-system "gtk-cffi")

How to save a list of all the installed packages in Emacs 24?

I am using prelude as a base Emacs configuration.
I have installed lots of packages from the package manager, and I want to use my settings on another machine.
I don't want to carry the installed packages and also I don't want to create a list manually.
What is the way of saving a list all the installed packages into prelude-package.el or any other file so that when I take this configuration to my other machine, they automatically get installed there on first use?
You can get a list of currently installed packages (excluding built in packages) from the variable package-activated-list. To automatically install them on startup, see this question: how to automatically install emacs packages by specifying a list of package names?
More specifically, if you do C-h v package-activated-list, copy the value shown, and insert it as the value of prelude-packages, emacs will automatically ensure those packages are installed on start up.
The canonical method is the best (described by ataylor). Here is a more clumsy method.
M-x list-packages. C-s installed till you find the first row of installed package. Start selecting with C-SPC. Go down till you reach built-in packages. Copy with M-w. C-x b for new buffer. Paste with C-y.C-x C-s to save file.
The only advantage that I see is this is a tad more descriptive — it shows a short description of your packages; which is useful when you install some packages and forget about them.
As mentioned at how to automatically install emacs packages by specifying a list of package names?, it would be better to also record the version of the package you need. In order to do so, you can use the following function:
(defun list-packages-and-versions ()
"Returns a list of all installed packages and their versions"
(mapcar
(lambda (pkg)
`(,pkg ,(package-desc-version
(cadr (assq pkg package-alist)))))
package-activated-list))
That will give you a list of (NAME VERSION) pairs. Unfortunately, I haven't been able to find a way to install a specific version of a package. It seems package.el always grabs the latest available. What I'm doing now is:
(defun install-packages-with-specific-versions (package-version-list)
"Install the packages in the given list with specific versions.
PACKAGE-VERSION-LIST should be a list of (NAME VERSION) lists,
where NAME is a symbol identifying the package and VERSION is
the minimum version to install."
(package-download-transaction
(package-compute-transaction () package-version-list)))
I've written a longer function to install packages matching the exact version number, but it fails because package.el by default only retrieves the latest versions available for each package. gist
As described above, using emacs normal mode. Here another the evil-mode way of doing it:
M-x list-packages; /installed (they will be highlighted); v (for visual-mode); j (to select them); y (to copy them); open a new buffer and paste them.

el-get in a portable emacs configuration solution

el-get goes a long way in helping achieve a portable emacs configuration setup. The idea is to declare the packages you want in the emacs config file, push that file to a repo, and pull it on all the computers where you want an identical emacs configuration. This is how the code might look in elisp:
(setq my-packages (append '(el-get switch-window yasnippet ...)
(mapcar 'el-get-source-name el-get-sources)))
(el-get 'sync my-packages)
el-get will make sure that the packages get automatically installed and properly initialized. However, my understanding is that when you dereference a package, it doesn't get uninstalled. And if you uninstall it manually, you'll have to do it across all the computers, also manually. In other words, el-get goes only half the way in achieving a truly portable solution. My question is if anybody has written elisp code that will uninstall the packages just by dereferencing them in init.el? Or whether I should look elsewhere for a fully portable declarative dependency management solution for emacs?
I'm answering myself here because in the end I opted for an alternate solution.
phils' answer is still valid, but I found it troublesome to have the .emacs.d directory under version control, and to be fair I didn't want to bother with fake submodules.
What I did instead: I contacted el-get's maintainer, Dimitri, and presented him with the problem.
Dimitri said:
I could see us adding an el-get-cleanup function that you would have to call with the current list of packages and that would el-get-remove any package already installed locally but not on the provided list.
(el-get-cleanup my-packages)
You could then use that from your user-init-file if you want to, or do
that as a routine every now and then.
With his guidance, I then wrote the function in question.
(defun el-get-cleanup (packages)
"Remove packages not explicitly declared"
(let* ((packages-to-keep (el-get-dependencies (mapcar 'el-get-as-symbol packages)))
(packages-to-remove (set-difference (mapcar 'el-get-as-symbol
(el-get-list-package-names-with-status
"installed")) packages-to-keep)))
(mapc 'el-get-remove packages-to-remove)))
Ah, the joys of open source...
(See also my blog post)
You should use el-get in conjunction with some form of version control. That provides the portability, so that when you remove a package and commit the result to your repository, the package will also be uninstalled for the other instances once they have pulled those changes.
If you are leaving the package files to el-get to manage, then those files may still exist on the other copies after the package is removed from one instance but, provided that el-get's status and autoload files are in your repo, I think the state of each package should be correct.
Personally, I recommend committing all files to your repository after installing a package. That way when you remove a package, commit the changes, and pull those changes from another instance, both copies are in the same state.
Moreover, I would never trust the availability, consistency, or permanence of a remote source when it comes to setting up a new instance of my Emacs configuration -- the act of cloning my repository is all that should be required to obtain a working system.
So: use el-get for installing and updating packages, and use version control to make it portable.