1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

* mh-search.el: New file containing contents of mh-index.el and

mh-pick.el. C-c C-c launches your mh-index-program; C-c C-p runs pick.
Pick no longer sets the "search" sequence. Instead, it brings up a
folder view that we're accustomed to. (closes SF #829207).
(mh-index-search): Rename to mh-search.
(mh-pick-menu): Rename menu from Pick to Search. Rename Execute the
Search to Perform Search and call mh-do-search. Add Search with Pick
menu item.
(mh-do-search): Delete.
(mh-search-mode): Rename from mh-pick-mode.
(MH-Search): Rename mode from MH-Pick.
(mh-search-mode-map): Rename from mh-pick-mode-map.
(mh-search-mode-help-messages): Rename from
mh-pick-mode-help-messages.
(mh-index-choose): Don't reuse the last value of mh-indexer; when
mh-pick-do-search sets it to 'pick, we don't necessarily want to stay
with that choice!

* mh-index.el: mh-pick.el: Merge into mh-search.el and delete.

* mh-customize.el (mh-index-program): Change mh-index-search to
mh-search in docstring.
(mh-tool-bar-search-function): Change default from mh-search-folder to
mh-search. Remove mh-search-folder as choice and rename
mh-index-search choice to mh-search. Fix docstring.
(mh-pick-mode-hook): Rename to mh-search-mode-hook and change
mh-search-folder to mh-search in docstring.

* mh-e.el (mh-folder-folder-menu): Delete Search a Folder. Change
Indexed Search to Search. Use mh-search instead of mh-index-search.
(mh-folder-map): Delete i (mh-index-search) keybinding. Change s from
mh-show-search-folder to mh-search.

* mh-seq.el (mh-put-msg-in-seq): Fix docstring now that
mh-search-folder no longer creates the search sequence.

* mh-utils.el (mh-show-search-folder): Delete.
(mh-show-folder-map): Delete i (mh-index-search) keybinding. Change s
from mh-show-search-folder to mh-search.
(mh-show-folder-menu): Delete Search a Folder. Change Indexed Search
to Search. Use mh-search instead of mh-index-search.
(mh-index-max-cmdline-args, mh-xargs, mh-quote-for-shell): Move here
from deleted mh-index.el.
This commit is contained in:
Bill Wohler 2006-01-13 06:40:14 +00:00
parent 5f3996dc74
commit 4414069939
7 changed files with 1373 additions and 1485 deletions

View File

@ -1,3 +1,52 @@
2006-01-12 Bill Wohler <wohler@newt.com>
* mh-search.el: New file containing contents of mh-index.el and
mh-pick.el. C-c C-c launches your mh-index-program; C-c C-p runs
pick. Pick no longer sets the "search" sequence. Instead, it
brings up a folder view that we're accustomed to. (closes SF
#829207).
(mh-index-search): Rename to mh-search.
(mh-pick-menu): Rename menu from Pick to Search. Rename Execute
the Search to Perform Search and call mh-do-search. Add Search
with Pick menu item.
(mh-do-search): Delete.
(mh-search-mode): Rename from mh-pick-mode.
(MH-Search): Rename mode from MH-Pick.
(mh-search-mode-map): Rename from mh-pick-mode-map.
(mh-search-mode-help-messages): Rename from
mh-pick-mode-help-messages.
(mh-index-choose): Don't reuse the last value of mh-indexer; when
mh-pick-do-search sets it to 'pick, we don't necessarily want to
stay with that choice!
* mh-index.el:
* mh-pick.el: Merge into mh-search.el and delete.
* mh-customize.el (mh-index-program): Change mh-index-search to
mh-search in docstring.
(mh-tool-bar-search-function): Change default from
mh-search-folder to mh-search. Remove mh-search-folder as choice
and rename mh-index-search choice to mh-search. Fix docstring.
(mh-pick-mode-hook): Rename to mh-search-mode-hook and change
mh-search-folder to mh-search in docstring.
* mh-e.el (mh-folder-folder-menu): Delete Search a Folder. Change
Indexed Search to Search. Use mh-search instead of
mh-index-search.
(mh-folder-map): Delete i (mh-index-search) keybinding. Change s
from mh-show-search-folder to mh-search.
* mh-seq.el (mh-put-msg-in-seq): Fix docstring now that
mh-search-folder no longer creates the search sequence.
* mh-utils.el (mh-show-search-folder): Delete.
(mh-show-folder-map): Delete i (mh-index-search) keybinding.
Change s from mh-show-search-folder to mh-search.
(mh-show-folder-menu): Delete Search a Folder. Change Indexed
Search to Search. Use mh-search instead of mh-index-search.
(mh-index-max-cmdline-args, mh-xargs, mh-quote-for-shell): Move
here from deleted mh-index.el.
2006-01-11 Bill Wohler <wohler@newt.com>
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Move here

View File

@ -725,7 +725,7 @@ have both swish++ and mairix installed and you want to use
mairix, then you can set this option to \"mairix\".
More information about setting up an indexing program to use with
MH-E can be found in the documentation of `mh-index-search'."
MH-E can be found in the documentation of `mh-search'."
:type '(choice (const :tag "Auto-detect" nil)
(const :tag "swish++" swish++)
(const :tag "swish-e" swish)
@ -1879,14 +1879,13 @@ threaded is less than `mh-large-folder'."
;;; The Tool Bar (:group 'mh-tool-bar)
(defcustom mh-tool-bar-search-function 'mh-search-folder
(defcustom mh-tool-bar-search-function 'mh-search
"*Function called by the tool bar search button.
Available functions include `mh-search-folder', the default, and
`mh-index-search'. You can also choose \"Other Function\" from
the \"Value Menu\" and enter a function of your own choosing."
:type '(choice (const mh-search-folder)
(const mh-index-search)
By default, this is set to `mh-search'. You can also choose
\"Other Function\" from the \"Value Menu\" and enter a function
of your own choosing."
:type '(choice (const mh-search)
(function :tag "Other Function"))
:group 'mh-tool-bar)
@ -2436,13 +2435,13 @@ go."
:group 'mh-hooks
:group 'mh-letter)
(defcustom mh-pick-mode-hook nil
"Hook run upon entry to `mh-pick-mode'\\<mh-folder-mode-map>.
(defcustom mh-search-mode-hook nil
"Hook run upon entry to `mh-search-mode'\\<mh-folder-mode-map>.
If you find that you do the same thing over and over when editing
the search template, you may wish to bind some shortcuts to keys.
This can be done with this hook which is called when
\\[mh-search-folder] is run on a new pattern."
\\[mh-search] is run on a new pattern."
:type 'hook
:group 'mh-hooks
:group 'mh-index)

View File

@ -1735,8 +1735,7 @@ Make it the current folder."
["List Folders" mh-list-folders t]
["Visit a Folder..." mh-visit-folder t]
["View New Messages" mh-index-new-messages t]
["Search a Folder..." mh-search-folder t]
["Indexed Search..." mh-index-search t]
["Search..." mh-search t]
"--"
["Quit MH-E" mh-quit t]))
@ -1862,9 +1861,9 @@ perform the operation on all messages in that region.
'mh-folder-view-stack () ; Stack of previous views of the
; folder.
'mh-index-data nil ; If the folder was created by a call
; to mh-index-search this contains info
; to mh-search, this contains info
; about the search results.
'mh-index-previous-search nil ; Previous folder and search-regexp
'mh-index-previous-search nil ; folder, indexer, search-regexp
'mh-index-msg-checksum-map nil ; msg -> checksum map
'mh-index-checksum-origin-map nil ; checksum -> ( orig-folder, orig-msg )
'mh-index-sequence-search-flag nil ; folder resulted from sequence search
@ -2705,7 +2704,6 @@ in list."
"S" mh-sort-folder
"c" mh-catchup
"f" mh-alt-visit-folder
"i" mh-index-search
"k" mh-kill-folder
"l" mh-list-folders
"n" mh-index-new-messages
@ -2713,7 +2711,7 @@ in list."
"p" mh-pack-folder
"q" mh-index-sequenced-messages
"r" mh-rescan-folder
"s" mh-search-folder
"s" mh-search
"u" mh-undo-folder
"v" mh-visit-folder)

View File

@ -1,402 +0,0 @@
;;; mh-pick.el --- make a search pattern and search for a message in MH-E
;; Copyright (C) 1993, 1995,
;; 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
;; Author: Bill Wohler <wohler@newt.com>
;; Maintainer: Bill Wohler <wohler@newt.com>
;; Keywords: mail
;; See: mh-e.el
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Internal support for MH-E package.
;;; Change Log:
;;; Code:
(eval-when-compile (require 'mh-acros))
(mh-require-cl)
(require 'mh-e)
(require 'easymenu)
(require 'gnus-util)
;;; Internal variables:
(defvar mh-pick-mode-map (make-sparse-keymap)
"Keymap for searching folder.")
(defvar mh-searching-folder nil) ;Folder this pick is searching.
(defvar mh-searching-function nil)
(defconst mh-pick-single-dash '(cc date from subject to)
"Search components that are supported by single-dash option in pick.")
;;;###mh-autoload
(defun mh-search-folder (folder window-config)
"Search FOLDER for messages matching a pattern.
With this command, you can search a folder for messages to or
from a particular person or about a particular subject. In fact,
you can also search for messages containing selected strings in
any arbitrary header field or any string found within the
messages.
You are first prompted for the name of the folder to search and
then placed in the following buffer in MH-Pick mode:
From:
To:
Cc:
Date:
Subject:
--------
Edit this template by entering your search criteria in an
appropriate header field that is already there, or create a new
field yourself. If the string you're looking for could be
anywhere in a message, then place the string underneath the row
of dashes. The command \\[mh-search-folder] uses the MH command
\"pick\" to do the real work.
There are no semantics associated with the search criteria--they
are simply treated as strings. Case is ignored when all lowercase
is used, and regular expressions (a la \"ed\") are available. It
is all right to specify several search criteria. What happens
then is that a logical _and_ of the various fields is performed.
If you prefer a logical _or_ operation, run \\[mh-search-folder]
multiple times.
As an example, let's say that we want to find messages from
Ginnean about horseback riding in the Kosciusko National
Park (Australia) during January, 1994. Normally we would start
with a broad search and narrow it down if necessary to produce a
manageable amount of data, but we'll cut to the chase and create
a fairly restrictive set of criteria as follows:
From: ginnean
To:
Cc:
Date: Jan 1994
Subject: horse.*kosciusko
--------
As with MH-Letter mode, MH-Pick provides commands like
\\<mh-pick-mode-map>\\[mh-to-field] to help you fill in the
blanks.
To perform the search, type \\[mh-do-search]. The selected
messages are placed in the \"search\" sequence, which you can use
later in forwarding, printing, or narrowing your field of view.
Subsequent searches are appended to the \"search\" sequence. If,
however, you wish to start with a clean slate, first delete the
\"search\" sequence.
If you're searching in a folder that is already displayed in an
MH-Folder buffer, only those messages contained in the buffer are
used for the search. Therefore, if you want to search in all
messages, first kill the folder's buffer with
\\<mh-folder-mode-map>\\[kill-buffer] or scan the entire folder
with \\[mh-rescan-folder].
If you find that you do the same thing over and over when editing
the search template, you may wish to bind some shortcuts to keys.
This can be done with the variable `mh-pick-mode-hook', which is
called when \\[mh-search-folder] is run on a new pattern.
If you have run the \\[mh-index-search] command, but change your
mind while entering the search criteria and actually want to run
a regular search, then you can use the command
\\<mh-pick-mode-map>\\[mh-pick-do-search] in the MH-Pick buffer.
In a program, argument WINDOW-CONFIG is the current window
configuration and is used when the search folder is dismissed."
(interactive (list (mh-prompt-for-folder "Search" mh-current-folder nil nil t)
(current-window-configuration)))
(let ((pick-folder (if (equal folder "+") mh-current-folder folder)))
(switch-to-buffer-other-window "search-pattern")
(if (or (zerop (buffer-size))
(not (y-or-n-p "Reuse pattern? ")))
(mh-make-pick-template)
(message ""))
(setq mh-searching-function 'mh-pick-do-search
mh-searching-folder pick-folder)
(mh-make-local-vars 'mh-current-folder folder
'mh-previous-window-config window-config)
(message "%s" (substitute-command-keys
(concat "Type \\[mh-do-search] to search messages, "
"\\[mh-help] for help")))))
(defun mh-make-pick-template ()
"Initialize the current buffer with a template for a pick pattern."
(let ((inhibit-read-only t)) (erase-buffer))
(insert "From: \n"
"To: \n"
"Cc: \n"
"Date: \n"
"Subject: \n"
"---------\n")
(mh-pick-mode)
(goto-char (point-min))
(dotimes (i 5)
(add-text-properties (point) (1+ (point)) '(front-sticky t))
(add-text-properties (- (line-end-position) 2) (1- (line-end-position))
'(rear-nonsticky t))
(add-text-properties (point) (1- (line-end-position)) '(read-only t))
(forward-line))
(add-text-properties (point) (1+ (point)) '(front-sticky t))
(add-text-properties (point) (1- (line-end-position)) '(read-only t))
(goto-char (point-max)))
;;; Build mh-pick-mode menu
;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
(easy-menu-define
mh-pick-menu mh-pick-mode-map "Menu for MH-E pick-mode"
'("Pick"
["Execute the Search" mh-pick-do-search t]))
;;; Help Messages
;; Group messages logically, more or less.
(defvar mh-pick-mode-help-messages
'((nil
"Search messages using pick: \\[mh-pick-do-search]\n"
"Search messages using index: \\[mh-index-do-search]\n"
"Move to a field by typing C-c C-f C-<field>\n"
"where <field> is the first letter of the desired field."))
"Key binding cheat sheet.
This is an associative array which is used to show the most common
commands. The key is a prefix char. The value is one or more strings
which are concatenated together and displayed in the minibuffer if ?
is pressed after the prefix character. The special key nil is used to
display the non-prefixed commands.
The substitutions described in `substitute-command-keys' are performed
as well.")
(put 'mh-pick-mode 'mode-class 'special)
(define-derived-mode mh-pick-mode fundamental-mode "MH-Pick"
"Mode for creating search templates in MH-E.\\<mh-pick-mode-map>
After each field name, enter the pattern to search for. If a field's
value does not matter for the search, leave it empty. To search the
entire message, supply the pattern in the \"body\" of the template.
Each non-empty field must be matched for a message to be selected. To
effect a logical \"or\", use \\[mh-search-folder] multiple times. When
you have finished, type \\[mh-pick-do-search] to do the search.
The hook `mh-pick-mode-hook' is called upon entry to this mode.
\\{mh-pick-mode-map}"
(make-local-variable 'mh-searching-folder)
(make-local-variable 'mh-searching-function)
(make-local-variable 'mh-help-messages)
(easy-menu-add mh-pick-menu)
(setq mh-help-messages mh-pick-mode-help-messages))
;;;###mh-autoload
(defun mh-pick-do-search ()
"Find messages that match the qualifications in the current pattern buffer.
Messages are searched for in the folder named in
`mh-searching-folder'. Add the messages found to the sequence
named \"search\"."
(interactive)
(let ((pattern-list (mh-pick-parse-search-buffer))
(folder mh-searching-folder)
(new-buffer-flag nil)
(window-config mh-previous-window-config)
range pick-args msgs)
(unless pattern-list
(error "No search pattern specified"))
(save-excursion
(cond ((get-buffer folder)
(set-buffer folder)
(setq range (if (and mh-first-msg-num mh-last-msg-num)
(format "%d-%d" mh-first-msg-num mh-last-msg-num)
"all")))
(t
(mh-make-folder folder)
(setq range "all")
(setq new-buffer-flag t))))
(setq pick-args (mh-pick-regexp-builder pattern-list))
(when pick-args
(setq msgs (mh-seq-from-command folder 'search
`("pick" ,folder ,range ,@pick-args))))
(message "Searching...done")
(if (not new-buffer-flag)
(switch-to-buffer folder)
(mh-scan-folder folder msgs)
(setq mh-previous-window-config window-config))
(mh-add-msgs-to-seq msgs 'search)
(delete-other-windows)))
;;;###mh-autoload
(defun mh-do-search ()
"Use the default searching function.
If \\[mh-search-folder] was used to create the search pattern
then pick is used to search the folder. Otherwise if
\\[mh-index-search] was used then the indexing program specified
in `mh-index-program' is used."
(interactive)
(if (symbolp mh-searching-function)
(funcall mh-searching-function)
(error "No searching function defined")))
(defun mh-seq-from-command (folder seq command)
"In FOLDER, make a sequence named SEQ by executing COMMAND.
COMMAND is a list. The first element is a program name and the
subsequent elements are its arguments, all strings."
(let ((msg)
(msgs ())
(case-fold-search t))
(save-excursion
(save-window-excursion
(if (eq 0 (apply 'mh-exec-cmd-quiet nil command))
;; "pick" outputs one number per line
(while (setq msg (car (mh-read-msg-list)))
(setq msgs (cons msg msgs))
(forward-line 1))))
(set-buffer folder)
(setq msgs (nreverse msgs)) ;put in ascending order
msgs)))
(defun mh-pick-parse-search-buffer ()
"Parse the search buffer contents.
The function returns a alist. The car of each element is either
the header name to search in or nil to search the whole message.
The cdr of the element is the pattern to search."
(save-excursion
(let ((pattern-list ())
(in-body-flag nil)
start begin)
(goto-char (point-min))
(while (not (eobp))
(if (search-forward "--------" (line-end-position) t)
(setq in-body-flag t)
(beginning-of-line)
(setq begin (point))
(setq start (if in-body-flag
(point)
(search-forward ":" (line-end-position) t)
(point)))
(push (cons (and (not in-body-flag)
(intern (downcase
(buffer-substring-no-properties
begin (1- start)))))
(mh-index-parse-search-regexp
(buffer-substring-no-properties
start (line-end-position))))
pattern-list))
(forward-line))
pattern-list)))
;; Functions specific to how pick works...
(defun mh-pick-construct-regexp (expr component)
"Construct pick compatible expression corresponding to EXPR.
COMPONENT is the component to search."
(cond ((atom expr) (list component expr))
((eq (car expr) 'and)
`("-lbrace" ,@(mh-pick-construct-regexp (cadr expr) component) "-and"
,@(mh-pick-construct-regexp (caddr expr) component) "-rbrace"))
((eq (car expr) 'or)
`("-lbrace" ,@(mh-pick-construct-regexp (cadr expr) component) "-or"
,@(mh-pick-construct-regexp (caddr expr) component) "-rbrace"))
((eq (car expr) 'not)
`("-lbrace" "-not" ,@(mh-pick-construct-regexp (cadr expr) component)
"-rbrace"))
(t (error "Unknown operator %s seen" (car expr)))))
;; All implementations of pick have special options -cc, -date, -from and
;; -subject that allow to search for corresponding components. Any other
;; component is searched using option --COMPNAME, for example: `pick
;; --x-mailer mh-e'. Mailutils "pick" supports this option using a certain
;; kludge, but it prefers the following syntax for this purpose:
;; "--component=COMPNAME --pattern=PATTERN".
;; -- Sergey Poznyakoff, Aug 2003
(defun mh-pick-regexp-builder (pattern-list)
"Generate pick search expression from PATTERN-LIST."
(let ((result ()))
(dolist (pattern pattern-list)
(when (cdr pattern)
(setq result `(,@result "-and" "-lbrace"
,@(mh-pick-construct-regexp
(if (and (mh-variant-p 'mu-mh) (car pattern))
(format "--pattern=%s" (cdr pattern))
(cdr pattern))
(if (car pattern)
(cond
((mh-variant-p 'mu-mh)
(format "--component=%s" (car pattern)))
((member (car pattern) mh-pick-single-dash)
(format "-%s" (car pattern)))
(t
(format "--%s" (car pattern))))
"-search"))
"-rbrace"))))
(cdr result)))
;;; Build the pick-mode keymap:
;; If this changes, modify mh-pick-mode-help-messages accordingly, above.
(gnus-define-keys mh-pick-mode-map
"\C-c?" mh-help
"\C-c\C-i" mh-index-do-search
"\C-c\C-p" mh-pick-do-search
"\C-c\C-c" mh-do-search
"\C-c\C-f\C-b" mh-to-field
"\C-c\C-f\C-c" mh-to-field
"\C-c\C-f\C-d" mh-to-field
"\C-c\C-f\C-f" mh-to-field
"\C-c\C-f\C-r" mh-to-field
"\C-c\C-f\C-s" mh-to-field
"\C-c\C-f\C-t" mh-to-field
"\C-c\C-fb" mh-to-field
"\C-c\C-fc" mh-to-field
"\C-c\C-fd" mh-to-field
"\C-c\C-ff" mh-to-field
"\C-c\C-fr" mh-to-field
"\C-c\C-fs" mh-to-field
"\C-c\C-ft" mh-to-field)
(provide 'mh-pick)
;; Local Variables:
;; indent-tabs-mode: nil
;; sentence-end-double-space: nil
;; End:
;; arch-tag: aef2b271-7768-42bd-a782-9a14ba9f83f7
;;; mh-pick.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -291,11 +291,6 @@ When you want to widen the view to all your messages again, use
(defun mh-put-msg-in-seq (range sequence)
"Add RANGE to SEQUENCE\\<mh-folder-mode-map>.
To place a message in a sequence, use this command to do it
manually, or use the MH command \"pick\" or the MH-E version of
\"pick\", \\[mh-search-folder], which create a sequence
automatically.
Give this command a RANGE and you can add all the messages in a
sequence to another sequence (for example,
\"\\[universal-argument] \\[mh-put-msg-in-seq] SourceSequence RET

View File

@ -847,7 +847,6 @@ still visible.\n")
(mh-defun-show-buffer mh-show-pack-folder mh-pack-folder)
(mh-defun-show-buffer mh-show-kill-folder mh-kill-folder t)
(mh-defun-show-buffer mh-show-list-folders mh-list-folders t)
(mh-defun-show-buffer mh-show-search-folder mh-search-folder t)
(mh-defun-show-buffer mh-show-undo-folder mh-undo-folder)
(mh-defun-show-buffer mh-show-delete-msg-from-seq
mh-delete-msg-from-seq)
@ -952,14 +951,13 @@ still visible.\n")
"S" mh-show-sort-folder
"c" mh-show-catchup
"f" mh-show-visit-folder
"i" mh-index-search
"k" mh-show-kill-folder
"l" mh-show-list-folders
"n" mh-index-new-messages
"o" mh-show-visit-folder
"q" mh-show-index-sequenced-messages
"r" mh-show-rescan-folder
"s" mh-show-search-folder
"s" mh-search
"t" mh-show-toggle-threads
"u" mh-show-undo-folder
"v" mh-show-visit-folder)
@ -1098,8 +1096,7 @@ still visible.\n")
["List Folders" mh-show-list-folders t]
["Visit a Folder..." mh-show-visit-folder t]
["View New Messages" mh-show-index-new-messages t]
["Search a Folder..." mh-show-search-folder t]
["Indexed Search..." mh-index-search t]
["Search..." mh-search t]
"--"
["Quit MH-E" mh-quit t]))
@ -2393,7 +2390,44 @@ used in searching."
;;; Issue commands to MH.
;;; Issue shell and MH commands.
(defvar mh-index-max-cmdline-args 500
"Maximum number of command line args.")
(defun mh-xargs (cmd &rest args)
"Partial imitation of xargs.
The current buffer contains a list of strings, one on each line.
The function will execute CMD with ARGS and pass the first
`mh-index-max-cmdline-args' strings to it. This is repeated till
all the strings have been used."
(goto-char (point-min))
(let ((current-buffer (current-buffer)))
(with-temp-buffer
(let ((out (current-buffer)))
(set-buffer current-buffer)
(while (not (eobp))
(let ((arg-list (reverse args))
(count 0))
(while (and (not (eobp)) (< count mh-index-max-cmdline-args))
(push (buffer-substring-no-properties (point) (line-end-position))
arg-list)
(incf count)
(forward-line))
(apply #'call-process cmd nil (list out nil) nil
(nreverse arg-list))))
(erase-buffer)
(insert-buffer-substring out)))))
;; XXX This should be applied anywhere MH-E calls out to /bin/sh.
(defun mh-quote-for-shell (string)
"Quote STRING for /bin/sh.
Adds double-quotes around entire string and quotes the characters
\\, `, and $ with a backslash."
(concat "\""
(loop for x across string
concat (format (if (memq x '(?\\ ?` ?$)) "\\%c" "%c") x))
"\""))
(defun mh-exec-cmd (command &rest args)
"Execute mh-command COMMAND with ARGS.
@ -2498,21 +2532,6 @@ RAISE-ERROR is non-nil, in which case an error is signaled if
;; Shush compiler.
(eval-when-compile (defvar mark-active))
(defun mh-exchange-point-and-mark-preserving-active-mark ()
"Put the mark where point is now, and point where the mark is now.
This command works even when the mark is not active, and
preserves whether the mark is active or not."
(interactive nil)
(let ((is-active (and (boundp 'mark-active) mark-active)))
(let ((omark (mark t)))
(if (null omark)
(error "No mark set in this buffer"))
(set-mark (point))
(goto-char omark)
(if (boundp 'mark-active)
(setq mark-active is-active))
nil)))
(defun mh-exec-cmd-output (command display &rest args)
"Execute MH command COMMAND with DISPLAY flag and ARGS.
Put the output into buffer after point.
@ -2530,6 +2549,21 @@ Output is expected to be shown to user, not parsed by MH-E."
;; The bug wasn't seen in emacs21 but still occurred in XEmacs21.4.
(mh-exchange-point-and-mark-preserving-active-mark))
(defun mh-exchange-point-and-mark-preserving-active-mark ()
"Put the mark where point is now, and point where the mark is now.
This command works even when the mark is not active, and
preserves whether the mark is active or not."
(interactive nil)
(let ((is-active (and (boundp 'mark-active) mark-active)))
(let ((omark (mark t)))
(if (null omark)
(error "No mark set in this buffer"))
(set-mark (point))
(goto-char omark)
(if (boundp 'mark-active)
(setq mark-active is-active))
nil)))
(defun mh-exec-lib-cmd-output (command &rest args)
"Execute MH library command COMMAND with ARGS.
Put the output into buffer after point.
@ -2552,6 +2586,10 @@ Set mark after inserted text."
(error "%s failed, check buffer %s for error message"
command mh-log-buffer)))
;;; List and string manipulation
(defun mh-list-to-string (l)
"Flatten the list L and make every element of the new list into a string."
(nreverse (mh-list-to-string-1 l)))