commit 7e346d82461441d5461dd82322e24f0e79905197 from: Thomas Adam date: Mon Jun 10 22:37:02 2024 UTC configure: add a --with-default-editor option Ths is useful for Linux distributions which might not solely rely on EDITOR/VISUAL being set in the environment, but would rather use a wrapper command. Debian prefers sensible-editor(1), for example. Rather than make hard-coded assumptions in telescope for each distribution, this will make it easier for packagers of telescope to set this if needed. Defaults to ed(1) if not set. commit - aecdde273e74130898dd4bb95ee6eef8ec212aa9 commit + 7e346d82461441d5461dd82322e24f0e79905197 blob - f8eca103140c852b1ec527dacb142f12b26b1726 blob + 6e380701ea980479acc9001ab62c34dc5808ba29 --- README.md +++ README.md @@ -88,6 +88,16 @@ provided by your distribution instead of using the bun - `--with-libbsd`: link with [libbsd][libbsd] - `--with-libimsg`: link with the [imsg-compat][imsg-compat] library +The default-editor can be changed at build-time with the following option: + + - `--with-default-editor`: defaults to `ed(1)` + +This is useful for distributions such as Debian, which prefers +`sensible-editor(1)` as a wrapper. + +This feature is mostly useful with the `mini-edit-external` command in +`telescope`. + [libbsd]: https://libbsd.freedesktop.org [imsg-compat]: https://github.com/bsd-ac/imsg-compat [libgrapheme]: https://libs.suckless.org/libgrapheme/ blob - e97e25722132465c874f58a2eb73ac925dd3096f blob + f066a7dfe8d7f1a37a121607a0423f7763892af9 --- configure.ac +++ configure.ac @@ -33,6 +33,14 @@ AC_ARG_WITH([libimsg], AC_ARG_WITH([libbsd], AS_HELP_STRING([--with-libbsd], [Build with libbsd library (default: disabled)])) + +AC_ARG_WITH([default-editor], + AS_HELP_STRING([--with-default-editor], + [Set the default editor to use (default: ed)]), + [DEFAULT_EDITOR=$withval], + [DEFAULT_EDITOR=ed]) +AC_MSG_NOTICE([Using default-editor: $DEFAULT_EDITOR]) +AC_DEFINE_UNQUOTED([DEFAULT_EDITOR], ["$DEFAULT_EDITOR"], [The default editor]) AS_IF([test "x$with_libbsd" = "xyes"], [ PKG_CHECK_MODULES([libbsd], [libbsd-overlay libbsd-ctor], [ blob - 71c965a058610a3336b04486dc8ae9bd97771eea blob + 5ba371c90bbcb942f30d8400444939be9917d8c2 --- ui.c +++ ui.c @@ -1441,7 +1441,7 @@ ui_edit_externally(void) if ((editor = getenv("VISUAL")) == NULL && (editor = getenv("EDITOR")) == NULL) - editor = "ed"; + editor = DEFAULT_EDITOR; endwin(); fprintf(stderr, "%s: running %s %s\n", getprogname(), editor, sfn);