[PATCH] fix ')edit'

30 views
Skip to first unread message

Qian Yun

unread,
Feb 4, 2024, 6:44:36 AM2/4/24
to fricas-devel
When DISPLAY is set, 'xterm -e "more +$line $name"' quits directly
without waiting for key press.

"less" doesn't have this problem.

- Qian

diff --git a/src/etc/SPADEDIT b/src/etc/SPADEDIT
index be6002f6..1c5cd2d1 100755
--- a/src/etc/SPADEDIT
+++ b/src/etc/SPADEDIT
@@ -6,8 +6,8 @@ if [ $# -eq 0 ]; then
exit
fi

-DEFAULTEDITOR='more +$line $name'
-DEFAULTXEDITOR='xterm -e "more +$line $name"'
+DEFAULTEDITOR='less +$line $name'
+DEFAULTXEDITOR='xterm -e "less +$line $name"'

if [ "$FRICASEDITOR" = "" ] ; then
echo ""
@@ -19,12 +19,12 @@ if [ "$FRICASEDITOR" = "" ] ; then
fi
if [ -z "$DISPLAY" ] ; then
echo "Warning: environment variable FRICASEDITOR not set."
- echo "Using 'more'."
+ echo "Using 'less'."
echo "Press space to continue, 'q' to quit."
FRICASEDITOR=$DEFAULTEDITOR
else
echo "Warning: environment variable FRICASEDITOR not set."
- echo "Launching 'more' in an 'xterm'."
+ echo "Launching 'less' in an 'xterm'."
echo "Press space to continue, 'q' to quit."
FRICASEDITOR=$DEFAULTXEDITOR
fi

Waldek Hebisch

unread,
Feb 4, 2024, 6:41:40 PM2/4/24
to fricas...@googlegroups.com
On Sun, Feb 04, 2024 at 07:44:32PM +0800, Qian Yun wrote:
> When DISPLAY is set, 'xterm -e "more +$line $name"' quits directly
> without waiting for key press.
>
> "less" doesn't have this problem.

We use 'more' because it is standard command: it is supposed to
be available even in a minimal system. There is now some competition
to 'less', user may have different viewer and 'less' may be
unavailable.

--
Waldek Hebisch

Qian Yun

unread,
Feb 4, 2024, 6:52:30 PM2/4/24
to fricas...@googlegroups.com
If the file is less than one page, "more" will exit directly.

Can you reproduce this on your machine?

- Qian

Waldek Hebisch

unread,
Feb 6, 2024, 7:37:05 PM2/6/24
to fricas...@googlegroups.com
On Mon, Feb 05, 2024 at 07:52:25AM +0800, Qian Yun wrote:
> If the file is less than one page, "more" will exit directly.
>
> Can you reproduce this on your machine?

Yes, indeed.

--
Waldek Hebisch

Qian Yun

unread,
Feb 7, 2024, 6:35:01 AM2/7/24
to fricas...@googlegroups.com
So we shall make the 'more -> less' change then?

- Qian

Waldek Hebisch

unread,
Feb 7, 2024, 8:12:11 AM2/7/24
to fricas...@googlegroups.com
On Wed, Feb 07, 2024 at 07:34:55PM +0800, Qian Yun wrote:
> So we shall make the 'more -> less' change then?

I will wait few days for possible additional info or ideas.
It is unfortunate that modern Linux distributions tends to
break traditional usage patterns: AFAIK on "virgin" Debian
system there is only 'more', and worse this 'more' is
half functional (it used to be that on Linux 'more' was
simply alternative name for 'less', and other system
had their own enhanced 'more').

Also, exit is problematic only in combination of xterm
behaviour, namely that xterm window vanishes immediately
after exit from 'more'.

--
Waldek Hebisch

Ralf Hemmecke

unread,
Feb 7, 2024, 8:36:01 AM2/7/24
to fricas...@googlegroups.com
On 2/7/24 14:12, Waldek Hebisch wrote:
> On Wed, Feb 07, 2024 at 07:34:55PM +0800, Qian Yun wrote:
>> So we shall make the 'more -> less' change then?
>
> I will wait few days for possible additional info or ideas.

I would be for a change to using 'less', but as Waldek said, that might
not be generally available.

Since SPADEDIT is a script, there is no need to hardcode

DEFAULTXEDITOR='xterm -e "more +$line $name"'

in this file. So one option could be

to test whether 'less' is reachable via the PATH and then set

DEFAULTXEDITOR='xterm -e "less +$line $name"'

or otherwise set something similar to

DEFAULTXEDITOR='xterm -e "more -e +$line $name; read x"'

. Seemingly, 'more' has an '-e' option.

OK, my suggestion would require to press ENTER instead of 'q', but you
get the idea. Maybe, for that case it would be easiest to change the
text in the 'echo' command accordingly.

Ralf

Waldek Hebisch

unread,
Mar 3, 2024, 8:20:36 AM3/3/24
to fricas...@googlegroups.com
My 'more' has no '-e' option. If this option is given it just
complains.

--
Waldek Hebisch

Ralf Hemmecke

unread,
Mar 3, 2024, 8:40:10 AM3/3/24
to fricas...@googlegroups.com
On 3/3/24 14:20, Waldek Hebisch wrote:
> My 'more' has no '-e' option. If this option is given it just
> complains.

Hmmm, that may well be. Are you working with a BSD version of "more"?

Is there a way to figure out the minimal set of common options that we
can rely on?

This is obviously not working.
https://www.man7.org/linux/man-pages/man1/more.1.html

Ralf

Waldek Hebisch

unread,
Mar 3, 2024, 8:52:11 AM3/3/24
to fricas...@googlegroups.com
On Sun, Mar 03, 2024 at 02:40:07PM +0100, Ralf Hemmecke wrote:
> On 3/3/24 14:20, Waldek Hebisch wrote:
> > My 'more' has no '-e' option. If this option is given it just
> > complains.
>
> Hmmm, that may well be. Are you working with a BSD version of "more"?

$ more -V
more from util-linux 2.25.2

Simply it is old.

> Is there a way to figure out the minimal set of common options that we can
> rely on?

AFAICS everbody claims POSIX compliance. But I am not sure if POSIX
mandates useful behaviour.

--
Waldek Hebisch

Waldek Hebisch

unread,
Apr 2, 2024, 2:12:39 PM4/2/24
to fricas...@googlegroups.com
On Wed, Feb 07, 2024 at 07:34:55PM +0800, Qian Yun wrote:
> So we shall make the 'more -> less' change then?

After some thinking my opinion is yes. I do not see how we
could cope with different behaviour of variants of 'more'
so insisting on 'less' is reasonable.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages