{"thread":{"id":"15275","subject":"[PATCH] builtin-help: fallback to GIT_MAN_VIEWER before man","startedAt":"2008-08-29T15:00:43Z","lastAt":"2008-08-29T16:12:48Z","messageCount":2,"participants":["Romain Francoise","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"89135","messageId":"877i9zsw6c.fsf@elegiac.orebokech.com","threadId":"15275","inReplyTo":null,"subject":"[PATCH] builtin-help: fallback to GIT_MAN_VIEWER before man","fromName":"Romain Francoise","fromEmail":"romain@orebokech.com","sentAt":"2008-08-29T15:00:43Z","receivedAt":"2008-08-29T15:00:43Z","isPatch":true,"sender":{"key":"romain@orebokech.com","avatar":"https://avatars.githubusercontent.com/u/49197?v=4"},"body":"In some situations it is useful to be able to switch viewers via the\nenvironment, e.g. in Emacs shell buffers.  So check the GIT_MAN_VIEWER\nenvironment variable and try it before falling back to \"man\".\n\nSigned-off-by: Romain Francoise <romain@orebokech.com>\n---\n\nThe motivation for this is that I want the viewer to be \"woman\" in\nEmacs shell buffers and \"man\" otherwise, and having an environment\nvariable (like PAGER or EDITOR) is cleaner than using a\nman.viewer.cmd wrapper to do the redirection.\n\n Documentation/git-help.txt |    4 +++-\n builtin-help.c             |    3 +++\n 2 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-help.txt b/Documentation/git-help.txt\nindex f414583..d9b9c34 100644\n--- a/Documentation/git-help.txt\n+++ b/Documentation/git-help.txt\n@@ -112,7 +112,9 @@ For example, this configuration:\n will try to use konqueror first. But this may fail (for example if\n DISPLAY is not set) and in that case emacs' woman mode will be tried.\n \n-If everything fails the 'man' program will be tried anyway.\n+If everything fails, or if no viewer is configured, the viewer specified\n+in the GIT_MAN_VIEWER environment variable will be tried.  If that\n+fails too, the 'man' program will be tried anyway.\n \n man.<tool>.path\n ~~~~~~~~~~~~~~~\ndiff --git a/builtin-help.c b/builtin-help.c\nindex 721038e..64207cb 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -361,12 +361,15 @@ static void show_man_page(const char *git_cmd)\n {\n \tstruct man_viewer_list *viewer;\n \tconst char *page = cmd_to_page(git_cmd);\n+\tconst char *fallback = getenv(\"GIT_MAN_VIEWER\");\n \n \tsetup_man_path();\n \tfor (viewer = man_viewer_list; viewer; viewer = viewer->next)\n \t{\n \t\texec_viewer(viewer->name, page); /* will return when unable */\n \t}\n+\tif (fallback)\n+\t\texec_viewer(fallback, page);\n \texec_viewer(\"man\", page);\n \tdie(\"no man viewer handled the request\");\n }\n-- \n1.6.0.1.141.g445ca.dirty\n"},{"id":"89140","messageId":"7vod3b4x6n.fsf@gitster.siamese.dyndns.org","threadId":"15275","inReplyTo":"877i9zsw6c.fsf@elegiac.orebokech.com","subject":"Re: [PATCH] builtin-help: fallback to GIT_MAN_VIEWER before man","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-29T16:12:48Z","receivedAt":"2008-08-29T16:12:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Romain Francoise <romain@orebokech.com> writes:\n\n> In some situations it is useful to be able to switch viewers via the\n> environment, e.g. in Emacs shell buffers.  So check the GIT_MAN_VIEWER\n> environment variable and try it before falling back to \"man\".\n>\n> Signed-off-by: Romain Francoise <romain@orebokech.com>\n> ---\n>\n> The motivation for this is that I want the viewer to be \"woman\" in\n> Emacs shell buffers and \"man\" otherwise, and having an environment\n> variable (like PAGER or EDITOR) is cleaner than using a\n> man.viewer.cmd wrapper to do the redirection.\n\nObviously I am biased, as I am among the people who have PAGER=cat and\nEDITOR=emacsclient, and 70% of whose command invocation is from within the\n\"M-x compile\", but I like this.\n"}]}