#!/bin/csh -f # Open the specified files in the Emacs editor. emacsautosaves set aquamacs_app = "/Applications/Aquamacs Emacs.app" if (! -e "$aquamacs_app:q") then emacs $*:q exit $status endif # Create any specified file that doesn't exist, since open doesn't set created_an_empty_file = "false" foreach file ($*:q) if (! -e $file:q) then echo "Creating empty file: $file" touch $file:q set created_an_empty_file = "true" endif end # Wait for editor to close if any files were created empty, so they can be # deleted later if still empty. set option_wait_till_editor_closes = "" if ("$created_an_empty_file" == "true") then set option_wait_till_editor_closes = "-W" endif unquarantine $*:q >&/dev/null # Open the editor with all of the specified files # -W = Wait till editor exits before proceeding. # -n = New instance of the editor, even if one is already open # -a appname = Application to open open $option_wait_till_editor_closes -n -a "$aquamacs_app:q" $*:q # Delete any files that are now zero length. # This is especially useful for typos in filenames, so the misspelled # file doesn't get created above by touch and left there. #?? Should perhaps keep track of which files were created above and delete #?? only them. Better to not delete files that already existed empty. #?? For now, at least we echo a line saying we did. foreach file ($*:q) if (-z $file:q) then echo -n "Deleting empty file: " rm -v $file:q endif end