| 103 | | :type '(choice (const erc-generate-log-file-name-long) |
|---|
| 104 | | (const erc-generate-log-file-name-short) |
|---|
| 105 | | (const erc-generate-log-file-name-with-date) |
|---|
| 106 | | (symbol))) |
|---|
| | 105 | :type '(choice (const :tag "Long style" erc-generate-log-file-name-long) |
|---|
| | 106 | (const :tag "Long, but with network name rather than server" |
|---|
| | 107 | erc-generate-log-file-name-network) |
|---|
| | 108 | (const :tag "Short" erc-generate-log-file-name-short) |
|---|
| | 109 | (const :tag "With date" erc-generate-log-file-name-with-date) |
|---|
| | 110 | (symbol :tag "Other function"))) |
|---|
| 234 | | This function is destined to be run from `erc-connect-pre-hook'." |
|---|
| 235 | | (when (erc-logging-enabled) |
|---|
| 236 | | (auto-save-mode -1) |
|---|
| 237 | | (setq buffer-file-name nil) |
|---|
| 238 | | (set (make-local-variable 'write-file-functions) |
|---|
| 239 | | '(erc-save-buffer-in-logs)) |
|---|
| 240 | | (when erc-log-insert-log-on-open |
|---|
| 241 | | (ignore-errors (insert-file-contents (erc-current-logfile)) |
|---|
| 242 | | (move-marker erc-last-saved-position |
|---|
| 243 | | (1- (point-max))))))) |
|---|
| 244 | | |
|---|
| 245 | | (defun erc-log-disable-logging () |
|---|
| 246 | | "Disable logging in the current buffer." |
|---|
| 247 | | (when (erc-logging-enabled) |
|---|
| 248 | | (setq buffer-offer-save nil |
|---|
| 249 | | erc-enable-logging nil))) |
|---|
| | 236 | This function is destined to be run from `erc-connect-pre-hook'. |
|---|
| | 237 | The current buffer is given by BUFFER." |
|---|
| | 238 | (when (erc-logging-enabled buffer) |
|---|
| | 239 | (with-current-buffer buffer |
|---|
| | 240 | (auto-save-mode -1) |
|---|
| | 241 | (setq buffer-file-name nil) |
|---|
| | 242 | (cond ((boundp 'write-file-functions) |
|---|
| | 243 | (set (make-local-variable 'write-file-functions) |
|---|
| | 244 | '(erc-save-buffer-in-logs))) |
|---|
| | 245 | ((boundp 'local-write-file-hooks) |
|---|
| | 246 | (setq local-write-file-hooks '(erc-save-buffer-in-logs))) |
|---|
| | 247 | (t |
|---|
| | 248 | (set (make-local-variable 'write-file-hooks) |
|---|
| | 249 | '(erc-save-buffer-in-logs)))) |
|---|
| | 250 | (when erc-log-insert-log-on-open |
|---|
| | 251 | (ignore-errors (insert-file-contents (erc-current-logfile)) |
|---|
| | 252 | (move-marker erc-last-saved-position |
|---|
| | 253 | (1- (point-max)))))))) |
|---|
| | 254 | |
|---|
| | 255 | (defun erc-log-disable-logging (buffer) |
|---|
| | 256 | "Disable logging in BUFFER." |
|---|
| | 257 | (when (erc-logging-enabled buffer) |
|---|
| | 258 | (with-current-buffer buffer |
|---|
| | 259 | (setq buffer-offer-save nil |
|---|
| | 260 | erc-enable-logging nil)))) |
|---|
| | 351 | ;; we need a make-safe-file-name function. |
|---|
| | 352 | (convert-standard-filename file))) |
|---|
| | 353 | |
|---|
| | 354 | (defun erc-generate-log-file-name-network (buffer target nick server port) |
|---|
| | 355 | "Generates a log-file name using the network name rather than server name. |
|---|
| | 356 | This results in a file name of the form #channel!nick@network.txt. |
|---|
| | 357 | This function is a possible value for `erc-generate-log-file-name-function'." |
|---|
| | 358 | (require 'erc-networks) |
|---|
| | 359 | (let ((file (concat |
|---|
| | 360 | (if target (concat target "!")) |
|---|
| | 361 | nick "@" |
|---|
| | 362 | (or (with-current-buffer buffer (erc-network-name)) server) |
|---|
| | 363 | ".txt"))) |
|---|