Commit 9b0dee5f 9b0dee5fa917d5804aa2ca89a186ea8da64578ca by Sergey Poznyakoff

Mail: configurable `headers' output format.

* mail/from.c: Rewrite using format string.
* mail/mail.c (default_setup): Set default value for `headline'.
(main): Fix call to util_do_command.
* mail/mail.h [HAVE_STDARG_H]: Remove conditions.
(mail_compile_headline): New proto.
* mail/mailvar.c (mailvar_tab): New variable "headline".
* mail/util.c: Minor fixes.
* NEWS, doc/programs.texi: Update.
1 parent f2eb56bb
1 GNU mailutils NEWS -- history of user-visible changes. 2009-08-03 1 GNU mailutils NEWS -- history of user-visible changes. 2009-08-14
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,
3 2008, 2009 Free Software Foundation, Inc. 3 2008, 2009 Free Software Foundation, Inc.
4 See the end of file for copying conditions. 4 See the end of file for copying conditions.
...@@ -83,6 +83,12 @@ described. ...@@ -83,6 +83,12 @@ described.
83 For each variable, this command prints its name, data type, current 83 For each variable, this command prints its name, data type, current
84 value and a short description. 84 value and a short description.
85 85
86 ** headline variable
87
88 The headline variable holds a format string to use for the header
89 summary. Its format is mostly compatible with that of the `nail'
90 mail reader.
91
86 ** showenvelope variable 92 ** showenvelope variable
87 93
88 If the `showenvelope' variable is set, print command will include the 94 If the `showenvelope' variable is set, print command will include the
...@@ -90,7 +96,7 @@ SMTP envelope in its output. ...@@ -90,7 +96,7 @@ SMTP envelope in its output.
90 96
91 ** fromfield variable 97 ** fromfield variable
92 98
93 The `fromenvelope' boolean variable, if set, instructs mail to obtain 99 The `fromfield' boolean variable, if set, instructs mail to obtain
94 the sender address from the `From:' header. This is the default. 100 the sender address from the `From:' header. This is the default.
95 If unset, the sender address is obtained from the SMTP envelope. 101 If unset, the sender address is obtained from the SMTP envelope.
96 102
......
...@@ -2240,14 +2240,14 @@ but before opening the mailbox. ...@@ -2240,14 +2240,14 @@ but before opening the mailbox.
2240 @itemx --file 2240 @itemx --file
2241 Operate on the mailbox given by the first non-optional command line 2241 Operate on the mailbox given by the first non-optional command line
2242 argument. If there is no such argument, read messages from the 2242 argument. If there is no such argument, read messages from the
2243 user's @file{mbox} file. @xref{Reading Mail} for more details about 2243 user's @file{mbox} file. @xref{Reading Mail}, for more details about
2244 using this option. 2244 using this option.
2245 @item -F 2245 @item -F
2246 @itemx --byname 2246 @itemx --byname
2247 Record outgoing messages in a file named after the first recipient. 2247 Record outgoing messages in a file named after the first recipient.
2248 The name is the login-name portion of the address found first on the 2248 The name is the login-name portion of the address found first on the
2249 @samp{To:} line in the mail header. This option sets the @samp{byname} 2249 @samp{To:} line in the mail header. This option sets the @samp{byname}
2250 variable, which see (@xref{byname}). 2250 variable, which see (@pxref{byname}).
2251 @item -H 2251 @item -H
2252 @itemx --headers 2252 @itemx --headers
2253 Print header summary to stdout and exit. 2253 Print header summary to stdout and exit.
...@@ -3482,6 +3482,7 @@ set ...@@ -3482,6 +3482,7 @@ set
3482 Following variables control the behavior of GNU @command{mail}: 3482 Following variables control the behavior of GNU @command{mail}:
3483 3483
3484 @table @code 3484 @table @code
3485 @kwindex append
3485 @item append 3486 @item append
3486 @*Type: Boolean, Read-Only 3487 @*Type: Boolean, Read-Only
3487 @*Default: True 3488 @*Default: True
...@@ -3491,6 +3492,7 @@ Messages saved in mbox are appended to the end rather than prepended. ...@@ -3491,6 +3492,7 @@ Messages saved in mbox are appended to the end rather than prepended.
3491 This is the default and cannot be changed. This variable exists only 3492 This is the default and cannot be changed. This variable exists only
3492 for compatibility with other @command{mailx} implementations. 3493 for compatibility with other @command{mailx} implementations.
3493 3494
3495 @kwindex appenddeadletter
3494 @item appenddeadletter 3496 @item appenddeadletter
3495 @*Type: Boolean. 3497 @*Type: Boolean.
3496 @*Default: False. 3498 @*Default: False.
...@@ -3500,6 +3502,7 @@ If this variable is @code{True}, the contents of canceled letter is ...@@ -3500,6 +3502,7 @@ If this variable is @code{True}, the contents of canceled letter is
3500 appended to the user's @file{dead.letter} file. Otherwise it overwrites 3502 appended to the user's @file{dead.letter} file. Otherwise it overwrites
3501 its contents. 3503 its contents.
3502 3504
3505 @kwindex askbcc
3503 @item askbcc 3506 @item askbcc
3504 @*Type: Boolean. 3507 @*Type: Boolean.
3505 @*Default: False. 3508 @*Default: False.
...@@ -3508,6 +3511,7 @@ its contents. ...@@ -3508,6 +3511,7 @@ its contents.
3508 When set to @code{True} the user will be prompted to enter @code{Bcc} 3511 When set to @code{True} the user will be prompted to enter @code{Bcc}
3509 field before composing the message. 3512 field before composing the message.
3510 3513
3514 @kwindex askcc
3511 @item askcc 3515 @item askcc
3512 @*Type: Boolean. 3516 @*Type: Boolean.
3513 @*Default: True. 3517 @*Default: True.
...@@ -3516,6 +3520,7 @@ field before composing the message. ...@@ -3516,6 +3520,7 @@ field before composing the message.
3516 When set to @code{True} the user will be prompted to enter @code{Cc} 3520 When set to @code{True} the user will be prompted to enter @code{Cc}
3517 field before composing the message. 3521 field before composing the message.
3518 3522
3523 @kwindex asksub
3519 @item asksub 3524 @item asksub
3520 @*Type: Boolean. 3525 @*Type: Boolean.
3521 @*Default: True in interactive mode, False otherwise. 3526 @*Default: True in interactive mode, False otherwise.
...@@ -3524,6 +3529,7 @@ field before composing the message. ...@@ -3524,6 +3529,7 @@ field before composing the message.
3524 When set to @code{True} the user will be prompted to enter @code{Subject} 3529 When set to @code{True} the user will be prompted to enter @code{Subject}
3525 field before composing the message. 3530 field before composing the message.
3526 3531
3532 @kwindex autoinc
3527 @item autoinc 3533 @item autoinc
3528 @*Type: Boolean. 3534 @*Type: Boolean.
3529 @*Default: True. 3535 @*Default: True.
...@@ -3531,6 +3537,7 @@ field before composing the message. ...@@ -3531,6 +3537,7 @@ field before composing the message.
3531 3537
3532 Automatically incorporate newly arrived messages. 3538 Automatically incorporate newly arrived messages.
3533 3539
3540 @kwindex autoprint
3534 @item autoprint 3541 @item autoprint
3535 @*Type: Boolean. 3542 @*Type: Boolean.
3536 @*Default: False. 3543 @*Default: False.
...@@ -3539,6 +3546,7 @@ Automatically incorporate newly arrived messages. ...@@ -3539,6 +3546,7 @@ Automatically incorporate newly arrived messages.
3539 Causes the delete command to behave like dp - thus, after deleting a 3546 Causes the delete command to behave like dp - thus, after deleting a
3540 message, the next one will be typed automatically. 3547 message, the next one will be typed automatically.
3541 3548
3549 @kwindex bang
3542 @item bang 3550 @item bang
3543 @*Type: Boolean. 3551 @*Type: Boolean.
3544 @*Default: False. 3552 @*Default: False.
...@@ -3548,6 +3556,7 @@ When set, every occurrence of @code{!} in arguments to @code{!} ...@@ -3548,6 +3556,7 @@ When set, every occurrence of @code{!} in arguments to @code{!}
3548 command is replaced with the last executed command. 3556 command is replaced with the last executed command.
3549 3557
3550 @anchor{byname} 3558 @anchor{byname}
3559 @kwindex byname
3551 @item byname 3560 @item byname
3552 @*Type: Boolean 3561 @*Type: Boolean
3553 @*Default: Unset 3562 @*Default: Unset
...@@ -3561,6 +3570,7 @@ The name is the login-name portion of the address found first on the ...@@ -3561,6 +3570,7 @@ The name is the login-name portion of the address found first on the
3561 It is set by the @option{--byname} (@option{-F}) command line option. 3570 It is set by the @option{--byname} (@option{-F}) command line option.
3562 3571
3563 @anchor{datefield} 3572 @anchor{datefield}
3573 @kwindex datefield
3564 @item datefield 3574 @item datefield
3565 @*Type: Boolean. 3575 @*Type: Boolean.
3566 @*Default: False. 3576 @*Default: False.
...@@ -3574,6 +3584,7 @@ will fall back to using @acronym{SMTP} envelope. ...@@ -3574,6 +3584,7 @@ will fall back to using @acronym{SMTP} envelope.
3574 3584
3575 @xref{fromfield}. 3585 @xref{fromfield}.
3576 3586
3587 @kwindex charset
3577 @item charset 3588 @item charset
3578 @*Type: string 3589 @*Type: string
3579 @*Default: @samp{auto} 3590 @*Default: @samp{auto}
...@@ -3586,6 +3597,7 @@ variable is set to @samp{auto}, @command{mail} tries to deduce the ...@@ -3586,6 +3597,7 @@ variable is set to @samp{auto}, @command{mail} tries to deduce the
3586 name of the character set from the value of @code{LC_ALL} environment 3597 name of the character set from the value of @code{LC_ALL} environment
3587 variable. Otherwise, its value is taken as the name of the charset. 3598 variable. Otherwise, its value is taken as the name of the charset.
3588 3599
3600 @kwindex cmd
3589 @item cmd 3601 @item cmd
3590 @*Type: String. 3602 @*Type: String.
3591 @*Default: Unset. 3603 @*Default: Unset.
...@@ -3593,6 +3605,7 @@ variable. Otherwise, its value is taken as the name of the charset. ...@@ -3593,6 +3605,7 @@ variable. Otherwise, its value is taken as the name of the charset.
3593 3605
3594 Contains default shell command for @code{pipe}. 3606 Contains default shell command for @code{pipe}.
3595 3607
3608 @kwindex columns
3596 @item columns 3609 @item columns
3597 @*Type: Numeric. 3610 @*Type: Numeric.
3598 @*Default: Detected at startup by querying the terminal device. If this 3611 @*Default: Detected at startup by querying the terminal device. If this
...@@ -3601,6 +3614,7 @@ fails, the value of environment variable @code{COLUMNS} is used. ...@@ -3601,6 +3614,7 @@ fails, the value of environment variable @code{COLUMNS} is used.
3601 3614
3602 This variable contains the number of columns on terminal screen. 3615 This variable contains the number of columns on terminal screen.
3603 3616
3617 @kwindex crt
3604 @item crt 3618 @item crt
3605 @*Type: Boolean or Numeric 3619 @*Type: Boolean or Numeric
3606 @*Default: True in interactive mode, False otherwise. 3620 @*Default: True in interactive mode, False otherwise.
...@@ -3614,6 +3628,7 @@ if @code{crt} is set without a value, then the height of the terminal ...@@ -3614,6 +3628,7 @@ if @code{crt} is set without a value, then the height of the terminal
3614 screen is used to compute the threshold. The number of lines on 3628 screen is used to compute the threshold. The number of lines on
3615 screen is controlled by @code{screen} variable. 3629 screen is controlled by @code{screen} variable.
3616 3630
3631 @kwindex debug
3617 @item debug 3632 @item debug
3618 @*Type: String to boolean 3633 @*Type: String to boolean
3619 @*Default: Not set 3634 @*Default: Not set
...@@ -3628,6 +3643,7 @@ information. If set to @samp{true} (i.e. @code{set debug}), sets ...@@ -3628,6 +3643,7 @@ information. If set to @samp{true} (i.e. @code{set debug}), sets
3628 maximum debugging (@samp{<trace7}) on mailbox and its underlying 3643 maximum debugging (@samp{<trace7}) on mailbox and its underlying
3629 objects. 3644 objects.
3630 3645
3646 @kwindex decode-fallback
3631 @item decode-fallback 3647 @item decode-fallback
3632 @*Type: String. 3648 @*Type: String.
3633 @*Default: @samp{none}. 3649 @*Default: @samp{none}.
...@@ -3650,6 +3666,7 @@ Unprintable characters are represented by their octal codes. Printable ...@@ -3650,6 +3666,7 @@ Unprintable characters are represented by their octal codes. Printable
3650 ones are printed @samp{as is}. 3666 ones are printed @samp{as is}.
3651 @end table 3667 @end table
3652 3668
3669 @kwindex debug
3653 @item debug 3670 @item debug
3654 @*Type: Boolean 3671 @*Type: Boolean
3655 @*Default: Unset 3672 @*Default: Unset
...@@ -3658,6 +3675,7 @@ ones are printed @samp{as is}. ...@@ -3658,6 +3675,7 @@ ones are printed @samp{as is}.
3658 This variable is not used. It exists for compatibility with other 3675 This variable is not used. It exists for compatibility with other
3659 @command{mailx} implementations and for future use. 3676 @command{mailx} implementations and for future use.
3660 3677
3678 @kwindex dot
3661 @item dot 3679 @item dot
3662 @*Type: Boolean. 3680 @*Type: Boolean.
3663 @*Default: False. 3681 @*Default: False.
...@@ -3666,6 +3684,7 @@ This variable is not used. It exists for compatibility with other ...@@ -3666,6 +3684,7 @@ This variable is not used. It exists for compatibility with other
3666 If @code{True}, causes @command{mail} to interpret a period alone on a line as the 3684 If @code{True}, causes @command{mail} to interpret a period alone on a line as the
3667 terminator of a message you are sending. 3685 terminator of a message you are sending.
3668 3686
3687 @kwindex emptystart
3669 @item emptystart 3688 @item emptystart
3670 @*Type: Boolean. 3689 @*Type: Boolean.
3671 @*Default: False. 3690 @*Default: False.
...@@ -3675,6 +3694,7 @@ If the mailbox is empty, @command{mail} normally prints @samp{No mail for user} ...@@ -3675,6 +3694,7 @@ If the mailbox is empty, @command{mail} normally prints @samp{No mail for user}
3675 exits immediately. If this option is set, @command{mail} will start no matter is 3694 exits immediately. If this option is set, @command{mail} will start no matter is
3676 the mailbox empty or not. 3695 the mailbox empty or not.
3677 3696
3697 @kwindex editheaders
3678 @item editheaders 3698 @item editheaders
3679 @*Type: Boolean. 3699 @*Type: Boolean.
3680 @*Default: False. 3700 @*Default: False.
...@@ -3684,6 +3704,7 @@ When set, @command{mail} will include message headers in the text to ...@@ -3684,6 +3704,7 @@ When set, @command{mail} will include message headers in the text to
3684 be the @code{~e} and @code{~v} escapes, thus allowing you to customize 3704 be the @code{~e} and @code{~v} escapes, thus allowing you to customize
3685 the headers. 3705 the headers.
3686 3706
3707 @kwindex escape
3687 @item escape 3708 @item escape
3688 @*Type: String. 3709 @*Type: String.
3689 @*Default: ~ 3710 @*Default: ~
...@@ -3692,6 +3713,7 @@ the headers. ...@@ -3692,6 +3713,7 @@ the headers.
3692 If defined, the first character of this option gives the character to 3713 If defined, the first character of this option gives the character to
3693 denoting escapes. 3714 denoting escapes.
3694 3715
3716 @kwindex flipr
3695 @item flipr 3717 @item flipr
3696 @*Type: Boolean 3718 @*Type: Boolean
3697 @*Default: Unset 3719 @*Default: Unset
...@@ -3700,6 +3722,7 @@ denoting escapes. ...@@ -3700,6 +3722,7 @@ denoting escapes.
3700 If set, the variable @code{flipr} swaps the meanings of @code{reply} 3722 If set, the variable @code{flipr} swaps the meanings of @code{reply}
3701 and @code{Reply} commands (@pxref{Replying}). 3723 and @code{Reply} commands (@pxref{Replying}).
3702 3724
3725 @kwindex folder
3703 @item folder 3726 @item folder
3704 @*Type: String. 3727 @*Type: String.
3705 @*Default: Unset. 3728 @*Default: Unset.
...@@ -3709,6 +3732,7 @@ The name of the directory to use for storing folders of messages. If ...@@ -3709,6 +3732,7 @@ The name of the directory to use for storing folders of messages. If
3709 unset, @env{$HOME} is assumed. 3732 unset, @env{$HOME} is assumed.
3710 3733
3711 @anchor{fromfield} 3734 @anchor{fromfield}
3735 @kwindex fromfield
3712 @item fromfield 3736 @item fromfield
3713 @*Type: Boolean. 3737 @*Type: Boolean.
3714 @*Default: True. 3738 @*Default: True.
...@@ -3719,6 +3743,7 @@ Unsetting this variable tells @command{mail} to obtain it from the ...@@ -3719,6 +3743,7 @@ Unsetting this variable tells @command{mail} to obtain it from the
3719 3743
3720 @xref{datefield}. 3744 @xref{datefield}.
3721 3745
3746 @kwindex header
3722 @item header 3747 @item header
3723 @*Type: Boolean. 3748 @*Type: Boolean.
3724 @*Default: True, unless started with @option{--nosum} (@option{-N}) option. 3749 @*Default: True, unless started with @option{--nosum} (@option{-N}) option.
...@@ -3727,6 +3752,56 @@ Unsetting this variable tells @command{mail} to obtain it from the ...@@ -3727,6 +3752,56 @@ Unsetting this variable tells @command{mail} to obtain it from the
3727 Whether to run @code{headers} command automatically after entering 3752 Whether to run @code{headers} command automatically after entering
3728 interactive mode. 3753 interactive mode.
3729 3754
3755 @kwindex headline
3756 @item headline
3757 @*Type: String
3758 @*Default: @samp{%>%a%4m %18f %16d %3l/%-5o %s}
3759
3760 A format string to use for the header summary. The @samp{%} character
3761 introduces a @dfn{format specifier}. Valid format specifiers are:
3762
3763 @multitable @columnfractions 0.2 0.8
3764 @headitem Letter @tab Meaning
3765 @item %a @tab Message attributes.
3766 @item %d @tab The date when the message was received.
3767 @item %f @tab The address of the message sender.
3768 @item %l @tab The number of lines of the message.
3769 @item %m @tab Message number.
3770 @item %o @tab The number of octets (bytes) in the message.
3771 @item %s @tab Message subject (if any).
3772 @item %S @tab Message subject (if any) in double quotes.
3773 @item %> @tab A @samp{>} for the current message, otherwise a space.
3774 @item %< @tab A @samp{<} for the current message, otherwise a space.
3775 @item %% @tab A `%' character.
3776 @end multitable
3777
3778 Some additional symbols are allowed between @samp{%} and the specifier
3779 letter. The @samp{-} character immediately following @samp{%}
3780 indicates that this field should be left aligned. Similarly, the
3781 @samp{+} character indicates right alignment. Default alignment
3782 depends on the type of the specifier: the specifiers that produce
3783 numeric values (@samp{%l}, @samp{%m}, and @samp{%o}) are aligned to
3784 the right, whereas the ones producing string values are aligned to the
3785 left.
3786
3787 A number following @samp{%} or the alignment flag, indicates the
3788 field width. Consider, for example, the following specifiers:
3789
3790 @table @asis
3791 @item %m
3792 Print current message number. Take as much screen columns as necessary
3793 to output it.
3794
3795 @item %4m
3796 @itemx %+4m
3797 Print current message number. Occupy 4 screen columns, truncate the
3798 output if it does not fit that width. Align the output to the right.
3799
3800 @item %-4m
3801 Same as above, but align to the left.
3802 @end table
3803
3804 @kwindex hold
3730 @item hold 3805 @item hold
3731 @*Type: Boolean. 3806 @*Type: Boolean.
3732 @*Default: False. 3807 @*Default: False.
...@@ -3737,6 +3812,7 @@ user's mailbox (@file{$HOME/mbox}). Otherwise, they will be held in ...@@ -3737,6 +3812,7 @@ user's mailbox (@file{$HOME/mbox}). Otherwise, they will be held in
3737 system mailbox also. This option is in effect only when operating 3812 system mailbox also. This option is in effect only when operating
3738 upon user's system mailbox. 3813 upon user's system mailbox.
3739 3814
3815 @kwindex ignore
3740 @item ignore 3816 @item ignore
3741 @*Type: Boolean. 3817 @*Type: Boolean.
3742 @*Default: False. 3818 @*Default: False.
...@@ -3746,6 +3822,7 @@ When set to @code{True}, @command{mail} will ignore keyboard interrupts ...@@ -3746,6 +3822,7 @@ When set to @code{True}, @command{mail} will ignore keyboard interrupts
3746 when composing messages. Otherwise an interrupt will be taken as a 3822 when composing messages. Otherwise an interrupt will be taken as a
3747 signal to abort composing. 3823 signal to abort composing.
3748 3824
3825 @kwindex ignoreeof
3749 @item ignoreeof 3826 @item ignoreeof
3750 @*Type: Boolean. 3827 @*Type: Boolean.
3751 @*Default: False. 3828 @*Default: False.
...@@ -3754,6 +3831,7 @@ signal to abort composing. ...@@ -3754,6 +3831,7 @@ signal to abort composing.
3754 Controls whether typing EOF character terminates the letter being 3831 Controls whether typing EOF character terminates the letter being
3755 composed. 3832 composed.
3756 3833
3834 @kwindex indentprefix
3757 @item indentprefix 3835 @item indentprefix
3758 @*Type: String. 3836 @*Type: String.
3759 @*Default: "\t" (a tab character). 3837 @*Default: "\t" (a tab character).
...@@ -3761,6 +3839,7 @@ composed. ...@@ -3761,6 +3839,7 @@ composed.
3761 3839
3762 String used by the @code{~m} tilde escape for indenting quoted messages. 3840 String used by the @code{~m} tilde escape for indenting quoted messages.
3763 3841
3842 @kwindex inplacealiases
3764 @item inplacealiases 3843 @item inplacealiases
3765 @*Type: Boolean 3844 @*Type: Boolean
3766 @*Default: False 3845 @*Default: False
...@@ -3770,6 +3849,7 @@ before entering send mode (@pxref{Composing Mail}). By default, the ...@@ -3770,6 +3849,7 @@ before entering send mode (@pxref{Composing Mail}). By default, the
3770 address header fields are left intact while composing, the alias 3849 address header fields are left intact while composing, the alias
3771 expansion takes place immediately before sending message. 3850 expansion takes place immediately before sending message.
3772 3851
3852 @kwindex keep
3773 @item keep 3853 @item keep
3774 @*Type: Boolean, Read-Only 3854 @*Type: Boolean, Read-Only
3775 @*Default: True 3855 @*Default: True
...@@ -3779,6 +3859,7 @@ Truncate the user's system mailbox when it is empty, instead of ...@@ -3779,6 +3859,7 @@ Truncate the user's system mailbox when it is empty, instead of
3779 removing it. This is the default and cannot be changed. This variable 3859 removing it. This is the default and cannot be changed. This variable
3780 exists only for compatibility with other @command{mailx} implementations. 3860 exists only for compatibility with other @command{mailx} implementations.
3781 3861
3862 @kwindex keepsave
3782 @item keepsave 3863 @item keepsave
3783 @*Type: Boolean. 3864 @*Type: Boolean.
3784 @*Default: False. 3865 @*Default: False.
...@@ -3788,6 +3869,7 @@ Controls whether saved messages should be kept in system mailbox too. ...@@ -3788,6 +3869,7 @@ Controls whether saved messages should be kept in system mailbox too.
3788 This variable is in effect only when operating upon a user's system 3869 This variable is in effect only when operating upon a user's system
3789 mailbox. 3870 mailbox.
3790 3871
3872 @kwindex mailx
3791 @item mailx 3873 @item mailx
3792 @*Type: Boolean. 3874 @*Type: Boolean.
3793 @*Default: False. 3875 @*Default: False.
...@@ -3807,6 +3889,7 @@ will exit with zero status. By default it exits with zero status only ...@@ -3807,6 +3889,7 @@ will exit with zero status. By default it exits with zero status only
3807 if the message was sent successfully. 3889 if the message was sent successfully.
3808 @end itemize 3890 @end itemize
3809 3891
3892 @kwindex metamail
3810 @item metamail 3893 @item metamail
3811 @*Type: Boolean or String. 3894 @*Type: Boolean or String.
3812 @*Default: True. 3895 @*Default: True.
...@@ -3830,6 +3913,7 @@ set metamail ...@@ -3830,6 +3913,7 @@ set metamail
3830 set metamail="metamail -m mail -p" 3913 set metamail="metamail -m mail -p"
3831 @end smallexample 3914 @end smallexample
3832 3915
3916 @kwindex mimenoask
3833 @item mimenoask 3917 @item mimenoask
3834 @*Type: String 3918 @*Type: String
3835 @*Default: Empty 3919 @*Default: Empty
...@@ -3850,6 +3934,7 @@ will disable prompting before displaying any textual files, no ...@@ -3850,6 +3934,7 @@ will disable prompting before displaying any textual files, no
3850 matter what their subtype is, and before displaying files with 3934 matter what their subtype is, and before displaying files with
3851 type @samp{image/jpeg}. 3935 type @samp{image/jpeg}.
3852 3936
3937 @kwindex metoo
3853 @item metoo 3938 @item metoo
3854 @*Type: Boolean. 3939 @*Type: Boolean.
3855 @*Default: False. 3940 @*Default: False.
...@@ -3859,6 +3944,7 @@ Usually, when an alias is expanded that contains the sender, the sender ...@@ -3859,6 +3944,7 @@ Usually, when an alias is expanded that contains the sender, the sender
3859 is removed from the expansion. Setting this option causes the sender to 3944 is removed from the expansion. Setting this option causes the sender to
3860 be included in the group. 3945 be included in the group.
3861 3946
3947 @kwindex mode
3862 @item mode 3948 @item mode
3863 @*Type: String, Read-Only 3949 @*Type: String, Read-Only
3864 @*Default: The name of current operation mode. 3950 @*Default: The name of current operation mode.
...@@ -3888,6 +3974,7 @@ The program operates in send mode. This means it was given one or more ...@@ -3888,6 +3974,7 @@ The program operates in send mode. This means it was given one or more
3888 recipient addresses in the command line. 3974 recipient addresses in the command line.
3889 @end table 3975 @end table
3890 3976
3977 @kwindex nullbody
3891 @item nullbody 3978 @item nullbody
3892 @* Type: Boolean 3979 @* Type: Boolean
3893 @* Default: True 3980 @* Default: True
...@@ -3912,6 +3999,7 @@ outputs something on its standard output or error: ...@@ -3912,6 +3999,7 @@ outputs something on its standard output or error:
3912 @end group 3999 @end group
3913 @end smallexample 4000 @end smallexample
3914 4001
4002 @kwindex showenvelope
3915 @item showenvelope 4003 @item showenvelope
3916 @*Type: Boolean 4004 @*Type: Boolean
3917 @*Default: Unset 4005 @*Default: Unset
...@@ -3919,6 +4007,7 @@ outputs something on its standard output or error: ...@@ -3919,6 +4007,7 @@ outputs something on its standard output or error:
3919 If this variable is set, the @code{print} command will include the 4007 If this variable is set, the @code{print} command will include the
3920 @acronym{STMP} envelope in its output. 4008 @acronym{STMP} envelope in its output.
3921 4009
4010 @kwindex nullbodymsg
3922 @item nullbodymsg 4011 @item nullbodymsg
3923 @*Type: String 4012 @*Type: String
3924 @*Default: Null message body; hope that's ok 4013 @*Default: Null message body; hope that's ok
...@@ -3930,6 +4019,7 @@ this text, in accordance with the current locale, is displayed. ...@@ -3930,6 +4019,7 @@ this text, in accordance with the current locale, is displayed.
3930 4019
3931 Unsetting this variable disables the warning. 4020 Unsetting this variable disables the warning.
3932 4021
4022 @kwindex onehop
3933 @item onehop 4023 @item onehop
3934 @*Type: Boolean 4024 @*Type: Boolean
3935 @*Default: Unset 4025 @*Default: Unset
...@@ -3938,6 +4028,7 @@ Unsetting this variable disables the warning. ...@@ -3938,6 +4028,7 @@ Unsetting this variable disables the warning.
3938 This variable is not used. It exists for compatibility with other 4028 This variable is not used. It exists for compatibility with other
3939 @command{mailx} implementations and for future use. 4029 @command{mailx} implementations and for future use.
3940 4030
4031 @kwindex outfolder
3941 @item outfolder 4032 @item outfolder
3942 @*Type: String. 4033 @*Type: String.
3943 @*Default: Unset. 4034 @*Default: Unset.
...@@ -3947,6 +4038,7 @@ Contains the directory in which files created by @code{save}, ...@@ -3947,6 +4038,7 @@ Contains the directory in which files created by @code{save},
3947 @code{write}, etc. commands will be stored. When unset, current 4038 @code{write}, etc. commands will be stored. When unset, current
3948 directory is assumed. 4039 directory is assumed.
3949 4040
4041 @kwindex page
3950 @item page 4042 @item page
3951 @*Type: Boolean. 4043 @*Type: Boolean.
3952 @*Default: False. 4044 @*Default: False.
...@@ -3955,6 +4047,7 @@ directory is assumed. ...@@ -3955,6 +4047,7 @@ directory is assumed.
3955 If set to @code{True}, the @code{pipe} command will emit a linefeed 4047 If set to @code{True}, the @code{pipe} command will emit a linefeed
3956 character after printing each message. 4048 character after printing each message.
3957 4049
4050 @kwindex prompt
3958 @item prompt 4051 @item prompt
3959 @*Type: String. 4052 @*Type: String.
3960 @*Default: "? " 4053 @*Default: "? "
...@@ -3962,6 +4055,7 @@ character after printing each message. ...@@ -3962,6 +4055,7 @@ character after printing each message.
3962 4055
3963 Contains the command prompt sequence. 4056 Contains the command prompt sequence.
3964 4057
4058 @kwindex quiet
3965 @item quiet 4059 @item quiet
3966 @*Type: Boolean 4060 @*Type: Boolean
3967 @*Default: Unset 4061 @*Default: Unset
...@@ -3970,6 +4064,7 @@ Contains the command prompt sequence. ...@@ -3970,6 +4064,7 @@ Contains the command prompt sequence.
3970 This variable is not used. It exists for compatibility with other 4064 This variable is not used. It exists for compatibility with other
3971 @command{mailx} implementations and for future use. 4065 @command{mailx} implementations and for future use.
3972 4066
4067 @kwindex quit
3973 @item quit 4068 @item quit
3974 @*Type: Boolean. 4069 @*Type: Boolean.
3975 @*Default: False, unless started with @option{--quit} (@option{-q}) option. 4070 @*Default: False, unless started with @option{--quit} (@option{-q}) option.
...@@ -3977,6 +4072,7 @@ This variable is not used. It exists for compatibility with other ...@@ -3977,6 +4072,7 @@ This variable is not used. It exists for compatibility with other
3977 4072
3978 When set, causes keyboard interrupts to terminate the program. 4073 When set, causes keyboard interrupts to terminate the program.
3979 4074
4075 @kwindex rc
3980 @item rc 4076 @item rc
3981 @*Type: Boolean. 4077 @*Type: Boolean.
3982 @*Default: True, unless started with @option{--norc} (@option{-N}) option. 4078 @*Default: True, unless started with @option{--norc} (@option{-N}) option.
...@@ -3985,6 +4081,7 @@ When set, causes keyboard interrupts to terminate the program. ...@@ -3985,6 +4081,7 @@ When set, causes keyboard interrupts to terminate the program.
3985 When this variable is set, @command{mail} will read the system-wide 4081 When this variable is set, @command{mail} will read the system-wide
3986 configuration file upon startup. See @ref{Mail Configuration Files}. 4082 configuration file upon startup. See @ref{Mail Configuration Files}.
3987 4083
4084 @kwindex readonly
3988 @item readonly 4085 @item readonly
3989 @*Type: Boolean 4086 @*Type: Boolean
3990 @*Default: False 4087 @*Default: False
...@@ -3995,6 +4092,7 @@ When set, mailboxes are opened in readonly mode. In this mode, any ...@@ -3995,6 +4092,7 @@ When set, mailboxes are opened in readonly mode. In this mode, any
3995 disabled. These commands include, but are not limited to: 4092 disabled. These commands include, but are not limited to:
3996 @code{delete}, @code{save} and @code{mbox}. 4093 @code{delete}, @code{save} and @code{mbox}.
3997 4094
4095 @kwindex record
3998 @item record 4096 @item record
3999 @*Type: String. 4097 @*Type: String.
4000 @*Default: Unset. 4098 @*Default: Unset.
...@@ -4002,12 +4100,14 @@ disabled. These commands include, but are not limited to: ...@@ -4002,12 +4100,14 @@ disabled. These commands include, but are not limited to:
4002 4100
4003 When set, any outgoing message will be saved to the named file. 4101 When set, any outgoing message will be saved to the named file.
4004 4102
4103 @kwindex recursivealiases
4005 @item recursivealiases 4104 @item recursivealiases
4006 @*Type: Boolean 4105 @*Type: Boolean
4007 @*Default: True 4106 @*Default: True
4008 4107
4009 When set, @command{mail} will expand aliases recursively. 4108 When set, @command{mail} will expand aliases recursively.
4010 4109
4110 @kwindex regex
4011 @item regex 4111 @item regex
4012 @*Type: Boolean. 4112 @*Type: Boolean.
4013 @*Default: True. 4113 @*Default: True.
...@@ -4016,6 +4116,7 @@ When set, @command{mail} will expand aliases recursively. ...@@ -4016,6 +4116,7 @@ When set, @command{mail} will expand aliases recursively.
4016 Setting this to @code{True} enables use of regular expressions in 4116 Setting this to @code{True} enables use of regular expressions in
4017 @samp{/.../} message specifications. 4117 @samp{/.../} message specifications.
4018 4118
4119 @kwindex replyprefix
4019 @item replyprefix 4120 @item replyprefix
4020 @*Type: String 4121 @*Type: String
4021 @*Default: @samp{Re: } 4122 @*Default: @samp{Re: }
...@@ -4024,6 +4125,7 @@ Setting this to @code{True} enables use of regular expressions in ...@@ -4024,6 +4125,7 @@ Setting this to @code{True} enables use of regular expressions in
4024 Sets the prefix that will be used when constructing the subject line 4125 Sets the prefix that will be used when constructing the subject line
4025 of a reply message. 4126 of a reply message.
4026 4127
4128 @kwindex replyregex
4027 @item replyregex 4129 @item replyregex
4028 @*Type: String 4130 @*Type: String
4029 @*Default: @samp{^re: *} 4131 @*Default: @samp{^re: *}
...@@ -4045,6 +4147,7 @@ set replyregex="^(re|odp|aw|ang)(\\[[0-9]+\\])?:[[:blank:]]" ...@@ -4045,6 +4147,7 @@ set replyregex="^(re|odp|aw|ang)(\\[[0-9]+\\])?:[[:blank:]]"
4045 @noindent 4147 @noindent
4046 (Notice the quoting of backslash characters). 4148 (Notice the quoting of backslash characters).
4047 4149
4150 @kwindex save
4048 @item save 4151 @item save
4049 @*Type: Boolean. 4152 @*Type: Boolean.
4050 @*Default: True. 4153 @*Default: True.
...@@ -4053,6 +4156,7 @@ set replyregex="^(re|odp|aw|ang)(\\[[0-9]+\\])?:[[:blank:]]" ...@@ -4053,6 +4156,7 @@ set replyregex="^(re|odp|aw|ang)(\\[[0-9]+\\])?:[[:blank:]]"
4053 When set, the aborted messages will be stored in the user's 4156 When set, the aborted messages will be stored in the user's
4054 @file{dead.file}. See also @code{appenddeadletter}. 4157 @file{dead.file}. See also @code{appenddeadletter}.
4055 4158
4159 @kwindex screen
4056 @item screen 4160 @item screen
4057 @*Type: Numeric. 4161 @*Type: Numeric.
4058 @*Default: Detected at startup by querying the terminal device. If this 4162 @*Default: Detected at startup by querying the terminal device. If this
...@@ -4061,6 +4165,7 @@ fails, the value of environment variable @code{LINES} is used. ...@@ -4061,6 +4165,7 @@ fails, the value of environment variable @code{LINES} is used.
4061 4165
4062 This variable contains the number of lines on terminal screen. 4166 This variable contains the number of lines on terminal screen.
4063 4167
4168 @kwindex sendmail
4064 @item sendmail 4169 @item sendmail
4065 @*Type: String. 4170 @*Type: String.
4066 @*Default: sendmail:/usr/lib/sendmail 4171 @*Default: sendmail:/usr/lib/sendmail
...@@ -4068,6 +4173,7 @@ This variable contains the number of lines on terminal screen. ...@@ -4068,6 +4173,7 @@ This variable contains the number of lines on terminal screen.
4068 4173
4069 Contains URL of the mail transport agent. 4174 Contains URL of the mail transport agent.
4070 4175
4176 @kwindex sendwait
4071 @item sendwait 4177 @item sendwait
4072 @*Type: Boolean 4178 @*Type: Boolean
4073 @*Default: Unset 4179 @*Default: Unset
...@@ -4076,6 +4182,7 @@ Contains URL of the mail transport agent. ...@@ -4076,6 +4182,7 @@ Contains URL of the mail transport agent.
4076 This variable is not used. It exists for compatibility with other 4182 This variable is not used. It exists for compatibility with other
4077 @command{mailx} implementations and for future use. 4183 @command{mailx} implementations and for future use.
4078 4184
4185 @kwindex showto
4079 @item showto 4186 @item showto
4080 @*Type: Boolean 4187 @*Type: Boolean
4081 @*Default: False 4188 @*Default: False
...@@ -4084,6 +4191,7 @@ This variable is not used. It exists for compatibility with other ...@@ -4084,6 +4191,7 @@ This variable is not used. It exists for compatibility with other
4084 If the message was sent by the user, print its recipient address in 4191 If the message was sent by the user, print its recipient address in
4085 the header summary. 4192 the header summary.
4086 4193
4194 @kwindex Sign
4087 @item Sign 4195 @item Sign
4088 @*Type: String. 4196 @*Type: String.
4089 @*Default: Unset. 4197 @*Default: Unset.
...@@ -4093,6 +4201,7 @@ Contains the filename holding users signature. The contents of this ...@@ -4093,6 +4201,7 @@ Contains the filename holding users signature. The contents of this
4093 file is appended to the end of a message being composed by @code{~A} 4201 file is appended to the end of a message being composed by @code{~A}
4094 escape. 4202 escape.
4095 4203
4204 @kwindex sign
4096 @item sign 4205 @item sign
4097 @*Type: String. 4206 @*Type: String.
4098 @*Default: Unset. 4207 @*Default: Unset.
...@@ -4102,6 +4211,7 @@ Contains the user's signature. The contents of this variable is appended ...@@ -4102,6 +4211,7 @@ Contains the user's signature. The contents of this variable is appended
4102 to the end of a message being composed by @code{~a} escape. Use 4211 to the end of a message being composed by @code{~a} escape. Use
4103 @code{Sign} variable, if your signature occupies more than one line. 4212 @code{Sign} variable, if your signature occupies more than one line.
4104 4213
4214 @kwindex showto
4105 @item showto 4215 @item showto
4106 @*Type: Boolean 4216 @*Type: Boolean
4107 @*Default: unset 4217 @*Default: unset
...@@ -4111,6 +4221,7 @@ If this variable is set, @command{mail} will show @code{To:} addresses ...@@ -4111,6 +4221,7 @@ If this variable is set, @command{mail} will show @code{To:} addresses
4111 instead of @code{From:} for all messages that come from the user that 4221 instead of @code{From:} for all messages that come from the user that
4112 invoked the program. 4222 invoked the program.
4113 4223
4224 @kwindex subject
4114 @item subject 4225 @item subject
4115 @*Type: String. 4226 @*Type: String.
4116 @*Default: Unset. 4227 @*Default: Unset.
...@@ -4119,6 +4230,7 @@ invoked the program. ...@@ -4119,6 +4230,7 @@ invoked the program.
4119 Contains default subject line. This will be used when @code{asksub} is 4230 Contains default subject line. This will be used when @code{asksub} is
4120 off. 4231 off.
4121 4232
4233 @kwindex toplines
4122 @item toplines 4234 @item toplines
4123 @*Type: Numeric. 4235 @*Type: Numeric.
4124 @*Default: 5 4236 @*Default: 5
...@@ -4126,6 +4238,7 @@ off. ...@@ -4126,6 +4238,7 @@ off.
4126 4238
4127 Number of lines to be displayed by @code{top} and @code{Top} commands. 4239 Number of lines to be displayed by @code{top} and @code{Top} commands.
4128 4240
4241 @kwindex variable-strict
4129 @item variable-strict 4242 @item variable-strict
4130 @itemx varstrict 4243 @itemx varstrict
4131 @*Type: Boolean. 4244 @*Type: Boolean.
...@@ -4138,6 +4251,7 @@ variables. Also, if the user is trying to set an unknown variable, ...@@ -4138,6 +4251,7 @@ variables. Also, if the user is trying to set an unknown variable,
4138 4251
4139 @xref{Setting and Unsetting the Variables}. 4252 @xref{Setting and Unsetting the Variables}.
4140 4253
4254 @kwindex variable-pretty-print
4141 @item variable-pretty-print 4255 @item variable-pretty-print
4142 @itemx varpp 4256 @itemx varpp
4143 @*Type: Boolean. 4257 @*Type: Boolean.
...@@ -4146,6 +4260,7 @@ variables. Also, if the user is trying to set an unknown variable, ...@@ -4146,6 +4260,7 @@ variables. Also, if the user is trying to set an unknown variable,
4146 If this variable is set, the listing ouput by @command{set} contains short 4260 If this variable is set, the listing ouput by @command{set} contains short
4147 descriptions before each variable. @xref{Setting and Unsetting the Variables}. 4261 descriptions before each variable. @xref{Setting and Unsetting the Variables}.
4148 4262
4263 @kwindex verbose
4149 @item verbose 4264 @item verbose
4150 @*Type: Boolean. 4265 @*Type: Boolean.
4151 @*Default: False. 4266 @*Default: False.
...@@ -4153,6 +4268,7 @@ descriptions before each variable. @xref{Setting and Unsetting the Variables}. ...@@ -4153,6 +4268,7 @@ descriptions before each variable. @xref{Setting and Unsetting the Variables}.
4153 4268
4154 When set, the actual delivery of messages is displayed on the user's terminal. 4269 When set, the actual delivery of messages is displayed on the user's terminal.
4155 4270
4271 @kwindex xmailer
4156 @item xmailer 4272 @item xmailer
4157 @*Type: Boolean. 4273 @*Type: Boolean.
4158 @*Default: Set. 4274 @*Default: Set.
......
...@@ -18,27 +18,220 @@ ...@@ -18,27 +18,220 @@
18 MA 02110-1301 USA */ 18 MA 02110-1301 USA */
19 19
20 #include "mail.h" 20 #include "mail.h"
21 #include <mu_umaxtostr.h>
21 22
22 /* 23 #define ALIGN_UNDEF -1
23 * f[rom] [msglist] 24 #define ALIGN_RIGHT 0
24 */ 25 #define ALIGN_LEFT 1
25 26
26 int 27 struct header_call_args
27 mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) 28 {
29 msgset_t *mspec;
30 mu_message_t msg;
31 size_t cols_rest;
32 char *buf;
33 size_t size;
34 };
35
36 struct header_segm
37 {
38 struct header_segm *next;
39 int align;
40 size_t width;
41 void *data;
42 char *(*get) (struct header_call_args *args, void *data);
43 };
44
45 void
46 header_ensure_space (struct header_call_args *args, size_t size)
47 {
48 if (size > args->size)
49 {
50 args->buf = xrealloc (args->buf, size);
51 args->size = size;
52 }
53 }
54
55 static char *
56 header_buf_string_len (struct header_call_args *args, const char *str,
57 size_t len)
58 {
59 header_ensure_space (args, len + 1);
60 memcpy (args->buf, str, len);
61 args->buf[len] = 0;
62 return args->buf;
63 }
64
65 static char *
66 header_buf_string (struct header_call_args *args, const char *str)
67 {
68 if (!str)
69 return header_buf_string_len (args, "", 0);
70 return header_buf_string_len (args, str, strlen (str));
71 }
72
73 static void
74 format_pad (size_t n)
75 {
76 for (; n; n--)
77 fputc (' ', ofile);
78 }
79
80 static void
81 format_headline (struct header_segm *seg, msgset_t *mspec, mu_message_t msg)
82 {
83 int screen_cols = util_getcols () - 2;
84 int out_cols = 0;
85 struct header_call_args args;
86
87 args.mspec = mspec;
88 args.msg = msg;
89 args.buf = NULL;
90 args.size = 0;
91
92 for (; seg; seg = seg->next)
93 {
94 size_t width, len;
95 size_t cols_rest = screen_cols - out_cols;
96 char *p;
97
98 args.cols_rest = cols_rest;
99 p = seg->get (&args, seg->data);
100
101 if (!p)
102 p = "";
103 len = strlen (p);
104
105 if (seg->width)
106 width = seg->width;
107 else
108 width = len;
109 if (width > cols_rest)
110 width = cols_rest;
111
112 if (len > width)
113 len = width;
114
115 if (seg->align == ALIGN_RIGHT)
116 {
117 format_pad (width - len);
118 fprintf (ofile, "%*.*s", len, len, p);
119 }
120 else
121 {
122 fprintf (ofile, "%*.*s", len, len, p);
123 format_pad (width - len);
124 }
125 out_cols += width;
126 }
127
128 fprintf (ofile, "\n");
129 free (args.buf);
130 }
131
132 static void
133 free_headline (struct header_segm *seg)
134 {
135 while (seg)
136 {
137 struct header_segm *next = seg->next;
138 if (seg->data)
139 free (seg->data);
140 free (seg);
141 seg = next;
142 }
143 }
144
145
146 static char *
147 hdr_text (struct header_call_args *args, void *data)
148 {
149 return data;
150 }
151
152 static char *
153 hdr_cur (struct header_call_args *args, void *data)
154 {
155 if (is_current_message (args->mspec->msg_part[0]))
156 return (char*) data;
157 return " ";
158 }
159
160 /* %a */
161 static char *
162 hdr_attr (struct header_call_args *args, void *data)
28 { 163 {
29 mu_header_t hdr = NULL;
30 mu_envelope_t env;
31 mu_attribute_t attr; 164 mu_attribute_t attr;
32 char *from = NULL, *subj = NULL, *fromp, *subjp; 165 char cflag;
33 int froml, subjl; 166
34 char date[80], st[10]; 167 mu_message_get_attribute (args->msg, &attr);
35 int cols = util_getcols () - 6; 168
36 int cflag; 169 if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED))
37 size_t m_size = 0, m_lines = 0; 170 cflag = 'M';
171 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED))
172 cflag = 'P';
173 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
174 cflag = '*';
175 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_TAGGED))
176 cflag = 'T';
177 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SHOWN))
178 cflag = 'R';
179 else if (mu_attribute_is_recent (attr))
180 cflag = 'N';
181 else if (!mu_attribute_is_read (attr))
182 cflag = 'U';
183 else
184 cflag = ' ';
185 return header_buf_string_len (args, &cflag, 1);
186 }
187
188 /* %d */
189 static char *
190 hdr_date (struct header_call_args *args, void *data)
191 {
192 char date[80];
193 mu_header_t hdr;
38 194
195 mu_message_get_header (args->msg, &hdr);
196
197 date[0] = 0;
198 if (mailvar_get (NULL, "datefield", mailvar_type_boolean, 0) == 0
199 && mu_header_get_value (hdr, MU_HEADER_DATE,
200 date, sizeof (date), NULL) == 0)
201 {
202 time_t t;
203 if (mu_parse_date (date, &t, NULL) == 0)
204 strftime (date, sizeof(date), "%a %b %e %H:%M", localtime (&t));
205 else
206 date[0] = 0;
207 }
208
209 if (date[0] == 0)
210 {
211 const char *p;
212 struct tm tm;
213 mu_timezone tz;
214 mu_envelope_t env;
215
216 mu_message_get_envelope (args->msg, &env);
217 if (mu_envelope_sget_date (env, &p) == 0
218 && mu_parse_ctime_date_time (&p, &tm, &tz) == 0)
219 strftime (date, sizeof(date), "%a %b %e %H:%M", &tm);
220 }
221 return header_buf_string (args, date);
222 }
223
224 /* %f */
225 static char *
226 hdr_from (struct header_call_args *args, void *data)
227 {
228 char *from = NULL;
229
39 if (mailvar_get (NULL, "fromfield", mailvar_type_boolean, 0) == 0) 230 if (mailvar_get (NULL, "fromfield", mailvar_type_boolean, 0) == 0)
40 { 231 {
41 mu_message_get_header (msg, &hdr); 232 mu_header_t hdr;
233
234 mu_message_get_header (args->msg, &hdr);
42 if (mu_header_aget_value_unfold (hdr, MU_HEADER_FROM, &from) == 0) 235 if (mu_header_aget_value_unfold (hdr, MU_HEADER_FROM, &from) == 0)
43 { 236 {
44 mu_address_t address = NULL; 237 mu_address_t address = NULL;
...@@ -49,7 +242,8 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) ...@@ -49,7 +242,8 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data)
49 242
50 if (mu_address_sget_email (address, 1, &email) == 0) 243 if (mu_address_sget_email (address, 1, &email) == 0)
51 { 244 {
52 if (mailvar_get (NULL, "showto", mailvar_type_boolean, 0) == 0 245 if (mailvar_get (NULL, "showto",
246 mailvar_type_boolean, 0) == 0
53 && mail_is_my_name (email)) 247 && mail_is_my_name (email))
54 { 248 {
55 char *tmp; 249 char *tmp;
...@@ -86,87 +280,263 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) ...@@ -86,87 +280,263 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data)
86 mu_envelope_t env = NULL; 280 mu_envelope_t env = NULL;
87 const char *sender = ""; 281 const char *sender = "";
88 282
89 if (mu_message_get_envelope (msg, &env) == 0) 283 if (mu_message_get_envelope (args->msg, &env) == 0)
90 mu_envelope_sget_sender (env, &sender); 284 mu_envelope_sget_sender (env, &sender);
91 from = strdup (sender); 285 from = strdup (sender);
92 } 286 }
93 287
288 header_buf_string (args, from);
289 free (from);
290 return args->buf;
291 }
292
293 /* %l */
294 static char *
295 hdr_lines (struct header_call_args *args, void *data)
296 {
297 size_t m_lines;
298 char buf[UINTMAX_STRSIZE_BOUND];
299 mu_message_lines (args->msg, &m_lines);
300
301 return header_buf_string (args, umaxtostr (m_lines, buf));
302 }
303
304 /* %m */
305 static char *
306 hdr_number (struct header_call_args *args, void *data)
307 {
308 char buf[UINTMAX_STRSIZE_BOUND];
309 return header_buf_string (args, umaxtostr (args->mspec->msg_part[0], buf));
310 }
311
312 /* %o */
313 static char *
314 hdr_size (struct header_call_args *args, void *data)
315 {
316 size_t m_size;
317 char buf[UINTMAX_STRSIZE_BOUND];
318 mu_message_size (args->msg, &m_size);
319
320 return header_buf_string (args, umaxtostr (m_size, buf));
321 }
322
323 /* %s */
324 static char *
325 hdr_subject (struct header_call_args *args, void *data)
326 {
327 mu_header_t hdr;
328 char *subj = NULL;
329
330 mu_message_get_header (args->msg, &hdr);
94 mu_header_aget_value_unfold (hdr, MU_HEADER_SUBJECT, &subj); 331 mu_header_aget_value_unfold (hdr, MU_HEADER_SUBJECT, &subj);
95 util_rfc2047_decode (&subj); 332 util_rfc2047_decode (&subj);
96 333
97 mu_message_get_attribute (msg, &attr); 334 header_buf_string (args, subj);
335 free (subj);
336 return args->buf;
337 }
338
339 /* %S */
340 static char *
341 hdr_q_subject (struct header_call_args *args, void *data)
342 {
343 mu_header_t hdr;
344 char *subj = NULL;
345 size_t len;
346
347 if (args->cols_rest <= 2)
348 return "\"\"";
98 349
99 if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED)) 350 mu_message_get_header (args->msg, &hdr);
100 cflag = 'M'; 351 mu_header_aget_value_unfold (hdr, MU_HEADER_SUBJECT, &subj);
101 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED)) 352 if (!subj)
102 cflag = 'P'; 353 return "";
103 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)) 354 util_rfc2047_decode (&subj);
104 cflag = '*';
105 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_TAGGED))
106 cflag = 'T';
107 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SHOWN))
108 cflag = 'R';
109 else if (mu_attribute_is_recent (attr))
110 cflag = 'N';
111 else if (!mu_attribute_is_read (attr))
112 cflag = 'U';
113 else
114 cflag = ' ';
115 355
116 date[0] = 0; 356 len = strlen (subj);
117 if (mailvar_get (NULL, "datefield", mailvar_type_boolean, 0) == 0 357 if (len + 2 > args->cols_rest)
118 && mu_header_get_value (hdr, MU_HEADER_DATE, date, sizeof (date), NULL) == 0) 358 len = args->cols_rest - 2;
359 header_ensure_space (args, len + 3);
360 args->buf[0] = '"';
361 memcpy (args->buf + 1, subj, len);
362 args->buf[len+1] = '"';
363 args->buf[len+2] = 0;
364 free (subj);
365 return args->buf;
366 }
367
368
369 static struct header_segm *
370 new_header_segment (int align, size_t width,
371 void *data,
372 char *(*get) (struct header_call_args *, void *))
373 {
374 struct header_segm *seg = xmalloc (sizeof (*seg));
375 seg->next = NULL;
376 seg->align = align;
377 seg->width = width;
378 seg->data = data;
379 seg->get = get;
380 return seg;
381 }
382
383 struct header_segm *
384 compile_headline (const char *str)
385 {
386 struct header_segm *head = NULL, *tail = NULL;
387 char *text;
388 int align;
389 size_t width;
390
391 #define ALIGN_STRING (align == ALIGN_UNDEF ? ALIGN_LEFT : ALIGN_RIGHT)
392 #define ALIGN_NUMBER (align == ALIGN_UNDEF ? ALIGN_RIGHT : ALIGN_LEFT)
393 #define ATTACH(p) \
394 do \
395 { \
396 if (!head) \
397 head = p; \
398 else \
399 tail->next = p; \
400 tail = p; \
401 } \
402 while (0)
403
404 while (*str)
119 { 405 {
120 time_t t; 406 struct header_segm *seg;
121 if (mu_parse_date (date, &t, NULL) == 0) 407 size_t len;
408 char *p = strchr (str, '%');
409 if (!p)
410 len = strlen (str);
411 else
412 len = p - str;
413 if (len)
122 { 414 {
123 strftime (date, sizeof(date), "%a %b %e %H:%M", localtime (&t)); 415 text = xmalloc (len + 1);
416 memcpy (text, str, len);
417 text[len] = 0;
418 seg = new_header_segment (ALIGN_LEFT, 0, text, hdr_text);
419 ATTACH (seg);
420 }
421 if (!p)
422 break;
423
424 str = ++p;
425
426 if (*str == '-')
427 {
428 str++;
429 align = ALIGN_LEFT;
430 }
431 else if (*str == '+')
432 {
433 str++;
434 align = ALIGN_RIGHT;
124 } 435 }
125 else 436 else
126 date[0] = 0; 437 align = ALIGN_UNDEF;
127 } 438
439 if (mu_isdigit (*str))
440 width = strtoul (str, (char**)&str, 10);
441 else
442 width = 0;
128 443
129 if (date[0] == 0) 444 switch (*str++)
130 { 445 {
131 const char *p; 446 case '%':
132 struct tm tm; 447 seg = new_header_segment (ALIGN_LEFT, 0, xstrdup ("%"), hdr_text);
133 mu_timezone tz; 448 break;
449
450 case 'a': /* Message attributes. */
451 seg = new_header_segment (ALIGN_STRING, width, NULL, hdr_attr);
452 break;
134 453
135 mu_message_get_envelope (msg, &env); 454 /* FIXME: %c The score of the message. */
136 if (mu_envelope_sget_date (env, &p) == 0 455
137 && mu_parse_ctime_date_time (&p, &tm, &tz) == 0) 456 case 'd': /* Message date */
138 strftime (date, sizeof(date), "%a %b %e %H:%M", &tm); 457 seg = new_header_segment (ALIGN_STRING, width, NULL, hdr_date);
458 break;
459
460 /* FIXME: %e The indenting level in threaded mode. */
461
462 case 'f': /* Message sender */
463 seg = new_header_segment (ALIGN_STRING, width, NULL, hdr_from);
464 break;
465
466 /* FIXME: %i The message thread structure. */
467
468 case 'l': /* The number of lines of the message */
469 seg = new_header_segment (ALIGN_NUMBER, width, NULL, hdr_lines);
470 break;
471
472 case 'm': /* Message number */
473 seg = new_header_segment (ALIGN_NUMBER, width, NULL, hdr_number);
474 break;
475
476 case 'o': /* The number of octets (bytes) in the message */
477 seg = new_header_segment (ALIGN_NUMBER, width, NULL, hdr_size);
478 break;
479
480 case 's': /* Message subject (if any) */
481 seg = new_header_segment (ALIGN_STRING, width, NULL, hdr_subject);
482 break;
483
484 case 'S': /* Message subject (if any) in double quotes */
485 seg = new_header_segment (ALIGN_STRING, width, NULL, hdr_q_subject);
486 break;
487
488 /* FIXME: %t The position in threaded/sorted order. */
489
490 case '>': /* A `>' for the current message, otherwise ` ' */
491 seg = new_header_segment (ALIGN_STRING, width, xstrdup (">"), hdr_cur);
492 break;
493
494 case '<': /* A `<' for the current message, otherwise ` ' */
495 seg = new_header_segment (ALIGN_STRING, width, xstrdup ("<"), hdr_cur);
496 break;
497
498 default:
499 mu_error (_("unknown escape: %%%c"), str[-1]);
500 len = str - p;
501 text = xmalloc (len);
502 memcpy (text, p, len-1);
503 text[len-1] = 0;
504 seg = new_header_segment (ALIGN_STRING, width, text, hdr_text);
505 }
506 ATTACH (seg);
139 } 507 }
140 508 return head;
141 mu_message_size (msg, &m_size); 509 #undef ALIGN_STRING
142 mu_message_lines (msg, &m_lines); 510 #undef ALIGN_NUMBER
143 511 #undef ATTACH
144 snprintf (st, sizeof (st), "%3d/%-5d", m_lines, m_size); 512 }
145 513
146 /* The "From" field will take a third of the screen. 514 /* FIXME: Should it be part of struct mailvar_variable for "headline"? */
147 Subject will take the rest. 515 static struct header_segm *mail_header_line;
148 FIXME: This is not quite correct that we use fixed sizes 516
149 18, 16 for the other fields. 517 void
150 */ 518 mail_compile_headline (struct mailvar_variable *var)
151 froml = cols / 3; 519 {
152 subjl = cols - froml - strlen (st) - 16; 520 free_headline (mail_header_line);
153 521 mail_header_line = compile_headline (var->value.string);
154 fromp = from ? from : ""; 522 }
155 subjp = subj ? subj : fromp; 523
156 fprintf (ofile, "%c%c%4d %-18.18s %-16.16s %s %.*s\n", 524
157 is_current_message (mspec->msg_part[0]) ? '>' : ' ', cflag, 525 /*
158 mspec->msg_part[0], 526 * f[rom] [msglist]
159 fromp, date, st, (subjl < 0) ? 0 : subjl, subjp); 527 */
160
161 free (from);
162 free (subj);
163 528
529 int
530 mail_from0 (msgset_t *mspec, mu_message_t msg, void *data)
531 {
532 format_headline (mail_header_line, mspec, msg);
164 return 0; 533 return 0;
165 } 534 }
166 535
167 int 536 int
168 mail_from (int argc, char **argv) 537 mail_from (int argc, char **argv)
169 { 538 {
170 return util_foreach_msg (argc, argv, MSG_NODELETED|MSG_SILENT, mail_from0, NULL); 539 return util_foreach_msg (argc, argv, MSG_NODELETED|MSG_SILENT,
540 mail_from0, NULL);
171 } 541 }
172 542
......
...@@ -287,6 +287,7 @@ static char *default_setup[] = { ...@@ -287,6 +287,7 @@ static char *default_setup[] = {
287 "set recursivealiases", 287 "set recursivealiases",
288 "set noinplacealiases", 288 "set noinplacealiases",
289 "set fromfield", 289 "set fromfield",
290 "set headline=\"%>%a%4m %18f %16d %3l/%-5o %s\"",
290 291
291 /* Start in mail reading mode */ 292 /* Start in mail reading mode */
292 "setq mode=read", 293 "setq mode=read",
...@@ -364,7 +365,7 @@ main (int argc, char **argv) ...@@ -364,7 +365,7 @@ main (int argc, char **argv)
364 365
365 /* set defaults for execution */ 366 /* set defaults for execution */
366 for (i = 0; i < sizeof (default_setup)/sizeof (default_setup[0]); i++) 367 for (i = 0; i < sizeof (default_setup)/sizeof (default_setup[0]); i++)
367 util_do_command (default_setup[i]); 368 util_do_command ("%s", default_setup[i]);
368 util_do_command ("set screen=%d", util_getlines ()); 369 util_do_command ("set screen=%d", util_getlines ());
369 util_do_command ("set columns=%d", util_getcols ()); 370 util_do_command ("set columns=%d", util_getcols ());
370 371
......
...@@ -45,11 +45,7 @@ ...@@ -45,11 +45,7 @@
45 #endif 45 #endif
46 #include <sys/wait.h> 46 #include <sys/wait.h>
47 #include <sys/types.h> 47 #include <sys/types.h>
48 #ifdef HAVE_STDARG_H 48 #include <stdarg.h>
49 # include <stdarg.h>
50 #else
51 # include <varargs.h>
52 #endif
53 #include <signal.h> 49 #include <signal.h>
54 50
55 #include <confpaths.h> 51 #include <confpaths.h>
...@@ -200,6 +196,8 @@ extern int mail_folders (int argc, char **argv); ...@@ -200,6 +196,8 @@ extern int mail_folders (int argc, char **argv);
200 extern int mail_followup (int argc, char **argv); 196 extern int mail_followup (int argc, char **argv);
201 extern int mail_from (int argc, char **argv); 197 extern int mail_from (int argc, char **argv);
202 extern int mail_from0 (msgset_t *mspec, mu_message_t msg, void *data); 198 extern int mail_from0 (msgset_t *mspec, mu_message_t msg, void *data);
199 extern void mail_compile_headline (struct mailvar_variable *var);
200
203 extern int mail_headers (int argc, char **argv); 201 extern int mail_headers (int argc, char **argv);
204 extern int mail_hold (int argc, char **argv); 202 extern int mail_hold (int argc, char **argv);
205 extern int mail_help (int argc, char **argv); 203 extern int mail_help (int argc, char **argv);
......
...@@ -130,6 +130,10 @@ struct mailvar_symbol mailvar_tab[] = ...@@ -130,6 +130,10 @@ struct mailvar_symbol mailvar_tab[] =
130 { { "header", }, 130 { { "header", },
131 MAILVAR_TYPEMASK (mailvar_type_boolean), 131 MAILVAR_TYPEMASK (mailvar_type_boolean),
132 N_("run the `headers' command after entering interactive mode") }, 132 N_("run the `headers' command after entering interactive mode") },
133 { { "headline", },
134 MAILVAR_TYPEMASK (mailvar_type_string),
135 N_("format string to use for the header summary"),
136 mail_compile_headline },
133 { { "hold", }, 137 { { "hold", },
134 MAILVAR_TYPEMASK (mailvar_type_boolean), 138 MAILVAR_TYPEMASK (mailvar_type_boolean),
135 N_("hold the read or saved messages in the system mailbox") }, 139 N_("hold the read or saved messages in the system mailbox") },
......
...@@ -468,7 +468,7 @@ util_get_homedir () ...@@ -468,7 +468,7 @@ util_get_homedir ()
468 char * 468 char *
469 util_fullpath (const char *inpath) 469 util_fullpath (const char *inpath)
470 { 470 {
471 return mu_tilde_expansion(inpath, "/", NULL); 471 return mu_tilde_expansion (inpath, "/", NULL);
472 } 472 }
473 473
474 char * 474 char *
...@@ -661,7 +661,7 @@ util_slist_to_string (mu_list_t list, const char *delim) ...@@ -661,7 +661,7 @@ util_slist_to_string (mu_list_t list, const char *delim)
661 } 661 }
662 662
663 void 663 void
664 util_strcat(char **dest, const char *str) 664 util_strcat (char **dest, const char *str)
665 { 665 {
666 if (!*dest) 666 if (!*dest)
667 *dest = strdup (str); 667 *dest = strdup (str);
...@@ -754,26 +754,13 @@ util_save_outgoing (mu_message_t msg, char *savefile) ...@@ -754,26 +754,13 @@ util_save_outgoing (mu_message_t msg, char *savefile)
754 } 754 }
755 } 755 }
756 756
757 #ifdef HAVE_STDARG_H
758 void 757 void
759 util_error (const char *format, ...) 758 util_error (const char *format, ...)
760 #else
761 void
762 util_error (va_alist)
763 va_dcl
764 #endif
765 { 759 {
766 va_list ap; 760 va_list ap;
767 761
768 #ifdef HAVE_STDARG_H 762 va_start (ap, format);
769 va_start(ap, format); 763
770 #else
771 char *format;
772
773 va_start (ap);
774 format = va_arg (ap, char *);
775 #endif
776
777 vfprintf (stderr, format, ap); 764 vfprintf (stderr, format, ap);
778 fprintf (stderr, "\n"); 765 fprintf (stderr, "\n");
779 766
......