Core module source in coffeescript?


#1

I am looking at find-and-replace to steal some code. But there only seems to be the transpiled output in JS. Is there some way to see the source?

I have been using CS for 3 years and I find JS hard to read. Also it would be nice to cut/paste to my coffeescript.


#2

#3

I noticed this too, that some packages retain their coffee files, while others just publish the JS.
I know both is allowed and possible, but is there a preference / recommendation on this?


#4

Thanks. So they just don’t include the source in the published package.

While I have your attention …

I realized the find-and-replace type of tool-panel is not what I need. I need one inside an editor pane at the bottom. Does anyone know of an example package that does this? If I can’t steal the code I’m afraid it’s going to be a long haul for me to figure it out.


#5

I have one. Publish the damn source!


#6

I’m not quite sure what you mean. Do you mean inside the pane, but not tied to the particular tab?


#7

I suppose it depends on what you mean by “published” … to me, the GitHub repo is the published source.


#8

To my knowledge, all packages publish their source, whether the package is developed in CoffeeScript or JavaScript is up to the package developer. There is no recommendation or preference that pushes people towards a particular choice. As a matter of fact, it is in the FAQ that the Atom team is on record as wanting to support both.


#9

I have to be careful what words I use. According to the docs the container for all the tabs is a pane. The docs also say the editor manages all the buffers. So I will use my own language for describing what I mean.

I need a tool pane (there’s that word again) like the find-and-replace tool pane. But it should only be attached to one tab. It should be inside the area that surrounds the text to be edited. But it should be at the bottom so the bottom of the text editing area is pushed up. Does that make sense?

BTW, I found an old post asking the same question (Adding panes to the current tab (EditorView)) and I replied.


#10

I think the interesting thing about find-and-replace is that it seems to be developed in coffeescript, but they went through the trouble of pre-compiling it before shipping it with atom, even though that’s not technically necessary.

So I suppose that was a bit confusing.


#11

If you’re talking about the built-in packages … they’re all transpiled when they’re installed alongside Atom:

[master][~/Source/atom] ll /Applications/Atom.app/Contents/Resources/app/node_modules/whitespace/lib
total 24
-rw-r--r--  1 Lee  admin   555B Jul 25 21:40 main.js
-rw-r--r--  1 Lee  admin   5.5K Jul 25 21:40 whitespace.js
[master][~/Source/atom] ll /Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib
total 192
-rw-r--r--  1 Lee  admin   3.0K Jul 25 21:40 buffer-patch.js
-rw-r--r--  1 Lee  admin   1.0K Jul 25 21:40 helpers.js
-rw-r--r--  1 Lee  admin   4.3K Jul 25 21:40 history.js
-rw-r--r--  1 Lee  admin   7.7K Jul 25 21:40 marker-manager.js
-rw-r--r--  1 Lee  admin   1.8K Jul 25 21:40 marker-patch.js
-rw-r--r--  1 Lee  admin    16K Jul 25 21:40 marker.js
-rw-r--r--  1 Lee  admin   3.1K Jul 25 21:40 point.js
-rw-r--r--  1 Lee  admin   6.6K Jul 25 21:40 range.js
-rw-r--r--  1 Lee  admin    31K Jul 25 21:40 text-buffer.js
-rw-r--r--  1 Lee  admin   2.1K Jul 25 21:40 transaction.js
[master][~/Source/atom] ll /Applications/Atom.app/Contents/Resources/app/node_modules/status-bar/lib
total 56
-rw-r--r--  1 Lee  admin   1.8K Jul 25 21:40 cursor-position-view.js
-rw-r--r--  1 Lee  admin   917B Jul 25 21:40 dev-mode-view.js
-rw-r--r--  1 Lee  admin   3.0K Jul 25 21:40 file-info-view.js
-rw-r--r--  1 Lee  admin   6.4K Jul 25 21:40 git-view.js
-rw-r--r--  1 Lee  admin   3.9K Jul 25 21:40 status-bar-view.js
-rw-r--r--  1 Lee  admin   1.4K Jul 25 21:40 status-bar.js

But that’s like looking at Chrome.exe and wondering why it isn’t available in C++ source code. You’re looking at the “built” version of the application. If you want the source, you should go to the repository.

As for why it’s transpiled beforehand, I’m certain that is a performance thing.


#12

Not true for all of them though.

If you use the “Open in Atom” button for packages in the Settings View, you get some with only coffee files, some with only JS.

I haven’t come across any that have both, yet.

Example: The popular autocomplete-plus package:

Edit: I just noticed you referred to built-in packages specifically. And yea I haven’t found one of those that isn’t all javasript.
It seems only the non-core packages that get installed after atom, seem to often still have the coffee files.


#13

Built-in packages aren’t installed in the same manner as manually installed packages. The built-in ones are compiled as part of the actual build process. (Compile from source to verify this for yourself.)


#14

Yea that makes sense.
And now that I think of it, I do build the latest releases usually and I have seen the coffee compile tasks. I just didn’t make the connection.

I am a fan of the Open In Atom feature inside the settings view. Maybe that could be enhanced to allow people to download the repo instead of opening the local version of the package.


#15

I have been using

apm develop <package_name>

This will work for find-and-replace and the rest of the default. This gives you nice coffee and links everything very nicely. Probably one of my favorite features of Atom. The docs below should mention atom -d IMO (I use that instead)

apm help develop

Usage: apm develop <package_name> []

Clone the given package’s Git repository to the directory specified,
install its dependencies, and link it for development to
~/.atom/dev/packages/<package_name>.

If no directory is specified then the repository is cloned to
~/github/<package_name>. The default folder to clone packages into can
be overridden using the ATOM_REPOS_HOME environment variable.

Once this command completes you can open a dev window from atom using
cmd-shift-o to run the package out of the newly cloned repository.

Options:
–help, -h Print this usage message