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