git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Romain Francoise <romain@orebokech.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com
Subject: [PATCH] builtin-help: fallback to GIT_MAN_VIEWER before man
Date: Fri, 29 Aug 2008 17:00:43 +0200	[thread overview]
Message-ID: <877i9zsw6c.fsf@elegiac.orebokech.com> (raw)

In some situations it is useful to be able to switch viewers via the
environment, e.g. in Emacs shell buffers.  So check the GIT_MAN_VIEWER
environment variable and try it before falling back to "man".

Signed-off-by: Romain Francoise <romain@orebokech.com>
---

The motivation for this is that I want the viewer to be "woman" in
Emacs shell buffers and "man" otherwise, and having an environment
variable (like PAGER or EDITOR) is cleaner than using a
man.viewer.cmd wrapper to do the redirection.

 Documentation/git-help.txt |    4 +++-
 builtin-help.c             |    3 +++
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt
index f414583..d9b9c34 100644
--- a/Documentation/git-help.txt
+++ b/Documentation/git-help.txt
@@ -112,7 +112,9 @@ For example, this configuration:
 will try to use konqueror first. But this may fail (for example if
 DISPLAY is not set) and in that case emacs' woman mode will be tried.
 
-If everything fails the 'man' program will be tried anyway.
+If everything fails, or if no viewer is configured, the viewer specified
+in the GIT_MAN_VIEWER environment variable will be tried.  If that
+fails too, the 'man' program will be tried anyway.
 
 man.<tool>.path
 ~~~~~~~~~~~~~~~
diff --git a/builtin-help.c b/builtin-help.c
index 721038e..64207cb 100644
--- a/builtin-help.c
+++ b/builtin-help.c
@@ -361,12 +361,15 @@ static void show_man_page(const char *git_cmd)
 {
 	struct man_viewer_list *viewer;
 	const char *page = cmd_to_page(git_cmd);
+	const char *fallback = getenv("GIT_MAN_VIEWER");
 
 	setup_man_path();
 	for (viewer = man_viewer_list; viewer; viewer = viewer->next)
 	{
 		exec_viewer(viewer->name, page); /* will return when unable */
 	}
+	if (fallback)
+		exec_viewer(fallback, page);
 	exec_viewer("man", page);
 	die("no man viewer handled the request");
 }
-- 
1.6.0.1.141.g445ca.dirty

             reply	other threads:[~2008-08-29 15:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-29 15:00 Romain Francoise [this message]
2008-08-29 16:12 ` [PATCH] builtin-help: fallback to GIT_MAN_VIEWER before man Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877i9zsw6c.fsf@elegiac.orebokech.com \
    --to=romain@orebokech.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).