From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Support taking the -O tag value from apropos(1) key=value search
Date: Tue, 1 Jan 2019 03:18:41 -0500 (EST) [thread overview]
Message-ID: <05f89afb8833ec5a@fantadrom.bsd.lv> (raw)
Log Message:
-----------
Support taking the -O tag value from apropos(1) key=value search terms;
feature improvement suggested by kn@.
While here, also make "-O value" work from standard input.
OK kn@
Modified Files:
--------------
mandoc:
main.c
mandoc.1
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.315
retrieving revision 1.316
diff -Lmain.c -Lmain.c -u -p -r1.315 -r1.316
--- main.c
+++ main.c
@@ -123,7 +123,7 @@ main(int argc, char *argv[])
struct manpage *res, *resp;
const char *progname, *sec, *thisarg;
char *conf_file, *defpaths, *auxpaths;
- char *oarg;
+ char *oarg, *tagarg;
unsigned char *uc;
size_t i, sz;
int prio, best_prio;
@@ -368,6 +368,17 @@ main(int argc, char *argv[])
#endif
}
+ /*
+ * Use the first argument for -O tag in addition to
+ * using it as a search term for man(1) or apropos(1).
+ */
+
+ if (conf.output.tag != NULL && *conf.output.tag == '\0') {
+ tagarg = argc > 0 && search.argmode == ARG_EXPR ?
+ strchr(*argv, '=') : NULL;
+ conf.output.tag = tagarg == NULL ? *argv : tagarg + 1;
+ }
+
/* man(1), whatis(1), apropos(1) */
if (search.argmode != ARG_FILE) {
@@ -480,8 +491,10 @@ main(int argc, char *argv[])
curp.mp = mparse_alloc(options, curp.os_e, curp.os_s);
if (argc < 1) {
- if (use_pager)
+ if (use_pager) {
tag_files = tag_init();
+ tag_files->tagname = conf.output.tag;
+ }
thisarg = "<stdin>";
mandoc_msg_setinfilename(thisarg);
parse(&curp, STDIN_FILENO, thisarg);
@@ -518,11 +531,7 @@ main(int argc, char *argv[])
if (use_pager) {
use_pager = 0;
tag_files = tag_init();
- if (conf.output.tag != NULL &&
- tag_files->tagname == NULL)
- tag_files->tagname =
- *conf.output.tag != '\0' ?
- conf.output.tag : *argv;
+ tag_files->tagname = conf.output.tag;
}
mandoc_msg_setinfilename(thisarg);
Index: mandoc.1
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.1,v
retrieving revision 1.235
retrieving revision 1.236
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.235 -r1.236
--- mandoc.1
+++ mandoc.1
@@ -307,8 +307,16 @@ If no
is specified, reuse the first command line argument that is not a
.Ar section
number.
-This is useful when it is the name of a manual page,
-in particular the name of a library function.
+If that argument is in
+.Xr apropos 1
+.Ar key Ns = Ns Ar val
+format, only the
+.Ar val
+is used rather than the argument as a whole.
+This is useful for commands like
+.Ql man -akO tag Ic=ulimit
+to search for a keyword and jump right to its definition
+in the matching manual pages.
.It Cm width Ns = Ns Ar width
The output width is set to
.Ar width
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2019-01-01 8:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=05f89afb8833ec5a@fantadrom.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/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).