(goto-char (point-max))
(lurk-render-prompt)))
-;;; URL buttons
-
-(defconst lurk-url-regex
- (rx (:
- (group (+ alpha))
- "://"
- (group (or (+ (any alnum "." "-"))
- (+ (any alnum ":"))))
- (opt (group (: ":" (+ digit))))
- (opt (group (: "/"
- (opt
- (* (any alnum ",.-~/@|:%#=&_"))
- (+ (any alnum "-~/@|:%#=&")))))))))
-
-(defun lurk-click-url (button)
- (browse-url (button-get button 'url)))
-
-(defun lurk-buttonify-urls (string)
- "Turn substrings which look like urls in STRING into clickable buttons."
- (with-temp-buffer
- (insert string)
- (goto-char (point-min))
- (while (re-search-forward lurk-url-regex nil t)
- (let ((url (match-string 0)))
- (make-text-button (match-beginning 0)
- (match-end 0)
- 'action #'lurk-click-url
- 'url url
- 'follow-link t
- 'face 'button
- 'help-echo "Open URL in browser.")))
- (buffer-string)))
-
;;; Output formatting and highlighting
;;
;; and for different elements of the context-specific text to have
;; different styling.
-;; Additionally, we can allow selective hiding of contexts via
+;; Additionally, we allow selective hiding of contexts via
;; the buffer-invisibility-spec.
(defvar lurk-context-facelists (make-hash-table :test 'equal)
lurk-context-facelists)
(force-window-update "*lurk*")))
+(defconst lurk-url-regex
+ (rx (:
+ (group (+ alpha))
+ "://"
+ (group (or (+ (any alnum "." "-"))
+ (+ (any alnum ":"))))
+ (opt (group (: ":" (+ digit))))
+ (opt (group (: "/"
+ (opt
+ (* (any alnum ",.-~/@|:%#=&_"))
+ (+ (any alnum "-~/@|:%#=&")))))))))
+
+(defun lurk-click-url (button)
+ (browse-url (button-get button 'url)))
+
+(defun lurk-buttonify-urls (string)
+ "Turn substrings which look like urls in STRING into clickable buttons."
+ (with-temp-buffer
+ (insert string)
+ (goto-char (point-min))
+ (while (re-search-forward lurk-url-regex nil t)
+ (let ((url (match-string 0)))
+ (make-text-button (match-beginning 0)
+ (match-end 0)
+ 'action #'lurk-click-url
+ 'url url
+ 'follow-link t
+ 'face 'button
+ 'help-echo "Open URL in browser.")))
+ (buffer-string)))
+
+
;;; Message evaluation
;;
(lurk-enter-string line))))
-;;; Command completion
-;;
-
;;; Interactive functions
;;
(lurk-zoom-in lurk-current-context))
(setq lurk-zoomed (not lurk-zoomed)))
+(defun lurk-complete-nick ()
+ (interactive)
+ (when (and (>= (point) lurk-input-marker) lurk-current-context)
+ (let* ((end (max lurk-input-marker (point)))
+ (space-idx (save-excursion
+ (re-search-backward " " lurk-input-marker t)))
+ (start (if space-idx (+ 1 space-idx) lurk-input-marker)))
+ (unless (string-prefix-p "/" (buffer-substring start end))
+ (completion-in-region start end (lurk-get-context-users lurk-current-context))))))
+
;;; Mode
;;
(defvar lurk-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "RET") 'lurk-enter)
- (define-key map (kbd "<tab>") 'lurk-complete)
+ (define-key map (kbd "<tab>") 'lurk-complete-nick)
(define-key map (kbd "C-c C-z") 'lurk-toggle-zoom)
(define-key map (kbd "<C-tab>") 'lurk-cycle-contexts-forward)
(define-key map (kbd "<C-S-tab>") 'lurk-cycle-contexts-reverse)