(defface lirc-faded
'((t :inherit font-lock-preprocessor-face))
- "Face used for Lirc text.")
+ "Face used for faded Lirc text.")
(defface lirc-bold
'((t :inherit font-lock-function-name-face))
- "Face used for Lirc text.")
+ "Face used for bold Lirc text.")
+
+(defface lirc-error
+ '((t :inherit font-lock-regexp-grouping-construct))
+ "Face used for Lirc error text.")
;;; Global variables
;;
"!" 'face 'lirc-bold)
(propertize
"-" 'face 'lirc-faded)))
-
+
+(defvar lirc-error-prompt
+ (propertize "!!!" 'face 'lirc-error))
+
;;; Network process
;;
(lirc-eval-msg-string (string-trim line))
(setq lirc-response line))))
-(defun lirc-get-process ()
+(defun lirc-get-process (&optional connect)
(let ((proc (get-process "lirc")))
(if (and proc (eq (process-status proc) 'open))
proc
- (make-network-process :name "lirc"
- :host lirc-host
- :service lirc-port
- :filter #'lirc-filter
- :nowait nil
- :tls-parameters (cons 'gnutls-x509pki
- (gnutls-boot-parameters
- :type 'gnutls-x509pki
- :hostname lirc-host))
- :buffer "*lirc*"))))
+ (if connect
+ (make-network-process :name "lirc"
+ :host lirc-host
+ :service lirc-port
+ :filter #'lirc-filter
+ :nowait nil
+ :tls-parameters (cons 'gnutls-x509pki
+ (gnutls-boot-parameters
+ :type 'gnutls-x509pki
+ :hostname lirc-host))
+ :buffer "*lirc*")
+ (lirc-display-error "No server connection established.")
+ (error "No server connection established")))))
;;; Messages
;;
'read-only t))))))
(defun lirc-connect ()
+ (lirc-get-process t)
(lirc-send-msg (lirc-msg nil nil "USER" lirc-user-name 0 "*" lirc-full-name))
(lirc-send-msg (lirc-msg nil nil "NICK" lirc-nick)))
(defun lirc-render-prompt ()
(with-current-buffer "*lirc*"
- (set-marker-insertion-type lirc-prompt-marker nil)
- (set-marker-insertion-type lirc-input-marker t)
(save-excursion
+ (set-marker-insertion-type lirc-prompt-marker nil)
+ (set-marker-insertion-type lirc-input-marker t)
(let ((inhibit-read-only t))
(delete-region lirc-prompt-marker lirc-input-marker)
(goto-char lirc-prompt-marker)
(propertize lirc-prompt-string
'face 'lirc-prompt
'read-only t
- 'rear-nonsticky t)))))
- (set-marker-insertion-type lirc-input-marker nil))
+ 'rear-nonsticky t)))
+ (set-marker-insertion-type lirc-input-marker nil))))
(defvar lirc-prompt-marker nil
"Marker for prompt position in LIRC buffer.")
(defun lirc-display-notice (&rest notices)
(lirc-display-string lirc-notice-prompt " " (apply #'concat notices)))
+(defun lirc-display-error (&rest messages)
+ (lirc-display-string lirc-error-prompt " "
+ (propertize (apply #'concat messages)
+ 'face 'lirc-error)))
+
;;; Message evaluation
;;
(let ((channel (car (lirc-msg-params msg))))
(setq lirc-current-channel channel)
(lirc-add-channel channel)
+ (lirc-display-notice "Joining channel " channel)
(lirc-render-prompt)))
("JOIN"
((and "PART"
(guard (equal lirc-nick (lirc-msg-src msg))))
+ (lirc-display-notice "Left channel " lirc-current-channel)
(setq lirc-current-channel nil)
(lirc-del-channel (car (lirc-msg-params msg)))
(lirc-render-prompt))