[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/gnus-select 5d21c62 3/7: Add support for IRCv3 mes
From: |
Andrew G Cohen |
Subject: |
[Emacs-diffs] feature/gnus-select 5d21c62 3/7: Add support for IRCv3 message tags. |
Date: |
Mon, 24 Apr 2017 21:17:11 -0400 (EDT) |
branch: feature/gnus-select
commit 5d21c627f763fcfcdf3bcda4981203509b440d45
Author: Vibhav Pant <address@hidden>
Commit: Andrew G Cohen <address@hidden>
Add support for IRCv3 message tags.
* erc-backend.el:
erc-response: Add `tags' element.
Add (erc-parse-tags).
(erc-parse-server-response): Use (erc-parse-tags) to parse message
tags (if any), and store them in `erc-resopnse' struct.
* erc.el: (erc-display-message): Expose message tags with text
properties of the corresponding message line.
---
lisp/erc/erc-backend.el | 30 +++++++++++++++++++++++++-----
lisp/erc/erc.el | 5 ++++-
2 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 8eac2e1..3368d67 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -53,6 +53,7 @@
;; CONTENTS --- `erc-response.contents'
;; SENDER --- `erc-response.sender'
;; LINE --- `erc-response.unparsed'
+;; TAGS --- `erc-response.tags'
;;
;; WARNING, WARNING!!
;; It's probably not a good idea to destructively modify the list
@@ -115,7 +116,8 @@
(sender "" :type string)
(command "" :type string)
(command-args '() :type list)
- (contents "" :type string))
+ (contents "" :type string)
+ (tags '() :type list))
;;; User data
@@ -955,16 +957,34 @@ See also `erc-server-send'."
;;;; Handling responses
+(defun erc-parse-tags (string)
+ "Parse IRCv3 tags list in STRING to a (tag . value) alist."
+ (let ((tags)
+ (tag-strings (split-string string ";")))
+ (dolist (tag-string tag-strings tags)
+ (let ((pair (split-string tag-string "=")))
+ (push (if (consp pair)
+ pair
+ `(,pair))
+ tags)))))
+
(defun erc-parse-server-response (proc string)
"Parse and act upon a complete line from an IRC server.
PROC is the process (connection) from which STRING was received.
PROCs `process-buffer' is `current-buffer' when this function is called."
(unless (string= string "") ;; Ignore empty strings
(save-match-data
- (let ((posn (if (eq (aref string 0) ?:)
- (string-match " " string)
- 0))
- (msg (make-erc-response :unparsed string)))
+ (let* ((tag-list (when (eq (aref string 0) ?@)
+ (substring string 1 (string-match " " string))))
+ (msg (make-erc-response :unparsed string :tags (when tag-list
+ (erc-parse-tags
+ tag-list))))
+ (string (if tag-list
+ (substring string (+ 1 (string-match " " string)))
+ string))
+ (posn (if (eq (aref string 0) ?:)
+ (string-match " " string)
+ 0)))
(setf (erc-response.sender msg)
(if (eq posn 0)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 7e19ebb..8c65016 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -2700,7 +2700,10 @@ See also `erc-format-message' and `erc-display-line'."
(unless (erc-hide-current-message-p parsed)
(erc-put-text-property 0 (length string) 'erc-parsed parsed string)
(erc-put-text-property 0 (length string) 'rear-sticky t string)
- (erc-display-line string buffer)))))
+ (when (erc-response.tags parsed)
+ (erc-put-text-property 0 (length string) 'tags (erc-response.tags
parsed)
+ string))
+ (erc-display-line string buffer)))))
(defun erc-message-type-member (position list)
"Return non-nil if the erc-parsed text-property at POSITION is in LIST.
- [Emacs-diffs] feature/gnus-select updated (6ff9a4f -> e7fd724), Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select 66d1ec0 6/7: Remove s_client usage from tls.el, Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select bcf49f6 5/7: Further robustify cedet bootstrap to loaddefs not yet built, Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select e528a75 4/7: Fix XBM colour rendering in NS port (bug#22060), Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select 5d21c62 3/7: Add support for IRCv3 message tags.,
Andrew G Cohen <=
- [Emacs-diffs] feature/gnus-select e7fd724 7/7: Don't advertise s_client in tls.el docs, Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select ec5a249 1/7: Needlessly refactor tests for clarity, Andrew G Cohen, 2017/04/24
- [Emacs-diffs] feature/gnus-select 7bbc43e 2/7: Add image sizing tests for an image that's narrow, Andrew G Cohen, 2017/04/24