Debian Codegraph @

contrib/mew-nmz-fixer.el

raw ◀ ▶
1 Debian patch touch this file
•1 ;; -*- mode: Emacs-Lisp -*-
2 ;;
3 ;;; mew-nmz-fixer.el
4 ;;
5 ;; Author: Hideyuki SHIRAI <[email protected]>
6 ;; Created: 2001-01-14(Sun)
7 ;;
8 ;; nmz-mew-summary-fixer.pl $B$r;H$C$F!"(Bpack $B$d(B sort $B$7$?8e$K(B
9 ;; mew-nmz $B7O(B Namazu index $B$r:G?7$KJ]$A$^$9!#(B
10 ;;
11 ;;; nmz-mew-summary-fixer.pl $B$O(B Rei FURUKAWA $B$5$s(B <[email protected]>
12 ;;; $B$,:n@.$7$?(B message $B$H(B index $B$NBP1~99?7(B Program $B$G$9!#(B
13 ;;
14 ;;
15 ;;;; $B;H$$J}(B ($B$^$:(B mew-nmz $B$r;H$($k$h$&$K$7$F$*$-$^$7$g$&(B)
16 ;; (eval-after-load "mew-nmz" '(require 'mew-nmz-fixer))
17 ;;
18
19 (eval-when-compile
20 (require 'mew)
21 (require 'mew-nmz))
22
23 ;;;; $B$3$s$J46$8$G(B key $B$K(B bind $B$9$k$bNI$7!#(B
24
25 (add-hook 'mew-summary-mode-hook
26 (lambda ()
27 (define-key mew-summary-mode-map "zf" 'mew-nmz-fixer-exec)))
28
29 ;; add-hook
30 (add-hook 'mew-sort-hook 'mew-nmz-fixer-exec)
31 (add-hook 'mew-pack-hook 'mew-nmz-fixer-exec)
32
33 ;; variable
34 (defvar mew-nmz-prog-fixer "nmz-mew-summary-fixer.pl"
35 "*nmz-mew-summary-fixer.pl $B$N(B Program $BL>!#(B
36 Windows $B$N?M$O(B \"nmz-mew-summary-fixer\" $B$N$h$&$K3HD%;R$rL5$/$7$?J}$,9,$;$+$b!#(B")
37
38 (defvar mew-nmz-prog-fixer-args
39 (if (memq system-type '(OS/2 emx windows-nt))
40 '("--windows-drive") '())
41 "*nmz-mew-summary-fixer.pl $B$KM?$($k(B option$B!#(B")
42
43 ;; internal variable
44 (defvar mew-nmz-fixer-process nil)
45 (make-variable-buffer-local 'mew-nmz-fixer-process)
46
47 ;; function
48 (defun mew-nmz-fixer-exec (&optional arg)
49 "Sort/Pack $B$N8e$G(B \"mew-nmz-summary-fixer\" $B$r5/F0$9$k!#(B
50 \"Another fixer running.\" $B$H$$$o$l$F:$$C$?$H$-$O!"(B'\\[universal-argument]' $BIU$-$G8F$S$^$7$g$&!#(B"
51 (interactive "P")
52 (mew-summary-only
53 (let* ((interactive-p (interactive-p))
54 (fld (if interactive-p
55 (mew-input-folder (mew-sinfo-get-case)
56 (mew-summary-folder-name))
57 (mew-summary-folder-name)))
58 (fixer (if (fboundp 'mew-which-exec)
59 (mew-which-exec mew-nmz-prog-fixer)
60 (mew-which mew-nmz-prog-fixer exec-path)))
61 (args mew-nmz-prog-fixer-args)
62 nmzdir)
63 (if arg
64 (progn
65 (setq mew-nmz-fixer-process nil)
66 (and interactive-p
67 (message "Set %s to free" mew-nmz-prog-fixer)))
68 (if (not (and fld fixer))
69 (and interactive-p
70 (message "Cannot exec %s" mew-nmz-prog-fixer))
71 (setq nmzdir (mew-nmz-expand-folder fld))
72 (if mew-nmz-fixer-process
73 (message "Another fixer running")
74 (if (and
75 nmzdir
76 (file-exists-p nmzdir)
77 (file-directory-p nmzdir)
78 (file-exists-p (expand-file-name "NMZ.i" nmzdir))
79 (file-exists-p (expand-file-name "NMZ.field.message-id" nmzdir))
80 (file-exists-p (expand-file-name "NMZ.field.size" nmzdir))
81 (file-exists-p (expand-file-name "NMZ.field.date" nmzdir))
82 (not (file-name-all-completions "NMZ.lock" nmzdir)))
83 (progn
84 (and interactive-p
85 (message "Exec %s (%s)..." mew-nmz-prog-fixer fld))
86 (mew-nmz-timestamp-new fld)
87 (setq mew-nmz-fixer-process
88 (apply (function start-process)
89 "nmz-fixer" (current-buffer) fixer
90 (append args
91 (list (mew-expand-folder fld) nmzdir))))
92 (set-process-sentinel mew-nmz-fixer-process 'mew-nmz-fixer-sentinel))
93 (and interactive-p
94 (message "Cannot exec %s at %s" mew-nmz-prog-fixer nmzdir)))))))))
95
96 (defun mew-nmz-fixer-sentinel (process event)
97 (save-excursion
98 (when (and (get-buffer (process-buffer process))
99 (buffer-live-p (process-buffer process)))
100 (set-buffer (process-buffer process))
101 (setq mew-nmz-fixer-process nil)
102 (mew-nmz-timestamp-rename (buffer-name))
103 (message "Exec %s (%s)...done"
104 mew-nmz-prog-fixer (buffer-name)))))
105
106 (provide 'mew-nmz-fixer)
107
108 ;;; Copyright Notice:
109
110 ;; Copyright (C) 2001 Mew developing team.
111 ;; All rights reserved.
112
113 ;; Redistribution and use in source and binary forms, with or without
114 ;; modification, are permitted provided that the following conditions
115 ;; are met:
116 ;;
117 ;; 1. Redistributions of source code must retain the above copyright
118 ;; notice, this list of conditions and the following disclaimer.
119 ;; 2. Redistributions in binary form must reproduce the above copyright
120 ;; notice, this list of conditions and the following disclaimer in the
121 ;; documentation and/or other materials provided with the distribution.
122 ;; 3. Neither the name of the team nor the names of its contributors
123 ;; may be used to endorse or promote products derived from this software
124 ;; without specific prior written permission.
125 ;;
126 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
127 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
128 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
129 ;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
130 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
131 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
132 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
133 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
134 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
135 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
136 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
137
138 ;;; mew-nmz-fixer.el ends here