Emacs lisp source code for
.elc
files?e.g.
cal-mayan.elc
Files in the
/bin
directory?e.g.
cat
,split
, andecho

- 13,230
-
2@ixtmixiix this seems like 2 separate questions... why not actually make it 2 separate questions... plus getting the sources for X actually depends highly on what X is. – xenoterracide Sep 18 '10 at 20:42
-
2@xenoterracide I don't think so... – ixtmixilix Sep 19 '10 at 00:17
-
Check out this old question. – Emanuel Berg Jan 15 '13 at 23:25
3 Answers
It depends a bit on what distribution you use. On a debian style system you could do something like this:
$ dpkg -S `which cat`
coreutils: /bin/cat
$ apt-get source coreutils
The last command will fetch the source archive and all the patches which were used to build the binary package that includes the cat command.
Alternatively you could just google for it. Or use even google code search.

- 57,532
-
I do use Debian, and that's the answer I needed. I wanted a way that did not involve a google search, and that would work for anything on my harddrive. Thanks. – ixtmixilix Sep 19 '10 at 00:17
-
1Correct! Only one detail: For this to work, in
/etc/apt/sources.list
, say you havedeb http://ftp.de.debian.org/debian sid main contrib non-free
. If so, add the same line (i.e., duplicate it), only append a-src
suffix todeb
:deb-src http://ftp.de.debian.org/debian sid main contrib non-free
. (And, runsudo aptitude update
when done.) Then, invokeapt-get
just the way told in this answer. – Emanuel Berg Jan 15 '13 at 23:55
For Emacs however, there is a special packet called emacs23-el under Ubuntu which includes all el-files of Emacs and installs them alongside the elc-Files. This has the advantage, that you can directly look at function and variable definitions from Emacs. Say you want to look at how the function string-insert-rectangle is defined. You hit C-h f string-insert-rectangle and a Help buffer appears with documentation, telling that it is defined in rect.el. If you click on rect.el Emacs automatically shows the function definition.

- 8,790
-
Right! On Debian sid I have
emacs24-el
as well as the one you mentioned. – Emanuel Berg Jan 16 '13 at 00:24
For RPM-based distributions you can ask "rpm -qi <somepackage>", or even "rpm -qi <somefile>" if you don't know the original package. It will tell you what the source RPM is, and the home page for the source. On Fedora (and other distributions using yum) you can then get the source package using yumdownloader, e.g. "yumdownloader --source <package>" will fetch it for you. The rpm(1) command will then allow you to unpack the source (the source RPM package contains the upstream source, assorted patches, configuration files, and a spec file that directs the building and installing of the result).
This comes handy if you need to install a package with some kind of local modifications (perhaps just to check out the next upstream version).

- 18,253
-
One confusing thing is, I have that tool (
/usr/bin/rpm
) on Debian (which is not RPM-based but usesdpkg
) - but fortunately it doesn't work as you describe it (that would have been too confusing!). For example, it says I don't have thedia
package, which I do (and aptitude agrees). Is that tool a leftover, or is it something (slightly) different, only with the same name? – Emanuel Berg Jan 15 '13 at 23:37 -
My answer was completing the question for RPM-based distributions. Your Debian RPM is either a workalike or a tool for working with RPMs on Debian. Or something even more bizarre. I'd be very suprised if it worked for you ;-) – vonbrand Jan 16 '13 at 03:05