[PATCH] startup: activate --modernbindings when name of binary equals "en"

Benno Schulenberg <[email protected]>
Newsgroups gmane.editors.nano.devel
Message-ID <[email protected]>
And install a symlink `en` to `nano` during `make install`.  This
facilitates a "zero-conf" invocation of nano with modern bindings.

Do not activate --modernbindings when the binary's name starts
with "e", as this interferes with Debian's alternatives system
that symlinks `editor` to `nano` by default.

This addresses https://savannah.gnu.org/bugs/?65810.
Reported-by: Colin Snover <[email protected]>
---
 src/Makefile.am | 5 +++--
 src/nano.c      | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index dff550d1..f2dab722 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,6 +46,7 @@ nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a \
 		$(GETRANDOM_LIB) $(LIB_CLOCK_GETTIME) $(LIBTHREAD)
 
 install-exec-hook:
-	cd $(DESTDIR)$(bindir) && rm -f rnano && $(LN_S) nano rnano
+	cd $(DESTDIR)$(bindir) && rm -f en rnano \
+				&& $(LN_S) nano en && $(LN_S) nano rnano
 uninstall-hook:
-	cd $(DESTDIR)$(bindir) && rm -f rnano
+	cd $(DESTDIR)$(bindir) && rm -f en rnano
diff --git a/src/nano.c b/src/nano.c
index cc894fdf..14cfb971 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1874,7 +1874,7 @@ int main(int argc, char **argv)
 	/* If the executable's name starts with 'r', activate restricted mode. */
 	if (*(tail(argv[0])) == 'r')
 		SET(RESTRICTED);
-	else if (*(tail(argv[0])) == 'e')
+	else if (strcmp(tail(argv[0]), "en") == 0)
 		SET(MODERN_BINDINGS);
 
 	while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
-- 
2.45.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.