emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 52cc9a5: Reimplement inline functions in ERC with d


From: Vibhav Pant
Subject: [Emacs-diffs] master 52cc9a5: Reimplement inline functions in ERC with define-inline.
Date: Sat, 18 Nov 2017 08:41:54 -0500 (EST)

branch: master
commit 52cc9a57f43bc0fee9adb20fc0b202dcc6af7575
Author: Vibhav Pant <address@hidden>
Commit: Vibhav Pant <address@hidden>

    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.
---
 lisp/erc/erc-backend.el  | 30 +++++++++--------
 lisp/erc/erc-dcc.el      | 11 +++---
 lisp/erc/erc-services.el | 28 ++++++++--------
 lisp/erc/erc.el          | 87 ++++++++++++++++++++++++++++--------------------
 4 files changed, 86 insertions(+), 70 deletions(-)

diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 8992325..68b30a9 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."
             (erc-log-irc-protocol line nil)
             (erc-parse-server-response process line)))))))
 
-(defsubst erc-server-reconnect-p (event)
+(define-inline erc-server-reconnect-p (event)
   "Return non-nil if ERC should attempt to reconnect automatically.
 EVENT is the message received from the closed connection process."
-  (or erc-server-reconnecting
-      (and erc-server-auto-reconnect
-           (not erc-server-banned)
-           ;; make sure we don't infinitely try to reconnect, unless the
-           ;; user wants that
-           (or (eq erc-server-reconnect-attempts t)
-               (and (integerp erc-server-reconnect-attempts)
-                    (< erc-server-reconnect-count
-                       erc-server-reconnect-attempts)))
-           (or erc-server-timed-out
-               (not (string-match "^deleted" event)))
-           ;; open-network-stream-nowait error for connection refused
-           (if (string-match "^failed with code 111" event) 'nonblocking t))))
+  (inline-letevals (event)
+    (inline-quote
+     (or erc-server-reconnecting
+         (and erc-server-auto-reconnect
+              (not erc-server-banned)
+              ;; make sure we don't infinitely try to reconnect, unless the
+              ;; user wants that
+              (or (eq erc-server-reconnect-attempts t)
+                  (and (integerp erc-server-reconnect-attempts)
+                       (< erc-server-reconnect-count
+                          erc-server-reconnect-attempts)))
+              (or erc-server-timed-out
+                  (not (string-match "^deleted" ,event)))
+              ;; open-network-stream-nowait error for connection refused
+              (if (string-match "^failed with code 111" ,event) 'nonblocking 
t))))))
 
 (defun erc-process-sentinel-2 (event buffer)
   "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 8003661..dba48f6 100644
--- a/lisp/erc/erc-dcc.el
+++ b/lisp/erc/erc-dcc.el
@@ -649,9 +649,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 +781,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.
diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el
index bce7711..c2e653d 100644
--- a/lisp/erc/erc-services.el
+++ b/lisp/erc/erc-services.el
@@ -312,26 +312,26 @@ The last two elements are optional."
                         (const :tag "Do not try to detect success" nil)))))
 
 
-(defsubst erc-nickserv-alist-sender (network &optional entry)
-  (nth 1 (or entry (assoc network erc-nickserv-alist))))
+(define-inline erc-nickserv-alist-sender (network &optional entry)
+  (inline-quote (nth 1 (or ,entry (assoc ,network erc-nickserv-alist)))))
 
-(defsubst erc-nickserv-alist-regexp (network &optional entry)
-  (nth 2 (or entry (assoc network erc-nickserv-alist))))
+(define-inline erc-nickserv-alist-regexp (network &optional entry)
+  (inline-quote (nth 2 (or ,entry (assoc ,network erc-nickserv-alist)))))
 
-(defsubst erc-nickserv-alist-nickserv (network &optional entry)
-  (nth 3 (or entry (assoc network erc-nickserv-alist))))
+(define-inline erc-nickserv-alist-nickserv (network &optional entry)
+  (inline-quote (nth 3 (or ,entry (assoc ,network erc-nickserv-alist)))))
 
-(defsubst erc-nickserv-alist-ident-keyword (network &optional entry)
-  (nth 4 (or entry (assoc network erc-nickserv-alist))))
+(define-inline erc-nickserv-alist-ident-keyword (network &optional entry)
+  (inline-quote (nth 4 (or ,entry (assoc ,network erc-nickserv-alist)))))
 
-(defsubst erc-nickserv-alist-use-nick-p (network &optional entry)
-  (nth 5 (or entry (assoc network erc-nickserv-alist))))
+(define-inline erc-nickserv-alist-use-nick-p (network &optional entry)
+  (inline-quote (nth 5 (or ,entry (assoc ,network erc-nickserv-alist)))))
 
-(defsubst erc-nickserv-alist-ident-command (network &optional entry)
-  (nth 6 (or entry (assoc network erc-nickserv-alist))))
+(define-inline erc-nickserv-alist-ident-command (network &optional entry)
+  (inline-quote (nth 6 (or ,entry (assoc ,network erc-nickserv-alist)))))
 
-(defsubst erc-nickserv-alist-identified-regexp (network &optional entry)
-  (nth 7 (or entry (assoc network erc-nickserv-alist))))
+(define-inline erc-nickserv-alist-identified-regexp (network &optional entry)
+  (inline-quote (nth 7 (or ,entry (assoc ,network erc-nickserv-alist)))))
 
 ;; Functions:
 
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 76f4c8b..cf5d2a1 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -399,25 +399,26 @@ If no server buffer exists, return nil."
   ;; This is useful for ordered name completion.
   (last-message-time nil))
 
-(defsubst erc-get-channel-user (nick)
+(define-inline erc-get-channel-user (nick)
   "Find the (USER . CHANNEL-DATA) element corresponding to NICK
 in the current buffer's `erc-channel-users' hash table."
-  (gethash (erc-downcase nick) erc-channel-users))
+  (inline-quote (gethash (erc-downcase ,nick) erc-channel-users)))
 
-(defsubst erc-get-server-user (nick)
+(define-inline erc-get-server-user (nick)
   "Find the USER corresponding to NICK in the current server's
 `erc-server-users' hash table."
-  (erc-with-server-buffer
-    (gethash (erc-downcase nick) erc-server-users)))
+  (inline-quote (erc-with-server-buffer
+                 (gethash (erc-downcase ,nick) erc-server-users))))
 
-(defsubst erc-add-server-user (nick user)
+(define-inline erc-add-server-user (nick user)
   "This function is for internal use only.
 
 Adds USER with nickname NICK to the `erc-server-users' hash table."
-  (erc-with-server-buffer
-    (puthash (erc-downcase nick) user erc-server-users)))
+  (inline-quote
+   (erc-with-server-buffer
+     (puthash (erc-downcase ,nick) ,user erc-server-users))))
 
-(defsubst erc-remove-server-user (nick)
+(define-inline erc-remove-server-user (nick)
   "This function is for internal use only.
 
 Removes the user with nickname NICK from the `erc-server-users'
@@ -425,8 +426,9 @@ hash table.  This user is not removed from the
 `erc-channel-users' lists of other buffers.
 
 See also: `erc-remove-user'."
-  (erc-with-server-buffer
-    (remhash (erc-downcase nick) erc-server-users)))
+  (inline-quote
+   (erc-with-server-buffer
+     (remhash (erc-downcase ,nick) erc-server-users))))
 
 (defun erc-change-user-nickname (user new-nick)
   "This function is for internal use only.
@@ -497,45 +499,55 @@ Removes all users in the current channel.  This is called 
by
              erc-channel-users)
     (clrhash erc-channel-users)))
 
-(defsubst erc-channel-user-owner-p (nick)
+(define-inline erc-channel-user-owner-p (nick)
   "Return non-nil if NICK is an owner of the current channel."
-  (and nick
-       (hash-table-p erc-channel-users)
-       (let ((cdata (erc-get-channel-user nick)))
-         (and cdata (cdr cdata)
-              (erc-channel-user-owner (cdr cdata))))))
-
-(defsubst erc-channel-user-admin-p (nick)
+  (inline-letevals (nick)
+    (inline-quote
+     (and ,nick
+         (hash-table-p erc-channel-users)
+         (let ((cdata (erc-get-channel-user ,nick)))
+           (and cdata (cdr cdata)
+                (erc-channel-user-owner (cdr cdata))))))))
+
+(define-inline erc-channel-user-admin-p (nick)
   "Return non-nil if NICK is an admin in the current channel."
-  (and nick
+  (inline-letevals (nick)
+    (inline-quote
+     (and ,nick
        (hash-table-p erc-channel-users)
-       (let ((cdata (erc-get-channel-user nick)))
+       (let ((cdata (erc-get-channel-user ,nick)))
          (and cdata (cdr cdata)
-              (erc-channel-user-admin (cdr cdata))))))
+              (erc-channel-user-admin (cdr cdata))))))))
 
-(defsubst erc-channel-user-op-p (nick)
+(define-inline erc-channel-user-op-p (nick)
   "Return non-nil if NICK is an operator in the current channel."
-  (and nick
+  (inline-letevals (nick)
+    (inline-quote
+     (and ,nick
        (hash-table-p erc-channel-users)
-       (let ((cdata (erc-get-channel-user nick)))
+       (let ((cdata (erc-get-channel-user ,nick)))
          (and cdata (cdr cdata)
-              (erc-channel-user-op (cdr cdata))))))
+              (erc-channel-user-op (cdr cdata))))))))
 
-(defsubst erc-channel-user-halfop-p (nick)
+(define-inline erc-channel-user-halfop-p (nick)
   "Return non-nil if NICK is a half-operator in the current channel."
-  (and nick
+  (inline-letevals (nick)
+    (inline-quote
+     (and ,nick
        (hash-table-p erc-channel-users)
-       (let ((cdata (erc-get-channel-user nick)))
+       (let ((cdata (erc-get-channel-user ,nick)))
          (and cdata (cdr cdata)
-              (erc-channel-user-halfop (cdr cdata))))))
+              (erc-channel-user-halfop (cdr cdata))))))))
 
-(defsubst erc-channel-user-voice-p (nick)
+(define-inline erc-channel-user-voice-p (nick)
   "Return non-nil if NICK has voice in the current channel."
-  (and nick
+  (inline-letevals (nick)
+    (inline-quote
+     (and ,nick
        (hash-table-p erc-channel-users)
-       (let ((cdata (erc-get-channel-user nick)))
+       (let ((cdata (erc-get-channel-user ,nick)))
          (and cdata (cdr cdata)
-              (erc-channel-user-voice (cdr cdata))))))
+              (erc-channel-user-voice (cdr cdata))))))))
 
 (defun erc-get-channel-user-list ()
   "Return a list of users in the current channel.  Each element
@@ -1343,10 +1355,11 @@ capabilities."
     (add-hook hook fun nil t)
     fun))
 
-(defsubst erc-log (string)
+(define-inline erc-log (string)
   "Logs STRING if logging is on (see `erc-log-p')."
-  (when erc-log-p
-    (erc-log-aux string)))
+  (inline-quote
+   (when erc-log-p
+     (erc-log-aux ,string))))
 
 (defun erc-server-buffer ()
   "Return the server buffer for the current buffer's process.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]