diff options
| author | Leo Liu | 2014-04-09 21:37:49 +0800 |
|---|---|---|
| committer | Leo Liu | 2014-04-09 21:37:49 +0800 |
| commit | 0b816f158782bd668cea3f013a4d6fb277ffe95a (patch) | |
| tree | 58167b84d52cf70b87873bcb7c07226f86e05749 | |
| parent | 5f6378eed5eb0f94bafceaf4c9a5e344463a0ab3 (diff) | |
| download | emacs-0b816f158782bd668cea3f013a4d6fb277ffe95a.tar.gz emacs-0b816f158782bd668cea3f013a4d6fb277ffe95a.zip | |
New command rcirc-cmd-reconnect
* net/rcirc.el (rcirc-connection-info): New variable.
(rcirc-connect): Use it to store connection info.
(rcirc-buffer-process): Avoid get-buffer-process which returns nil
for killed process.
(rcirc-cmd-reconnect): New command.
(rcirc-mode, set-rcirc-encode-coding-system)
(set-rcirc-decode-coding-system, rcirc-connect): Use setq-local.
Fixes: debbugs:17045
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/net/rcirc.el | 109 |
2 files changed, 72 insertions, 47 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index efc09b40d78..8f27ffbf636 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2014-04-09 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * net/rcirc.el (rcirc-connection-info): New variable. | ||
| 4 | (rcirc-connect): Use it to store connection info. | ||
| 5 | (rcirc-buffer-process): Avoid get-buffer-process which returns nil | ||
| 6 | for killed process. | ||
| 7 | (rcirc-cmd-reconnect): New command. (Bug#17045) | ||
| 8 | (rcirc-mode, set-rcirc-encode-coding-system) | ||
| 9 | (set-rcirc-decode-coding-system, rcirc-connect): Use setq-local. | ||
| 10 | |||
| 1 | 2014-04-09 Daniel Colascione <dancol@dancol.org> | 11 | 2014-04-09 Daniel Colascione <dancol@dancol.org> |
| 2 | 12 | ||
| 3 | * emacs-lisp/cl-indent.el: Add comment claiming | 13 | * emacs-lisp/cl-indent.el: Add comment claiming |
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index f129bfe6783..5a75617c485 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el | |||
| @@ -521,6 +521,7 @@ If ARG is non-nil, instead prompt for connection parameters." | |||
| 521 | (defvar rcirc-user-authenticated nil) | 521 | (defvar rcirc-user-authenticated nil) |
| 522 | (defvar rcirc-user-disconnect nil) | 522 | (defvar rcirc-user-disconnect nil) |
| 523 | (defvar rcirc-connecting nil) | 523 | (defvar rcirc-connecting nil) |
| 524 | (defvar rcirc-connection-info nil) | ||
| 524 | (defvar rcirc-process nil) | 525 | (defvar rcirc-process nil) |
| 525 | 526 | ||
| 526 | ;;;###autoload | 527 | ;;;###autoload |
| @@ -549,22 +550,23 @@ If ARG is non-nil, instead prompt for connection parameters." | |||
| 549 | (set-process-sentinel process 'rcirc-sentinel) | 550 | (set-process-sentinel process 'rcirc-sentinel) |
| 550 | (set-process-filter process 'rcirc-filter) | 551 | (set-process-filter process 'rcirc-filter) |
| 551 | 552 | ||
| 552 | (set (make-local-variable 'rcirc-process) process) | 553 | (setq-local rcirc-connection-info |
| 553 | (set (make-local-variable 'rcirc-server) server) | 554 | (list server port nick user-name full-name startup-channels |
| 554 | (set (make-local-variable 'rcirc-server-name) server) ; Update when we get 001 response. | 555 | password encryption)) |
| 555 | (set (make-local-variable 'rcirc-buffer-alist) nil) | 556 | (setq-local rcirc-process process) |
| 556 | (set (make-local-variable 'rcirc-nick-table) | 557 | (setq-local rcirc-server server) |
| 557 | (make-hash-table :test 'equal)) | 558 | (setq-local rcirc-server-name server) ; Update when we get 001 response. |
| 558 | (set (make-local-variable 'rcirc-nick) nick) | 559 | (setq-local rcirc-buffer-alist nil) |
| 559 | (set (make-local-variable 'rcirc-process-output) nil) | 560 | (setq-local rcirc-nick-table (make-hash-table :test 'equal)) |
| 560 | (set (make-local-variable 'rcirc-startup-channels) startup-channels) | 561 | (setq-local rcirc-nick nick) |
| 561 | (set (make-local-variable 'rcirc-last-server-message-time) | 562 | (setq-local rcirc-process-output nil) |
| 562 | (current-time)) | 563 | (setq-local rcirc-startup-channels startup-channels) |
| 563 | 564 | (setq-local rcirc-last-server-message-time (current-time)) | |
| 564 | (set (make-local-variable 'rcirc-timeout-timer) nil) | 565 | |
| 565 | (set (make-local-variable 'rcirc-user-disconnect) nil) | 566 | (setq-local rcirc-timeout-timer nil) |
| 566 | (set (make-local-variable 'rcirc-user-authenticated) nil) | 567 | (setq-local rcirc-user-disconnect nil) |
| 567 | (set (make-local-variable 'rcirc-connecting) t) | 568 | (setq-local rcirc-user-authenticated nil) |
| 569 | (setq-local rcirc-connecting t) | ||
| 568 | 570 | ||
| 569 | (add-hook 'auto-save-hook 'rcirc-log-write) | 571 | (add-hook 'auto-save-hook 'rcirc-log-write) |
| 570 | 572 | ||
| @@ -782,11 +784,11 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.") | |||
| 782 | (defun rcirc-buffer-process (&optional buffer) | 784 | (defun rcirc-buffer-process (&optional buffer) |
| 783 | "Return the process associated with channel BUFFER. | 785 | "Return the process associated with channel BUFFER. |
| 784 | With no argument or nil as argument, use the current buffer." | 786 | With no argument or nil as argument, use the current buffer." |
| 785 | (or (get-buffer-process (if buffer | 787 | (let ((buffer (or buffer (if (buffer-live-p rcirc-server-buffer) |
| 786 | (with-current-buffer buffer | 788 | rcirc-server-buffer |
| 787 | rcirc-server-buffer) | 789 | (error "Server buffer deleted"))))) |
| 788 | rcirc-server-buffer)) | 790 | (or (with-current-buffer buffer rcirc-process) |
| 789 | rcirc-process)) | 791 | rcirc-process))) |
| 790 | 792 | ||
| 791 | (defun rcirc-server-name (process) | 793 | (defun rcirc-server-name (process) |
| 792 | "Return PROCESS server name, given by the 001 response." | 794 | "Return PROCESS server name, given by the 001 response." |
| @@ -928,12 +930,12 @@ IRC command completion is performed only if '/' is the first input char." | |||
| 928 | (defun set-rcirc-decode-coding-system (coding-system) | 930 | (defun set-rcirc-decode-coding-system (coding-system) |
| 929 | "Set the decode coding system used in this channel." | 931 | "Set the decode coding system used in this channel." |
| 930 | (interactive "zCoding system for incoming messages: ") | 932 | (interactive "zCoding system for incoming messages: ") |
| 931 | (set (make-local-variable 'rcirc-decode-coding-system) coding-system)) | 933 | (setq-local rcirc-decode-coding-system coding-system)) |
| 932 | 934 | ||
| 933 | (defun set-rcirc-encode-coding-system (coding-system) | 935 | (defun set-rcirc-encode-coding-system (coding-system) |
| 934 | "Set the encode coding system used in this channel." | 936 | "Set the encode coding system used in this channel." |
| 935 | (interactive "zCoding system for outgoing messages: ") | 937 | (interactive "zCoding system for outgoing messages: ") |
| 936 | (set (make-local-variable 'rcirc-encode-coding-system) coding-system)) | 938 | (setq-local rcirc-encode-coding-system coding-system)) |
| 937 | 939 | ||
| 938 | (defvar rcirc-mode-map | 940 | (defvar rcirc-mode-map |
| 939 | (let ((map (make-sparse-keymap))) | 941 | (let ((map (make-sparse-keymap))) |
| @@ -990,25 +992,25 @@ This number is independent of the number of lines in the buffer.") | |||
| 990 | (setq major-mode 'rcirc-mode) | 992 | (setq major-mode 'rcirc-mode) |
| 991 | (setq mode-line-process nil) | 993 | (setq mode-line-process nil) |
| 992 | 994 | ||
| 993 | (set (make-local-variable 'rcirc-input-ring) | 995 | (setq-local rcirc-input-ring |
| 994 | ;; If rcirc-input-ring is already a ring with desired size do | 996 | ;; If rcirc-input-ring is already a ring with desired |
| 995 | ;; not re-initialize. | 997 | ;; size do not re-initialize. |
| 996 | (if (and (ring-p rcirc-input-ring) | 998 | (if (and (ring-p rcirc-input-ring) |
| 997 | (= (ring-size rcirc-input-ring) | 999 | (= (ring-size rcirc-input-ring) |
| 998 | rcirc-input-ring-size)) | 1000 | rcirc-input-ring-size)) |
| 999 | rcirc-input-ring | 1001 | rcirc-input-ring |
| 1000 | (make-ring rcirc-input-ring-size))) | 1002 | (make-ring rcirc-input-ring-size))) |
| 1001 | (set (make-local-variable 'rcirc-server-buffer) (process-buffer process)) | 1003 | (setq-local rcirc-server-buffer (process-buffer process)) |
| 1002 | (set (make-local-variable 'rcirc-target) target) | 1004 | (setq-local rcirc-target target) |
| 1003 | (set (make-local-variable 'rcirc-topic) nil) | 1005 | (setq-local rcirc-topic nil) |
| 1004 | (set (make-local-variable 'rcirc-last-post-time) (current-time)) | 1006 | (setq-local rcirc-last-post-time (current-time)) |
| 1005 | (set (make-local-variable 'fill-paragraph-function) 'rcirc-fill-paragraph) | 1007 | (setq-local fill-paragraph-function 'rcirc-fill-paragraph) |
| 1006 | (set (make-local-variable 'rcirc-recent-quit-alist) nil) | 1008 | (setq-local rcirc-recent-quit-alist nil) |
| 1007 | (set (make-local-variable 'rcirc-current-line) 0) | 1009 | (setq-local rcirc-current-line 0) |
| 1008 | 1010 | ||
| 1009 | (use-hard-newlines t) | 1011 | (use-hard-newlines t) |
| 1010 | (set (make-local-variable 'rcirc-short-buffer-name) nil) | 1012 | (setq-local rcirc-short-buffer-name nil) |
| 1011 | (set (make-local-variable 'rcirc-urls) nil) | 1013 | (setq-local rcirc-urls nil) |
| 1012 | 1014 | ||
| 1013 | ;; setup for omitting responses | 1015 | ;; setup for omitting responses |
| 1014 | (setq buffer-invisibility-spec '()) | 1016 | (setq buffer-invisibility-spec '()) |
| @@ -1023,18 +1025,18 @@ This number is independent of the number of lines in the buffer.") | |||
| 1023 | (serv (if (consp (car i)) (cdar i) ""))) | 1025 | (serv (if (consp (car i)) (cdar i) ""))) |
| 1024 | (when (and (string-match chan (or target "")) | 1026 | (when (and (string-match chan (or target "")) |
| 1025 | (string-match serv (rcirc-server-name process))) | 1027 | (string-match serv (rcirc-server-name process))) |
| 1026 | (set (make-local-variable 'rcirc-decode-coding-system) | 1028 | (setq-local rcirc-decode-coding-system |
| 1027 | (if (consp (cdr i)) (cadr i) (cdr i))) | 1029 | (if (consp (cdr i)) (cadr i) (cdr i))) |
| 1028 | (set (make-local-variable 'rcirc-encode-coding-system) | 1030 | (setq-local rcirc-encode-coding-system |
| 1029 | (if (consp (cdr i)) (cddr i) (cdr i)))))) | 1031 | (if (consp (cdr i)) (cddr i) (cdr i)))))) |
| 1030 | 1032 | ||
| 1031 | ;; setup the prompt and markers | 1033 | ;; setup the prompt and markers |
| 1032 | (set (make-local-variable 'rcirc-prompt-start-marker) (point-max-marker)) | 1034 | (setq-local rcirc-prompt-start-marker (point-max-marker)) |
| 1033 | (set (make-local-variable 'rcirc-prompt-end-marker) (point-max-marker)) | 1035 | (setq-local rcirc-prompt-end-marker (point-max-marker)) |
| 1034 | (rcirc-update-prompt) | 1036 | (rcirc-update-prompt) |
| 1035 | (goto-char rcirc-prompt-end-marker) | 1037 | (goto-char rcirc-prompt-end-marker) |
| 1036 | 1038 | ||
| 1037 | (set (make-local-variable 'overlay-arrow-position) (make-marker)) | 1039 | (setq-local overlay-arrow-position (make-marker)) |
| 1038 | 1040 | ||
| 1039 | ;; if the user changes the major mode or kills the buffer, there is | 1041 | ;; if the user changes the major mode or kills the buffer, there is |
| 1040 | ;; cleanup work to do | 1042 | ;; cleanup work to do |
| @@ -2210,6 +2212,19 @@ CHANNELS is a comma- or space-separated string of channel names." | |||
| 2210 | reason | 2212 | reason |
| 2211 | rcirc-id-string)))) | 2213 | rcirc-id-string)))) |
| 2212 | 2214 | ||
| 2215 | (defun-rcirc-command reconnect (_) | ||
| 2216 | "Reconnect to current server." | ||
| 2217 | (interactive "i") | ||
| 2218 | (with-rcirc-server-buffer | ||
| 2219 | (cond | ||
| 2220 | (rcirc-connecting (message "Already connecting")) | ||
| 2221 | ((process-live-p process) (message "Server process is alive")) | ||
| 2222 | (t (let ((conn-info rcirc-connection-info)) | ||
| 2223 | (setf (nth 5 conn-info) | ||
| 2224 | (cl-remove-if-not #'rcirc-channel-p | ||
| 2225 | (mapcar #'car rcirc-buffer-alist))) | ||
| 2226 | (apply #'rcirc-connect conn-info)))))) | ||
| 2227 | |||
| 2213 | (defun-rcirc-command nick (nick) | 2228 | (defun-rcirc-command nick (nick) |
| 2214 | "Change nick to NICK." | 2229 | "Change nick to NICK." |
| 2215 | (interactive "i") | 2230 | (interactive "i") |