X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/275a5dd65098a2d6fcc14c21f805fc8d5e4479ee..8520d9c4e50520db79410ec6ef0052df129231dc:/lisp/net/rcirc.el diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index bd9d6846a4..f6981aeabd 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -455,15 +455,7 @@ If ARG is non-nil, instead prompt for connection parameters." :channels) " ")) "[, ]+" t)) - (encryption - (intern (completing-read "Encryption (default plain): " - '("plain" "tls") - nil t - (let ((choice (plist-get server-plist - :encryption))) - (when choice - (symbol-name choice))) - nil "plain")))) + (encryption (rcirc-prompt-for-encryption server-plist))) (rcirc-connect server port nick user-name rcirc-default-full-name channels password encryption)) @@ -596,6 +588,17 @@ If ARG is non-nil, instead prompt for connection parameters." (time-to-seconds (current-time)) (float-time))) +(defun rcirc-prompt-for-encryption (server-plist) + "Prompt the user for the encryption method to use. +SERVER-PLIST is the property list for the server." + (let ((msg "Encryption (default %s): ") + (choices '("plain" "tls")) + (default (or (plist-get server-plist :encryption) + 'plain))) + (intern + (completing-read (format msg default) + choices nil t nil nil (symbol-name default))))) + (defun rcirc-keepalive () "Send keep alive pings to active rcirc processes. Kill processes that have not received a server message since the @@ -812,18 +815,19 @@ If SILENT is non-nil, do not print the message in any irc buffer." (defvar rcirc-input-ring nil) (defvar rcirc-input-ring-index 0) + (defun rcirc-prev-input-string (arg) (ring-ref rcirc-input-ring (+ rcirc-input-ring-index arg))) -(defun rcirc-insert-prev-input (arg) - (interactive "p") +(defun rcirc-insert-prev-input () + (interactive) (when (<= rcirc-prompt-end-marker (point)) (delete-region rcirc-prompt-end-marker (point-max)) (insert (rcirc-prev-input-string 0)) (setq rcirc-input-ring-index (1+ rcirc-input-ring-index)))) -(defun rcirc-insert-next-input (arg) - (interactive "p") +(defun rcirc-insert-next-input () + (interactive) (when (<= rcirc-prompt-end-marker (point)) (delete-region rcirc-prompt-end-marker (point-max)) (setq rcirc-input-ring-index (1- rcirc-input-ring-index)) @@ -932,14 +936,6 @@ IRC command completion is performed only if '/' is the first input char." map) "Keymap for rcirc mode.") -(defvar rcirc-browse-url-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") 'rcirc-browse-url-at-point) - (define-key map (kbd "") 'rcirc-browse-url-at-mouse) - (define-key map [follow-link] 'mouse-face) - map) - "Keymap used for browsing URLs in `rcirc-mode'.") - (defvar rcirc-short-buffer-name nil "Generated abbreviation to use to indicate buffer activity.") @@ -968,7 +964,13 @@ This number is independent of the number of lines in the buffer.") (setq mode-line-process nil) (set (make-local-variable 'rcirc-input-ring) - (make-ring rcirc-input-ring-size)) + ;; If rcirc-input-ring is already a ring with desired size do + ;; not re-initialize. + (if (and (ring-p rcirc-input-ring) + (= (ring-size rcirc-input-ring) + rcirc-input-ring-size)) + rcirc-input-ring + (make-ring rcirc-input-ring-size))) (set (make-local-variable 'rcirc-server-buffer) (process-buffer process)) (set (make-local-variable 'rcirc-target) target) (set (make-local-variable 'rcirc-topic) nil) @@ -977,6 +979,7 @@ This number is independent of the number of lines in the buffer.") (set (make-local-variable 'rcirc-recent-quit-alist) nil) (set (make-local-variable 'rcirc-current-line) 0) + (use-hard-newlines t) (set (make-local-variable 'rcirc-short-buffer-name) nil) (set (make-local-variable 'rcirc-urls) nil) @@ -984,7 +987,7 @@ This number is independent of the number of lines in the buffer.") (setq buffer-invisibility-spec '()) (setq buffer-display-table (make-display-table)) (set-display-table-slot buffer-display-table 4 - (let ((glyph (make-glyph-code + (let ((glyph (make-glyph-code ?. 'font-lock-keyword-face))) (make-vector 3 glyph))) @@ -1148,7 +1151,7 @@ Create the buffer if it doesn't exist." (rcirc-generate-new-buffer-name process target)))) (with-current-buffer new-buffer (rcirc-mode process target) - (rcirc-put-nick-channel process (rcirc-nick process) target + (rcirc-put-nick-channel process (rcirc-nick process) target rcirc-current-line)) new-buffer))))) @@ -1235,7 +1238,7 @@ Create the buffer if it doesn't exist." (interactive) (let ((pos (1+ (- (point) rcirc-prompt-end-marker)))) (goto-char (point-max)) - (let ((text (buffer-substring-no-properties rcirc-prompt-end-marker + (let ((text (buffer-substring-no-properties rcirc-prompt-end-marker (point))) (parent (buffer-name))) (delete-region rcirc-prompt-end-marker (point)) @@ -1474,7 +1477,7 @@ record activity." (match-string 1 text))) rcirc-ignore-list)) ;; do not ignore if we sent the message - (not (string= sender (rcirc-nick process)))) + (not (string= sender (rcirc-nick process)))) (let* ((buffer (rcirc-target-buffer process sender response target text)) (inhibit-read-only t)) (with-current-buffer buffer @@ -1560,18 +1563,16 @@ record activity." ;; keep window on bottom line if it was already there (when rcirc-scroll-show-maximum-output - (walk-windows (lambda (w) - (when (eq (window-buffer w) (current-buffer)) - (with-current-buffer (window-buffer w) - (when (eq major-mode 'rcirc-mode) - (with-selected-window w - (when (<= (- (window-height) - (count-screen-lines (window-point) - (window-start)) - 1) - 0) - (recenter -1))))))) - nil t)) + (let ((window (get-buffer-window))) + (when window + (with-selected-window window + (when (eq major-mode 'rcirc-mode) + (when (<= (- (window-height) + (count-screen-lines (window-point) + (window-start)) + 1) + 0) + (recenter -1))))))) ;; flush undo (can we do something smarter here?) (buffer-disable-undo) @@ -1652,8 +1653,8 @@ log-files with absolute names (see `rcirc-log-filename-function')." (defun rcirc-view-log-file () "View logfile corresponding to the current buffer." (interactive) - (find-file-other-window - (expand-file-name (funcall rcirc-log-filename-function + (find-file-other-window + (expand-file-name (funcall rcirc-log-filename-function (rcirc-buffer-process) rcirc-target) rcirc-log-directory))) @@ -2141,6 +2142,16 @@ CHANNELS is a comma- or space-separated string of channel names." (dolist (b buffers) ;; order the new channel buffers in the buffer list (switch-to-buffer b))))) +(defun-rcirc-command invite (nick-channel) + "Invite NICK to CHANNEL." + (interactive (list + (concat + (completing-read "Invite nick: " + (with-rcirc-server-buffer rcirc-nick-table)) + " " + (read-string "Channel: ")))) + (rcirc-send-string process (concat "INVITE " nick-channel))) + ;; TODO: /part #channel reason, or consider removing #channel altogether (defun-rcirc-command part (channel) "Part CHANNEL." @@ -2348,21 +2359,6 @@ keywords when no KEYWORD is given." (browse-url (completing-read "rcirc browse-url: " completions nil nil initial-input 'history) arg))) - -(defun rcirc-browse-url-at-point (point) - "Send URL at point to `browse-url'." - (interactive "d") - (let ((beg (previous-single-property-change (1+ point) 'mouse-face)) - (end (next-single-property-change point 'mouse-face))) - (browse-url (buffer-substring-no-properties beg end)))) - -(defun rcirc-browse-url-at-mouse (event) - "Send URL at mouse click to `browse-url'." - (interactive "e") - (let ((position (event-end event))) - (with-current-buffer (window-buffer (posn-window position)) - (rcirc-browse-url-at-point (posn-point position))))) - (defun rcirc-markup-timestamp (sender response) (goto-char (point-min)) @@ -2403,12 +2399,16 @@ keywords when no KEYWORD is given." (while (and rcirc-url-regexp ;; nil means disable URL catching (re-search-forward rcirc-url-regexp nil t)) (let ((start (match-beginning 0)) - (end (match-end 0))) - (rcirc-add-face start end 'rcirc-url) - (add-text-properties start end (list 'mouse-face 'highlight - 'keymap rcirc-browse-url-map)) + (end (match-end 0)) + (url (match-string-no-properties 0))) + (make-button start end + 'face 'rcirc-url + 'follow-link t + 'rcirc-url url + 'action (lambda (button) + (browse-url (button-get button 'rcirc-url)))) ;; record the url - (push (buffer-substring-no-properties start end) rcirc-urls)))) + (push url rcirc-urls)))) (defun rcirc-markup-keywords (sender response) (when (and (string= response "PRIVMSG") @@ -2443,7 +2443,7 @@ keywords when no KEYWORD is given." rcirc-fill-column) (t fill-column)) ;; make sure ... doesn't cause line wrapping - 3))) + 3))) (fill-region (point) (point-max) nil t)))) ;;; handlers @@ -2530,6 +2530,7 @@ the only argument." (member message (list (format "You are now identified for \C-b%s\C-b." rcirc-nick) + (format "You are successfully identified as \C-b%s\C-b." rcirc-nick) "Password accepted - you are now recognized." ))) (and ;; quakenet @@ -2711,7 +2712,8 @@ the only argument." (setq rcirc-topic (caddr args))))) (defun rcirc-handler-333 (process sender args text) - "Not in rfc1459.txt" + "333 says who set the topic and when. +Not in rfc1459.txt" (let ((buffer (or (rcirc-get-buffer process (cadr args)) (rcirc-get-temp-buffer-create process (cadr args))))) (with-current-buffer buffer @@ -2810,7 +2812,7 @@ Passwords are stored in `rcirc-authinfo' (which see)." ;; quakenet authentication doesn't rely on the user's nickname. ;; the variable `nick' here represents the Q account name. (when (eq method 'quakenet) - (rcirc-send-privmsg + (rcirc-send-privmsg process "Q@CServe.quakenet.org" (format "AUTH %s %s" nick (car args))))))))))