annotate lisp/mail/mh-funcs.el @ 45289:bc4552b5622c

*** empty log message ***
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 14 May 2002 14:22:41 +0000
parents 67b464da13ec
children 2568d5a27317
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
1 ;;; mh-funcs.el --- mh-e functions not everyone will use right away
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
2 ;; Time-stamp: <2001-07-14 13:08:45 pavel>
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
4 ;; Copyright (C) 1993, 1995 Free Software Foundation, Inc.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
6 ;; This file is part of GNU Emacs.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
11333
53174cfc29fa Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11332
diff changeset
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; any later version.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
11333
53174cfc29fa Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11332
diff changeset
13 ;; GNU Emacs is distributed in the hope that it will be useful,
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU General Public License for more details.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
21 ;; Boston, MA 02111-1307, USA.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;;; Commentary:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
25 ;; Internal support for mh-e package.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
26 ;; Putting these functions in a separate file lets mh-e start up faster,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
27 ;; since less Lisp code needs to be loaded all at once.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
29 ;;; Change Log:
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
30
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
31 ;; $Id: mh-funcs.el,v 1.5 1996/01/14 07:34:30 erik Exp $
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
32
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;; Code:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 (provide 'mh-funcs)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (require 'mh-e)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
38 ;;; customization
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
39
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (defvar mh-sortm-args nil
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 "Extra arguments to have \\[mh-sort-folder] pass to the \"sortm\" command.
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
42 The arguments are passed to sortm if \\[mh-sort-folder] is given a
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
43 prefix argument. Normally default arguments to sortm are specified in the
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
44 MH profile.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 For example, '(\"-nolimit\" \"-textfield\" \"subject\") is a useful setting.")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
47 (defvar mh-note-copied "C"
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
48 "String whose first character is used to notate copied messages.")
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
49
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
50 (defvar mh-note-printed "P"
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
51 "String whose first character is used to notate printed messages.")
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
52
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
53 ;;; functions
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
54
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (defun mh-burst-digest ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 "Burst apart the current message, which should be a digest.
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
57 The message is replaced by its table of contents and the messages from the
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 digest are inserted into the folder after that message."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (interactive)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (let ((digest (mh-get-msg-num t)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (mh-process-or-undo-commands mh-current-folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (mh-set-folder-modified-p t) ; lock folder while bursting
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (message "Bursting digest...")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (mh-exec-cmd "burst" mh-current-folder digest "-inplace")
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
65 (with-mh-folder-updating (t)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
66 (beginning-of-line)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
67 (delete-region (point) (point-max)))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
68 (mh-regenerate-headers (format "%d-last" digest) t)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
69 (mh-goto-cur-msg)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (message "Bursting digest...done")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
73 (defun mh-copy-msg (msg-or-seq folder)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
74 "Copy the specified MESSAGE(s) to another FOLDER without deleting them.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 Default is the displayed message. If optional prefix argument is
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 provided, then prompt for the message sequence."
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
77 (interactive (list (if current-prefix-arg
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (mh-read-seq-default "Copy" t)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
79 (mh-get-msg-num t))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
80 (mh-prompt-for-folder "Copy to" "" t)))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
81 (mh-exec-cmd "refile" msg-or-seq "-link" "-src" mh-current-folder folder)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (if (numberp msg-or-seq)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
83 (mh-notate msg-or-seq mh-note-copied mh-cmd-note)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
84 (mh-notate-seq msg-or-seq mh-note-copied mh-cmd-note)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (defun mh-kill-folder ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 "Remove the current folder."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (interactive)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (if (or mh-do-not-confirm
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (yes-or-no-p (format "Remove folder %s? " mh-current-folder)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (let ((folder mh-current-folder))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (if (null mh-folder-list)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (mh-set-folder-list))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (mh-set-folder-modified-p t) ; lock folder to kill it
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (mh-exec-cmd-daemon "rmf" folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (setq mh-folder-list
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (delq (assoc folder mh-folder-list) mh-folder-list))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
98 (run-hooks 'mh-folder-list-change-hook)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (message "Folder %s removed" folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (mh-set-folder-modified-p nil) ; so kill-buffer doesn't complain
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (if (get-buffer mh-show-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (kill-buffer mh-show-buffer))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (kill-buffer folder))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (message "Folder not removed")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (defun mh-list-folders ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 "List mail folders."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (interactive)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
110 (with-output-to-temp-buffer mh-temp-buffer
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (save-excursion
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
112 (switch-to-buffer mh-temp-buffer)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (message "Listing folders...")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (mh-exec-cmd-output "folders" t (if mh-recursive-folders
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 "-recurse"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 "-norecurse"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (goto-char (point-min))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (message "Listing folders...done"))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (defun mh-pack-folder (range)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 "Renumber the messages of a folder to be 1..n.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 First, offer to execute any outstanding commands for the current folder.
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
125 If optional prefix argument provided, prompt for the RANGE of messages
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 to display after packing. Otherwise, show the entire folder."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (interactive (list (if current-prefix-arg
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (mh-read-msg-range
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 "Range to scan after packing [all]? ")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 "all")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (mh-pack-folder-1 range)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (mh-goto-cur-msg)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (message "Packing folder...done"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (defun mh-pack-folder-1 (range)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; Close and pack the current folder.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (mh-process-or-undo-commands mh-current-folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (message "Packing folder...")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (mh-set-folder-modified-p t) ; lock folder while packing
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (save-excursion
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
142 (mh-exec-cmd-quiet t "folder" mh-current-folder "-pack"
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
143 "-norecurse" "-fast"))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (mh-regenerate-headers range))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (defun mh-pipe-msg (command include-headers)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 "Pipe the current message through the given shell COMMAND.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 If INCLUDE-HEADERS (prefix argument) is provided, send the entire message.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 Otherwise just send the message's body without the headers."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (interactive
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (list (read-string "Shell command on message: ") current-prefix-arg))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
153 (let ((msg-file-to-pipe (mh-msg-filename (mh-get-msg-num t)))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
154 (message-directory default-directory))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (save-excursion
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
156 (set-buffer (get-buffer-create mh-temp-buffer))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (erase-buffer)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
158 (insert-file-contents msg-file-to-pipe)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (goto-char (point-min))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (if (not include-headers) (search-forward "\n\n"))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
161 (let ((default-directory message-directory))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
162 (shell-command-on-region (point) (point-max) command nil)))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (defun mh-page-digest ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 "Advance displayed message to next digested message."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (interactive)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (mh-in-show-buffer (mh-show-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ;; Go to top of screen (in case user moved point).
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (move-to-window-line 0)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (let ((case-fold-search nil))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 ;; Search for blank line and then for From:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (or (and (search-forward "\n\n" nil t)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
174 (re-search-forward "^From:" nil t))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (error "No more messages in digest")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 ;; Go back to previous blank line, then forward to the first non-blank.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (search-backward "\n\n" nil t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (forward-line 2)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (mh-recenter 0)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (defun mh-page-digest-backwards ()
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 "Back up displayed message to previous digested message."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (interactive)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (mh-in-show-buffer (mh-show-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ;; Go to top of screen (in case user moved point).
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (move-to-window-line 0)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (let ((case-fold-search nil))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (beginning-of-line)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (or (and (search-backward "\n\n" nil t)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
191 (re-search-backward "^From:" nil t))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (error "No previous message in digest")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ;; Go back to previous blank line, then forward to the first non-blank.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (if (search-backward "\n\n" nil t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (forward-line 2))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (mh-recenter 0)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (defun mh-print-msg (msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 "Print MESSAGE(s) (default: displayed message) on printer.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 If optional prefix argument provided, then prompt for the message sequence.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 The variable mh-lpr-command-format is used to generate the print command.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 The messages are formatted by mhl. See the variable mhl-formfile."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (interactive (list (if current-prefix-arg
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (reverse (mh-seq-to-msgs
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (mh-read-seq-default "Print" t)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (mh-get-msg-num t))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (if (numberp msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (message "Printing message...")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (message "Printing sequence..."))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (let ((print-command
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (if (numberp msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (format "%s -nobell -clear %s %s | %s"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (expand-file-name "mhl" mh-lib)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (mh-msg-filename msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (if (stringp mhl-formfile)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (format "-form %s" mhl-formfile)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 "")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (format mh-lpr-command-format
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (if (numberp msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (format "%s/%d" mh-current-folder
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (format "Sequence from %s" mh-current-folder))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (format "(scan -clear %s ; %s -nobell -clear %s %s) | %s"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (mapconcat (function (lambda (msg) msg)) msg-or-seq " ")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (expand-file-name "mhl" mh-lib)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (if (stringp mhl-formfile)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (format "-form %s" mhl-formfile)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 "")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (mh-msg-filenames msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (format mh-lpr-command-format
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (if (numberp msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (format "%s/%d" mh-current-folder
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (format "Sequence from %s"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 mh-current-folder)))))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (if mh-print-background
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (mh-exec-cmd-daemon shell-file-name "-c" print-command)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (call-process shell-file-name nil nil nil "-c" print-command))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (if (numberp msg-or-seq)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
241 (mh-notate msg-or-seq mh-note-printed mh-cmd-note)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
242 (mh-notate-seq msg-or-seq mh-note-printed mh-cmd-note))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (mh-add-msgs-to-seq msg-or-seq 'printed t)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (if (numberp msg-or-seq)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (message "Printing message...done")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (message "Printing sequence...done"))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (defun mh-msg-filenames (msgs &optional folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 ;; Return a list of file names for MSGS in FOLDER (default current folder).
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (mapconcat (function (lambda (msg) (mh-msg-filename msg folder))) msgs " "))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
254 (defun mh-sort-folder (&optional extra-args)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 "Sort the messages in the current folder by date.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 Calls the MH program sortm to do the work.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 The arguments in the list mh-sortm-args are passed to sortm
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
258 if this function is passed an argument."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (interactive "P")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (mh-process-or-undo-commands mh-current-folder)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (setq mh-next-direction 'forward)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (mh-set-folder-modified-p t) ; lock folder while sorting
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (message "Sorting folder...")
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
264 (mh-exec-cmd "sortm" mh-current-folder (if extra-args mh-sortm-args))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (message "Sorting folder...done")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (mh-scan-folder mh-current-folder "all"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (defun mh-undo-folder (&rest ignore)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
270 "Undo all pending deletes and refiles in current folder."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (interactive)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (cond ((or mh-do-not-confirm
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (yes-or-no-p "Undo all commands in folder? "))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (setq mh-delete-list nil
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 mh-refile-list nil
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 mh-seq-list nil
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 mh-next-direction 'forward)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (with-mh-folder-updating (nil)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (mh-unmark-all-headers t)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (t
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (message "Commands not undone.")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (sit-for 2))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
285 (defun mh-store-msg (directory)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 "Store the file(s) contained in the current message into DIRECTORY.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 The message can contain a shar file or uuencoded file.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 Default directory is the last directory used, or initially the value of
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 mh-store-default-directory or the current directory."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (interactive (list (let ((udir (or mh-store-default-directory default-directory)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (read-file-name "Store message in directory: "
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 udir udir nil))))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
293 (let ((msg-file-to-store (mh-msg-filename (mh-get-msg-num t))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (save-excursion
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
295 (set-buffer (get-buffer-create mh-temp-buffer))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (erase-buffer)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
297 (insert-file-contents msg-file-to-store)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
298 (mh-store-buffer directory))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
300 (defun mh-store-buffer (directory)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 "Store the file(s) contained in the current buffer into DIRECTORY.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 The buffer can contain a shar file or uuencoded file.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 Default directory is the last directory used, or initially the value of
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 `mh-store-default-directory' or the current directory."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (interactive (list (let ((udir (or mh-store-default-directory default-directory)))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
306 (read-file-name "Store buffer in directory: "
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
307 udir udir nil))))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
308 (let ((store-directory (expand-file-name directory))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
309 (sh-start (save-excursion
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
310 (goto-char (point-min))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
311 (if (re-search-forward
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
312 "^#![ \t]*/bin/sh\\|^#\\|^: " nil t)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
313 (progn
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
314 ;; The "cut here" pattern was removed from above
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
315 ;; because it seemed to hurt more than help.
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
316 ;; But keep this to make it easier to put it back.
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
317 (if (looking-at "^[^a-z0-9\"]*cut here\\b")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (forward-line 1))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
319 (beginning-of-line)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
320 (if (looking-at "^[#:]....+\n\\( ?\n\\)?end$")
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
321 nil ;most likely end of a uuencode
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
322 (point))))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (log-buffer (get-buffer-create "*Store Output*"))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
324 (command "sh")
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
325 (uudecode-filename "(unknown filename)"))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
326 (if (not sh-start)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
327 (save-excursion
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
328 (goto-char (point-min))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
329 (if (re-search-forward "^begin [0-7]+ " nil t)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
330 (setq uudecode-filename
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
331 (buffer-substring (point)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
332 (progn (end-of-line) (point)))))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (save-excursion
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (set-buffer log-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (if (not (file-directory-p store-directory))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (progn
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
338 (insert "mkdir " directory "\n")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (call-process "mkdir" nil log-buffer t store-directory)))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
340 (insert "cd " directory "\n")
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
341 (setq mh-store-default-directory directory)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
342 (if (not sh-start)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (progn
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (setq command "uudecode")
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
345 (insert uudecode-filename " being uudecoded...\n"))))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (set-window-start (display-buffer log-buffer) 0) ;watch progress
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
347 (let (value)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
348 (let ((default-directory (file-name-as-directory store-directory)))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
349 (setq value (call-process-region sh-start (point-max) command
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
350 nil log-buffer t)))
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
351 (set-buffer log-buffer)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
352 (mh-handle-process-error command value))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (insert "\n(mh-store finished)\n")))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 14169
diff changeset
355 ;;; mh-funcs.el ends here