(yet another?) nedit wrapper to edit unicode files...
Thomas Orgis
thomas-forum at orgis.org
Wed Apr 30 11:38:55 CEST 2008
Note: I tried to send this two times with files attached... it didn't
come through, perhaps because of SPAM detection.
I have uploaded the attachments to
http://thomas.orgis.org/unedit.tar.gz
Please get them from there if interested...
Hi,
there's been discussion about nedit's future support of unicode files
and possible in-between steps like macros converting from/to encodings
on load/save.
I thought I'd share my current solution, being less of an nedit macro
wizard than a perl hacker...
I have written this kindof nedit wrapper shell for converting files to
some nedit-compatible encoding (using iconv), start nedit client with
LANG=...ISO-8869-x and convert back to Unicode (or whatever).
Thought perhaps someone else could be interested...
I called it "unedit" (for unicode nedit). It can take a list of files
on the command line to work on and is controllable via single
keypresses for functions like writing back the current 8bit version to
Unicode, opening new files, closing files (removing the 8bit copy). For
opening files I stronly recommend having Term::ReadLine::Gnu (or some
other smart readline variant) Perl module installed, which gives proper
tab expansion for file names.
This says unedit -h:
unedit v1.0.0 - A wrapper shell for editing UTF files with nedit.
The basic function is to convert the files from UTF-8 to some 8bit
encoding and edit that 8bit version with nedit, converting back to UTF
when done.
This wrapper features a little text shell for managing a list of files
but also supports a serial editing mode without shell control (to
replace ncl -wait).
Generic parameter example (list of real parameters follows):
unedit -s -xyz -s=value --long --long=value [--] <files/stuff>
Just mentioning -s equals -s=1 (true), while +s equals -s=0 (false).
Using separator "--" makes sure that parameter parsing stops.
Recognized parameters:
NAME, SHORT [VALUE] DESCRIPTION
backfilter, b [iconv -f ISO_8859-15 -t UTF-8] filter back to external encoding
config, I [/home/thomas/progs/thor/scripterei/unedit.conf] Which configfile to use;
special: just -I or --config causes printing a current config file to STDOUT
editor, e [ncl] editor command, typically ncl (but maybe with a svrname parameter), should not block
filter, f [iconv -f UTF-8 -t ISO_8859-15] filter from external encoding to editor encoding
help, h [1] show the help message, give value > 1 for more help
locale, l [LANG=de_DE.ISO8859-15] var settings, going into the line to launch editor (bourne shell...)
run, r [run] the command to run on the "r" (run) action
serial, S [0] serial mode, goes once over given list of files and exits
serial-editor, E [ncl -wait] editor command that blocks for serial mode
sum, s [md5sum] the checksum command to determine file change
version [0] print out the program version
The included files are:
- bin/unedit: the wrapper/shell script itself, can run standalone
- lib/perl/Param.pm: a Perl module for parameter and config file
processing (change the internal/external encoding, nedit command, etc.)
This should go into the same directory as unedit or into ../lib/perl .
This is optional, you can edit the script itself to have the set
of options you'll likely use every time.
- etc/unedit.conf: an example config file I use (german locale, if that
would matter to nedit... ISO-8859-15 encoding).
A config file is found as nedit.conf in same dir as the program,
$HOME/.unedit, ../etc/unedit.conf .
It's sort of trivial but then, it is quite useful for me to ease editing
UTF-encoded files. In comparison to import/export macros that a user has
to invoke (or nedit needs to guess) this has the advantage for keeping
things straight for nedit: A file you edit there has _always_ your chosen
8bit encoding, the external encoding being handled by the wrapper
Of course the preferred solution to this problem would be to support
Unicode internally, but when will that happen, realistically?
Well, I shared by crap -- now, comments and flames, anyone? ;-)
Alrighty then,
Thomas.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://www.nedit.org/pipermail/discuss/attachments/20080430/2b0ac80d/signature.bin
More information about the Discuss
mailing list