Commit f9ef0729 authored by David Byers's avatar David Byers
Browse files

Prefix argument on kom-list-summary causes each subject to be listed only once

parent fb8f0c54
2001-11-13 David Byers <davby@ida.liu.se>
List unique subjects when prefix is given to kom-list-summary
* commands2.el: (kom-list-summary): Prefix argument sets "unique"
flag to lyskom-list-summary.
(lyskom-list-summary): Added "unique" argument.
(lyskom-do-list-summary): Aded "unique" argument.
(kom-list-summary): List unique subjects when a prefix argument is
given.
* utilities.el (lyskom-string-member): New function
2001-11-13 Ulrik Haugen <qha@lysator.liu.se>
* vars.el.in (lyskom-button-actions): added button-type:
......
......@@ -932,18 +932,19 @@
;;; Author: Linus Tolke
(def-kom-command kom-list-summary ()
(def-kom-command kom-list-summary (prefix)
"List a summary of the unread in the current conf.
The summary contains the date, number of lines, author and subject of the text
on one line."
(interactive)
(interactive "P")
(if (read-list-isempty lyskom-reading-list)
(lyskom-insert-string 'have-to-be-in-conf-with-unread)
(lyskom-list-summary nil)))
(lyskom-list-summary nil prefix)))
(defun lyskom-list-summary (conf-no)
(defun lyskom-list-summary (conf-no &optional unique)
"List a summary of unread texts in conference CONF-NO.
If CONF-NO is nil, list the first text-list element in lyskom-reading-list.
If UNIQUE is non-nil, list only the first text with a particular subject.
The summary contains the date, number of lines, author and subject of
the text on one line."
......@@ -965,37 +966,45 @@ the text on one line."
(setq read-info (read-list->nth read-list r))
(when read-info
(lyskom-do-list-summary
(text-list->texts (read-info->text-list read-info))))
(text-list->texts (read-info->text-list read-info))
unique))
))
(defun lyskom-do-list-summary (texts)
"List a summary of the texts in TEXTS.
The summary contains the date, number of lines, author and subject of the text
on one line."
(let ((time (lyskom-current-server-time))
(author-width (/ (- (lyskom-window-width) 27) 3)))
;; Start fetching all text-stats and text to list them.
(lyskom-format-insert (concat "%-7#1s %-10#2s %-4#3s %-"
(int-to-string author-width)
"#4s %#5s\n")
(lyskom-get-string 'Texts)
(lyskom-get-string 'Date)
(lyskom-get-string 'Lines)
(lyskom-get-string 'Author)
(lyskom-get-string 'Subject))
(lyskom-traverse
text-no texts
(let ((text-stat (blocking-do 'get-text-stat text-no))
(text (blocking-do 'get-text text-no))
;; We could do som optimization here.
;; We really don't need the whole text.
)
(lyskom-print-summary-line text-stat text text-no
(time->year time)
(time->mon time)
(time->mday time))
(sit-for 0)))))
(defun lyskom-do-list-summary (texts &optional unique)
"List a summary of the texts in TEXTS.
The summary contains the date, number of lines, author and subject of the text
on one line."
(let ((time (lyskom-current-server-time))
(author-width (/ (- (lyskom-window-width) 27) 3))
(unique-subjects nil))
;; Start fetching all text-stats and text to list them.
(lyskom-format-insert (concat "%-7#1s %-10#2s %-4#3s %-"
(int-to-string author-width)
"#4s %#5s\n")
(lyskom-get-string 'Texts)
(lyskom-get-string 'Date)
(lyskom-get-string 'Lines)
(lyskom-get-string 'Author)
(lyskom-get-string 'Subject))
(lyskom-traverse
text-no texts
(let ((text-stat (blocking-do 'get-text-stat text-no))
(text (blocking-do 'get-text text-no))
;; We could do som optimization here.
;; We really don't need the whole text.
)
(when (or (not unique)
(let* ((txt (text->decoded-text-mass text text-stat))
(eos (string-match (regexp-quote "\n") txt))
(subject (substring txt 0 eos)))
(and (not (lyskom-string-member subject unique-subjects))
(setq unique-subjects (cons subject unique-subjects)))))
(lyskom-print-summary-line text-stat text text-no
(time->year time)
(time->mon time)
(time->mday time)))
(sit-for 0)))))
(defun lyskom-print-summary-line (text-stat text text-no year mon mday)
......
......@@ -547,6 +547,18 @@ The value is actually the element of LIST whose car equals KEY."
(setq list (cdr list)))
result))
(defun lyskom-string-member (key list)
"Return non-nil if KEY is the same string as the car of an element of LIST.
The value is actually the element of LIST whose car equals KEY."
(let ((s (and key (downcase key)))
(result nil))
(while list
(when (lyskom-string= s (downcase (car list)))
(setq result (car list))
(setq list nil))
(setq list (cdr list)))
result))
(defun lyskom-string-rassoc (key list)
"Return non-nil if KEY is the same string as the cdr of an element of LIST.
The value is actually the element of LIST whose car equals KEY."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment