(lurk-display-notice nil " \x02" (elt row 0) "\x02: " (elt row 1)))
(lurk-display-notice nil "Use /HELP COMMAND to display information about a specific command.")))
-;;; Command entering
-;;
-
-(defun lurk-enter-string (string)
- (if (string-prefix-p "/" string)
- (pcase string
- ((rx (: "/" (let cmd-str (+ (not whitespace)))
- (opt (+ whitespace)
- (let params-str (+ anychar))
- string-end)))
- (let ((command-row (assoc (upcase cmd-str) lurk-command-table #'equal))
- (params (if params-str
- (split-string params-str nil t)
- nil)))
- (if command-row
- (funcall (elt command-row 2) params)
- (lurk-send-msg (lurk-msg nil nil (upcase cmd-str) params)))))
- (_
- (lurk-display-error "Badly formed command.")))
- (unless (string-empty-p string)
- (if lurk-current-context
- (progn
- (lurk-send-msg (lurk-msg nil nil "PRIVMSG"
- lurk-current-context
- string))
- (lurk-display-message lurk-nick lurk-current-context string))
- (lurk-display-error "No current context.")))))
-
(defun lurk-command-debug (params)
(setq lurk-debug
(if params
(lurk-display-notice nil "Usage: /msg <nick> <message>")))
+;;; Command entering
+;;
+
+(defun lurk-enter-string (string)
+ (if (string-prefix-p "/" string)
+ (pcase string
+ ((rx (: "/" (let cmd-str (+ (not whitespace)))
+ (opt (+ whitespace)
+ (let params-str (+ anychar))
+ string-end)))
+ (let ((command-row (assoc (upcase cmd-str) lurk-command-table #'equal))
+ (params (if params-str
+ (split-string params-str nil t)
+ nil)))
+ (if command-row
+ (funcall (elt command-row 2) params)
+ (lurk-send-msg (lurk-msg nil nil (upcase cmd-str) params)))))
+ (_
+ (lurk-display-error "Badly formed command.")))
+ (unless (string-empty-p string)
+ (if lurk-current-context
+ (progn
+ (lurk-send-msg (lurk-msg nil nil "PRIVMSG"
+ lurk-current-context
+ string))
+ (lurk-display-message lurk-nick lurk-current-context string))
+ (lurk-display-error "No current context.")))))
+
+
;;; Command history
;;
(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)
(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
;;
(lurk-zoom-in lurk-current-context))
(setq lurk-zoomed (not lurk-zoomed)))
+(defun lurk-history-next ()
+ (interactive)
+ (lurk-history-cycle -1))
+
+(defun lurk-history-prev ()
+ (interactive)
+ (lurk-history-cycle +1))
+
(defun lurk-complete-input ()
(interactive)
(let ((completion-ignore-case t))
(unless (string-prefix-p "/" (buffer-substring start end))
(completion-in-region start end (lurk-get-context-users lurk-current-context)))))))))
+(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))))
+
+
;;; Mode
;;
(when (fboundp 'evil-set-initial-state)
(evil-set-initial-state 'lurk-mode 'insert))
+
;;; Main start procedure
;;