This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathweechat-smiley.el
86 lines (69 loc) · 2.67 KB
/
weechat-smiley.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
;;; weechat-smiley --- Display smiley faces ;; -*- lexical-binding: t -*-
;; Copyright (C) 2013 Rüdiger Sonderfeld <[email protected]>
;; Author: Rüdiger Sonderfeld <[email protected]>
;; Moritz Ulrich <[email protected]>
;; Aristid Breitkreuz <[email protected]>
;; Keywords: irc chat network weechat
;; URL: https://github.com/the-kenny/weechat.el
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; This module uses `smiley-region' from Gnus smiley.el.
;; To support short smileys (without nose) use:
;;
;; (setq smiley-regexp-alist
;; '(("\\(;-?)\\)\\W" 1 "blink")
;; ("[^;]\\(;)\\)\\W" 1 "blink")
;; ("\\(:-?]\\)\\W" 1 "forced")
;; ("\\(8-?)\\)\\W" 1 "braindamaged")
;; ("\\(:-?|\\)\\W" 1 "indifferent")
;; ("\\(:-?[/\\]\\)\\W" 1 "wry")
;; ("\\(:-?(\\)\\W" 1 "sad")
;; ("\\(X-?)\\)\\W" 1 "dead")
;; ("\\(:-?{\\)\\W" 1 "frown")
;; ("\\(>:-?)\\)\\W" 1 "evil")
;; ("\\(;-?(\\)\\W" 1 "cry")
;; ("\\(:-?D\\)\\W" 1 "grin")
;; ;; "smile" must be come after "evil"
;; ("\\(\\^?:-?)\\)\\W" 1 "smile")))
;; It might be necessary to run
;;
;; (setq smiley-cached-regexp-alist nil)
;; (smiley-update-cache)
;;
;; To make it work when smiley is already loaded.
;;; Code:
(require 'smiley)
(require 'weechat)
(defun weechat-smiley-buffer ()
"Smiley the region."
(let ((inhibit-read-only t))
(smiley-buffer)))
(defun weechat-smiley--do ()
"Hook for weechat."
(save-excursion
(let ((inhibit-read-only t))
(smiley-region (+ (point-min) weechat-text-column) (point-max)))))
(weechat-do-buffers (weechat-smiley-buffer))
(add-hook 'weechat-insert-modify-hook #'weechat-smiley--do)
(defun weechat-smiley-unload-function ()
"Remove smileys from buffer."
(save-restriction
(widen)
(let ((inhibit-read-only t))
(weechat-do-buffers
;; smiley-toggle-buffer is broken somewhere in
;; `gnus-with-article-buffer'. Remove smileys directly.
(smiley-region (point-min) (point-max))
(gnus-delete-images 'smiley)))))
(provide 'weechat-smiley)
;;; weechat-smiley.el ends here