Mercurial > addons > slrn-macros > slrn-unread-threads-macro
view unread-threads.sl @ 1:e50b2ba42af7 default tip
Change license to GPL-2.0+
author | Guido Berhoerster <guido+slrn@berhoerster.name> |
---|---|
date | Sat, 25 Jul 2015 17:13:16 +0200 |
parents | 4ec1eb102837 |
children |
line wrap: on
line source
% unread-threads.sl - display complete threads if they contain unread articles % % Copyright (C) 2009 Guido Berhoerster <guido+slrn@berhoerster.name> % % This program is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License % as published by the Free Software Foundation; either version 2 % of the License, or (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. %open_log_file(make_home_filename("slrn-debug.log")); %_traceback = 1; implements("UnreadThreads"); define select_group_unread_threads() { variable msgid = NULL; variable flags; variable saved_header_flags = Assoc_Type[]; variable saved_show_article = get_variable_value("show_article"); set_integer_variable("show_article", 0); set_prefix_argument(4); if (select_group() == -1) return; reset_prefix_arg(); uncollapse_threads(); while (((msgid == NULL) && (not get_header_flags() & HEADER_READ)) || header_next_unread()) { msgid = extract_article_header("Message-ID"); ifnot (strlen(msgid)) continue; % move on to next unread article if this thread has already been % processed if (assoc_key_exists(saved_header_flags, msgid)) continue; % move to first article of the current thread while (has_parent()) () = header_up(1); % save the flags of each article in this thread in saved_header_flags % and mark it unread loop (thread_size()) { msgid = extract_article_header("Message-ID"); saved_header_flags[msgid] = get_header_flags(); call("undelete"); } % move one article up since "undelete" except for the very last message % moves one article down ifnot (msgid == extract_article_header("Message-ID")) () = header_up(1); } % return if there are no unread articles ifnot (length(saved_header_flags)) { collapse_threads(); % clear message area message(""); return; } % remove all read articles and restore flags for the remaining articles call("expunge"); foreach msgid, flags(saved_header_flags) using("keys", "values") { () = locate_header_by_msgid(msgid, 0); set_header_flags(flags); } % place cursor on first unread article collapse_threads(); call("header_bob"); if (get_header_flags() & HEADER_READ) header_next_unread(); % obey show_article setting if (saved_show_article) call("hide_article"); set_integer_variable("show_article", saved_show_article); % clear message area message(""); return; }