I'm not sure wether cask really rewrites the Cask file, cause I have two (independent) installations, that both have missing entries in the Cask-file that are nevertheless installed in the .cask
folder.
Since I'm not really an elisp hacker (but try to become one), for now I only have a tcl script that writes out a Cask files that mirrors the current installed packages.
#!/usr/bin/env tclsh
#
# get-installed-cask ?cask-archive?
# print out a Cask-file with all currently installed packages
if {[llength $argv] > 0} {
cd [lindex $argv 0]
}
set names [exec find elpa/ -maxdepth 1 -type d]
proc getName {fn} {
set sub ""
regexp {elpa/(.*)-[01-9.]+} $fn all sub
return $sub
}
foreach name $names {
set name [string trim $name]
set new [getName $name]
switch $new {
"" -
"archives" -
"gnupg" {
; # nothing
}
default {
lappend result $new
}
}
}
set result [lsort -dictionary $result]
puts "(source gnu)
(source melpa)
(source org)
"
foreach name $result {
puts "(depends-on \"$name\")"
}
Call it with the cask-archive directory that you want to enumerate:
get-installed-cask ~/.emacs.d/.cask/24.5.1/
Simply use diff (meld or ...) to see the differences.
And BTW: change the hardcoded list of repositories to suite your installation.