# Start the NEdit editor: # Run the script .ned in the current directory if it exists; nc otherwise ACTION ned { TYPE COMMAND # LABEL Run NEdit (server mode) WINDOW_TYPE NO_STDIO ICON nedit LABEL Run NEdit in server mode EXEC_STRING sh -c \ 'if [ "$#" = 1 ] && [ -d "$1" ]; then \ : a directory was sent to the action - go there ; \ cd "$1"; shift; \ d="$1"; \ elif [ "$#" = 2 ] && [ -d "$1" ] && [ -d "$2" ]; then \ : two directories - find common subdir ; \ a="$1" ; b="$2" \; d= ; \ z=1 ; \ while [ "`echo $a | sed -e '"'s:/.*::'"'`" = \ "`echo $b | sed -e '"'s:/.*::'"'`" ] && \ [ -n "`echo $a | sed -e '"'s:[^/]::g'"'`" ]; \ do \ d="$d`echo $a | sed -e '"'s:/.*:/:'"'`"; \ a="`echo $a | sed -e '"'s:[^/]*/::'"'`"; \ b="`echo $b | sed -e '"'s:[^/]*/::'"'`"; \ : sanity check - loop no more than 30 times ; \ if [ $z = 30 ] ; then echo 30 iters ; exit; fi; \ z=`expr $z + 1` ; \ done ; \ : now buld macro string ; \ m="new():focus_window(\\"last\\"):" ; \ m="${m}:insert_string(\\"diff -r $a $b\\")" ; \ m=`echo "$m" | tr : \\\\\\n` ; \ set - -do "$m" ; \ if mmessage -text "$*" ; then :; else exit; fi; \ elif [ -f "$1" ]; then \ : a file was given - use its directory ; \ d=`dirname "$1"`; \ fi; \ \ : find suitable .ned script; \ if [ -f .ned ] && [ -x .ned ]; then \ : in the current directory ; \ cmd="exec .ned"; \ else \ \ : starting in current directory, look for a .ned ; \ : somewhere higher in the tree ; \ [ -z "$d" ] && d="$PWD"; \ ned=; \ while [ "$d" != "/" ] && \ [ -n "$d" ] && [ -z "$ned" ]; do \ if [ -f "$d/.ned" ] && [ -x "$d/.ned" ]; then \ ned="$d/.ned"; \ fi; \ d=`dirname "$d"`; \ done; \ \ : if nothing found, use any .ned in HOME ; \ if [ -z "$ned" ] && \ [ -f "$HOME/.ned" ] && [ -x "$HOME/.ned" ]; then \ ned="$HOME/.ned"; \ fi; \ \ if [ -n "$ned" ]; then \ cmd="exec \"$ned\""; \ else \ : no .ned script - just use plain nc; \ cmd="nc -noask"; \ fi; \ fi; \ \ : invoke the command chosen; \ if [ x"$1" = x"$PWD/.ned" ]; then \ shift; $cmd "$@"; \ elif [ x"$1" = x"$PWD" ]; then \ shift; $cmd "$@"; \ else \ $cmd "$@"; \ fi' - %Args% DESCRIPTION Runs an unnamed NEdit server (or execute .ned in \ the current directory or one of its ancestors) } DATA_ATTRIBUTES NEditRunFile { ICON nedit ACTIONS NEdit,Run DESCRIPTION This file is run automatically as part of the ned \ action: it is intended to start a new NEdit server \ (using a .ned script if found) or connect to an \ existing one. } DATA_CRITERIA NEditRunFile1 { DATA_ATTRIBUTES_NAME NEditRunFile PATH_PATTERN */.ned MODE !d&x } ACTION Run { LABEL Run NEdit (server mode) ARG_TYPE NEditRunFile TYPE MAP MAP_ACTION ned }