summaryrefslogtreecommitdiff
path: root/lisp/erc
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2007-01-17 18:17:35 +0000
committerMiles Bader <miles@gnu.org>2007-01-17 18:17:35 +0000
commit01d9e862ba3a2f22b17e95c7086648f56415c357 (patch)
treeb4181d14baf62c146585e93edec7a7d4aa3d0d96 /lisp/erc
parent6904f7fe8ed11bf4c94c009b4ef300f4ccdfa2e6 (diff)
downloademacs-01d9e862ba3a2f22b17e95c7086648f56415c357.tar.gz
Merge from erc--main--0
Backport additional functions and macros that erc-capab.el needs. Revision: emacs@sv.gnu.org/emacs--devo--0--patch-600 Creator: Michael Olson <mwolson@gnu.org>
Diffstat (limited to 'lisp/erc')
-rw-r--r--lisp/erc/ChangeLog10
-rw-r--r--lisp/erc/erc.el19
2 files changed, 29 insertions, 0 deletions
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog
index 79ab94269ba..9b7b17ceec4 100644
--- a/lisp/erc/ChangeLog
+++ b/lisp/erc/ChangeLog
@@ -387,6 +387,16 @@
(erc-make-mode-line-buffer-name): Add help-echo and mouse-face
properties to channel name.
+2006-08-20 Michael Olson <mwolson@gnu.org>
+
+ * erc.el (erc-with-server-buffer): New macro that switches to the
+ current ERC server buffer and runs some code. If no server buffer
+ is available, return nil. This is a useful way to access
+ variables in the server buffer.
+ (erc-open-server-buffer-p): New function that returns non-nil if
+ the given buffer is an ERC server buffer that has an open IRC
+ process.
+
2006-08-14 Diane Murray <disumu@x3y2z1.net>
* erc-menu.el: Updated copyright years. Removed EmacsWiki URL.
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 350a77b8210..927dce02d64 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -355,6 +355,17 @@ nicknames with erc-server-user struct instances.")
(cdr (assq (aref s (match-beginning 0)) c)))))
s))
+(defmacro erc-with-server-buffer (&rest body)
+ "Execute BODY in the current ERC server buffer.
+If no server buffer exists, return nil."
+ (let ((buffer (make-symbol "buffer")))
+ `(let ((,buffer (erc-server-buffer)))
+ (when (buffer-live-p ,buffer)
+ (with-current-buffer ,buffer
+ ,@body)))))
+(put 'erc-with-server-buffer 'lisp-indent-function 0)
+(put 'erc-with-server-buffer 'edebug-form-spec '(body))
+
(defstruct (erc-server-user (:type vector) :named)
;; User data
nickname host login full-name info
@@ -1339,6 +1350,14 @@ If BUFFER is nil, the current buffer is used."
(and (eq major-mode 'erc-mode)
(null (erc-default-target)))))
+(defun erc-open-server-buffer-p (&optional buffer)
+ "Return non-nil if argument BUFFER is an ERC server buffer that
+has an open IRC process.
+
+If BUFFER is nil, the current buffer is used."
+ (and (erc-server-buffer-p)
+ (erc-server-process-alive)))
+
(defun erc-query-buffer-p (&optional buffer)
"Return non-nil if BUFFER is an ERC query buffer.
If BUFFER is nil, the current buffer is used."