(lurk-display-message lurk-nick lurk-current-context string))
(lurk-display-error "No current context.")))))
+(defvar lurk-history nil
+ "Commands and messages sent in current session.")
+
+
(defun lurk-enter ()
"Enter current contents of line after prompt."
(interactive)
(with-current-buffer "*lurk*"
(let ((line (buffer-substring lurk-input-marker (point-max))))
+ (push line lurk-history)
+ (setq lurk-history-index nil)
(let ((inhibit-read-only t))
(delete-region lurk-input-marker (point-max)))
(lurk-enter-string line))))
+(defvar lurk-history-index nil)
+
+(defun lurk-history-cycle (delta)
+ (when lurk-history
+ (with-current-buffer "*lurk*"
+ (if lurk-history-index
+ (setq lurk-history-index
+ (max 0
+ (min (- (length lurk-history) 1)
+ (+ delta lurk-history-index))))
+ (setq lurk-history-index 0))
+ (delete-region lurk-input-marker (point-max))
+ (insert (elt lurk-history lurk-history-index)))))
+
+(defun lurk-history-next ()
+ (interactive)
+ (lurk-history-cycle -1))
+
+(defun lurk-history-prev ()
+ (interactive)
+ (lurk-history-cycle +1))
;;; Interactive functions
;;
(unless (string-prefix-p "/" (buffer-substring start end))
(completion-in-region start end (lurk-get-context-users lurk-current-context))))))
+
;;; Mode
;;
(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)
+ (define-key map (kbd "<C-up>") 'lurk-history-prev)
+ (define-key map (kbd "<C-down>") 'lurk-history-next)
+ ;; (when (fboundp 'evil-define-key*)
+ ;; (evil-define-key* 'insert map
+ ;; (kbd "<C-Up>") 'lurk-history-prev
+ ;; (kbd "<C-Down>") 'lurk-history-next))
map))
+(defvar lurk-mode-map)
+
(define-derived-mode lurk-mode text-mode "lurk"
"Major mode for LURK.")