EmacsWiki: Text Mate (original) (raw)

If you want TextMate-style “fuzzy” file (and other) completion, see Icicles - Completion Methods and Styles or IDO-mode.

If you want automatic indentation of pasted text like in TextMate, see AutoIndentation. This is also accomplished by auto-indent-mode.el

See textmate-mode for an attempt of having the TextMate behaviour for parenthesis and quotes (auto-closing, overwriting, smart delete). Alternatively, AutoPairs. Note that AutoPairs, doesn’t support the M-Return and S-M-Return keys of TextMate. This can be done by using AutoIndentMode.

Pair insertion goes hand in hand with (vi-like) OpenNextLine commands.

See WholeLineOrRegion for line-wise copying and cutting when no text is selected.

YASnippet is a template system for Emacs.

If you want TextMate’s Filter Through Command, see ExecuteExternalCommand.

multiple-line-edit provides a feature similar to the command “Edit Each Line In Selection”.

SpeedBar is similar to the TextMate’s Project Drawer. There’s also ECB, and Ide-skel.

AquamacsEmacs has a lot of TextMate’s key bindings by default.


Question: How can I get the equivalent of TextMate’s “Go To File” (Navigation > Go To File, or Command-T) functionality in Emacs? None of the buffer switching techniques I’ve found really do what TextMate does – namely, apply fuzzy completion to all files found in a project. For Emacs, applying fuzzy completion to all files recursively found in a given directory would be awesome.

Answer 1: Use Ido or Icicles to get TextMate’s kind of “fuzzy” matching (called “flex” matching in Ido and “scatter” matching in Icicles). Just turn on this kind of matching in Ido or Icicles (M-( toggles it in Icicles), and from then on file-name matching will automatically use it. With Icicles you can have fuzzy matching for every kind of input, not just files and buffers. See Icicles - Completion Methods and Styles.

Answer 2: Use ‘find-file-in-project’ with Ido or Icicles, to get TextMate’s behavior with regard to projects of files. You can get ‘find-file-in-project’ here: http://github.com/eschulte/rinari/tree/0c3db2ffbdb1f7002c63c510b99d54ad97635776/find-file-in-project.el

Answer 3: Use the Emacs tags file as your project metaphor. The following function uses Ido to select among the files listed in the tags file:

(defun ido-find-file-in-tag-files ()
  (interactive)
  (save-excursion
    (let ((enable-recursive-minibuffers t)) (visit-tags-table-buffer))
    (find-file (expand-file-name
                (ido-completing-read "Project file: "
                                     (tags-table-files) nil t)))))

It can be bound to C-t or a similar key for convenience: (global-set-key "\C-t" 'ido-find-file-in-tag-files)

I found this had terrible behavior (emacs seizing up) if I typoed and my typo was not a match in the TAGS file. The following fixed the issue for me: https://bitbucket.org/durin42/dotfiles/src/tip/.elisp/settings/50.localfuncs.el#cl-9

(defvar af-ido-flex-fuzzy-limit (* 2000 5))
(defadvice ido-set-matches-1 (around my-ido-set-matches-1 activate)
    (let ((ido-enable-flex-matching (< (* (length (ad-get-arg 0)) (length ido-text))
                                 af-ido-flex-fuzzy-limit)))
        ad-do-it))

Philipp: Is there an equivalent command that supports TAGS generated by GNU gtags?

Answer 4: Use Icicles multi-command ‘icicle-find-file-in-tag-table’ to do the same thing as Answer 3 (there’s nothing to code). And when you use it, you can also take advantage of progressive completion, cycling and all of the other Icicles features.

Answer 5: If you use CScopeAndEmacs, you can search through (and open) all the files referenced in the cscope.out file.

Answer 6: If you use the Sunrise Commander, you can narrow the contents of a pane (containing a directory listing or the results of a find or locate operation) with fuzzy matching by pressing C-c /.


Question: is there a way to have the same behaviour of Textmate when drag’n’dropping a folder from Finder to the Emacs icon in the dock such that a new Emacs window is opened with a project drawer (i.e. speedbar) that is initialized to browse the selected folder ?


CategoryCompletion