-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack.el
138 lines (119 loc) · 4.27 KB
/
slack.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
;;; slack.el --- slack configuration -*- lexical-binding: t; -*-
(use-package slack
:straight (:type git :host github :repo "isamert/emacs-slack" :branch "master")
:disabled t
:init
(setq slack-buffer-emojify t
slack-prefer-current-team t
slack-file-dir "~/Downloads/")
;; just here to avoid issues with autoloads below not sure why this is necessary
(defun slack-thread-message-buffer ())
:config
;; make default same window
(setq slack-buffer-function #'switch-to-buffer)
;; setup team
(slack-register-team
:name "silvermanlabhq"
:default t
:token (auth-source-pick-first-password
:host "silvermanlabhq.slack.com"
:user "[email protected]")
:cookie (auth-source-pick-first-password
:host "silvermanlabhq.slack.com"
:user "[email protected]^cookie")
:subscribed-channels '((bacteremia fido-development general random interesting-papers))
:modeline-enabled t
:modeline-name "")
;; setup modeline
;; https://github.com/yuya373/emacs-slack/pull/179
;; (setq slack-modeline-formatter 'slack-default-modeline-formatter)
(defun jds~slack-default-modeline-formatter (alist)
"Element in ALIST is '((team-name . ((thread . (has-unreads .
mention-count)) (channel . (has-unreads . mention-count)))))"
(mapconcat #'(lambda (e)
(let* ((team-name (car e))
(summary (cdr e))
(thread (cdr (cl-assoc 'thread summary)))
(channel (cdr (cl-assoc 'channel summary)))
(thread-has-unreads (car thread))
(channel-has-unreads (car channel))
(has-unreads (or thread-has-unreads
channel-has-unreads))
(thread-mention-count (cdr thread))
(channel-mention-count (cdr channel)))
(format " S:%s "
(if (or channel-has-unreads (< 0 channel-mention-count))
(propertize (number-to-string channel-mention-count)
'face 'slack-modeline-channel-has-unreads-face)
channel-mention-count))))
alist " "))
(setq slack-modeline-formatter 'jds~slack-default-modeline-formatter)
(setq slack-enable-global-mode-string t)
;; enable live markup in messages
;; (setq slack-enable-wysiwyg t)
;; add company support
;; (add-to-list 'company-backends 'company-slack-backend)
;; setup tab command - bind over lui mode completion
;; (add-hook 'slack-mode-hook 'jds/completion-keys)
;; (setq lui-completion-function 'company-complete)
;; auto-start slack if connected to the internet and not already started
(if (and (jds~internet-up-p)
;; (not (fboundp 'slack-select-rooms))
)
(slack-start))
)
;; quick reactions with thumbs up
;;;###autoload
(defun jds/slack-message-add-thumbsup ()
(interactive)
(slack-if-let* ((buf slack-current-buffer)
;; (team (slack-buffer-team buf))
(reaction "+1"))
(slack-buffer-add-reaction-to-message buf
reaction
(slack-get-ts))))
(use-package ol-emacs-slack
:straight (ol-emacs-slack :type git :host github :repo "ag91/ol-emacs-slack"))
(jds/localleader-def
:keymaps 'slack-info-mode-map
:state 'normal
"u" #'slack-room-update-messages)
(jds/localleader-def
:keymaps 'slack-mode-map
:state 'normal
"d" 'slack-buffer-kill
"+" 'jds/slack-message-add-thumbsup
"rr" 'slack-message-add-reaction
"rR" 'slack-message-remove-reaction
"rs" 'slack-message-show-reaction-users
"pl" 'slack-room-pins-list
"pa" 'slack-message-pins-add
"pr" 'slack-message-pins-remove
"s" 'slack-search-from-messages
"fs" 'slack-search-from-files
"fl" 'slack-file-list
"mm" 'slack-message-write-another-buffer
"me" 'slack-message-edit
"md" 'slack-message-delete
"u" 'slack-room-update-messages
"M" 'slack-message-embed-mention
"C" 'slack-message-embed-channel
"a" 'slack-file-upload
"A" 'slack-download-file-at-point)
(general-define-key
:keymaps 'slack-mode-map
:states 'n
"C-j" 'slack-buffer-goto-next-message
"C-k" 'slack-buffer-goto-prev-message)
(jds/localleader-def
:keymaps 'slack-edit-message-mode-map
:state 'normal
"k" 'slack-message-cancel-edit
"m" 'slack-message-send-from-buffer
"M" 'slack-message-embed-mention
"C" 'slack-message-embed-channel)
;; dependencies
(use-package alert
:commands (alert)
:init
(setq alert-default-style 'notifier))