proposal docs/contrib/whatnow2.sh

2022-02-26 Thread Philipp Takacs
Hi

I have written a small whatnow replacement[0]. This might be intresting
for some of you. The main benefit from it, is that it works without be
a shell. You allways work from your own shell.

It is a drop in replacement for whatnow. So all you need to do is to
put this script in your path and set whatnowproc or -whatnowproc
appropriate. To work with the current draft just call "whatnow2 [...]".

There are some problems for nmh users and changes between this version
and the mmh version:

This works only with the drafts folder, because it was written without
draftfile in mind. Also it currently works only with one drafts folder.
I don't know how hard is it to change this.

There is no "mime" command, because mmh don't have one. It's easy to add
one.

This version stores the state in a seperate file next to the draft. The
suffix of this file can be configured by the Metafile-Extension option
and falls back to '.meta'. In the mmh version is it also posible to
store the state in the draft itself. Therefor some changes in mhl are
required.

There are some options which aren't necesary set on nmh. I have added
sane[1] fallbacks, if they are not set. The following options and
fallbacks are used:

* draftfolder: +drafts
* Attachment-Header: Nmh-Attachment
* listproc: show

I hope I haven't missed some problems. If you have problems with it let
me know.

Philipp

[0] I have written this for mmh and never tested it with nmh but it should
just work in most cases

[1] I hope there are sane
#!/bin/sh

printhelp()
{
	echo "Usage: $0 command"
	echo "  commands are:"
	echo "  edit [editor]"
	echo "  list"
	echo "  send [sendargs]"
	echo "  delete"
	echo "  display"
	echo "  attach files"
	echo "  alist"
	echo "  detach anum"
	echo "  refile +folder"
	echo "  -help"
	echo "  -version"
}

version()
{
	if [ $1 -eq 0 ]
	then
		echo "$0 has no own version number, thus this instead:"
		folder -version
		exit 0
	fi
	echo "$0 has no own version number, thus this instead:" 1>&2
	folder -version 1>&2
	exit 1
}

usage()
{
	if [ $1 -eq 0 ]
	then
		printhelp
		exit 0
	fi
	printhelp 1>&2
	exit 1
}

get_editor()
{
	if [ -f "$mhmetafile" ]
	then
		lasteditor=`anno -list -component 'nmh-last-editor' "$mhmetafile"`
		if [ -n "$lasteditor" ]
		then
			editor=`echo $lasteditor | cut -d ' ' -f 1`
			mheditor=`mhparam "$editor-next"`
			[ -n "$mheditor" ] && return
			mheditor=$lasteditor
			return
		fi
	fi
	if [ -n "$MMHEDITOR" ]
	then
		mheditor=$MMHEDITOR
		return
	fi
	mheditor=`mhparam 'Editor'`
}

save_config()
{
	component="$1"
	newtext="$2"
	anno -delete -number all -component "$component" "$mhmetafile"
	anno -nodate -component "$component" -text "$newtext" "$mhmetafile"
}

get_showproc()
{
	mhshowproc=`mhparam 'listproc'`
	mhshowproc=${mhshowproc:-show}
	return
}

get_realpath()
{
	reldir=`dirname "$1"`
	filename=`basename "$1"`
	cd "$reldir"
	echo "$PWD/$filename"
	cd "$OLDPWD"
}

create()
{
	if [ -z "$mhdraft" ]
	then
		usage 1
	fi
	mhext=`mhparam Metafile-Extension`
	mhext=${mhext:-.meta}
	mhmetafile="$mhdraft""$mhext"
	touch "$mhmetafile"
	if [ -z "$mheditor" ]
	then
		get_editor
	fi
	if [ "$mhuse" -eq 1 ]
	then
		exec $mheditor $mhdraft
		return
	fi
	save_config nmh-mhaltmsg "$mhaltmsg"
	save_config nmh-mhdist "$mhdist"
	save_config nmh-mhfolder "$mhfolder"
	save_config nmh-mhmessages "$mhmessages"
	save_config nmh-mhannotate "$mhannotate"
	save_config nmh-last-editor "$mheditor"
	exec $mheditor "$mhdraft"
}

edit()
{
	if [ $# -eq 0 ]
	then
		get_editor
	else
		mheditor="$@"
	fi

	save_config nmh-last-editor "$mheditor"
	exec $mheditor "$mhdraft"
}

list()
{
	get_showproc
	exec $mhshowproc -file $mhdraft
}

sendfunktion()
{
	export mhaltmsg=`anno -list -component 'nmh-mhaltmsg' "$mhmetafile"`
	export mhdist=`anno -list -component 'nmh-mhdist' "$mhmetafile"`
	export mhfolder=`anno -list -component 'nmh-mhfolder' "$mhmetafile"`
	export mhmessages=`anno -list -component 'nmh-mhmessages' "$mhmetafile"`
	export mhannotate=`anno -list -component 'nmh-mhannotate' "$mhmetafile"`
	send "$@" "$mhdraft" || exit $?
	rm -f "$mhmetafile"
	exit 0
}

delete()
{
	folder -push "$draftfolder" >/dev/null 2>&1
	rmm "$draftfolder" c
	folder -pop >/dev/null 2>&1
	rm "$mhmetafile"
}

attach()
{
	header=`mhparam 'Attachment-Header'`
	while [ -n "$1" ]
	do
		if [ ! -f "$1" ]
		then
			echo "file not found: $1" 1>&2
			shift
			echo -n "folloing files are not attached: " 1>&2
			echo -n "$1" 1>&2
			echo "$@" 1>&2
			exit 1
		fi
		file=`get_realpath "$1"`
		anno -nodate -append -component "$header" -text "$file" "$mhdraft"
		shift
	done
}

alist()
{
	header=`mhparam 'Attachment-Header'`
	header=${header:-Nmh-Attachment}
	anno -list -number -component "$header" "$mhdraft"
}

detach()
{
	header=`mhparam 'Attachment-Header'`
	header=${header:-Nmh-Attachment}
	while [ -n "$1" ]
	do
		anno -delete -component "$header" -number "$1" "$mhdraft"
		if [ $? -ne 0 ]
		then
			echo "can't delet attachment $1" 1>&2
			exit 1
		fi
		shift
	done
}

display()
{
	mhalt

Re: mhfixmsg character set conversion

2022-02-26 Thread David Levine
I wrote:

> Steven wrote:
>
> > ...but I'm less happy to have to report that I just ran into a new
> > problem.  In particular, I just received a message with this header:
> >
> >Subject: Re: [KCBExec]
> > =?utf-8?q?Fwd=3A_r=C3=A9pertoire_des_ensembles_musicau?=
> > =?utf-8?q?x?=
>
> Well, mhfixmsg doesn't expect a mix of unencoded and encoded text.
> I'll look into it.

This should fix it for you, Steven:

commit 732ca0d39ddb82a06892a9eb3e6040c87e36f74b
Fixed mhfixmsg(1) -decodeheader to support mixed encoded/undecoded.

Reported by Steven Winikoff.

David



Re: Just updated from CentOS 7 to Rocky Linux 8.5 and can't find nmh anywhere

2022-02-26 Thread Kevin Layer
David, if it helps, I was able to build on Rocky Linux 8.5, in a docker
container, by just adding these packages:

make rpm-build ncurses-devel gdbm-devel flex

I did enable PowerTools in the container, too.  I can send my script, if
anyone wants it.


Re: mhfixmsg character set conversion

2022-02-26 Thread Steven Winikoff
>This should fix it for you, Steven:

It does.

Thanks again!  I really appreciate your help with this.

 - Steven
-- 
___
Steven Winikoff  | Sometimes you will never know the value
Montreal, QC, Canada | of a moment until it becomes a memory.
s...@smwonline.ca |
http://smwonline.ca  | - Dr. Seuss