--from-here and --literal options do not interact

Jonathan Jacobs <[email protected]>
Newsgroups gmane.comp.gnu.global.bugs
Message-ID <CAM187SFKPfYDJmgDzMYJ-6wuh4mwkanXrKKv4-Z0RbCYxEHp+A@mail.gmail.com>
Good day,

In an attempt to improve support in the emacs library, ggtags, for
symbols named with lisp conventions such as "earmuffs" (surrounded by
asterisks, such as *some-variable*) I noticed that the handling for
the --from-here option does not interact with the --literal option:

$ global -v --result=grep --color=always --path-style=shorter
--from-here=77:emulator/beam/erl_process.c -x --literal -- '*ok*'
global: regular expression is not allowed with the --from-here option.

The man page doesn't go into any detail other than to say "Regular
expression is not allowed for pattern." However the intent of the
--literal option is to indicate that the search term is in fact not a
regular expression.

I've attached a patch that I think might enable the use of --literal
with --from-here, it seems the rest of the code in this path will
treat it literally without additional code although I lack the
expertise required to confirm that.

Regards,
Jonathan Jacobs

_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global
literal_from_here.patch (application/octet-stream, 585 B)
Index: global/global.c
===================================================================
RCS file: /sources/global/global/global/global.c,v
retrieving revision 1.310
diff -u -r1.310 global.c
--- global/global.c	15 May 2017 10:49:53 -0000	1.310
+++ global/global.c	20 Sep 2017 10:11:46 -0000
@@ -850,7 +850,7 @@
 	 * decide tag type.
 	 */
 	if (context_file) {
-		if (isregex(av))
+		if (!literal && isregex(av))
 			die_with_code(2, "regular expression is not allowed with the --from-here option.");
 		db = decide_tag_by_context(av, context_file, atoi(context_lineno));
 	} else {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.