annotate lisp/mh-e/mh-utils.el @ 79020:f59eafc3c43c

(follow-mode-hook, follow-mode): Doc fixes. (follow-mode-off-hook): Mark as obsolete.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 09 Oct 2007 08:37:26 +0000
parents 800dd75c042b
children 3c2488d0ebd9 794e428cd497 f55f9811f5d7
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,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 70059
diff changeset
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 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
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
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
78231
800dd75c042b Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
15 ;; the Free Software Foundation; either version 3, or (at your option)
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
16 ;; any later version.
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
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63531
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63531
diff changeset
26 ;; Boston, MA 02110-1301, USA.
49459
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 ;;; Commentary:
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 ;;; Change Log:
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
31
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
32 ;;; Code:
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
33
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
34 (require 'mh-e)
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
35 (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
36
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
37 (require 'font-lock)
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
38
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
39 ;;; CL Replacements
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
40
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
41 ;;;###mh-autoload
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
42 (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
43 "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
44 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
45 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
46 (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
47 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
48 finally return nil))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
49
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
50
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
51
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
52 ;;; General Utilities
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
53
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
54 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
55 (defun mh-beginning-of-word (&optional n)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
56 "Return position of the N th word backwards."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
57 (unless n (setq n 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
58 (let ((syntax-table (syntax-table)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
59 (unwind-protect
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
60 (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
61 (mh-mail-abbrev-make-syntax-table)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
62 (set-syntax-table mail-abbrev-syntax-table)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
63 (backward-word n)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
64 (point))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
65 (set-syntax-table syntax-table))))
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
66
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
67 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
68 (defun mh-colors-available-p ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
69 "Check if colors are available in the Emacs being used."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
70 (or mh-xemacs-flag
68529
7daec5f4a289 * mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68520
diff changeset
71 (let ((color-cells (mh-display-color-cells)))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
72 (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
73
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
74 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
75 (defun mh-colors-in-use-p ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
76 "Check if colors are being used in the folder buffer."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
77 (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
78
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
79 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
80 (defun mh-delete-line (lines)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
81 "Delete the next LINES lines."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
82 (delete-region (point) (progn (forward-line lines) (point))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
83
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
84 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
85 (defun mh-make-local-vars (&rest pairs)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
86 "Initialize local variables according to the variable-value PAIRS."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
87 (while pairs
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
88 (set (make-local-variable (car pairs)) (car (cdr pairs)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
89 (setq pairs (cdr (cdr pairs)))))
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
90
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
91 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
92 (defun mh-mapc (function list)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
93 "Apply FUNCTION to each element of LIST for side effects only."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
94 (while list
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
95 (funcall function (car list))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
96 (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
97
69221
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
98 (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
99 "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
100
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
101 ;;;###mh-autoload
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
102 (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
103 "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
104 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
105 (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
106 (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
107 (when (and string
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
108 (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
109 (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
110 (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
111 (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
112 (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
113 quoted-pick-expr))
7db1bc48b98c * mh-limit.el (mh-narrow-to-cc, mh-narrow-to-from)
Bill Wohler <wohler@newt.com>
parents: 69215
diff changeset
114
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
115 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
116 (defun mh-replace-string (old new)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
117 "Replace all occurrences of OLD with NEW in the current buffer.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
118 Ignores case when searching for OLD."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
119 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
120 (let ((case-fold-search t))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
121 (while (search-forward old nil t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
122 (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
123
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
124
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
125
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
126 ;;; Logo Display
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
127
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
128 (defvar mh-logo-cache nil)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
129
69492
6afc0d1f682b * mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents: 69472
diff changeset
130 ;; 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
131 (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
132
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
133 ;;;###mh-autoload
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
134 (defun mh-logo-display ()
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
135 "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
136 (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
137 (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
138 (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
139 (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
140 image-load-path))))
69245
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
141 (add-text-properties
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
142 0 2
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
143 `(display ,(or mh-logo-cache
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
144 (setq mh-logo-cache
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
145 (mh-funcall-if-exists
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
146 find-image '((:type xpm :ascent center
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
147 :file "mh-logo.xpm"))))))
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
148 (car mode-line-buffer-identification))))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
149 (mh-do-in-xemacs
69245
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
150 (setq modeline-buffer-identification
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
151 (list
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
152 (if mh-modeline-glyph
f3bbf5f32462 * mh-folder.el (mh-tool-bar-init): Autoload.
Bill Wohler <wohler@newt.com>
parents: 69221
diff changeset
153 (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
154 (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
155 (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
156
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
157
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 ;;; Read MH Profile
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
160
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
161 (defvar mh-find-path-run nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
162 "Non-nil if `mh-find-path' has been run already.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
163 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
164 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
165
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
166 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
167 (defun mh-find-path ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
168 "Set variables from user's MH profile.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
169
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
170 This function sets `mh-user-path' from your \"Path:\" MH profile
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
171 component (but defaults to \"Mail\" if one isn't present),
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
172 `mh-draft-folder' from \"Draft-Folder:\", `mh-unseen-seq' from
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
173 \"Unseen-Sequence:\", `mh-previous-seq' from
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
174 \"Previous-Sequence:\", and `mh-inbox' from \"Inbox:\" (defaults
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
175 to \"+inbox\").
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
176
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
177 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
178 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
179 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
180 MH-E."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
181 (unless mh-find-path-run
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
182 ;; Sanity checks.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
183 (if (and (getenv "MH")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
184 (not (file-readable-p (getenv "MH"))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
185 (error "MH environment variable contains unreadable file %s"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
186 (getenv "MH")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
187 (if (null (mh-variants))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
188 (error "Install MH and run install-mh before running MH-E"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
189 (let ((profile "~/.mh_profile"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
190 (if (not (file-readable-p profile))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
191 (error "Run install-mh before running MH-E")))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
192 ;; Read MH profile.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
193 (setq mh-user-path (mh-profile-component "Path"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
194 (if (not mh-user-path)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
195 (setq mh-user-path "Mail"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
196 (setq mh-user-path
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
197 (file-name-as-directory
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
198 (expand-file-name mh-user-path (expand-file-name "~"))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
199 (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
200 mh-user-path))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
201 (setq mh-draft-folder (mh-profile-component "Draft-Folder"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
202 (if mh-draft-folder
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
203 (progn
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
204 (if (not (mh-folder-name-p mh-draft-folder))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
205 (setq mh-draft-folder (format "+%s" mh-draft-folder)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
206 (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
207 (error
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
208 "Draft folder \"%s\" not found; create it and try again"
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
209 (mh-expand-file-name mh-draft-folder)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
210 (setq mh-inbox (mh-profile-component "Inbox"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
211 (cond ((not mh-inbox)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
212 (setq mh-inbox "+inbox"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
213 ((not (mh-folder-name-p mh-inbox))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
214 (setq mh-inbox (format "+%s" mh-inbox))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
215 (setq mh-unseen-seq (mh-profile-component "Unseen-Sequence"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
216 (if mh-unseen-seq
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
217 (setq mh-unseen-seq (intern mh-unseen-seq))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
218 (setq mh-unseen-seq 'unseen)) ;old MH default?
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
219 (setq mh-previous-seq (mh-profile-component "Previous-Sequence"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
220 (if mh-previous-seq
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
221 (setq mh-previous-seq (intern mh-previous-seq)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
222 (run-hooks 'mh-find-path-hook)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
223 (mh-collect-folder-names)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
224 (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
225
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
226
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
227
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
228 ;;; Help Functions
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
229
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
230 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
231 (defun mh-ephem-message (string)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
232 "Display STRING in the minibuffer momentarily."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
233 (message "%s" string)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
234 (sit-for 5)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
235 (message ""))
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-default nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
238 "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
239
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
240 (defvar mh-help-messages nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
241 "Help messages for all modes.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
242 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
243 representing the mode; the value is described in `mh-set-help'.")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
244
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
245 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
246 (defun mh-set-help (messages &optional default)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
247 "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
248
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
249 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
250 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
251 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
252 are concatenated together and displayed in a help buffer if ? is
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
253 pressed after the prefix character. The special key nil is used
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
254 to display the non-prefixed commands.
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 The substitutions described in `substitute-command-keys' are performed as
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
257 well.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
258
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
259 If optional argument DEFAULT is non-nil, then these messages will
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
260 be used if help is asked for an unknown mode."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
261 (add-to-list 'mh-help-messages (cons major-mode messages))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
262 (if default
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
263 (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
264
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
265 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
266 (defun mh-help (&optional help-messages)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
267 "Display cheat sheet for the MH-E commands.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
268 See `mh-set-help' for setting the help messages.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
269 HELP-MESSAGES are used instead if given.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
270 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
271 and displayed in a help buffer."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
272 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
273 (let* ((help (or help-messages
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
274 (cdr (assoc nil (assoc major-mode mh-help-messages)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
275 (text (substitute-command-keys (mapconcat 'identity help ""))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
276 (with-electric-help
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
277 (function
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
278 (lambda ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
279 (insert text)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
280 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
281
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
282 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
283 (defun mh-prefix-help ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
284 "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
285 (interactive)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
286 ;; 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
287 ;; 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
288 ;; 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
289 ;; 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
290 ;; from the recent keys.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
291 (let* ((keys (recent-keys))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
292 (prefix-char (elt keys (- (length keys) 2)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
293 (help (cdr (assoc prefix-char (assoc major-mode mh-help-messages)))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
294 (mh-help help)))
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
295
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
296
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
297
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
298 ;;; 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
299
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
300 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
301 (defun mh-coalesce-msg-list (messages)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
302 "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
303 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
304 Message lists passed to MH programs should be processed by this
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
305 function to avoid exceeding system command line argument limits."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
306 (let ((msgs (sort (copy-sequence messages) 'mh-greaterp))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
307 (range-high nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
308 (prev -1)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
309 (ranges nil))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
310 (while prev
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
311 (if range-high
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
312 (if (or (not (numberp prev))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
313 (not (equal (car msgs) (1- prev))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
314 (progn ;non-sequential, flush old range
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
315 (if (eq prev range-high)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
316 (setq ranges (cons range-high ranges))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
317 (setq ranges (cons (format "%s-%s" prev range-high) ranges)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
318 (setq range-high nil))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
319 (or range-high
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
320 (setq range-high (car msgs))) ;start new or first range
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
321 (setq prev (car msgs))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
322 (setq msgs (cdr msgs)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
323 ranges))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
324
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
325 (defun mh-greaterp (msg1 msg2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
326 "Return the greater of two message indicators MSG1 and MSG2.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
327 Strings are \"smaller\" than numbers.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
328 Valid values are things like \"cur\", \"last\", 1, and 1820."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
329 (if (numberp msg1)
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 (> msg1 msg2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
332 t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
333 (if (numberp msg2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
334 nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
335 (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
336
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
337 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
338 (defun mh-lessp (msg1 msg2)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
339 "Return the lesser of two message indicators MSG1 and MSG2.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
340 Strings are \"smaller\" than numbers.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
341 Valid values are things like \"cur\", \"last\", 1, and 1820."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
342 (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
343
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
344 ;;;###mh-autoload
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
345 (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
346 "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
347 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
348 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
349 (save-excursion
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
350 (beginning-of-line)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
351 (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
352 (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
353 (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
354 (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
355 (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
356 (t nil))))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
357
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
358 (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
359
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
360
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
361
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
362 ;;; 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
363
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
364 (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
365 (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
366 (defvar mh-flists-partial-line "")
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
367 (defvar mh-flists-process nil)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
368
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
369 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
370 (defun mh-clear-sub-folders-cache ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
371 "Clear `mh-sub-folders-cache'."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
372 (clrhash mh-sub-folders-cache))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
373
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
374 ;; Initialize mh-sub-folders-cache...
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
375 (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
376 "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
377 (unless mh-flists-process
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
378 (setq mh-flists-process
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
379 (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
380 "-recurse" "-fast"))))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
381
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
382 (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
383 "Read folder names.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
384 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
385 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
386 (let ((position 0)
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
387 (prevailing-match-data (match-data))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
388 line-end folder)
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
389 (unwind-protect
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
390 (while (setq line-end (string-match "\n" output position))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
391 (setq folder (format "+%s%s"
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
392 mh-flists-partial-line
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
393 (substring output position line-end)))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
394 (setq mh-flists-partial-line "")
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
395 (unless (equal (aref folder 1) ?.)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
396 (mh-populate-sub-folders-cache folder))
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
397 (setq position (1+ line-end)))
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
398 (set-match-data prevailing-match-data))
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
399 (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
400
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
401 (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
402 "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
403 (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
404 (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
405 (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
406 (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
407 (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
408 (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
409 (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
410 (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
411 finally return nil)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
412 (push (list child1) cache-entry)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
413 (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
414 (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
415 (when parent
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
416 (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
417 when (equal (car x) child2)
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
418 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
419
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
420 (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
421 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
422 return-nil-if-folder-empty)
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
423 "Normalizes FOLDER name.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
424
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
425 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
426 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
427 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
428
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
429 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
430 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
431 empty string then nothing is added.
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
432
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
433 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
434 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
435 removed.
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
436
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
437 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
438 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
439 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
440 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
441 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
442 no effect."
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
443 (cond
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
444 ((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
445 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
446 (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
447 ((stringp folder)
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
448 ;; 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
449 (while (string-match "//" folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
450 (setq folder (replace-match "/" nil t folder)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
451 (let* ((length (length folder))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
452 (trailing-slash-present (and (> length 0)
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
453 (equal (aref folder (1- length)) ?/)))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
454 (leading-slash-present (and (> length 0)
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
455 (equal (aref folder 0) ?/))))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
456 (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
457 (stringp mh-current-folder-name))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
458 (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
459 (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
460 ;; 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
461 ;; 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
462 ;; ("+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
463 ;; 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
464 ;; strings.
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
465 (let ((components (delete "" (split-string folder "/")))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
466 (result ()))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
467 ;; Remove .. and . from the pathname.
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
468 (dolist (component components)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
469 (cond ((and (equal component "..") result)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
470 (pop result))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
471 ((equal component ".."))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
472 ((equal component "."))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
473 (t (push component result))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
474 (setq folder "")
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
475 (dolist (component result)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
476 (setq folder (concat component "/" folder)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
477 ;; Remove trailing '/' if needed.
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
478 (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
479 (when (not (equal folder ""))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
480 (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
481 (when leading-slash-present
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
482 (setq folder (concat "/" folder)))))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
483 (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
484 ((equal folder "")
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
485 (setq folder "+"))
ade4a047af1b * mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents: 69273
diff changeset
486 ((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
487 (setq folder (concat "+" folder))))))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
488 folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
489
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
490 (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
491 "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
492 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
493 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
494 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
495 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
496 `(if (cdr ,folder)
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
497 t
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
498 nil))
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
499
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
500 ;;;###mh-autoload
68188
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
501 (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
502 "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
503 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
504 + 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
505 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
506 +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
507
69215
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
508 (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
509 => (\"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
510 (mh-folder-list \"+lists\")
69451
6c89c044a798 (mh-folder-list): Fix docstring (closes SF #1448498).
Bill Wohler <wohler@newt.com>
parents: 69286
diff changeset
511 => (\"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
512
ef5cd9601f14 (mh-folder-list): Fix problem with passing in a folder and getting
Bill Wohler <wohler@newt.com>
parents: 69212
diff changeset
513 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
514 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
515 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
516 (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
517 ;; 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
518 ;; 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
519 ;; 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
520 (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
521 (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
522 (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
523 (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
524 (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
525 ;; 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
526 ;; 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
527 (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
528 (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
529 (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
530 (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
531 (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
532 (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
533 (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
534 (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
535 (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
536 folder-list))
dcf226991252 * mh-search.el (mh-index-next-result-function): Add format to
Bill Wohler <wohler@newt.com>
parents: 68163
diff changeset
537
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
538 ;;;###mh-autoload
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
539 (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
540 "Find the subfolders of FOLDER.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
541 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
542 results of the actual folders call.
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
543
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
544 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
545 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
546 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
547 (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
548 (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
549 (sub-folders (cond ((eq match 'no-result)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
550 (setf (gethash folder mh-sub-folders-cache)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
551 (mh-sub-folders-actual folder)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
552 (t match))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
553 (if add-trailing-slash-flag
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
554 (mapcar #'(lambda (x)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
555 (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
556 sub-folders)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
557 sub-folders)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
558
70059
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
559 ;; 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
560 ;; 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
561 ;; 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
562 ;; 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
563 ;; 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
564 ;; 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
565 (defun mh-sub-folders-actual (folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
566 "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
567 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
568 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
569 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
570 (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
571 (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
572 nil (t nil) nil "-noheader" "-norecurse" "-nototal"
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
573 ,@(if (stringp folder) (list folder) ())))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
574 (results ())
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
575 (current-folder (concat
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
576 (with-temp-buffer
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
577 (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
578 nil '(t nil) nil "-fast")
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
579 (buffer-substring (point-min) (1- (point-max))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
580 "+")))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
581 (with-temp-buffer
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
582 (apply #'call-process arg-list)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
583 (goto-char (point-min))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
584 (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
585 (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
586 (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
587 (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
588 (mh-line-beginning-position) t)))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
589 (when (integerp has-pos)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
590 (while (equal (char-after has-pos) ? )
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
591 (decf has-pos))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
592 (incf has-pos)
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
593 (while (equal (char-after start-pos) ? )
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
594 (incf start-pos))
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
595 (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
596 (first-char (aref name 0))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
597 (last-char (aref name (1- (length name)))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
598 (unless (member first-char '(?. ?# ?,))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
599 (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
600 (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
601 (push
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
602 (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
603 (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
604 results))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
605 (forward-line 1))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
606 (setq results (nreverse results))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
607 (when (stringp folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
608 (setq results (cdr results))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
609 (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
610 (setq results (mapcar (lambda (f)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
611 (cons (substring (car f) folder-name-len)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
612 (cdr f)))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
613 results))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
614 results))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
615
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
616 ;;;###mh-autoload
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
617 (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
618 "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
619 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
620 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
621 well.
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
622
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
623 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
624 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
625 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
626 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
627 +foo/bar!"
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
628 (remhash folder mh-sub-folders-cache)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
629 (block ancestor-found
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
630 (let ((parent folder)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
631 (one-ancestor-found nil)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
632 last-slash)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
633 (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
634 (setq parent (substring parent 0 last-slash))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
635 (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
636 (remhash parent mh-sub-folders-cache)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
637 (if one-ancestor-found
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
638 (return-from ancestor-found)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
639 (setq one-ancestor-found t))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
640 (remhash nil mh-sub-folders-cache))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
641
68465
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
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
644 ;;; Folder Utilities
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
645
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
646 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
647 (defun mh-folder-name-p (name)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
648 "Return non-nil if NAME is the name of a folder.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
649 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
650 with \"+\"."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
651 (if (symbolp name)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
652 (eq (aref (symbol-name name) 0) ?+)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
653 (and (> (length name) 0)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
654 (eq (aref name 0) ?+))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
655
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
656 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
657 (defun mh-expand-file-name (filename &optional default)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
658 "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
659 Any filename that starts with '+' is treated as a folder name.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
660 See `expand-file-name' for description of DEFAULT."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
661 (if (mh-folder-name-p filename)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
662 (expand-file-name (substring filename 1) mh-user-path)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
663 (expand-file-name filename default)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
664
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
665 (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
666
57c4e7929f99 * mh-alias.el (mh-alias-gecos-name): Use replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents: 68013
diff changeset
667 ;; 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
668 (defvar mh-speed-flists-cache)
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
669
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
670 (defvar mh-allow-root-folder-flag nil
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
671 "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
672 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
673 `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
674 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
675
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
676 This variable should never be set.")
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
677
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
678 (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
679 (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
680
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
681 (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
682
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
683 ;;;###mh-autoload
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
684 (defun mh-speed-flists-active-p ()
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
685 "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
686 (and (featurep 'mh-speed)
56406
d36b00b98db0 Upgraded to MH-E version 7.4.4.
Bill Wohler <wohler@newt.com>
parents: 52401
diff changeset
687 (not mh-speed-flists-inhibit-flag)
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
688 (> (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
689
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
690 ;;;###mh-autoload
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
691 (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
692 "Programmable completion for folder names.
67758
6b063593fdad Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents: 67756
diff changeset
693 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
694 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
695 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
696 `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
697 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
698 (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
699 ;; 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
700 ;; 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
701 (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
702 (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
703 ;; 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
704 (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
705 ;; Either +folder/remainder, +remainder, or "".
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
706 (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
707 (name (substring name 1))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
708 (t ""))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
709 (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
710 (let ((try-res
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
711 (try-completion
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
712 name
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
713 (mapcar (lambda (x)
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
714 (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
715 (cdr x)))
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
716 (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
717 predicate)))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
718 (cond ((eq try-res nil) nil)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
719 ((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
720 ((eq try-res t) name)
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
721 (t try-res))))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
722 ((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
723 (mapcar (lambda (x)
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
724 (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
725 (all-completions
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
726 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
727 ((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
728 (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
729 (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
730 mh-user-path)
9028ccec5e38 (mh-sub-folders-actual): Mention that folder must have been processed
Bill Wohler <wohler@newt.com>
parents: 70028
diff changeset
731 (substring name 1))))
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
732 (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
733 ((equal path mh-user-path) nil)
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
734 (t (file-exists-p path))))))))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
735
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
736 ;; 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
737 (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
738 (defvar minibuffer-completing-file-name) ; XEmacs
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
739
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
740 (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
741 "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
742 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
743 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
744 (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
745 (let ((completion-root-regexp "^[+/]")
56673
e9a6cbc8ca5e Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents: 56406
diff changeset
746 (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
747 (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
748 (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
749 'mh-folder-hist default))
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
750 t))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
751
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
752 ;;;###mh-autoload
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
753 (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
754 &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
755 "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
756 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
757 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
758 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
759 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
760 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
761 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
762 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
763 (if (null default)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
764 (setq default ""))
65681
4312387e37c8 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64085
diff changeset
765 (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
766 ((equal "" default) "")
65681
4312387e37c8 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64085
diff changeset
767 (t (format " (default %s)" default))))
4312387e37c8 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64085
diff changeset
768 (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
769 (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
770 read-name folder-name)
50702
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
771 (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
772 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
773 (equal read-name "")
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
774 (equal default "")))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
775 (cond ((or (equal read-name "")
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
776 (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
777 (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
778 ((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
779 (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
780 (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
781 (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
782 (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
783 (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
784 (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
785 (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
786 (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
787 (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
788 (child (if last-slash
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
789 (substring folder-name (1+ last-slash))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
790 (substring folder-name 1))))
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
791 (unless (member child
7dd3d5eae9c7 Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents: 49598
diff changeset
792 (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
793 (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
794 (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
795 (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
796 (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
797 can-create
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
798 (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
799 (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
800 folder-name)))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
801 (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
802 (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
803 (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
804 (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
805 (mh-speed-add-folder folder-name))
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
806 (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
807 (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
808 (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
809 ((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
810 (error "%s is not a directory"
49578
b35587af8747 Upgraded to MH-E version 7.2.
Bill Wohler <wohler@newt.com>
parents: 49459
diff changeset
811 (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
812 folder-name))
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
813
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
814
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
815
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
816 ;;; Message Utilities
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
817
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
818 ;; 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
819 ;; 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
820 ;; mh-letter.el until a message is actually composed.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
821
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
822 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
823 (defun mh-in-header-p ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
824 "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
825 (< (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
826
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
827 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
828 (defun mh-extract-from-header-value ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
829 "Extract From: string from header."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
830 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
831 (if (not (mh-goto-header-field "From:"))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
832 nil
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
833 (skip-chars-forward " \t")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
834 (buffer-substring-no-properties
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
835 (point) (progn (mh-header-field-end)(point))))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
836
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
837 ;;;###mh-autoload
68477
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
838 (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
839 "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
840 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
841 current buffer."
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
842 (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
843 (progn
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
844 (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
845 (let ((start (point)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
846 (mh-header-field-end)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
847 (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
848 ""))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
849
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
850 ;;;###mh-autoload
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
851 (defun mh-goto-header-field (field)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
852 "Move to FIELD in the message header.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
853 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
854 Returns t if found, nil if not."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
855 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
856 (let ((case-fold-search t)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
857 (headers-end (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
858 (mh-goto-header-end 0)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
859 (point))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
860 (re-search-forward (format "^%s" field) headers-end t)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
861
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
862 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
863 (defun mh-goto-header-end (arg)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
864 "Move the cursor ARG lines after the header."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
865 (if (re-search-forward "^-*$" nil nil)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
866 (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
867
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
868 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
869 (defun mh-mail-header-end ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
870 "Substitute for `mail-header-end' that doesn't widen the buffer.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
871
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
872 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
873 messages, where the buffer has been narrowed. This function works
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
874 in this situation."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
875 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
876 ;; XXX: The following replaces a call to rfc822-goto-eoh. Occasionally,
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
877 ;; 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
878 ;; From xxx@yyy Mon May 10 11:48:07 2004
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
879 ;; 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
880 ;; header. The replacement allows From_ lines in the mail header.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
881 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
882 (loop for p = (re-search-forward
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
883 "^\\([:\n]\\|[^: \t\n]+[ \t\n]\\)" nil 'move)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
884 do (cond ((null p) (return))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
885 (t (goto-char (match-beginning 0))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
886 (unless (looking-at "From ") (return))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
887 (goto-char p))))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
888 (point)))
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
889
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
890 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
891 (defun mh-header-field-beginning ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
892 "Move to the beginning of the current header field.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
893 Handles RFC 822 continuation lines."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
894 (beginning-of-line)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
895 (while (looking-at "^[ \t]")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
896 (forward-line -1)))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
897
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
898 ;;;###mh-autoload
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
899 (defun mh-header-field-end ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
900 "Move to the end of the current header field.
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
901 Handles RFC 822 continuation lines."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
902 (forward-line 1)
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
903 (while (looking-at "^[ \t]")
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
904 (forward-line 1))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
905 (backward-char 1)) ;to end of previous line
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
906
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
907 ;;;###mh-autoload
68477
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
908 (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
909 "Hide all skipped fields."
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
910 (save-excursion
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
911 (goto-char (point-min))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
912 (save-restriction
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
913 (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
914 (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
915 (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
916 (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
917 (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
918 (beginning-of-line 2)))))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
919
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
920 ;;;###mh-autoload
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
921 (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
922 "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
923 (let ((field (downcase field)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
924 (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
925 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
926 finally return nil)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
927
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
928 (defvar mh-hidden-header-keymap
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
929 (let ((map (make-sparse-keymap)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
930 (mh-do-in-gnu-emacs
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
931 (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
932 (mh-do-in-xemacs
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
933 (define-key map '(button2)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
934 '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
935 map))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
936
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
937 ;;;###mh-autoload
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
938 (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
939 "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
940
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
941 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
942 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
943 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
944 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
945 (interactive (list nil))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
946 (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
947 (progn
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
948 (end-of-line)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
949 (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
950 (let ((buffer-read-only nil)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
951 (modified-flag (buffer-modified-p))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
952 (begin (point))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
953 end)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
954 (end-of-line)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
955 (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
956 (match-beginning 0)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
957 (point-max))))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
958 (goto-char begin)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
959 ;; Make it clickable...
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
960 (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
961 mouse-face highlight))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
962 (unwind-protect
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
963 (cond ((or (and (not arg)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
964 (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
965 (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
966 (>= 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
967 (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
968 (> (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
969 (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
970 (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
971 (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
972 ;; 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
973 ;; 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
974 ((eq arg 'long)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
975 (end-of-line 4)
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 (t (end-of-line)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
979 (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
980 (beginning-of-line)))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
981 (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
982
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
983 ;;;###mh-autoload
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
984 (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
985 "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
986 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
987 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
988 (let ((need-space t))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
989 (while (memq (char-after) '(?\t ?\ ))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
990 (forward-char)
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
991 (setq need-space nil))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
992 (when need-space (insert " "))))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
993
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
994 (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
995 "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
996 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
997 (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
998 (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
999 (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
1000 (when (> end (point))
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
1001 (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
1002
0f44616074ba * mh-comp.el (mh-letter-hide-all-skipped-fields)
Bill Wohler <wohler@newt.com>
parents: 68465
diff changeset
1003 ;;;###mh-autoload
68465
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1004 (defun mh-signature-separator-p ()
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1005 "Return non-nil if buffer includes \"^-- $\"."
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1006 (save-excursion
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1007 (goto-char (point-min))
37d03b3298bf The Great Cleanup
Bill Wohler <wohler@newt.com>
parents: 68206
diff changeset
1008 (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
1009
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1010 (provide 'mh-utils)
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1011
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1012 ;; Local Variables:
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1013 ;; indent-tabs-mode: nil
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1014 ;; sentence-end-double-space: nil
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1015 ;; End:
49459
06b77df47802 * mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff changeset
1016
67681
3a8785724cca * mh-acros.el:
Bill Wohler <wohler@newt.com>
parents: 67656
diff changeset
1017 ;; 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
1018 ;;; mh-utils.el ends here