]> git.neil.brown.name Git - edlib.git/commitdiff
rfc822header: improvements to render attribute on headers.
authorNeilBrown <neil@brown.name>
Tue, 29 Aug 2023 09:11:20 +0000 (19:11 +1000)
committerNeilBrown <neil@brown.name>
Tue, 29 Aug 2023 09:11:20 +0000 (19:11 +1000)
1/ the render:rfc822header-FOO attr is now render:rfc822header:FOO
   to differentiate from e.g. render:rfc822header-wrap which doesn't
   identify a header.
2/ The "FOO" in the above is now always lower-case.  This removes the
   need to differentiate between hdr and hdr_found
3/ The value of that attr is the type of header.  This will be used
    more later.
4/ change notmuch to make proper use of some of the above.

Signed-off-by: NeilBrown <neil@brown.name>
lib-rfc822header.c
python/module-notmuch.py

index 132ade78201b78d10a358c04126f01b6e2761733..8030c84ae95ca70910928161edd84511c90d5566 100644 (file)
@@ -267,6 +267,7 @@ static void copy_header(struct pane *doc safe,
        char buf[20];
        wint_t ch;
        char attr[100];
+       char *a;
        int is_list = type && strcmp(type, "list") == 0;
 
        m = mark_dup(start);
@@ -321,12 +322,13 @@ static void copy_header(struct pane *doc safe,
        call("doc:replace", p, 1, NULL, "\n", 0, point);
        snprintf(buf, sizeof(buf), "%zd", strlen(hdr_found)+1);
        call("doc:set-attr", p, 1, hstart, "render:rfc822header", 0, NULL, buf);
-       if (strlen(hdr) == strlen(hdr_found))
-               /* Refer canonical name, if no 'Resent-' */
-               snprintf(attr, sizeof(attr), "render:rfc822header-%s", hdr);
-       else
-               snprintf(attr, sizeof(attr), "render:rfc822header-%s", hdr_found);
-       call("doc:set-attr", p, 1, hstart, attr, 0, NULL, "10000");
+       snprintf(attr, sizeof(attr), "render:rfc822header:%s", hdr_found);
+       /* make header name lowercase */
+       for (a = attr; *a; a++) {
+               if ((unsigned char)(*a) < 128 && isupper(*a))
+                       *a = tolower(*a);
+       }
+       call("doc:set-attr", p, 1, hstart, attr, 0, NULL, type);
 
        mark_free(hstart);
        mark_free(m);
index 5206b1bafc4b5b673f13ba3eb95a6c0f40de1afa..6a11461bdb23f9541598482860e4d3fb506efbdc 100644 (file)
@@ -3458,21 +3458,21 @@ class notmuch_message_view(edlib.Pane):
     def handle_map_attr(self, key, focus, mark, str, str2, comm2, **a):
         "handle:map-attr"
         if str == "render:rfc822header":
-            comm2("attr:callback", focus, int(str2), mark, "fg:#6495ed", 121)
+            comm2("attr:callback", focus, int(str2), mark, "fg:#6495ed,nobold", 121)
             comm2("attr:callback", focus, 0, mark, "wrap-tail: ,wrap-head:    ",
-                  119)
+                  121)
             return 1
         if str == "render:rfc822header-wrap":
             comm2("attr:callback", focus, int(str2), mark, "wrap", 120)
             return 1
-        if str == "render:rfc822header-subject":
-            comm2("attr:callback", focus, int(str2), mark, "fg:blue,bold", 120)
+        if str == "render:rfc822header:subject":
+            comm2("attr:callback", focus, 10000, mark, "fg:blue,bold", 120)
             return 1
-        if str == "render:rfc822header-to":
-            comm2("attr:callback", focus, int(str2), mark, "fg:blue,bold", 120)
+        if str == "render:rfc822header:to":
+            comm2("attr:callback", focus, 10000, mark, "fg:blue,bold", 120)
             return 1
         if str == "render:hide":
-            comm2("attr:callback", focus, int(str2), mark, "hide", 100000)
+            comm2("attr:callback", focus, 10000, mark, "hide", 100000)
         if str == "render:bold":
             comm2("attr:callback", focus, 100000 if str2 == "1" else -1,
                   mark, "bold", 120)