aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVibhav Pant2017-11-18 19:10:08 +0530
committerVibhav Pant2017-11-18 19:10:08 +0530
commit52cc9a57f43bc0fee9adb20fc0b202dcc6af7575 (patch)
tree83b15a507797227f9a594d769be588665eaef859
parent6b8e9b74bd2343b26c73f41f61a34ebfd1b11a9d (diff)
downloademacs-52cc9a57f43bc0fee9adb20fc0b202dcc6af7575.tar.gz
emacs-52cc9a57f43bc0fee9adb20fc0b202dcc6af7575.zip
Reimplement inline functions in ERC with define-inline.
* lisp/erc/erc-backend.el: (erc-server-reconnect-p): Reimplement using define-inline. * lisp/erc/erc-dcc.el: (erc-dcc-unquote-filename, erc-dcc-get-parent): Reimplement using define-inline. * lisp/erc/erc-services.el: (erc-nickserv-alist-sender, erc-nickserv-alist-regexp, erc-nickserv-alist-nickserv, erc-nickserv-alist-ident-keyword, erc-nickserv-alist-use-nick-p, erc-nickserv-alist-ident-command, erc-nickserv-alist-identified-regexp): Reimplement using define-inline. * lisp/erc/erc.el: (erc-get-channel-user, erc-get-server-user, erc-add-server-user, erc-remove-server-user, erc-channel-user-owner-p, erc-channel-user-admin-p, erc-channel-user-op-p, erc-channel-user-halfop-p, erc-channel-user-voice-p, erc-log): Reimplement using define-inline.
-rw-r--r--lisp/erc/erc-backend.el30
-rw-r--r--lisp/erc/erc-dcc.el11
-rw-r--r--lisp/erc/erc-services.el28
-rw-r--r--lisp/erc/erc.el87
4 files changed, 86 insertions, 70 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 89923257dd7..68b30a9216d 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -644,22 +644,24 @@ Make sure you are in an ERC buffer when running this."
644 (erc-log-irc-protocol line nil) 644 (erc-log-irc-protocol line nil)
645 (erc-parse-server-response process line))))))) 645 (erc-parse-server-response process line)))))))
646 646
647(defsubst erc-server-reconnect-p (event) 647(define-inline erc-server-reconnect-p (event)
648 "Return non-nil if ERC should attempt to reconnect automatically. 648 "Return non-nil if ERC should attempt to reconnect automatically.
649EVENT is the message received from the closed connection process." 649EVENT is the message received from the closed connection process."
650 (or erc-server-reconnecting 650 (inline-letevals (event)
651 (and erc-server-auto-reconnect 651 (inline-quote
652 (not erc-server-banned) 652 (or erc-server-reconnecting
653 ;; make sure we don't infinitely try to reconnect, unless the 653 (and erc-server-auto-reconnect
654 ;; user wants that 654 (not erc-server-banned)
655 (or (eq erc-server-reconnect-attempts t) 655 ;; make sure we don't infinitely try to reconnect, unless the
656 (and (integerp erc-server-reconnect-attempts) 656 ;; user wants that
657 (< erc-server-reconnect-count 657 (or (eq erc-server-reconnect-attempts t)
658 erc-server-reconnect-attempts))) 658 (and (integerp erc-server-reconnect-attempts)
659 (or erc-server-timed-out 659 (< erc-server-reconnect-count
660 (not (string-match "^deleted" event))) 660 erc-server-reconnect-attempts)))
661 ;; open-network-stream-nowait error for connection refused 661 (or erc-server-timed-out
662 (if (string-match "^failed with code 111" event) 'nonblocking t)))) 662 (not (string-match "^deleted" ,event)))
663 ;; open-network-stream-nowait error for connection refused
664 (if (string-match "^failed with code 111" ,event) 'nonblocking t))))))
663 665
664(defun erc-process-sentinel-2 (event buffer) 666(defun erc-process-sentinel-2 (event buffer)
665 "Called when `erc-process-sentinel-1' has detected an unexpected disconnect." 667 "Called when `erc-process-sentinel-1' has detected an unexpected disconnect."
diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
index 8003661e577..dba48f6dcfd 100644
--- a/lisp/erc/erc-dcc.el
+++ b/lisp/erc/erc-dcc.el
@@ -649,9 +649,10 @@ that subcommand."
649 "\"\\(\\(.*?\\(\\\\\"\\)?\\)+?\\)\"\\|\\([^ ]+\\)" 649 "\"\\(\\(.*?\\(\\\\\"\\)?\\)+?\\)\"\\|\\([^ ]+\\)"
650 "\\) \\([0-9]+\\) \\([0-9]+\\) *\\([0-9]*\\)")) 650 "\\) \\([0-9]+\\) \\([0-9]+\\) *\\([0-9]*\\)"))
651 651
652(defsubst erc-dcc-unquote-filename (filename) 652(define-inline erc-dcc-unquote-filename (filename)
653 (erc-replace-regexp-in-string "\\\\\\\\" "\\" 653 (inline-quote
654 (erc-replace-regexp-in-string "\\\\\"" "\"" filename t t) t t)) 654 (erc-replace-regexp-in-string "\\\\\\\\" "\\"
655 (erc-replace-regexp-in-string "\\\\\"" "\"" ,filename t t) t t)))
655 656
656(defun erc-dcc-handle-ctcp-send (proc query nick login host to) 657(defun erc-dcc-handle-ctcp-send (proc query nick login host to)
657 "This is called if a CTCP DCC SEND subcommand is sent to the client. 658 "This is called if a CTCP DCC SEND subcommand is sent to the client.
@@ -780,8 +781,8 @@ unconfirmed."
780 :group 'erc-dcc 781 :group 'erc-dcc
781 :type '(choice (const nil) integer)) 782 :type '(choice (const nil) integer))
782 783
783(defsubst erc-dcc-get-parent (proc) 784(define-inline erc-dcc-get-parent (proc)
784 (plist-get (erc-dcc-member :peer proc) :parent)) 785 (inline-quote (plist-get (erc-dcc-member :peer ,proc) :parent)))
785 786
786(defun erc-dcc-send-block (proc) 787(defun erc-dcc-send-block (proc)
787 "Send one block of data. 788 "Send one block of data.
diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el
index bce771112e9..c2e653d9166 100644
--- a/lisp/erc/erc-services.el
+++ b/lisp/erc/erc-services.el
@@ -312,26 +312,26 @@ The last two elements are optional."
312 (const :tag "Do not try to detect success" nil))))) 312 (const :tag "Do not try to detect success" nil)))))
313 313
314 314
315(defsubst erc-nickserv-alist-sender (network &optional entry) 315(define-inline erc-nickserv-alist-sender (network &optional entry)
316 (nth 1 (or entry (assoc network erc-nickserv-alist)))) 316 (inline-quote (nth 1 (or ,entry (assoc ,network erc-nickserv-alist)))))
317 317
318(defsubst erc-nickserv-alist-regexp (network &optional entry) 318(define-inline erc-nickserv-alist-regexp (network &optional entry)
319 (nth 2 (or entry (assoc network erc-nickserv-alist)))) 319 (inline-quote (nth 2 (or ,entry (assoc ,network erc-nickserv-alist)))))
320 320
321(defsubst erc-nickserv-alist-nickserv (network &optional entry) 321(define-inline erc-nickserv-alist-nickserv (network &optional entry)
322 (nth 3 (or entry (assoc network erc-nickserv-alist)))) 322 (inline-quote (nth 3 (or ,entry (assoc ,network erc-nickserv-alist)))))
323 323
324(defsubst erc-nickserv-alist-ident-keyword (network &optional entry) 324(define-inline erc-nickserv-alist-ident-keyword (network &optional entry)
325 (nth 4 (or entry (assoc network erc-nickserv-alist)))) 325 (inline-quote (nth 4 (or ,entry (assoc ,network erc-nickserv-alist)))))
326 326
327(defsubst erc-nickserv-alist-use-nick-p (network &optional entry) 327(define-inline erc-nickserv-alist-use-nick-p (network &optional entry)
328 (nth 5 (or entry (assoc network erc-nickserv-alist)))) 328 (inline-quote (nth 5 (or ,entry (assoc ,network erc-nickserv-alist)))))
329 329
330(defsubst erc-nickserv-alist-ident-command (network &optional entry) 330(define-inline erc-nickserv-alist-ident-command (network &optional entry)
331 (nth 6 (or entry (assoc network erc-nickserv-alist)))) 331 (inline-quote (nth 6 (or ,entry (assoc ,network erc-nickserv-alist)))))
332 332
333(defsubst erc-nickserv-alist-identified-regexp (network &optional entry) 333(define-inline erc-nickserv-alist-identified-regexp (network &optional entry)
334 (nth 7 (or entry (assoc network erc-nickserv-alist)))) 334 (inline-quote (nth 7 (or ,entry (assoc ,network erc-nickserv-alist)))))
335 335
336;; Functions: 336;; Functions:
337 337
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 76f4c8b35ab..cf5d2a16f30 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -399,25 +399,26 @@ If no server buffer exists, return nil."
399 ;; This is useful for ordered name completion. 399 ;; This is useful for ordered name completion.
400 (last-message-time nil)) 400 (last-message-time nil))
401 401
402(defsubst erc-get-channel-user (nick) 402(define-inline erc-get-channel-user (nick)
403 "Find the (USER . CHANNEL-DATA) element corresponding to NICK 403 "Find the (USER . CHANNEL-DATA) element corresponding to NICK
404in the current buffer's `erc-channel-users' hash table." 404in the current buffer's `erc-channel-users' hash table."
405 (gethash (erc-downcase nick) erc-channel-users)) 405 (inline-quote (gethash (erc-downcase ,nick) erc-channel-users)))
406 406
407(defsubst erc-get-server-user (nick) 407(define-inline erc-get-server-user (nick)
408 "Find the USER corresponding to NICK in the current server's 408 "Find the USER corresponding to NICK in the current server's
409`erc-server-users' hash table." 409`erc-server-users' hash table."
410 (erc-with-server-buffer 410 (inline-quote (erc-with-server-buffer
411 (gethash (erc-downcase nick) erc-server-users))) 411 (gethash (erc-downcase ,nick) erc-server-users))))
412 412
413(defsubst erc-add-server-user (nick user) 413(define-inline erc-add-server-user (nick user)
414 "This function is for internal use only. 414 "This function is for internal use only.
415 415
416Adds USER with nickname NICK to the `erc-server-users' hash table." 416Adds USER with nickname NICK to the `erc-server-users' hash table."
417 (erc-with-server-buffer 417 (inline-quote
418 (puthash (erc-downcase nick) user erc-server-users))) 418 (erc-with-server-buffer
419 (puthash (erc-downcase ,nick) ,user erc-server-users))))
419 420
420(defsubst erc-remove-server-user (nick) 421(define-inline erc-remove-server-user (nick)
421 "This function is for internal use only. 422 "This function is for internal use only.
422 423
423Removes the user with nickname NICK from the `erc-server-users' 424Removes the user with nickname NICK from the `erc-server-users'
@@ -425,8 +426,9 @@ hash table. This user is not removed from the
425`erc-channel-users' lists of other buffers. 426`erc-channel-users' lists of other buffers.
426 427
427See also: `erc-remove-user'." 428See also: `erc-remove-user'."
428 (erc-with-server-buffer 429 (inline-quote
429 (remhash (erc-downcase nick) erc-server-users))) 430 (erc-with-server-buffer
431 (remhash (erc-downcase ,nick) erc-server-users))))
430 432
431(defun erc-change-user-nickname (user new-nick) 433(defun erc-change-user-nickname (user new-nick)
432 "This function is for internal use only. 434 "This function is for internal use only.
@@ -497,45 +499,55 @@ Removes all users in the current channel. This is called by
497 erc-channel-users) 499 erc-channel-users)
498 (clrhash erc-channel-users))) 500 (clrhash erc-channel-users)))
499 501
500(defsubst erc-channel-user-owner-p (nick) 502(define-inline erc-channel-user-owner-p (nick)
501 "Return non-nil if NICK is an owner of the current channel." 503 "Return non-nil if NICK is an owner of the current channel."
502 (and nick 504 (inline-letevals (nick)
503 (hash-table-p erc-channel-users) 505 (inline-quote
504 (let ((cdata (erc-get-channel-user nick))) 506 (and ,nick
505 (and cdata (cdr cdata) 507 (hash-table-p erc-channel-users)
506 (erc-channel-user-owner (cdr cdata)))))) 508 (let ((cdata (erc-get-channel-user ,nick)))
507 509 (and cdata (cdr cdata)
508(defsubst erc-channel-user-admin-p (nick) 510 (erc-channel-user-owner (cdr cdata))))))))
511
512(define-inline erc-channel-user-admin-p (nick)
509 "Return non-nil if NICK is an admin in the current channel." 513 "Return non-nil if NICK is an admin in the current channel."
510 (and nick 514 (inline-letevals (nick)
515 (inline-quote
516 (and ,nick
511 (hash-table-p erc-channel-users) 517 (hash-table-p erc-channel-users)
512 (let ((cdata (erc-get-channel-user nick))) 518 (let ((cdata (erc-get-channel-user ,nick)))
513 (and cdata (cdr cdata) 519 (and cdata (cdr cdata)
514 (erc-channel-user-admin (cdr cdata)))))) 520 (erc-channel-user-admin (cdr cdata))))))))
515 521
516(defsubst erc-channel-user-op-p (nick) 522(define-inline erc-channel-user-op-p (nick)
517 "Return non-nil if NICK is an operator in the current channel." 523 "Return non-nil if NICK is an operator in the current channel."
518 (and nick 524 (inline-letevals (nick)
525 (inline-quote
526 (and ,nick
519 (hash-table-p erc-channel-users) 527 (hash-table-p erc-channel-users)
520 (let ((cdata (erc-get-channel-user nick))) 528 (let ((cdata (erc-get-channel-user ,nick)))
521 (and cdata (cdr cdata) 529 (and cdata (cdr cdata)
522 (erc-channel-user-op (cdr cdata)))))) 530 (erc-channel-user-op (cdr cdata))))))))
523 531
524(defsubst erc-channel-user-halfop-p (nick) 532(define-inline erc-channel-user-halfop-p (nick)
525 "Return non-nil if NICK is a half-operator in the current channel." 533 "Return non-nil if NICK is a half-operator in the current channel."
526 (and nick 534 (inline-letevals (nick)
535 (inline-quote
536 (and ,nick
527 (hash-table-p erc-channel-users) 537 (hash-table-p erc-channel-users)
528 (let ((cdata (erc-get-channel-user nick))) 538 (let ((cdata (erc-get-channel-user ,nick)))
529 (and cdata (cdr cdata) 539 (and cdata (cdr cdata)
530 (erc-channel-user-halfop (cdr cdata)))))) 540 (erc-channel-user-halfop (cdr cdata))))))))
531 541
532(defsubst erc-channel-user-voice-p (nick) 542(define-inline erc-channel-user-voice-p (nick)
533 "Return non-nil if NICK has voice in the current channel." 543 "Return non-nil if NICK has voice in the current channel."
534 (and nick 544 (inline-letevals (nick)
545 (inline-quote
546 (and ,nick
535 (hash-table-p erc-channel-users) 547 (hash-table-p erc-channel-users)
536 (let ((cdata (erc-get-channel-user nick))) 548 (let ((cdata (erc-get-channel-user ,nick)))
537 (and cdata (cdr cdata) 549 (and cdata (cdr cdata)
538 (erc-channel-user-voice (cdr cdata)))))) 550 (erc-channel-user-voice (cdr cdata))))))))
539 551
540(defun erc-get-channel-user-list () 552(defun erc-get-channel-user-list ()
541 "Return a list of users in the current channel. Each element 553 "Return a list of users in the current channel. Each element
@@ -1343,10 +1355,11 @@ capabilities."
1343 (add-hook hook fun nil t) 1355 (add-hook hook fun nil t)
1344 fun)) 1356 fun))
1345 1357
1346(defsubst erc-log (string) 1358(define-inline erc-log (string)
1347 "Logs STRING if logging is on (see `erc-log-p')." 1359 "Logs STRING if logging is on (see `erc-log-p')."
1348 (when erc-log-p 1360 (inline-quote
1349 (erc-log-aux string))) 1361 (when erc-log-p
1362 (erc-log-aux ,string))))
1350 1363
1351(defun erc-server-buffer () 1364(defun erc-server-buffer ()
1352 "Return the server buffer for the current buffer's process. 1365 "Return the server buffer for the current buffer's process.