summaryrefslogtreecommitdiffhomepage
path: root/net/signel.org
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2020-07-08 16:51:47 +0100
committerjao <jao@gnu.org>2020-07-08 16:51:47 +0100
commit398c059dc13ab46bffffc0087a95b8b31bb1f90b (patch)
tree01e912f8e52aea7ff0cb342493d9bb6a22f79ddc /net/signel.org
parent313a6938101c868c5633fa82e6acea87486277dd (diff)
downloadelibs-398c059dc13ab46bffffc0087a95b8b31bb1f90b.tar.gz
elibs-398c059dc13ab46bffffc0087a95b8b31bb1f90b.tar.bz2
signel tweaks
Diffstat (limited to 'net/signel.org')
-rw-r--r--net/signel.org59
1 files changed, 31 insertions, 28 deletions
diff --git a/net/signel.org b/net/signel.org
index 6f54456..25b7d25 100644
--- a/net/signel.org
+++ b/net/signel.org
@@ -393,6 +393,12 @@ functions to format those parts:
(when (looking-at-p (regexp-quote signel-prompt))
(let ((inhibit-read-only t))
(delete-char (length signel-prompt)))))
+
+(defun signel--delete-last-prompt ()
+ (goto-char (point-max))
+ (when (re-search-backward (concat "^" (regexp-quote signel-prompt)))
+ (signel--delete-prompt)))
+
#+end_src
With that, we're finally ready to insert messages in our signel chat
@@ -414,35 +420,32 @@ buffers:
(when (fboundp 'tracking-add-buffer)
(tracking-add-buffer (current-buffer) '(signel-notification))))
+(defun signel--needs-insert-p (data stamp rec-stamp msg)
+ (or data
+ (and (or rec-stamp stamp)
+ (not (string= source signel-cli-user))
+ (or signel-report-deliveries
+ (and signel-report-read (signel--msg-is-read msg))))))
+
(defun signel--update-chat-buffer (source data stamp rec-stamp msg)
- (when-let ((b (signel--contact-buffer source)))
- (with-current-buffer b
- (goto-char (point-max))
- (beginning-of-line)
- (signel--delete-prompt)
- (if data
- (let ((p (point)))
- (insert (signel--timestamp "[" stamp "] ")
- (signel--contact (signel--contact-name source))
- signel-prompt
- data
- "\n")
- (fill-region p (point))
- (signel--prompt-and-notify))
- (let ((is-delivery (or (signel--msg-is-delivery msg)
- (signel--msg-is-receipt msg)))
- (is-read (signel--msg-is-read msg)))
- (if (and (or rec-stamp stamp)
- (not (string= source signel-cli-user))
- (or signel-report-deliveries
- (and signel-report-read is-read)))
- (let ((inhibit-read-only t))
- (insert (signel--timestamp "*" (or rec-stamp stamp) "* ")
- (signel--notice (if is-read "(read)" "(delivered)"))
- "\n")
- (signel--prompt-and-notify))
- (signel--insert-prompt))))
- (end-of-line))))
+ (when (signel--needs-insert-p data stamp rec-stamp msg)
+ (when-let ((b (signel--contact-buffer source)))
+ (with-current-buffer b
+ (signel--delete-last-prompt)
+ (if data
+ (let ((p (point)))
+ (insert (signel--timestamp "[" stamp "] ")
+ (signel--contact (signel--contact-name source))
+ signel-prompt
+ data
+ "\n")
+ (fill-region p (point)))
+ (let ((is-read (signel--msg-is-read msg)))
+ (insert (signel--timestamp "*" (or rec-stamp stamp) "* ")
+ (signel--notice (if is-read "(read)" "(delivered)"))
+ "\n")))
+ (signel--prompt-and-notify)
+ (end-of-line)))))
#+end_src
There are some rough edges in the above implementation that must be