Package: debianutils
Version: 2.16
Followup-For: Bug #250732
I tested some of the editors I have installed. Well, ok, I just went
nuts and installed all the text editors in the "Editors" section. I
skipped xemacs and the vi clones, because I assume they'll work.
foo +1000 /usr/share/dict/words
BTW, not all editors provide the /usr/bin/editor alternative. Users
might still set their $EDITOR to them, though.
And I reworked sensible-editor to support this:
----------
#!/bin/sh
# recognize $1 as a +linenumber argument and if necessary for the editor,
# translate it to the editor's prefered command line style.
# If the editor can't be told about line numbers, just pass the argument
# through anyway. The user will probably get an editor buffer on a file
# called +linenum, and they can figure out which line to go to!
# currently we don't do anything for /usr/bin/editor, although some
# packages provide the /usr/bin/editor alternative with a program that
# doesn't handle +linenum. If we can't do the right thing, be transparent.
# editors which handle +linenum:
#
#emacslike: emacs, jed, joe, jove, zile
#vi: vim,levee,
#other: nano, aee, ee, geresh, le, lpe, mcedit, mined, mped, nedit, zed
# if $1 is of the form +number, it will compare not equal to zero
if [ 0 -ne "$1" ] 2>/dev/null;then
LNUM="${1#+}"
fi
for editor in "$VISUAL" "$EDITOR" editor nano nano-tiny vi; do
if [ -z "$editor" ];then continue; fi # skip empty VISUAL or EDITOR
if [ "$LNUM" ];then
case $( basename $editor ) in
kate|kwrite)
( shift; $editor "--line=$LNUM" "$@" );;
fte|?fte | the)
( shift; $editor "-l$LNUM" "$@" );;
sam)
( shift; # sam is weird!
{ sleep 1.5; B -$LNUM; } &
sam "$@" )
;;
wily) (wily -e "wgoto :$LNUM" "$@" );;
# editors without a line number option at all:
# qemacs|e3em) emacslike
# ed|xed) vi
# gnotepad+|kedit|leafpad|mousepad|ptked|scite|teaed) notepad gui
# xedit|axe|xwpe|yudit) other x11
# jered,ne,qe) # other tty-based
# hexedit|tetradraw) non-text editors
*) $editor "$@";;
esac
else
$editor "$@"
fi
ret="$?"
if [ "$ret" -ne 126 ] && [ "$ret" -ne 127 ]; then
exit "$ret"
fi
done
echo "Couldn't find an editor!" 1>&2
echo "Set the \$EDITOR environment variable to your desired editor." 1>&2
exit 1
----------
And yes, it still works with dash. It's all Posix shell.
It could stand to have some of the comments moved out of the script
itself, I guess!
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-ck5
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages debianutils depends on:
ii coreutils 5.94-1 The GNU core utilities
ii libc6 2.3.6-7 GNU C Library: Shared libraries
ii mktemp 1.5-1 Makes unique filenames for tempora
debianutils recommends no packages.
-- no debconf information
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]