Mercurial > emacs
annotate lisp/mh-e/mh-exec.el @ 68199:5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
to help remove dependency on mh-utils.
* mh-exec.el: New file. Move process support routines here from
mh-utils.el.
* mh-init.el (mh-utils): Remove require.
(mh-exec): Add require.
(mh-profile-component, mh-profile-component-value): Move here from
mh-utils.el.
* mh-utils.el (mh-pgp-support-flag): Move to mh-comp.el to reduce
dependencies on mh-utils.el.
(mh-profile-component, mh-profile-component-value): Move to mh-init.el
since that's the only place that uses them. (Other than mh-alias.el;
I'm thinking that mh-find-path can set variable from the Aliasfile
component like it does the other components).
(mh-index-max-cmdline-args, mh-xargs, mh-quote-for-shell)
(mh-exec-cmd, mh-exec-cmd-error, mh-exec-cmd-daemon)
(mh-exec-cmd-env-daemon, mh-process-daemon, mh-exec-cmd-quiet)
(defvar, mh-exec-cmd-output)
(mh-exchange-point-and-mark-preserving-active-mark)
(mh-exec-lib-cmd-output, mh-handle-process-error): Move to new file
mh-exec.el so that mh-init.el doesn't have to depend on mh-utils.el,
breaking circular dependency.
* mh-alias.el: mh-customize.el: mh-e.el: mh-funcs.el: mh-gnus.el:
* mh-identity.el: mh-inc.el: mh-junk.el: mh-mime.el: mh-print.el:
* mh-search.el: mh-seq.el: mh-speed.el: Added debugging statements
(commented out) around requires to help find dependency loops. Will
remove them when issues are resolved.
author | Bill Wohler <wohler@newt.com> |
---|---|
date | Sun, 15 Jan 2006 08:17:56 +0000 |
parents | |
children | 3e14f7a3572e |
rev | line source |
---|---|
68199
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1 ;;; mh-exec.el --- MH-E process support |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
2 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
3 ;; Copyright (C) 1993, 1995, 1997, |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
5 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
6 ;; Author: Bill Wohler <wohler@newt.com> |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
7 ;; Maintainer: Bill Wohler <wohler@newt.com> |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
8 ;; Keywords: mail |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
9 ;; See: mh-e.el |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
10 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
11 ;; This file is part of GNU Emacs. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
12 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
14 ;; it under the terms of the GNU General Public License as published by |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
15 ;; the Free Software Foundation; either version 2, or (at your option) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
16 ;; any later version. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
17 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
18 ;; GNU Emacs is distributed in the hope that it will be useful, |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
21 ;; GNU General Public License for more details. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
22 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
23 ;; You should have received a copy of the GNU General Public License |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
26 ;; Boston, MA 02110-1301, USA. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
27 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
28 ;;; Commentary: |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
29 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
30 ;; Issue shell and MH commands |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
31 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
32 ;;; Change Log: |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
33 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
34 ;;; Code: |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
35 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
36 ;;; |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
37 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
38 (defvar mh-index-max-cmdline-args 500 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
39 "Maximum number of command line args.") |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
40 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
41 (defun mh-xargs (cmd &rest args) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
42 "Partial imitation of xargs. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
43 The current buffer contains a list of strings, one on each line. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
44 The function will execute CMD with ARGS and pass the first |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
45 `mh-index-max-cmdline-args' strings to it. This is repeated till |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
46 all the strings have been used." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
47 (goto-char (point-min)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
48 (let ((current-buffer (current-buffer))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
49 (with-temp-buffer |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
50 (let ((out (current-buffer))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
51 (set-buffer current-buffer) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
52 (while (not (eobp)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
53 (let ((arg-list (reverse args)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
54 (count 0)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
55 (while (and (not (eobp)) (< count mh-index-max-cmdline-args)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
56 (push (buffer-substring-no-properties (point) (line-end-position)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
57 arg-list) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
58 (incf count) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
59 (forward-line)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
60 (apply #'call-process cmd nil (list out nil) nil |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
61 (nreverse arg-list)))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
62 (erase-buffer) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
63 (insert-buffer-substring out))))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
64 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
65 ;; XXX This should be applied anywhere MH-E calls out to /bin/sh. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
66 (defun mh-quote-for-shell (string) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
67 "Quote STRING for /bin/sh. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
68 Adds double-quotes around entire string and quotes the characters |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
69 \\, `, and $ with a backslash." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
70 (concat "\"" |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
71 (loop for x across string |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
72 concat (format (if (memq x '(?\\ ?` ?$)) "\\%c" "%c") x)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
73 "\"")) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
74 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
75 (defun mh-exec-cmd (command &rest args) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
76 "Execute mh-command COMMAND with ARGS. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
77 The side effects are what is desired. Any output is assumed to be |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
78 an error and is shown to the user. The output is not read or |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
79 parsed by MH-E." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
80 (save-excursion |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
81 (set-buffer (get-buffer-create mh-log-buffer)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
82 (let* ((initial-size (mh-truncate-log-buffer)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
83 (start (point)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
84 (args (mh-list-to-string args))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
85 (apply 'call-process (expand-file-name command mh-progs) nil t nil args) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
86 (when (> (buffer-size) initial-size) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
87 (save-excursion |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
88 (goto-char start) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
89 (insert "Errors when executing: " command) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
90 (loop for arg in args do (insert " " arg)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
91 (insert "\n")) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
92 (save-window-excursion |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
93 (switch-to-buffer-other-window mh-log-buffer) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
94 (sit-for 5)))))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
95 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
96 (defun mh-exec-cmd-error (env command &rest args) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
97 "In environment ENV, execute mh-command COMMAND with ARGS. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
98 ENV is nil or a string of space-separated \"var=value\" elements. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
99 Signals an error if process does not complete successfully." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
100 (save-excursion |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
101 (set-buffer (get-buffer-create mh-temp-buffer)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
102 (erase-buffer) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
103 (let ((process-environment process-environment)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
104 ;; XXX: We should purge the list that split-string returns of empty |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
105 ;; strings. This can happen in XEmacs if leading or trailing spaces |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
106 ;; are present. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
107 (dolist (elem (if (stringp env) (split-string env " ") ())) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
108 (push elem process-environment)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
109 (mh-handle-process-error |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
110 command (apply #'call-process (expand-file-name command mh-progs) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
111 nil t nil (mh-list-to-string args)))))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
112 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
113 (defun mh-exec-cmd-daemon (command filter &rest args) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
114 "Execute MH command COMMAND in the background. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
115 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
116 If FILTER is non-nil then it is used to process the output |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
117 otherwise the default filter `mh-process-daemon' is used. See |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
118 `set-process-filter' for more details of FILTER. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
119 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
120 ARGS are passed to COMMAND as command line arguments." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
121 (save-excursion |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
122 (set-buffer (get-buffer-create mh-log-buffer)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
123 (mh-truncate-log-buffer)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
124 (let* ((process-connection-type nil) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
125 (process (apply 'start-process |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
126 command nil |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
127 (expand-file-name command mh-progs) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
128 (mh-list-to-string args)))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
129 (set-process-filter process (or filter 'mh-process-daemon)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
130 process)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
131 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
132 (defun mh-exec-cmd-env-daemon (env command filter &rest args) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
133 "In ennvironment ENV, execute mh-command COMMAND in the background. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
134 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
135 ENV is nil or a string of space-separated \"var=value\" elements. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
136 Signals an error if process does not complete successfully. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
137 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
138 If FILTER is non-nil then it is used to process the output |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
139 otherwise the default filter `mh-process-daemon' is used. See |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
140 `set-process-filter' for more details of FILTER. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
141 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
142 ARGS are passed to COMMAND as command line arguments." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
143 (let ((process-environment process-environment)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
144 (dolist (elem (if (stringp env) (split-string env " ") ())) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
145 (push elem process-environment)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
146 (apply #'mh-exec-cmd-daemon command filter args))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
147 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
148 (defun mh-process-daemon (process output) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
149 "PROCESS daemon that puts OUTPUT into a temporary buffer. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
150 Any output from the process is displayed in an asynchronous |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
151 pop-up window." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
152 (with-current-buffer (get-buffer-create mh-log-buffer) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
153 (insert-before-markers output) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
154 (display-buffer mh-log-buffer))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
155 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
156 (defun mh-exec-cmd-quiet (raise-error command &rest args) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
157 "Signal RAISE-ERROR if COMMAND with ARGS fails. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
158 Execute MH command COMMAND with ARGS. ARGS is a list of strings. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
159 Return at start of mh-temp buffer, where output can be parsed and |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
160 used. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
161 Returns value of `call-process', which is 0 for success, unless |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
162 RAISE-ERROR is non-nil, in which case an error is signaled if |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
163 `call-process' returns non-0." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
164 (set-buffer (get-buffer-create mh-temp-buffer)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
165 (erase-buffer) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
166 (let ((value |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
167 (apply 'call-process |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
168 (expand-file-name command mh-progs) nil t nil |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
169 args))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
170 (goto-char (point-min)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
171 (if raise-error |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
172 (mh-handle-process-error command value) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
173 value))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
174 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
175 ;; Shush compiler. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
176 (eval-when-compile (defvar mark-active)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
177 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
178 (defun mh-exec-cmd-output (command display &rest args) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
179 "Execute MH command COMMAND with DISPLAY flag and ARGS. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
180 Put the output into buffer after point. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
181 Set mark after inserted text. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
182 Output is expected to be shown to user, not parsed by MH-E." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
183 (push-mark (point) t) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
184 (apply 'call-process |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
185 (expand-file-name command mh-progs) nil t display |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
186 (mh-list-to-string args)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
187 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
188 ;; The following is used instead of 'exchange-point-and-mark because the |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
189 ;; latter activates the current region (between point and mark), which |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
190 ;; turns on highlighting. So prior to this bug fix, doing "inc" would |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
191 ;; highlight a region containing the new messages, which is undesirable. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
192 ;; The bug wasn't seen in emacs21 but still occurred in XEmacs21.4. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
193 (mh-exchange-point-and-mark-preserving-active-mark)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
194 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
195 (defun mh-exchange-point-and-mark-preserving-active-mark () |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
196 "Put the mark where point is now, and point where the mark is now. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
197 This command works even when the mark is not active, and |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
198 preserves whether the mark is active or not." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
199 (interactive nil) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
200 (let ((is-active (and (boundp 'mark-active) mark-active))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
201 (let ((omark (mark t))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
202 (if (null omark) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
203 (error "No mark set in this buffer")) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
204 (set-mark (point)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
205 (goto-char omark) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
206 (if (boundp 'mark-active) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
207 (setq mark-active is-active)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
208 nil))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
209 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
210 (defun mh-exec-lib-cmd-output (command &rest args) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
211 "Execute MH library command COMMAND with ARGS. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
212 Put the output into buffer after point. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
213 Set mark after inserted text." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
214 (apply 'mh-exec-cmd-output (expand-file-name command mh-lib-progs) nil args)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
215 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
216 (defun mh-handle-process-error (command status) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
217 "Raise error if COMMAND returned non-zero STATUS, otherwise return STATUS." |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
218 (if (equal status 0) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
219 status |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
220 (goto-char (point-min)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
221 (insert (if (integerp status) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
222 (format "%s: exit code %d\n" command status) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
223 (format "%s: %s\n" command status))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
224 (save-excursion |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
225 (let ((error-message (buffer-substring (point-min) (point-max)))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
226 (set-buffer (get-buffer-create mh-log-buffer)) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
227 (mh-truncate-log-buffer) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
228 (insert error-message))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
229 (error "%s failed, check buffer %s for error message" |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
230 command mh-log-buffer))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
231 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
232 (provide 'mh-exec) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
233 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
234 ;; Local Variables: |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
235 ;; indent-tabs-mode: nil |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
236 ;; sentence-end-double-space: nil |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
237 ;; End: |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
238 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
239 ;;; mh-utils.el ends here |