Commit c8654a86 authored by David Byers's avatar David Byers

Bug fixes.

Better support for hiding entries in kom-edit-membership
parent 8eab81f9
2000-04-01 David Byers <davby@ida.liu.se>
* mship-edit.el (lp--calculate-distance): Fix problem when
stepping backwards too far.
(lp--next-entry): Handle invisible entries.
(lp--previous-entry): Same here.
(lp--last-entry): Handle case when all entries are invisible.
(lp--first-entry): Same here.
(lp--scroll-advice): Same here.
2000-03-29 David Byers <davby@ida.liu.se>
* commands2.el (kom-review-mail-headers): Never wrap e-mail
headers.
2000-03-27 David Byers <davby@ida.liu.se>
* utilities.el (nfirst): Non-recursive implementation to avoid
hitting max-eval-depth when reviewing old texts.
2000-03-26 David Byers <davby@ida.liu.se>
* vars.el.in (kom-morons): New variable.
......
......@@ -2260,8 +2260,9 @@ Return-value: 'no-session if there is no suitable session to switch to
((null headers) (lyskom-format-insert 'no-mail-headers text-no))
(t (lyskom-format-insert 'mail-headers-for text-no)
(mapcar (lambda (el)
(lyskom-format-insert "%#1t" (aux-item->data el))
(lyskom-insert "\n"))
(let ((kom-autowrap nil))
(lyskom-format-insert "%#1t" (aux-item->data el))
(lyskom-insert "\n")))
headers)))))
......
......@@ -9,10 +9,6 @@
;; Maybe move setting the membership priority to
;; lyskom-change-membership-priority.
;;
;; We get into all kinds of trouble if we hide all entries. In particular
;; check all users of lp--get-last-visible-entry and
;; lp--get-next-visible-entry.
;;
;; -------------------------------------------------------------------------
;; When prioritizing an entry we need to sort the read lists to put
;; the entries in the proper order. It's possible that we'll have to
......@@ -515,9 +511,10 @@ entry priority"
"Return the last visible entry in the list."
(let* ((pos (1- (length (lp--all-entries))))
(entry (lp--get-entry pos)))
(while (and entry (not (lp--entry->visible entry)))
(setq pos (1- pos)))
entry))
(while (and (> pos 0) entry (not (lp--entry->visible entry)))
(setq pos (1- pos))
(setq entry (lp--get-entry pos)))
(if (lp--entry->visible entry) entry nil)))
(defun lp--get-entry (pos)
"Return the entry at position POS in the list."
......@@ -908,16 +905,19 @@ Forces a mode line update"
(defun lp--calculate-distance (pos delta)
"Return one more than the number of entries between POS and POS+DELTA.
This includes visible and invisible entries. The sign of the
returned value has the same sign as DELTA."
returned value has the same sign as DELTA. The result is clipped to the
size of the list."
(let ((step (signum delta))
(num (abs delta))
(result 0))
(while (> num 0)
(setq pos (+ step pos))
(setq result (1+ result))
(let ((entry (lp--get-entry pos)))
(cond ((null entry) (setq result (1+ result) num 0))
((lp--entry->visible (lp--get-entry pos)) (setq num (1- num))))))
(if (< pos 0)
(setq num 0)
(setq result (1+ result))
(let ((entry (lp--get-entry pos)))
(cond ((null entry) (setq result (1+ result) num 0))
((lp--entry->visible (lp--get-entry pos)) (setq num (1- num)))))))
(* result step)))
......@@ -1157,18 +1157,19 @@ possible in the list."
The cursor will always move to the start of the target entry."
(interactive "p")
(let* ((entry (lp--entry-at (point)))
(pos (cond ((and (null entry) (< (point)
(lp--entry->start-marker
(lp--get-entry
(lp--next-visible-entry 0)))))
0)
((and (null entry) (> (point)
(lp--entry->end-marker
(lp--get-last-visible-entry))))
(1- (length (lp--all-entries))))
(t (max 0 (- (lp--entry-position entry) count))))))
(last-entry (lp--get-last-visible-entry))
(first-entry (lp--next-visible-entry 0))
(pos (lp--entry-position entry))
(new-pos (cond ((null last-entry) nil)
((and (null entry) (< (point)
(lp--entry->start-marker
(lp--get-entry first-entry)))) 0)
((and (null entry) (> (point)
(lp--entry->end-marker last-entry)))
(1- (length (lp--all-entries))))
(t (max 0 (+ pos (lp--calculate-distance pos (- count))))))))
(condition-case nil
(goto-char (lp--entry->start-marker (lp--get-entry pos)))
(goto-char (lp--entry->start-marker (lp--get-entry new-pos)))
(error nil))))
(defun lp--next-entry (count)
......@@ -1176,35 +1177,42 @@ The cursor will always move to the start of the target entry."
The cursor will always move to the start of the target entry."
(interactive "p")
(let* ((entry (lp--entry-at (point)))
(pos (cond ((and (null entry) (< (point)
(last-entry (lp--get-last-visible-entry))
(first-entry (lp--next-visible-entry 0))
(pos (lp--entry-position entry))
(new-pos (cond ((null last-entry) nil)
((and (null entry) (< (point)
(lp--entry->start-marker
(lp--get-entry
(lp--next-visible-entry 0)))))
first-entry))))
0)
((and (null entry) (> (point)
(lp--entry->end-marker
(lp--get-last-visible-entry))))
last-entry)))
(1- (length (lp--all-entries))))
(t (min (1- (length (lp--all-entries)))
(+ (lp--entry-position entry) count))))))
(+ pos (lp--calculate-distance pos count)))))))
(condition-case nil
(goto-char (lp--entry->start-marker (lp--get-entry pos)))
(goto-char (lp--entry->start-marker (lp--get-entry new-pos)))
(error nil))))
(defun lp--first-entry ()
"Move point to the first entry in the membership list."
(interactive)
(condition-case nil
(goto-char (lp--entry->start-marker
(lp--get-entry (lp--next-visible-entry 0))))
(let ((entry (lp--get-entry (lp--next-visible-entry 0))))
(cond ((null entry) (goto-char lp--list-end-marker))
(t (goto-char (lp--entry->start-marker
(lp--get-entry (lp--next-visible-entry 0)))))))
(error nil)))
(defun lp--last-entry ()
"Move point to the last entry in the membership list."
(interactive)
(condition-case nil
(goto-char
(lp--entry->start-marker (lp--get-last-visible-entry)))
(let ((entry (lp--get-last-visible-entry)))
(cond ((null entry) (goto-char lp--list-end-marker))
(t (goto-char (lp--entry->start-marker entry)))))
(error nil)))
(defun lp--goto-priority (priority)
......@@ -1260,20 +1268,24 @@ entry with an adjacent priority."
(funcall fn)
(when (and (boundp 'lyskom-buffer-category)
lyskom-buffer-category 'prioritize)
(cond ((> (point) (lp--entry->end-marker (lp--get-last-visible-entry)))
(goto-char (lp--entry->end-marker (lp--get-last-visible-entry)))
(when (> (current-column) cur)
(beginning-of-line)
(forward-char cur)))
((< (point) (lp--entry->start-marker
(lp--get-entry (lp--next-visible-entry 0))))
(goto-char (lp--entry->start-marker
(lp--get-entry (lp--next-visible-entry 0))))
(end-of-line)
(when (> (current-column) cur)
(beginning-of-line)
(forward-char cur)))))))
(let ((last-entry (lp--get-last-visible-entry ))
(first-entry (lp--next-visible-entry 0)))
(cond ((null last-entry)
(goto-char lp--list-end-marker))
((> (point) (lp--entry->end-marker last-entry))
(goto-char (lp--entry->end-marker last-entry))
(when (> (current-column) cur)
(beginning-of-line)
(forward-char cur)))
((< (point) (lp--entry->start-marker
(lp--get-entry first-entry)))
(goto-char (lp--entry->start-marker
(lp--get-entry first-entry)))
(end-of-line)
(when (> (current-column) cur)
(beginning-of-line)
(forward-char cur))))))))
(defadvice scroll-up-command (around lp--scroll-up-advice activate)
(lp--scroll-advice (lambda () ad-do-it)))
......@@ -1417,7 +1429,9 @@ Entry to this mode runs lyskom-prioritize-mode-hook."
(make-local-variable 'lp--entry-list)
(make-local-variable 'lp--list-start-marker)
(make-local-variable 'lp--list-end-marker)
(make-local-variable 'lp--buffer-done)
(setq lp--entry-list nil)
(setq lp--buffer-done nil)
(lyskom-format-insert "\
Medlemskap för %#1M på %#2s
......
......@@ -61,9 +61,12 @@
(defun nfirst (n list)
"Return a list of the N first elements of LIST."
(if (or (<= n 0) (not list))
nil
(cons (car list) (nfirst (1- n) (cdr list)))))
(let ((result nil))
(while (and (> n 0) list)
(setq result (cons (car list) result)
list (cdr list)
n (1- n)))
(nreverse result)))
(defun lyskom-rotate-list (list el)
"Destructively rotate LIST so EL becomes the first element.
......
......@@ -100,6 +100,7 @@ Note that this function must not be called asynchronously."
(mx-cc (lyskom-get-aux-item (text-stat->aux-items text-stat) 20))
(mx-filename (lyskom-get-aux-item (text-stat->aux-items text-stat) 10104))
(mx-sender (lyskom-get-aux-item (text-stat->aux-items text-stat) 10103))
(mx-headers (lyskom-get-aux-item (text-stat->aux-items text-stat) 24))
(mx-reply-to (lyskom-get-aux-item (text-stat->aux-items text-stat) 18)))
......@@ -164,7 +165,7 @@ Note that this function must not be called asynchronously."
;; Insert imported at
(cond ((and mx-from
(cond ((and (or mx-from mx-author mx-sender mx-headers)
(text-stat->author text-stat)
kom-show-imported-importer)
(lyskom-format-insert 'text-imported-at-by
......
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