unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#22116: [PATCH] * etags.c: Add support for Ruby language.
@ 2015-12-08 10:56 lu4nx
  2015-12-08 17:33 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: lu4nx @ 2015-12-08 10:56 UTC (permalink / raw)
  To: 22116; +Cc: lu4nx

---
 lib-src/etags.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/lib-src/etags.c b/lib-src/etags.c
index 8b980d3..7c8c503 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -364,6 +364,7 @@ static void PHP_functions (FILE *);
 static void PS_functions (FILE *);
 static void Prolog_functions (FILE *);
 static void Python_functions (FILE *);
+static void Ruby_functions (FILE *);
 static void Scheme_functions (FILE *);
 static void TeX_commands (FILE *);
 static void Texinfo_nodes (FILE *);
@@ -722,6 +723,12 @@ static const char Python_help [] =
 "In Python code, 'def' or 'class' at the beginning of a line\n\
 generate a tag.";
 
+static const char *Ruby_suffixes [] =
+  { "rb", NULL };
+static const char Ruby_help [] =
+  "In Ruby code, 'def' or 'class' at the beginning of a line\n\
+generate a tag.";
+
 /* Can't do the `SCM' or `scm' prefix with a version number. */
 static const char *Scheme_suffixes [] =
   { "oak", "sch", "scheme", "SCM", "scm", "SM", "sm", "ss", "t", NULL };
@@ -800,6 +807,7 @@ static language lang_names [] =
   { "proc",      no_lang_help,   plain_C_entries,   plain_C_suffixes   },
   { "prolog",    Prolog_help,    Prolog_functions,  Prolog_suffixes    },
   { "python",    Python_help,    Python_functions,  Python_suffixes    },
+  { "ruby",      Ruby_help,      Ruby_functions,    Ruby_suffixes      },
   { "scheme",    Scheme_help,    Scheme_functions,  Scheme_suffixes    },
   { "tex",       TeX_help,       TeX_commands,      TeX_suffixes       },
   { "texinfo",   Texinfo_help,   Texinfo_nodes,     Texinfo_suffixes   },
@@ -4532,6 +4540,31 @@ Python_functions (FILE *inf)
     }
 }
 
+/*
+ * Ruby support
+ * Idea by Xi Lu <lx@shellcodes.org> (2015)
+ */
+static void
+Ruby_functions (FILE *inf)
+{
+  char *cp = NULL;
+
+  LOOP_ON_INPUT_LINES (inf, lb, cp)
+    {
+      cp = skip_spaces (cp);
+      if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class"))
+	{
+	  char *name = cp;
+
+	  while (!notinname (*cp))
+	    cp++;
+
+	  make_tag(name, cp -name, true,
+		   lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
+	}
+    }
+}
+
 \f
 /*
  * PHP support
@@ -4954,7 +4987,22 @@ Lua_functions (FILE *inf)
       (void)LOOKING_AT (bp, "local"); /* skip possible "local" */
 
       if (LOOKING_AT (bp, "function"))
-	get_tag (bp, NULL);
+	{
+	  char *tag_name, *tp_dot, *tp_colon;
+
+	  get_tag (bp, &tag_name);
+	  /* If the tag ends with ".foo" or ":foo", make an additional tag for
+	     "foo".  */
+	  tp_dot = strrchr (tag_name, '.');
+	  tp_colon = strrchr (tag_name, ':');
+	  if (tp_dot || tp_colon)
+	    {
+	      char *p = tp_dot > tp_colon ? tp_dot : tp_colon;
+	      int len_add = p - tag_name + 1;
+
+	      get_tag (bp + len_add, NULL);
+	    }
+	}
     }
 }
 
-- 
2.5.0








^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#22116: [PATCH] * etags.c: Add support for Ruby language.
  2015-12-08 10:56 bug#22116: [PATCH] * etags.c: Add support for Ruby language lu4nx
@ 2015-12-08 17:33 ` Eli Zaretskii
  2015-12-08 17:43   ` lu4nx
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2015-12-08 17:33 UTC (permalink / raw)
  To: lu4nx; +Cc: 22116

> From: lu4nx <lx@shellcodes.org>
> Date: Tue,  8 Dec 2015 18:56:04 +0800
> Cc: lu4nx <lx@shellcodes.org>
> 
> +/*
> + * Ruby support

Thanks.

> @@ -4954,7 +4987,22 @@ Lua_functions (FILE *inf)
>        (void)LOOKING_AT (bp, "local"); /* skip possible "local" */
>  
>        if (LOOKING_AT (bp, "function"))
> -	get_tag (bp, NULL);
> +	{
> +	  char *tag_name, *tp_dot, *tp_colon;
> +
> +	  get_tag (bp, &tag_name);
> +	  /* If the tag ends with ".foo" or ":foo", make an additional tag for
> +	     "foo".  */
> +	  tp_dot = strrchr (tag_name, '.');
> +	  tp_colon = strrchr (tag_name, ':');
> +	  if (tp_dot || tp_colon)
> +	    {
> +	      char *p = tp_dot > tp_colon ? tp_dot : tp_colon;
> +	      int len_add = p - tag_name + 1;
> +
> +	      get_tag (bp + len_add, NULL);
> +	    }
> +	}
>      }
>  }

This part is certainly not yours, and it has nothing to do with Ruby,
AFAICT.  Right?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#22116: [PATCH] * etags.c: Add support for Ruby language.
  2015-12-08 17:33 ` Eli Zaretskii
@ 2015-12-08 17:43   ` lu4nx
  2015-12-26  4:36     ` Dmitry Gutov
  0 siblings, 1 reply; 4+ messages in thread
From: lu4nx @ 2015-12-08 17:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: lu4nx, 22116

yes,it has nothing to do with Ruby, thanks ;-)



在 2015年12月9日,上午1:33,Eli Zaretskii <eliz@gnu.org> 写道:

>> From: lu4nx <lx@shellcodes.org>
>> Date: Tue,  8 Dec 2015 18:56:04 +0800
>> Cc: lu4nx <lx@shellcodes.org>
>> 
>> +/*
>> + * Ruby support
> 
> Thanks.
> 
>> @@ -4954,7 +4987,22 @@ Lua_functions (FILE *inf)
>>       (void)LOOKING_AT (bp, "local"); /* skip possible "local" */
>> 
>>       if (LOOKING_AT (bp, "function"))
>> -    get_tag (bp, NULL);
>> +    {
>> +      char *tag_name, *tp_dot, *tp_colon;
>> +
>> +      get_tag (bp, &tag_name);
>> +      /* If the tag ends with ".foo" or ":foo", make an additional tag for
>> +         "foo".  */
>> +      tp_dot = strrchr (tag_name, '.');
>> +      tp_colon = strrchr (tag_name, ':');
>> +      if (tp_dot || tp_colon)
>> +        {
>> +          char *p = tp_dot > tp_colon ? tp_dot : tp_colon;
>> +          int len_add = p - tag_name + 1;
>> +
>> +          get_tag (bp + len_add, NULL);
>> +        }
>> +    }
>>     }
>> }
> 
> This part is certainly not yours, and it has nothing to do with Ruby,
> AFAICT.  Right?
> 
> 
> 







^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#22116: [PATCH] * etags.c: Add support for Ruby language.
  2015-12-08 17:43   ` lu4nx
@ 2015-12-26  4:36     ` Dmitry Gutov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Gutov @ 2015-12-26  4:36 UTC (permalink / raw)
  To: lu4nx, Eli Zaretskii; +Cc: 22116-done

On 12/08/2015 07:43 PM, lu4nx wrote:
> yes,it has nothing to do with Ruby, thanks ;-)

Since this has been applied, closing.

Thanks again.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-26  4:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-08 10:56 bug#22116: [PATCH] * etags.c: Add support for Ruby language lu4nx
2015-12-08 17:33 ` Eli Zaretskii
2015-12-08 17:43   ` lu4nx
2015-12-26  4:36     ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).