annotate lisp/mh-e/mh-utils.el @ 96671:86881ffcdf4e

* entering.texi (Entering Emacs): Update prev node. * glossary.texi (Glossary): Remove xref to Text Characters.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 15 Jul 2008 15:29:07 +0000
parents bf02306ea6d7
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: 68206
diff changeset
1 ;;; mh-utils.el --- MH-E general utilities
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
2
62847
aa8c2e12ee24 Upgraded to MH-E version 7.84.
Bill Wohler <wohler@newt.com>
parents: 62767
diff changeset
3 ;; Copyright (C) 1993, 1995, 1997,
79713
3c2488d0ebd9 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78231
diff changeset
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
5
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
6 ;; Author: Bill Wohler <wohler@newt.com>
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
7 ;; Maintainer: Bill Wohler <wohler@newt.com>
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
8 ;; Keywords: mail
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
9 ;; See: mh-e.el
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
10
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
12
94663
90c9ebd43589 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
14 ;; 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: 87649
diff changeset
15 ;; 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: 87649
diff changeset
16 ;; (at your option) any later version.
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
17
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
21 ;; GNU General Public License for more details.
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
22
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
23 ;; 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: 87649
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
25
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
26 ;;; Commentary:
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
27
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
28 ;;; Change Log:
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
29
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
30 ;;; Code:
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
31
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
32 (require 'mh-e)
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
33 (mh-require-cl)
68096
57c4e7929f99 * mh-alias.el (mh-alias-gecos-name): Use replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68013
diff changeset
34
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
35 (require 'font-lock)
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
36
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
37 ;;; CL Replacements
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
38
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
39 ;;;###mh-autoload
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
40 (defun mh-search-from-end (char string)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
41 "Return the position of last occurrence of CHAR in STRING.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
42 If CHAR is not present in STRING then return nil. The function is
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
43 used in lieu of `search' in the CL package."
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
44 (loop for index from (1- (length string)) downto 0
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
45 when (equal (aref string index) char) return index
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
46 finally return nil))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
47
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
48
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
49
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
50 ;;; General Utilities
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
51
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
52 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
53 (defun mh-beginning-of-word (&optional n)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
54 "Return position of the N th word backwards."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
55 (unless n (setq n 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
56 (let ((syntax-table (syntax-table)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
57 (unwind-protect
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
58 (save-excursion
68520
6a7173abcf59 * mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents: 68477
diff changeset
59 (mh-mail-abbrev-make-syntax-table)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
60 (set-syntax-table mail-abbrev-syntax-table)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
61 (backward-word n)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
62 (point))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
63 (set-syntax-table syntax-table))))
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
64
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
65 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
66 (defun mh-colors-available-p ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
67 "Check if colors are available in the Emacs being used."
86202
794e428cd497 * eshell/esh-util.el (eshell-under-xemacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78231
diff changeset
68 (or (featurep 'xemacs)
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
69 (let ((color-cells (mh-display-color-cells)))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
70 (and (numberp color-cells) (>= color-cells 8)))))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
71
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
72 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
73 (defun mh-colors-in-use-p ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
74 "Check if colors are being used in the folder buffer."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
75 (and mh-colors-available-flag font-lock-mode))
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
76
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
77 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
78 (defun mh-delete-line (lines)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
79 "Delete the next LINES lines."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
80 (delete-region (point) (progn (forward-line lines) (point))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
81
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
82 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
83 (defun mh-make-local-vars (&rest pairs)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
84 "Initialize local variables according to the variable-value PAIRS."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
85 (while pairs
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
86 (set (make-local-variable (car pairs)) (car (cdr pairs)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
87 (setq pairs (cdr (cdr pairs)))))
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
88
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
89 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
90 (defun mh-mapc (function list)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
91 "Apply FUNCTION to each element of LIST for side effects only."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
92 (while list
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
93 (funcall function (car list))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
94 (setq list (cdr list))))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
95
69221
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
96 (defvar mh-pick-regexp-chars ".*$["
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
97 "List of special characters in pick regular expressions.")
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
98
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
99 ;;;###mh-autoload
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
100 (defun mh-quote-pick-expr (pick-expr)
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
101 "Quote `mh-pick-regexp-chars' in PICK-EXPR.
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
102 PICK-EXPR is a list of strings. Return nil if PICK-EXPR is nil."
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
103 (let ((quoted-pick-expr))
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
104 (dolist (string pick-expr)
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
105 (when (and string
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
106 (not (string-equal string "")))
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
107 (loop for i from 0 to (1- (length mh-pick-regexp-chars)) do
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
108 (let ((s (string ?\\ (aref mh-pick-regexp-chars i))))
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
109 (setq string (mh-replace-regexp-in-string s s string t t))))
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
110 (setq quoted-pick-expr (append quoted-pick-expr (list string)))))
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
111 quoted-pick-expr))
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
112
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
113 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
114 (defun mh-replace-string (old new)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
115 "Replace all occurrences of OLD with NEW in the current buffer.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
116 Ignores case when searching for OLD."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
117 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
118 (let ((case-fold-search t))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
119 (while (search-forward old nil t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
120 (replace-match new t t))))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
121
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
122
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
123
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
124 ;;; Logo Display
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
125
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
126 (defvar mh-logo-cache nil)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
127
69492
6afc0d1f682b * mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents: 69472
diff changeset
128 ;; Shush compiler.
6afc0d1f682b * mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents: 69472
diff changeset
129 (defvar image-load-path)
6afc0d1f682b * mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents: 69472
diff changeset
130
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
131 ;;;###mh-autoload
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
132 (defun mh-logo-display ()
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
133 "Modify mode line to display MH-E logo."
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
134 (mh-do-in-gnu-emacs
69472
5259cc742763 * mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents: 69451
diff changeset
135 (let* ((load-path (mh-image-load-path-for-library "mh-e" "mh-logo.xpm"))
69492
6afc0d1f682b * mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents: 69472
diff changeset
136 (image-load-path (cons (car load-path)
6afc0d1f682b * mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents: 69472
diff changeset
137 (when (boundp 'image-load-path)
6afc0d1f682b * mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents: 69472
diff changeset
138 image-load-path))))
69245
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
139 (add-text-properties
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
140 0 2
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
141 `(display ,(or mh-logo-cache
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
142 (setq mh-logo-cache
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
143 (mh-funcall-if-exists
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
144 find-image '((:type xpm :ascent center
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
145 :file "mh-logo.xpm"))))))
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
146 (car mode-line-buffer-identification))))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
147 (mh-do-in-xemacs
69245
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
148 (setq modeline-buffer-identification
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
149 (list
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
150 (if mh-modeline-glyph
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
151 (cons modeline-buffer-id-left-extent mh-modeline-glyph)
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
152 (cons modeline-buffer-id-left-extent "XEmacs%N:"))
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
153 (cons modeline-buffer-id-right-extent " %17b")))))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
154
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
155
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
156
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
157 ;;; Read MH Profile
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
158
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
159 (defvar mh-find-path-run nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
160 "Non-nil if `mh-find-path' has been run already.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
161 Do not access this variable; `mh-find-path' already uses it to
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
162 avoid running more than once.")
67756
7ff92ad99326 * mh-alias.el (mh-alias-reload): Sync docstrings with manual.
Bill Wohler <wohler@newt.com>
parents: 67681
diff changeset
163
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
164 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
165 (defun mh-find-path ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
166 "Set variables from user's MH profile.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
167
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
168 This function sets `mh-user-path' from your \"Path:\" MH profile
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
169 component (but defaults to \"Mail\" if one isn't present),
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
170 `mh-draft-folder' from \"Draft-Folder:\", `mh-unseen-seq' from
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
171 \"Unseen-Sequence:\", `mh-previous-seq' from
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
172 \"Previous-Sequence:\", and `mh-inbox' from \"Inbox:\" (defaults
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
173 to \"+inbox\").
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
174
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
175 The hook `mh-find-path-hook' is run after these variables have
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
176 been set. This hook can be used the change the value of these
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
177 variables if you need to run with different values between MH and
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
178 MH-E."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
179 (unless mh-find-path-run
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
180 ;; Sanity checks.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
181 (if (and (getenv "MH")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
182 (not (file-readable-p (getenv "MH"))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
183 (error "MH environment variable contains unreadable file %s"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
184 (getenv "MH")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
185 (if (null (mh-variants))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
186 (error "Install MH and run install-mh before running MH-E"))
95095
bf02306ea6d7 (mh-find-path): Don't throw error if MH environment variable is being
Bill Wohler <wohler@newt.com>
parents: 94663
diff changeset
187 (if (not (or (getenv "MH") (file-readable-p "~/.mh_profile")))
bf02306ea6d7 (mh-find-path): Don't throw error if MH environment variable is being
Bill Wohler <wohler@newt.com>
parents: 94663
diff changeset
188 (error "Run install-mh before running MH-E"))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
189 ;; Read MH profile.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
190 (setq mh-user-path (mh-profile-component "Path"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
191 (if (not mh-user-path)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
192 (setq mh-user-path "Mail"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
193 (setq mh-user-path
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
194 (file-name-as-directory
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
195 (expand-file-name mh-user-path (expand-file-name "~"))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
196 (mh-set-x-image-cache-directory (expand-file-name ".mhe-x-image-cache"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
197 mh-user-path))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
198 (setq mh-draft-folder (mh-profile-component "Draft-Folder"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
199 (if mh-draft-folder
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
200 (progn
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
201 (if (not (mh-folder-name-p mh-draft-folder))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
202 (setq mh-draft-folder (format "+%s" mh-draft-folder)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
203 (if (not (file-exists-p (mh-expand-file-name mh-draft-folder)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
204 (error
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
205 "Draft folder \"%s\" not found; create it and try again"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
206 (mh-expand-file-name mh-draft-folder)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
207 (setq mh-inbox (mh-profile-component "Inbox"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
208 (cond ((not mh-inbox)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
209 (setq mh-inbox "+inbox"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
210 ((not (mh-folder-name-p mh-inbox))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
211 (setq mh-inbox (format "+%s" mh-inbox))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
212 (setq mh-unseen-seq (mh-profile-component "Unseen-Sequence"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
213 (if mh-unseen-seq
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
214 (setq mh-unseen-seq (intern mh-unseen-seq))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
215 (setq mh-unseen-seq 'unseen)) ;old MH default?
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
216 (setq mh-previous-seq (mh-profile-component "Previous-Sequence"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
217 (if mh-previous-seq
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
218 (setq mh-previous-seq (intern mh-previous-seq)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
219 (run-hooks 'mh-find-path-hook)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
220 (mh-collect-folder-names)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
221 (setq mh-find-path-run t)))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
222
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
223
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
224
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
225 ;;; Help Functions
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
226
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
227 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
228 (defun mh-ephem-message (string)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
229 "Display STRING in the minibuffer momentarily."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
230 (message "%s" string)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
231 (sit-for 5)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
232 (message ""))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
233
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
234 (defvar mh-help-default nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
235 "Mode to use if messages are not present for the current mode.")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
236
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
237 (defvar mh-help-messages nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
238 "Help messages for all modes.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
239 This is an alist of alists. The primary key is a symbol
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
240 representing the mode; the value is described in `mh-set-help'.")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
241
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
242 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
243 (defun mh-set-help (messages &optional default)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
244 "Set help messages.
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
245
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
246 The MESSAGES are assumed to be an associative array. It is used
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
247 to show help for the most common commands in the current mode.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
248 The key is a prefix char. The value is one or more strings which
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
249 are concatenated together and displayed in a help buffer if ? is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
250 pressed after the prefix character. The special key nil is used
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
251 to display the non-prefixed commands.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
252
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
253 The substitutions described in `substitute-command-keys' are performed as
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
254 well.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
255
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
256 If optional argument DEFAULT is non-nil, then these messages will
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
257 be used if help is asked for an unknown mode."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
258 (add-to-list 'mh-help-messages (cons major-mode messages))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
259 (if default
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
260 (setq mh-help-default major-mode)))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
261
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
262 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
263 (defun mh-help (&optional help-messages)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
264 "Display cheat sheet for the MH-E commands.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
265 See `mh-set-help' for setting the help messages.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
266 HELP-MESSAGES are used instead if given.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
267 This is a list of one or more strings which are concatenated together
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
268 and displayed in a help buffer."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
269 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
270 (let* ((help (or help-messages
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
271 (cdr (assoc nil (assoc major-mode mh-help-messages)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
272 (text (substitute-command-keys (mapconcat 'identity help ""))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
273 (with-electric-help
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
274 (function
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
275 (lambda ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
276 (insert text)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
277 mh-help-buffer)))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
278
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
279 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
280 (defun mh-prefix-help ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
281 "Display cheat sheet for the commands of the current prefix in minibuffer."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
282 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
283 ;; We got here because the user pressed a "?", but he pressed a prefix key
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
284 ;; before that. Since the the key vector starts at index 0, the index of the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
285 ;; last keystroke is length-1 and thus the second to last keystroke is at
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
286 ;; length-2. We use that information to obtain a suitable prefix character
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
287 ;; from the recent keys.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
288 (let* ((keys (recent-keys))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
289 (prefix-char (elt keys (- (length keys) 2)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
290 (help (cdr (assoc prefix-char (assoc major-mode mh-help-messages)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
291 (mh-help help)))
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
292
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
293
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
294
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
295 ;;; Message Number Utilities
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
296
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
297 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
298 (defun mh-coalesce-msg-list (messages)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
299 "Given a list of MESSAGES, return a list of message number ranges.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
300 This is the inverse of `mh-read-msg-list', which expands ranges.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
301 Message lists passed to MH programs should be processed by this
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
302 function to avoid exceeding system command line argument limits."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
303 (let ((msgs (sort (copy-sequence messages) 'mh-greaterp))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
304 (range-high nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
305 (prev -1)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
306 (ranges nil))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
307 (while prev
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
308 (if range-high
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
309 (if (or (not (numberp prev))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
310 (not (equal (car msgs) (1- prev))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
311 (progn ;non-sequential, flush old range
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
312 (if (eq prev range-high)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
313 (setq ranges (cons range-high ranges))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
314 (setq ranges (cons (format "%s-%s" prev range-high) ranges)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
315 (setq range-high nil))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
316 (or range-high
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
317 (setq range-high (car msgs))) ;start new or first range
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
318 (setq prev (car msgs))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
319 (setq msgs (cdr msgs)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
320 ranges))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
321
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
322 (defun mh-greaterp (msg1 msg2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
323 "Return the greater of two message indicators MSG1 and MSG2.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
324 Strings are \"smaller\" than numbers.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
325 Valid values are things like \"cur\", \"last\", 1, and 1820."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
326 (if (numberp msg1)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
327 (if (numberp msg2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
328 (> msg1 msg2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
329 t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
330 (if (numberp msg2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
331 nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
332 (string-lessp msg2 msg1))))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
333
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
334 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
335 (defun mh-lessp (msg1 msg2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
336 "Return the lesser of two message indicators MSG1 and MSG2.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
337 Strings are \"smaller\" than numbers.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
338 Valid values are things like \"cur\", \"last\", 1, and 1820."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
339 (not (mh-greaterp msg1 msg2)))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
340
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
341 ;;;###mh-autoload
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
342 (defun mh-get-msg-num (error-if-no-message)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
343 "Return the message number of the displayed message.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
344 If the argument ERROR-IF-NO-MESSAGE is non-nil, then complain if
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
345 the cursor is not pointing to a message."
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
346 (save-excursion
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
347 (beginning-of-line)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
348 (cond ((looking-at (mh-scan-msg-number-regexp))
62847
aa8c2e12ee24 Upgraded to MH-E version 7.84.
Bill Wohler <wohler@newt.com>
parents: 62767
diff changeset
349 (string-to-number (buffer-substring (match-beginning 1)
aa8c2e12ee24 Upgraded to MH-E version 7.84.
Bill Wohler <wohler@newt.com>
parents: 62767
diff changeset
350 (match-end 1))))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
351 (error-if-no-message
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
352 (error "Cursor not pointing to message"))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
353 (t nil))))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
354
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
355 (add-to-list 'debug-ignored-errors "^Cursor not pointing to message$")
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
356
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
357
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
358
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
359 ;;; Folder Cache and Access
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
360
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
361 (defvar mh-sub-folders-cache (make-hash-table :test #'equal))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
362 (defvar mh-current-folder-name nil)
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
363 (defvar mh-flists-partial-line "")
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
364 (defvar mh-flists-process nil)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
365
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
366 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
367 (defun mh-clear-sub-folders-cache ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
368 "Clear `mh-sub-folders-cache'."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
369 (clrhash mh-sub-folders-cache))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
370
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
371 ;; Initialize mh-sub-folders-cache...
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
372 (defun mh-collect-folder-names ()
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
373 "Collect folder names by running \"folders\"."
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
374 (unless mh-flists-process
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
375 (setq mh-flists-process
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
376 (mh-exec-cmd-daemon "folders" 'mh-collect-folder-names-filter
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
377 "-recurse" "-fast"))))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
378
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
379 (defun mh-collect-folder-names-filter (process output)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
380 "Read folder names.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
381 PROCESS is the flists process that was run to collect folder
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
382 names and the function is called when OUTPUT is available."
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
383 (let ((position 0)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
384 (prevailing-match-data (match-data))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
385 line-end folder)
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
386 (unwind-protect
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
387 (while (setq line-end (string-match "\n" output position))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
388 (setq folder (format "+%s%s"
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
389 mh-flists-partial-line
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
390 (substring output position line-end)))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
391 (setq mh-flists-partial-line "")
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
392 (unless (equal (aref folder 1) ?.)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
393 (mh-populate-sub-folders-cache folder))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
394 (setq position (1+ line-end)))
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
395 (set-match-data prevailing-match-data))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
396 (setq mh-flists-partial-line (substring output position))))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
397
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
398 (defun mh-populate-sub-folders-cache (folder)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
399 "Tell `mh-sub-folders-cache' about FOLDER."
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
400 (let* ((last-slash (mh-search-from-end ?/ folder))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
401 (child1 (substring folder (1+ (or last-slash 0))))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
402 (parent (and last-slash (substring folder 0 last-slash)))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
403 (parent-slash (and parent (mh-search-from-end ?/ parent)))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
404 (child2 (and parent (substring parent (1+ (or parent-slash 0)))))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
405 (grand-parent (and parent-slash (substring parent 0 parent-slash)))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
406 (cache-entry (gethash parent mh-sub-folders-cache)))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
407 (unless (loop for x in cache-entry when (equal (car x) child1) return t
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
408 finally return nil)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
409 (push (list child1) cache-entry)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
410 (setf (gethash parent mh-sub-folders-cache)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
411 (sort cache-entry (lambda (x y) (string< (car x) (car y)))))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
412 (when parent
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
413 (loop for x in (gethash grand-parent mh-sub-folders-cache)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
414 when (equal (car x) child2)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
415 do (progn (setf (cdr x) t) (return)))))))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
416
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
417 (defun mh-normalize-folder-name (folder &optional empty-string-okay
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
418 dont-remove-trailing-slash
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
419 return-nil-if-folder-empty)
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
420 "Normalizes FOLDER name.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
421
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
422 Makes sure that two '/' characters never occur next to each
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
423 other. Also all occurrences of \"..\" and \".\" are suitably
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
424 processed. So \"+inbox/../news\" will be normalized to \"+news\".
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
425
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
426 If optional argument EMPTY-STRING-OKAY is nil then a '+' is added
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
427 at the front if FOLDER lacks one. If non-nil and FOLDER is the
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
428 empty string then nothing is added.
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
429
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
430 If optional argument DONT-REMOVE-TRAILING-SLASH is non-nil then a
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
431 trailing '/' if present is retained (if present), otherwise it is
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
432 removed.
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
433
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
434 If optional argument RETURN-NIL-IF-FOLDER-EMPTY is non-nil, then
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
435 return nil if FOLDER is \"\" or \"+\". This is useful when
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
436 normalizing the folder for the \"folders\" command which displays
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
437 the directories in / if passed \"+\". This is usually not
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
438 desired. If this argument is non-nil, then EMPTY-STRING-OKAY has
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
439 no effect."
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
440 (cond
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
441 ((if (and (or (equal folder "+") (equal folder ""))
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
442 return-nil-if-folder-empty)
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
443 (setq folder nil)))
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
444 ((stringp folder)
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
445 ;; Replace two or more consecutive '/' characters with a single '/'
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
446 (while (string-match "//" folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
447 (setq folder (replace-match "/" nil t folder)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
448 (let* ((length (length folder))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
449 (trailing-slash-present (and (> length 0)
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
450 (equal (aref folder (1- length)) ?/)))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
451 (leading-slash-present (and (> length 0)
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
452 (equal (aref folder 0) ?/))))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
453 (when (and (> length 0) (equal (aref folder 0) ?@)
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
454 (stringp mh-current-folder-name))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
455 (setq folder (format "%s/%s/" mh-current-folder-name
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
456 (substring folder 1))))
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
457 ;; XXX: Purge empty strings from the list that split-string
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
458 ;; returns. In XEmacs, (split-string "+foo/" "/") returns
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
459 ;; ("+foo" "") while in GNU Emacs it returns ("+foo"). In the
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
460 ;; code it is assumed that the components list has no empty
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
461 ;; strings.
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
462 (let ((components (delete "" (split-string folder "/")))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
463 (result ()))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
464 ;; Remove .. and . from the pathname.
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
465 (dolist (component components)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
466 (cond ((and (equal component "..") result)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
467 (pop result))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
468 ((equal component ".."))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
469 ((equal component "."))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
470 (t (push component result))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
471 (setq folder "")
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
472 (dolist (component result)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
473 (setq folder (concat component "/" folder)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
474 ;; Remove trailing '/' if needed.
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
475 (unless (and trailing-slash-present dont-remove-trailing-slash)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
476 (when (not (equal folder ""))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
477 (setq folder (substring folder 0 (1- (length folder))))))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
478 (when leading-slash-present
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
479 (setq folder (concat "/" folder)))))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
480 (cond ((and empty-string-okay (equal folder "")))
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
481 ((equal folder "")
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
482 (setq folder "+"))
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
483 ((not (equal (aref folder 0) ?+))
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
484 (setq folder (concat "+" folder))))))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
485 folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
486
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
487 (defmacro mh-children-p (folder)
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
488 "Return t if FOLDER from sub-folders cache has children.
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
489 The car of folder is the name, and the cdr is either t or some
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
490 sort of count that I do not understand. It's too small to be the
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
491 number of messages in the sub-folders and too large to be the
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
492 number of sub-folders. XXX"
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
493 `(if (cdr ,folder)
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
494 t
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
495 nil))
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
496
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
497 ;;;###mh-autoload
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
498 (defun mh-folder-list (folder)
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
499 "Return FOLDER and its descendents.
69215
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
500 FOLDER may have a + prefix. Returns a list of strings without the
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
501 + prefix. If FOLDER is nil, then all folders are considered. For
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
502 example, if your Mail directory only contains the folders +inbox,
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
503 +outbox, +lists, and +lists/mh-e, then
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
504
69215
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
505 (mh-folder-list nil)
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
506 => (\"inbox\" \"lists\" \"lists/mh-e\" \"outbox\")
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
507 (mh-folder-list \"+lists\")
69451
6c89c044a798 (mh-folder-list): Fix docstring (closes SF #1448498).
Bill Wohler <wohler@newt.com>
parents: 69286
diff changeset
508 => (\"lists\" \"lists/mh-e\")
69215
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
509
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
510 Respects the value of `mh-recursive-folders-flag'. If this flag
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
511 is nil, and the sub-folders have not been explicitly viewed, then
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
512 they will not be returned."
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
513 (let ((folder-list))
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
514 ;; Normalize folder. Strip leading + and trailing slash(es). If no
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
515 ;; folder is specified, ensure it is nil to avoid adding the
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
516 ;; folder to the folder-list and adding a slash to it.
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
517 (when folder
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
518 (setq folder (mh-replace-regexp-in-string "^\+" "" folder))
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
519 (setq folder (mh-replace-regexp-in-string "/+$" "" folder))
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
520 (if (equal folder "")
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
521 (setq folder nil)))
69215
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
522 ;; Add provided folder to list, unless all folders are asked for.
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
523 ;; Then append slash to separate sub-folders.
69215
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
524 (unless (null folder)
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
525 (setq folder-list (list folder))
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
526 (setq folder (concat folder "/")))
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
527 (loop for f in (mh-sub-folders folder) do
69215
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
528 (setq folder-list
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
529 (append folder-list
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
530 (if (mh-children-p f)
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
531 (mh-folder-list (concat folder (car f)))
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
532 (list (concat folder (car f)))))))
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
533 folder-list))
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
534
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
535 ;;;###mh-autoload
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
536 (defun mh-sub-folders (folder &optional add-trailing-slash-flag)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
537 "Find the subfolders of FOLDER.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
538 The function avoids running folders unnecessarily by caching the
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
539 results of the actual folders call.
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
540
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
541 If optional argument ADD-TRAILING-SLASH-FLAG is non-nil then a
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
542 slash is added to each of the sub-folder names that may have
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
543 nested folders within them."
69278
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
544 (let* ((folder (mh-normalize-folder-name folder nil nil t))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
545 (match (gethash folder mh-sub-folders-cache 'no-result))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
546 (sub-folders (cond ((eq match 'no-result)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
547 (setf (gethash folder mh-sub-folders-cache)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
548 (mh-sub-folders-actual folder)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
549 (t match))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
550 (if add-trailing-slash-flag
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
551 (mapcar #'(lambda (x)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
552 (if (cdr x) (cons (concat (car x) "/") (cdr x)) x))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
553 sub-folders)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
554 sub-folders)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
555
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
556 ;; FIXME: This function does not do well if FOLDER does not exist. It
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
557 ;; then changes the context to that folder which causes problems down
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
558 ;; the line. Since a folder in the cache could later be deleted, it
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
559 ;; would be good for mh-sub-folders-actual to return nil in this case
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
560 ;; so that mh-sub-folders could delete it from the cache. This
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
561 ;; function could protect itself by using a temporary context.
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
562 (defun mh-sub-folders-actual (folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
563 "Execute the command folders to return the sub-folders of FOLDER.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
564 Filters out the folder names that start with \".\" so that
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
565 directories that aren't usually mail folders are hidden.
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
566 Expects FOLDER to have already been normalized with
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
567 (mh-normalize-folder-name folder nil nil t)"
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
568 (let ((arg-list `(,(expand-file-name "folders" mh-progs)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
569 nil (t nil) nil "-noheader" "-norecurse" "-nototal"
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
570 ,@(if (stringp folder) (list folder) ())))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
571 (results ())
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
572 (current-folder (concat
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
573 (with-temp-buffer
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
574 (call-process (expand-file-name "folder" mh-progs)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
575 nil '(t nil) nil "-fast")
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
576 (buffer-substring (point-min) (1- (point-max))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
577 "+")))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
578 (with-temp-buffer
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
579 (apply #'call-process arg-list)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
580 (goto-char (point-min))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
581 (while (not (and (eolp) (bolp)))
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
582 (goto-char (mh-line-end-position))
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
583 (let ((start-pos (mh-line-beginning-position))
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
584 (has-pos (search-backward " has "
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
585 (mh-line-beginning-position) t)))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
586 (when (integerp has-pos)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
587 (while (equal (char-after has-pos) ? )
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
588 (decf has-pos))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
589 (incf has-pos)
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
590 (while (equal (char-after start-pos) ? )
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
591 (incf start-pos))
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
592 (let* ((name (buffer-substring start-pos has-pos))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
593 (first-char (aref name 0))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
594 (last-char (aref name (1- (length name)))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
595 (unless (member first-char '(?. ?# ?,))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
596 (when (and (equal last-char ?+) (equal name current-folder))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
597 (setq name (substring name 0 (1- (length name)))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
598 (push
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
599 (cons name
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
600 (search-forward "(others)" (mh-line-end-position) t))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
601 results))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
602 (forward-line 1))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
603 (setq results (nreverse results))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
604 (when (stringp folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
605 (setq results (cdr results))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
606 (let ((folder-name-len (length (format "%s/" (substring folder 1)))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
607 (setq results (mapcar (lambda (f)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
608 (cons (substring (car f) folder-name-len)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
609 (cdr f)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
610 results))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
611 results))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
612
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
613 ;;;###mh-autoload
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
614 (defun mh-remove-from-sub-folders-cache (folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
615 "Remove FOLDER and its parent from `mh-sub-folders-cache'.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
616 FOLDER should be unconditionally removed from the cache. Also the
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
617 last ancestor of FOLDER present in the cache must be removed as
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
618 well.
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
619
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
620 To see why this is needed assume we have a folder +foo which has
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
621 a single sub-folder qux. Now we create the folder +foo/bar/baz.
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
622 Here we will need to invalidate the cached sub-folders of +foo,
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
623 otherwise completion on +foo won't tell us about the option
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
624 +foo/bar!"
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
625 (remhash folder mh-sub-folders-cache)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
626 (block ancestor-found
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
627 (let ((parent folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
628 (one-ancestor-found nil)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
629 last-slash)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
630 (while (setq last-slash (mh-search-from-end ?/ parent))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
631 (setq parent (substring parent 0 last-slash))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
632 (unless (eq (gethash parent mh-sub-folders-cache 'none) 'none)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
633 (remhash parent mh-sub-folders-cache)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
634 (if one-ancestor-found
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
635 (return-from ancestor-found)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
636 (setq one-ancestor-found t))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
637 (remhash nil mh-sub-folders-cache))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
638
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
639
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
640
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
641 ;;; Folder Utilities
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
642
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
643 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
644 (defun mh-folder-name-p (name)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
645 "Return non-nil if NAME is the name of a folder.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
646 A name (a string or symbol) can be a folder name if it begins
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
647 with \"+\"."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
648 (if (symbolp name)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
649 (eq (aref (symbol-name name) 0) ?+)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
650 (and (> (length name) 0)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
651 (eq (aref name 0) ?+))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
652
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
653 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
654 (defun mh-expand-file-name (filename &optional default)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
655 "Expand FILENAME like `expand-file-name', but also handle MH folder names.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
656 Any filename that starts with '+' is treated as a folder name.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
657 See `expand-file-name' for description of DEFAULT."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
658 (if (mh-folder-name-p filename)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
659 (expand-file-name (substring filename 1) mh-user-path)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
660 (expand-file-name filename default)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
661
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
662 (defvar mh-folder-hist nil)
68096
57c4e7929f99 * mh-alias.el (mh-alias-gecos-name): Use replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68013
diff changeset
663
57c4e7929f99 * mh-alias.el (mh-alias-gecos-name): Use replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68013
diff changeset
664 ;; Shush compiler.
70027
0e0916499a15 * mh-funcs.el (view-exit-action): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents: 69492
diff changeset
665 (defvar mh-speed-flists-cache)
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
666
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
667 (defvar mh-allow-root-folder-flag nil
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
668 "Non-nil means \"+\" is an acceptable folder name.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
669 This variable is used to communicate with
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
670 `mh-folder-completion-function'. That function can have exactly
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
671 three arguments so we bind this variable to t or nil.
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
672
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
673 This variable should never be set.")
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
674
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
675 (defvar mh-folder-completion-map (copy-keymap minibuffer-local-completion-map))
67852
5b7ceef33307 (mh-process-daemon): Don't change buffer in proc-filter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67760
diff changeset
676 (define-key mh-folder-completion-map " " 'minibuffer-complete) ;Why???
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
677
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
678 (defvar mh-speed-flists-inhibit-flag nil)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
679
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
680 ;;;###mh-autoload
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
681 (defun mh-speed-flists-active-p ()
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
682 "Check if speedbar is running with message counts enabled."
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
683 (and (featurep 'mh-speed)
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
684 (not mh-speed-flists-inhibit-flag)
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
685 (> (hash-table-count mh-speed-flists-cache) 0)))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
686
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
687 ;;;###mh-autoload
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
688 (defun mh-folder-completion-function (name predicate flag)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
689 "Programmable completion for folder names.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
690 NAME is the partial folder name that has been input. PREDICATE if
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
691 non-nil is a function that is used to filter the possible
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
692 choices. FLAG is nil to indicate `try-completion', t for
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
693 `all-completions', or the symbol lambda for `test-completion'.
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
694 See Info node `(elisp) Programmed Completion' for details."
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
695 (let* ((orig-name name)
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
696 ;; After normalization, name is nil, +, or +something. If a
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
697 ;; trailing slash is present, it is preserved.
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
698 (name (mh-normalize-folder-name name nil t))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
699 (last-slash (mh-search-from-end ?/ name))
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
700 ;; nil if + or +folder; +folder/ if slash present.
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
701 (last-complete (if last-slash (substring name 0 (1+ last-slash)) nil))
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
702 ;; Either +folder/remainder, +remainder, or "".
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
703 (remainder (cond (last-complete (substring name (1+ last-slash)))
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
704 (name (substring name 1))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
705 (t ""))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
706 (cond ((eq flag nil)
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
707 (let ((try-res
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
708 (try-completion
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
709 name
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
710 (mapcar (lambda (x)
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
711 (cons (concat (or last-complete "+") (car x))
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
712 (cdr x)))
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
713 (mh-sub-folders last-complete t))
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
714 predicate)))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
715 (cond ((eq try-res nil) nil)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
716 ((and (eq try-res t) (equal name orig-name)) t)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
717 ((eq try-res t) name)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
718 (t try-res))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
719 ((eq flag t)
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
720 (mapcar (lambda (x)
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
721 (concat (or last-complete "+") x))
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
722 (all-completions
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
723 remainder (mh-sub-folders last-complete t) predicate)))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
724 ((eq flag 'lambda)
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
725 (let ((path (concat (unless (and (> (length name) 1)
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
726 (eq (aref name 1) ?/))
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
727 mh-user-path)
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
728 (substring name 1))))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
729 (cond (mh-allow-root-folder-flag (file-exists-p path))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
730 ((equal path mh-user-path) nil)
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
731 (t (file-exists-p path))))))))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
732
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
733 ;; Shush compiler.
70028
d81780942bb8 * mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents: 70027
diff changeset
734 (defvar completion-root-regexp) ; XEmacs
d81780942bb8 * mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents: 70027
diff changeset
735 (defvar minibuffer-completing-file-name) ; XEmacs
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
736
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
737 (defun mh-folder-completing-read (prompt default allow-root-folder-flag)
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
738 "Read folder name with PROMPT and default result DEFAULT.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
739 If ALLOW-ROOT-FOLDER-FLAG is non-nil then \"+\" is allowed to be
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
740 a folder name corresponding to `mh-user-path'."
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
741 (mh-normalize-folder-name
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
742 (let ((completion-root-regexp "^[+/]")
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
743 (minibuffer-local-completion-map mh-folder-completion-map)
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
744 (mh-allow-root-folder-flag allow-root-folder-flag))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
745 (completing-read prompt 'mh-folder-completion-function nil nil nil
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
746 'mh-folder-hist default))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
747 t))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
748
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
749 ;;;###mh-autoload
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
750 (defun mh-prompt-for-folder (prompt default can-create
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
751 &optional default-string allow-root-folder-flag)
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
752 "Prompt for a folder name with PROMPT.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
753 Returns the folder's name as a string. DEFAULT is used if the
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
754 folder exists and the user types return. If the CAN-CREATE flag
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
755 is t, then a folder is created if it doesn't already exist. If
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
756 optional argument DEFAULT-STRING is non-nil, use it in the prompt
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
757 instead of DEFAULT. If ALLOW-ROOT-FOLDER-FLAG is non-nil then the
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
758 function will accept the folder +, which means all folders when
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
759 used in searching."
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
760 (if (null default)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
761 (setq default ""))
65681
4312387e37c8 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64085
diff changeset
762 (let* ((default-string (cond (default-string (format " (default %s)" default-string))
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
763 ((equal "" default) "")
65681
4312387e37c8 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64085
diff changeset
764 (t (format " (default %s)" default))))
4312387e37c8 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64085
diff changeset
765 (prompt (format "%s folder%s: " prompt default-string))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
766 (mh-current-folder-name mh-current-folder)
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
767 read-name folder-name)
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
768 (while (and (setq read-name (mh-folder-completing-read
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
769 prompt default allow-root-folder-flag))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
770 (equal read-name "")
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
771 (equal default "")))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
772 (cond ((or (equal read-name "")
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
773 (and (equal read-name "+") (not allow-root-folder-flag)))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
774 (setq read-name default))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
775 ((not (mh-folder-name-p read-name))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
776 (setq read-name (format "+%s" read-name))))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
777 (if (or (not read-name) (equal "" read-name))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
778 (error "No folder specified"))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
779 (setq folder-name read-name)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
780 (cond ((and (> (length folder-name) 0)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
781 (eq (aref folder-name (1- (length folder-name))) ?/))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
782 (setq folder-name (substring folder-name 0 -1))))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
783 (let* ((last-slash (mh-search-from-end ?/ folder-name))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
784 (parent (and last-slash (substring folder-name 0 last-slash)))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
785 (child (if last-slash
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
786 (substring folder-name (1+ last-slash))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
787 (substring folder-name 1))))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
788 (unless (member child
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
789 (mapcar #'car (gethash parent mh-sub-folders-cache)))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
790 (mh-remove-from-sub-folders-cache folder-name)))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
791 (let ((new-file-flag
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
792 (not (file-exists-p (mh-expand-file-name folder-name)))))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
793 (cond ((and new-file-flag
67857
226904e7d40b (mh-prompt-for-folder): Use can-create argument to suppress creation
Bill Wohler <wohler@newt.com>
parents: 67852
diff changeset
794 can-create
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
795 (y-or-n-p
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
796 (format "Folder %s does not exist. Create it? "
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
797 folder-name)))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
798 (message "Creating %s" folder-name)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
799 (mh-exec-cmd-error nil "folder" folder-name)
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
800 (mh-remove-from-sub-folders-cache folder-name)
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
801 (when (boundp 'mh-speed-folder-map)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
802 (mh-speed-add-folder folder-name))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
803 (message "Creating %s...done" folder-name))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
804 (new-file-flag
67857
226904e7d40b (mh-prompt-for-folder): Use can-create argument to suppress creation
Bill Wohler <wohler@newt.com>
parents: 67852
diff changeset
805 (error "Folder %s does not exist" folder-name))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
806 ((not (file-directory-p (mh-expand-file-name folder-name)))
68013
bbc0e52abce5 * mh-alias.el (mh-alias-add-alias): Grand message and error string
Bill Wohler <wohler@newt.com>
parents: 67988
diff changeset
807 (error "%s is not a directory"
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
808 (mh-expand-file-name folder-name)))))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
809 folder-name))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
810
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
811
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
812
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
813 ;;; Message Utilities
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
814
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
815 ;; Functions that would ordinarily be in mh-letter.el that are needed
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
816 ;; by mh-show.el are found here in order to prevent the loading of
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
817 ;; mh-letter.el until a message is actually composed.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
818
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
819 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
820 (defun mh-in-header-p ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
821 "Return non-nil if the point is in the header of a draft message."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
822 (< (point) (mh-mail-header-end)))
68163
3b7532a82079 * mh-search.el: New file containing contents of mh-index.el and
Bill Wohler <wohler@newt.com>
parents: 68137
diff changeset
823
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
824 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
825 (defun mh-extract-from-header-value ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
826 "Extract From: string from header."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
827 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
828 (if (not (mh-goto-header-field "From:"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
829 nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
830 (skip-chars-forward " \t")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
831 (buffer-substring-no-properties
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
832 (point) (progn (mh-header-field-end)(point))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
833
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
834 ;;;###mh-autoload
68477
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
835 (defun mh-get-header-field (field)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
836 "Find and return the body of FIELD in the mail header.
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
837 Returns the empty string if the field is not in the header of the
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
838 current buffer."
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
839 (if (mh-goto-header-field field)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
840 (progn
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
841 (skip-chars-forward " \t") ;strip leading white space in body
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
842 (let ((start (point)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
843 (mh-header-field-end)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
844 (buffer-substring-no-properties start (point))))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
845 ""))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
846
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
847 ;;;###mh-autoload
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
848 (defun mh-goto-header-field (field)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
849 "Move to FIELD in the message header.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
850 Move to the end of the FIELD name, which should end in a colon.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
851 Returns t if found, nil if not."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
852 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
853 (let ((case-fold-search t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
854 (headers-end (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
855 (mh-goto-header-end 0)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
856 (point))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
857 (re-search-forward (format "^%s" field) headers-end t)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
858
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
859 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
860 (defun mh-goto-header-end (arg)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
861 "Move the cursor ARG lines after the header."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
862 (if (re-search-forward "^-*$" nil nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
863 (forward-line arg)))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
864
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
865 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
866 (defun mh-mail-header-end ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
867 "Substitute for `mail-header-end' that doesn't widen the buffer.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
868
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
869 In MH-E we frequently need to find the end of headers in nested
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
870 messages, where the buffer has been narrowed. This function works
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
871 in this situation."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
872 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
873 ;; XXX: The following replaces a call to rfc822-goto-eoh. Occasionally,
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
874 ;; mail headers that MH-E has to read contains lines of the form:
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
875 ;; From xxx@yyy Mon May 10 11:48:07 2004
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
876 ;; In this situation, rfc822-goto-eoh doesn't go to the end of the
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
877 ;; header. The replacement allows From_ lines in the mail header.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
878 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
879 (loop for p = (re-search-forward
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
880 "^\\([:\n]\\|[^: \t\n]+[ \t\n]\\)" nil 'move)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
881 do (cond ((null p) (return))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
882 (t (goto-char (match-beginning 0))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
883 (unless (looking-at "From ") (return))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
884 (goto-char p))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
885 (point)))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
886
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
887 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
888 (defun mh-header-field-beginning ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
889 "Move to the beginning of the current header field.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
890 Handles RFC 822 continuation lines."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
891 (beginning-of-line)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
892 (while (looking-at "^[ \t]")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
893 (forward-line -1)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
894
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
895 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
896 (defun mh-header-field-end ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
897 "Move to the end of the current header field.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
898 Handles RFC 822 continuation lines."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
899 (forward-line 1)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
900 (while (looking-at "^[ \t]")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
901 (forward-line 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
902 (backward-char 1)) ;to end of previous line
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
903
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
904 ;;;###mh-autoload
68477
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
905 (defun mh-letter-hide-all-skipped-fields ()
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
906 "Hide all skipped fields."
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
907 (save-excursion
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
908 (goto-char (point-min))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
909 (save-restriction
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
910 (narrow-to-region (point) (mh-mail-header-end))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
911 (while (re-search-forward mh-letter-header-field-regexp nil t)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
912 (if (mh-letter-skipped-header-field-p (match-string 1))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
913 (mh-letter-toggle-header-field-display -1)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
914 (mh-letter-toggle-header-field-display 'long))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
915 (beginning-of-line 2)))))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
916
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
917 ;;;###mh-autoload
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
918 (defun mh-letter-skipped-header-field-p (field)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
919 "Check if FIELD is to be skipped."
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
920 (let ((field (downcase field)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
921 (loop for x in mh-compose-skipped-header-fields
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
922 when (equal (downcase x) field) return t
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
923 finally return nil)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
924
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
925 (defvar mh-hidden-header-keymap
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
926 (let ((map (make-sparse-keymap)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
927 (mh-do-in-gnu-emacs
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
928 (define-key map [mouse-2] 'mh-letter-toggle-header-field-display-button))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
929 (mh-do-in-xemacs
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
930 (define-key map '(button2)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
931 'mh-letter-toggle-header-field-display-button))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
932 map))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
933
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
934 ;;;###mh-autoload
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
935 (defun mh-letter-toggle-header-field-display (arg)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
936 "Toggle display of header field at point.
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
937
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
938 Use this command to display truncated header fields. This command
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
939 is a toggle so entering it again will hide the field. This
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
940 command takes a prefix argument ARG: if negative then the field
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
941 is hidden, if positive then the field is displayed."
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
942 (interactive (list nil))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
943 (when (and (mh-in-header-p)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
944 (progn
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
945 (end-of-line)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
946 (re-search-backward mh-letter-header-field-regexp nil t)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
947 (let ((buffer-read-only nil)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
948 (modified-flag (buffer-modified-p))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
949 (begin (point))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
950 end)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
951 (end-of-line)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
952 (setq end (1- (if (re-search-forward "^[^ \t]" nil t)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
953 (match-beginning 0)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
954 (point-max))))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
955 (goto-char begin)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
956 ;; Make it clickable...
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
957 (add-text-properties begin end `(keymap ,mh-hidden-header-keymap
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
958 mouse-face highlight))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
959 (unwind-protect
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
960 (cond ((or (and (not arg)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
961 (text-property-any begin end 'invisible 'vanish))
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
962 (and (numberp arg)
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
963 (>= arg 0))
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
964 (and (eq arg 'long)
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
965 (> (mh-line-beginning-position 5) end)))
68477
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
966 (remove-text-properties begin end '(invisible nil))
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
967 (search-forward ":" (mh-line-end-position) t)
68477
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
968 (mh-letter-skip-leading-whitespace-in-header-field))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
969 ;; XXX Redesign to make usable by user. Perhaps use a positive
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
970 ;; numeric prefix to make that many lines visible.
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
971 ((eq arg 'long)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
972 (end-of-line 4)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
973 (mh-letter-truncate-header-field end)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
974 (beginning-of-line))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
975 (t (end-of-line)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
976 (mh-letter-truncate-header-field end)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
977 (beginning-of-line)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
978 (set-buffer-modified-p modified-flag)))))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
979
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
980 ;;;###mh-autoload
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
981 (defun mh-letter-skip-leading-whitespace-in-header-field ()
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
982 "Skip leading whitespace in a header field.
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
983 If the header field doesn't have at least one space after the
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
984 colon then a space character is added."
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
985 (let ((need-space t))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
986 (while (memq (char-after) '(?\t ?\ ))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
987 (forward-char)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
988 (setq need-space nil))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
989 (when need-space (insert " "))))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
990
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
991 (defun mh-letter-truncate-header-field (end)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
992 "Replace text from current line till END with an ellipsis.
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
993 If the current line is too long truncate a part of it as well."
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
994 (let ((max-len (min (window-width) 62)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
995 (when (> (+ (current-column) 4) max-len)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
996 (backward-char (- (+ (current-column) 5) max-len)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
997 (when (> end (point))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
998 (add-text-properties (point) end '(invisible vanish)))))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
999
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
1000 ;;;###mh-autoload
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1001 (defun mh-signature-separator-p ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1002 "Return non-nil if buffer includes \"^-- $\"."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1003 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1004 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1005 (re-search-forward mh-signature-separator-regexp nil t)))
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
1006
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1007 (provide 'mh-utils)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1008
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1009 ;; Local Variables:
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1010 ;; indent-tabs-mode: nil
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1011 ;; sentence-end-double-space: nil
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1012 ;; End:
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1013
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1014 ;; arch-tag: 1af39fdf-f66f-4b06-9b48-18a7656c8e36
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1015 ;;; mh-utils.el ends here