Hi,
I love the way TextMate allows me to catch errors from the output and
make them clickable, so that I can quickly correct them.
But I think this process can be improved even more with two requests:
- Allow for multi-line captures: (pdf)latex produces quite verbose
errormessages that almost always are on two lines. I haven't been able to
get TextMate to catch both lines and let me see it back in the overview.
- If TextMate could also jump to the place in the output where the error
was produced, it would be great, because context is often important in
finding the cause of the error and it's very hard to define regexps to
grasp all those things.
Thanks,
Jeroen.
Command purpose: Do a reasonably valiant attempt to locate all senders
of a particular message/method within the project.
Usage: Highlight the method name, excluding the parameter portion of
the method signature, and execute this command. It will search across
all source in your project and return a clickable list of method
invocations. It doesn't work perfectly, but it often works very
satisfactorily. Example, you would like to find all the places where
public void handleRequest(HttpServletRequest request,
HttpServletResponse response) is used, simply highlight handleRequest
and execute the command which will bring up a window with links to
these occurrences.
Command:
grep -rn "\.$TM_SELECTED_TEXT(" $TM_PROJECT_DIRECTORY | grep "\.java"
Standard Input: None
Standard Ouput: Show in separate window
Pattern: ^.*\/(\w+\.java):(\d+):.*
Format string: $1 $2
File register: 1 Line: 2
Command purpose: Do a reasonably good job of finding all declarations
of a particular method within the project.
Usage: Same as above.
Command:
grep -rn "[ ]$TM_SELECTED_TEXT(" $TM_PROJECT_DIRECTORY | grep "\.java"
Standard Input: None
Standard Ouput: Show in separate window
Pattern: ^.*\/(\w+\.java):(\d+):.*
Format string: $1 $2
File register: 1 Line: 2
Command purpose: Do a reasonably good job of finding a class definition
within the project.
Usage: Same as above, but highlight the class name. Example,
Dispatcher d = new DispatcherServlet();, highlight DispatcherServlet
and execute the command. This will bring up a window with clickable
links to each declaration found.
Command:
egrep -rns "class[ ]+$TM_SELECTED_TEXT[ ]+" $TM_PROJECT_DIRECTORY |
grep "\.java"
Standard Input: None
Standard Ouput: Show in separate window
Pattern: ^.*\/(\w+\.java):(\d+):.*
Format string: $1 $2
File register: 1 Line: 2
Command purpose: Do a reasonably good job of finding an interface
definition within the project.
Usage: Same as above, but highlight the class name. Example,
Dispatcher d = new DispatcherServlet();, highlight Dispatcher (assuming
it is an interface) and execute the command. This will bring up a
window with clickable links to each declaration found.
Command:
egrep -rns "interface[ ]+$TM_SELECTED_TEXT[ ]+" $TM_PROJECT_DIRECTORY |
grep "\.java"
Standard Input: None
Standard Ouput: Show in separate window
Pattern: ^.*\/(\w+\.java):(\d+):.*
Format string: $1 $2
File register: 1 Line: 2
Command purpose: Open a window listing all the methods found in a
particular class. assuming the class containing the method definitions
exists in the project.
Usage: Highlight the class name for which you would like to search,
then execute the command. This will bring up a window, no links sorry,
that lists the method signature for each of the methods local to that
class, i.e., non-inherited methods. I find this useful when I quickly
want to find what methods are available without having to search for
the file or read documentation.
cat `egrep -rnsl "class[ ]+$TM_SELECTED_TEXT[ ]+" .` | egrep "public[
]+\<.*\>[ ]+\<.*\>\(.*\)[ ]+(throws .*|){"
Standard Input: None
Standard Ouput: Show in separate window
Pattern: ^.*\/(\w+\.java):(\d+):.*
Format string: $1 $2
File register: 1 Line: 2
Enjoy,
Lang Riley
Below are some useful java snippets and their explanations that I
created. I will try to take the time later to add them to the wiki:
Snippet result: Create a class in java with auto-generated package
name, author, date, class name.
Usage: For the autogeneration of the package you should create your
class file in its proper location, e.g., org.foo.bar.Batz.java would be
created in the directory bar which is a subdirectory of foo and org
directories. The autogeneration of package name and classname also
assumes that your class package directory structure has as its parent
directory a directory named 'src'. You can of course change that in
the third call to sed for both the package name and the class name.
Trigger: jcl (or whatever you want to trigger it with)
Snippet:
${1:package `echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*src.//' | sed 's/.[A-Za-z]*.java//g'`};
/**
* ${2:`echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*src.//' | sed 's/.*\.\([A-Za-z]*\).java/\1/g'`}
*
* @author ${9:`niutil -readprop / /users/$USER realname`}
* @since `date +%D`
*/
public class ${2:`echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' |
sed 's/.*src.//' | sed 's/.*\.\([A-Za-z]*\).java/\1/g'`} ${3:extends}
$4 ${5:implements} $6${7:,}$8 {
$0
}
Snippet result: Create a private scoped variable. Not that useful,
but heh, it is here if you want it.
Usage: No explanation necessary.
Trigger: jpv
private ${1:String} $2;
$0
Snippet result: Create a public scoped method
Usage: No special comments. Pretty straight forward.
Trigger: jpum
Snippet:
/**
* $2
*
* @param $4 $5
* ${6:@return} $7
*/
public ${1:void} $2(${3:String} $4) {
$0
}
Snippet result: Create an if statement with guard comment
Usage:
Trigger: jif
Snippet:
if ($1) { // $2
$0
}
Snippet result: Create a privately scoped method.
Usage:
Trigger: jpm
Snippet:
/**
* $2
*
* @param $4 $5
* ${6:@return} $7
*/
private ${1:void} $2(${3:String} $4) {
$0
}
Snippet result: Create a while statement with guard comment
Usage:
Trigger: jwh
Snippet:
while ($1) { // $2
$0
}
Snippet result: Create a try/catch/finally block
Usage:
Trigger: jtc
Snippet:
try {
$2
} catch ($1 e) {
$3
} finally {
$0
}
Snippet result: Create a class variable/constant.
Usage:
Trigger: jps
Snippet:
private static final ${1:String} $2 = "$0";
Snippet result: Create an if/else statement with guard comments
Usage:
Trigger: jelse
Snippet:
if ($1) { // $2
$0
} else { // $3
}
Snippet result: Create the package imports and instantiation code for
using jakarta commons logging package.
Usage: I would suggest executing the snippet in the import area of you
class definition and then cut/pasting the instantiation code to the
private member variable declaration area.
Trigger: jlog
Snippet:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** Logger for this class and subclasses */
protected final Log logger = LogFactory.getLog(getClass());
Snippet result: Create a JUnit TestCase subclass for unit testing.
Auto-generates the package name and the proper imports for the class
that will be tested.
Usage: Assumes JUnit unit test class naming convention is followed
whereby if a class named UserDao is being unit tested, the unit test
class would be named UserDaoTests.java and would be located in a
parallel directory structure analogous to its package name. Also
assumes, as is standard convention, that unit test packages have as
their parent directory 'test' and the classes which they test have the
parent directory of 'src'. For example, UserDao.java would be located,
let's say, in src/org/foo/bar/dao/ and its unit test class,
UserDaoTests.java, would be in test/org/foo/bar/dao/. Of course, if
you don't work that way, you can message the regular expressions to
suite your environment.
Trigger: jtest
Snippet:
package `echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*test.//' | sed 's/.[A-Za-z]*.java//g'`;
import junit.framework.TestCase;
import `echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*test.//' | sed 's/Tests.java//'`;
/**
* ${2:`echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*test.//' | sed 's/.*\.\([A-Za-z]*\).java/\1/g'`}
*
* @author ${4:`niutil -readprop / /users/$USER realname`}
* @since `date +%D`
*/
public class ${2:`echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' |
sed 's/.*test.//' | sed 's/.*\.\([A-Za-z]*\).java/\1/g'`} extends
TestCase {
private ${5:`echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' |
sed 's/.*test.//' | sed 's/Tests.java//' | sed
's/.*\.\([A-Za-z]*\)$/\1/'`} ${6:`echo $TM_FILEPATH | sed 's/\//./g'
| sed 's/^.//' | sed 's/.*test.//' | sed 's/Tests.java//' | sed
's/.*\.\([A-Za-z]*\)$/\1/' | perl -e 'print lcfirst(<>)'`};
public ${5:`echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*test.//' | sed 's/Tests.java//' | sed 's/.*\.\([A-Za-z]*\)$/\1/'`}
get${5:`echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*test.//' | sed 's/Tests.java//' | sed
's/.*\.\([A-Za-z]*\)$/\1/'`}() { return this.${6:`echo $TM_FILEPATH |
sed 's/\//./g' | sed 's/^.//' | sed 's/.*test.//' | sed
's/Tests.java//' | sed 's/.*\.\([A-Za-z]*\)$/\1/' | perl -e 'print
lcfirst(<>)'`}; }
public void set${5:`echo $TM_FILEPATH | sed 's/\//./g' | sed
's/^.//' | sed 's/.*test.//' | sed 's/Tests.java//' | sed
's/.*\.\([A-Za-z]*\)$/\1/'`}(${5:`echo $TM_FILEPATH | sed 's/\//./g' |
sed 's/^.//' | sed 's/.*test.//' | sed 's/Tests.java//' | sed
's/.*\.\([A-Za-z]*\)$/\1/'`} ${6:`echo $TM_FILEPATH | sed 's/\//./g' |
sed 's/^.//' | sed 's/.*test.//' | sed 's/Tests.java//' | sed
's/.*\.\([A-Za-z]*\)$/\1/' | perl -e 'print lcfirst(<>)'`}) {
this.${6:`echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*test.//' | sed 's/Tests.java//' | sed 's/.*\.\([A-Za-z]*\)$/\1/' |
perl -e 'print lcfirst(<>)'`} = ${6:`echo $TM_FILEPATH | sed
's/\//./g' | sed 's/^.//' | sed 's/.*test.//' | sed 's/Tests.java//' |
sed 's/.*\.\([A-Za-z]*\)$/\1/' | perl -e 'print lcfirst(<>)'`}; }
public void test$8() {
$0
}
}
Snippet result: Create public getter/setter pair for a private instance
variable. This really comes in handy if you do a lot of dependency
injection style development, for bean properties.
Usage:
Trigger: jprops
Snippet:
public $1 get$2() { return this.$3; }
public void set$2($1 $3) { this.$3 = $3; }
Snippet result: Create a JSTL output statement for jsp code.
Usage:
Trigger: jcout
Snippet:
<c:out value="\${$1}"/>$0
Snippet result: Create an interface definition with autogenerated
package name, interface name, author name, and date.
Usage: Same as the usage for the java class snippet.
Trigger: jid
Snippet:
${1:package `echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*src.//' | sed 's/.[A-Za-z]*.java//g'`};
/**
* ${2:`echo $TM_FILEPATH | sed 's/\//./g' | sed 's/^.//' | sed
's/.*src.//' | sed 's/.*\.\([A-Za-z]*\).java/\1/g'`}
*
* @author ${3:`niutil -readprop / /users/$USER realname`}
* @since `date +%D`
*/
public interface ${4:`echo $TM_FILEPATH | sed 's/\//./g' | sed
's/^.//' | sed 's/.*src.//' | sed 's/.*\.\([A-Za-z]*\).java/\1/g'`} {
$0
}
Hope it helps someone, it sure has saved me a ton of typing.
Regards,
Lang Riley
I've been trying to get into the habit of using CVS, so I have created
a few TM command scripts that performs the basic CVS shell commands.
HOW do I convert the text returned from a Finder display dialog script
into a shell variable ????
sort of like this:
osascript -e "tell application \"Finder\"
display dialog \"mxCVS::Commit Message\" default answer
theDefaultAnswer buttons {\"Cancel\", \"OK\"} default button 2
set the theMessage to the text returned of the result
end tell"
$CVSmsg = output from the above AS script
I'm having a bug problem with the Applescript execution of "do shell
script", as AS can't somehow access $CVSROOT from .bash_profile or even
from /etc/profile which really pisses me off. Every other aspect of
CVS works OK, but not through AS.
Kind regards,
Mats
I wanted to have a beta out before the new year, so it's now available
:) I'm 'announcing' it since it turns out the automatic version check
was broken around 1.0.2b8 or so, in that it doesn't schedule a check
before the preferences window has opened.
So just open the preferences, and you should be told about it (if beta
versions are included in the check).
This bug actually lead to interesting statistics, because I can
correlate number of downloads with number of version checks (based on
IP address) and estimate how many actually open the preferences, which
is ~25%.
Beta 1 is btw only a minor update, as December wasn't my most
productive month. But it does feature mode-dependent lookup for
snippets and macros, which I think is rather cool :)
> > 1. Allow undo from find/replace dialog. Lots of times I enter in the
> > wrong regular expression and the find/replace goes badly. I want to
> > hit apple-Z and Undo it and fire up another search, but instead I have
> > to switch to the text window.
>
>hmm... so undo should fall through to the main window? currently I
>could do that, but if I introduce a multi-line mode for the
>find/replace strings it would probably be natural for these to also
>have undo/redo, which would then clash!?!
That's true too; it would be great to someday have undo in the
textbox. And maybe even commands! :)
Maybe instead of my suggestion there could be a little button on the
Find/Replace box that says Undo Last Replace?
2. PDF
Webkit already gives you PDF viewing for free, if you have Schubert's
PDF Plugin (doesn't everyone?) For instance, you can enter in the url
of a PDF file in TM's web preview and view PDFs right now. I just
need a way to tell TM to show a PDF in the web preview.
- Eric
--
Eric Hsu, Assistant Professor of Mathematics
San Francisco State University
erichsu(a)math.sfsu.edu
http://math.sfsu.edu/hsu
A few small requests for this marvelous editor.
1. Allow undo from find/replace dialog. Lots of times I enter in the
wrong regular expression and the find/replace goes badly. I want to
hit apple-Z and Undo it and fire up another search, but instead I
have to switch to the text window.
2. It would be great if the new ( :) ) txmt: resource locator allows
us to load things like txmt://a.pdf, which would then get loaded into
the web preview window. Reason: I want to hack up a replacement for
TeXShop within TM. Already you can make a command to have pdftex
create a .pdf output file and open it in Preview. I'd like it to show
up in TM! It would feel cleaner that way.
3. Allow syntax files to be reloaded. Then we could edit them within
TM and see the results without quitting and restarting.
best wishes, Eric
--
Eric Hsu, Assistant Professor of Mathematics
San Francisco State University
erichsu(a)math.sfsu.edu
http://math.sfsu.edu/hsu
here is a better google search command that escapes spaces and uses
highlighted text rather than the current word:
open http://www.google.com/search?q=`echo $TM_SELECTED_TEXT | sed 's/
/+/g'`
Standard input: selected text
Standard output: discard
Hi,
can you please make find/replace settings persistent between sessions
the way other settings are?
They revert to their default values each time I restart the editor.
David
Hi,
a common practice is to let Undo undo all characters entered during
last stroke (that is, not interrupted by movements or other operations
(find/replace/search) at once. That is, If I type a few words, then
press Option-Z, I expect all the words to disappear, not one letter at
a time. This is the way undo works in most environments, including
emacs, vi, TextEdit, AppleWorks, sam, acme, Word ...
David