Mercurial > emacs
annotate lisp/erc/erc-log.el @ 110410:f2e111723c3a
Merge changes made in Gnus trunk.
Reimplement nnimap, and do tweaks to the rest of the code to support that.
* gnus-int.el (gnus-finish-retrieve-group-infos)
(gnus-retrieve-group-data-early): New functions.
* gnus-range.el (gnus-range-nconcat): New function.
* gnus-start.el (gnus-get-unread-articles): Support early retrieval of
data.
(gnus-read-active-for-groups): Support finishing the early retrieval of
data.
* gnus-sum.el (gnus-summary-move-article): Pass the move-to group name
if the move is internal, so that nnimap can do fast internal moves.
* gnus.el (gnus-article-special-mark-lists): Add uid/active tuples, for
nnimap usage.
* nnimap.el: Rewritten.
* nnmail.el (nnmail-inhibit-default-split-group): New internal variable
to allow the mail splitting to not return a default group. This is
useful for nnimap, which will leave unmatched mail in the inbox.
* utf7.el (utf7-encode): Autoload.
Implement shell connection.
* nnimap.el (nnimap-open-shell-stream): New function.
(nnimap-open-connection): Use it.
Get the number of lines by using BODYSTRUCTURE.
(nnimap-transform-headers): Get the number of lines in each message.
(nnimap-retrieve-headers): Query for BODYSTRUCTURE so that we get the
number of lines.
Not all servers return UIDNEXT. Work past this problem.
Remove junk from end of file.
Fix typo in "bogus" section.
Make capabilties be case-insensitive.
Require cl when compiling.
Don't bug out if the LIST command doesn't have any parameters.
2010-09-17 Knut Anders Hatlen <kahatlen@gmail.com> (tiny change)
* nnimap.el (nnimap-get-groups): Don't bug out if the LIST command
doesn't have any parameters.
(mm-text-html-renderer): Document gnus-article-html.
2010-09-17 Julien Danjou <julien@danjou.info> (tiny fix)
* mm-decode.el (mm-text-html-renderer): Document gnus-article-html.
* dgnushack.el: Define netrc-credentials.
If the user doesn't have a /etc/services, supply some sensible port defaults.
Have `unseen-or-unread' select an unread unseen article first.
(nntp-open-server): Return whether the open was successful or not.
Throughout all files, replace (save-excursion (set-buffer ...)) with (with-current-buffer ... ).
Save result so that it doesn't say "failed" all the time.
Add ~/.authinfo to the default, since that's probably most useful for users.
Don't use the "finish" method when we're reading from the agent.
Add some more nnimap-relevant agent stuff to nnagent.el.
* nnimap.el (nnimap-with-process-buffer): Removed.
Revert one line that was changed by mistake in the last checkin.
(nnimap-open-connection): Don't error out when we can't make a connection
nnimap-related changes to avoid bugging out if we can't contact a server.
* gnus-start.el (gnus-get-unread-articles): Don't try to scan groups
from methods that are denied.
* nnimap.el (nnimap-possibly-change-group): Return nil if we can't log
in.
(nnimap-finish-retrieve-group-infos): Make sure we're not waiting for
nothing.
* gnus-sum.el (gnus-select-newsgroup): Indent.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Sat, 18 Sep 2010 10:02:19 +0000 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
rev | line source |
---|---|
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
1 ;;; erc-log.el --- Logging facilities for ERC. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
2 |
106815 | 3 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
4 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
5 ;; Author: Lawrence Mitchell <wence@gmx.li> |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
6 ;; Keywords: IRC, chat, client, Internet, logging |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
7 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
8 ;; Created 2003-04-26 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
9 ;; Logging code taken from erc.el and modified to use markers. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
10 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
11 ;; This file is part of GNU Emacs. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
12 |
94660
2a734255bcc7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
14 ;; it under the terms of the GNU General Public License as published by |
94660
2a734255bcc7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
2a734255bcc7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
16 ;; (at your option) any later version. |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
17 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
18 ;; GNU Emacs is distributed in the hope that it will be useful, |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
21 ;; GNU General Public License for more details. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
22 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
23 ;; You should have received a copy of the GNU General Public License |
94660
2a734255bcc7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
25 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
26 ;;; Commentary: |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
27 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
28 ;; This file implements log file writing support for ERC. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
29 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
30 ;; Quick start: |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
31 ;; |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
32 ;; (require 'erc-log) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
33 ;; (setq erc-log-channels-directory "/path/to/logfiles") ; must be writable |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
34 ;; (erc-log-enable) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
35 ;; |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
36 ;; Or: |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
37 ;; |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
38 ;; M-x customize-variable erc-modules, and add "log". |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
39 ;; |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
40 ;; There are two ways to setup logging. The first (default) method |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
41 ;; will save buffers on /part, /quit, or killing the channel |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
42 ;; buffer. |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
43 ;; |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
44 ;; The second will write to the log files on each incoming or outgoing |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
45 ;; line - this may not be optimal on a laptop HDD. To use this |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
46 ;; method, add the following to the above instructions. |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
47 ;; |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
48 ;; (setq erc-save-buffer-on-part nil |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
49 ;; erc-save-queries-on-quit nil |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
50 ;; erc-log-write-after-send t |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
51 ;; erc-log-write-after-insert t) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
52 ;; |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
53 ;; If you only want to save logs for some buffers, customise the |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
54 ;; variable `erc-enable-logging'. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
55 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
56 ;; How it works: |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
57 ;; |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
58 ;; If logging is enabled, at some point, `erc-save-buffer-in-logs' |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
59 ;; will be called. The "end" of the buffer is taken from |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
60 ;; `erc-insert-marker', while `erc-last-saved-position' holds the |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
61 ;; position the buffer was last saved at (as a marker, or if the |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
62 ;; buffer hasn't been saved before, as the number 1 (point-min)). |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
63 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
64 ;; The region between `erc-last-saved-position' and |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
65 ;; `erc-insert-marker' is saved to the current buffer's logfile, and |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
66 ;; `erc-last-saved-position' is updated to reflect this. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
67 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
68 ;;; History: |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
69 ;; 2003-04-26: logging code pulled out of erc.el. Switched to using |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
70 ;; markers. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
71 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
72 ;;; TODO: |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
73 ;; |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
74 ;; * Really, we need to lock the logfiles somehow, so that if a user |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
75 ;; is running multiple emacsen and/or on the same channel as more |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
76 ;; than one user, only one process writes to the logfile. This is |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
77 ;; especially needed for those logfiles with no nick in them, as |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
78 ;; these would become corrupted. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
79 ;; For a single emacs process, the problem could be solved using a |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
80 ;; variable which contained the names of buffers already being |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
81 ;; logged. This would require that logging be buffer-local, |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
82 ;; possibly not a bad thing anyway, since many people don't want to |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
83 ;; log the server buffer. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
84 ;; For multiple emacsen the problem is trickier. On some systems, |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
85 ;; on could use the function `lock-buffer' and `unlock-buffer'. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
86 ;; However, file locking isn't implemented on all platforms, for |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
87 ;; example, there is none on w32 systems. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
88 ;; A third possibility might be to fake lockfiles. However, this |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
89 ;; might lead to problems if an emacs crashes, as the lockfile |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
90 ;; would be left lying around. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
91 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
92 ;;; Code: |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
93 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
94 (require 'erc) |
76856 | 95 (eval-when-compile |
96 (require 'erc-networks) | |
97 (require 'cl)) | |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
98 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
99 (defgroup erc-log nil |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
100 "Logging facilities for ERC." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
101 :group 'erc) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
102 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
103 (defcustom erc-generate-log-file-name-function 'erc-generate-log-file-name-long |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
104 "*A function to generate a log filename. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
105 The function must take five arguments: BUFFER, TARGET, NICK, SERVER and PORT. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
106 BUFFER is the buffer to be saved, |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
107 TARGET is the name of the channel, or the target of the query, |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
108 NICK is the current nick, |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
109 SERVER and PORT are the parameters that were used to connect to BUFFERs |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
110 `erc-server-process'. |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
111 |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
112 If you want to write logs into different directories, make a |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
113 custom function which returns the directory part and set |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
114 `erc-log-channels-directory' to its name." |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
115 :group 'erc-log |
76856 | 116 :type '(choice (const :tag "Long style" erc-generate-log-file-name-long) |
117 (const :tag "Long, but with network name rather than server" | |
118 erc-generate-log-file-name-network) | |
119 (const :tag "Short" erc-generate-log-file-name-short) | |
120 (const :tag "With date" erc-generate-log-file-name-with-date) | |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
121 (function :tag "Other function"))) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
122 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
123 (defcustom erc-truncate-buffer-on-save nil |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
124 "Truncate any ERC (channel, query, server) buffer when it is saved." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
125 :group 'erc-log |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
126 :type 'boolean) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
127 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
128 (defcustom erc-enable-logging t |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
129 "If non-nil, ERC will log IRC conversations. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
130 This can either be a boolean value of nil or t, or a function. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
131 If the value is a function, it will be called with one argument, the |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
132 name of the current ERC buffer. One possible function, which saves |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
133 all but server buffers is `erc-log-all-but-server-buffers'. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
134 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
135 This variable is buffer local. Setting it via \\[customize] sets the |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
136 default value. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
137 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
138 Log files are stored in `erc-log-channels-directory'." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
139 :group 'erc-log |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
140 :type '(choice boolean |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
141 function)) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
142 (make-variable-buffer-local 'erc-enable-logging) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
143 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
144 (defcustom erc-log-channels-directory "~/log" |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
145 "The directory to place log files for channels. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
146 Leave blank to disable logging. If not nil, all the channel |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
147 buffers are logged in separate files in that directory. The |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
148 directory should not end with a trailing slash. |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
149 |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
150 If this is the name of a function, the function will be called |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
151 with the buffer, target, nick, server, and port arguments. See |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
152 `erc-generate-log-file-name-function' for a description of these |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
153 arguments." |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
154 :group 'erc-log |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
155 :type '(choice directory |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
156 (function "Function") |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
157 (const :tag "Disable logging" nil))) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
158 |
71883 | 159 (defcustom erc-log-insert-log-on-open nil |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
160 "*Insert log file contents into the buffer if a log file exists." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
161 :group 'erc-log |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
162 :type 'boolean) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
163 |
71883 | 164 (defcustom erc-save-buffer-on-part t |
165 "*Save the channel buffer content using `erc-save-buffer-in-logs' on PART. | |
166 | |
167 If you set this to nil, you may want to enable both | |
168 `erc-log-write-after-send' and `erc-log-write-after-insert'." | |
169 :group 'erc-log | |
170 :type 'boolean) | |
171 | |
172 (defcustom erc-save-queries-on-quit t | |
173 "*Save all query (also channel) buffers of the server on QUIT. | |
174 | |
175 If you set this to nil, you may want to enable both | |
176 `erc-log-write-after-send' and `erc-log-write-after-insert'." | |
177 :group 'erc-log | |
178 :type 'boolean) | |
179 | |
180 (defcustom erc-log-write-after-send nil | |
181 "*If non-nil, write to log file after every message you send. | |
182 | |
183 If you set this to nil, you may want to enable both | |
184 `erc-save-buffer-on-part' and `erc-save-queries-on-quit'." | |
185 :group 'erc-log | |
186 :type 'boolean) | |
187 | |
188 (defcustom erc-log-write-after-insert nil | |
189 "*If non-nil, write to log file when new text is added to a | |
190 logged ERC buffer. | |
191 | |
192 If you set this to nil, you may want to enable both | |
193 `erc-save-buffer-on-part' and `erc-save-queries-on-quit'." | |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
194 :group 'erc-log |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
195 :type 'boolean) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
196 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
197 (defcustom erc-log-file-coding-system (if (featurep 'xemacs) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
198 'binary |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
199 'emacs-mule) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
200 "*The coding system ERC should use for writing log files. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
201 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
202 This should ideally, be a \"catch-all\" coding system, like |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
203 `emacs-mule', or `iso-2022-7bit'." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
204 :group 'erc-log) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
205 |
84636
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
206 (defcustom erc-log-filter-function nil |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
207 "*If non-nil, pass text through the given function before writing it to |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
208 a log file. |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
209 |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
210 The function should take one argument, which is the text to filter." |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
211 :group 'erc-log |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
212 :type '(choice (function "Function") |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
213 (const :tag "No filtering" nil))) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
214 |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
215 |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
216 ;;;###autoload (autoload 'erc-log-mode "erc-log" nil t) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
217 (define-erc-module log nil |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
218 "Automatically logs things you receive on IRC into files. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
219 Files are stored in `erc-log-channels-directory'; file name |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
220 format is defined through a formatting function on |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
221 `erc-generate-log-file-name-function'. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
222 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
223 Since automatic logging is not always a Good Thing (especially if |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
224 people say things in different coding systems), you can turn logging |
79413
857da0a07a42
(log): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
78476
diff
changeset
|
225 behavior on and off with the variable `erc-enable-logging', which can |
86109
c785443b57f8
(log): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
85845
diff
changeset
|
226 also be a predicate function. To only log when you are not set away, use: |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
227 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
228 \(setq erc-enable-logging |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
229 (lambda (buffer) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
230 (with-current-buffer buffer |
76856 | 231 (null (erc-away-time)))))" |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
232 ;; enable |
71883 | 233 ((when erc-log-write-after-insert |
234 (add-hook 'erc-insert-post-hook 'erc-save-buffer-in-logs)) | |
235 (when erc-log-write-after-send | |
236 (add-hook 'erc-send-post-hook 'erc-save-buffer-in-logs)) | |
237 (add-hook 'erc-kill-buffer-hook 'erc-save-buffer-in-logs) | |
238 (add-hook 'erc-kill-channel-hook 'erc-save-buffer-in-logs) | |
74093 | 239 (add-hook 'kill-emacs-hook 'erc-log-save-all-buffers) |
71883 | 240 (add-hook 'erc-quit-hook 'erc-conditional-save-queries) |
241 (add-hook 'erc-part-hook 'erc-conditional-save-buffer) | |
242 ;; append, so that 'erc-initialize-log-marker runs first | |
72249 | 243 (add-hook 'erc-connect-pre-hook 'erc-log-setup-logging 'append) |
244 (dolist (buffer (erc-buffer-list)) | |
76856 | 245 (erc-log-setup-logging buffer))) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
246 ;; disable |
71883 | 247 ((remove-hook 'erc-insert-post-hook 'erc-save-buffer-in-logs) |
248 (remove-hook 'erc-send-post-hook 'erc-save-buffer-in-logs) | |
249 (remove-hook 'erc-kill-buffer-hook 'erc-save-buffer-in-logs) | |
250 (remove-hook 'erc-kill-channel-hook 'erc-save-buffer-in-logs) | |
74093 | 251 (remove-hook 'kill-emacs-hook 'erc-log-save-all-buffers) |
71883 | 252 (remove-hook 'erc-quit-hook 'erc-conditional-save-queries) |
253 (remove-hook 'erc-part-hook 'erc-conditional-save-buffer) | |
72249 | 254 (remove-hook 'erc-connect-pre-hook 'erc-log-setup-logging) |
255 (dolist (buffer (erc-buffer-list)) | |
76856 | 256 (erc-log-disable-logging buffer)))) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
257 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
258 (define-key erc-mode-map "\C-c\C-l" 'erc-save-buffer-in-logs) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
259 |
71883 | 260 ;;; functionality referenced from erc.el |
76856 | 261 (defun erc-log-setup-logging (buffer) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
262 "Setup the buffer-local logging variables in the current buffer. |
76856 | 263 This function is destined to be run from `erc-connect-pre-hook'. |
264 The current buffer is given by BUFFER." | |
265 (when (erc-logging-enabled buffer) | |
266 (with-current-buffer buffer | |
267 (auto-save-mode -1) | |
268 (setq buffer-file-name nil) | |
85845
e95712050fdc
Silence some byte-compiler warnings in ERC
Michael Olson <mwolson@gnu.org>
parents:
85743
diff
changeset
|
269 (erc-set-write-file-functions '(erc-save-buffer-in-logs)) |
76856 | 270 (when erc-log-insert-log-on-open |
271 (ignore-errors (insert-file-contents (erc-current-logfile)) | |
272 (move-marker erc-last-saved-position | |
273 (1- (point-max)))))))) | |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
274 |
76856 | 275 (defun erc-log-disable-logging (buffer) |
276 "Disable logging in BUFFER." | |
277 (when (erc-logging-enabled buffer) | |
278 (with-current-buffer buffer | |
279 (setq buffer-offer-save nil | |
280 erc-enable-logging nil)))) | |
72249 | 281 |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
282 (defun erc-log-all-but-server-buffers (buffer) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
283 "Returns t if logging should be enabled in BUFFER. |
78476
4f90f1cb8ef0
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78219
diff
changeset
|
284 Returns nil if `erc-server-buffer-p' returns t." |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
285 (save-excursion |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
286 (save-window-excursion |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
287 (set-buffer buffer) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
288 (not (erc-server-buffer-p))))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
289 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
290 (defun erc-save-query-buffers (process) |
74093 | 291 "Save all buffers of the given PROCESS." |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
292 (erc-with-all-buffers-of-server process |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
293 nil |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
294 (erc-save-buffer-in-logs))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
295 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
296 (defun erc-conditional-save-buffer (buffer) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
297 "Save Query BUFFER if `erc-save-queries-on-quit' is t." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
298 (when erc-save-buffer-on-part |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
299 (erc-save-buffer-in-logs buffer))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
300 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
301 (defun erc-conditional-save-queries (process) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
302 "Save Query buffers of PROCESS if `erc-save-queries-on-quit' is t." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
303 (when erc-save-queries-on-quit |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
304 (erc-save-query-buffers process))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
305 |
74093 | 306 ;; Make sure that logs get saved, even if someone overrides the active |
307 ;; process prompt for a quick exit from Emacs | |
308 (defun erc-log-save-all-buffers () | |
309 (dolist (buffer (erc-buffer-list)) | |
310 (erc-save-buffer-in-logs buffer))) | |
311 | |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
312 ;;;###autoload |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
313 (defun erc-logging-enabled (&optional buffer) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
314 "Return non-nil if logging is enabled for BUFFER. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
315 If BUFFER is nil, the value of `current-buffer' is used. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
316 Logging is enabled if `erc-log-channels-directory' is non-nil, the directory |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
317 is writeable (it will be created as necessary) and |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
318 `erc-enable-logging' returns a non-nil value." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
319 (and erc-log-channels-directory |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
320 (or (functionp erc-log-channels-directory) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
321 (erc-directory-writable-p erc-log-channels-directory)) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
322 (if (functionp erc-enable-logging) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
323 (funcall erc-enable-logging (or buffer (current-buffer))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
324 erc-enable-logging))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
325 |
72301 | 326 (defun erc-log-standardize-name (filename) |
327 "Make FILENAME safe to use as the name of an ERC log. | |
328 This will not work with full paths, only names. | |
329 | |
330 Any unsafe characters in the name are replaced with \"!\". The | |
331 filename is downcased." | |
332 (downcase (erc-replace-regexp-in-string | |
333 "[/\\]" "!" (convert-standard-filename filename)))) | |
334 | |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
335 (defun erc-current-logfile (&optional buffer) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
336 "Return the logfile to use for BUFFER. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
337 If BUFFER is nil, the value of `current-buffer' is used. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
338 This is determined by `erc-generate-log-file-name-function'. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
339 The result is converted to lowercase, as IRC is case-insensitive" |
84387
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
340 (unless buffer (setq buffer (current-buffer))) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
341 (let ((target (or (buffer-name buffer) (erc-default-target))) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
342 (nick (erc-current-nick)) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
343 (server erc-session-server) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
344 (port erc-session-port)) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
345 (expand-file-name |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
346 (erc-log-standardize-name |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
347 (funcall erc-generate-log-file-name-function |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
348 buffer target nick server port)) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
349 (if (functionp erc-log-channels-directory) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
350 (funcall erc-log-channels-directory |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
351 buffer target nick server port) |
4ee03308c9b6
Sync ERC 5.3 (devel) from upstream
Michael Olson <mwolson@gnu.org>
parents:
78476
diff
changeset
|
352 erc-log-channels-directory)))) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
353 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
354 (defun erc-generate-log-file-name-with-date (buffer &rest ignore) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
355 "This function computes a short log file name. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
356 The name of the log file is composed of BUFFER and the current date. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
357 This function is a possible value for `erc-generate-log-file-name-function'." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
358 (concat (buffer-name buffer) "-" (format-time-string "%Y-%m-%d") ".txt")) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
359 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
360 (defun erc-generate-log-file-name-short (buffer &rest ignore) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
361 "This function computes a short log file name. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
362 In fact, it only uses the buffer name of the BUFFER argument, so |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
363 you can affect that using `rename-buffer' and the-like. This |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
364 function is a possible value for |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
365 `erc-generate-log-file-name-function'." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
366 (concat (buffer-name buffer) ".txt")) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
367 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
368 (defun erc-generate-log-file-name-long (buffer target nick server port) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
369 "Generates a log-file name in the way ERC always did it. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
370 This results in a file name of the form #channel!nick@server:port.txt. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
371 This function is a possible value for `erc-generate-log-file-name-function'." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
372 (let ((file (concat |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
373 (if target (concat target "!")) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
374 nick "@" server ":" (cond ((stringp port) port) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
375 ((numberp port) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
376 (number-to-string port))) ".txt"))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
377 ;; we need a make-safe-file-name function. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
378 (convert-standard-filename file))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
379 |
76856 | 380 (defun erc-generate-log-file-name-network (buffer target nick server port) |
381 "Generates a log-file name using the network name rather than server name. | |
382 This results in a file name of the form #channel!nick@network.txt. | |
383 This function is a possible value for `erc-generate-log-file-name-function'." | |
384 (require 'erc-networks) | |
385 (let ((file (concat | |
386 (if target (concat target "!")) | |
387 nick "@" | |
388 (or (with-current-buffer buffer (erc-network-name)) server) | |
389 ".txt"))) | |
390 ;; we need a make-safe-file-name function. | |
391 (convert-standard-filename file))) | |
392 | |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
393 ;;;###autoload |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
394 (defun erc-save-buffer-in-logs (&optional buffer) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
395 "Append BUFFER contents to the log file, if logging is enabled. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
396 If BUFFER is not provided, current buffer is used. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
397 Logging is enabled if `erc-logging-enabled' returns non-nil. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
398 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
399 This is normally done on exit, to save the unsaved portion of the |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
400 buffer, since only the text that runs off the buffer limit is logged |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
401 automatically. |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
402 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
403 You can save every individual message by putting this function on |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
404 `erc-insert-post-hook'." |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
405 (interactive) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
406 (or buffer (setq buffer (current-buffer))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
407 (when (erc-logging-enabled buffer) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
408 (let ((file (erc-current-logfile buffer)) |
85743 | 409 (coding-system erc-log-file-coding-system) |
410 (inhibit-clash-detection t)) ; needed for XEmacs | |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
411 (save-excursion |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
412 (with-current-buffer buffer |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
413 (save-restriction |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
414 (widen) |
79413
857da0a07a42
(log): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
78476
diff
changeset
|
415 ;; early on in the initialization, don't try and write the log out |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
416 (when (and (markerp erc-last-saved-position) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
417 (> erc-insert-marker (1+ erc-last-saved-position))) |
84636
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
418 (let ((start (1+ (marker-position erc-last-saved-position))) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
419 (end (marker-position erc-insert-marker))) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
420 (if (functionp erc-log-filter-function) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
421 (let ((text (buffer-substring start end))) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
422 (with-temp-buffer |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
423 (insert (funcall erc-log-filter-function text)) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
424 (let ((coding-system-for-write coding-system)) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
425 (write-region (point-min) (point-max) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
426 file t 'nomessage)))) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
427 (let ((coding-system-for-write coding-system)) |
ffc87ddd4025
Sync changes from upstream ERC
Michael Olson <mwolson@gnu.org>
parents:
84387
diff
changeset
|
428 (write-region start end file t 'nomessage)))) |
68451
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
429 (if (and erc-truncate-buffer-on-save (interactive-p)) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
430 (progn |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
431 (let ((inhibit-read-only t)) (erase-buffer)) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
432 (move-marker erc-last-saved-position (point-max)) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
433 (erc-display-prompt)) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
434 (move-marker erc-last-saved-position |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
435 ;; If we place erc-last-saved-position at |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
436 ;; erc-insert-marker, because text gets |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
437 ;; inserted /before/ erc-insert-marker, |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
438 ;; the log file will not be saved |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
439 ;; (erc-last-saved-position will always |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
440 ;; be equal to erc-insert-marker). |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
441 (1- (marker-position erc-insert-marker))))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
442 (set-buffer-modified-p nil)))))) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
443 t) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
444 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
445 (provide 'erc-log) |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
446 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
447 ;;; erc-log.el ends here |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
448 ;; |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
449 ;; Local Variables: |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
450 ;; indent-tabs-mode: t |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
451 ;; tab-width: 8 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
452 ;; End: |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
453 |
fc745b05e928
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
454 ;; arch-tag: 54072f99-9f0a-4846-8908-2ccde92221de |