From 17ee0e400bef47c371afcae76037f9ea6a44ad13 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 10 Sep 2018 14:51:14 -0400 Subject: Support Vim, Tmux, Emacs with Stow After moving off of Meta, Dotfiles has a greater responsibility to manage configs. Vim, Tmux, and Emacs are now within Stow's purview. --- .../elpa/slack-20180712.2222/slack-reaction.el | 117 +++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-reaction.el (limited to 'configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-reaction.el') diff --git a/configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-reaction.el b/configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-reaction.el new file mode 100644 index 000000000000..d0cff1a80370 --- /dev/null +++ b/configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-reaction.el @@ -0,0 +1,117 @@ +;;; slack-reaction.el --- deal with reactions -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 yuya.minami + +;; Author: yuya.minami +;; Keywords: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; + +;;; Code: + +(require 'eieio) + +(defclass slack-reaction () + ((name :initarg :name :type string) + (count :initarg :count :type integer) + (users :initarg :users :initform ()))) + +(defmethod slack-reaction-join ((r slack-reaction) other) + (if (string= (oref r name) (oref other name)) + (progn + (cl-incf (oref r count)) + (oset r users (append (oref other users) (oref r users))) + r))) + +(defmethod slack-reaction-user-names ((r slack-reaction) team) + (with-slots (users) r + (mapcar #'(lambda (u) (slack-user-name u team)) + users))) + +(defmethod slack-equalp ((r slack-reaction) other) + (slack-reaction-equalp r other)) + +(defmethod slack-reaction-equalp ((r slack-reaction) other) + (string= (oref r name) (oref other name))) + +(defmethod slack-reaction-help-text ((r slack-reaction) team) + (let ((user-names (slack-reaction-user-names r team))) + (format "%s reacted with :%s:" + (mapconcat #'identity user-names ", ") + (oref r name)))) + +(defvar slack-reaction-keymap + (let ((keymap (make-sparse-keymap))) + (define-key keymap (kbd "RET") #'slack-reaction-toggle) + (define-key keymap [mouse-1] #'slack-reaction-toggle) + keymap)) + +(defun slack-reaction-toggle () + (interactive) + (slack-if-let* ((buffer slack-current-buffer) + (reaction (get-text-property (point) 'reaction)) + (reaction-name (oref reaction name)) + (reaction-users (oref reaction users)) + (team (oref buffer team)) + (self-id (oref team self-id))) + (if (cl-find-if #'(lambda (id) (string= id self-id)) reaction-users) + (slack-message-reaction-remove reaction-name + (slack-get-ts) + (oref buffer room) + team) + (slack-message--add-reaction buffer reaction-name)))) + +(defun slack-reaction-help-echo (_window _string pos) + (slack-if-let* ((buffer slack-current-buffer) + (reaction (get-text-property pos 'reaction)) + (team (oref buffer team))) + (slack-reaction-help-text reaction team))) + +(defmethod slack-reaction-to-string ((r slack-reaction) team) + (propertize (format " :%s: %d " (oref r name) (oref r count)) + 'face 'slack-message-output-reaction + 'mouse-face 'highlight + 'keymap slack-reaction-keymap + 'reaction r + 'help-echo #'slack-reaction-help-echo)) + +(defun slack-reaction-echo-description () + (slack-if-let* ((buffer slack-current-buffer) + (reaction (get-text-property (point) 'reaction)) + (team (oref buffer team))) + (message (slack-reaction-help-text reaction team)))) + +(defun slack-reaction-notify (payload team room) + (let* ((user-id (plist-get payload :user)) + (reaction (plist-get payload :reaction)) + (msg (slack-user-message "msg" + :text (format "added reaction %s" reaction) + :user user-id))) + (slack-message-notify msg room team))) + +(defun slack-reaction--find (reactions reaction) + (cl-find-if #'(lambda (e) (slack-reaction-equalp e reaction)) + reactions)) + +(defun slack-reaction--delete (reactions reaction) + (cl-delete-if #'(lambda (e) (slack-reaction-equalp e reaction)) + reactions)) + +(provide 'slack-reaction) +;;; slack-reaction.el ends here + -- cgit 1.4.1