summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--net/signel.org80
-rw-r--r--themes/jao-themes.el9
2 files changed, 57 insertions, 32 deletions
diff --git a/net/signel.org b/net/signel.org
index b429b21..6f54456 100644
--- a/net/signel.org
+++ b/net/signel.org
@@ -328,50 +328,71 @@ named ~signel-user~ that is set /after/ enabling ~signel-chat-mode~: order
here matters because the major mode activation cleans up the values of
any local variables previously set (i always forget that!).
-We have now almost all the ingredients to write
-~signel--update-chat-buffer~, the function that inserts the received
-message data into the chat buffer. We'll just need a couple of new
-faces for the different parts of inserted messages:
+* And a customization group
+
+We're going to need a couple of new faces for the different parts of
+inserted messages, so we'll take the chance to be tidy and introduce a
+customization group:
#+begin_src emacs-lisp
(defgroup signel nil "Signel")
-(defface signel-contact-face '((t :weight bold))
+(defface signel-contact '((t :weight bold))
"Face for contact names."
:group 'signel)
-(defface signel-timestamp-face '((t :foreground "grey70"))
+(defface signel-timestamp '((t :foreground "grey70"))
"Face for timestamp names."
:group 'signel)
-(defface signel-notice-face '((t :inherit signel-timestamp-face))
+(defface signel-notice '((t :inherit signel-timestamp))
"Face for delivery notices."
:group 'signel)
-(defface signel-prompt-face '((t :weight bold))
+(defface signel-prompt '((t :weight bold))
"Face for the input prompt marker."
:group 'signel)
-(defface signel-notification-face '((t :foreground "burlywood"))
+(defface signel-user '((t :foreground "orangered"))
+ "Face for sent messages."
+ :group 'signel)
+
+(defface signel-notification '((t :foreground "burlywood"))
"Face for notifications shown by tracking, when available."
:group 'signel)
#+end_src
-and let's be tidy and define little functions to format those parts:
+
+* Displaying incoming messages
+
+We have now almost all the ingredients to write
+~signel--update-chat-buffer~, the function that inserts the received
+message data into the chat buffer. Let's define a few little
+functions to format those parts:
#+begin_src emacs-lisp
(defun signel--contact (name)
- (propertize name 'face 'signel-contact-face))
+ (propertize name 'face 'signel-contact))
(defun signel--timestamp (&rest p)
- (propertize (apply #'concat p) 'face 'signel-timestamp-face))
+ (propertize (apply #'concat p) 'face 'signel-timestamp))
(defun signel--notice (notice)
- (propertize notice 'face 'signel-notice-face))
-
-(defun signel--prompt ()
- (propertize signel-prompt 'face 'signel-prompt-face))
+ (propertize notice 'face 'signel-notice))
+
+(defun signel--insert-prompt ()
+ (let ((inhibit-read-only t)
+ (p (point)))
+ (insert signel-prompt)
+ (set-text-properties p (- (point) 1)
+ '(face signel-prompt
+ read-only t front-sticky t rear-sticky t))))
+
+(defun signel--delete-prompt ()
+ (when (looking-at-p (regexp-quote signel-prompt))
+ (let ((inhibit-read-only t))
+ (delete-char (length signel-prompt)))))
#+end_src
With that, we're finally ready to insert messages in our signel chat
@@ -389,21 +410,21 @@ buffers:
:type 'boolean)
(defun signel--prompt-and-notify ()
- (insert (signel--prompt))
+ (signel--insert-prompt)
(when (fboundp 'tracking-add-buffer)
- (tracking-add-buffer (current-buffer) '(signel-notification-face))))
+ (tracking-add-buffer (current-buffer) '(signel-notification))))
(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)
- (ignore-errors (delete-char (length signel-prompt)))
+ (signel--delete-prompt)
(if data
(let ((p (point)))
(insert (signel--timestamp "[" stamp "] ")
(signel--contact (signel--contact-name source))
- (signel--prompt)
+ signel-prompt
data
"\n")
(fill-region p (point))
@@ -415,11 +436,12 @@ buffers:
(not (string= source signel-cli-user))
(or signel-report-deliveries
(and signel-report-read is-read)))
- (progn (insert (signel--timestamp "*" (or rec-stamp stamp) "* ")
- (signel--notice (if is-read "(read)" "(delivered)"))
- "\n")
- (signel--prompt-and-notify))
- (insert (signel--prompt)))))
+ (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))))
#+end_src
@@ -429,7 +451,7 @@ handling of timestamps and their formats. And of course notifications
should be much more customizable (here i'm using [[https://github.com/jorgenschaefer/circe/blob/master/tracking.el][Circe's tracking.el]]
if available).
-* The DBUS interface
+* Sending messages: the DBUS interface
With that, we're going to receive and display messages and simple
receipts, and i'm sure that we will feel the urge to answer some of
@@ -482,12 +504,14 @@ when the buffer was created."
(let* ((p (point))
(plen (length signel-prompt))
(msg (buffer-substring (+ p plen) (point-max))))
- (delete-char plen)
+ (signel--delete-prompt)
(signel--send-message signel-user msg)
(insert (signel--timestamp (format-time-string "(%H:%M) ")))
(fill-region p (point-max))
(goto-char (point-max))
- (insert "\n" (signel--prompt))))
+ (set-text-properties p (point) '(face signel-user))
+ (insert "\n")
+ (signel--insert-prompt)))
#+end_src
and we can bind it to the return key in signal chat buffers:
diff --git a/themes/jao-themes.el b/themes/jao-themes.el
index c288ef6..595f027 100644
--- a/themes/jao-themes.el
+++ b/themes/jao-themes.el
@@ -811,10 +811,11 @@
(show-paren-match (p hilite))
(show-paren-mismatch (p error))
(signel-contact-face (p f11))
- (signel-notice-face (p dimm))
- (signel-notification-face (p warning))
- (signel-prompt-face bf)
- (signel-timestamp-face (p dimm))
+ (signel-notice (p dimm))
+ (signel-notification (p warning))
+ (signel-prompt it)
+ (signel-timestamp (p dimm))
+ (signel-user (p f00))
(slack-channel-button-face (~ link))
(slack-message-action-face (~ link))
(slack-message-mention-face (p f01))