patch 8.2.4989: cannot specify a function name for :defcompile

Problem:    Cannot specify a function name for :defcompile.
Solution:   Implement a function name argument for :defcompile.
diff --git a/src/userfunc.c b/src/userfunc.c
index 42e285f..6eabd8b 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -4997,36 +4997,115 @@
 }
 
 /*
+ * Find a function by name, including "<lambda>123".
+ * Check for "profile" and "debug" arguments and set"compile_type".
+ * Return NULL if not found.
+ */
+    ufunc_T *
+find_func_by_name(char_u *name, compiletype_T *compile_type)
+{
+    char_u	*arg = name;
+    char_u	*fname;
+    ufunc_T	*ufunc;
+    int		is_global = FALSE;
+
+    *compile_type = CT_NONE;
+    if (STRNCMP(arg, "profile", 7) == 0 && VIM_ISWHITE(arg[7]))
+    {
+	*compile_type = CT_PROFILE;
+	arg = skipwhite(arg + 7);
+    }
+    else if (STRNCMP(arg, "debug", 5) == 0 && VIM_ISWHITE(arg[5]))
+    {
+	*compile_type = CT_DEBUG;
+	arg = skipwhite(arg + 5);
+    }
+
+    if (STRNCMP(arg, "<lambda>", 8) == 0)
+    {
+	arg += 8;
+	(void)getdigits(&arg);
+	fname = vim_strnsave(name, arg - name);
+    }
+    else
+	fname = trans_function_name(&arg, &is_global, FALSE,
+		      TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD, NULL, NULL, NULL);
+    if (fname == NULL)
+    {
+	semsg(_(e_invalid_argument_str), name);
+	return NULL;
+    }
+    if (!ends_excmd2(name, arg))
+    {
+	emsg(ex_errmsg(e_trailing_characters_str, arg));
+	return NULL;
+    }
+
+    ufunc = find_func(fname, is_global);
+    if (ufunc == NULL)
+    {
+	char_u *p = untrans_function_name(fname);
+
+	if (p != NULL)
+	    // Try again without making it script-local.
+	    ufunc = find_func(p, FALSE);
+    }
+    vim_free(fname);
+    if (ufunc == NULL)
+	semsg(_(e_cannot_find_function_str), name);
+    return ufunc;
+}
+
+/*
  * :defcompile - compile all :def functions in the current script that need to
- * be compiled.  Except dead functions.  Doesn't do profiling.
+ * be compiled or the one specified by the argument.
+ * Skips dead functions.  Doesn't do profiling.
  */
     void
-ex_defcompile(exarg_T *eap UNUSED)
+ex_defcompile(exarg_T *eap)
 {
-    long	todo = (long)func_hashtab.ht_used;
-    int		changed = func_hashtab.ht_changed;
-    hashitem_T	*hi;
     ufunc_T	*ufunc;
 
-    for (hi = func_hashtab.ht_array; todo > 0 && !got_int; ++hi)
+    if (*eap->arg != NUL)
     {
-	if (!HASHITEM_EMPTY(hi))
-	{
-	    --todo;
-	    ufunc = HI2UF(hi);
-	    if (ufunc->uf_script_ctx.sc_sid == current_sctx.sc_sid
-		    && ufunc->uf_def_status == UF_TO_BE_COMPILED
-		    && (ufunc->uf_flags & FC_DEAD) == 0)
-	    {
-		(void)compile_def_function(ufunc, FALSE, CT_NONE, NULL);
+	compiletype_T compile_type;
 
-		if (func_hashtab.ht_changed != changed)
+	ufunc = find_func_by_name(eap->arg, &compile_type);
+	if (ufunc != NULL)
+	{
+	    if (func_needs_compiling(ufunc, compile_type))
+		(void)compile_def_function(ufunc, FALSE, compile_type, NULL);
+	    else
+		smsg(_("Function %s does not need compiling"), eap->arg);
+	}
+    }
+    else
+    {
+	long	todo = (long)func_hashtab.ht_used;
+	int		changed = func_hashtab.ht_changed;
+	hashitem_T	*hi;
+
+	for (hi = func_hashtab.ht_array; todo > 0 && !got_int; ++hi)
+	{
+	    if (!HASHITEM_EMPTY(hi))
+	    {
+		--todo;
+		ufunc = HI2UF(hi);
+		if (ufunc->uf_script_ctx.sc_sid == current_sctx.sc_sid
+			&& ufunc->uf_def_status == UF_TO_BE_COMPILED
+			&& (ufunc->uf_flags & FC_DEAD) == 0)
 		{
-		    // a function has been added or removed, need to start over
-		    todo = (long)func_hashtab.ht_used;
-		    changed = func_hashtab.ht_changed;
-		    hi = func_hashtab.ht_array;
-		    --hi;
+		    (void)compile_def_function(ufunc, FALSE, CT_NONE, NULL);
+
+		    if (func_hashtab.ht_changed != changed)
+		    {
+			// a function has been added or removed, need to start
+			// over
+			todo = (long)func_hashtab.ht_used;
+			changed = func_hashtab.ht_changed;
+			hi = func_hashtab.ht_array;
+			--hi;
+		    }
 		}
 	    }
 	}