[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
where-are-we: find out the context when reading (any) source code
From: |
Haojun Bao |
Subject: |
where-are-we: find out the context when reading (any) source code |
Date: |
Wed, 18 Aug 2010 23:31:32 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
Hi, all
I have wrote a little lisp and a perl script to tell where I am when I'm
reading source code. The lisp code is short:
(defun where-are-we ()
(interactive)
(save-excursion
(end-of-line)
(shell-command-on-region
1 (point)
(concat "where-are-we "
(or (buffer-file-name) (buffer-name))
(format " %s" tab-width)))))
The perl script (also named where-are-we) is attached. When invoked on
the last line of the above lisp code, the output is like following:
/home/bhj/windows-config/.emacs:1005: (format " %s"
tab-width)))))
(defun where-are-we ()
...
(save-excursion
...
(shell-command-on-region
...
(concat "where-are-we "
...
=> (format " %s" tab-width)))))
Another example from reading Android source code:
/home/bhj/src/android/frameworks/base/libs/ui/EventHub.cpp:474:
outFlags[codeIndex] = 1;
/*
* Inspect the known devices to determine whether physical keys exist
for the given
* framework-domain key codes.
*/
bool EventHub::hasKeys(size_t numCodes, int32_t* keyCodes, uint8_t*
outFlags) {
for (size_t codeIndex = 0; codeIndex < numCodes; codeIndex++) {
...
for (int n = 0; (n < mFDCount) && (outFlags[codeIndex] == 0);
n++) {
if (mDevices[n]) {
...
if (!err) {
...
for (size_t sc = 0; sc < scanCodes.size(); sc++) {
if (test_bit(scanCodes[sc],
mDevices[n]->keyBitmask)) {
=> outFlags[codeIndex] = 1;
Supposedly this can be useful when reading source code and taking note,
even better if used with remember.el. That way, you can easily write a
scenario analysis about which function called which function and so
on...
Hope you can find it useful.
where-are-we
Description: Binary data
- where-are-we: find out the context when reading (any) source code,
Haojun Bao <=