• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/erc/

Lines Matching +defs:buffer +defs:file +defs:format

16 ;; This file is part of GNU Emacs.
29 ;; along with GNU Emacs; see the file COPYING. If not, write to the
137 "NEWS file for variable name changes since ERC 5.0.4.")))
267 (make-variable-buffer-local 'erc-session-password)
286 without arguments, with the current buffer set to the buffer of
327 Functions are passed a buffer as the first argument."
338 (make-variable-buffer-local 'erc-channel-users)
343 (make-variable-buffer-local 'erc-server-users)
358 (defmacro erc-with-server-buffer (&rest body)
359 "Execute BODY in the current ERC server buffer.
360 If no server buffer exists, return nil."
361 (let ((buffer (make-symbol "buffer")))
362 `(let ((,buffer (erc-server-buffer)))
363 (when (buffer-live-p ,buffer)
364 (with-current-buffer ,buffer
366 (put 'erc-with-server-buffer 'lisp-indent-function 0)
367 (put 'erc-with-server-buffer 'edebug-form-spec '(body))
389 in the current buffer's `erc-channel-users' hash table."
395 (erc-with-server-buffer
402 (erc-with-server-buffer
413 (erc-with-server-buffer
424 (erc-with-server-buffer
428 (if (buffer-live-p buf)
429 (with-current-buffer buf
448 (delq (current-buffer)
466 (if (buffer-live-p buf)
467 (with-current-buffer buf
517 (erc-with-server-buffer
540 (erc-with-server-buffer
597 (make-variable-buffer-local 'erc-channel-topic)
603 (make-variable-buffer-local 'erc-channel-modes)
607 (make-variable-buffer-local 'erc-insert-marker)
611 (make-variable-buffer-local 'erc-input-marker)
638 If non-nil, this will be used in the ERC buffer to indicate
680 to display, the parsed server message, the target buffer (or
686 `erc-echo-notice-in-default-buffer',
687 `erc-echo-notice-in-target-buffer',
689 `erc-echo-notice-in-server-buffer',
690 `erc-echo-notice-in-active-non-server-buffer',
691 `erc-echo-notice-in-active-buffer',
694 `erc-echo-notice-in-first-user-buffer'"
697 :options '(erc-echo-notice-in-default-buffer
698 erc-echo-notice-in-target-buffer
700 erc-echo-notice-in-server-buffer
701 erc-echo-notice-in-active-non-server-buffer
702 erc-echo-notice-in-active-buffer
705 erc-echo-notice-in-first-user-buffer))
708 '(erc-echo-notice-in-default-buffer)
711 to display, the parsed server message, the target buffer (or
717 `erc-echo-notice-in-default-buffer',
718 `erc-echo-notice-in-target-buffer',
720 `erc-echo-notice-in-server-buffer',
721 `erc-echo-notice-in-active-non-server-buffer',
722 `erc-echo-notice-in-active-buffer',
725 `erc-echo-notice-in-first-user-buffer'"
728 :options '(erc-echo-notice-in-default-buffer
729 erc-echo-notice-in-target-buffer
731 erc-echo-notice-in-server-buffer
732 erc-echo-notice-in-active-non-server-buffer
733 erc-echo-notice-in-active-buffer
736 erc-echo-notice-in-first-user-buffer))
808 (make-variable-buffer-local 'erc-ignore-list)
838 (defcustom erc-startup-file-list
848 :type '(repeat file))
863 "A marker containing the position the current buffer was last saved at.")
864 (make-variable-buffer-local 'erc-last-saved-position)
866 (defcustom erc-kill-buffer-on-part nil
867 "Kill the channel buffer on PART.
875 See the variable `erc-kill-buffer-on-part' for details."
879 (defcustom erc-kill-server-buffer-on-quit nil
880 "Kill the server buffer of the process on QUIT."
954 (defvar erc-grab-buffer-name "*erc-grab*"
955 "The name of the buffer created by `erc-grab-region'.")
997 To change the text inserted into the buffer without changing the text
1002 inserting that particular string into the buffer.
1011 "Insert the text into the target buffer or not.
1024 While this hook is run, narrowing is in effect and `current-buffer' is
1025 the buffer where the text got inserted. One possible value to add here
1035 :options '(erc-truncate-buffer
1037 erc-save-buffer-in-logs))
1043 While this hook is run, narrowing is in effect and `current-buffer' is
1044 the buffer where the text got inserted.
1144 "ERC face used for messages you receive in the main erc buffer."
1198 "When set to t, generate debug messages in a separate debug buffer.")
1200 (defvar erc-debug-log-file (expand-file-name "ERC.debug")
1201 "Debug log file name.")
1204 (make-variable-buffer-local 'erc-dbuf)
1214 If LOCAL-P is non-nil, the mode will be created as a buffer-local
1231 (mode (intern (format "erc-%s-mode" (downcase sn))))
1232 (group (intern (format "erc-%s" (downcase sn))))
1233 (enable (intern (format "erc-%s-enable" (downcase sn))))
1234 (disable (intern (format "erc-%s-disable" (downcase sn)))))
1238 ,(format "Toggle ERC %S mode.
1247 ,(format "Enable ERC %S mode."
1254 ,(format "Disable ERC %S mode."
1264 (format "erc-%s-mode"
1276 "Execute FORMS the next time EVENT occurs in the `current-buffer'.
1278 You should make sure that `current-buffer' is a server buffer.
1291 (unless (erc-server-buffer-p)
1293 "You should only run `erc-once-with-server-event' in a server buffer"))
1296 (put fun 'erc-original-buffer (current-buffer))
1298 (with-current-buffer (get ',fun 'erc-original-buffer)
1306 "Execute FORMS the next time EVENT occurs in any server buffer.
1315 When FORMS execute, the current buffer is the server buffer associated with the
1331 (defun erc-server-buffer ()
1332 "Return the server buffer for the current buffer's process.
1333 The buffer-local variable `erc-server-process' is used to find
1334 the process buffer."
1335 (and (erc-server-buffer-live-p)
1336 (process-buffer erc-server-process)))
1338 (defun erc-server-buffer-live-p ()
1339 "Return t if the server buffer has not been killed."
1341 (buffer-live-p (process-buffer erc-server-process))))
1343 (defun erc-server-buffer-p (&optional buffer)
1344 "Return non-nil if argument BUFFER is an ERC server buffer.
1346 If BUFFER is nil, the current buffer is used."
1347 (with-current-buffer (or buffer (current-buffer))
1351 (defun erc-open-server-buffer-p (&optional buffer)
1352 "Return non-nil if argument BUFFER is an ERC server buffer that
1355 If BUFFER is nil, the current buffer is used."
1356 (and (erc-server-buffer-p)
1359 (defun erc-query-buffer-p (&optional buffer)
1360 "Return non-nil if BUFFER is an ERC query buffer.
1361 If BUFFER is nil, the current buffer is used."
1362 (with-current-buffer (or buffer (current-buffer))
1371 (erc-with-server-buffer
1378 (erc-server-send (format "ISON %s" nick))
1388 (let ((cb (current-buffer))
1391 (session-buffer (erc-server-buffer)))
1392 (if session-buffer
1394 (set-buffer session-buffer)
1395 (if (not (and erc-dbuf (bufferp erc-dbuf) (buffer-live-p erc-dbuf)))
1397 (setq erc-dbuf (get-buffer-create
1400 (set-buffer erc-dbuf)
1407 (set-buffer cb))
1410 ;; Last active buffer, to print server messages in the right place
1412 (defvar erc-active-buffer nil
1413 "The current active buffer, the one where the user typed the last command.
1414 Defaults to the server buffer, and should only be set in the
1415 server buffer.")
1416 (make-variable-buffer-local 'erc-active-buffer)
1418 (defun erc-active-buffer ()
1419 "Return the value of `erc-active-buffer' for the current server.
1420 Defaults to the server buffer."
1421 (erc-with-server-buffer
1422 (if (buffer-live-p erc-active-buffer)
1423 erc-active-buffer
1424 (setq erc-active-buffer (current-buffer)))))
1426 (defun erc-set-active-buffer (buffer)
1427 "Set the value of `erc-active-buffer' to BUFFER."
1428 (cond ((erc-server-buffer)
1429 (with-current-buffer (erc-server-buffer)
1430 (setq erc-active-buffer buffer)))
1431 (t (setq erc-active-buffer buffer))))
1466 (defcustom erc-join-buffer 'buffer
1467 "Determines how to display the newly created IRC buffer.
1471 'bury - bury it in a new buffer,
1472 any other value - in place of the current buffer."
1478 (const buffer)))
1484 :type '(repeat (cons :format "%v"
1489 "*Non-nil means the erc frames are dedicated to that buffer.
1490 This only has effect when `erc-join-buffer' is set to `frame'."
1498 ((and (bufferp channel) (buffer-live-p channel))
1499 (with-current-buffer channel
1505 If non-nil, a new buffer will only be created when you join
1547 (defun erc-generate-new-buffer-name (server port target &optional proc)
1548 "Create a new buffer name based on the arguments."
1555 "*erc-server-buffer*"))))
1556 ;; Reuse existing buffers, but not if the buffer is a connected server
1557 ;; buffer and not if its associated with a different server than the
1558 ;; current ERC buffer.
1560 (get-buffer buf-name)
1562 (with-current-buffer (get-buffer buf-name)
1563 (and (erc-server-buffer-p)
1565 (with-current-buffer (get-buffer buf-name)
1569 (generate-new-buffer-name buf-name))))
1571 (defun erc-get-buffer-create (server port target &optional proc)
1572 "Create a new buffer based on the arguments."
1573 (get-buffer-create (erc-generate-new-buffer-name server port target proc)))
1588 (defmacro erc-with-buffer (spec &rest body)
1589 "Execute BODY in the buffer associated with SPEC.
1595 If TARGET is a buffer, use it. Otherwise, use the buffer
1599 See `erc-get-buffer' for details.
1601 See also `with-current-buffer'.
1616 (erc-get-buffer ,target ,proc))))))
1617 (when (buffer-live-p ,buf)
1618 (with-current-buffer ,buf
1620 (put 'erc-with-buffer 'lisp-indent-function 1)
1621 (put 'erc-with-buffer 'edebug-form-spec '((form &optional form) body))
1623 (defun erc-get-buffer (target &optional proc)
1624 "Return the buffer matching TARGET in the process PROC.
1627 (catch 'buffer
1628 (erc-buffer-filter
1633 (throw 'buffer (current-buffer)))))
1636 (defun erc-buffer-filter (predicate &optional proc)
1638 PREDICATE is a function executed with each buffer, if it returns t, that buffer
1647 (when (buffer-live-p buf)
1648 (with-current-buffer buf
1654 (buffer-list)))))
1656 (defun erc-buffer-list (&optional predicate proc)
1658 PREDICATE is a function which executes with every buffer satisfying
1664 (erc-buffer-filter predicate proc))
1676 (mapcar (lambda (buffer)
1677 (with-current-buffer buffer
1679 (erc-buffer-list ,pre
1685 "Use `iswitchb-read-buffer' to prompt for a ERC buffer to switch to.
1689 `erc-modified-channels-alist' in front of the buffer list.
1702 (mapcar 'buffer-name
1703 (erc-buffer-list
1706 (switch-to-buffer
1707 (iswitchb-read-buffer
1710 (buffer-name (caar (last erc-modified-channels-alist)))
1719 (erc-buffer-filter
1725 (defun erc-buffer-list-with-nick (nick proc)
1727 (with-current-buffer (process-buffer proc)
1736 "List of default recipients of the current buffer.")
1737 (make-variable-buffer-local 'erc-default-recipients)
1741 (make-variable-buffer-local 'erc-session-user-full-name)
1745 (make-variable-buffer-local 'erc-channel-user-limit)
1749 (make-variable-buffer-local 'erc-channel-key)
1753 (make-variable-buffer-local 'erc-invitation)
1759 buffer rather than a server buffer.")
1760 (make-variable-buffer-local 'erc-away)
1764 (make-variable-buffer-local 'erc-channel-list)
1768 (make-variable-buffer-local 'erc-bad-nick)
1772 (make-variable-buffer-local 'erc-logged-in)
1776 (make-variable-buffer-local 'erc-default-nicks)
1780 (make-variable-buffer-local 'erc-nick-change-attempt-count)
1785 ;; each item is in the format '(old . new)
1806 (let ((f (intern-soft (format "erc-%s-mode" module))))
1842 (const :tag "scrolltobottom: Scroll to the bottom of the buffer"
1880 (defun erc-setup-buffer (buffer)
1881 "Consults `erc-join-buffer' to find out how to display `BUFFER'."
1882 (cond ((eq erc-join-buffer 'window)
1884 (display-buffer buffer)
1885 (switch-to-buffer-other-window buffer)))
1886 ((eq erc-join-buffer 'window-noselect)
1887 (display-buffer buffer))
1888 ((eq erc-join-buffer 'bury)
1890 ((eq erc-join-buffer 'frame)
1896 (switch-to-buffer buffer)
1901 (display-buffer buffer)
1902 (switch-to-buffer buffer)))))
1909 already connected and just create a separate buffer for the new
1915 Returns the buffer for the given server or channel."
1920 (buffer (erc-get-buffer-create server port channel))
1921 (old-buffer (current-buffer))
1926 (set-buffer buffer)
1935 ;; go to the end of the buffer and open a new line
1936 ;; (the buffer may have existed)
1953 (progn ;; server buffer
1957 (progn ;; target buffer
1967 ;; last active buffer, defaults to this one
1968 (erc-set-active-buffer buffer)
1981 ;; debug output buffer
1984 (get-buffer-create (concat "*ERC-DEBUG: " server "*"))))
1997 ;; Saving log file on exit
1998 (run-hook-with-args 'erc-connect-pre-hook buffer)
2001 (erc-server-connect erc-session-server erc-session-port buffer))
2004 ;; Now display the buffer in a window as per user wishes.
2005 (unless (eq buffer old-buffer)
2007 ;; we can't log to debug buffer, it may not exist yet
2008 (message "erc: old buffer %s, switching to %s"
2009 old-buffer buffer))
2010 (erc-setup-buffer buffer))
2012 buffer))
2014 (defun erc-initialize-log-marker (buffer)
2016 BUFFER is the current buffer."
2017 (with-current-buffer buffer
2032 This is determined by looking for the appropriate buffer and checking
2034 If no buffer matches, return nil."
2035 (erc-buffer-list
2084 (erc-format-message 'nick-in-use ?n nick)
2106 ;; bncs transparent, so that erc-compute-buffer-name displays
2109 (erc-format-message 'nick-in-use ?n nick)
2154 (defun erc-open-ssl-stream (name buffer host port)
2156 The process will be given the name NAME, its target buffer will be
2159 (let ((proc (open-tls-stream name buffer host port)))
2171 "If non-nil, log all IRC protocol traffic to the buffer \"*erc-protocol*\".
2173 The buffer is created if it doesn't exist.
2176 visible \"*erc-protocol*\" buffer, it will be recreated shortly,
2183 "Append STRING to the buffer *erc-protocol*.
2187 The buffer is created if it doesn't exist.
2190 and appears in face `erc-input-face' in the buffer."
2194 (with-current-buffer (get-buffer-create "*erc-protocol*")
2216 (debug-buffer-window (get-buffer-window (current-buffer) t)))
2217 (when debug-buffer-window
2218 (select-window debug-buffer-window)
2227 If ARG is non-nil, show the *erc-protocol* buffer."
2229 (let* ((buf (get-buffer-create "*erc-protocol*")))
2230 (with-current-buffer buf
2234 (insert (erc-make-notice "This buffer displays all IRC protocol traffic exchanged with each server.\n"))
2235 (insert (erc-make-notice "Kill this buffer to terminate protocol logging.\n\n")))
2238 (add-hook 'kill-buffer-hook
2244 (format "IRC protocol logging %s at %s -- Press ENTER to toggle logging.\n"
2249 (not (get-buffer-window "*erc-protocol*" t)))
2250 (display-buffer buf t))
2251 (message "IRC protocol traffic logging %s (see buffer *erc-protocol*)."
2260 (erc-send-ctcp-message tgt (format "ACTION %s" str) force)
2262 nil 'input (current-buffer)
2272 (defun erc-display-line-1 (string buffer)
2276 If `erc-insert-this' is still t, STRING gets inserted into the buffer.
2281 (set-buffer (or buffer (process-buffer erc-server-process)))
2285 (buffer-undo-list t)
2293 (format "(%S)" string) " in buffer "
2294 (format "%s" buffer)))
2303 (save-excursion ;; to restore point in the new buffer
2318 ;; Translate buffer positions in buffer-undo-list by SHIFT.
2319 (unless (or (zerop shift) (atom buffer-undo-list))
2320 (let ((list buffer-undo-list) elt)
2351 (defun erc-display-line (string &optional buffer)
2354 or omitted, the default ERC buffer for the `erc-session-server' is used.
2355 The BUFFER can be an actual buffer, a list of buffers, 'all or 'active.
2357 current session. 'active means the current active buffer
2358 \(`erc-active-buffer'). If the buffer can't be resolved, the current
2359 buffer is used. `erc-display-line-1' is used to display STRING.
2365 ((bufferp buffer) (list buffer))
2366 ((listp buffer) buffer)
2367 ((processp buffer) (list (process-buffer buffer)))
2368 ((eq 'all buffer)
2370 (erc-buffer-list nil erc-server-process))
2371 ((and (eq 'active buffer) (erc-active-buffer))
2372 (list (erc-active-buffer)))
2373 ((erc-server-buffer-live-p)
2374 (list (process-buffer erc-server-process)))
2375 (t (list (current-buffer)))))
2376 (when (buffer-live-p buf)
2380 (if (erc-server-buffer-live-p)
2381 (erc-display-line-1 string (process-buffer erc-server-process))
2382 (erc-display-line-1 string (current-buffer))))))
2399 (defun erc-display-message (parsed type buffer msg &rest args)
2402 ARGS, PARSED, and TYPE are used to format MSG sensibly.
2404 See also `erc-format-message' and `erc-display-line'."
2406 (apply 'erc-format-message msg args)
2422 (erc-display-line string buffer)
2426 (erc-display-line string buffer)))))
2437 (make-variable-buffer-local 'erc-send-input-line-function)
2443 (setq line (format "PRIVMSG %s :%s"
2454 (let ((arglist (format "%S" (erc-function-arglist fun))))
2489 (erc-display-message nil 'error (current-buffer) 'incorrect-args
2493 ?d (format "%s\n"
2499 (erc-display-message nil 'error (current-buffer) 'no-target)
2539 nil nil 'active (format "Set %S to %S" var val))
2546 nil nil 'active (format "Set %S to %S" var val))
2558 (concat (format "%S:" var)
2561 (format " %S\n" val)))))
2563 (current-buffer)) t)
2575 (erc-log (format "cmd: DEFAULT: %s" line))
2585 (y-or-n-p (format "Use regexp-quoted form (%s) instead? "
2589 (erc-make-notice (format "Now ignoring %s" user))
2591 (erc-with-server-buffer (add-to-list 'erc-ignore-list user)))
2592 (if (null (erc-with-server-buffer erc-ignore-list))
2598 (erc-with-server-buffer erc-ignore-list))))
2603 (let ((ignored-nick (car (erc-with-server-buffer
2608 (unless (y-or-n-p (format "Remove this regexp (%s)? "
2612 (erc-make-notice (format "%s is not currently ignored!" user))
2616 (erc-make-notice (format "No longer ignoring %s" user))
2618 (erc-with-server-buffer
2643 nil 'notice (current-buffer) 'ops
2646 (erc-display-message nil 'notice (current-buffer) 'ops-none)))
2665 (erc-log (format "cmd: AWAY: %s" reason))
2677 #'erc-open-server-buffer-p
2689 (erc-log (format "cmd: CTCP [%s]: [%s]" nick str))
2748 (erc-display-message nil 'error (current-buffer) 'no-invitation))
2754 (with-current-buffer chanbuf (erc-default-target)))
2757 (switch-to-buffer (car (erc-member-ignore-case chnl
2759 (erc-log (format "cmd: JOIN: %s" chnl))
2761 (erc-server-send (format "JOIN %s %s" chnl key))
2762 (erc-server-send (format "JOIN %s" chnl)))))))
2773 (make-variable-buffer-local 'erc-channel-new-member-names)
2784 (erc-log (format "cmd: DEFAULT: NAMES %s" tgt))
2785 (erc-with-buffer
2789 (erc-display-message nil 'error (current-buffer) 'no-default-channel)))
2795 LINE has the format: \"#CHANNEL NICK REASON\" or \"NICK REASON\"."
2798 (setq reasonstring (format "Kicked by %s" (erc-current-nick))))
2801 (erc-log (format "cmd: KICK: %s/%s: %s" nick target reasonstring))
2802 (erc-server-send (format "KICK %s %s :%s" target nick reasonstring)
2813 (format "cmd: KICK: %s/%s: %s" target ch reasonstring))
2815 (format "KICK %s %s :%s" ch target reasonstring) nil ch))
2816 (erc-display-message nil 'error (current-buffer)
2824 If LINE continues beyond the file name, the rest of
2832 (let* ((file-to-find (match-string 1 line))
2834 (file (erc-find-file file-to-find erc-script-path)))
2835 (erc-log (format "cmd: LOAD: %s" file-to-find))
2837 ((not file)
2838 (erc-display-message nil 'error (current-buffer)
2839 'cannot-find-file ?f file-to-find))
2840 ((not (file-readable-p file))
2841 (erc-display-message nil 'error (current-buffer)
2842 'cannot-read-file ?f file))
2844 (message "Loading \'%s\'..." file)
2845 (erc-load-script file)
2846 (message "Loading \'%s\'...done" file))))
2856 (format "WHOIS %s %s" user server)
2857 (format "WHOIS %s" user))))
2858 (erc-log (format "cmd: %s" send))
2870 (let ((origbuf (current-buffer))
2872 (erc-with-server-buffer
2918 (format "%s has been idle for %s."
2930 (with-current-buffer ,(current-buffer)
2939 LINE has the format \"USER ACTION\"."
2945 (erc-log (format "cmd: DESCRIBE: [%s] %s" dst s))
2956 (erc-log (format "cmd: ME: %s" s))
2963 "Show all lines in the current buffer matching the regexp LINE.
2967 The lines are shown in a buffer named `*Occur*'.
2968 It serves as a menu to find any of the occurrences in this buffer.
2969 \\[describe-mode] in that buffer will explain how.
2983 (concat (erc-format-my-nick) line)
2984 (current-buffer))
3000 (erc-log (format "cmd: MODE: %s" s))
3029 (erc-log (format "cmd: NICK: %s (erc-bad-nick: %S)" nick erc-bad-nick))
3030 (let ((nicklen (cdr (assoc "NICKLEN" (erc-with-server-buffer
3036 (erc-server-send (format "NICK %s" nick))
3051 (erc-log (format "cmd: PART: %s: %s" ch reason))
3053 (format "PART %s" ch)
3054 (format "PART %s :%s" ch reason))
3063 (erc-log (format "cmd: PART: %s: %s" ch reason))
3065 (format "PART %s" ch)
3066 (format "PART %s :%s" ch reason))
3068 (erc-display-message nil 'error (current-buffer) 'no-target)))
3077 (let ((time (format "%f" (erc-current-time))))
3078 (erc-log (format "cmd: PING: %s" time))
3094 `erc-join-buffer'. If USER is omitted, close the current query buffer if one
3098 (let ((session-buffer (erc-server-buffer)))
3100 (erc-query user session-buffer)
3111 (format "\C-bERC\C-b %s (IRC client for Emacs)"; - \C-b%s\C-b"
3138 (format "\C-bERC\C-b %s (IRC client for Emacs)"; - \C-b%s\C-b"
3169 (buffer (erc-server-buffer))
3172 (with-current-buffer (if (and buffer
3173 (bufferp buffer))
3174 buffer
3175 (current-buffer))
3176 (erc-log (format "cmd: QUIT: %s" reason))
3178 (erc-set-active-buffer (erc-server-buffer))
3180 (erc-server-send (format "QUIT :%s" reason)))
3201 (erc-with-all-buffers-of-server nil #'erc-open-server-buffer-p
3209 (let ((buffer (or (erc-server-buffer) (current-buffer)))
3211 (with-current-buffer (if (bufferp buffer) buffer (current-buffer))
3215 (setq process (get-buffer-process (erc-server-buffer)))
3224 (erc-log (format "cmd: SERVER: %s" server))
3238 (erc-send-message (format "I'm using ERC %s with %s %s (%s%s) of %s."
3256 (format ", %s scroll bars"
3266 (erc-send-message (format "I'm using the following modules: %s!"
3295 (erc-log (format "cmd: TIME: %s" args))
3303 LINE has the format: \"#CHANNEL TOPIC\", \"#CHANNEL\", \"TOPIC\"
3314 (erc-log (format "cmd: TOPIC [%s]: %s" ch topic))
3315 (erc-server-send (format "TOPIC %s :%s" ch topic) nil ch))
3320 (erc-server-send (format "TOPIC %s" ch) nil ch)
3325 (erc-server-send (format "TOPIC %s" ch) nil ch)
3333 (erc-log (format "cmd: TOPIC [%s]: %s" ch topic))
3334 (erc-server-send (format "TOPIC %s :%s" ch topic) nil ch))
3335 (erc-display-message nil 'error (current-buffer) 'no-target)))
3359 (erc-server-send (format "TOPIC %s :" chnl))
3372 (make-variable-buffer-local 'erc-channel-banlist)
3380 (chnl-name (buffer-name)))
3392 (erc-with-server-buffer
3395 `(with-current-buffer ,chnl-name
3400 (erc-server-send (format "MODE %s b" chnl)))))
3404 (format "No bans for channel: %s\n" chnl))
3420 (erc-make-notice (format "Ban list for channel: %s\n"
3425 (erc-display-line (format fmt "Ban Mask" "Banned By") 'active)
3431 (format fmt
3462 (erc-with-server-buffer
3465 `(with-current-buffer ,chnl
3470 (erc-server-send (format "MODE %s b" chnl)))))
3479 (format "MODE %s -%s %s" (erc-default-target)
3497 "Copy the region between START and END in a recreatable format.
3500 into control codes and writes them to a separate buffer. The
3504 (erc-set-active-buffer (current-buffer))
3506 (let* ((cb (current-buffer))
3507 (buf (generate-new-buffer erc-grab-buffer-name))
3508 (region (buffer-substring start end))
3510 (set-buffer buf)
3513 (set-buffer cb)
3514 (switch-to-buffer-other-window buf)))
3518 (defun erc-display-prompt (&optional buffer pos prompt face)
3523 If BUFFER is nil, the `current-buffer' is used.
3529 (ob (current-buffer)))
3532 (when (and buffer (bufferp buffer))
3533 (set-buffer buffer))
3536 ;; in the current buffer
3562 ;; Clear the undo buffer now, so the user can undo his stuff,
3564 (setq buffer-undo-list nil)
3565 (set-buffer ob)))
3584 (erc-set-active-buffer (current-buffer))
3597 (table (when (erc-server-buffer-live-p)
3598 (set-buffer (process-buffer erc-server-process))
3631 (format "Limit for %s (RET to remove limit): "
3635 (erc-server-send (format "MODE %s +l %s" tgt limit))
3636 (erc-server-send (format "MODE %s -l" tgt)))))
3642 (format "Key for %s (RET to remove key): "
3646 (erc-server-send (format "MODE %s +k %s" tgt key))
3647 (erc-server-send (format "MODE %s -k" tgt)))))
3653 (format "Reason for quitting %s: "
3725 ;(make-variable-buffer-local 'erc-server-vectors)
3735 "Open a query buffer on TARGET, using SERVER.
3737 `erc-join-buffer' before calling this."
3739 (buffer-live-p server)
3740 (set-buffer server))
3741 (error "Couldn't switch to server buffer"))
3757 "If non-nil, create a query buffer each time you receive a private message.
3759 If the buffer doesn't already exist it is created. This can be
3761 appear. See the documentation for `erc-join-buffer' for
3765 (const buffer)
3772 "If non-nil create query buffer on receiving any PRIVMSG at all.
3779 (defcustom erc-format-query-as-channel-p t
3780 "If non-nil, format text from others in a query buffer like in a channel,
3781 otherwise format like a private message."
3787 Only happens when the session buffer isn't visible."
3826 (format "Nickname %s is %s, try another." nick reason))
3830 (erc-with-server-buffer
3851 (format "Nickname %s is %s, trying %s"
3886 (not (erc-get-buffer query proc))
3888 (let ((erc-join-buffer erc-auto-query))
3901 (defun erc-format-privmessage (nick msg privp msgp)
3905 (str (format "%s%s%s %s" mark-s nick mark-e msg))
3916 (defcustom erc-format-nick-function 'erc-format-nick
3917 "*Function to format a nickname for message display."
3921 (defun erc-format-nick (&optional user channel-data)
3923 See also `erc-format-nick-function'."
3926 (defun erc-format-@nick (&optional user channel-data)
3930 See also `erc-format-nick-function'."
3936 (defun erc-format-my-nick ()
3949 (defun erc-echo-notice-in-default-buffer (s parsed buffer sender)
3950 "Echos a private notice in the default buffer, namely the
3951 target buffer specified by BUFFER, or there is no target buffer,
3952 the server buffer. This function is designed to be added to
3955 (erc-display-message parsed nil buffer s)
3958 (defun erc-echo-notice-in-target-buffer (s parsed buffer sender)
3963 (if buffer
3964 (progn (erc-display-message parsed nil buffer s) t)
3967 (defun erc-echo-notice-in-minibuffer (s parsed buffer sender)
3974 (defun erc-echo-notice-in-server-buffer (s parsed buffer sender)
3975 "Echos a private notice in the server buffer. This function is
3981 (defun erc-echo-notice-in-active-non-server-buffer (s parsed buffer sender)
3982 "Echos a private notice in the active buffer if the active
3983 buffer is not the server buffer. This function is designed to be
3986 buffer is not the server buffer."
3987 (if (not (eq (erc-server-buffer) (erc-active-buffer)))
3991 (defun erc-echo-notice-in-active-buffer (s parsed buffer sender)
3992 "Echos a private notice in the active buffer. This function is
3998 (defun erc-echo-notice-in-user-buffers (s parsed buffer sender)
4002 returns non-nil iff there is at least one buffer for which the
4005 See also: `erc-echo-notice-in-first-user-buffer',
4006 `erc-buffer-list-with-nick'."
4007 (let ((buffers (erc-buffer-list-with-nick sender erc-server-process)))
4012 (defun erc-echo-notice-in-user-and-target-buffers (s parsed buffer sender)
4017 at least one buffer for which the sender is a member or the
4021 `erc-buffer-list-with-nick'."
4022 (let ((buffers (erc-buffer-list-with-nick sender erc-server-process)))
4023 (add-to-list 'buffers buffer)
4028 (defun erc-echo-notice-in-first-user-buffer (s parsed buffer sender)
4032 returns non-nil iff there is at least one buffer for which the
4036 `erc-buffer-list-with-nick'."
4037 (let ((buffers (erc-buffer-list-with-nick sender erc-server-process)))
4048 ;; Determine to which buffer the message corresponds
4049 (let ((buffer (erc-get-buffer channel proc)))
4050 (with-current-buffer buffer
4059 (buffer (erc-get-buffer channel proc)))
4060 (with-current-buffer buffer
4070 (buffer (erc-get-buffer tgt proc)))
4071 (when buffer
4072 (with-current-buffer buffer
4112 (let ((f (erc-select-startup-file)))
4120 (with-current-buffer (process-buffer proc)
4125 (buffer (process-buffer proc)))
4128 (erc-set-initial-user-mode nick buffer)
4129 (erc-server-setup-periodical-ping buffer)
4132 (defun erc-set-initial-user-mode (nick buffer)
4134 The server buffer is given by BUFFER."
4135 (with-current-buffer buffer
4141 (erc-log (format "changing mode for %s to %s" nick mode))
4142 (erc-server-send (format "MODE %s %s" nick mode)))))))
4197 (buf (or (erc-get-buffer to proc)
4198 (erc-get-buffer nick proc)
4199 (process-buffer proc))))
4211 (erc-send-ctcp-notice nick (format "CLIENTINFO %s" s)))))
4220 (erc-send-ctcp-notice nick (format "ECHO %s" s)))))
4228 (format "FINGER I'm %s." (erc-current-nick))
4229 (format "FINGER %s (%s@%s)."
4245 (erc-send-ctcp-notice nick (format "PING %s" arg)))))
4252 (erc-send-ctcp-notice nick (format "TIME %s" (current-time-string))))
4259 (erc-send-ctcp-notice nick (format "USERINFO %s" erc-user-information)))
4267 nick (format
4358 (let ((sessionbuf (process-buffer proc)))
4360 (with-current-buffer sessionbuf
4362 (erc-log (format "erc-process-away: away-nick: %s, away-p: %s"
4376 (set-buffer (erc-active-buffer))
4381 (format "is back (gone for %s)"
4395 be called with the current buffer set to the channel buffer.
4404 received. Should be called with the current buffer set to the
4405 channel buffer.
4445 The buffer where the change happened is current while this hook is called."
4494 (if (buffer-live-p buf)
4495 (with-current-buffer buf
4526 (erc-log (format "update-member: user = %S, cuser = %S" user cuser))
4555 :buffers (list (current-buffer))))
4558 (cons (current-buffer)
4583 (erc-with-buffer
4601 (erc-with-buffer
4606 "Find a buffer for CHANNEL and set the TOPIC for it.
4610 (erc-with-buffer (channel)
4616 (erc-update-mode-line-buffer (current-buffer))))
4627 (erc-get-buffer tgt erc-server-process))))
4629 (with-current-buffer buf
4643 (erc-update-mode-line-buffer buf)))))
4719 (erc-get-buffer tgt erc-server-process))))
4721 ;; FIXME! This used to have an original buffer
4723 ;; buffer. Is this wanted behavior?
4724 (set-buffer buf)
4760 (erc-with-buffer
4767 (erc-with-buffer
4786 (erc-log (format "user-change: type: %S nlh: %S l: %S" type nlh l))
4899 ((not (erc-server-buffer-live-p))
4903 (erc-set-active-buffer (current-buffer))
4906 (old-buf (current-buffer)))
4914 ;; Fix the buffer if the command didn't kill it
4915 (when (buffer-live-p old-buf)
4916 (with-current-buffer old-buf
4922 (let ((buffer-modified (buffer-modified-p)))
4924 (set-buffer-modified-p buffer-modified))))))
4930 "Return the input of the user in the current buffer."
4931 (buffer-substring
5001 (insert (erc-format-my-nick))
5017 (let ((cmd (intern-soft (format "erc-cmd-%s" (upcase command)))))
5032 (format "%s" (match-string 2 line))
5059 (with-current-buffer (if (buffer-live-p (erc-server-buffer))
5060 (erc-server-buffer)
5061 (current-buffer))
5066 (with-current-buffer (if (buffer-live-p (erc-server-buffer))
5067 (erc-server-buffer)
5068 (current-buffer))
5103 (defun erc-delete-default-channel (channel &optional buffer)
5105 (let ((ob (current-buffer)))
5106 (with-current-buffer (if (and buffer
5107 (bufferp buffer))
5108 buffer
5109 (current-buffer))
5142 (dolist (ignored (erc-with-server-buffer erc-ignore-list))
5155 (erc-with-buffer (tgt proc)
5233 (erc-set-active-buffer (current-buffer))
5237 (erc-display-message nil 'error (current-buffer) 'no-target))
5271 (erc-set-active-buffer (current-buffer))
5277 (erc-log (format "%s: Toggle mode %s OFF" tgt mode))
5279 (erc-server-send (format "MODE %s -%s" tgt mode)))
5280 (t (erc-log (format "%s: Toggle channel mode %s ON" tgt mode))
5282 (erc-server-send (format "MODE %s +%s" tgt mode))))))
5289 (erc-display-message nil 'error (current-buffer) 'no-target))))
5294 (erc-set-active-buffer (current-buffer))
5297 (erc-display-message nil 'error (current-buffer) 'no-target))))
5308 (defun erc-find-file (file &optional path)
5314 (let ((filepath file))
5315 (if (file-readable-p filepath) filepath
5318 (progn (setq filepath (expand-file-name file (car path)))
5319 (not (file-readable-p filepath))))
5323 (defun erc-select-startup-file ()
5324 "Select an ERC startup file.
5325 See also `erc-startup-file-list'."
5327 (dolist (f erc-startup-file-list)
5329 (when (file-readable-p f)
5332 (defun erc-find-script-file (file)
5334 (erc-find-file file erc-script-path))
5336 (defun erc-load-script (file)
5343 (erc-log (concat "erc-load-script: " file))
5345 ((string-match "\\.el$" file)
5346 (load file))
5348 (erc-load-irc-script file))))
5409 (t (erc-log (format "BUG in erc-process-script-line: bad escape sequence: %S\n" esc))
5420 (defun erc-load-irc-script (file &optional force)
5422 (erc-log (concat "erc-load-script: " file))
5423 (let ((str (with-temp-buffer
5424 (insert-file-contents file)
5425 (buffer-string))))
5434 (let* ((cb (current-buffer))
5461 (erc-log (format "login: nick: %s, user: %s %s %s :%s"
5468 (erc-server-send (format "PASS %s" erc-session-password))
5470 (erc-server-send (format "NICK %s" (erc-current-nick)))
5472 (format "USER %s %s %s :%s"
5483 Sets the buffer local variables:
5555 "Convert the long number represented by STRING into an Emacs format.
5556 Returns a list of the form (HIGH LOW), compatible with Emacs time format."
5584 (format "%02d:%02d.%02d"
5591 (let (days hours minutes format-args output)
5598 format-args (if (> days 0)
5607 output (apply 'format format-args))
5648 (unless (file-attributes dir) (make-directory dir))
5649 (or (file-accessible-directory-p dir) (error "Cannot access %s" dir)))
5657 (not (erc-server-buffer-p)))
5658 (kill-buffer (current-buffer))))
5687 (if full-name (format " (%s)" full-name) "")
5689 (format " and is +%s%s on %s"
5700 See `current-time' for details on the time format."
5701 (erc-with-server-buffer erc-away))
5705 (defcustom erc-mode-line-format "%s %a"
5708 The string is formatted using `format-spec' and the result is set as the value
5709 of `mode-line-buffer-identification'.
5719 %s: In the server-buffer, this gets filled with the value of
5725 (defcustom erc-header-line-format "%n on %t (%m,%l) %o"
5732 See `erc-mode-line-format' for which characters are can be used."
5774 (defcustom erc-mode-line-away-status-format
5778 `format-time-string'."
5785 (with-temp-buffer
5793 (buffer-string))))
5795 (defun erc-format-target ()
5804 (defun erc-format-target-and/or-server ()
5813 (t (buffer-name (current-buffer))))))
5815 (defun erc-format-away-status ()
5816 "Return a formatted `erc-mode-line-away-status-format'
5820 (format-time-string erc-mode-line-away-status-format a)
5823 (defun erc-format-channel-modes ()
5829 (format "lk %.0f %s" erc-channel-user-limit
5831 (format "kl %.0f" erc-channel-user-limit)))
5834 (format "l %.0f" erc-channel-user-limit))
5837 (format "k %s" erc-channel-key)
5841 (defun erc-format-lag-time ()
5843 (let ((lag (erc-with-server-buffer erc-server-lag)))
5844 (cond (lag (format "lag:%.0f" lag))
5847 (defun erc-update-mode-line-buffer (buffer)
5848 "Update the mode line in a single ERC buffer BUFFER."
5849 (with-current-buffer buffer
5850 (let ((spec (format-spec-make
5851 ?a (erc-format-away-status)
5852 ?l (erc-format-lag-time)
5853 ?m (erc-format-channel-modes)
5857 ?s (erc-format-target-and/or-server)
5858 ?t (erc-format-target)))
5873 (setq modeline-buffer-identification
5874 (list (format-spec erc-mode-line-format spec)))
5877 (setq mode-line-buffer-identification
5878 (list (format-spec erc-mode-line-format spec)))
5880 (when (boundp 'header-line-format)
5881 (let ((header (if erc-header-line-format
5882 (format-spec erc-header-line-format spec)
5885 (setq header-line-format nil))
5887 (let ((help-echo (with-temp-buffer
5890 (buffer-string))))
5891 (setq header-line-format
5899 (t (setq header-line-format
5907 (defun erc-update-mode-line (&optional buffer)
5911 (if (and buffer (bufferp buffer))
5912 (erc-update-mode-line-buffer buffer)
5913 (dolist (buf (erc-buffer-list))
5914 (when (buffer-live-p buf)
5915 (erc-update-mode-line-buffer buf)))))
5940 (format "ERC %s (GNU Emacs %s)" erc-version-string emacs-version)))
5979 "Open a window for every non-server buffer related to `erc-session-server'.
5984 (error "No erc-server-process found in current buffer"))
5985 (let ((bufs (erc-buffer-list nil erc-server-process)))
5988 (switch-to-buffer (car bufs))
5993 (switch-to-buffer (car bufs))
5997 (defun erc-popup-input-buffer ()
5998 "Provide an input buffer."
6000 (let ((buffer-name (generate-new-buffer-name "*ERC input*"))
6008 (pop-to-buffer (make-indirect-buffer (current-buffer) buffer-name))
6011 (shrink-window-if-larger-than-buffer)))
6020 (defun erc-define-catalog-entry (catalog entry format-spec)
6023 format-spec))
6035 (cannot-find-file . "Cannot find file %f")
6036 (cannot-read-file . "Cannot read file %f")
6161 (format "You have left channel %s" channel)
6162 (format "%s (%s@%s) has left channel %s%s"
6165 (format ": %s"
6171 (make-variable-buffer-local 'erc-current-message-catalog)
6187 (defun erc-format-message (msg &rest args)
6190 See also `format-spec'."
6195 (error "No format spec for message %s" msg))
6198 (format-spec entry (apply 'format-spec-make args))))
6202 (add-hook 'kill-buffer-hook 'erc-kill-buffer-function)
6205 "*Invoked whenever a server-buffer is killed via `kill-buffer'."
6210 "*Invoked whenever a channel-buffer is killed via `kill-buffer'."
6214 (defcustom erc-kill-buffer-hook nil
6215 "*Hook run whenever a non-server or channel buffer is killed.
6217 See also `kill-buffer'."
6221 (defun erc-kill-buffer-function ()
6222 "Function to call when an ERC buffer is killed.
6223 This function should be on `kill-buffer-hook'.
6224 When the current buffer is in `erc-mode', this function will run
6226 `erc-kill-server-hook' if the server buffer was killed,
6227 `erc-kill-channel-hook' if a channel buffer was killed,
6228 or `erc-kill-buffer-hook' if any other buffer."
6232 ((eq (erc-server-buffer) (current-buffer))
6237 (run-hooks 'erc-kill-buffer-hook)))))
6240 "Sends a QUIT command to the server when the server buffer is killed.
6244 (erc-server-send (format "QUIT :%s" (funcall erc-quit-reason nil)))))
6247 "Sends a PART command to the server when the channel buffer is killed.
6251 (erc-server-send (format "PART %s :%s" tgt
6294 (let ((server-buffer
6295 (car (erc-buffer-filter
6299 (erc-open-server-buffer-p)))))))
6300 (with-current-buffer (or server-buffer (current-buffer))
6301 (if (and server-buffer channel)
6304 (not server-buffer) password nil channel
6305 (when server-buffer
6306 (get-buffer-process server-buffer)))))))