diff options
author | William Carroll <wpcarro@gmail.com> | 2018-09-10T18·51-0400 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2018-09-10T18·53-0400 |
commit | 17ee0e400bef47c371afcae76037f9ea6a44ad13 (patch) | |
tree | 0e5efee6f00e402890e91f3eceb4b29408a498b6 /configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-pinned-items-buffer.el | |
parent | 8b2fadf4776b7ddb4a67b4bc8ff6463770e56028 (diff) |
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.
Diffstat (limited to 'configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-pinned-items-buffer.el')
-rw-r--r-- | configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-pinned-items-buffer.el | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-pinned-items-buffer.el b/configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-pinned-items-buffer.el new file mode 100644 index 000000000000..e938e6a7dcf9 --- /dev/null +++ b/configs/shared/emacs/.emacs.d/elpa/slack-20180712.2222/slack-pinned-items-buffer.el @@ -0,0 +1,105 @@ +;;; slack-pinned-items-buffer.el --- -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 + +;; Author: <yuya373@yuya373> +;; 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; + +;;; Code: + +(require 'eieio) +(require 'slack-util) +(require 'slack-room-buffer) + +(define-derived-mode slack-pinned-items-buffer-mode slack-buffer-mode "Slack Pinned Items") + +(defclass slack-pinned-items-buffer (slack-room-buffer) + ((items :initarg :items :type list))) + +(defmethod slack-buffer-name :static ((class slack-pinned-items-buffer) room team) + (format "%s %s" (call-next-method) "Pinned Items")) + +(defmethod slack-buffer-name ((this slack-pinned-items-buffer)) + (with-slots (room team) this + (slack-buffer-name 'slack-pinned-items-buffer + room team))) + +(defmethod slack-buffer-buffer ((this slack-pinned-items-buffer)) + (slack-if-let* ((buf (get-buffer (slack-buffer-name this)))) + (progn + (slack-pinned-items-buffer-insert-items this) + buf) + (slack-buffer-init-buffer this))) + +(defmethod slack-pinned-items-buffer-insert-items ((this slack-pinned-items-buffer)) + (let* ((buf (get-buffer (slack-buffer-name this))) + (header-face '(:underline t :weight bold)) + (buf-header (propertize "Pinned Items\n" 'face header-face))) + (with-current-buffer buf + (let ((inhibit-read-only t)) + (delete-region (point-min) lui-output-marker)) + (let ((lui-time-stamp-position nil)) + (lui-insert buf-header t)) + (with-slots (team items) this + (if (< 0 (length items)) + (cl-loop for m in items + do (slack-buffer-insert this m t)) + (let ((inhibit-read-only t)) + (insert "No Pinned Items"))))))) + +(defmethod slack-buffer-init-buffer ((this slack-pinned-items-buffer)) + (let* ((buf (call-next-method))) + (with-current-buffer buf + (slack-pinned-items-buffer-mode) + (slack-buffer-set-current-buffer this)) + (slack-pinned-items-buffer-insert-items this) + (with-slots (room team) this + (slack-buffer-push-new-3 'slack-pinned-items-buffer room team)) + buf)) + +(defun slack-create-pinned-items-buffer (room team items) + + (cl-labels + ((create-item + (item) + (let ((type (plist-get item :type))) + (slack-pinned-item-create + (cond + ((string= type "message") + (slack-message-create (plist-get item :message) + team :room room)) + ((string= type "file") + (or (slack-file-find (plist-get (plist-get item :file) :id) team) + (slack-file-create (plist-get item :file)))) + ((string= type "file_comment") + (slack-file-comment-create (plist-get item :comment) + (plist-get (plist-get item :file) :id)))))))) + (slack-if-let* ((buf (slack-buffer-find 'slack-pinned-items-buffer room team))) + (progn + (oset buf items (mapcar #'create-item items)) + buf) + (slack-pinned-items-buffer :room room + :team team + :items (mapcar #'create-item items))))) + + + +(provide 'slack-pinned-items-buffer) +;;; slack-pinned-items-buffer.el ends here |