Officially support tab-completion of standard slack emoji

Using the weechat-idiomatic interface.

TODO: Deprecate /input complete_* code
v1
Tony Olagbaiye 7 years ago
parent ffcbd66a7e
commit cb597736f1
No known key found for this signature in database
GPG Key ID: 7420820577A31D11

@ -20,6 +20,7 @@
| Status: | Under Development | | Status: | Under Development |
| Location: | [[http://github.com/bqv/weechat-slack]] | | Location: | [[http://github.com/bqv/weechat-slack]] |
| Version: | 0.1.0 | | Version: | 0.1.0 |
| Disclaimer: | Slack's API is a thing of horror |
* Description * Description
@ -77,7 +78,7 @@
- [ ] Implement sending websocket =typing= message - [ ] Implement sending websocket =typing= message
** TODO [#B] Implement completion engine (milestone v0.3) ** TODO [#B] Implement completion engine (milestone v0.3)
- [ ] Tab completion for slack emoji (see [[http://github.com/bqv/weechat-slack/issues/3][#3]]) - [ ] Tab completion for slack emoji (see [[http://github.com/bqv/weechat-slack/issues/3][#3]])
- [ ] Support Slack Emoji - [X] +Support Slack Emoji+
- [ ] Support Custom Emoji - [ ] Support Custom Emoji
- [ ] Tab completion for display/user names (see [[http://github.com/bqv/weechat-slack/issues/1][#1]]) - [ ] Tab completion for display/user names (see [[http://github.com/bqv/weechat-slack/issues/1][#1]])
- [ ] Sort nick-completion by recent (see [[http://github.com/bqv/weechat-slack/issues/4][#4]]) - [ ] Sort nick-completion by recent (see [[http://github.com/bqv/weechat-slack/issues/4][#4]])
@ -102,6 +103,13 @@
Please submit a pull request or create an issue Please submit a pull request or create an issue
to add a new or missing feature. to add a new or missing feature.
* Appropriating
As there is no C library for Slack at the time of
writing, this project implements the APIs from
scratch, and as such one could butcher this repository
to create a minimal Slack C library.
* License * License
weechat-slack is licensed under the Mozilla Public weechat-slack is licensed under the Mozilla Public

@ -2,7 +2,9 @@
// License, version 2.0. If a copy of the MPL was not distributed with this // License, version 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include "weechat-plugin.h" #include "weechat-plugin.h"
#include "slack.h" #include "slack.h"
@ -13,6 +15,10 @@
void slack_completion_init() void slack_completion_init()
{ {
struct t_config_option *option;
const char *default_template;
/*
weechat_hook_command_run("/input return", weechat_hook_command_run("/input return",
&slack_emoji_input_replace_cb, &slack_emoji_input_replace_cb,
NULL, NULL); NULL, NULL);
@ -20,9 +26,24 @@ void slack_completion_init()
weechat_hook_command_run("/input complete*", weechat_hook_command_run("/input complete*",
&slack_emoji_input_complete_cb, &slack_emoji_input_complete_cb,
NULL, NULL); NULL, NULL);
*/
weechat_hook_completion("slack_emoji", weechat_hook_completion("slack_emoji",
N_("slack emoji"), N_("slack emoji"),
&slack_emoji_complete_by_name_cb, &slack_emoji_complete_by_name_cb,
NULL, NULL); NULL, NULL);
option = weechat_config_get("weechat.completion.default_template");
default_template = weechat_config_string(option);
if (!weechat_strcasestr(default_template, "%(slack_emoji)"))
{
size_t length = snprintf(NULL, 0, "%s|%s",
default_template,
"%(slack_emoji)") + 1;
char *new_template = malloc(length);
snprintf(new_template, length, "%s|%s",
default_template,
"%(slack_emoji)");
weechat_config_option_set(option, new_template, 1);
free(new_template);
}
} }

@ -8,6 +8,9 @@
#include "weechat-plugin.h" #include "weechat-plugin.h"
#include "slack.h" #include "slack.h"
#include "slack-workspace.h"
#include "slack-channel.h"
#include "slack-buffer.h"
#include "slack-emoji.h" #include "slack-emoji.h"
#include "slack-emoji.inc" #include "slack-emoji.inc"
@ -99,10 +102,14 @@ int slack_emoji_complete_by_name_cb(const void *pointer, void *data,
struct t_gui_buffer *buffer, struct t_gui_buffer *buffer,
struct t_gui_completion *completion) struct t_gui_completion *completion)
{ {
struct t_slack_workspace *workspace;
struct t_slack_channel *channel;
(void) pointer; (void) pointer;
(void) data; (void) data;
(void) completion_item; (void) completion_item;
(void) buffer;
slack_buffer_get_workspace_and_channel(buffer, &workspace, &channel);
size_t i, emoji_count = sizeof(slack_emoji_by_name) size_t i, emoji_count = sizeof(slack_emoji_by_name)
/ sizeof(struct t_slack_emoji_by_name); / sizeof(struct t_slack_emoji_by_name);
@ -201,6 +208,8 @@ int slack_emoji_input_replace_cb(const void *pointer, void *data,
(void) buffer; (void) buffer;
(void) command; (void) command;
/* TBI */
return WEECHAT_RC_OK; return WEECHAT_RC_OK;
} }

Loading…
Cancel
Save