[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/erc/erc-log.el,v
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/erc/erc-log.el,v |
Date: |
Sun, 01 Apr 2007 13:36:42 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Miles Bader <miles> 07/04/01 13:36:38
Index: lisp/erc/erc-log.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/erc/erc-log.el,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- lisp/erc/erc-log.el 21 Jan 2007 02:47:36 -0000 1.7
+++ lisp/erc/erc-log.el 1 Apr 2007 13:36:37 -0000 1.8
@@ -85,7 +85,9 @@
;;; Code:
(require 'erc)
-(eval-when-compile (require 'cl))
+(eval-when-compile
+ (require 'erc-networks)
+ (require 'cl))
(defgroup erc-log nil
"Logging facilities for ERC."
@@ -100,10 +102,12 @@
SERVER and PORT are the parameters used to connect BUFFERs
`erc-server-process'."
:group 'erc-log
- :type '(choice (const erc-generate-log-file-name-long)
- (const erc-generate-log-file-name-short)
- (const erc-generate-log-file-name-with-date)
- (symbol)))
+ :type '(choice (const :tag "Long style" erc-generate-log-file-name-long)
+ (const :tag "Long, but with network name rather than server"
+ erc-generate-log-file-name-network)
+ (const :tag "Short" erc-generate-log-file-name-short)
+ (const :tag "With date" erc-generate-log-file-name-with-date)
+ (symbol :tag "Other function")))
(defcustom erc-truncate-buffer-on-save nil
"Truncate any ERC (channel, query, server) buffer when it is saved."
@@ -197,7 +201,7 @@
\(setq erc-enable-logging
(lambda (buffer)
(with-current-buffer buffer
- (not erc-away))))"
+ (null (erc-away-time)))))"
;; enable
((when erc-log-write-after-insert
(add-hook 'erc-insert-post-hook 'erc-save-buffer-in-logs))
@@ -211,8 +215,7 @@
;; append, so that 'erc-initialize-log-marker runs first
(add-hook 'erc-connect-pre-hook 'erc-log-setup-logging 'append)
(dolist (buffer (erc-buffer-list))
- (when (buffer-live-p buffer)
- (with-current-buffer buffer (erc-log-setup-logging)))))
+ (erc-log-setup-logging buffer)))
;; disable
((remove-hook 'erc-insert-post-hook 'erc-save-buffer-in-logs)
(remove-hook 'erc-send-post-hook 'erc-save-buffer-in-logs)
@@ -223,30 +226,38 @@
(remove-hook 'erc-part-hook 'erc-conditional-save-buffer)
(remove-hook 'erc-connect-pre-hook 'erc-log-setup-logging)
(dolist (buffer (erc-buffer-list))
- (when (buffer-live-p buffer)
- (with-current-buffer buffer (erc-log-disable-logging))))))
+ (erc-log-disable-logging buffer))))
(define-key erc-mode-map "\C-c\C-l" 'erc-save-buffer-in-logs)
;;; functionality referenced from erc.el
-(defun erc-log-setup-logging ()
+(defun erc-log-setup-logging (buffer)
"Setup the buffer-local logging variables in the current buffer.
-This function is destined to be run from `erc-connect-pre-hook'."
- (when (erc-logging-enabled)
+This function is destined to be run from `erc-connect-pre-hook'.
+The current buffer is given by BUFFER."
+ (when (erc-logging-enabled buffer)
+ (with-current-buffer buffer
(auto-save-mode -1)
(setq buffer-file-name nil)
+ (cond ((boundp 'write-file-functions)
(set (make-local-variable 'write-file-functions)
- '(erc-save-buffer-in-logs))
+ '(erc-save-buffer-in-logs)))
+ ((boundp 'local-write-file-hooks)
+ (setq local-write-file-hooks '(erc-save-buffer-in-logs)))
+ (t
+ (set (make-local-variable 'write-file-hooks)
+ '(erc-save-buffer-in-logs))))
(when erc-log-insert-log-on-open
(ignore-errors (insert-file-contents (erc-current-logfile))
(move-marker erc-last-saved-position
- (1- (point-max)))))))
+ (1- (point-max))))))))
-(defun erc-log-disable-logging ()
- "Disable logging in the current buffer."
- (when (erc-logging-enabled)
+(defun erc-log-disable-logging (buffer)
+ "Disable logging in BUFFER."
+ (when (erc-logging-enabled buffer)
+ (with-current-buffer buffer
(setq buffer-offer-save nil
- erc-enable-logging nil)))
+ erc-enable-logging nil))))
(defun erc-log-all-but-server-buffers (buffer)
"Returns t if logging should be enabled in BUFFER.
@@ -340,6 +351,19 @@
;; we need a make-safe-file-name function.
(convert-standard-filename file)))
+(defun erc-generate-log-file-name-network (buffer target nick server port)
+ "Generates a log-file name using the network name rather than server name.
+This results in a file name of the form address@hidden
+This function is a possible value for `erc-generate-log-file-name-function'."
+ (require 'erc-networks)
+ (let ((file (concat
+ (if target (concat target "!"))
+ nick "@"
+ (or (with-current-buffer buffer (erc-network-name)) server)
+ ".txt")))
+ ;; we need a make-safe-file-name function.
+ (convert-standard-filename file)))
+
;;;###autoload
(defun erc-save-buffer-in-logs (&optional buffer)
"Append BUFFER contents to the log file, if logging is enabled.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/erc/erc-log.el,v,
Miles Bader <=