[Github-comments] [geany/geany] Use a format string instead of repeating almost the same string 9 times (#1058)

Matthew Brush notifications at xxxxx
Thu Jun 9 00:49:00 UTC 2016


Another way might be like:

```c
#define ADD_KB_CUSTOM_COMMAND(n, key, mod) \
	add_kb(group, GEANY_KEYS_FORMAT_SENTOCMD##n, NULL, key, mod, \
		"edit_sentocmd"#n, _("Send to Custom Command "#n), NULL)
```

Not sure if that works for gettext scanning or translations though. Alternatively, we could use `g_intern_string()` which will copy the given string, then we can free our formatted one, to avoid "leaking" it like:

```c
#define ADD_KB_CUSTOM_COMMAND(n, key, mod) \
	do { \
		gchar *label = g_strdup_printf(_("Send to Custom Command %d"), n); \
		add_kb(group, GEANY_KEYS_FORMAT_SENDTOCMD##n, NULL, key, mod, \
				"edit_sendtocmd"#n, g_intern_string(label), NULL); \
		g_free(label); \
	} while(0)
```

Or just leak them...

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1058#issuecomment-224773699
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160608/1781195e/attachment.html>


More information about the Github-comments mailing list