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