Function: erc-save-buffer-in-logs
erc-save-buffer-in-logs is an autoloaded, interactive and
byte-compiled function defined in erc-log.el.gz.
Signature
(erc-save-buffer-in-logs &optional BUFFER)
Documentation
Append BUFFER contents to the log file, if logging is enabled.
If BUFFER is not provided, current buffer is used.
Logging is enabled if erc-logging-enabled returns non-nil.
This is normally done on exit, to save the unsaved portion of the buffer, since only the text that runs off the buffer limit is logged automatically.
You can save every individual message by putting this function on
erc-insert-post-hook.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-log.el.gz
;;;###autoload
(defun erc-save-buffer-in-logs (&optional buffer)
"Append BUFFER contents to the log file, if logging is enabled.
If BUFFER is not provided, current buffer is used.
Logging is enabled if `erc-logging-enabled' returns non-nil.
This is normally done on exit, to save the unsaved portion of the
buffer, since only the text that runs off the buffer limit is logged
automatically.
You can save every individual message by putting this function on
`erc-insert-post-hook'."
(interactive)
(unless (bufferp buffer) (setq buffer (current-buffer)))
(when (erc-logging-enabled buffer)
(let ((file (erc-current-logfile buffer))
(coding-system erc-log-file-coding-system))
(save-excursion
(with-current-buffer buffer
(save-restriction
(widen)
;; early on in the initialization, don't try and write the log out
(when (and (markerp erc-last-saved-position)
(null erc--insert-marker) ; suppress when splicing
(> erc-insert-marker (1+ erc-last-saved-position)))
(let ((start (1+ (marker-position erc-last-saved-position)))
(end (marker-position erc-insert-marker)))
(if (functionp erc-log-filter-function)
(let ((text (buffer-substring start end)))
(with-temp-buffer
(insert (funcall erc-log-filter-function text))
(let ((coding-system-for-write coding-system))
(write-region (point-min) (point-max)
file t 'nomessage))))
(let ((coding-system-for-write coding-system))
(write-region start end file t 'nomessage))))
(if (and erc-truncate-buffer-on-save
(called-interactively-p 'interactive))
(let ((erc-log--save-in-progress-p t))
(save-excursion (goto-char erc-insert-marker)
(erc-cmd-CLEAR))
(erc-button--display-error-notice-with-keys
(erc-server-buffer) "Option `%s' is deprecated."
" Use /CLEAR instead." 'erc-truncate-buffer-on-save))
(move-marker erc-last-saved-position
;; If we place erc-last-saved-position at
;; erc-insert-marker, because text gets
;; inserted /before/ erc-insert-marker,
;; the log file will not be saved
;; (erc-last-saved-position will always
;; be equal to erc-insert-marker).
(1- (marker-position erc-insert-marker)))))
(set-buffer-modified-p nil))))))
t)