X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=lurk.el;h=447f5f5d31674f923707665514ddc44d798490b0;hb=bbb819b11b302e1352ec5c704df53b006527b0b0;hp=f030555415e7ac50bb3657ca00417fddd0bbcec9;hpb=1f57d5c028e295e732927c268de80daf2f8f0cae;p=lurk.git diff --git a/lurk.el b/lurk.el index f030555..447f5f5 100644 --- a/lurk.el +++ b/lurk.el @@ -409,6 +409,11 @@ portion of the source component of the message, as LURK doesn't use this.") (if lurk-display-header (lurk-setup-header)))) +(defun lurk-clear-buffer () + "Completely erase all non-prompt and non-input text from lurk buffer." + (with-current-buffer "*lurk*" + (let ((inhibit-read-only t)) + (delete-region (point-min) lurk-prompt-marker)))) ;;; Output formatting and highlighting ;; @@ -446,8 +451,21 @@ portion of the source component of the message, as LURK doesn't use this.") (fill-region (point-min) (point-max) nil t) (buffer-string)))) +(defun lurk--start-of-final-line () + (with-current-buffer "*lurk*" + (save-excursion + (goto-char (point-max)) + (line-beginning-position)))) + +(defun lurk-scroll-windows-to-last-line () + (with-current-buffer "*lurk*" + (dolist (window (get-buffer-window-list)) + (if (>= (window-point window) (lurk--start-of-final-line)) + (with-selected-window window + (recenter -1)))))) + (defun lurk-display-string (context prefix &rest strings) - (with-current-buffer (get-buffer-create "*lurk*") + (with-current-buffer "*lurk*" (save-excursion (goto-char lurk-prompt-marker) (let* ((inhibit-read-only t) @@ -474,7 +492,8 @@ portion of the source component of the message, as LURK doesn't use this.") 'face (lurk-get-context-facelist context) 'read-only t 'context context - 'invisible context-atom)))))))) + 'invisible context-atom))))))) + (lurk-scroll-windows-to-last-line)) (defun lurk-display-message (from to text) (let ((context (if (eq 'channel (lurk-get-context-type to)) @@ -533,7 +552,8 @@ portion of the source component of the message, as LURK doesn't use this.") (remove-from-invisibility-spec this-context-atom) (add-to-invisibility-spec this-context-atom))))) lurk-context-facelists) - (force-window-update "*lurk*"))) + (force-window-update "*lurk*")) + (lurk-scroll-windows-to-last-line)) (defun lurk-zoom-out () (with-current-buffer "*lurk*" @@ -542,7 +562,18 @@ portion of the source component of the message, as LURK doesn't use this.") (let ((this-context-atom (if this-context (intern this-context) nil))) (remove-from-invisibility-spec this-context-atom))) lurk-context-facelists) - (force-window-update "*lurk*"))) + (force-window-update "*lurk*")) + (lurk-scroll-windows-to-last-line)) + +(defun lurk-clear-context (context) + (with-current-buffer "*lurk*" + (save-excursion + (goto-char (point-min)) + (let ((inhibit-read-only t) + (match nil)) + (while (setq match (text-property-search-forward 'context context t)) + (delete-region (prop-match-beginning match) + (prop-match-end match))))))) (defconst lurk-url-regex (rx (: @@ -586,7 +617,8 @@ portion of the source component of the message, as LURK doesn't use this.") (strikethrough nil) (prev-point (point))) (while (re-search-forward (rx (or (any "\x02\x1D\x1F\x1E\x0F") - (: "\x03" (+ digit) (opt "," (* digit))))) nil t) + (: "\x03" (+ digit) (opt "," (* digit))))) + nil t) (let ((beg (+ (match-beginning 0) 1))) (if bold (add-face-text-property prev-point beg '(:weight bold))) @@ -834,14 +866,17 @@ in which case they match anything.") ("HEADER" "Toggle display of header." lurk-command-header lurk-boolean-completions) ("CONNECT" "Connect to an IRC network." lurk-command-connect lurk-network-completions) ("NETWORKS" "List known IRC networks." lurk-command-networks) + ("JOIN" "Join one or more channels." lurk-command-join) ("TOPIC" "Set topic for current channel." lurk-command-topic) ("ME" "Display action." lurk-command-me) - ("VERSION" "Request version of another user's client via CTCP." lurk-command-version) + ("VERSION" "Request version of another user's client via CTCP." lurk-command-version lurk-nick-completions) ("PART" "Leave channel." lurk-command-part lurk-context-completions) ("QUIT" "Disconnect from current network." lurk-command-quit) ("NICK" "Change nick." lurk-command-nick) ("LIST" "Display details of one or more channels." lurk-command-list) + ("WHOIS" "Ask server for details of nick." nil lurk-nick-completions) ("MSG" "Send private message to user." lurk-command-msg lurk-nick-completions) + ("CLEAR" "Clear buffer text." lurk-command-clear lurk-context-completions) ("HELP" "Display help on client commands." lurk-command-help lurk-help-completions)) "Table of commands explicitly supported by Lurk.") @@ -910,6 +945,12 @@ in which case they match anything.") " " (number-to-string port) "]"))) (lurk-display-notice nil "(Modify the `lurk-networks' variable to add more.)")) +(defun lurk-command-join (params) + (if params + (dolist (channel params) + (lurk-send-msg (lurk-msg nil nil "JOIN" channel))) + (lurk-display-notice nil "Usage: /join channel [channel2 ...]"))) + (defun lurk-command-part (params) (let ((channel (if params (car params) lurk-current-context))) (if channel @@ -970,6 +1011,11 @@ in which case they match anything.") (lurk-display-message lurk-nick to text)) (lurk-display-notice nil "Usage: /msg "))) +(defun lurk-command-clear (params) + (if (not params) + (lurk-clear-buffer) + (dolist (context params) + (lurk-clear-context context)))) ;;; Command entering ;; @@ -985,7 +1031,7 @@ in which case they match anything.") (params (if params-str (split-string params-str nil t) nil))) - (if command-row + (if (and command-row (elt command-row 2)) (funcall (elt command-row 2) params) (lurk-send-msg (lurk-msg nil nil (upcase cmd-str) params))))) (_