aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2008-01-02 02:20:56 +0000
committerMiles Bader2008-01-02 02:20:56 +0000
commitaacde24f5cdebc6d7ccb2f50a9d8e413906c4497 (patch)
tree164428e2f737beaecf39a165b451affdc22aec46
parentb201b9880e01120b7e64f82c98464c5bea630b0d (diff)
downloademacs-aacde24f5cdebc6d7ccb2f50a9d8e413906c4497.tar.gz
emacs-aacde24f5cdebc6d7ccb2f50a9d8e413906c4497.zip
Make rcirc logging more customizable
(rcirc-log-filename-function): New variable. (rcirc-log): Use `rcirc-log-filename-function' to generate the log-file name. Don't log anything if it returns nil. (rcirc-log-write): Use `expand-file-name' when merging the log-file name from the alist with rcirc-log-directory; this does the right thing if the name in the alist already an absolute filename. Make the log-file directory if necessary. Revision: emacs@sv.gnu.org/emacs--devo--0--patch-976
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/net/rcirc.el53
2 files changed, 44 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fc4e3046931..470812daa18 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12008-01-02 Miles Bader <Miles Bader <miles@gnu.org>>
2
3 * net/rcirc.el (rcirc-log-filename-function): New variable.
4 (rcirc-log): Use `rcirc-log-filename-function' to generate the
5 log-file name. Don't log anything if it returns nil.
6 (rcirc-log-write): Use `expand-file-name' when merging the
7 log-file name from the alist with rcirc-log-directory; this does
8 the right thing if the name in the alist already an absolute
9 filename. Make the log-file directory if necessary.
10
12007-12-29 Richard Stallman <rms@gnu.org> 112007-12-29 Richard Stallman <rms@gnu.org>
2 12
3 * font-lock.el (font-lock-prepend-text-property) 13 * font-lock.el (font-lock-prepend-text-property)
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index a1a0e0ca8e9..06e5c1ad678 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -1480,32 +1480,47 @@ record activity."
1480 (run-hook-with-args 'rcirc-print-hooks 1480 (run-hook-with-args 'rcirc-print-hooks
1481 process sender response target text))))) 1481 process sender response target text)))))
1482 1482
1483(defcustom rcirc-log-filename-function 'rcirc-generate-new-buffer-name
1484 "A function to generate the filename used by rcirc's logging facility.
1485
1486It is called with two arguments, PROCESS and TARGET (see
1487`rcirc-generate-new-buffer-name' for their meaning), and should
1488return the filename, or nil if no logging is desired for this
1489session.
1490
1491If the returned filename is absolute (`file-name-absolute-p'
1492returns true), then it is used as-is, otherwise the resulting
1493file is put into `rcirc-log-directory'."
1494 :group 'rcirc
1495 :type 'function)
1496
1483(defun rcirc-log (process sender response target text) 1497(defun rcirc-log (process sender response target text)
1484 "Record line in `rcirc-log', to be later written to disk." 1498 "Record line in `rcirc-log', to be later written to disk."
1485 (let* ((filename (rcirc-generate-new-buffer-name process target)) 1499 (let ((filename (funcall rcirc-log-filename-function process target)))
1486 (cell (assoc-string filename rcirc-log-alist)) 1500 (unless (null filename)
1487 (line (concat (format-time-string rcirc-time-format) 1501 (let ((cell (assoc-string filename rcirc-log-alist))
1488 (substring-no-properties 1502 (line (concat (format-time-string rcirc-time-format)
1489 (rcirc-format-response-string process sender 1503 (substring-no-properties
1490 response target text)) 1504 (rcirc-format-response-string process sender
1491 "\n"))) 1505 response target text))
1492 (if cell 1506 "\n")))
1493 (setcdr cell (concat (cdr cell) line)) 1507 (if cell
1494 (setq rcirc-log-alist 1508 (setcdr cell (concat (cdr cell) line))
1495 (cons (cons filename line) rcirc-log-alist))))) 1509 (setq rcirc-log-alist
1510 (cons (cons filename line) rcirc-log-alist)))))))
1496 1511
1497(defun rcirc-log-write () 1512(defun rcirc-log-write ()
1498 "Flush `rcirc-log-alist' data to disk. 1513 "Flush `rcirc-log-alist' data to disk.
1499 1514
1500Log data is written to `rcirc-log-directory'." 1515Log data is written to `rcirc-log-directory', except for
1501 (make-directory rcirc-log-directory t) 1516log-files with absolute names (see `rcirc-log-filename-function')."
1502 (dolist (cell rcirc-log-alist) 1517 (dolist (cell rcirc-log-alist)
1503 (with-temp-buffer 1518 (let ((filename (expand-file-name (car cell) rcirc-log-directory))
1504 (insert (cdr cell)) 1519 (coding-system-for-write 'utf-8))
1505 (let ((coding-system-for-write 'utf-8)) 1520 (make-directory (file-name-directory filename) t)
1506 (write-region (point-min) (point-max) 1521 (with-temp-buffer
1507 (concat rcirc-log-directory "/" (car cell)) 1522 (insert (cdr cell))
1508 t 'quiet)))) 1523 (write-region (point-min) (point-max) filename t 'quiet))))
1509 (setq rcirc-log-alist nil)) 1524 (setq rcirc-log-alist nil))
1510 1525
1511(defun rcirc-join-channels (process channels) 1526(defun rcirc-join-channels (process channels)