annotate lisp/mh-e/mh-acros.el @ 99540:c5c8f07bc47c

* w32-fns.el (w32-shell-dos-semantics): * calendar/diary-lib.el (diary-face-attrs): * international/mule-cmds.el (set-default-coding-systems) (prefer-coding-system): * net/tramp.el (tramp-set-completion-function): * progmodes/vhdl-mode.el (vhdl-file-header): * term/pc-win.el (msdos-show-help): Fix typos in docstrings. * emacs-lisp/authors.el (authors-fixed-entries): Fix typo in value. * files.el (enable-local-eval, not-modified, kill-buffer-ask) (kill-matching-buffers, save-buffers-kill-emacs) (save-buffers-kill-terminal): Fix typos in docstrings. (switch-to-buffer-other-window): Reflow docstring. (revert-buffer): Doc fix. (define-project-bindings): Rename arg LIST to SETTINGS. (project-find-settings-file): Use `let', not `let*'. Use `when'.
author Juanma Barranquero <lekktu@gmail.com>
date Fri, 14 Nov 2008 13:05:18 +0000
parents 33aa6dc538c6
children a9dc0e7c3f2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
1 ;;; mh-acros.el --- macros used in MH-E
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
2
79713
3c2488d0ebd9 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78231
diff changeset
3 ;; Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
4
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
5 ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
6 ;; Maintainer: Bill Wohler <wohler@newt.com>
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
7 ;; Keywords: mail
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
8 ;; See: mh-e.el
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
9
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
11
94663
90c9ebd43589 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 80067
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
94663
90c9ebd43589 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 80067
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
90c9ebd43589 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 80067
diff changeset
15 ;; (at your option) any later version.
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
16
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
21
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94663
90c9ebd43589 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 80067
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
24
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
25 ;;; Commentary:
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
26
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
27 ;; This file contains all macros that are used in more than one file.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
28 ;; If you run "make recompile" in CVS Emacs and see the message
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
29 ;; "Source is newer than compiled," it is a sign that macro probably
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
30 ;; needs to be moved here.
68213
a08b47775f9b * mh-acros.el (require): Remove defadvice of require as defadvice is
Bill Wohler <wohler@newt.com>
parents: 68189
diff changeset
31
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
32 ;; Historically, it was so named with a silent "m" so that it would be
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
33 ;; compiled first. Otherwise, "make recompile" in CVS Emacs would use
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
34 ;; compiled files with stale macro definitions. Later, no-byte-compile
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
35 ;; was added to the Local Variables section to avoid this problem and
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
36 ;; because it's pointless to compile a file full of macros. But we
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
37 ;; kept the name.
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
38
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
39 ;;; Change Log:
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
40
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
41 ;;; Code:
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
42
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
43 (require 'cl)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
44
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
45
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
46
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
47 ;;; Compatibility
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
48
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
49 ;;;###mh-autoload
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
50 (defmacro mh-require-cl ()
67760
9c3504ae6060 Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents: 67758
diff changeset
51 "Macro to load \"cl\" if needed.
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
52
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
53 Emacs coding conventions require that the \"cl\" package not be
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
54 required at runtime. However, the \"cl\" package in Emacs 21.4
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
55 and earlier left \"cl\" routines in their macro expansions. In
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
56 particular, the expansion of (setf (gethash ...) ...) used
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
57 functions in \"cl\" at run time. This macro recognizes that and
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
58 loads \"cl\" appropriately."
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
59 (if (eq (car (macroexpand '(setf (gethash foo bar) baz))) 'cl-puthash)
56787
25da1d331c99 Upgraded to MH-E version 7.82.
Bill Wohler <wohler@newt.com>
parents: 56751
diff changeset
60 `(require 'cl)
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
61 `(eval-when-compile (require 'cl))))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
62
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
63 ;;;###mh-autoload
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
64 (defmacro mh-do-in-gnu-emacs (&rest body)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
65 "Execute BODY if in GNU Emacs."
80067
0f7d101ad47f (mh-do-in-gnu-emacs, mh-do-in-xemacs)
Richard M. Stallman <rms@gnu.org>
parents: 79713
diff changeset
66 (declare (debug t))
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
67 (unless (featurep 'xemacs) `(progn ,@body)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
68 (put 'mh-do-in-gnu-emacs 'lisp-indent-hook 'defun)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
69
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
70 ;;;###mh-autoload
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
71 (defmacro mh-do-in-xemacs (&rest body)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
72 "Execute BODY if in XEmacs."
80067
0f7d101ad47f (mh-do-in-gnu-emacs, mh-do-in-xemacs)
Richard M. Stallman <rms@gnu.org>
parents: 79713
diff changeset
73 (declare (debug t))
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
74 (when (featurep 'xemacs) `(progn ,@body)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
75 (put 'mh-do-in-xemacs 'lisp-indent-hook 'defun)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
76
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
77 ;;;###mh-autoload
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
78 (defmacro mh-funcall-if-exists (function &rest args)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
79 "Call FUNCTION with ARGS as parameters if it exists."
62847
aa8c2e12ee24 Upgraded to MH-E version 7.84.
Bill Wohler <wohler@newt.com>
parents: 62465
diff changeset
80 (when (fboundp function)
aa8c2e12ee24 Upgraded to MH-E version 7.84.
Bill Wohler <wohler@newt.com>
parents: 62465
diff changeset
81 `(when (fboundp ',function)
aa8c2e12ee24 Upgraded to MH-E version 7.84.
Bill Wohler <wohler@newt.com>
parents: 62465
diff changeset
82 (funcall ',function ,@args))))
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
83
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
84 ;;;###mh-autoload
70061
b3ab71ac7f4e * mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
85 (defmacro defun-mh (name function arg-list &rest body)
68520
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
86 "Create function NAME.
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
87 If FUNCTION exists, then NAME becomes an alias for FUNCTION.
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
88 Otherwise, create function NAME with ARG-LIST and BODY."
68137
ec4727559827 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Move here from
Bill Wohler <wohler@newt.com>
parents: 67760
diff changeset
89 (let ((defined-p (fboundp function)))
68520
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
90 (if defined-p
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
91 `(defalias ',name ',function)
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
92 `(defun ,name ,arg-list ,@body))))
70061
b3ab71ac7f4e * mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
93 (put 'defun-mh 'lisp-indent-function 'defun)
95688
33aa6dc538c6 (toplevel): Put `doc-string-elt' properties on `defun-mh'
John Paul Wallington <jpw@pobox.com>
parents: 94663
diff changeset
94 (put 'defun-mh 'doc-string-elt 4)
68137
ec4727559827 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Move here from
Bill Wohler <wohler@newt.com>
parents: 67760
diff changeset
95
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
96 ;;;###mh-autoload
70061
b3ab71ac7f4e * mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
97 (defmacro defmacro-mh (name macro arg-list &rest body)
68520
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
98 "Create macro NAME.
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
99 If MACRO exists, then NAME becomes an alias for MACRO.
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
100 Otherwise, create macro NAME with ARG-LIST and BODY."
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
101 (let ((defined-p (fboundp macro)))
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
102 (if defined-p
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
103 `(defalias ',name ',macro)
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
104 `(defmacro ,name ,arg-list ,@body))))
70061
b3ab71ac7f4e * mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
105 (put 'defmacro-mh 'lisp-indent-function 'defun)
95688
33aa6dc538c6 (toplevel): Put `doc-string-elt' properties on `defun-mh'
John Paul Wallington <jpw@pobox.com>
parents: 94663
diff changeset
106 (put 'defmacro-mh 'doc-string-elt 4)
68137
ec4727559827 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Move here from
Bill Wohler <wohler@newt.com>
parents: 67760
diff changeset
107
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
108
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
109
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
110 ;;; Miscellaneous
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
111
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
112 ;;;###mh-autoload
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
113 (defmacro mh-make-local-hook (hook)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
114 "Make HOOK local if needed.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
115 XEmacs and versions of GNU Emacs before 21.1 require
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
116 `make-local-hook' to be called."
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
117 (when (and (fboundp 'make-local-hook)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
118 (not (get 'make-local-hook 'byte-obsolete-info)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
119 `(make-local-hook ,hook)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
120
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
121 ;;;###mh-autoload
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
122 (defmacro mh-mark-active-p (check-transient-mark-mode-flag)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
123 "A macro that expands into appropriate code in XEmacs and nil in GNU Emacs.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
124 In GNU Emacs if CHECK-TRANSIENT-MARK-MODE-FLAG is non-nil then
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
125 check if variable `transient-mark-mode' is active."
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
126 (cond ((featurep 'xemacs) ;XEmacs
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
127 `(and (boundp 'zmacs-regions) zmacs-regions (region-active-p)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
128 ((not check-transient-mark-mode-flag) ;GNU Emacs
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
129 `(and (boundp 'mark-active) mark-active))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
130 (t ;GNU Emacs
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
131 `(and (boundp 'transient-mark-mode) transient-mark-mode
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
132 (boundp 'mark-active) mark-active))))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
133
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
134 ;; Shush compiler.
70028
d81780942bb8 * mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
135 (defvar struct) ; XEmacs
d81780942bb8 * mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
136 (defvar x) ; XEmacs
d81780942bb8 * mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
137 (defvar y) ; XEmacs
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
138
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
139 ;;;###mh-autoload
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
140 (defmacro mh-defstruct (name-spec &rest fields)
67760
9c3504ae6060 Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents: 67758
diff changeset
141 "Replacement for `defstruct' from the \"cl\" package.
9c3504ae6060 Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents: 67758
diff changeset
142 The `defstruct' in the \"cl\" library produces compiler warnings,
9c3504ae6060 Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents: 67758
diff changeset
143 and generates code that uses functions present in \"cl\" at
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
144 run-time. This is a partial replacement, that avoids these
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
145 issues.
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
146
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
147 NAME-SPEC declares the name of the structure, while FIELDS
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
148 describes the various structure fields. Lookup `defstruct' for
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
149 more details."
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
150 (let* ((struct-name (if (atom name-spec) name-spec (car name-spec)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
151 (conc-name (or (and (consp name-spec)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
152 (cadr (assoc :conc-name (cdr name-spec))))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
153 (format "%s-" struct-name)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
154 (predicate (intern (format "%s-p" struct-name)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
155 (constructor (or (and (consp name-spec)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
156 (cadr (assoc :constructor (cdr name-spec))))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
157 (intern (format "make-%s" struct-name))))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
158 (field-names (mapcar #'(lambda (x) (if (atom x) x (car x))) fields))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
159 (field-init-forms (mapcar #'(lambda (x) (and (consp x) (cadr x)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
160 fields))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
161 (struct (gensym "S"))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
162 (x (gensym "X"))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
163 (y (gensym "Y")))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
164 `(progn
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
165 (defun* ,constructor (&key ,@(mapcar* #'(lambda (x y) (list x y))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
166 field-names field-init-forms))
56751
72a02133177e Upgraded to MH-E version 7.81.
Bill Wohler <wohler@newt.com>
parents: 56677
diff changeset
167 (list (quote ,struct-name) ,@field-names))
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
168 (defun ,predicate (arg)
56751
72a02133177e Upgraded to MH-E version 7.81.
Bill Wohler <wohler@newt.com>
parents: 56677
diff changeset
169 (and (consp arg) (eq (car arg) (quote ,struct-name))))
72a02133177e Upgraded to MH-E version 7.81.
Bill Wohler <wohler@newt.com>
parents: 56677
diff changeset
170 ,@(loop for x from 1
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
171 for y in field-names
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
172 collect `(defmacro ,(intern (format "%s%s" conc-name y)) (z)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
173 (list 'nth ,x z)))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
174 (quote ,struct-name))))
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
175
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
176 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
177 (defmacro with-mh-folder-updating (save-modification-flag &rest body)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
178 "Format is (with-mh-folder-updating (SAVE-MODIFICATION-FLAG) &body BODY).
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
179 Execute BODY, which can modify the folder buffer without having to
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
180 worry about file locking or the read-only flag, and return its result.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
181 If SAVE-MODIFICATION-FLAG is non-nil, the buffer's modification flag
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
182 is unchanged, otherwise it is cleared."
80067
0f7d101ad47f (mh-do-in-gnu-emacs, mh-do-in-xemacs)
Richard M. Stallman <rms@gnu.org>
parents: 79713
diff changeset
183 (declare (debug t))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
184 (setq save-modification-flag (car save-modification-flag)) ; CL style
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
185 `(prog1
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
186 (let ((mh-folder-updating-mod-flag (buffer-modified-p))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
187 (buffer-read-only nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
188 (buffer-file-name nil)) ;don't let the buffer get locked
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
189 (prog1
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
190 (progn
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
191 ,@body)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
192 (mh-set-folder-modified-p mh-folder-updating-mod-flag)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
193 ,@(if (not save-modification-flag)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
194 '((mh-set-folder-modified-p nil)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
195 (put 'with-mh-folder-updating 'lisp-indent-hook 'defun)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
196
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
197 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
198 (defmacro mh-in-show-buffer (show-buffer &rest body)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
199 "Format is (mh-in-show-buffer (SHOW-BUFFER) &body BODY).
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
200 Display buffer SHOW-BUFFER in other window and execute BODY in it.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
201 Stronger than `save-excursion', weaker than `save-window-excursion'."
80067
0f7d101ad47f (mh-do-in-gnu-emacs, mh-do-in-xemacs)
Richard M. Stallman <rms@gnu.org>
parents: 79713
diff changeset
202 (declare (debug t))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
203 (setq show-buffer (car show-buffer)) ; CL style
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
204 `(let ((mh-in-show-buffer-saved-window (selected-window)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
205 (switch-to-buffer-other-window ,show-buffer)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
206 (if mh-bury-show-buffer-flag (bury-buffer (current-buffer)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
207 (unwind-protect
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
208 (progn
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
209 ,@body)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
210 (select-window mh-in-show-buffer-saved-window))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
211 (put 'mh-in-show-buffer 'lisp-indent-hook 'defun)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
212
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
213 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
214 (defmacro mh-do-at-event-location (event &rest body)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
215 "Switch to the location of EVENT and execute BODY.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
216 After BODY has been executed return to original window. The
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
217 modification flag of the buffer in the event window is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
218 preserved."
80067
0f7d101ad47f (mh-do-in-gnu-emacs, mh-do-in-xemacs)
Richard M. Stallman <rms@gnu.org>
parents: 79713
diff changeset
219 (declare (debug t))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
220 (let ((event-window (make-symbol "event-window"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
221 (event-position (make-symbol "event-position"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
222 (original-window (make-symbol "original-window"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
223 (original-position (make-symbol "original-position"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
224 (modified-flag (make-symbol "modified-flag")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
225 `(save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
226 (let* ((,event-window
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
227 (or (mh-funcall-if-exists posn-window (event-start ,event))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
228 (mh-funcall-if-exists event-window ,event)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
229 (,event-position
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
230 (or (mh-funcall-if-exists posn-point (event-start ,event))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
231 (mh-funcall-if-exists event-closest-point ,event)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
232 (,original-window (selected-window))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
233 (,original-position (progn
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
234 (set-buffer (window-buffer ,event-window))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
235 (set-marker (make-marker) (point))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
236 (,modified-flag (buffer-modified-p))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
237 (buffer-read-only nil))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
238 (unwind-protect (progn
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
239 (select-window ,event-window)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
240 (goto-char ,event-position)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
241 ,@body)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
242 (set-buffer-modified-p ,modified-flag)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
243 (goto-char ,original-position)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
244 (set-marker ,original-position nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
245 (select-window ,original-window))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
246 (put 'mh-do-at-event-location 'lisp-indent-hook 'defun)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
247
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
248
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
249
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
250 ;;; Sequences and Ranges
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
251
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
252 ;;;###mh-autoload
80067
0f7d101ad47f (mh-do-in-gnu-emacs, mh-do-in-xemacs)
Richard M. Stallman <rms@gnu.org>
parents: 79713
diff changeset
253 (defsubst mh-seq-msgs (sequence)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
254 "Extract messages from the given SEQUENCE."
80067
0f7d101ad47f (mh-do-in-gnu-emacs, mh-do-in-xemacs)
Richard M. Stallman <rms@gnu.org>
parents: 79713
diff changeset
255 (cdr sequence))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
256
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
257 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
258 (defmacro mh-iterate-on-messages-in-region (var begin end &rest body)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
259 "Iterate over region.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
260
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
261 VAR is bound to the message on the current line as we loop
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
262 starting from BEGIN till END. In each step BODY is executed.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
263
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
264 If VAR is nil then the loop is executed without any binding."
80067
0f7d101ad47f (mh-do-in-gnu-emacs, mh-do-in-xemacs)
Richard M. Stallman <rms@gnu.org>
parents: 79713
diff changeset
265 (declare (debug (symbolp body)))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
266 (unless (symbolp var)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
267 (error "Can not bind the non-symbol %s" var))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
268 (let ((binding-needed-flag var))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
269 `(save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
270 (goto-char ,begin)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
271 (beginning-of-line)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
272 (while (and (<= (point) ,end) (not (eobp)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
273 (when (looking-at mh-scan-valid-regexp)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
274 (let ,(if binding-needed-flag `((,var (mh-get-msg-num t))) ())
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
275 ,@body))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
276 (forward-line 1)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
277 (put 'mh-iterate-on-messages-in-region 'lisp-indent-hook 'defun)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
278
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
279 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
280 (defmacro mh-iterate-on-range (var range &rest body)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
281 "Iterate an operation over a region or sequence.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
282
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
283 VAR is bound to each message in turn in a loop over RANGE, which
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
284 can be a message number, a list of message numbers, a sequence, a
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
285 region in a cons cell, or a MH range (something like last:20) in
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
286 a string. In each iteration, BODY is executed.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
287
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
288 The parameter RANGE is usually created with
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
289 `mh-interactive-range' in order to provide a uniform interface to
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
290 MH-E functions."
80067
0f7d101ad47f (mh-do-in-gnu-emacs, mh-do-in-xemacs)
Richard M. Stallman <rms@gnu.org>
parents: 79713
diff changeset
291 (declare (debug (symbolp body)))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
292 (unless (symbolp var)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
293 (error "Can not bind the non-symbol %s" var))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
294 (let ((binding-needed-flag var)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
295 (msgs (make-symbol "msgs"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
296 (seq-hash-table (make-symbol "seq-hash-table")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
297 `(cond ((numberp ,range)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
298 (when (mh-goto-msg ,range t t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
299 (let ,(if binding-needed-flag `((,var ,range)) ())
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
300 ,@body)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
301 ((and (consp ,range)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
302 (numberp (car ,range)) (numberp (cdr ,range)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
303 (mh-iterate-on-messages-in-region ,var
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
304 (car ,range) (cdr ,range)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
305 ,@body))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
306 (t (let ((,msgs (cond ((and ,range (symbolp ,range))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
307 (mh-seq-to-msgs ,range))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
308 ((stringp ,range)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
309 (mh-translate-range mh-current-folder
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
310 ,range))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
311 (t ,range)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
312 (,seq-hash-table (make-hash-table)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
313 (dolist (msg ,msgs)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
314 (setf (gethash msg ,seq-hash-table) t))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
315 (mh-iterate-on-messages-in-region v (point-min) (point-max)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
316 (when (gethash v ,seq-hash-table)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
317 (let ,(if binding-needed-flag `((,var v)) ())
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
318 ,@body))))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68236
diff changeset
319 (put 'mh-iterate-on-range 'lisp-indent-hook 'defun)
66357
f5ade15d46f2 * mh-identity.el (mh-assoc-ignore-case): Merge with version in
Bill Wohler <wohler@newt.com>
parents: 64085
diff changeset
320
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
321 (provide 'mh-acros)
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
322
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 66357
diff changeset
323 ;; Local Variables:
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 66357
diff changeset
324 ;; no-byte-compile: t
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 66357
diff changeset
325 ;; indent-tabs-mode: nil
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 66357
diff changeset
326 ;; sentence-end-double-space: nil
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 66357
diff changeset
327 ;; End:
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
328
56677
5aafbbdd005f Add arch taglines
Miles Bader <miles@gnu.org>
parents: 56676
diff changeset
329 ;; arch-tag: b383b49a-494f-4ed0-a30a-cb6d5d2da4ff
56676
db6d7638a259 Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
diff changeset
330 ;;; mh-acros.el ends here