From 16bc177a4a894650809a1990fa6c8d184ba23d93 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Sun, 25 Jul 2010 10:56:32 -0700 Subject: [PATCH] Allow HOMEBREW_EDITOR for non-project editing. If set, use "HOMEBREW_EDITOR" when editing a single file, or multiple files in the same folder. Note that this setting does not affect `brew edit`, since opening all of Homebrew at once requires an editor with proper project support. --- Library/Contributions/manpages/brew.1.md | 11 ++++++++++- Library/Homebrew/utils.rb | 7 ++++++- share/man/man1/brew.1 | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Library/Contributions/manpages/brew.1.md b/Library/Contributions/manpages/brew.1.md index 0c5ce1eff7..1b1939eac4 100644 --- a/Library/Contributions/manpages/brew.1.md +++ b/Library/Contributions/manpages/brew.1.md @@ -149,6 +149,14 @@ didn't include with OS X. * HOMEBREW\_DEBUG: If set, instructs Homebrew to always assume `--debug` when running commands. + * HOMEBREW\_EDITOR: + If set, Homebrew will use this editor when editing a single formula, or + several formulae in the same folder. + + *NOTE*: `brew edit` will open all of Homebrew as discontinuous files and + folders. TextMate can handle this correctly in project mode, but many + editors will do strange things in this case. + * HOMEBREW\_SVN: When exporting from Subversion, Homebrew will use `HOMEBREW_SVN` if set, a Homebrew-built Subversion if installed, or the system-provided binary. @@ -165,7 +173,8 @@ didn't include with OS X. configurations.) * HOMEBREW\_USE\_LLVM: - If set, instructs Homebrew to use the LLVM front-ends to the GCC compilers. + If set, instructs Homebrew to use the LLVM front-ends to the GCC compilers. + *NOTE*: Not all formulae will build correctly under LLVM. * HOMEBREW\_VERBOSE: diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 1fc8a9544b..8b3d6fb793 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -140,11 +140,16 @@ def puts_columns items, cols = 4 end def exec_editor *args - editor=ENV['EDITOR'] + editor = ENV['HOMEBREW_EDITOR'] || ENV['EDITOR'] if editor.nil? if system "/usr/bin/which -s mate" + # TextMate editor='mate' + elsif system "/usr/bin/which -s edit" + # BBEdit / TextWrangler + editor='edit' else + # Default to vim editor='/usr/bin/vim' end end diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1 index bb5853e36b..67c34b3e02 100644 --- a/share/man/man1/brew.1 +++ b/share/man/man1/brew.1 @@ -164,6 +164,13 @@ HOMEBREW_DEBUG If set, instructs Homebrew to always assume \fB\-\-debug\fR when running commands\. . .TP +HOMEBREW_EDITOR +If set, Homebrew will use this editor when editing a single formula, or several formulae in the same folder\. +. +.IP +\fINOTE\fR: \fBbrew edit\fR will open all of Homebrew as discontinuous files and folders\. TextMate can handle this correctly in project mode, but many editors will do strange things in this case\. +. +.TP HOMEBREW_SVN When exporting from Subversion, Homebrew will use \fBHOMEBREW_SVN\fR if set, a Homebrew\-built Subversion if installed, or the system\-provided binary\. . @@ -181,7 +188,7 @@ This issue typically occurs when using FileVault (or certain custom SSD configur HOMEBREW_USE_LLVM If set, instructs Homebrew to use the LLVM front\-ends to the GCC compilers\. . -.br +.IP \fINOTE\fR: Not all formulae will build correctly under LLVM\. . .TP