X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=lurk.el;h=66517ba7994604ba30b37333dfda120640f50fe8;hb=ee4de69b88aeb45a4635a5baac687217d3c8c8a2;hp=d96937623efcf7068822d4b61bf52c08f93e53c9;hpb=8d5f43f0bd77d211cca577b99fc93be7d87a9231;p=lurk.git diff --git a/lurk.el b/lurk.el index d969376..66517ba 100644 --- a/lurk.el +++ b/lurk.el @@ -271,10 +271,13 @@ portion of the source component of the message, as LURK doesn't use this.") (defun lurk-get-context-users (name) (gethash name lurk-contexts)) +(defun lurk-context-known-p (name) + (not (eq (gethash name lurk-contexts 0) 0))) + (defun lurk-add-context-users (context users) (puthash context - (append users - (gethash context lurk-contexts)) + (cl-union users + (gethash context lurk-contexts)) lurk-contexts)) (defun lurk-del-context-user (context user) @@ -443,8 +446,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) @@ -471,7 +487,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)) @@ -530,7 +547,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*" @@ -539,7 +557,8 @@ 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)) (defconst lurk-url-regex (rx (: @@ -635,15 +654,19 @@ portion of the source component of the message, as LURK doesn't use this.") (let* ((params (lurk-msg-params msg)) (channel (elt params 2)) (names (split-string (elt params 3)))) - (lurk-add-context-users channel names))) + (if (lurk-context-known-p channel) + (lurk-add-context-users channel names) + (lurk-display-notice nil "Users in " channel ": " (string-join names " "))))) ("366" ; ENDOFNAMES (let* ((params (lurk-msg-params msg)) (channel (elt params 1))) - (lurk-display-notice - channel - (lurk--as-string (length (lurk-get-context-users channel))) - " users in " channel))) + (if (lurk-context-known-p channel) + (lurk-display-notice + channel + (lurk--as-string (length (lurk-get-context-users channel))) + " users in " channel) + (lurk-display-notice nil "End of " channel " names list.")))) ("331" (let* ((params (lurk-msg-params msg)) @@ -827,13 +850,15 @@ 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) ("HELP" "Display help on client commands." lurk-command-help lurk-help-completions)) "Table of commands explicitly supported by Lurk.") @@ -903,9 +928,11 @@ 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-quit (params) - (let ((quit-msg (if params (string-join params " ") nil))) - (lurk-send-msg (lurk-msg nil nil "QUIT" quit-msg)))) +(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))) @@ -922,7 +949,7 @@ in which case they match anything.") (lurk-display-notice nil "Usage: /version "))) (defun lurk-command-quit (params) - (let ((quit-msg (if params (string-join parms " ") lurk-default-quit-msg))) + (let ((quit-msg (if params (string-join params " ") lurk-default-quit-msg))) (lurk-send-msg (lurk-msg nil nil "QUIT" quit-msg)))) (defun lurk-command-nick (params) @@ -982,7 +1009,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))))) (_