Mercurial > emacs
annotate lisp/mh-e/mh-exec.el @ 68202:3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
standalone compile.
(mh-progs, mh-lib, mh-lib-progs): Move here from mh-init.el.
* mh-init.el (mh-progs, mh-lib, mh-lib-progs): Move to mh-exec.el,
where they are used.
author | Bill Wohler <wohler@newt.com> |
---|---|
date | Sun, 15 Jan 2006 18:27:26 +0000 |
parents | 5012e59a73c7 |
children | bd5caab540b5 |
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 |
68202
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
36 (eval-when-compile (require 'mh-acros)) |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
37 (mh-require-cl) |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
38 |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
39 (require 'mh-buffers) |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
40 (require 'mh-utils) |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
41 |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
42 (defvar mh-progs nil |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
43 "Directory containing MH commands, such as inc, repl, and rmm.") |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
44 |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
45 ;;;###autoload |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
46 (put 'mh-progs 'risky-local-variable t) |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
47 |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
48 (defvar mh-lib nil |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
49 "Directory containing the MH library. |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
50 This directory contains, among other things, the components file.") |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
51 |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
52 ;;;###autoload |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
53 (put 'mh-lib 'risky-local-variable t) |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
54 |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
55 (defvar mh-lib-progs nil |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
56 "Directory containing MH helper programs. |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
57 This directory contains, among other things, the mhl program.") |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
58 |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
59 ;;;###autoload |
3e14f7a3572e
* mh-exec.el: Require mh-acros, mh-buffers, and mh-utils for
Bill Wohler <wohler@newt.com>
parents:
68199
diff
changeset
|
60 (put 'mh-lib-progs 'risky-local-variable t) |
68199
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
61 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
62 (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
|
63 "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
|
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 (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
|
66 "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
|
67 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
|
68 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
|
69 `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
|
70 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
|
71 (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
|
72 (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
|
73 (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
|
74 (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
|
75 (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
|
76 (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
|
77 (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
|
78 (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
|
79 (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
|
80 (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
|
81 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
|
82 (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
|
83 (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
|
84 (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
|
85 (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
|
86 (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
|
87 (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
|
88 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
89 ;; 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
|
90 (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
|
91 "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
|
92 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
|
93 \\, `, 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
|
94 (concat "\"" |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
95 (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
|
96 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
|
97 "\"")) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
98 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
99 (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
|
100 "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
|
101 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
|
102 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
|
103 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
|
104 (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
|
105 (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
|
106 (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
|
107 (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
|
108 (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
|
109 (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
|
110 (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
|
111 (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
|
112 (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
|
113 (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
|
114 (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
|
115 (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
|
116 (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
|
117 (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
|
118 (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
|
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 (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
|
121 "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
|
122 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
|
123 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
|
124 (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
|
125 (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
|
126 (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
|
127 (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
|
128 ;; 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
|
129 ;; 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
|
130 ;; 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
|
131 (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
|
132 (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
|
133 (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
|
134 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
|
135 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
|
136 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
137 (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
|
138 "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
|
139 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
140 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
|
141 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
|
142 `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
|
143 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
144 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
|
145 (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
|
146 (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
|
147 (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
|
148 (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
|
149 (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
|
150 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
|
151 (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
|
152 (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
|
153 (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
|
154 process)) |
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-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
|
157 "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
|
158 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
159 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
|
160 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
|
161 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
162 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
|
163 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
|
164 `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
|
165 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
166 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
|
167 (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
|
168 (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
|
169 (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
|
170 (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
|
171 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
172 (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
|
173 "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
|
174 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
|
175 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
|
176 (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
|
177 (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
|
178 (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
|
179 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
180 (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
|
181 "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
|
182 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
|
183 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
|
184 used. |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
185 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
|
186 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
|
187 `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
|
188 (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
|
189 (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
|
190 (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
|
191 (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
|
192 (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
|
193 args))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
194 (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
|
195 (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
|
196 (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
|
197 value))) |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
198 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
199 ;; 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
|
200 (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
|
201 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
202 (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
|
203 "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
|
204 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
|
205 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
|
206 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
|
207 (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
|
208 (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
|
209 (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
|
210 (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
|
211 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
212 ;; 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
|
213 ;; 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
|
214 ;; 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
|
215 ;; 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
|
216 ;; 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
|
217 (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
|
218 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
219 (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
|
220 "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
|
221 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
|
222 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
|
223 (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
|
224 (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
|
225 (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
|
226 (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
|
227 (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
|
228 (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
|
229 (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
|
230 (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
|
231 (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
|
232 nil))) |
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 (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
|
235 "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
|
236 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
|
237 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
|
238 (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
|
239 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
240 (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
|
241 "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
|
242 (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
|
243 status |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
244 (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
|
245 (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
|
246 (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
|
247 (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
|
248 (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
|
249 (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
|
250 (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
|
251 (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
|
252 (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
|
253 (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
|
254 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
|
255 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
256 (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
|
257 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
258 ;; 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
|
259 ;; 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
|
260 ;; 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
|
261 ;; End: |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
262 |
5012e59a73c7
* mh-comp.el (mh-pgp-support-flag): Move here from mh-utils.el; needed
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
263 ;;; mh-utils.el ends here |