summaryrefslogtreecommitdiff
path: root/pith
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2016-12-18 12:55:31 -0700
committerEduardo Chappa <chappa@washington.edu>2016-12-18 12:55:31 -0700
commit0674c5f2bbeb0402fccc41eb5855d24ed1220ea8 (patch)
tree2780a4b7c3e9442dbbfab1788d21bfff8bb04a0b /pith
parentaccf5768851fc5f323e66c41de43061e86d4a9f6 (diff)
downloadalpine-0674c5f2bbeb0402fccc41eb5855d24ed1220ea8.tar.xz
* New token SHORTSUBJECT, SHORTSUBJKEY and SHORTSUBJKEYINIT to shorten
the subject, removing list name information from the subject (text enclosed between "[" and "]".)
Diffstat (limited to 'pith')
-rw-r--r--pith/indxtype.h4
-rw-r--r--pith/mailindx.c43
-rw-r--r--pith/pine.hlp21
-rw-r--r--pith/reply.c31
-rw-r--r--pith/reply.h2
5 files changed, 85 insertions, 16 deletions
diff --git a/pith/indxtype.h b/pith/indxtype.h
index 4a0a51d6..533ed57b 100644
--- a/pith/indxtype.h
+++ b/pith/indxtype.h
@@ -70,7 +70,9 @@ typedef enum {iNothing, iStatus, iFStatus, iIStatus, iSIStatus,
iLstMonYear, iLstMonYear2Digit,
iLstYear, iLstYear2Digit,
iMessNo, iAtt, iMsgID,
- iSubject, iSubjKey, iSubjKeyInit,
+ iSubject, iShortSubject,
+ iSubjKey, iShortSubjKey,
+ iSubjKeyInit, iShortSubjKeyInit,
iSubjectText, iSubjKeyText, iSubjKeyInitText,
iOpeningText, iOpeningTextNQ,
iKey, iKeyInit,
diff --git a/pith/mailindx.c b/pith/mailindx.c
index 54b0defd..b79677a5 100644
--- a/pith/mailindx.c
+++ b/pith/mailindx.c
@@ -89,7 +89,7 @@ long fetch_size(INDEXDATA_S *);
BODY *fetch_body(INDEXDATA_S *);
char *fetch_firsttext(INDEXDATA_S *idata, int);
char *fetch_header(INDEXDATA_S *idata, char *hdrname);
-void subj_str(INDEXDATA_S *, char *, size_t, SubjKW, int, ICE_S *);
+void subj_str(INDEXDATA_S *, char *, size_t, SubjKW, int, int, ICE_S *);
void key_str(INDEXDATA_S *, SubjKW, ICE_S *);
void header_str(INDEXDATA_S *, HEADER_TOK_S *, ICE_S *);
void prio_str(INDEXDATA_S *, IndexColType, ICE_S *);
@@ -455,11 +455,14 @@ static INDEX_PARSE_T itokens[] = {
{"SIZENARROW", iSizeNarrow, FOR_INDEX},
{"KSIZE", iKSize, FOR_INDEX},
{"SUBJECT", iSubject, FOR_INDEX|FOR_REPLY_INTRO|FOR_TEMPLATE},
+ {"SHORTSUBJECT", iShortSubject, FOR_INDEX|FOR_REPLY_INTRO|FOR_TEMPLATE},
{"FULLSTATUS", iFStatus, FOR_INDEX},
{"IMAPSTATUS", iIStatus, FOR_INDEX},
{"SHORTIMAPSTATUS", iSIStatus, FOR_INDEX},
{"SUBJKEY", iSubjKey, FOR_INDEX},
+ {"SHORTSUBJKEY", iShortSubjKey, FOR_INDEX},
{"SUBJKEYINIT", iSubjKeyInit, FOR_INDEX},
+ {"SHORTSUBJKEYINIT",iShortSubjKeyInit, FOR_INDEX},
{"SUBJECTTEXT", iSubjectText, FOR_INDEX},
{"SUBJKEYTEXT", iSubjKeyText, FOR_INDEX},
{"SUBJKEYINITTEXT", iSubjKeyInitText, FOR_INDEX},
@@ -1355,10 +1358,13 @@ setup_index_header_widths(MAILSTREAM *stream)
cdesc->width++;
space_left--;
if(space_left > 0 && (cdesc->ctype == iSubject
+ || cdesc->ctype == iShortSubject
|| cdesc->ctype == iSubjectText
|| cdesc->ctype == iSubjKey
+ || cdesc->ctype == iShortSubjKey
|| cdesc->ctype == iSubjKeyText
|| cdesc->ctype == iSubjKeyInit
+ || cdesc->ctype == iShortSubjKeyInit
|| cdesc->ctype == iSubjKeyInitText)){
cdesc->width++;
space_left--;
@@ -2048,10 +2054,13 @@ format_index_index_line(INDEXDATA_S *idata)
if(cdesc->ctype == iMessNo)
snprintf(str, sizeof(str), "%*.*s", ifield->width, ifield->width, " ");
else if(idata->bogus < 2 && (cdesc->ctype == iSubject
+ || cdesc->ctype == iShortSubject
|| cdesc->ctype == iSubjectText
|| cdesc->ctype == iSubjKey
+ || cdesc->ctype == iShortSubjKey
|| cdesc->ctype == iSubjKeyText
|| cdesc->ctype == iSubjKeyInit
+ || cdesc->ctype == iShortSubjKeyInit
|| cdesc->ctype == iSubjKeyInitText))
snprintf(str, sizeof(str), "%s", _("[ No Message Text Available ]"));
}
@@ -2751,27 +2760,39 @@ format_index_index_line(INDEXDATA_S *idata)
break;
case iSubject:
- subj_str(idata, str, sizeof(str), NoKW, 0, ice);
+ subj_str(idata, str, sizeof(str), NoKW, 0, 0, ice);
+ break;
+
+ case iShortSubject:
+ subj_str(idata, str, sizeof(str), NoKW, 0, 1, ice);
break;
case iSubjectText:
- subj_str(idata, str, sizeof(str), NoKW, 1, ice);
+ subj_str(idata, str, sizeof(str), NoKW, 1, 0, ice);
break;
case iSubjKey:
- subj_str(idata, str, sizeof(str), KW, 0, ice);
+ subj_str(idata, str, sizeof(str), KW, 0, 0, ice);
+ break;
+
+ case iShortSubjKey:
+ subj_str(idata, str, sizeof(str), KW, 0, 1, ice);
break;
case iSubjKeyText:
- subj_str(idata, str, sizeof(str), KW, 1, ice);
+ subj_str(idata, str, sizeof(str), KW, 1, 0, ice);
break;
case iSubjKeyInit:
- subj_str(idata, str, sizeof(str), KWInit, 0, ice);
+ subj_str(idata, str, sizeof(str), KWInit, 0, 0, ice);
+ break;
+
+ case iShortSubjKeyInit:
+ subj_str(idata, str, sizeof(str), KWInit, 0, 1, ice);
break;
case iSubjKeyInitText:
- subj_str(idata, str, sizeof(str), KWInit, 1, ice);
+ subj_str(idata, str, sizeof(str), KWInit, 1, 0, ice);
break;
case iOpeningText:
@@ -3257,7 +3278,7 @@ format_thread_index_line(INDEXDATA_S *idata)
buffer[0] = '\0';
save_sfstr_func = pith_opt_truncate_sfstr;
pith_opt_truncate_sfstr = NULL;
- subj_str(idata, buffer, sizeof(buffer), NoKW, 0, NULL);
+ subj_str(idata, buffer, sizeof(buffer), NoKW, 0, 0, NULL);
pith_opt_truncate_sfstr = save_sfstr_func;
}
@@ -5248,7 +5269,6 @@ scorevalfrommsg(MAILSTREAM *stream, MsgNo rawno, HEADER_TOK_S *hdrtok, int no_fe
return(retval);
}
-
/*
* Put a string representing the subject into str. Idata tells us which
* message we are referring to.
@@ -5261,10 +5281,11 @@ scorevalfrommsg(MAILSTREAM *stream, MsgNo rawno, HEADER_TOK_S *hdrtok, int no_fe
* strsize -- size of str buffer
* kwtype -- prepend keywords or kw initials before the subject
* opening -- add first text from body of message if there's room
+ * shorten -- if on, shorten the subject.
* ice -- index cache entry for message
*/
void
-subj_str(INDEXDATA_S *idata, char *str, size_t strsize, SubjKW kwtype, int opening, ICE_S *ice)
+subj_str(INDEXDATA_S *idata, char *str, size_t strsize, SubjKW kwtype, int opening, int shorten, ICE_S *ice)
{
char *subject, *origsubj, *origstr, *rawsubj, *sptr = NULL;
char *p, *border, *q = NULL, *free_subj = NULL;
@@ -5327,6 +5348,8 @@ subj_str(INDEXDATA_S *idata, char *str, size_t strsize, SubjKW kwtype, int openi
* to free it at the end of this routine.
*/
+ if(shorten)
+ shorten_subject(origsubj);
/*
* prepend_keyword will put the keyword stuff before the subject
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 753983d4..3c731585 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any
reasonable place to be called from.
Dummy change to get revision in pine.hlp
============= h_revision =================
-Alpine Commit 193 2016-12-16 20:11:15
+Alpine Commit 194 2016-12-18 12:55:24
============= h_news =================
<HTML>
<HEAD>
@@ -199,6 +199,10 @@ Additions include:
to 1.0.0c. This includes version 1.1.0. Alpine also builds with
LibreSSL.
+ <LI> New SHORTSUBJECT, SHORTSUBJKEY and SHORTSUBJKEYINIT token for index
+ format, which removes text in the SUBJECT between &quot;[&quot; and
+ &quot;]&quot;.
+
<LI> Alpine will include attachments when forwarding some
multipart/alternative messages for which it did not use to include
attachments.
@@ -19048,7 +19052,7 @@ and in the target of Filter Rules.
<DT>SUBJECT</DT>
<DD>
This token represents the Subject the sender gave the message.
-Alternatives for use in the index screen are
+Alternatives for use in the index screen are SHORTSUBJECT,
SUBJKEY, SUBJKEYINIT, SUBJECTTEXT, SUBJKEYTEXT, and SUBJKEYINITTEXT.
You may color the subject text in the MESSAGE INDEX screen differently by using the
<A HREF="h_config_index_subject_color">Index Subject Color</A> and the
@@ -19256,7 +19260,7 @@ to format the date string. It may end up formatting dates so that they look
like DATEISO tokens, or SHORTDATE2 tokens, or something else entirely.
The feature
<A HREF="h_config_dates_to_local"><!--#echo var="FEAT_convert-dates-to-localtime"--></A>
-may have an affect on the values of these tokens.
+may have an effect on the values of these tokens.
If you want more control you may use one of the following.
<DL>
<DT>SMARTDATE</DT> <DD>If the option
@@ -19289,7 +19293,7 @@ to format the date string. It may end up formatting dates so that they look
like DATEISO tokens, or SHORTDATE2 tokens, or something else entirely.
The feature
<A HREF="h_config_dates_to_local"><!--#echo var="FEAT_convert-dates-to-localtime"--></A>
-may have an affect on the values of these tokens.
+may have an effect on the values of these tokens.
The possible choices are:
<DL>
<DT>SMARTDATETIME</DT> <DD>If the option
@@ -19640,6 +19644,15 @@ the &quot;<!--#echo var="VAR_index-format"-->&quot; could slow down the
display a little while Alpine collects the necessary information.
</DD>
+<DT>SHORTSUBJECT</DT>
+<DD>
+This token is the same as SUBJECT, but
+removes text between &quot;[&quot; and &quot;]&quot;.
+Typically text enclosed between these characters corresponds to
+mailing list names, and may be unnecessary or unwanted in some
+instances.
+</DD>
+
<DT>SUBJKEY</DT>
<DD>
This token is the same as the SUBJECT token unless keywords are set for
diff --git a/pith/reply.c b/pith/reply.c
index 7ceb31f8..b89a8614 100644
--- a/pith/reply.c
+++ b/pith/reply.c
@@ -1704,6 +1704,33 @@ get_news_data(ENVELOPE *env, IndexColType type, char *buf, size_t maxlen)
buf[orig_maxlen] = '\0';
}
+void
+shorten_subject(char *origsubj)
+{
+ char *s, *t, *u;
+ int endlist = 0;
+
+ if(origsubj == NULL || *origsubj == '\0')
+ return;
+
+ for(t=s=origsubj; *s ; s++){
+ switch(*s){
+ /* this transforms "A [B [C] D" into "A D" should this be
+ * "A [B D"?
+ */
+ case '[' : if((u = strchr(s+1,']')) != NULL){
+ s = u;
+ endlist = 1;
+ }
+ else
+ *t++ = *s;
+ break;
+ case ' ' : if(endlist == 0) *t++ = *s; break;
+ default : endlist = 0; *t++ = *s; break;
+ }
+ }
+ *t = '\0';
+}
/*
* Buf is at least size maxlen+1
@@ -1863,6 +1890,7 @@ get_reply_data(ENVELOPE *env, ACTION_S *role, IndexColType type, char *buf, size
break;
case iSubject:
+ case iShortSubject:
if(env && env->subject){
size_t n, len;
unsigned char *p, *tmp = NULL;
@@ -1882,6 +1910,9 @@ get_reply_data(ENVELOPE *env, ACTION_S *role, IndexColType type, char *buf, size
if(tmp)
fs_give((void **)&tmp);
+
+ if(type == iShortSubject)
+ shorten_subject(buf);
}
break;
diff --git a/pith/reply.h b/pith/reply.h
index 067b3a8c..4b49ae17 100644
--- a/pith/reply.h
+++ b/pith/reply.h
@@ -104,6 +104,6 @@ char *simple_read_remote_file(char *, char *);
BODY *forward_multi_alt(MAILSTREAM *, ENVELOPE *, BODY *, long, char *, void *, gf_io_t, int);
BODY *forward_multi_alt_mixed(MAILSTREAM *, ENVELOPE *, BODY *, long, char *, void *, gf_io_t, int);
int same_subject(char *, char *s);
-
+void shorten_subject(char *);
#endif /* PITH_REPLY_INCLUDED */