Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
  1. Emacs lisp source code for .elc files?

    e.g. cal-mayan.elc

  2. Files in the /bin directory?

    e.g. cat, split, and echo

share|improve this question
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 0:17
    
Check out this old question. –  Emanuel Berg Jan 15 '13 at 23:25
add comment

3 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
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 0:17
1  
Correct! Only one detail: For this to work, in /etc/apt/sources.list, say you have deb 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 to deb: deb-src http://ftp.de.debian.org/debian sid main contrib non-free. (And, run sudo aptitude update when done.) Then, invoke apt-get just the way told in this answer. –  Emanuel Berg Jan 15 '13 at 23:55
add comment

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).

share|improve this answer
    
One confusing thing is, I have that tool (/usr/bin/rpm) on Debian (which is not RPM-based but uses dpkg) - but fortunately it doesn't work as you describe it (that would have been too confusing!). For example, it says I don't have the dia 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 3:05
add comment

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.

share|improve this answer
    
Right! On Debian sid I have emacs24-el as well as the one you mentioned. –  Emanuel Berg Jan 16 '13 at 0:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.