summaryrefslogtreecommitdiff
path: root/lisp/erc/erc-dcc.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/erc/erc-dcc.el')
-rw-r--r--lisp/erc/erc-dcc.el77
1 files changed, 31 insertions, 46 deletions
diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
index 2b41c8c705b..526add1a61f 100644
--- a/lisp/erc/erc-dcc.el
+++ b/lisp/erc/erc-dcc.el
@@ -47,16 +47,15 @@
;; /dcc get nick [file] - Accept DCC offer from nick
;; /dcc list - List all DCC offers/connections
;; /dcc send nick file - Offer DCC SEND to nick
-;;
-;; Please note that offering DCC connections (offering chats and sending
-;; files) is only supported with Emacs 22.
;;; Code:
(require 'erc)
-(eval-when-compile (require 'pcomplete))
+;; Strictly speaking, should only be needed at compile time.
+;; Require at run-time too to silence compiler.
+(require 'pcomplete)
-;;;###autoload (autoload 'erc-dcc-mode "erc-dcc")
+;;;###autoload(autoload 'erc-dcc-mode "erc-dcc")
(define-erc-module dcc nil
"Provide Direct Client-to-Client support for ERC."
((add-hook 'erc-server-401-functions 'erc-dcc-no-such-nick))
@@ -222,14 +221,6 @@ which is big-endian."
(setq i (1- i)))
str))
-(defconst erc-most-positive-int-bytes
- (ceiling (/ (ceiling (/ (log most-positive-fixnum) (log 2))) 8.0))
- "Maximum number of bytes for a fixnum.")
-
-(defconst erc-most-positive-int-msb
- (lsh most-positive-fixnum (- 0 (* 8 (1- erc-most-positive-int-bytes))))
- "Content of the most significant byte of most-positive-fixnum.")
-
(defun erc-unpack-int (str)
"Unpack a packed string into an integer."
(let ((len (length str)))
@@ -240,16 +231,11 @@ which is big-endian."
(when (> start 0)
(setq str (substring str start))
(setq len (- len start))))
- ;; make sure size is not larger than Emacs can handle
- (when (or (> len (min 4 erc-most-positive-int-bytes))
- (and (eq len erc-most-positive-int-bytes)
- (> (aref str 0) erc-most-positive-int-msb)))
- (error "ERC-DCC (erc-unpack-int): packet to send is too large"))
;; unpack
(let ((num 0)
(count 0))
(while (< count len)
- (setq num (+ num (lsh (aref str (- len count 1)) (* 8 count))))
+ (setq num (+ num (ash (aref str (- len count 1)) (* 8 count))))
(setq count (1+ count)))
num)))
@@ -365,7 +351,6 @@ created subprocess, or nil."
:buffer nil
:host (erc-dcc-host)
:service port
- :nowait t
:noquery nil
:filter filter
:sentinel sentinel
@@ -433,23 +418,23 @@ where FOO is one of CLOSE, GET, SEND, LIST, CHAT, etc."
(when (fboundp 'make-network-process) '("send"))))
(pcomplete-here
(pcase (intern (downcase (pcomplete-arg 1)))
- (`chat (mapcar (lambda (elt) (plist-get elt :nick))
+ ('chat (mapcar (lambda (elt) (plist-get elt :nick))
(erc-remove-if-not
#'(lambda (elt)
(eq (plist-get elt :type) 'CHAT))
erc-dcc-list)))
- (`close (erc-delete-dups
+ ('close (erc-delete-dups
(mapcar (lambda (elt) (symbol-name (plist-get elt :type)))
erc-dcc-list)))
- (`get (mapcar #'erc-dcc-nick
+ ('get (mapcar #'erc-dcc-nick
(erc-remove-if-not
#'(lambda (elt)
(eq (plist-get elt :type) 'GET))
erc-dcc-list)))
- (`send (pcomplete-erc-all-nicks))))
+ ('send (pcomplete-erc-all-nicks))))
(pcomplete-here
(pcase (intern (downcase (pcomplete-arg 2)))
- (`get (mapcar (lambda (elt) (plist-get elt :file))
+ ('get (mapcar (lambda (elt) (plist-get elt :file))
(erc-remove-if-not
#'(lambda (elt)
(and (eq (plist-get elt :type) 'GET)
@@ -457,13 +442,13 @@ where FOO is one of CLOSE, GET, SEND, LIST, CHAT, etc."
(plist-get elt :nick))
(pcomplete-arg 1))))
erc-dcc-list)))
- (`close (mapcar #'erc-dcc-nick
+ ('close (mapcar #'erc-dcc-nick
(erc-remove-if-not
#'(lambda (elt)
(eq (plist-get elt :type)
(intern (upcase (pcomplete-arg 1)))))
erc-dcc-list)))
- (`send (pcomplete-entries)))))
+ ('send (pcomplete-entries)))))
(defun erc-dcc-do-CHAT-command (proc &optional nick)
(when nick
@@ -649,9 +634,10 @@ that subcommand."
"\"\\(\\(.*?\\(\\\\\"\\)?\\)+?\\)\"\\|\\([^ ]+\\)"
"\\) \\([0-9]+\\) \\([0-9]+\\) *\\([0-9]*\\)"))
-(defsubst erc-dcc-unquote-filename (filename)
- (erc-replace-regexp-in-string "\\\\\\\\" "\\"
- (erc-replace-regexp-in-string "\\\\\"" "\"" filename t t) t t))
+(define-inline erc-dcc-unquote-filename (filename)
+ (inline-quote
+ (erc-replace-regexp-in-string "\\\\\\\\" "\\"
+ (erc-replace-regexp-in-string "\\\\\"" "\"" ,filename t t) t t)))
(defun erc-dcc-handle-ctcp-send (proc query nick login host to)
"This is called if a CTCP DCC SEND subcommand is sent to the client.
@@ -780,8 +766,8 @@ unconfirmed."
:group 'erc-dcc
:type '(choice (const nil) integer))
-(defsubst erc-dcc-get-parent (proc)
- (plist-get (erc-dcc-member :peer proc) :parent))
+(define-inline erc-dcc-get-parent (proc)
+ (inline-quote (plist-get (erc-dcc-member :peer ,proc) :parent)))
(defun erc-dcc-send-block (proc)
"Send one block of data.
@@ -824,8 +810,8 @@ bytes sent."
?s (number-to-string (- sent-marker (point-min))))
(setq erc-dcc-list (delete elt erc-dcc-list))
(set-buffer-modified-p nil)
- (kill-buffer (current-buffer))
- (delete-process proc))
+ (delete-process proc)
+ (kill-buffer (current-buffer)))
((<= confirmed-marker sent-marker)
(while (and (< (- sent-marker confirmed-marker)
(or erc-dcc-pump-bytes
@@ -838,8 +824,8 @@ bytes sent."
(marker-position confirmed-marker)
(marker-position sent-marker)))
(set-buffer-modified-p nil)
- (kill-buffer (current-buffer))
- (delete-process proc))))))
+ (delete-process proc)
+ (kill-buffer (current-buffer)))))))
(defun erc-dcc-display-send (proc)
(erc-display-message
@@ -931,10 +917,7 @@ filter and a process sentinel, and making the connection."
(buffer-disable-undo (current-buffer))
;; This is necessary to have the buffer saved as-is in GNU
;; Emacs.
- ;; XEmacs change: We don't have `set-buffer-multibyte', setting
- ;; coding system to 'binary below takes care of us.
- (when (fboundp 'set-buffer-multibyte)
- (set-buffer-multibyte nil))
+ (set-buffer-multibyte nil)
(setq mode-line-process '(":%s")
buffer-read-only t)
@@ -989,8 +972,9 @@ rather than every 1024 byte block, but nobody seems to care."
(let ((inhibit-read-only t)
received-bytes)
(goto-char (point-max))
- (if str
- (insert (string-make-unibyte str)))
+ (when str
+ (cl-assert (not (multibyte-string-p str)))
+ (insert str))
(when (> (point-max) erc-dcc-receive-cache)
(erc-dcc-append-contents (current-buffer) erc-dcc-file-name))
@@ -1034,7 +1018,7 @@ transfer is complete."
?s (number-to-string erc-dcc-byte-count)
?t (format "%.0f"
(erc-time-diff (plist-get erc-dcc-entry-data :start-time)
- (erc-current-time)))))
+ nil))))
(kill-buffer (process-buffer proc))
(delete-process proc))
@@ -1094,14 +1078,14 @@ Possible values are: ask, auto, ignore."
(pcomplete-here '("auto" "ask" "ignore")))
(defalias 'pcomplete/erc-mode/SREQ 'pcomplete/erc-mode/CREQ)
+(define-obsolete-variable-alias 'erc-dcc-chat-filter-hook
+ 'erc-dcc-chat-filter-functions "24.3")
+
(defvar erc-dcc-chat-filter-functions '(erc-dcc-chat-parse-output)
"Abnormal hook run after parsing (and maybe inserting) a DCC message.
Each function is called with two arguments: the ERC process and
the unprocessed output.")
-(define-obsolete-variable-alias 'erc-dcc-chat-filter-hook
- 'erc-dcc-chat-filter-functions "24.3")
-
(defvar erc-dcc-chat-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "RET") 'erc-send-current-line)
@@ -1260,5 +1244,6 @@ other client."
;;; erc-dcc.el ends here
;;
;; Local Variables:
+;; generated-autoload-file: "erc-loaddefs.el"
;; indent-tabs-mode: nil
;; End: