git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] help: implement multi-valued "man.viewer" config option

From
XMXavier Maillard <xma@gnu.org>
Date
Mar 12, 2008, 01:00 UTC
Message-ID
<200803120100.m2C105YM010496@localhost.localdomain>
In-Reply-To
<20080311085113.176df1af.chriscool@tuxfamily.org>
   Junio suggested:
   > How about allowing multi-valued man.viewer like this:
   >
   >        [man]
   >                viewer = woman
   >                viewer = konqueror
   >                viewer = man
   >
   > and have:
   >
   >        static struct man_viewer {
   >                char *name;
   >                void (*exec)(const char *);
   >        } viewers[] = {
   >                { "woman", exec_woman },
   >                { "konqueror", exec_konqueror },
   >                { "man", exec_man },
   >                { NULL, },
   >        };
   >
   > Then you can iterate the man.viewer values, ask the viewer's
   > exec() function to show the page (or return when it is not
   > in an environment that it can be useful).
   >
   > show_man_page() would become:
   >
   >        for (each viewer in user's config)
   >                viewer.exec(page); /* will return when unable */
   >        die("no man viewer handled the request");
   This patch implements the above using a list of exec functions that
   is filled when reading the config.
   To do that the exec functions have been moved before reading the
   config. This makes the patch much longer than it would be otherwise.
   Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Tested-by: Xavier Maillard <xma@gnu.org>

Though, I thought that when one entry had failed we would have switched to the next until none could be found thus

I (voluntary) made a typo in my .git/config file as reflected by:

[xma@localhost 23:57:18 git]$ git config --get-all man.viewer woma <- TYPO HERE konqueror man

and I then tried git config --help. I thought it would have tried all entries and as a last resort would have failed back to man but it did not act like this:

[xma@localhost 23:57:11 git]$ git config --help error: 'woma': unsupported man viewer. fatal: bad config file line 16 in .git/config

Ok, woma in not supported here and it is reported like this but would it be possible to just throw an error on stdout and try another viewer ? We could even imagine something even more general like the possibility for the user to write his own man viewer (a bash script for example) and set it as a candidate.

By the way, I do not see any reason to put man as a candidate. "man" should be the default when nothing is specified or when all candidates have failed.

Anyway, thank you for this implementation.
	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org
Previous: Christian CouderNext: Christian Couder
Message 2 of 6 in “help: implement multi-valued "man.viewer" config option”
  1. help: implement multi-valued "man.viewer" config optionChristian Couder, Mar 11, 2008
  2. Xavier MaillardMar 12, 2008
  3. Christian CouderMar 12, 2008
  4. Xavier MaillardMar 14, 2008
  5. Christian CouderMar 14, 2008
  6. Xavier MaillardMar 15, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.