;;; erc-log.el --- Logging facilities for ERC.
-;; Copyright (C) 2003-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2016 Free Software Foundation, Inc.
;; Author: Lawrence Mitchell <wence@gmx.li>
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: IRC, chat, client, Internet, logging
;; Created 2003-04-26
;;; Code:
(require 'erc)
-(eval-when-compile
- (require 'erc-networks)
- (require 'cl))
+(eval-when-compile (require 'erc-networks))
(defgroup erc-log nil
"Logging facilities for ERC."
:group 'erc)
(defcustom erc-generate-log-file-name-function 'erc-generate-log-file-name-long
- "*A function to generate a log filename.
+ "A function to generate a log filename.
The function must take five arguments: BUFFER, TARGET, NICK, SERVER and PORT.
BUFFER is the buffer to be saved,
TARGET is the name of the channel, or the target of the query,
custom function which returns the directory part and set
`erc-log-channels-directory' to its name."
:group 'erc-log
- :type '(choice (const :tag "Long style" erc-generate-log-file-name-long)
- (const :tag "Long, but with network name rather than server"
+ :type '(choice (const :tag "#channel!nick@server:port.txt"
+ erc-generate-log-file-name-long)
+ (const :tag "#channel!nick@network.txt"
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)
+ (const :tag "#channel.txt" erc-generate-log-file-name-short)
+ (const :tag "#channel@date.txt"
+ erc-generate-log-file-name-with-date)
(function :tag "Other function")))
(defcustom erc-truncate-buffer-on-save nil
(const :tag "Disable logging" nil)))
(defcustom erc-log-insert-log-on-open nil
- "*Insert log file contents into the buffer if a log file exists."
+ "Insert log file contents into the buffer if a log file exists."
:group 'erc-log
:type 'boolean)
(defcustom erc-save-buffer-on-part t
- "*Save the channel buffer content using `erc-save-buffer-in-logs' on PART.
+ "Save the channel buffer content using `erc-save-buffer-in-logs' on PART.
If you set this to nil, you may want to enable both
`erc-log-write-after-send' and `erc-log-write-after-insert'."
:type 'boolean)
(defcustom erc-save-queries-on-quit t
- "*Save all query (also channel) buffers of the server on QUIT.
+ "Save all query (also channel) buffers of the server on QUIT.
If you set this to nil, you may want to enable both
`erc-log-write-after-send' and `erc-log-write-after-insert'."
:type 'boolean)
(defcustom erc-log-write-after-send nil
- "*If non-nil, write to log file after every message you send.
+ "If non-nil, write to log file after every message you send.
If you set this to nil, you may want to enable both
`erc-save-buffer-on-part' and `erc-save-queries-on-quit'."
:type 'boolean)
(defcustom erc-log-write-after-insert nil
- "*If non-nil, write to log file when new text is added to a
+ "If non-nil, write to log file when new text is added to a
logged ERC buffer.
If you set this to nil, you may want to enable both
(defcustom erc-log-file-coding-system (if (featurep 'xemacs)
'binary
'emacs-mule)
- "*The coding system ERC should use for writing log files.
+ "The coding system ERC should use for writing log files.
This should ideally, be a \"catch-all\" coding system, like
`emacs-mule', or `iso-2022-7bit'."
+ :type 'coding-system
:group 'erc-log)
(defcustom erc-log-filter-function nil
- "*If non-nil, pass text through the given function before writing it to
+ "If non-nil, pass text through the given function before writing it to
a log file.
The function should take one argument, which is the text to filter."
(setq buffer-file-name nil)
(erc-set-write-file-functions '(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))))))))
+ (ignore-errors
+ (save-excursion
+ (goto-char (point-min))
+ (insert-file-contents (erc-current-logfile)))
+ (move-marker erc-last-saved-position
+ (1- (point-max))))))))
(defun erc-log-disable-logging (buffer)
"Disable logging in BUFFER."
;; we need a make-safe-file-name function.
(convert-standard-filename file)))
+(declare-function erc-network-name "erc-networks" ())
+
(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 #channel!nick@network.txt.
file t 'nomessage))))
(let ((coding-system-for-write coding-system))
(write-region start end file t 'nomessage))))
- (if (and erc-truncate-buffer-on-save (interactive-p))
+ (if (and erc-truncate-buffer-on-save
+ (called-interactively-p 'interactive))
(progn
(let ((inhibit-read-only t)) (erase-buffer))
(move-marker erc-last-saved-position (point-max))