docs/master

view discussion.roff @ 200:c299ed65d015

Spell checked.
author markus schnalke <meillo@marmaro.de>
date Thu, 12 Jul 2012 01:18:02 +0200
parents 5cd9bacdfcd3
children 9317d789cef9
line source
1 .H0 "Discussion
2 .P
3 This main chapter discusses the practical work accomplished in the
4 mmh project.
5 It is structured along the goals set for the project.
6 The concrete work undertaken
7 is described in the examples of how the general goals were achieved.
8 The discussion compares the current version of mmh with the state of
9 nmh just before the mmh project started, i.e. fall 2011.
10 Current changes of nmh will be mentioned only as side notes.
11 .\" XXX where do I discuss the parallel development of nmh?
12 .P
13 For the reader's convenience, the structure of modern email systems
14 is depicted in the figure.
15 It illustrates the path a message takes from sender to recipient.
16 .sp
17 .KS
18 .in 2c
19 .so input/mail-agents.pic
20 .KE
21 .sp
22 .LP
23 The ellipses denote mail agents, i.e. different jobs in email processing:
24 .IP "Mail User Agent (MUA)
25 The only program the user interacts directly with.
26 It includes functions to compose new mail, display received mail,
27 and to manage the mail storage.
28 Also called \fImail client\fP.
29 .IP "Mail Submission Agent (MSA)
30 A special kind of Mail Transfer Agent, used to submit mail into the
31 mail transport system.
32 .IP "Mail Transfer Agent (MTA)
33 A node in the mail transport system.
34 Transfers incoming mail to a transport node nearer to the final destination.
35 It may be the final destination itself.
36 .IP "Mail Delivery Agent (MDA)
37 Delivers mail by storing it onto disk, usually according to a set of rules.
38 .IP "Mail Retrieval Agent (MRA)
39 Initiates the transfer of mail from a remote server to the local machine.
40 (The dashed arrow represents the pull request.)
41 .P
42 The dashed boxes represent groups that usually reside on single machines.
43 The box on the lower left represents the sender's local system.
44 The box on the upper left represents the first mail transfer node.
45 The box on the upper right represents the transfer node responsible for the
46 destination address.
47 The box on the lower right represents the recipient's local system.
48 Often, the boxes above the dotted line are servers on the Internet.
49 Many mail clients, including nmh, have all of the components below
50 the dotted line implemented.
51 Not so in mmh, which is an MUA only.
58 .\" --------------------------------------------------------------
59 .H1 "Streamlining
61 .P
62 MH once provided anything necessary for email handling.
63 The community around nmh has the similar understanding that nmh should
64 provide a complete email system.
65 In fundamental contrast, mmh shall be an MUA only.
66 I believe that the development of all-in-one mail systems is obsolete.
67 Today, email is too complex to be fully covered by a single project.
68 Such a project will not be able to excel in all aspects.
69 Instead, the aspects of email should be covered by multiple projects,
70 which then can be combined to form a complete system.
71 Excellent implementations for the various aspects of email already exist.
72 Just to name three examples: Postfix is a specialized MTA,
73 .\" XXX homepages verlinken
74 Procmail is a specialized MDA, and Fetchmail is a specialized MRA.
75 I believe that it is best to use such specialized tools instead of
76 providing the same function again as a side-component in the project.
77 .\" XXX mail agent picture here
78 .P
79 Doing something well requires focusing on a small set of specific aspects.
80 Under the assumption that development focussed on a particular area
81 produces better results there, specialized projects will be superior
82 in their field of focus.
83 Hence, all-in-one mail system projects \(en no matter if monolithic
84 or modular \(en will never be the best choice in any of the fields.
85 Even in providing the best consistent all-in-one system, they are likely
86 to be beaten by projects that focus only on integrating existing mail
87 components to create a homogeneous system.
88 .P
89 The limiting resource in the community development of free software
90 is usually man power.
91 .\" XXX FIXME ref!
92 If the development power is spread over a large development area,
93 it becomes even more difficult to compete with the specialists in the
94 various fields.
95 The concrete situation for MH-based mail systems is even tougher,
96 given their small and aged community, concerning both developers and users.
97 .P
98 In consequence, I believe that the available development resources
99 should focus on the point where MH is most unique.
100 This is clearly the user interface \(en the MUA.
101 Peripheral parts should be removed to streamline mmh for the MUA task.
104 .H2 "Mail Transfer Facilities
105 .Id mail-transfer-facilities
106 .P
107 In contrast to nmh, which also provides mail submission and mail retrieval
108 agents, mmh is an MUA only.
109 This general difference initiated the development of mmh.
110 The removal of the mail transfer facilities was the first work task
111 in the mmh project.
112 .P
113 Focusing on one mail agent role only, is motivated by Eric Allman's
114 experience with Sendmail.
115 He identified the limitation of Sendmail to the MTA task as one reason for
116 its success:
117 .[ [
118 costales sendmail
119 .], p. xviii]
120 .QS
121 Second, I limited myself to the routing function \(en
122 I wouldn't write user agents or delivery back-ends.
123 This was a departure of the dominant through of the time,
124 in which routing logic, local delivery, and often the network code
125 were incorporated directly into the user agents.
126 .QE
127 .P
128 In nmh, the MSA is called \fIMessage Transfer Service\fP (MTS).
129 This facility, implemented by the
130 .Pn post
131 command, established network connections and spoke SMTP to submit
132 messages to be relayed to the outside world.
133 The changes in email demanded changes in this part of nmh as well.
134 Encryption and authentication for network connections
135 needed to be supported, hence TLS and SASL were introduced into nmh.
136 This added complexity to nmh without improving it in its core functions.
137 Also, keeping up with recent developments in the field of
138 mail transfer requires development power and specialists.
139 In mmh, this whole facility was simply cut off.
140 .Ci f6aa95b724fd8c791164abe7ee5468bf5c34f226
141 .Ci fecd5d34f65597a4dfa16aeabea7d74b191532c3
142 .Ci 156d35f6425bea4c1ed3c4c79783dc613379c65b
143 Instead, mmh depends on an external MSA.
144 The only outgoing interface available to mmh is the
145 .Pn sendmail
146 command, which almost any MSA provides.
147 If not, a wrapper program can be written.
148 It must read the message from the standard input, extract the
149 recipient addresses from the message header, and hand the message
150 over to the MSA.
151 For example, a wrapper script for qmail would be:
152 .VS
153 #!/bin/sh
154 exec qmail-inject # ignore command line arguments
155 VE
156 The requirement to parse the recipient addresses out of the message header
157 is likely to be removed in the future.
158 Then mmh would pass the recipient addresses as command line arguments.
159 This appears to be the better interface.
160 .\" XXX implement it
161 .P
162 To retrieve mail, the
163 .Pn inc
164 command acted as an MRA.
165 It established network connections
166 and spoke POP3 to retrieve mail from remote servers.
167 As with mail submission, the network connections required encryption and
168 authentication, thus TLS and SASL were added.
169 Support for message retrieval through IMAP will soon become necessary
170 additions, too, and likewise for any other changes in mail transfer.
171 Not so for mmh because it has dropped the support for retrieving mail
172 from remote locations.
173 .Ci ab7b48411962d26439f92f35ed084d3d6275459c
174 Instead, it depends on an external tool to cover this task.
175 Mmh has two paths for messages to enter mmh's mail storage:
176 (1) Mail can be incorporated with
177 .Pn inc
178 from the system maildrop, or (2) with
179 .Pn rcvstore
180 by reading them, one at a time, from the standard input.
181 .P
182 With the removal of the MSA and MRA, mmh converted from an all-in-one
183 mail system to being an MUA only.
184 Now, of course, mmh depends on third-party software.
185 An external MSA is required to transfer mail to the outside world;
186 an external MRA is required to retrieve mail from remote machines.
187 Excellent implementations of such software exist,
188 which likely are superior than the internal version.
189 Additionally, the best suiting programs can be freely chosen.
190 .P
191 As it had already been possible to use an external MSA or MRA,
192 why not keep the internal version for convenience?
193 .\" XXX ueberleitung
194 The question whether there is sense in having a fall-back pager in all
195 the command line tools, for the cases when
196 .Pn more
197 or
198 .Pn less
199 are not available, appears to be ridiculous.
200 Of course, MSAs and MRAs are more complex than text pagers
201 and not necessarily available but still the concept of orthogonal
202 design holds: ``Write programs that do one thing and do it well.''
203 .[
204 mcilroy unix phil
205 p. 53
206 .]
207 .[
208 mcilroy bstj foreword
209 .]
210 Here, this part of the Unix philosophy was applied not only
211 to the programs but to the project itself.
212 In other words:
213 Develop projects that focus on one thing and do it well.
214 Projects which have grown complex should be split, for the same
215 reasons that programs which have grown complex should be split.
216 If it is conceptionally more elegant to have the MSA and MRA as
217 separate projects then they should be separated.
218 In my opinion, this is the case here.
219 The RFCs propose this separation by clearly distinguishing the different
220 mail handling tasks [RFC\|821].
221 The small interfaces between the mail agents support the separation.
222 .P
223 Email once had been small and simple.
224 At that time,
225 .Pn /bin/mail
226 had covered everything there was to email and still was small and simple.
227 Later, the essential complexity of email increased.
228 (Essential complexity is the complexity defined by the problem itself.\0
229 .[[
230 brooks no silver bullet
231 .]])
232 Email systems reacted to this change: they grew.
233 RFCs started to introduce the concept of mail agents to separate the
234 various tasks because they became more extensive and new tasks appeared.
235 As the mail systems grew even more, parts were split off.
236 For instance, a POP server was included in the original MH;
237 it was removed in nmh.
238 Now is the time to go one step further and split off the MSA and MRA, too.
239 Not only does this decrease the code size of the project,
240 more importantly, it unburdens mmh of the whole field of
241 message transfer with all its implications for the project.
242 There is no more need for concern with changes in network transfer.
243 This independence is gained by depending on an external program
244 that covers the field.
245 Today, this is a reasonable exchange.
246 .P
247 .\" XXX ueberleitung ???
248 Functionality can be added in three different ways:
249 .LI 1
250 Implementing the function in the project itself.
251 .LI 2
252 Depending on a library that provides the function.
253 .LI 3
254 Depending on a program that provides the function.
255 .LP
256 .\" XXX Rework sentence
257 While implementing the function in the project itself leads to the
258 largest increase in code size and requires the most maintenance
259 and development work,
260 it increases the project's independence of other software the most.
261 Using libraries or external programs requires less maintenance work
262 but introduces dependencies on external software.
263 Programs have the smallest interfaces and provide the best separation,
264 but possibly limit the information exchange.
265 External libraries are more strongly connected than external programs,
266 thus information can be exchanged in a more flexible manner.
267 Adding code to a project increases maintenance work.
268 .\" XXX ref
269 Implementing complex functions in the project itself adds
270 a lot of code.
271 This should be avoided if possible.
272 Hence, the dependencies only change in their character,
273 not in their existence.
274 In mmh, library dependencies on
275 .Pn libsasl2
276 and
277 .Pn libcrypto /\c
278 .Pn libssl
279 were traded against program dependencies on an MSA and an MRA.
280 This also meant trading build-time dependencies against run-time
281 dependencies.
282 Besides providing stronger separation and greater flexibility,
283 program dependencies also allowed
284 over 6\|000 lines of code to be removed from mmh.
285 This made mmh's code base about 12\|% smaller.
286 Reducing the project's code size by such an amount without actually
287 losing functionality is a convincing argument.
288 Actually, as external MSAs and MRAs are likely superior to the
289 project's internal versions, the common user even gains functionality.
290 .P
291 Users of MH should not have problems setting up an external MSA and MRA.
292 Also, the popular MSAs and MRAs have large communities and a lot
293 of available documentation.
294 Choices for MSAs range from full-featured MTAs such as
295 .\" XXX refs
296 .I Postfix ,
297 over mid-size MTAs such as
298 .I masqmail
299 and
300 .I dma ,
301 to small forwarders such as
302 .I ssmtp
303 and
304 .I nullmailer .
305 Choices for MRAs include
306 .I fetchmail ,
307 .I getmail ,
308 .I mpop
309 and
310 .I fdm .
313 .H2 "Non-MUA Tools
314 .P
315 One goal of mmh is to remove the tools that are not part of the MUA's task.
316 Furthermore, any tools that do not significantly improve the MUA's job
317 should be removed.
318 Loosely related and rarely used tools distract from the lean appearance.
319 They require maintenance work without adding much to the core task.
320 By removing these tools, the project shall become more streamlined
321 and focused.
322 In mmh, the following tools are not available anymore:
323 .BU
324 .Pn conflict
325 was removed
326 .Ci 8b235097cbd11d728c07b966cf131aa7133ce5a9
327 because it is a mail system maintenance tool that is not MUA-related.
328 It even checked
329 .Fn /etc/passwd
330 and
331 .Fn /etc/group
332 for consistency, which is completely unrelated to email.
333 A tool like
334 .Pn conflict
335 is surely useful, but it should not be shipped with mmh.
336 .\" XXX historic reasons?
337 .BU
338 .Pn rcvtty
339 was removed
340 .Ci 14767c94b3827be7c867196467ed7aea5f6f49b0
341 because its use case of writing to the user's terminal
342 on reception of mail is obsolete.
343 If users like to be informed of new mail, the shell's
344 .Ev MAILPATH
345 variable or graphical notifications are technically more appealing.
346 Writing directly to terminals is hardly ever desired today.
347 If, though, one prefers this approach, the standard tool
348 .Pn write
349 can be used in a way similar to:
350 .VS
351 scan -file - | write `id -un`
352 VE
353 .BU
354 .Pn viamail
355 .\" XXX was macht viamail
356 was removed
357 .Ci eda72d6a7a7c20ff123043fb7f19c509ea01f932
358 when the new attachment system was activated, because
359 .Pn forw
360 could then cover the task itself.
361 The program
362 .Pn sendfiles
363 was rewritten as a shell script wrapper around
364 .Pn forw .
365 .Ci 0e82199cf3c991a173e0ac8aa776efdb3ded61e6
366 .BU
367 .Pn msgchk
368 .\" XXX was macht msgchk
369 was removed
370 .Ci bb9360ead7eb7a3fedcce2eeedfc660014e41dbe ,
371 because it lost its use case when POP support was removed.
372 A call to
373 .Pn msgchk
374 provided hardly more information than:
375 .VS
376 ls -l /var/mail/meillo
377 VE
378 It did distinguish between old and new mail, but
379 these details can be retrieved with
380 .Pn stat (1),
381 too.
382 A small shell script could be written to print the information
383 in a similar way, if truly necessary.
384 As mmh's
385 .Pn inc
386 only incorporates mail from the user's local maildrop,
387 and thus no data transfers over slow networks are involved,
388 there is hardly any need to check for new mail before incorporating it.
389 .BU
390 .Pn msh
391 was removed
392 .Ci 916690191222433a6923a4be54b0d8f6ac01bd02
393 because the tool was in conflict with the philosophy of MH.
394 It provided an interactive shell to access the features of MH,
395 but it was not just a shell tailored to the needs of mail handling.
396 Instead, it was one large program that had several MH tools built in.
397 This conflicts with the major feature of MH of being a tool chest.
398 .Pn msh 's
399 main use case had been accessing Bulletin Boards, which have ceased to
400 be popular.
401 .P
402 Removing
403 .Pn msh
404 together with the truly archaic code relicts
405 .Pn vmh
406 and
407 .Pn wmh
408 saved more than 7\|000 lines of C code \(en
409 about 15\|% of the project's original source code amount.
410 Having less code \(en with equal readability, of course \(en
411 for the same functionality is an advantage.
412 Less code means less bugs and less maintenance work.
413 As
414 .Pn rcvtty
415 and
416 .Pn msgchk
417 are assumed to be rarely used and can be implemented in different ways,
418 why should one keep them?
419 Removing them streamlines mmh.
420 .Pn viamail 's
421 use case is now partly obsolete and partly covered by
422 .Pn forw ,
423 hence there's no reason to still maintain it.
424 .Pn conflict
425 is not related to the mail client, and
426 .Pn msh
427 conflicts with the basic concept of MH.
428 These two tools might still be useful, but they should not be part of mmh.
429 .P
430 Finally, there is
431 .Pn slocal .
432 .Pn slocal
433 is an MDA and thus not directly MUA-related.
434 It should be removed from mmh, because including it conflicts with
435 the idea that mmh is an MUA only.
436 .Pn slocal
437 should rather become a separate project.
438 However,
439 .Pn slocal
440 provides rule-based processing of messages, like filing them into
441 different folders, which is otherwise not available in mmh.
442 Although
443 .Pn slocal
444 neither pulls in dependencies, nor does it include a separate
445 technical area (cf. Sec.
446 .Cf mail-transfer-facilities ),
447 it still accounts for about 1\|000 lines of code that need to be maintained.
448 As
449 .Pn slocal
450 is almost self-standing, it should be split off into a separate project.
451 This would cut the strong connection between the MUA mmh and the MDA
452 .Pn slocal .
453 For anyone not using MH,
454 .Pn slocal
455 would become yet another independent MDA, like
456 .I procmail .
457 Then
458 .Pn slocal
459 could be installed without the complete MH system.
460 Likewise, mmh users could decide to use
461 .I procmail
462 without having a second, unused MDA,
463 .Pn slocal ,
464 installed.
465 That appears to be conceptionally the best solution.
466 Yet,
467 .Pn slocal
468 is not split off.
469 I defer the decision over
470 .Pn slocal
471 out of a need for deeper investigation.
472 In the meanwhile, it remains part of mmh.
473 However, its continued existence is not significant because
474 .Pn slocal
475 is unrelated to the rest of the project.
479 .H2 "Displaying Messages
480 .Id mhshow
481 .P
482 Since the very beginning, already in the first concept paper,
483 .\" XXX ref!!!
484 .Pn show
485 had been MH's message display program.
486 .Pn show
487 mapped message numbers and sequences to files and invoked
488 .Pn mhl
489 to have the files formatted.
490 With MIME, this approach was not sufficient anymore.
491 MIME messages can consist of multiple parts. Some parts are not
492 directly displayable and text content might be encoded in
493 foreign charsets.
494 .Pn show 's
495 understanding of messages and
496 .Pn mhl 's
497 display capabilities could not cope with the task any longer.
498 .P
499 Instead of extending these tools, additional tools were written from
500 scratch and added to the MH tool chest.
501 Doing so is encouraged by the tool chest approach.
502 Modular design is a great advantage for extending a system,
503 as new tools can be added without interfering with existing ones.
504 First, the new MIME features were added in form of the single program
505 .Pn mhn .
506 The command
507 .Cl "mhn -show 42
508 would show the MIME message numbered 42.
509 With the 1.0 release of nmh in February 1999, Richard Coleman finished
510 the split of
511 .Pn mhn
512 into a set of specialized tools, which together covered the
513 multiple aspects of MIME.
514 One of them was
515 .Pn mhshow ,
516 which replaced
517 .Cl "mhn -show" .
518 It was capable of displaying MIME messages appropriately.
519 .P
520 From then on, two message display tools were part of nmh,
521 .Pn show
522 and
523 .Pn mhshow .
524 To ease the life of users,
525 .Pn show
526 was extended to automatically hand the job over to
527 .Pn mhshow
528 if displaying the message would be beyond
529 .Pn show 's
530 abilities.
531 In consequence, the user would simply invoke
532 .Pn show
533 (possibly through
534 .Pn next
535 or
536 .Pn prev )
537 and get the message printed with either
538 .Pn show
539 or
540 .Pn mhshow ,
541 whatever was more appropriate.
542 .P
543 Having two similar tools for essentially the same task is redundant.
544 Usually, users would not distinguish between
545 .Pn show
546 and
547 .Pn mhshow
548 in their daily mail reading.
549 Having two separate display programs was therefore mainly unnecessary
550 from a user's point of view.
551 Besides, the development of both programs needed to be in sync,
552 to ensure that the programs behaved in a similar way,
553 because they were used like a single tool.
554 Different behavior would have surprised the user.
555 .P
556 Today, non-MIME messages are rather seen to be a special case of
557 MIME messages, although it is the other way round.
558 As
559 .Pn mhshow
560 had already been able to display non-MIME messages, it appeared natural
561 to drop
562 .Pn show
563 in favor of using
564 .Pn mhshow
565 exclusively.
566 .Ci 4c1efddfd499300c7e74263e57d8aa137e84c853
567 Removing
568 .Pn show
569 is no loss in function, because functionally
570 .Pn mhshow
571 covers it completely.
572 The old behavior of
573 .Pn show
574 can still be emulated with the simple command line:
575 .VS
576 mhl `mhpath c`
577 VE
578 .P
579 For convenience,
580 .Pn mhshow
581 was renamed to
582 .Pn show
583 after
584 .Pn show
585 was gone.
586 It is clear that such a rename may confuse future developers when
587 trying to understand the history.
588 Nevertheless, I consider the convenience on the user's side,
589 to call
590 .Pn show
591 when they want a message to be displayed, to outweigh the inconvenience
592 on the developer's side when understanding the project history.
593 .P
594 To prepare for the transition,
595 .Pn mhshow
596 was reworked to behave more like
597 .Pn show
598 first.
599 (cf. Sec.
600 .Cf mhshow )
601 .\" XXX code commits?
602 Once the tools behaved more alike, the replacing appeared to be
603 even more natural.
604 Today, mmh's new
605 .Pn show
606 has become the one single message display program once more,
607 with the difference
608 that today it handles MIME messages as well as non-MIME messages.
609 The outcome of the transition is one program less to maintain,
610 no second display program for users to deal with,
611 and less system complexity.
612 .P
613 Still, removing the old
614 .Pn show
615 hurts in one regard: It had been such a simple program.
616 Its lean elegance is missing from the new
617 .Pn show ,
618 .\" XXX
619 however there is no alternative;
620 supporting MIME demands higher essential complexity.
622 .ig
623 XXX
624 Consider including text on scan listings here
626 Scan listings shall not contain body content. Hence, removed this feature.
627 Scan listings shall operator on message headers and non-message information
628 only. Displaying the beginning of the body complicates everything too much.
629 That's no surprise, because it's something completely different. If you
630 want to examine the body, then use show(1)/mhshow(1).
631 Changed the default scan formats accordingly.
632 .Ci 70b2643e0da8485174480c644ad9785c84f5bff4
633 ..
638 .H2 "Configure Options
639 .P
640 Customization is a double-edged sword.
641 It allows better suiting setups, but not for free.
642 There is the cost of code complexity to be able to customize.
643 There is the cost of less tested setups, because there are
644 more possible setups and especially corner cases.
645 Additionally, there is the cost of choice itself.
646 The code complexity directly affects the developers.
647 Less tested code affects both users and developers.
648 The problem of choice affects the users, for once by having to choose,
649 but also by more complex interfaces that require more documentation.
650 Whenever options add few advantages but increase the complexity of the
651 system, they should be considered for removal.
652 I have reduced the number of project-specific configure options from
653 fifteen to three.
655 .U3 "Mail Transfer Facilities
656 .P
657 With the removal of the mail transfer facilities five configure
658 options vanished:
659 .P
660 The switches
661 .Sw --with-tls
662 and
663 .Sw --with-cyrus-sasl
664 had activated the support for transfer encryption and authentication.
665 .\" XXX cf
666 .\" XXX gruende kurz wiederholen
667 This is not needed anymore.
668 .Ci fecd5d34f65597a4dfa16aeabea7d74b191532c3
669 .Ci 156d35f6425bea4c1ed3c4c79783dc613379c65b
670 .P
671 .\" XXX cf
672 .\" XXX ``For the same reason ...''
673 The configure switch
674 .Sw --enable-pop
675 activated the message retrieval facility.
676 The code area that would be conditionally compiled in for TLS and SASL
677 support had been small.
678 The conditionally compiled code area for POP support had been much larger.
679 Whereas the code base changes would only slightly change on toggling
680 TLS or SASL support, it changed much on toggling POP support.
681 The changes in the code base could hardly be overviewed.
682 By having POP support togglable, a second code base had been created,
683 one that needed to be tested.
684 This situation is basically similar for the conditional TLS and SASL
685 code, but there the changes are minor and can yet be overviewed.
686 Still, conditional compilation of a code base creates variations
687 of the original program.
688 More variations require more testing and maintenance work.
689 .P
690 Two other options only specified default configuration values:
691 .Sw --with-mts
692 defined the default transport service.
693 .Ci f6aa95b724fd8c791164abe7ee5468bf5c34f226
694 With
695 .Sw --with-smtpservers
696 default SMTP servers could be specified.
697 .Ci 128545e06224233b7e91fc4c83f8830252fe16c9
698 Both of them became irrelevant when the SMTP transport service was removed.
699 .\" XXX code ref
700 In mmh, all messages are handed over to
701 .Pn sendmail
702 for transportation.
705 .U3 "Backup Prefix
706 .P
707 The backup prefix is the string that was prepended to message
708 filenames to tag them as deleted.
709 By default it had been the comma character (`\fL,\fP').
710 .\" XXX Zeitlich ordnen
711 In July 2000, Kimmo Suominen introduced
712 the configure option
713 .Sw --with-hash-backup
714 to change the default to the hash character `\f(CW#\fP'.
715 The choice was probably personal preference, because first, the
716 option was named
717 .Sw --with-backup-prefix.
718 and had the prefix character as argument.
719 But giving the hash character as argument caused too many problems
720 for Autoconf,
721 thus the option was limited to use the hash character as the default prefix.
722 This supports the assumption, that the choice for the hash was
723 personal preference only.
724 Being related or not, words that start with the hash character
725 introduce a comment in the Unix shell.
726 Thus, the command line
727 .Cl "rm #13 #15
728 calls
729 .Pn rm
730 without arguments because the first hash character starts the comment
731 that reaches until the end of the line.
732 To delete the backup files,
733 .Cl "rm ./#13 ./#15"
734 needs to be used.
735 Using the hash as backup prefix can be seen as a precaution against
736 data loss.
737 .P
738 First, I removed the configure option but added the profile entry
739 .Pe backup-prefix ,
740 which allows to specify an arbitrary string as backup prefix.
741 .Ci 6c40d481d661d532dd527eaf34cebb6d3f8ed086
742 Profile entries are the common method to change mmh's behavior.
743 This change did not remove the choice but moved it to a location where
744 it suited better.
745 .P
746 Eventually, however, the new trash folder concept
747 (cf. Sec.
748 .Cf trash-folder )
749 removed the need for the backup prefix completely.
750 .Ci 8edc5aaf86f9f77124664f6801bc6c6cdf258173
751 .Ci ca0b3e830b86700d9e5e31b1784de2bdcaf58fc5
754 .U3 "Editor and Pager
755 .P
756 The two configure options
757 .CW --with-editor=EDITOR
758 .CW --with-pager=PAGER
759 were used to specify the default editor and pager at configure time.
760 Doing so at configure time made sense in the eighties,
761 when the set of available editors and pagers varied much across
762 different systems.
763 Today, the situation is more homogeneous.
764 The programs
765 .Pn vi
766 and
767 .Pn more
768 can be expected to be available on every Unix system,
769 as they are specified by POSIX since two decades.
770 (The specifications for
771 .Pn vi
772 and
773 .Pn more
774 appeared in
775 .[
776 posix 1987
777 .]
778 and,
779 .[
780 posix 1992
781 .]
782 respectively.)
783 As a first step, these two tools were hard-coded as defaults.
784 .Ci 5d43a99db70c12a673028c7758c20cbe3e13ef5f
785 Not changed were the
786 .Pe editor
787 and
788 .Pe moreproc
789 profile entries, which allowed the user to override the system defaults.
790 Later, the concept was reworked to respect the standard environment
791 variables
792 .Ev VISUAL
793 and
794 .Ev PAGER
795 if they are set.
796 Today, mmh determines the editor to use in the following order,
797 taking the first available and non-empty item:
798 .LI 1
799 Environment variable
800 .Ev MMHEDITOR
801 .LI 2
802 Profile entry
803 .Pe Editor
804 .LI 3
805 Environment variable
806 .Ev VISUAL
807 .LI 4
808 Environment variable
809 .Ev EDITOR
810 .LI 5
811 Command
812 .Pn vi .
813 .LP
814 .Ci f85f4b7ae62e3d05a945dcd46ead51f0a2a89a9b
815 .P
816 The pager to use is determined in a similar order,
817 also taking the first available and non-empty item:
818 .LI 1
819 Environment variable
820 .Ev MMHPAGER
821 .LI 2
822 Profile entry
823 .Pe Pager
824 (replaces
825 .Pe moreproc )
826 .LI 3
827 Environment variable
828 .Ev PAGER
829 .LI 4
830 Command
831 .Pn more .
832 .LP
833 .Ci 0c4214ea2aec6497d0d67b436bbee9bc1d225f1e
834 .P
835 By respecting the
836 .Ev VISUAL /\c
837 .Ev EDITOR
838 and
839 .Ev PAGER
840 environment variables,
841 the new behavior confirms better to the common style on Unix systems.
842 Additionally, the new approach is more uniform and clearer to users.
845 .U3 "ndbm
846 .P
847 .Pn slocal
848 used to depend on
849 .I ndbm ,
850 a database library.
851 The database is used to store the `\fLMessage-ID\fP's of all
852 messages delivered.
853 This enables
854 .Pn slocal
855 to suppress delivering the same message to the same user twice.
856 (This features was enabled by the
857 .Sw -suppressdup
858 switch.)
859 .P
860 A variety of versions of the database library exist.
861 .[
862 wolter unix incompat notes dbm
863 .]
864 Complicated autoconf code was needed to detect them correctly.
865 Furthermore, the configure switches
866 .Sw --with-ndbm=ARG
867 and
868 .Sw --with-ndbmheader=ARG
869 were added to help with difficult setups that would
870 not be detected automatically or correctly.
871 .P
872 By removing the suppress duplicates feature of
873 .Pn slocal ,
874 the dependency on
875 .I ndbm
876 vanished and 120 lines of complex autoconf code could be saved.
877 .Ci ecd6d6a20cb7a1507e3a20d6c4cb3a1cf14c6bbf
878 The change removed functionality too, but that is minor to the
879 improvement by dropping the dependency and the complex autoconf code.
880 .\" XXX argument: slocal ist sowieso nicht teil vom mmh kern
882 .U3 "mh-e Support
883 .P
884 The configure option
885 .Sw --disable-mhe
886 was removed when the mh-e support was reworked.
887 Mh-e is the Emacs front-end to MH.
888 It requires MH to provide minor additional functions.
889 The
890 .Sw --disable-mhe
891 configure option could switch these extensions off.
892 After removing the support for old versions of mh-e,
893 only the
894 .Sw -build
895 switches of
896 .Pn forw
897 and
898 .Pn repl
899 are left to be mh-e extensions.
900 They are now always built in because they add little code and complexity.
901 In consequence, the
902 .Sw --disable-mhe
903 configure option was removed
904 .Ci a7ce7b4a580d77b6c2c4d980812beb589aa4c643
905 Removing the option removed a second code setup that would have
906 needed to be tested.
907 .\" XXX datum?
908 This change was first accomplished in nmh and thereafter merged into mmh.
909 .P
910 The interface changes in mmh require mh-e to be adjusted in order
911 to be able to use mmh as back-end.
912 This will require minor changes to mh-e, but removing the
913 .Sw -build
914 switches would require more rework.
916 .U3 "Masquerading
917 .P
918 The configure option
919 .Sw --enable-masquerade
920 could take up to three arguments:
921 `draft_from', `mmailid', and `username_extension'.
922 They activated different types of address masquerading.
923 All of them were implemented in the SMTP-speaking
924 .Pn post
925 command, which provided an MSA.
926 Address masquerading is an MTA's task and mmh does not cover
927 this field anymore.
928 Hence, true masquerading needs to be implemented in the external MTA.
929 .P
930 The
931 .I mmailid
932 masquerading type is the oldest one of the three and the only one
933 available in the original MH.
934 It provided a
935 .I username
936 to
937 .I fakeusername
938 mapping, based on the password file's GECOS field.
939 The man page
940 .Mp mh-tailor (5)
941 described the use case as being the following:
942 .QS
943 This is useful if you want the messages you send to always
944 appear to come from the name of an MTA alias rather than your
945 actual account name. For instance, many organizations set up
946 `First.Last' sendmail aliases for all users. If this is
947 the case, the GECOS field for each user should look like:
948 ``First [Middle] Last <First.Last>''
949 .QE
950 .P
951 As mmh sends outgoing mail via the local MTA only,
952 the best location to do such global rewrites is there.
953 Besides, the MTA is conceptionally the right location because it
954 does the reverse mapping for incoming mail (aliasing), too.
955 Furthermore, masquerading set up there is readily available for all
956 mail software on the system.
957 Hence, mmailid masquerading was removed.
958 .Ci 0836c8000ccb34b59410ef1c15b1b7feac70ce5f
959 .P
960 The
961 .I username_extension
962 masquerading type did not replace the username but would append a suffix,
963 specified by the
964 .Ev USERNAME_EXTENSION
965 environment variable, to it.
966 This provided support for the
967 .I user-extension
968 feature of qmail and the similar
969 .I "plussed user
970 processing of sendmail.
971 The decision to remove this username_extension masquerading was
972 motivated by the fact that
973 .Pn spost
974 had not supported it already.
975 .Ci 2abae0bfd0ad5bf898461e50aa4b466d641f23d9
976 Username extensions are possible in mmh, but less convenient to use.
977 .\" XXX covered by next paragraph
978 .\" XXX format file %(getenv USERNAME_EXTENSION)
979 .P
980 The
981 .I draft_from
982 masquerading type instructed
983 .Pn post
984 to use the value of the
985 .Hd From
986 header field as SMTP envelope sender.
987 Sender addresses could be replaced completely.
988 .Ci b14ea6073f77b4359aaf3fddd0e105989db9
989 Mmh offers a kind of masquerading similar in effect, but
990 with technical differences.
991 As mmh does not transfer messages itself, the local MTA has final control
992 over the sender's address. Any masquerading mmh introduces may be reverted
993 by the MTA.
994 In times of pedantic spam checking, an MTA will take care to use
995 sensible envelope sender addresses to keep its own reputation up.
996 Nonetheless, the MUA can set the
997 .Hd From
998 header field and thereby propose
999 a sender address to the MTA.
1000 The MTA may then decide to take that one or generate the canonical sender
1001 address for use as envelope sender address.
1002 .P
1003 In mmh, the MTA will always extract the recipient and sender from the
1004 message header (\c
1005 .Pn sendmail 's
1006 .Sw -t
1007 switch).
1008 The
1009 .Hd From
1010 header field of the draft may be set arbitrary by the user.
1011 If it is missing, the canonical sender address will be generated by the MTA.
1013 .U3 "Remaining Options
1014 .P
1015 Two configure options remain in mmh.
1016 One is the locking method to use:
1017 .Sw --with-locking=[dot|fcntl|flock|lockf] .
1018 The idea of removing all methods except the portable dot locking
1019 and having that one as the default is appealing, but this change
1020 requires deeper technical investigation into the topic.
1021 The other option,
1022 .Sw --enable-debug ,
1023 compiles the programs with debugging symbols and does not strip them.
1024 This option is likely to stay.
1029 .H2 "Command Line Switches
1030 .P
1031 The command line switches of MH tools is similar to the X Window style.
1032 .\" XXX ref
1033 They are words, introduced by a single dash.
1034 For example:
1035 .Cl "-truncate" .
1036 Every program in mmh has two generic switches:
1037 .Sw -help ,
1038 to print a short message on how to use the program, and
1039 .Sw -Version
1040 (with capital `V'), to tell what version of mmh the program belongs to.
1041 .P
1042 Switches change the behavior of programs.
1043 Programs that do one thing in one way require no switches.
1044 In most cases, doing something in exactly one way is too limiting.
1045 If there is basically one task to accomplish, but it should be done
1046 in various ways, switches are a good approach to alter the behavior
1047 of a program.
1048 Changing the behavior of programs provides flexibility and customization
1049 to users, but at the same time it complicates the code, documentation and
1050 usage of the program.
1051 .\" XXX: Ref
1052 Therefore, the number of switches should be kept small.
1053 A small set of well-chosen switches does no harm.
1054 But usually, the number of switches increases over time.
1055 Already in 1985, Rose and Romine have identified this as a major
1056 problem of MH:
1057 .[ [
1058 rose romine real work
1059 .], p. 12]
1060 .QS
1061 A complaint often heard about systems which undergo substantial development
1062 by many people over a number of years, is that more and more options are
1063 introduced which add little to the functionality but greatly increase the
1064 amount of information a user needs to know in order to get useful work done.
1065 This is usually referred to as creeping featurism.
1066 .QP
1067 Unfortunately MH, having undergone six years of off-and-on development by
1068 ten or so well-meaning programmers (the present authors included),
1069 suffers mightily from this.
1070 .QE
1071 .P
1072 Being reluctant to adding new switches \(en or `options',
1073 as Rose and Romine call them \(en is one part of a counter-action,
1074 the other part is removing hardly used switches.
1075 Nmh's tools had lots of switches already implemented,
1076 hence, cleaning up by removing some of them was the more important part
1077 of the counter-action.
1078 Removing existing functionality is always difficult because it
1079 breaks programs that use these functions.
1080 Also, for every obsolete feature, there'll always be someone who still
1081 uses it and thus opposes its removal.
1082 This puts the developer into the position,
1083 where sensible improvements to style are regarded as destructive acts.
1084 Yet, living with the featurism is far worse, in my eyes, because
1085 future needs will demand adding further features,
1086 worsening the situation more and more.
1087 Rose and Romine added in a footnote,
1088 ``[...]
1089 .Pn send
1090 will no doubt acquire an endless number of switches in the years to come.''
1091 Although clearly humorous, the comment points to the nature of the problem.
1092 Refusing to add any new switches would encounter the problem at its root,
1093 but this is not practical.
1094 New needs will require new switches and it would be unwise to block
1095 them strictly.
1096 Nevertheless, removing obsolete switches still is an effective approach
1097 to deal with the problem.
1098 Working on an experimental branch without an established user base,
1099 eased my work because I did not offend users when I removed existing
1100 functions.
1101 .P
1102 Rose and Romine counted 24 visible and 9 more hidden switches for
1103 .Pn send .
1104 In nmh, they increased up to 32 visible and 12 hidden ones.
1105 At the time of writing, no more than 4 visible switches and 1 hidden switch
1106 have remained in mmh's
1107 .Pn send .
1108 These numbers include two generic switches,
1109 .Sw -help
1110 and
1111 .Sw -Version .
1112 Hidden switches are ones not documented.
1113 In mmh, 12 tools have hidden switches.
1114 9 of them are
1115 .Sw -debug
1116 switches, the other 6 provide special interfaces for internal use.
1117 .P
1118 The figure displays the number of switches for each of the tools
1119 that is available in both nmh and mmh.
1120 The tools are sorted by the number of switches they had in nmh.
1121 Visible and hidden switches were counted,
1122 but not the generic help and version switches.
1123 Whereas in the beginning of the project, the average tool had 11 switches,
1124 now it has no more than 5 \(en only half as many.
1125 If the `no' switches and similar inverse variant are folded onto
1126 their counter-parts, the average tool had 8 switches in pre-mmh times and
1127 has 4 now.
1128 The total number of functional switches in mmh dropped from 465
1129 to 233.
1131 .KS
1132 .in 1c
1133 .so input/switches.grap
1134 .KE
1136 .P
1137 A part of the switches vanished after functions were removed.
1138 This was the case for network mail transfer, for instance.
1139 Sometimes, however, the work flow was the other way:
1140 I looked through the
1141 .Mp mh-chart (7)
1142 man page to identify the tools with apparently too many switches.
1143 Then considering the value of each of the switches by examining
1144 the tool's man page and source code, aided by recherche and testing.
1145 This way, the removal of functions was suggested by the aim to reduce
1146 the number of switches per command.
1149 .U3 "Draft Folder Facility
1150 .P
1151 A change early in the project was the complete transition from
1152 the single draft message to the draft folder facility.
1153 .Ci 337338b404931f06f0db2119c9e145e8ca5a9860
1154 .\" XXX ref to section ...
1155 The draft folder facility was introduced in the mid-eighties, when
1156 Rose and Romine called it a ``relatively new feature''.
1157 .[
1158 rose romine real work
1159 .]
1160 Since then, the facility had existed but was inactive by default.
1161 The default activation and the related rework of the tools made it
1162 possible to remove the
1163 .Sw -[no]draftfolder ,
1164 and
1165 .Sw -draftmessage
1166 switches from
1167 .Pn comp ,
1168 .Pn repl ,
1169 .Pn forw ,
1170 .Pn dist ,
1171 .Pn whatnow ,
1172 and
1173 .Pn send .
1174 .Ci 337338b404931f06f0db2119c9e145e8ca5a9860
1175 The only flexibility removed with this change is having multiple
1176 draft folders within one profile.
1177 I consider this a theoretical problem only.
1178 At the same time, the
1179 .Sw -draft
1180 switch of
1181 .Pn anno ,
1182 .Pn refile ,
1183 and
1184 .Pn send
1185 was removed.
1186 The special treatment of \fIthe\fP draft message became irrelevant after
1187 the rework of the draft system.
1188 (cf. Sec.
1189 .Cf draft-folder )
1190 Furthermore,
1191 .Pn comp
1192 no longer needs a
1193 .Sw -file
1194 switch as the draft folder facility together with the
1195 .Sw -form
1196 switch are sufficient.
1199 .U3 "In Place Editing
1200 .P
1201 .Pn anno
1202 had the switches
1203 .Sw -[no]inplace
1204 to either annotate the message in place and thus preserve hard links,
1205 or annotate a copy to replace the original message, breaking hard links.
1206 Following the assumption that linked messages should truly be the
1207 same message, and annotating it should not break the link, the
1208 .Sw -[no]inplace
1209 switches were removed and the previous default
1210 .Sw -inplace
1211 was made the only behavior.
1212 .Ci c8195849d2e366c569271abb0f5f60f4ebf0b4d0
1213 The
1214 .Sw -[no]inplace
1215 switches of
1216 .Pn repl ,
1217 .Pn forw ,
1218 and
1219 .Pn dist
1220 could be removed, too, as they were simply passed through to
1221 .Pn anno .
1222 .P
1223 .Pn burst
1224 also had
1225 .Sw -[no]inplace
1226 switches, but with different meaning.
1227 With
1228 .Sw -inplace ,
1229 the digest had been replaced by the table of contents (i.e. the
1230 introduction text) and the burst messages were placed right
1231 after this message, renumbering all following messages.
1232 Also, any trailing text of the digest was lost, though,
1233 in practice, it usually consists of an end-of-digest marker only.
1234 Nontheless, this behavior appeared less elegant than the
1235 .Sw -noinplace
1236 behavior, which already had been the default.
1237 Nmh's
1238 .Mp burst (1)
1239 man page reads:
1240 .QS
1241 If
1242 .Sw -noinplace
1243 is given, each digest is preserved, no table
1244 of contents is produced, and the messages contained within
1245 the digest are placed at the end of the folder. Other messages
1246 are not tampered with in any way.
1247 .QE
1248 .LP
1249 The decision to drop the
1250 .Sw -inplace
1251 behavior was supported by the code complexity and the possible data loss
1252 it caused.
1253 .Sw -noinplace
1254 was chosen to be the definitive behavior.
1255 .Ci 68a686adeb39223a5e1ad35e4a24890ec053679d
1258 .U3 "Forms and Format Strings
1259 .P
1260 Historically, the tools that had
1261 .Sw -form
1262 switches to supply a form file had
1263 .Sw -format
1264 switches as well to supply the contents of a form file as a string
1265 on the command line directly.
1266 In consequence, the following two lines equaled:
1267 .VS
1268 scan -form scan.mailx
1269 scan -format "`cat .../scan.mailx`"
1270 VE
1271 The
1272 .Sw -format
1273 switches were dropped in favor for extending the
1274 .Sw -form
1275 switches.
1276 .Ci f51956be123db66b00138f80464d06f030dbb88d
1277 If their argument starts with an equal sign (`='),
1278 then the rest of the argument is taken as a format string,
1279 otherwise the arguments is treated as the name of a format file.
1280 Thus, now the following two lines equal:
1281 .VS
1282 scan -form scan.mailx
1283 scan -form "=`cat .../scan.mailx`"
1284 VE
1285 This rework removed the prefix collision between
1286 .Sw -form
1287 and
1288 .Sw -format .
1289 Now, typing
1290 .Sw -fo
1291 suffices to specify form or format string.
1292 .P
1293 The different meaning of
1294 .Sw -format
1295 for
1296 .Pn repl
1297 and
1298 .Pn forw
1299 was removed in mmh.
1300 .Pn forw
1301 was completely switched to MIME-type forwarding, thus removing the
1302 .Sw -[no]format .
1303 .Ci 6e271608b7b9c23771523f88d23a4d3593010cf1
1304 For
1305 .Pn repl ,
1306 the
1307 .Sw -[no]format
1308 switches were reworked to
1309 .Sw -[no]filter
1310 switches.
1311 .Ci 67411b1f95d6ec987b4c732459e1ba8a8ac192c6
1312 The
1313 .Sw -format
1314 switches of
1315 .Pn send
1316 and
1317 .Pn post ,
1318 which had a third meaning,
1319 were removed likewise.
1320 .Ci f3cb7cde0e6f10451b6848678d95860d512224b9
1321 Eventually, the ambiguity of the
1322 .Sw -format
1323 switches was resolved by not anymore having any such switch in mmh.
1326 .U3 "MIME Tools
1327 .P
1328 The MIME tools, which were once part of
1329 .Pn mhn
1330 .\" XXX
1331 (whatever that stood for),
1332 had several switches that added little practical value to the programs.
1333 The
1334 .Sw -[no]realsize
1335 switches of
1336 .Pn mhbuild
1337 and
1338 .Pn mhlist
1339 were removed, doing real size calculations always now
1340 .Ci 8d8f1c3abc586c005c904e52c4adbfe694d2201c ,
1341 as nmh's
1342 .Mp mhbuild (1)
1343 man page states
1344 ``This provides an accurate count at the expense of a small delay.''
1345 This small delay is not noticable on modern systems.
1346 .P
1347 The
1348 .Sw -[no]check
1349 switches were removed together with the support for
1350 .Hd Content-MD5
1351 header fields [RFC\|1864].
1352 .Ci 31dc797eb5178970d68962ca8939da3fd9a8efda
1353 (cf. Sec.
1354 .Cf content-md5 )
1355 .P
1356 The
1357 .Sw -[no]ebcdicsafe
1358 and
1359 .Sw -[no]rfc934mode
1360 switches of
1361 .Pn mhbuild
1362 were removed because they are considered obsolete.
1363 .Ci 01a3480928da485b4d6109d36d751dfa71799d58
1364 .Ci 3363e2624dce0eb8164cf8b3f1ab385c8ff72e88
1365 .P
1366 Content caching of external MIME parts, activated with the
1367 .Sw -rcache
1368 and
1369 .Sw -wcache
1370 switches was completely removed.
1371 .Ci d1fefd9f614e4dc3cda16da6c69133c1b2005269
1372 External MIME parts are rare today, having a caching facility
1373 for them appears to be unnecessary.
1374 .P
1375 In pre-MIME times,
1376 .Pn mhl
1377 had covered many tasks that are part of MIME handling today.
1378 Therefore,
1379 .Pn mhl
1380 could be simplified to a large extend, reducing the number of its
1381 switches from 21 to 6.
1382 .Ci 350ad6d3542a07639213cf2a4fe524e829c1e7b6
1383 .Ci 0e46503be3c855bddaeae3843e1b659279c35d70
1388 .U3 "Header Printing
1389 .P
1390 .Pn folder 's
1391 data output is self-explaining enough that
1392 displaying the header line makes little sense.
1393 Hence, the
1394 .Sw -[no]header
1395 switch was removed and headers are never printed.
1396 .Ci 601cc73d1fa05ce96faa728f036d6c51b91701c7
1397 .P
1398 In
1399 .Pn mhlist ,
1400 the
1401 .Sw -[no]header
1402 switches were removed, too.
1403 .Ci b24f96523aaf60e44e04a3ffb1d22e69a13a602f
1404 But in this case headers are always printed,
1405 because the output is not self-explaining.
1406 .P
1407 .Pn scan
1408 also had
1409 .Sw -[no]header
1410 switches.
1411 Printing the header had been sensible until the introduction of
1412 format strings made it impossible to display the column headings.
1413 Only the folder name and the current date remained to be printed.
1414 As this information can be perfectly retrieved by
1415 .Pn folder
1416 and
1417 .Pn date ,
1418 consequently, the switches were removed.
1419 .Ci c477dc5d1d03fa6d9a8ab3dd3508c63cbddc044e
1420 .P
1421 By removing all
1422 .Sw -header
1423 switches, the collision with
1424 .Sw -help
1425 on the first two letters was resolved.
1426 Currently,
1427 .Sw -h
1428 evaluates to
1429 .Sw -help
1430 for all tools of mmh.
1433 .U3 "Suppressing Edits or the Invocation of the WhatNow Shell
1434 .P
1435 The
1436 .Sw -noedit
1437 switch of
1438 .Pn comp ,
1439 .Pn repl ,
1440 .Pn forw ,
1441 .Pn dist ,
1442 and
1443 .Pn whatnow
1444 was removed, but it can now be replaced by specifying
1445 .Sw -editor
1446 with an empty argument.
1447 .Ci 75fca31a5b9d5c1a99c74ab14c94438d8852fba9
1448 (Specifying
1449 .Cl "-editor /bin/true
1450 is nearly the same, only differing by the previous editor being set.)
1451 .P
1452 The more important change is the removal of the
1453 .Sw -nowhatnowproc
1454 switch.
1455 .Ci ee4f43cf2ef0084ec698e4e87159a94c01940622
1456 This switch had introduced an awkward behavior, as explained in nmh's
1457 man page for
1458 .Mp comp (1):
1459 .QS
1460 The
1461 .Sw -editor
1462 .Ar editor
1463 switch indicates the editor to use for
1464 the initial edit. Upon exiting from the editor,
1465 .Pn comp
1466 will invoke the
1467 .Pn whatnow
1468 program. See
1469 .Mp whatnow (1)
1470 for a discussion of available options.
1471 The invocation of this program can be
1472 inhibited by using the
1473 .Sw -nowhatnowproc
1474 switch. (In truth of fact, it is the
1475 .Pn whatnow
1476 program which starts the initial edit.
1477 Hence,
1478 .Sw -nowhatnowproc
1479 will prevent any edit from occurring.)
1480 .QE
1481 .P
1482 Effectively, the
1483 .Sw -nowhatnowproc
1484 switch creates only a draft message.
1485 As
1486 .Cl "-whatnowproc /bin/true
1487 causes the same behavior, the
1488 .Sw -nowhatnowproc
1489 switch was removed for being redundant.
1490 Likely, the
1491 .Sw -nowhatnowproc
1492 switch was intended to be used by front-ends.
1496 .U3 "Various
1497 .BU
1498 With the removal of MMDF maildrop format support,
1499 .Pn packf
1500 and
1501 .Pn rcvpack
1502 no longer needed their
1503 .Sw -mbox
1504 and
1505 .Sw -mmdf
1506 switches.
1507 .Sw -mbox
1508 is the sole behavior now.
1509 .Ci 3916ab66ad5d183705ac12357621ea8661afd3c0
1510 Further rework in both tools made the
1511 .Sw -file
1512 switch unnecessary.
1513 .Ci ca1023716d4c2ab890696f3e41fa0d94267a940e
1515 .BU
1516 Mmh's tools will no longer clear the screen (\c
1517 .Pn scan 's
1518 and
1519 .Pn mhl 's
1520 .Sw -[no]clear
1521 switches
1522 .Ci e57b17343dcb3ff373ef4dd089fbe778f0c7c270
1523 .Ci 943765e7ac5693ae177fd8d2b5a2440e53ce816e ).
1524 Neither will
1525 .Pn mhl
1526 ring the bell (\c
1527 .Sw -[no]bell
1528 .Ci e11983f44e59d8de236affa5b0d0d3067c192e24 )
1529 nor page the output itself (\c
1530 .Sw -length
1531 .Ci 5b9d883db0318ed2b84bb82dee880d7381f99188 ).
1532 .\" XXX Ref
1533 Generally, the pager to use is no longer specified with the
1534 .Sw -[no]moreproc
1535 command line switches for
1536 .Pn mhl
1537 and
1538 .Pn show /\c
1539 .Pn mhshow .
1540 .Ci 39e87a75b5c2d3572ec72e717720b44af291e88a
1542 .BU
1543 In order to avoid prefix collisions among switch names, the
1544 .Sw -version
1545 switch was renamed to
1546 .Sw -Version
1547 (with capital `V').
1548 .Ci 32b2354dbaf4bf934936eb5b102a4a3d2fdd209a
1549 Every program has the
1550 .Sw -version
1551 switch but its first three letters collided with the
1552 .Sw -verbose
1553 switch, present in many programs.
1554 The rename solved this problem once for all.
1555 Although this rename breaks a basic interface, having the
1556 .Sw -V
1557 abbreviation to display the version information, isn't all too bad.
1559 .BU
1560 .Sw -[no]preserve
1561 of
1562 .Pn refile
1563 was removed
1564 .Ci 8edc5aaf86f9f77124664f6801bc6c6cdf258173
1565 because what use was it anyway?
1566 Quoting nmh's man page
1567 .Mp refile (1):
1568 .QS
1569 Normally when a message is refiled, for each destination
1570 folder it is assigned the number which is one above the current
1571 highest message number in that folder. Use of the
1572 .Sw -preserv
1573 [sic!] switch will override this message renaming, and try
1574 to preserve the number of the message. If a conflict for a
1575 particular folder occurs when using the
1576 .Sw -preserve
1577 switch, then
1578 .Pn refile
1579 will use the next available message number which
1580 is above the message number you wish to preserve.
1581 .QE
1583 .BU
1584 The removal of the
1585 .Sw -[no]reverse
1586 switches of
1587 .Pn scan
1588 .Ci 8edc5aaf86f9f77124664f6801bc6c6cdf258173
1589 is a bug fix, supported by the comments
1590 ``\-[no]reverse under #ifdef BERK (I really HATE this)''
1591 by Rose and
1592 ``Lists messages in reverse order with the `\-reverse' switch.
1593 This should be considered a bug.'' by Romine in the documentation.
1594 .\" XXX Ref: welche datei genau.
1595 The question remains why neither Rose and Romine had fixed this
1596 bug in the eighties when they wrote these comments nor has anyone
1597 thereafter.
1600 .ig
1602 forw: [no]dashstuffing(mhl)
1604 mhshow: [no]pause [no]serialonly
1606 mhmail: resent queued
1607 inc: snoop, (pop)
1609 mhl: [no]faceproc folder sleep
1610 [no]dashstuffing(forw) digest list volume number issue number
1612 prompter: [no]doteof
1614 refile: [no]preserve [no]unlink [no]rmmproc
1616 send: [no]forward [no]mime [no]msgid
1617 [no]push split [no]unique (sasl) width snoop [no]dashstuffing
1618 attach attachformat
1619 whatnow: (noedit) attach
1621 slocal: [no]suppressdups
1623 spost: [no]filter [no]backup width [no]push idanno
1624 [no]check(whom) whom(whom)
1626 whom: ???
1628 ..
1631 .ig
1633 .P
1634 In the best case, all switches are unambiguous on the first character,
1635 or on the three-letter prefix for the `no' variants.
1636 Reducing switch prefix collisions, shortens the necessary prefix length
1637 the user must type.
1638 Having less switches helps best.
1640 ..
1643 .\" XXX: whatnow prompt commands
1648 .\" --------------------------------------------------------------
1649 .H1 "Modernizing
1650 .P
1651 In the more than thirty years of MH's existence, its code base was
1652 increasingly extended.
1653 New features entered the project and became alternatives to the
1654 existing behavior.
1655 Relicts from several decades have gathered in the code base,
1656 but seldom obsolete features were dropped.
1657 This section describes the removing of old code
1658 and the modernizing of the default setup.
1659 It focuses on the functional aspect only;
1660 the non-functional aspects of code style are discussed in Sec.
1661 .Cf code-style .
1664 .H2 "Code Relicts
1665 .P
1666 My position regarding the removal of obsolete functions of mmh,
1667 .\" XXX ``in order to remove old code,''
1668 is much more revolutional than the nmh community appreciates.
1669 Working on an experimental version, I was quickly able to drop
1670 functionality I considered ancient.
1671 The need for consensus with peers would have slowed this process down.
1672 Without the need to justify my decisions, I was able to rush forward.
1673 In December 2011, Paul Vixie motivated the nmh developers to just
1674 .\" XXX ugs
1675 do the work:
1676 .[
1677 paul vixie edginess nmh-workers
1678 .]
1679 .QS
1680 let's stop walking on egg shells with this code base. there's no need to
1681 discuss whether to keep using vfork, just note in [sic!] passing, [...]
1682 we don't need a separate branch for removing vmh
1683 or ridding ourselves of #ifdef's or removing posix replacement functions
1684 or depending on pure ansi/posix ``libc''.
1685 .QP
1686 these things should each be a day or two of work and the ``main branch''
1687 should just be modern. [...]
1688 let's push forward, aggressively.
1689 .QE
1690 .LP
1691 I did so already in the months before.
1692 I pushed forward.
1693 .\" XXX semicolon ?
1694 I simply dropped the cruft.
1695 .P
1696 The decision to drop a feature was based on literature research and
1697 careful thinking, but whether having had contact with this particular
1698 feature within my own computer life served as a rule of thumb.
1699 I explained my reasons in the commit messages
1700 in the version control system.
1701 Hence, others can comprehend my view and argue for undoing the change
1702 if I have missed an important aspect.
1703 I was quick in dropping parts.
1704 I rather include falsely dropped parts again, than going at a slower pace.
1705 Mmh is experimental work; it requires tough decisions.
1706 .\" XXX ``exp. work'' schon oft gesagt
1709 .U3 "Forking
1710 .P
1711 Being a tool chest, MH creates many processes.
1712 In earlier times
1713 .Fu fork()
1714 had been an expensive system call, because the process's image needed
1715 to be completely duplicated at once.
1716 This expensive work was especially unnecessary in the commonly occurring
1717 case wherein the image is replaced by a call to
1718 .Fu exec()
1719 right after having forked the child process.
1720 The
1721 .Fu vfork()
1722 system call was invented to speed up this particular case.
1723 It completely omits the duplication of the image.
1724 On old systems this resulted in significant speed ups.
1725 Therefore MH used
1726 .Fu vfork()
1727 whenever possible.
1728 .P
1729 Modern memory management units support copy-on-write semantics, which make
1730 .Fu fork()
1731 almost as fast as
1732 .Fu vfork() .
1733 The man page of
1734 .Mp vfork (2)
1735 in FreeBSD 8.0 states:
1736 .QS
1737 This system call will be eliminated when proper system sharing mechanisms
1738 are implemented. Users should not depend on the memory sharing semantics
1739 of vfork() as it will, in that case, be made synonymous to fork(2).
1740 .QE
1741 .LP
1742 Vixie supports the removal with the note that ``the last
1743 system on which fork was so slow that an mh user would notice it, was
1744 Eunice. that was 1987''.
1745 .[
1746 nmh-workers vixie edginess
1747 .]
1748 I replaced all calls to
1749 .Fu vfork()
1750 with calls to
1751 .Fu fork() .
1752 .Ci 40821f5c1316e9205a08375e7075909cc9968e7d
1753 .P
1754 Related to the costs of
1755 .Fu fork()
1756 is the probability of its success.
1757 In the eighties, on heavy loaded systems, calls to
1758 .Fu fork()
1759 were prone to failure.
1760 Hence, many of the
1761 .Fu fork()
1762 calls in the code were wrapped into loops to retry the
1763 .Fu fork()
1764 several times, to increase the chances to succeed, eventually.
1765 On modern systems, a failing
1766 .Fu fork()
1767 call is unusual.
1768 Hence, in the rare case when
1769 .Fu fork()
1770 fails, mmh programs simply abort.
1771 .Ci 5fbf37ee68e018998ada61eeab73e035b26834b6
1774 .U3 "Header Fields
1775 .BU
1776 The
1777 .Hd Encrypted
1778 header field was introduced by RFC\|822,
1779 but already marked as legacy in RFC\|2822.
1780 Today, OpenPGP provides the basis for standardized exchange of encrypted
1781 messages [RFC\|4880, RFC\|3156].
1782 Hence, the support for
1783 .Hd Encrypted
1784 header fields is removed in mmh.
1785 .Ci 064527f7b57ab050e5af13e15ad99aeeab125857
1786 .BU
1787 The native support for
1788 .Hd Face
1789 header fields has been removed, as well.
1790 .Ci 8e5be81f784682822f5e868c1bf3c8624682bd23
1791 This feature is similar to the
1792 .Hd X-Face
1793 header field in its intent,
1794 but takes a different approach to store the image.
1795 Instead of encoding the image data directly into the header field,
1796 it contains the hostname and UDP port where the image
1797 date can be retrieved.
1798 There is even a third Face system,
1799 which is the successor of
1800 .Hd X-Face ,
1801 although it re-uses the
1802 .Hd Face
1803 header field.
1804 It was invented in 2005 and supports colored PNG images.
1805 None of the Face systems described here is popular today.
1806 Hence, mmh has no direct support for them.
1807 .BU
1808 .Id content-md5
1809 The
1810 .Hd Content-MD5
1811 header field was introduced by RFC\|1864.
1812 It provides detection of data corruption during the transfer.
1813 But it can not ensure verbatim end-to-end delivery of the contents
1814 [RFC\|1864].
1815 The proper approach to verify content integrity in an
1816 end-to-end relationship is the use of digital signatures.
1817 .\" XXX (RFCs FIXME).
1818 On the other hand, transfer protocols should detect corruption during
1819 the transmission.
1820 The TCP includes a checksum field therefore.
1821 These two approaches in combinations render the
1822 .Hd Content-MD5
1823 header field superfluous.
1824 Not a single one out of 4\|200 messages from two decades
1825 in an nmh-workers mailing list archive contains a
1826 .Hd Content-MD5
1827 header field.
1828 Neither did any of the 60\|000 messages in my personal mail storage.
1829 Removing the support for this header field,
1830 removed the last place where MD5 computation was needed.
1831 .Ci 31dc797eb5178970d68962ca8939da3fd9a8efda
1832 Hence, the MD5 code could be removed as well.
1833 Over 500 lines of code vanished by this one change.
1836 .U3 "MMDF maildrop support
1837 .P
1838 This type of format is conceptionally similar to the mbox format,
1839 but uses a different message delimiter (`\fL\\1\\1\\1\\1\fP',
1840 commonly written as `\fL^A^A^A^A\fP', instead of `\fLFrom\0\fP').
1841 Mbox is the de-facto standard maildrop format on Unix,
1842 whereas the MMDF maildrop format is now forgotten.
1843 By dropping the MMDF maildrop format support,
1844 mbox became the only packed mailbox format supported in mmh.
1845 .P
1846 The simplifications within the code were moderate.
1847 Mainly, the reading and writing of MMDF mailbox files was removed.
1848 But also, switches of
1849 .Pn packf
1850 and
1851 .Pn rcvpack
1852 could be removed.
1853 .Ci 3916ab66ad5d183705ac12357621ea8661afd3c0
1854 In the message parsing function
1855 .Fn sbr/m_getfld.c ,
1856 knowledge of MMDF packed mail boxes was removed.
1857 .Ci 684ec30d81e1223a282764452f4902ed4ad1c754
1858 Further code structure simplifications may be possible there,
1859 because only one single packed mailbox format is left to be supported.
1860 I have not worked on them yet because
1861 .Fu m_getfld()
1862 is heavily optimized and thus dangerous to touch.
1863 The risk of damaging the intricate workings of the optimized code is
1864 too high.
1867 .U3 "Prompter's Control Keys
1868 .P
1869 The program
1870 .Pn prompter
1871 queries the user to fill in a message form.
1872 When used by
1873 .Pn comp
1874 as
1875 .Cl "comp -editor prompter" ,
1876 the resulting behavior is similar to
1877 .Pn mailx .
1878 Apparently,
1879 .Pn prompter
1880 had not been touched lately.
1881 Otherwise it's hardly explainable why it
1882 still offered the switches
1883 .Sw -erase
1884 .Ar chr
1885 and
1886 .Sw -kill
1887 .Ar chr
1888 to name the characters for command line editing.
1889 The times when this had been necessary are long time gone.
1890 Today these things work out-of-the-box, and if not, are configured
1891 with the standard tool
1892 .Pn stty .
1893 The switches are removed now
1894 .Ci 0bd9750710cdbab80cfb4036dd87af20afe1552f .
1897 .U3 "Hardcopy Terminal Support
1898 .P
1899 More of a funny anecdote is a check for being connected to a
1900 hardcopy terminal.
1901 It remained in the code until spring 2012, when I finally removed it
1902 .Ci b7764c4a6b71d37918a97594d866258f154017ca .
1903 .P
1904 The check only prevented a pager to be placed between the printing
1905 program (\c
1906 .Pn mhl )
1907 and the terminal.
1908 In nmh, this could have been ensured statically with the
1909 .Sw -nomoreproc
1910 at the command line, too.
1911 In mmh, setting the profile entry
1912 .Pe Pager
1913 or the environment variable
1914 .Ev PAGER
1915 to
1916 .Pn cat
1917 is sufficient.
1922 .H2 "Attachments
1923 .P
1924 The mind model of email attachments is unrelated to MIME.
1925 Although the MIME RFCs [RFC\|2045\(enRFC\|2049] define the technical
1926 requirements for having attachments, they do not mention the word
1927 attachment.
1928 Instead of attachments, MIME talks about ``multi-part message bodies''
1929 [RFC\|2045], a more general concept.
1930 Multi-part messages are messages
1931 ``in which one or more different
1932 sets of data are combined in a single body''
1933 [RFC\|2046].
1934 MIME keeps its descriptions generic;
1935 it does not imply specific usage models.
1936 One usage model became prevalent: attachments.
1937 The idea is having a main text document with files of arbitrary kind
1938 attached to it.
1939 In MIME terms, this is a multi-part message having a text part first
1940 and parts of arbitrary type following.
1941 .P
1942 MH's MIME support is a direct implementation of the RFCs.
1943 The perception of the topic described in the RFCs is clearly visible
1944 in MH's implementation.
1945 .\" XXX rewrite ``no idea''.
1946 As a result,
1947 MH had all the MIME features but no idea of attachments.
1948 But users do not need all the MIME features,
1949 they want convenient attachment handling.
1952 .U3 "Composing MIME Messages
1953 .P
1954 In order to improve the situation on the message composing side,
1955 Jon Steinhart had added an attachment system to nmh in 2002.
1956 .Ci 7480dbc14bc90f2d872d434205c0784704213252
1957 In the file
1958 .Fn docs/README-ATTACHMENTS ,
1959 he described his motivation to do so as such:
1960 .QS
1961 Although nmh contains the necessary functionality for MIME message
1962 handing [sic!], the interface to this functionality is pretty obtuse.
1963 There's no way that I'm ever going to convince my partner to write
1964 .Pn mhbuild
1965 composition files!
1966 .QE
1967 .LP
1968 With this change, the mind model of attachments entered nmh.
1969 In the same document:
1970 .QS
1971 These changes simplify the task of managing attachments on draft files.
1972 They allow attachments to be added, listed, and deleted.
1973 MIME messages are automatically created when drafts with attachments
1974 are sent.
1975 .QE
1976 .LP
1977 Unfortunately, the attachment system,
1978 like any new facilities in nmh,
1979 was inactive by default.
1980 .P
1981 During my work in Argentina, I tried to improve the attachment system.
1982 But, because of great opposition in the nmh community,
1983 my patch died as a proposal on the mailing list, after long discussions.
1984 .[
1985 nmh-workers attachment proposal
1986 .]
1987 In January 2012, I extended the patch and applied it to mmh.
1988 .Ci 8ff284ff9167eff8f5349481529332d59ed913b1
1989 In mmh, the attachment system is active by default.
1990 Instead of command line switches, the
1991 .Pe Attachment-Header
1992 profile entry is used to specify
1993 the name of the attachment header field.
1994 It is pre-defined to
1995 .Hd Attach .
1996 .P
1997 To add an attachment to a draft, a header line needs to be added:
1998 .VS
1999 To: bob
2000 Subject: The file you wanted
2001 Attach: /path/to/the/file-bob-wanted
2002 --------
2003 Here it is.
2004 VE
2005 The header field can be added to the draft manually in the editor,
2006 or by using the `attach' command at the WhatNow prompt, or
2007 non-interactively with
2008 .Pn anno :
2009 .VS
2010 anno -append -nodate -component Attach -text /path/to/attachment
2011 VE
2012 Drafts with attachment headers are converted to MIME automatically by
2013 .Pn send .
2014 The conversion to MIME is invisible to the user.
2015 The draft stored in the draft folder is always in source form with
2016 attachment headers.
2017 If the MIMEification fails (e.g. because the file to attach
2018 is not accessible) the original draft is not changed.
2019 .P
2020 The attachment system handles the forwarding of messages, too.
2021 If the attachment header value starts with a plus character (`\fL+\fP'),
2022 like in
2023 .Cl "Attach: +bob 30 42" ,
2024 the given messages in the specified folder will be attached.
2025 This allowed to simplify
2026 .Pn forw .
2027 .Ci f41f04cf4ceca7355232cf7413e59afafccc9550
2028 .P
2029 Closely related to attachments is non-ASCII text content,
2030 because it requires MIME too.
2031 In nmh, the user needed to call `mime' at the WhatNow prompt
2032 to have the draft converted to MIME.
2033 This was necessary whenever the draft contained non-ASCII characters.
2034 If the user did not call `mime', a broken message would be sent.
2035 Therefore, the
2036 .Pe automimeproc
2037 profile entry could be specified to have the `mime' command invoked
2038 automatically each time.
2039 Unfortunately, this approach conflicted with the attachment system
2040 because the draft would already be in MIME format at the time
2041 when the attachment system wanted to MIMEify it.
2042 To use nmh's attachment system, `mime' must not be called at the
2043 WhatNow prompt and
2044 .Pe automimeproc
2045 must not be set in the profile.
2046 But then the case of non-ASCII text without attachment headers was
2047 not caught.
2048 All in all, the solution was complex and irritating.
2049 My patch from December 2010
2050 .[
2051 nmh-workers attachment proposal
2052 .]
2053 would have simplified the situation.
2054 .P
2055 Mmh's current solution is even more elaborate.
2056 Any necessary MIMEification is done automatically.
2057 There is no `mime' command at the WhatNow prompt anymore.
2058 The draft will be converted automatically to MIME when either an
2059 attachment header or non-ASCII text is present.
2060 Furthermore, the hash character (`\fL#\fP') is not special any more
2061 at line beginnings in the draft message.
2062 .\" XXX REF ?
2063 Users need not concern themselves with the whole topic at all.
2064 .P
2065 Although the new approach does not anymore support arbitrary MIME
2066 compositions directly, the full power of
2067 .Pn mhbuild
2068 can still be accessed.
2069 Given no attachment headers are included, the user can create
2070 .Pn mhbuild
2071 composition drafts like in nmh.
2072 Then, at the WhatNow prompt, he needs to invoke
2073 .Cl "edit mhbuild
2074 to convert it to MIME.
2075 Because the resulting draft does neither contain non-ASCII characters
2076 nor has it attachment headers, the attachment system will not touch it.
2077 .P
2078 The approach taken in mmh is tailored towards today's most common case:
2079 a text part, possibly with attachments.
2080 This case was simplified.
2083 .U3 "MIME Type Guessing
2084 .P
2085 From the programmer's point of view, the use of
2086 .Pn mhbuild
2087 composition drafts had one notable advantage over attachment headers:
2088 The user provides the appropriate MIME types for files to include.
2089 The attachment system needs to find out the correct MIME type itself.
2090 This is a difficult task, yet it spares the user irritating work.
2091 Determining the correct MIME type of content is partly mechanical,
2092 partly intelligent work.
2093 Forcing the user to find out the correct MIME type,
2094 forces him to do partly mechanical work.
2095 Letting the computer do the work can lead to bad choices for difficult
2096 content.
2097 For mmh, the latter option was chosen.
2098 .P
2099 Determining the MIME type by the suffix of the file name is a dumb
2100 approach, yet it is simple to implement and provides good results
2101 for the common cases.
2102 Mmh implements this approach in the
2103 .Pn print-mimetype
2104 script.
2105 .Ci 4b5944268ea0da7bb30598a27857304758ea9b44
2106 Using it is the default choice.
2107 .P
2108 A far better, though less portable, approach is the use of
2109 .Pn file .
2110 This standard tool tries to determine the type of files.
2111 Unfortunately, its capabilities and accuracy varies from system to system.
2112 Additionally, its output was only intended for human beings,
2113 but not to be used by programs.
2114 It varies much.
2115 Nevertheless, modern versions of GNU
2116 .Pn file ,
2117 which is prevalent on the popular GNU/Linux systems,
2118 provide MIME type output in machine-readable form.
2119 Although this solution is highly system-dependent,
2120 it solves the difficult problem well.
2121 On systems where GNU
2122 .Pn file ,
2123 version 5.04 or higher, is available it should be used.
2124 One needs to specify the following profile entry to do so:
2125 .Ci 3baec236a39c5c89a9bda8dbd988d643a21decc6
2126 .VS
2127 Mime-Type-Query: file -b --mime
2128 VE
2129 .LP
2130 Other versions of
2131 .Pn file
2132 might possibly be usable with wrapper scripts to reformat the output.
2133 The diversity among
2134 .Pn file
2135 implementations is great; one needs to check the local variant.
2136 .P
2137 If no MIME type can be determined, text content gets sent as
2138 `text/plain' and anything else under the generic fall-back type
2139 `application/octet-stream'.
2140 It is not possible in mmh to override the automatic MIME type guessing
2141 for a specific file.
2142 To do so, either the user would need to know in advance for which file
2143 the automatic guessing fails, or the system would require interaction.
2144 I consider both cases impractical.
2145 The existing solution should be sufficient.
2146 If not, the user may always fall back to
2147 .Pn mhbuild
2148 composition drafts and ignore the attachment system.
2151 .U3 "Storing Attachments
2152 .P
2153 Extracting MIME parts of a message and storing them to disk is performed by
2154 .Pn mhstore .
2155 The program has two operation modes,
2156 .Sw -auto
2157 and
2158 .Sw -noauto .
2159 With the former one, each part is stored under the filename given in the
2160 MIME part's meta information, if available.
2161 This naming information is usually available for modern attachments.
2162 If no filename is available, this MIME part is stored as if
2163 .Sw -noauto
2164 would have been specified.
2165 In the
2166 .Sw -noauto
2167 mode, the parts are processed according to rules, defined by
2168 .Pe mhstore-store-*
2169 profile entries.
2170 These rules define generic filename templates for storing
2171 or commands to post-process the contents in arbitrary ways.
2172 If no matching rule is available the part is stored under a generic
2173 filename, built from message number, MIME part number, and MIME type.
2174 .P
2175 The
2176 .Sw -noauto
2177 mode had been the default in nmh because it was considered safe,
2178 in contrast to the
2179 .Sw -auto
2180 mode.
2181 In mmh,
2182 .Sw -auto
2183 is not dangerous anymore.
2184 Two changes were necessary:
2185 .LI 1
2186 Any directory path is removed from the proposed filename.
2187 Thus, the files are always stored in the expected directory.
2188 .Ci 41b6eadbcecf63c9a66aa5e582011987494abefb
2189 .LI 2
2190 Tar files are not extracted automatically any more.
2191 Thus, the rest of the file system will not be touched.
2192 .Ci 94c80042eae3383c812d9552089953f9846b1bb6
2193 .LP
2194 Now, the outcome of mmh's
2195 .Cl "mhstore -auto
2196 can be foreseen from the output of
2197 .Cl "mhlist -verbose" .
2198 .P
2199 The
2200 .Sw -noauto
2201 mode is seen to be more powerful but less convenient.
2202 On the other hand,
2203 .Sw -auto
2204 is safe now and
2205 storing attachments under their original name is intuitive.
2206 Hence,
2207 .Sw -auto
2208 serves better as the default option.
2209 .Ci 3410b680416c49a7617491af38bc1929855a331d
2210 .P
2211 Files are stored into the directory given by the
2212 .Pe Nmh-Storage
2213 profile entry, if set, or
2214 into the current working directory, otherwise.
2215 Storing to different directories is only possible with
2216 .Pe mhstore-store-*
2217 profile entries.
2218 .P
2219 Still, in both modes, existing files get overwritten silently.
2220 This can be considered a bug.
2221 Yet, each other behavior has its draw-backs, too.
2222 Refusing to replace files requires adding a
2223 .Sw -force
2224 option.
2225 Users will likely need to invoke
2226 .Pn mhstore
2227 a second time with
2228 .Sw -force .
2229 Eventually, only the user can decide in the specific case.
2230 This requires interaction, which I like to avoid if possible.
2231 Appending a unique suffix to the filename is another bad option.
2232 For now, the behavior remains as it is.
2233 .P
2234 In mmh, only MIME parts of type message are special in
2235 .Pn mhstore 's
2236 .Sw -auto
2237 mode.
2238 Instead of storing message/rfc822 parts as files to disk,
2239 they are stored as messages into the current mail folder.
2240 The same applies to message/partial, although the parts are
2241 automatically reassembled beforehand.
2242 MIME parts of type message/external-body are not automatically retrieved
2243 anymore.
2244 Instead, information on how to retrieve them is output.
2245 Not supporting this rare case saved nearly one thousand lines of code.
2246 .Ci 55e1d8c654ee0f7c45b9361ce34617983b454c32
2247 .\" XXX mention somewhere else too: (The profile entry `nmh-access-ftp'
2248 .\" and sbr/ruserpass.c for reading ~/.netrc are gone now.)
2249 `application/octet-stream; type=tar' is not special anymore.
2250 Automatically extracting such MIME parts had been the dangerous part
2251 of the
2252 .Sw -auto
2253 mode.
2254 .Ci 94c80042eae3383c812d9552089953f9846b1bb6
2258 .U3 "Showing MIME Messages
2259 .P
2260 The program
2261 .Pn mhshow
2262 had been written to display MIME messages.
2263 It implemented the conceptional view of the MIME RFCs.
2264 Nmh's
2265 .Pn mhshow
2266 handled each MIME part independently, presenting them separately
2267 to the user.
2268 This does not match today's understanding of email attachments,
2269 where displaying a message is seen to be a single, integrated operation.
2270 Today, email messages are expected to consist of a main text part
2271 plus possibly attachments.
2272 They are not any more seen to be arbitrary MIME hierarchies with
2273 information on how to display the individual parts.
2274 I adjusted
2275 .Pn mhshow 's
2276 behavior to the modern view on the topic.
2277 .P
2278 One should note that this section completely ignores the original
2279 .Pn show
2280 program, because it was not capable to display MIME messages
2281 and is no longer part of mmh.
2282 .\" XXX ref to other section
2283 Although
2284 .Pn mhshow
2285 was renamed to
2286 .Pn show
2287 in mmh, this section uses the name
2288 .Pn mhshow ,
2289 in order to avoid confusion.
2290 .P
2291 In mmh, the basic idea is that
2292 .Pn mhshow
2293 should display a message in one single pager session.
2294 Therefore,
2295 .Pn mhshow
2296 invokes a pager session for all its output,
2297 whenever it prints to a terminal.
2298 .Ci a4197ea6ffc5c1550e8b52d5a654bcaaaee04a4e
2299 In consequence,
2300 .Pn mhl
2301 does no more invoke a pager.
2302 .Ci 0e46503be3c855bddaeae3843e1b659279c35d70
2303 With
2304 .Pn mhshow
2305 replacing the original
2306 .Pn show ,
2307 output from
2308 .Pn mhl
2309 does not go to the terminal directly, but through
2310 .Pn mhshow .
2311 Hence,
2312 .Pn mhl
2313 does not need to invoke a pager.
2314 The one and only job of
2315 .Pn mhl
2316 is to format messages or parts of them.
2317 The only place in mmh, where a pager is invoked is
2318 .Pn mhshow .
2319 .P
2320 .Pe mhshow-show-*
2321 profile entries can be used to display MIME parts in a specific way.
2322 For instance, PDF and Postscript files could be converted to plain text
2323 to display them in the terminal.
2324 In mmh, MIME parts will always be displayed serially.
2325 The request to display the MIME type `multipart/parallel' in parallel
2326 is ignored.
2327 It is simply treated as `multipart/mixed'.
2328 .Ci d0581ba306a7299113a346f9b4c46ce97bc4cef6
2329 This could already be requested with the, now removed,
2330 .Sw -serialonly
2331 switch of
2332 .Pn mhshow .
2333 As MIME parts are always processed exclusively, i.e. serially,
2334 the `%e' escape in
2335 .Pe mhshow-show-*
2336 profile entries became useless and was thus removed.
2337 .Ci a20d405db09b7ccca74d3e8c57550883da49e1ae
2338 .P
2339 In the intended setup, only text content would be displayed.
2340 Non-text content would be converted to text by appropriate
2341 .Pe mhshow-show-*
2342 profile entries before, if possible and wanted.
2343 All output would be displayed in a single pager session.
2344 Other kinds of attachments are ignored.
2345 With
2346 .Pe mhshow-show-*
2347 profile entries for them, they can be displayed serially along
2348 the message.
2349 For parallel display, the attachments need to be stored to disk first.
2350 .P
2351 To display text content in foreign charsets, they need to be converted
2352 to the native charset.
2353 Therefore,
2354 .Pe mhshow-charset-*
2355 profile entries used to be needed.
2356 In mmh, the conversion is performed automatically by piping the
2357 text through the
2358 .Pn iconv
2359 command, if necessary.
2360 .Ci 2433122c20baccb10b70b49c04c6b0497b5b3b60
2361 Custom
2362 .Pe mhshow-show-*
2363 rules for textual content might need a
2364 .Cl "iconv -f %c %f |
2365 prefix to have the text converted to the native charset.
2366 .P
2367 Although the conversion of foreign charsets to the native one
2368 has improved, it is not consistent enough.
2369 Further work needs to be done and
2370 the basic concepts in this field need to be re-thought.
2371 Though, the default setup of mmh displays message in foreign charsets
2372 correctly without the need to configure anything.
2375 .ig
2377 .P
2378 mhshow/mhstore: Removed support for retrieving message/external-body parts.
2379 These tools will not download the contents automatically anymore. Instead,
2380 they print the information needed to get the contents. If someone should
2381 really receive one of those rare message/external-body messages, he can
2382 do the job manually. We save nearly a thousand lines of code. That's worth
2383 it!
2384 (The profile entry `nmh-access-ftp' and sbr/ruserpass.c for reading
2385 ~/.netrc are gone now.)
2386 .Ci 55e1d8c654ee0f7c45b9361ce34617983b454c32
2388 ..
2392 .H2 "Signing and Encrypting
2393 .P
2394 Nmh offers no direct support for digital signatures and message encryption.
2395 This functionality needed to be added through third-party software.
2396 In mmh, the functionality should be included because it
2397 is a part of modern email and likely wanted by users of mmh.
2398 A fresh mmh installation should support signing and encrypting
2399 out-of-the-box.
2400 Therefore, Neil Rickert's
2401 .Pn mhsign
2402 and
2403 .Pn mhpgp
2404 scripts
2405 .[
2406 neil rickert mhsign mhpgp
2407 .]
2408 were included into mmh
2409 .Ci f45cdc98117a84f071759462c7ae212f4bc5ab2e
2410 .Ci 58cf09aa36e9f7f352a127158bbf1c5678bc6ed8 .
2411 The scripts fit well because they are lightweight and
2412 similar of style to the existing tools.
2413 Additionally, no licensing difficulties appeared,
2414 as they are part of the public domain.
2415 .P
2416 .Pn mhsign
2417 handles the signing and encrypting part.
2418 It comprises about 250 lines of shell code and interfaces between
2419 .Pn gnupg
2420 and
2421 the MH system.
2422 It was meant to be invoked manually at the WhatNow prompt, but in mmh,
2423 .Pn send
2424 invokes
2425 .pn mhsign
2426 automatically
2427 .Ci c7b5e1df086bcc37ff40163ee67571f076cf6683 .
2428 Special header fields were introduced to request this action.
2429 If a draft contains the
2430 .Hd Sign
2431 header field,
2432 .Pn send
2433 will initiate the signing.
2434 The signing key is either chosen automatically or specified by the
2435 .Pe Pgpkey
2436 profile entry.
2437 .Pn send
2438 always create signatures using the PGP/MIME standard, \" REF XXX
2439 but by manually invoking
2440 .Pn mhsign ,
2441 old-style non-MIME signatures can be created as well.
2442 To encrypt an outgoing message, the draft needs to contain an
2443 .Hd Enc
2444 header field.
2445 Public keys of all recipients are searched for in the gnupg keyring and
2446 in a file called
2447 .Fn pgpkeys ,
2448 which contains exceptions and overrides.
2449 Unless public keys are found for all recipients,
2450 .Pn mhsign
2451 will refuse to encrypt it.
2452 Currently, messages with hidden (BCC) recipients can not be encrypted.
2453 This work is pending because it requires a structurally more complex
2454 approach.
2455 .P
2456 .Pn mhpgp
2457 is the companion to
2458 .Pn mhsign .
2459 It verifies signatures and decrypts messages.
2460 Encrypted messages can either be temporarily decrypted for display
2461 or permanently decrypted and stored into the current folder.
2462 Currently,
2463 .Pn mhpgp
2464 needs to be invoked manually.
2465 The integration into
2466 .Pn show
2467 and
2468 .Pn mhstore
2469 to verify signatures and decrypt messages as needs
2470 is planned but not realized yet.
2471 .P
2472 Both scripts were written for nmh, hence they needed to be adjust
2473 according to the differences between nmh and mmh.
2474 For instance, they use the backup prefix no longer.
2475 Furthermore, compatibility support for old PGP features was dropped.
2476 .P
2477 The integrated message signing and encrypting support is one of the
2478 most recent features in mmh.
2479 It has not yet had the time to mature.
2480 User feedback and personal experience need to be accumulated to
2481 direct the further development of the facility.
2482 Although the feedback and experience is still missing,
2483 it seems to be worthwhile to consider adding
2484 .Sw -[no]sign
2485 and
2486 .Sw -[no]enc
2487 switches to
2488 .Pn send ,
2489 to be able to override the corresponding header fields.
2490 A profile entry:
2491 .VS
2492 send: -sign
2493 VE
2494 would then activate signing for all outgoing messages.
2495 With the present approach, a
2496 .Hd Send
2497 header component needs to be added to each draft template
2498 to achieve the same result.
2499 Adding the switches would ease the work greatly and keep the
2500 template files clean.
2505 .H2 "Draft and Trash Folder
2506 .P
2508 .U3 "Draft Folder
2509 .Id draft-folder
2510 .P
2511 In the beginning, MH had the concept of a draft message.
2512 This is the file
2513 .Fn draft
2514 in the MH directory, which is treated special.
2515 On composing a message, this draft file was used.
2516 When starting to compose another message before the former one was sent,
2517 the user had to decide among:
2518 .LI 1
2519 Using the old draft to finish and send it before starting with a new one.
2520 .LI 2
2521 Discarding the old draft and replacing it with a new one.
2522 .LI 3
2523 Preserving the old draft by refiling it to a folder.
2524 .LP
2525 It was only possible to work in alternation on multiple drafts.
2526 Therefore, the current draft needed to be refiled to a folder and
2527 another one re-used for editing.
2528 Working on multiple drafts at the same time was impossible.
2529 The usual approach of switching to a different MH context did not
2530 help anything.
2531 .P
2532 The draft folder facility exists to
2533 allow true parallel editing of drafts, in a straight forward way.
2534 It was introduced by Marshall T. Rose, already in 1984.
2535 Similar to other new features, the draft folder was inactive by default.
2536 Even in nmh, the highly useful draft folder was not available
2537 out-of-the-box.
2538 At least, Richard Coleman added the man page
2539 .Mp mh-draft (5)
2540 to better document the feature.
2541 .P
2542 Not using the draft folder facility has the single advantage of having
2543 the draft file at a static location.
2544 This is simple in simple cases but the concept does not scale for more
2545 complex cases.
2546 The concept of the draft message is too limited for the problem.
2547 Therefore the draft folder was introduced.
2548 It is the more powerful and more natural concept.
2549 The draft folder is a folder like any other folder in MH.
2550 Its messages can be listed like any other messages.
2551 A draft message is no longer a special case.
2552 Tools do not need special switches to work on the draft message.
2553 Hence corner cases were removed.
2554 .P
2555 The trivial part of the work was activating the draft folder with a
2556 default name.
2557 I chose the name
2558 .Fn +drafts
2559 for obvious reasons.
2560 In consequence, the command line switches
2561 .Sw -draftfolder
2562 and
2563 .Sw -draftmessage
2564 could be removed.
2565 More difficult but also more improving was updating the tools to the
2566 new concept.
2567 For nearly three decades, the tools needed to support two draft handling
2568 approaches.
2569 By fully switching to the draft folder, the tools could be simplified
2570 by dropping the awkward draft message handling code.
2571 .Sw -draft
2572 switches were removed because operating on a draft message is no longer
2573 special.
2574 It became indistinguishable to operating on any other message.
2575 .Ci 337338b404931f06f0db2119c9e145e8ca5a9860
2576 .P
2577 There is no more need to query the user for draft handling
2578 .Ci 2d48b455c303a807041c35e4248955f8bec59eeb .
2579 It is always possible to add another new draft.
2580 Refiling drafts is without difference to refiling other messages.
2581 All of these special cases are gone.
2582 Yet, one draft-related switch remained.
2583 .Pn comp
2584 still has
2585 .Sw -[no]use
2586 for switching between two modes:
2587 .LI 1
2588 .Sw -use
2589 to modify an existing draft.
2590 .LI 2
2591 .Sw -nouse
2592 to compose a new draft, possibly taking some existing message as template.
2593 .LP
2594 In either case, the behavior of
2595 .Pn comp
2596 is deterministic.
2597 .P
2598 .Pn send
2599 now operates on the current message in the draft folder by default.
2600 As message and folder can both be overridden by specifying them on
2601 the command line, it is possible to send any message in the mail storage
2602 by simply specifying its number and folder.
2603 In contrast to the other tools,
2604 .Pn send
2605 takes the draft folder as its default folder.
2606 .P
2607 Dropping the draft message concept in favor for the draft folder concept,
2608 removed special cases with regular cases.
2609 This simplified the source code of the tools, as well as the concepts.
2610 In mmh, draft management does not break with the MH concepts
2611 but applies them.
2612 .Cl "scan +drafts" ,
2613 for instance, is a truly natural request.
2614 Most of the work was already performed by Rose in the eighties.
2615 The original improvement of mmh is dropping the old draft message approach
2616 and thus simplifying the tools, the documentation and the system as a whole.
2617 Although my part in the draft handling improvement was small,
2618 it was an important one.
2621 .U3 "Trash Folder
2622 .Id trash-folder
2623 .P
2624 Similar to the situation for drafts is the situation for removed messages.
2625 Historically, a message was ``deleted'' by prepending a specific
2626 \fIbackup prefix\fP, usually the comma character,
2627 to the file name.
2628 The specific file would then be ignored by MH because only files with
2629 names consisting of digits only are treated as messages.
2630 Although files remained in the file system,
2631 the messages were no longer visible in MH.
2632 To truly delete them, a maintenance job was needed.
2633 Usually a cron job was installed to delete them after a grace time.
2634 For instance:
2635 .VS
2636 find $HOME/Mail -type f -name ',*' -ctime +7 -delete
2637 VE
2638 In such a setup, the original message could be restored
2639 within the grace time interval by stripping the
2640 backup prefix from the file name.
2641 But the user could not rely on this statement.
2642 If the last message of a folder with six messages (\fL1-6\fP) was removed,
2643 message
2644 .Fn 6 ,
2645 became file
2646 .Fn ,6 .
2647 If then a new message entered the same folder, it would be named with
2648 the number one above the highest existing message number.
2649 In this case the message would be named
2650 .Fn 6
2651 then.
2652 If this new message would be removed as well,
2653 then the backup of the former message is overwritten.
2654 Hence, the ability to restore removed messages did not only depend on
2655 the sweeping cron job but also on the removing of further messages.
2656 It is undesirable to have such obscure and complex mechanisms.
2657 The user should be given a small set of clear assertions, such as
2658 ``Removed files are restorable within a seven-day grace time.''
2659 With the addition ``... unless a message with the same name in the
2660 same folder is removed before.'' the statement becomes complex.
2661 A user will hardly be able to keep track of any removal to know
2662 if the assertion still holds true for a specific file.
2663 In practice, the real mechanism is unclear to the user.
2664 The consequences of further removals are not obvious.
2665 .P
2666 Furthermore, the backup files are scattered within the whole mail storage.
2667 This complicates managing them.
2668 It is possible with the help of
2669 .Pn find ,
2670 but everything would be more convenient
2671 if the deleted messages would be collected in one place.
2672 .P
2673 The profile entry
2674 .Pe rmmproc
2675 (previously named
2676 .Pe Delete-Prog )
2677 was introduced very early to improve the situation.
2678 It could be set to any command, which would be executed to remove
2679 the specified messages.
2680 This would override the default action described above.
2681 Refiling the to-be-removed files to a trash folder is the usual example.
2682 Nmh's man page
2683 .Mp rmm (1)
2684 proposes to set the
2685 .Pe rmmproc
2686 to
2687 .Cl "refile +d
2688 to move messages to the trash folder,
2689 .Fn +d ,
2690 instead of renaming them with the backup prefix.
2691 The man page proposes additionally the expunge command
2692 .Cl "rm `mhpath +d all`
2693 to empty the trash folder.
2694 .P
2695 Removing messages in such a way has advantages.
2696 The mail storage is prevented from being cluttered with removed messages
2697 because they are all collected in one place.
2698 Existing and removed messages are thus separated more strictly.
2699 No backup files are silently overwritten.
2700 But most important is the ability to keep removed messages in the MH domain.
2701 Messages in the trash folder can be listed like those in any other folder.
2702 Deleted messages can be displayed like any other messages.
2703 .Pn refile
2704 can restore deleted messages.
2705 All operations on deleted files are still covered by the MH tools.
2706 The trash folder is just like any other folder in the mail storage.
2707 .P
2708 Similar to the draft folder case, I dropped the old backup prefix approach
2709 in favor for replacing it by the better suiting trash folder system.
2710 Hence,
2711 .Pn rmm
2712 calls
2713 .Pn refile
2714 to move the to-be-removed message to the trash folder,
2715 .Fn +trash
2716 by default.
2717 To sweep it clean, the user can use
2718 .Cl "rmm -unlink +trash a" ,
2719 where the
2720 .Sw -unlink
2721 switch causes the files to be unlinked.
2722 .Ci 8edc5aaf86f9f77124664f6801bc6c6cdf258173
2723 .Ci ca0b3e830b86700d9e5e31b1784de2bdcaf58fc5
2724 .P
2725 Dropping the legacy approach and converting to the new approach completely
2726 simplified the code base.
2727 The relationship between
2728 .Pn rmm
2729 and
2730 .Pn refile
2731 was inverted.
2732 In mmh,
2733 .Pn rmm
2734 invokes
2735 .Pn refile ,
2736 which used to be the other way round.
2737 Yet, the relationship is simpler now.
2738 Loops, like described in nmh's man page for
2739 .Mp refile (1),
2740 can no longer occur:
2741 .QS
2742 Since
2743 .Pn refile
2744 uses your
2745 .Pe rmmproc
2746 to delete the message, the
2747 .Pe rmmproc
2748 must NOT call
2749 .Pn refile
2750 without specifying
2751 .Sw -normmproc
2752 or you will create an infinite loop.
2753 .QE
2754 .LP
2755 .Pn rmm
2756 either unlinks a message with
2757 .Fu unlink()
2758 or invokes
2759 .Pn refile
2760 to move it to the trash folder.
2761 .Pn refile
2762 does not invoke any tools.
2763 .P
2764 By generalizing the message removal in the way that it became covered
2765 by the MH concepts made the whole system more powerful.
2771 .H2 "Modern Defaults
2772 .P
2773 Nmh has a bunch of convenience-improving features inactive by default,
2774 although one can expect every new user wanting to have them active.
2775 The reason they are inactive by default is the wish to stay compatible
2776 with old versions.
2777 But what is the definition for old versions?
2778 Still, the highly useful draft folder facility has not been activated
2779 by default although it was introduced over twenty-five years ago.
2780 .[
2781 rose romine real work
2782 .]
2783 The community seems not to care.
2784 This is one of several examples that require new users to first build up
2785 a profile before they can access the modern features of nmh.
2786 Without an extensive profile, the setup is hardly usable
2787 for modern emailing.
2788 The point is not the customization of the setup,
2789 but the need to activate generally useful facilities.
2790 .P
2791 Yet, the real problem lies less in enabling the features, as this is
2792 straight forward as soon as one knows what he wants.
2793 The real problem is that new users need deep insight into the project
2794 to find out about inactive features nmh already provides.
2795 To give an example, I needed one year of using nmh
2796 before I became aware of the existence of the attachment system.
2797 One could argue that this fact disqualifies my reading of the
2798 documentation.
2799 If I would have installed nmh from source back then, I could agree.
2800 Yet, I had used a prepackaged version and had expected that it would
2801 just work.
2802 Nevertheless, I had been convinced by the concepts of MH already
2803 and I am a software developer,
2804 still I required a lot of time to discover the cool features.
2805 How can we expect users to be even more advanced than me,
2806 just to allow them use MH in a convenient and modern way?
2807 Unless they are strongly convinced of the concepts, they will fail.
2808 I have seen friends of me giving up disappointed
2809 before they truly used the system,
2810 although they had been motivated in the beginning.
2811 They suffer hard enough to get used to the tool chest approach,
2812 we developers should spare them further inconveniences.
2813 .P
2814 Maintaining compatibility for its own sake is bad,
2815 because the code base collects more and more compatibility code.
2816 Sticking to the compatibility code means remaining limited;
2817 whereas adjusting to the changes renders the compatibility unnecessary.
2818 Keeping unused alternatives in the code is a bad choice as they likely
2819 gather bugs, by not being well tested.
2820 Also, the increased code size and the greater number of conditions
2821 increase the maintenance costs.
2822 If any MH implementation would be the back-end of widespread
2823 email clients with large user bases, compatibility would be more
2824 important.
2825 Yet, it appears as if this is not the case.
2826 Hence, compatibility is hardly important for technical reasons.
2827 Its importance originates rather from personal reasons.
2828 Nmh's user base is small and old.
2829 Changing the interfaces would cause inconvenience to long-term users of MH.
2830 It would force them to change their many years old MH configurations.
2831 I do understand this aspect, but by sticking to the old users,
2832 new users are kept away.
2833 Yet, the future lies in new users.
2834 In consequence, mmh invites new users by providing a convenient
2835 and modern setup, readily usable out-of-the-box.
2836 .P
2837 In mmh, all modern features are active by default and many previous
2838 approaches are removed or only accessible in manual ways.
2839 New default features include:
2840 .BU
2841 The attachment system (\c
2842 .Hd Attach ).
2843 .Ci 8ff284ff9167eff8f5349481529332d59ed913b1
2844 .BU
2845 The draft folder facility (\c
2846 .Fn +drafts ).
2847 .Ci 337338b404931f06f0db2119c9e145e8ca5a9860
2848 .BU
2849 The unseen sequence (`u')
2850 .Ci c2360569e1d8d3678e294eb7c1354cb8bf7501c1
2851 and the sequence negation prefix (`!').
2852 .Ci db74c2bd004b2dc9bf8086a6d8bf773ac051f3cc
2853 .BU
2854 Quoting the original message in the reply.
2855 .Ci 67411b1f95d6ec987b4c732459e1ba8a8ac192c6
2856 .BU
2857 Forwarding messages using MIME.
2858 .Ci 6e271608b7b9c23771523f88d23a4d3593010cf1
2859 .LP
2860 In consequence, a setup with a profile that defines only the path to the
2861 mail storage, is already convenient to use.
2862 Again, Paul Vixie's ``edginess'' call supports the direction I took:
2863 ``the `main branch' should just be modern''.
2864 .[
2865 paul vixie edginess nmh-workers
2866 .]
2872 .\" --------------------------------------------------------------
2873 .H1 "Styling
2874 .P
2875 Kernighan and Pike have emphasized the importance of style in the
2876 preface of their book:
2877 .[ [
2878 kernighan pike practice of programming
2879 .], p. x]
2880 .QS
2881 Chapter 1 discusses programming style.
2882 Good style is so important to good programming that we have chose
2883 to cover it first.
2884 .QE
2885 This section covers changes in mmh that were guided by the desire
2886 to improve on style.
2887 Many of them follow the rules given in the quoted book.
2888 .[
2889 kernighan pike practice of programming
2890 .]
2895 .H2 "Code Style
2896 .Id code-style
2897 .P
2898 .U3 "Indentation Style
2899 .P
2900 Indentation styles are the holy cow of programmers.
2901 Kernighan and Pike
2902 .[ [
2903 kernighan pike practice of programming
2904 .], p. 10]
2905 wrote:
2906 .QS
2907 Programmers have always argued about the layout of programs,
2908 but the specific style is much less important than its consistent
2909 application.
2910 Pick one style, preferably ours, use it consistently, and don't waste
2911 time arguing.
2912 .QE
2913 .P
2914 I agree that the constant application is most important,
2915 but I believe that some styles have advantages over others.
2916 For instance the indentation with tab characters only.
2917 Tab characters directly map to the nesting level \(en
2918 one tab, one level.
2919 Tab characters are flexible because developers can adjust them to
2920 whatever width they like to have.
2921 There is no more need to run
2922 .Pn unexpand
2923 or
2924 .Pn entab
2925 programs to ensure the correct mixture of leading tabs and spaces.
2926 The simple rules are: (1) Leading whitespace must consist of tabs only.
2927 (2) Any other whitespace should consist of spaces.
2928 These two rules ensure the integrity of the visual appearance.
2929 Although reformatting existing code should be avoided, I did it.
2930 I did not waste time arguing; I just reformatted the code.
2931 .Ci a485ed478abbd599d8c9aab48934e7a26733ecb1
2933 .U3 "Comments
2934 .P
2935 Section 1.6 of
2936 .[ [
2937 kernighan pike practice of programming
2938 .], p. 23]
2939 demands: ``Don't belabor the obvious.''
2940 Hence, I simply removed all the comments in the following code excerpt:
2941 .VS
2942 context_replace(curfolder, folder); /* update current folder */
2943 seq_setcur(mp, mp->lowsel); /* update current message */
2944 seq_save(mp); /* synchronize message sequences */
2945 folder_free(mp); /* free folder/message structure */
2946 context_save(); /* save the context file */
2948 [...]
2950 int c; /* current character */
2951 char *cp; /* miscellaneous character pointer */
2953 [...]
2955 /* NUL-terminate the field */
2956 *cp = '\0';
2957 VE
2958 .Ci 426543622b377fc5d091455cba685e114b6df674
2959 .P
2960 The program code explains enough itself, already.
2963 .U3 "Names
2964 .P
2965 Kernighan and Pike suggest:
2966 ``Use active names for functions''.
2967 .[ [
2968 kernighan pike practice of programming
2969 .], p. 4]
2970 One application of this rule was the rename of
2971 .Fu check_charset()
2972 to
2973 .Fu is_native_charset() .
2974 .Ci 8d77b48284c58c135a6b2787e721597346ab056d
2975 The same change fixed a violation of ``Be accurate''
2976 .[ [
2977 kernighan pike practice of programming
2978 .], p. 4]
2979 as well.
2980 The code did not match the expectation the function suggested,
2981 as it, for whatever reason, only compared the first ten characters
2982 of the charset name.
2983 .P
2984 More important than using active names is using descriptive names.
2985 .VS
2986 m_unknown(in); /* the MAGIC invocation... */
2987 VE
2988 Renaming the obscure
2989 .Fu m_unknown()
2990 function was a delightful event, although it made the code less funny.
2991 .Ci 611d68d19204d7cbf5bd585391249cb5bafca846
2992 .P
2993 Magic numbers are generally considered bad style.
2994 Obviously, Kernighan and Pike agree:
2995 ``Give names to magic numbers''.
2996 .[ [
2997 kernighan pike practice of programming
2998 .], p. 19]
2999 One such change was naming the type of input \(en mbox or mail folder \(en
3000 to be scanned:
3001 .VS
3002 #define SCN_MBOX (-1)
3003 #define SCN_FOLD 0
3004 VE
3005 .Ci 7ffb36d28e517a6f3a10272056fc127592ab1c19
3006 .P
3007 The argument
3008 .Ar outnum
3009 of the function
3010 .Fu scan()
3011 in
3012 .Fn uip/scansbr.c
3013 defines the number of the message to be created.
3014 If no message is to be created, the argument is misused to transport
3015 program logic.
3016 This lead to obscure code.
3017 I improved the clarity of the code by introducing two variables:
3018 .VS
3019 int incing = (outnum > 0);
3020 int ismbox = (outnum != 0);
3021 VE
3022 They cover the magic values and are used for conditions.
3023 The variable
3024 .Ar outnum
3025 is only used when it holds an ordinary message number.
3026 .Ci b8b075c77be7794f3ae9ff0e8cedb12b48fd139f
3027 The clarity improvement of the change showed detours in the program logic
3028 of related code parts.
3029 Having the new variables with descriptive names, a more
3030 straight forward implementation became apparent.
3031 Before the code was clarified, the possibility to improve had not be seen.
3032 .Ci aa60b0ab5e804f8befa890c0a6df0e3143ce0723
3036 .H2 "Structural Rework
3037 .P
3038 Although the stylistic changes described up to here improve the
3039 readability of the source code, all of them are changes ``in the small''.
3040 Structural changes affect a much larger area.
3041 They are more difficult to do but lead to larger improvements,
3042 especially as they influence the outer shape of the tools as well.
3043 .P
3044 At the end of their chapter on style,
3045 Kernighan and Pike ask: ``But why worry about style?''
3046 .[ [
3047 kernighan pike practice of programming
3048 .], p. 28]
3049 Following are two examples of structural rework that show
3050 why style is important in the first place.
3053 .U3 "Rework of \f(CWanno\fP
3054 .P
3055 Until 2002,
3056 .Pn anno
3057 had six functional command line switches,
3058 .Sw -component
3059 and
3060 .Sw -text ,
3061 which have an argument each,
3062 and the two pairs of flags,
3063 .Sw -[no]date
3064 and
3065 .Sw -[no]inplace .
3066 Then Jon Steinhart introduced his attachment system.
3067 In need for more advanced annotation handling, he extended
3068 .Pn anno .
3069 He added five more switches:
3070 .Sw -draft ,
3071 .Sw -list ,
3072 .Sw -delete ,
3073 .Sw -append ,
3074 and
3075 .Sw -number ,
3076 the last one taking an argument.
3077 .Ci 7480dbc14bc90f2d872d434205c0784704213252
3078 Later,
3079 .Sw -[no]preserve
3080 was added.
3081 .Ci d9b1d57351d104d7ec1a5621f090657dcce8cb7f
3082 Then, the Synopsis section of the man page
3083 .Mp anno (1)
3084 read:
3085 .VS
3086 anno [+folder] [msgs] [-component field] [-inplace | -noinplace]
3087 [-date | -nodate] [-draft] [-append] [-list] [-delete]
3088 [-number [num|all]] [-preserve | -nopreserve] [-version]
3089 [-help] [-text body]
3090 VE
3091 .LP
3092 The implementation followed the same structure.
3093 Problems became visible when
3094 .Cl "anno -list -number 42
3095 worked on the current message instead on message number 42,
3096 and
3097 .Cl "anno -list -number l:5
3098 did not work on the last five messages but failed with the mysterious
3099 error message: ``anno: missing argument to -list''.
3100 Yet, the invocation matched the specification in the man page.
3101 There, the correct use of
3102 .Sw -number
3103 was defined as being
3104 .Cl "[-number [num|all]]
3105 and the textual description for the combination with
3106 .Sw -list
3107 read:
3108 .QS
3109 The
3110 .Sw -list
3111 option produces a listing of the field bodies for
3112 header fields with names matching the specified component,
3113 one per line. The listing is numbered, starting at 1, if the
3114 .Sw -number
3115 option is also used.
3116 .QE
3117 .LP
3118 The problem was manifold.
3119 The code required a numeric argument to the
3120 .Sw -number
3121 switch.
3122 If it was missing or non-numeric,
3123 .Pn anno
3124 aborted with an error message that had an off-by-one error,
3125 printing the switch one before the failing one.
3126 Semantically, the argument to the
3127 .Sw -number
3128 switch is only necessary in combination with
3129 .Sw -delete ,
3130 but not with
3131 .Sw -list .
3132 .P
3133 Trying to fix these problems on the surface would not have solved
3134 them truly, as they originate from a discrepance between the
3135 structure of the problem and the structure implemented in the program.
3136 Such structural differences can not be cured on the surface.
3137 They need to be solved by adjusting the structure of the implementation
3138 to the structure of the problem.
3139 .P
3140 In 2002, the new switches
3141 .Sw -list
3142 and
3143 .Sw -delete
3144 were added in the same way, the
3145 .Sw -number
3146 switch for instance had been added.
3147 Yet, they are of structural different type.
3148 Semantically,
3149 .Sw -list
3150 and
3151 .Sw -delete
3152 introduce modes of operation.
3153 Historically,
3154 .Pn anno
3155 had only one operation mode: adding header fields.
3156 With the extension it got two more modes:
3157 .\" XXX got
3158 listing and deleting header fields.
3159 The structure of the code changes did not pay respect to this
3160 fundamental change to
3161 .Pn anno 's
3162 behavior.
3163 Neither the implementation nor the documentation did clearly
3164 define them as being exclusive modes of operation.
3165 Having identified the problem, I solved it by putting structure into
3166 .Pn anno
3167 and its documentation.
3168 .Ci d54c8db8bdf01e8381890f7729bc0ef4a055ea11
3169 .P
3170 The difference is visible in both the code and the documentation.
3171 The following code excerpt:
3172 .VS
3173 int delete = -2; /* delete header element if set */
3174 int list = 0; /* list header elements if set */
3175 [...]
3176 case DELETESW: /* delete annotations */
3177 delete = 0;
3178 continue;
3179 case LISTSW: /* produce a listing */
3180 list = 1;
3181 continue;
3182 VE
3183 .LP
3184 was replaced by:
3185 .VS
3186 static enum { MODE_ADD, MODE_DEL, MODE_LIST } mode = MODE_ADD;
3187 [...]
3188 case DELETESW: /* delete annotations */
3189 mode = MODE_DEL;
3190 continue;
3191 case LISTSW: /* produce a listing */
3192 mode = MODE_LIST;
3193 continue;
3194 VE
3195 .LP
3196 The replacement code does not only reflect the problem's structure better,
3197 it is easier to understand as well.
3198 The same applies to the documentation.
3199 The man page was completely reorganized to propagate the same structure.
3200 This is visible in the Synopsis section:
3201 .VS
3202 anno [+folder] [msgs] [-component field] [-text body]
3203 [-append] [-date | -nodate] [-preserve | -nopreserve]
3204 [-Version] [-help]
3206 anno -delete [+folder] [msgs] [-component field] [-text
3207 body] [-number num | all ] [-preserve | -nopreserve]
3208 [-Version] [-help]
3210 anno -list [+folder] [msgs] [-component field] [-number]
3211 [-Version] [-help]
3212 VE
3213 .\" XXX think about explaining the -preserve rework?
3217 .U3 "Path Conversion
3218 .P
3219 Four kinds of path names can appear in MH:
3220 .LI 1
3221 Absolute Unix directory paths, like
3222 .Fn /etc/passwd .
3223 .LI 2
3224 Relative Unix directory paths, like
3225 .Fn ./foo/bar .
3226 .LI 3
3227 Absolute MH folder paths, like
3228 .Fn +friends/phil .
3229 .LI 4
3230 Relative MH folder paths, like
3231 .Fn @subfolder .
3232 .LP
3233 The last type, relative MH folder paths, are hardly documented.
3234 Nonetheless, they are useful for large mail storages.
3235 The current mail folder is specified as `\c
3236 .Fn @ ',
3237 just like the current directory is specified as `\c
3238 .Fn . '.
3239 .P
3240 To allow MH tools to understand all four notations,
3241 they need to convert between them.
3242 .\" XXX between?
3243 In nmh, these path name conversion functions were located in the files
3244 .Fn sbr/path.c
3245 (``return a pathname'') and
3246 .Fn sbr/m_maildir.c
3247 (``get the path for the mail directory'').
3248 The seven functions in the two files were documented with no more
3249 than two comments, which described obvious information.
3250 The function signatures were neither explaining:
3251 .VS
3252 char *path(char *, int);
3253 char *pluspath(char *);
3254 char *m_mailpath(char *);
3255 char *m_maildir(char *);
3256 VE
3257 .P
3258 My investigation provides the following description:
3259 .LI 1
3260 The second parameter of
3261 .Fu path()
3262 defines the type of path given as first parameter.
3263 Directory paths are converted to absolute directory paths.
3264 Folder paths are converted to absolute folder paths.
3265 Folder paths must not include a leading `\fL@\fP' character.
3266 Leading plus characters are preserved.
3267 The result is a pointer to newly allocated memory.
3268 .LI 2
3269 .Fu pluspath()
3270 is a convenience-wrapper to
3271 .Fu path() ,
3272 to convert folder paths only.
3273 This function can not be used for directory paths.
3274 An empty string parameter causes a buffer overflow.
3275 .LI 3
3276 .Fu m_mailpath()
3277 converts directory paths to absolute directory paths.
3278 The characters `\fL+\fP' or `\fL@\fP' at the beginning of the path name are
3279 treated literal, i.e. as the first character of a relative directory path.
3280 Hence, this function can not be used for folder paths.
3281 In any case, the result is an absolute directory path.
3282 The result is a pointer to newly allocated memory.
3283 .LI 4
3284 .Fu m_maildir()
3285 returns the parameter unchanged if it is an absolute directory path
3286 or begins with the entry `\fL.\fP' or `\fL..\fP'.
3287 All other strings are prepended with the current working directory.
3288 Hence, this functions can not be used for folder paths.
3289 The result is either an absolute directory path or a relative
3290 directory path, starting with a dot.
3291 In contrast to the other functions, the result is a pointer to
3292 static memory.
3293 .P
3294 The situation was obscure, irritating, error-prone, and non-orthogonal.
3295 No clear terminology was used to name the different kinds of path names.
3296 The first argument of
3297 .Fu m_mailpath() ,
3298 for instance, was named
3299 .Ar folder ,
3300 though
3301 .Fu m_mailpath()
3302 can not be used for MH folders.
3303 .P
3304 I reworked the path name conversion completely, introducing clarity.
3305 First of all, the terminology needed to be defined.
3306 A path name is either in the Unix domain, then it is called
3307 \fIdirectory path\fP, `dirpath' for short, or it is in the MH domain,
3308 then it is called \fIfolder path\fP, `folpath' for short.
3309 The two terms need to be used with strict distinction.
3310 Having a clear terminology is often an indicator of having understood
3311 the problem itself.
3312 Second, I exploited the concept of path type indicators.
3313 By requesting every path name to start with a clear type identifier,
3314 conversion between the types can be fully automated.
3315 Thus the tools can accept paths of any type from the user.
3316 Therefore, it was necessary to require relative directory paths to be
3317 prefixed with a dot character.
3318 In consequence, the dot character could no longer be an alias for the
3319 current message.
3320 .Ci cff0e16925e7edbd25b8b9d6d4fbdf03e0e60c01
3321 Third, I created three new functions to replace the previous mess:
3322 .LI 1
3323 .Fu expandfol()
3324 converts folder paths to absolute folder paths,
3325 without the leading plus character.
3326 Directory paths are simply passed through.
3327 This function is to be used for folder paths only, thus the name.
3328 The result is a pointer to static memory.
3329 .LI 2
3330 .Fu expanddir()
3331 converts directory paths to absolute directory paths.
3332 Folder paths are treated as relative directory paths.
3333 This function is to be used for directory paths only, thus the name.
3334 The result is a pointer to static memory.
3335 .LI 3
3336 .Fu toabsdir()
3337 converts any type of path to an absolute directory path.
3338 This is the function of choice for path conversion.
3339 Absolute directory paths are the most general representation of a
3340 path name.
3341 The result is a pointer to static memory.
3342 .P
3343 .\" XXX ueberfluessig?
3344 The new functions have names that indicate their use.
3345 Two of the functions convert relative to absolute path names of the
3346 same type.
3347 The third function converts any path name type to the most general one,
3348 the absolute directory path.
3349 All of the functions return pointers to static memory.
3350 All three functions are implemented in
3351 .Fn sbr/path.c .
3352 .Fn sbr/m_maildir.c
3353 is removed.
3354 .Ci d39e2c447b0d163a5a63f480b23d06edb7a73aa0
3355 .P
3356 Along with the path conversion rework, I also replaced
3357 .Fu getfolder(FDEF)
3358 with
3359 .Fu getdeffol()
3360 and
3361 .Fu getfolder(FCUR)
3362 with
3363 .Fu getcurfol() ,
3364 which is only a convenience wrapper for
3365 .Fu expandfol("@") .
3366 This code was moved from
3367 .Fn sbr/getfolder.c
3368 to
3369 .Fn sbr/path.c .
3370 .Ci d39e2c447b0d163a5a63f480b23d06edb7a73aa0
3371 .P
3372 The related function
3373 .Fu etcpath()
3374 was moved to
3375 .Fn sbr/path.c ,
3376 too
3377 .Ci b4c29794c12099556151d93a860ee51badae2e35 .
3378 Previously, it had been located in
3379 .Fn config/config.c ,
3380 for whatever reasons.
3381 .P
3382 .Fn sbr/path.c
3383 now contains all path handling code.
3384 .\" XXX naechste zeile weg?
3385 Only 173 lines of code were needed to replace the previous 252 lines.
3386 The readability of the code is highly improved.
3387 Additionally, each of the six exported and one static functions
3388 is introduced by an explaining comment.
3393 .H2 "Profile Reading
3394 .P
3395 The MH profile contains the configuration for the user-specific MH setup.
3396 MH tools read the profile right after starting up,
3397 as it contains the location of the user's mail storage
3398 and similar settings that influence the whole setup.
3399 Furthermore, the profile contains the default switches for the tools,
3400 hence, it must be read before the command line switches are processed.
3401 .P
3402 For historic reasons, some MH tools did not read the profile and context.
3403 Among them were
3404 .Pn post /\c
3405 .Pn spost ,
3406 .Pn mhmail ,
3407 and
3408 .Pn slocal .
3409 The reason why these tools ignored the profile were not clearly stated.
3410 During the discussion on the nmh-workers mailing list,
3411 David Levine posted an explanation, quoting John Romine:
3412 .[
3413 nmh-workers levine post profile
3414 .]
3415 .QS
3416 I asked John Romine and here's what he had to say, which
3417 agrees and provides an example that convinces me:
3418 .QS
3419 My take on this is that
3420 .Pn post
3421 should not be called by users directly, and it doesn't read the
3422 .Fn .mh_profile
3423 (only front-end UI programs read the profile).
3424 .QP
3425 For example, there can be contexts where
3426 .Pn post
3427 is called by a helper program (like `\c
3428 .Pn mhmail ')
3429 which may be run by a non-MH user.
3430 We don't want this to prompt the user to create an MH profile, etc.
3431 .QP
3432 My suggestion would be to have
3433 .Pn send
3434 pass a (hidden) `\c
3435 .Sw -fileproc
3436 .Ar proc '
3437 option to
3438 .Pn post
3439 if needed.
3440 You could also
3441 use an environment variable (I think
3442 .Pn send /\c
3443 .Pn whatnow
3444 do this).
3445 .QE
3446 I think that's the way to go.
3447 My personal preference is to use a command line option,
3448 not an environment variable.
3449 .QE
3450 .P
3451 To solve the problem of
3452 .Pn post
3453 not honoring the
3454 .Pe fileproc
3455 profile entry,
3456 the community roughly agreed that a switch
3457 .Sw -fileproc
3458 should be added to
3459 .Pn post
3460 to be able to pass a different fileproc.
3461 I strongly disagree with this approach because it does not solve
3462 the problem; it only removes a single symptom.
3463 The problem is that
3464 .Pn post
3465 does not behave as expected.
3466 But all programs should behave as expected.
3467 Clear and simple concepts are a precondition for this.
3468 Hence, the real solution is having all MH tools read the profile.
3469 .P
3470 The problem has a further aspect.
3471 It mainly originates in
3472 .Pn mhmail .
3473 .Pn mhmail
3474 was intended to be a replacement for
3475 .Pn mailx
3476 on systems with MH installations.
3477 .Pn mhmail
3478 should have been able to use just like
3479 .Pn mailx ,
3480 but sending the message via MH's
3481 .Pn post
3482 instead of
3483 .Pn sendmail .
3484 Using
3485 .Pn mhmail
3486 should not be influenced by the question whether the user had
3487 MH set up for himself or not.
3488 .Pn mhmail
3489 did not read the profile as this requests the user to set up MH
3490 if not done yet.
3491 As
3492 .Pn mhmail
3493 used
3494 .Pn post ,
3495 .Pn post
3496 could not read the profile neither.
3497 This is the reason why
3498 .Pn post
3499 does not read the profile.
3500 This is the reason for the actual problem.
3501 It was not much of a problem because
3502 .Pn post
3503 was not intended to be used by users directly.
3504 .Pn send
3505 is the interactive front-end to
3506 .Pn post .
3507 .Pn send
3508 read the profile and passed all relevant values on the command line to
3509 .Pn post
3510 \(en an awkward solution.
3511 .P
3512 The important insight is that
3513 .Pn mhmail
3514 is no true MH tool.
3515 The concepts broke because this outlandish tool was treated as any other
3516 MH tool.
3517 Instead it should have been treated accordingly to its foreign style.
3518 The solution is not to prevent the tools reading the profile but
3519 to instruct them reading a different profile.
3520 .Pn mhmail
3521 could have set up a well-defined profile and caused all MH tools
3522 in the session to use it by exporting an environment variable.
3523 With this approach, no special cases would have been introduced,
3524 no surprises would have been caused.
3525 By writing a clean-profile-wrapper, the concept could have been
3526 generalized orthogonally to the whole MH tool chest.
3527 Then Rose's motivation behind the decision that
3528 .Pn post
3529 ignores the profile, as quoted by Jeffrey Honig,
3530 would have become possible:
3531 .[
3532 nmh-workers honig post profile
3533 .]
3534 .QS
3535 when you run mh commands in a script, you want all the defaults to be
3536 what the man page says.
3537 when you run a command by hand, then you want your own defaults...
3538 .QE
3539 .LP
3540 Yet, I consider this explanation shortsighted.
3541 We should rather regard theses two cases as just two different MH setups,
3542 based on two different profiles.
3543 Mapping such problems on the concepts of switching between different
3544 profiles, solves them once for all.
3545 .P
3546 In mmh, the wish to have
3547 .Pn mhmail
3548 as a replacement for
3549 .Pn mailx
3550 is considered obsolete.
3551 Mmh's
3552 .Pn mhmail
3553 does no longer cover this use-case.
3554 Currently,
3555 .Pn mhmail
3556 is in a transition state.
3557 .Ci 32d4f9daaa70519be3072479232ff7be0500d009
3558 It may become a front-end to
3559 .Pn comp ,
3560 which provides an interface more convenient in some cases.
3561 In this case,
3562 .Pn mhmail
3563 will become an ordinary MH tool, reading the profile.
3564 If, however, this idea will not convince, then
3565 .Pn mhmail
3566 will be removed.
3567 .P
3568 Every program in the mmh tool chest reads the profile.
3569 The only exception is
3570 .Pn slocal ,
3571 which is not considered part of the mmh tool chest.
3572 This MDA is only distributed with mmh, currently.
3573 Mmh has no
3574 .Pn post
3575 program, but
3576 .Pn spost ,
3577 which now reads the profile.
3578 .Ci 3e017a7abbdf69bf0dff7a4073275961eda1ded8
3579 With this change,
3580 .Pn send
3581 and
3582 .Pn spost
3583 can be considered to be merged.
3584 .Pn spost
3585 is only invoked directly by the to-be-changed
3586 .Pn mhmail
3587 implementation and by
3588 .Pn rcvdist ,
3589 which will require rework.
3590 .P
3591 The
3592 .Fu context_foil()
3593 function to pretend to have read an empty profile was removed.
3594 .Ci 68af8da96bea87a5541988870130b6209ce396f6
3595 All mmh tools read the profile.
3599 .H2 "Standard Libraries
3600 .P
3601 MH is one decade older than the POSIX and ANSI C standards.
3602 Hence, MH included own implementations of functions
3603 that are standardized and thus widely available today,
3604 but were not back then.
3605 Today, twenty years after the POSIX and ANSI C were published,
3606 developers can expect systems to comply with these standards.
3607 In consequence, MH-specific replacements for standard functions
3608 can and should be dropped.
3609 Kernighan and Pike advise: ``Use standard libraries.''
3610 .[ [
3611 kernighan pike practice of programming
3612 .], p. 196]
3613 Actually, MH had followed this advice in history,
3614 but it had not adjusted to the changes in this field.
3615 The
3616 .Fu snprintf()
3617 function, for instance, was standardized with C99 and is available
3618 almost everywhere because of its high usefulness.
3619 The project's own implementation of
3620 .Fu snprintf()
3621 was dropped in March 2012 in favor for using the one of the
3622 standard library.
3623 .Ci 0052f1024deb0a0a2fc2e5bacf93d45a5a9c9b32
3624 Such decisions limit the portability of mmh
3625 if systems do not support these standardized and widespread functions.
3626 This compromise is made because mmh focuses on the future.
3627 .P
3628 .\" XXX kuerzen und mit dem naechsten Absatz vereinen
3629 I am still in my twenties and my C and Unix experience comprises
3630 only half a dozen years.
3631 Hence, I need to learn about the history in retrospective.
3632 I have not used those ancient constructs myself.
3633 I have not suffered from their incompatibilities.
3634 I have not longed for standardization.
3635 All my programming experience is from a time when ANSI C and POSIX
3636 were well established already.
3637 I have only read a lot of books about the (good) old times.
3638 This puts me in a difficult position when working with old code.
3639 I need to freshly acquire knowledge about old code constructs and ancient
3640 programming styles, whereas older programmers know these things by
3641 heart from their own experience.
3642 .P
3643 Being aware of the situation, I rather let people with more historic
3644 experience replace ancient code constructs with standardized ones.
3645 Lyndon Nerenberg covered large parts of this task for the nmh project.
3646 He converted project-specific functions to POSIX replacements,
3647 also removing the conditionals compilation of now standardized features.
3648 Ken Hornstein and David Levine had their part in the work, too.
3649 Often, I only needed to pull over changes from nmh into mmh.
3650 These changes include many commits; these are among them:
3651 .Ci 768b5edd9623b7238e12ec8dfc409b82a1ed9e2d
3652 .Ci 0052f1024deb0a0a2fc2e5bacf93d45a5a9c9b32 .
3653 .P
3654 During my own work, I tidied up the \fIMH standard library\fP,
3655 .Fn libmh.a ,
3656 which is located in the
3657 .Fn sbr
3658 (``subroutines'') directory in the source tree.
3659 The MH library includes functions that mmh tools usually need.
3660 Among them are MH-specific functions for profile, context, sequence,
3661 and folder handling, but as well
3662 MH-independent functions, such as auxiliary string functions,
3663 portability interfaces and error-checking wrappers for critical
3664 functions of the standard library.
3665 .P
3666 I have replaced the
3667 .Fu atooi()
3668 function with calls to
3669 .Fu strtoul()
3670 with the third parameter, the base, set to eight.
3671 .Fu strtoul()
3672 is part of C89 and thus considered safe to use.
3673 .Ci c490c51b3c0f8871b6953bd0c74551404f840a74
3674 .P
3675 I did remove project-included fallback implementations of
3676 .Fu memmove()
3677 and
3678 .Fu strerror() ,
3679 although Peter Maydell had re-included them into nmh in 2008
3680 to support SunOS 4.
3681 Nevertheless, these functions are part of ANSI C.
3682 Systems that do not even provide full ANSI C support should not
3683 put a load on mmh.
3684 .Ci b067ff5c465a5d243ce5a19e562085a9a1a97215
3685 .P
3686 The
3687 .Fu copy()
3688 function copies the string in parameter one to the location in
3689 parameter two.
3690 In contrast to
3691 .Fu strcpy() ,
3692 it returns a pointer to the terminating null-byte in the destination area.
3693 The code was adjusted to replace
3694 .Fu copy()
3695 with
3696 .Fu strcpy() ,
3697 except within
3698 .Fu concat() ,
3699 where
3700 .Fu copy()
3701 was more convenient.
3702 Therefore, the definition of
3703 .Fu copy()
3704 was moved into the source file of
3705 .Fu concat()
3706 and its visibility is now limited to it.
3707 .Ci 552fd7253e5ee9e554c5c7a8248a6322aa4363bb
3708 .P
3709 The function
3710 .Fu r1bindex()
3711 had been a generalized version of
3712 .Fu basename()
3713 with minor differences.
3714 As all calls to
3715 .Fu r1bindex()
3716 had the slash (`/') as delimiter anyway,
3717 replacing
3718 .Fu r1bindex()
3719 with the more specific and better-named function
3720 .Fu basename()
3721 became desirable.
3722 Unfortunately, many of the 54 calls to
3723 .Fu r1bindex()
3724 depended on a special behavior,
3725 which differed from the POSIX specification for
3726 .Fu basename() .
3727 Hence,
3728 .Fu r1bindex()
3729 was kept but renamed to
3730 .Fu mhbasename() ,
3731 fixing the delimiter to the slash.
3732 .Ci 240013872c392fe644bd4f79382d9f5314b4ea60
3733 For possible uses of
3734 .Fu r1bindex()
3735 with a different delimiter,
3736 the ANSI C function
3737 .Fu strrchr()
3738 provides the core functionality.
3739 .P
3740 The
3741 .Fu ssequal()
3742 function \(en apparently for ``substring equal'' \(en
3743 was renamed to
3744 .Fu isprefix() ,
3745 because this is what it actually checks.
3746 .Ci c20b4fa14515c7ab388ce35411d89a7a92300711
3747 Its source file had included the following comments, no joke.
3748 .VS
3749 /*
3750 * THIS CODE DOES NOT WORK AS ADVERTISED.
3751 * It is actually checking if s1 is a PREFIX of s2.
3752 * All calls to this function need to be checked to see
3753 * if that needs to be changed. Prefix checking is cheaper, so
3754 * should be kept if it's sufficient.
3755 */
3757 /*
3758 * Check if s1 is a substring of s2.
3759 * If yes, then return 1, else return 0.
3760 */
3761 VE
3762 Two months later, it was completely removed by replacing it with
3763 .Fu strncmp() .
3764 .Ci b0b1dd37ff515578cf7cba51625189eb34a196cb
3770 .H2 "User Data Locations
3771 .P
3772 In nmh, a personal setup consists of the MH profile and the MH directory.
3773 The profile is a file named
3774 .Fn \&.mh_profile
3775 in the user's home directory.
3776 It contains the static configuration.
3777 It also contains the location of the MH directory in the profile entry
3778 .Pe Path .
3779 The MH directory contains the mail storage and is the first
3780 place to search for personal forms, scan formats, and similar
3781 configuration files.
3782 The location of the MH directory can be chosen freely by the user.
3783 The default and usual name is a directory named
3784 .Fn Mail
3785 in the home directory.
3786 .P
3787 The way MH data is split between profile and MH directory is a legacy.
3788 It is only sensible in a situation where the profile is the only
3789 configuration file.
3790 Why else should the mail storage and the configuration files be intermixed?
3791 They are different kinds of data:
3792 The data to be operated on and the configuration to change how
3793 tools operate.
3794 .\" XXX bad ... inapropriate?
3795 Splitting the configuration between the profile and the MH directory
3796 is bad.
3797 Merging the mail storage and the configuration in one directory is bad
3798 as well.
3799 As the mail storage and the configuration were not separated sensibly
3800 in the first place, I did it now.
3801 .P
3802 Personal mmh data is grouped by type, resulting in two distinct parts:
3803 the mail storage and the configuration.
3804 In mmh, the mail storage directory still contains all the messages,
3805 but, in exception of public sequences files, nothing else.
3806 In difference to nmh, the auxiliary configuration files are no longer
3807 located there.
3808 Therefore, the directory is no longer called the user's \fIMH directory\fP
3809 but his \fImail storage\fP.
3810 Its location is still user-chosen, with the default name
3811 .Fn Mail ,
3812 in the user's home directory.
3813 In mmh, the configuration is grouped together in
3814 the hidden directory
3815 .Fn \&.mmh
3816 in the user's home directory.
3817 This \fImmh directory\fP contains the context file, personal forms,
3818 scan formats, and the like, but also the user's profile, now named
3819 .Fn profile .
3820 The location of the profile is no longer fixed to
3821 .Fn $HOME/.mh_profile
3822 but to
3823 .Fn $HOME/.mmh/profile .
3824 Having both the file
3825 .Fn $HOME/.mh_profile
3826 and the configuration directory
3827 .Fn $HOME/.mmh
3828 appeared to be inconsistent.
3829 The approach chosen for mmh is consistent, simple, and familiar to
3830 Unix users.
3831 .Ci 7030d7edb099bff36ded7548bb5380f7acab4f9b
3832 .P
3833 MH allows users to have multiple MH setups.
3834 Therefore, it is necessary to select a different profile.
3835 The profile is the single entry point to access the rest of a
3836 personal MH setup.
3837 In nmh, the environment variable
3838 .Ev MH
3839 could be used to specify a different profile.
3840 To operate in the same MH setup with a separate context,
3841 the
3842 .Ev MHCONTEXT
3843 environment variable could be used.
3844 This allows having own current folders and current messages in
3845 each terminal, for instance.
3846 In mmh, three environment variables are used.
3847 .Ev MMH
3848 overrides the default location of the mmh directory (\c
3849 .Fn .mmh ).
3850 .Ev MMHP
3851 and
3852 .Ev MMHC
3853 override the paths to the profile and context files, respectively.
3854 This approach allows the set of personal configuration files to be chosen
3855 independently from the profile, context, and mail storage.
3856 .Ci 7030d7edb099bff36ded7548bb5380f7acab4f9b
3857 .P
3858 The separation of the files by type is sensible and convenient.
3859 The new approach has no functional disadvantages,
3860 as every setup I can imagine can be implemented with both approaches,
3861 possibly even easier with the new approach.
3862 The main achievement of the change is the clear and sensible split
3863 between mail storage and configuration.
3869 .H2 "Modularization
3870 .P
3871 The source code of the mmh tools is located in the
3872 .Fn uip
3873 (``user interface programs'') directory.
3874 Each tool has a source file with the name of the command.
3875 For example,
3876 .Pn rmm
3877 is built from
3878 .Fn uip/rmm.c .
3879 Some source files are used for multiple programs.
3880 For example
3881 .Fn uip/scansbr.c
3882 is used for both
3883 .Pn scan
3884 and
3885 .Pn inc .
3886 In nmh, 49 tools were built from 76 source files.
3887 This is a ratio of 1.6 source files per program.
3888 32 programs depended on multiple source files;
3889 17 programs depended on one source file only.
3890 In mmh, 39 tools are built from 51 source files.
3891 This is a ratio of 1.3 source files per program.
3892 18 programs depend on multiple source files;
3893 21 programs depend on one source file only.
3894 (These numbers and the ones in the following text ignore the MH library
3895 as well as shell scripts and multiple names for the same program.)
3896 .\" XXX graph
3897 .P
3898 Splitting the source code of a large program into multiple files can
3899 increase the readability of its source code.
3900 .\" XXX however?
3901 Most of the mmh tools are simple and straight-forward programs.
3902 With the exception of the MIME handling tools,
3903 .Pn pick
3904 is the largest tool.
3905 It contains 1\|037 lines of source code, excluding the MH library.
3906 Only the MIME handling tools (\c
3907 .Pn mhbuild ,
3908 .Pn mhstore ,
3909 .Pn show ,
3910 etc.)
3911 are larger.
3912 Splitting programs with less than 1\|000 lines of code into multiple
3913 source files seldom leads to better readability.
3914 For such tools, splitting makes sense
3915 when parts of the code are reused in other programs,
3916 and the reused code fragment is (1) not general enough
3917 for including it in the MH library
3918 or (2) has dependencies on a library that only few programs need.
3919 .Fn uip/packsbr.c ,
3920 for instance, provides the core program logic for the
3921 .Pn packf
3922 and
3923 .Pn rcvpack
3924 programs.
3925 .Fn uip/packf.c
3926 and
3927 .Fn uip/rcvpack.c
3928 mainly wrap the core function appropriately.
3929 No other tools use the folder packing functions.
3930 As another example,
3931 .Fn uip/termsbr.c
3932 provides termcap support, which requires linking with a termcap or
3933 curses library.
3934 Including
3935 .Fn uip/termsbr.c
3936 into the MH library would require every program to be linked with
3937 termcap or curses, although only few of the programs require it.
3938 .P
3939 The task of MIME handling is complex enough that splitting its code
3940 into multiple source files improves the readability.
3941 The program
3942 .Pn mhstore ,
3943 for instance, is compiled out of seven source files with 2\|500
3944 lines of code in summary.
3945 The main code file
3946 .Fn uip/mhstore.c
3947 consists of 800 lines; the other 1\|700 lines of code are reused in
3948 other MIME handling tools.
3949 It seems to be worthwhile to bundle the generic MIME handling code into
3950 a MH-MIME library, as a companion to the MH standard library.
3951 This is left open for the future.
3952 .P
3953 The work already accomplished focussed on the non-MIME tools.
3954 The amount of code compiled into each program was reduced.
3955 This eases the understanding of the code base.
3956 In nmh,
3957 .Pn comp
3958 was built from six source files:
3959 .Fn comp.c ,
3960 .Fn whatnowproc.c ,
3961 .Fn whatnowsbr.c ,
3962 .Fn sendsbr.c ,
3963 .Fn annosbr.c ,
3964 and
3965 .Fn distsbr.c .
3966 In mmh, it builds from only two:
3967 .Fn comp.c
3968 and
3969 .Fn whatnowproc.c .
3970 In nmh's
3971 .Pn comp ,
3972 the core function of
3973 .Pn whatnow ,
3974 .Pn send ,
3975 and
3976 .Pn anno
3977 were compiled into
3978 .Pn comp .
3979 This saved the need to execute these programs with
3980 .Fu fork()
3981 and
3982 .Fu exec() ,
3983 two expensive system calls.
3984 Whereas this approach improved the time performance,
3985 it interwove the source code.
3986 Core functionalities were not encapsulated into programs but into
3987 function, which were then wrapped by programs.
3988 For example,
3989 .Fn uip/annosbr.c
3990 included the function
3991 .Fu annotate() .
3992 Each program that wanted to annotate messages, included the source file
3993 .Fn uip/annosbr.c
3994 and called
3995 .Fu annotate() .
3996 Because the function
3997 .Fu annotate()
3998 was used like the tool
3999 .Pn anno ,
4000 it had seven parameters, reflecting the command line switches of the tool.
4001 When another pair of command line switches was added to
4002 .Pn anno ,
4003 a rather ugly hack was implemented to avoid adding another parameter
4004 to the function.
4005 .Ci d9b1d57351d104d7ec1a5621f090657dcce8cb7f
4006 .P
4007 Separation simplifies the understanding of program code
4008 because the area influenced by any particular statement is smaller.
4009 The separating on the program-level is more strict than the separation
4010 on the function level.
4011 In mmh, the relevant code of
4012 .Pn comp
4013 comprises the two files
4014 .Fn uip/comp.c
4015 and
4016 .Fn uip/whatnowproc.c ,
4017 together 210 lines of code.
4018 In nmh,
4019 .Pn comp
4020 comprises six files with 2\|450 lines.
4021 Not all of the code in these six files was actually used by
4022 .Pn comp ,
4023 but the code reader needed to read all of the code first to know which
4024 parts were used.
4025 .P
4026 As I have read a lot in the code base during the last two years,
4027 I learned about the easy and the difficult parts.
4028 Code is easy to understand if the influenced code area is small
4029 and its boundaries are strictly defined.
4030 Furthermore, the code needs to solve the problem in a straight-forward way.
4031 .P
4032 .\" XXX move this paragraph somewhere else?
4033 Reading
4034 .Pn rmm 's
4035 source code in
4036 .Fn uip/rmm.c
4037 is my recommendation for a beginner's entry point into the code base of nmh.
4038 The reasons are that the task of
4039 .Pn rmm
4040 is straight forward and it consists of one small source code file only,
4041 yet its source includes code constructs typical for MH tools.
4042 With the introduction of the trash folder in mmh,
4043 .Pn rmm
4044 became a bit more complex, because it invokes
4045 .Pn refile .
4046 Still, it is a good example for a simple tool with clear sources.
4047 .P
4048 Understanding
4049 .Pn comp
4050 .\" XXX kate fragen: more vs. as much
4051 requires to read 210 lines of code in mmh, but ten times more in nmh.
4052 Due to the aforementioned hack in
4053 .Pn anno
4054 to save the additional parameter, information passed through the program's
4055 source base in obscure ways.
4056 Thus, understanding
4057 .Pn comp ,
4058 required understanding the inner workings of
4059 .Fn uip/annosbr.c
4060 first.
4061 To be sure to fully understand a program, its whole source code needs
4062 to be examined.
4063 Not doing so is a leap of faith, assuming that the developers
4064 have avoided obscure programming techniques.
4065 By separating the tools on the program-level, the boundaries are
4066 clearly visible and technically enforced.
4067 The interfaces are calls to
4068 .Fu exec()
4069 rather than arbitrary function calls.
4070 .P
4071 But the real problem is another:
4072 Nmh violates the golden ``one tool, one job'' rule of the Unix philosophy.
4073 .\" XXX ref
4074 Understanding
4075 .Pn comp
4076 requires understanding
4077 .Fn uip/annosbr.c
4078 and
4079 .Fn uip/sendsbr.c
4080 because
4081 .Pn comp
4082 does annotate and send messages.
4083 In nmh, there surely exists the tool
4084 .Pn send ,
4085 which does mainly send messages.
4086 But
4087 .Pn comp
4088 and
4089 .Pn repl
4090 and
4091 .Pn forw
4092 and
4093 .Pn dist
4094 and
4095 .Pn whatnow
4096 and
4097 .Pn viamail ,
4098 they all (!) have the same message sending function included, as well.
4099 In result,
4100 .Pn comp
4101 sends messages without using
4102 .Pn send .
4103 The situation is the same as if
4104 .Pn grep
4105 would page without
4106 .Pn more
4107 just because both programs are part of the same code base.
4108 .P
4109 The clear separation on the surface \(en the tool chest approach \(en
4110 is violated on the level below.
4111 This violation is for the sake of time performance.
4112 On systems where
4113 .Fu fork()
4114 and
4115 .Fu exec()
4116 are expensive, the quicker response might be noticable.
4117 In the old times, sacrificing readability and conceptional beauty for
4118 speed might even have been a must to prevent MH from being unusably slow.
4119 Whatever the reasons had been, today they are gone.
4120 No longer should we sacrifice readability or conceptional beauty.
4121 No longer should we violate the Unix philosophy's ``one tool, one job''
4122 guideline.
4123 .\" XXX ref
4124 No longer should we keep speed improvements that became unnecessary.
4125 .P
4126 Therefore, mmh's
4127 .Pn comp
4128 does no longer send messages.
4129 In mmh, different jobs are divided among separate programs that
4130 invoke each other as needed.
4131 In consequence,
4132 .Pn comp
4133 invokes
4134 .Pn whatnow
4135 which thereafter invokes
4136 .Pn send .
4137 .Ci 3df5ab3c116e6d4a2fb4bb5cc9dfc5f781825815
4138 .Ci c73c00bfccd22ec77e9593f47462aeca4a8cd9c0
4139 The clear separation on the surface is maintained on the level below.
4140 Human users and the tools use the same interface \(en
4141 annotations, for example, are made by invoking
4142 .Pn anno ,
4143 no matter if requested by programs or by human beings.
4144 .Ci 469a4163c2a1a43731d412eaa5d9cae7d670c48b
4145 .Ci aed384169af5204b8002d06e7a22f89197963d2d
4146 .Ci 3caf9e298a8861729ca8b8a84f57022b6f3ea742
4147 The decrease of tools built from multiple source files and thus
4148 the decrease of
4149 .Fn uip/*sbr.c
4150 files confirm the improvement.
4151 .Ci 9e6d91313f01c96b4058d6bf419a8ca9a207bc33
4152 .ci 81744a46ac9f845d6c2b9908074d269275178d2e
4153 .Ci f0f858069d21111f0dbea510044593f89c9b0829
4154 .Ci 0503a6e9be34f24858b55b555a5c948182b9f24b
4155 .Ci 27826f9353e0f0b04590b7d0f8f83e60462b90f0
4156 .Ci d1da1f94ce62160aebb30df4063ccbc53768656b
4157 .Ci c42222869e318fff5dec395eca3e776db3075455
4158 .P
4159 .\" XXX move this paragraph up somewhere
4160 One disadvantage needs to be taken with this change:
4161 The compiler can no longer check the integrity of the interfaces.
4162 By changing the command line interfaces of tools, it is
4163 the developer's job to adjust the invocations of these tools as well.
4164 As this is a manual task and regression tests, which could detect such
4165 problems, are not available yet, it is prone to errors.
4166 These errors will not be detected at compile time but at run time.
4167 Installing regression tests is a pending task.
4168 In the best case, a uniform way of invoking tools from other tools
4169 can be developed to allow automated testing at compile time.
4172 .ig
4173 XXX consider writing about mhl vs. mhlproc
4175 sbr/showfile.c
4177 23 /*
4178 24 ** If you have your lproc listed as "mhl",
4179 25 ** then really invoked the mhlproc instead
4180 26 ** (which is usually mhl anyway).
4181 27 */
4183 Sat Nov 24 19:09:14 1984 /mtr (agent: Marshall Rose) <uci@udel-dewey>
4185 sbr/showfile.c: if lproc is "mhl", use mhlproc for consistency
4186 (Actually, user should use "lproc: show", "showproc: mhl".)
4187 ..