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

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> 2000-03-26 David Byers <davby@ida.liu.se>
* vars.el.in (kom-morons): New variable. * vars.el.in (kom-morons): New variable.
......
...@@ -2260,8 +2260,9 @@ Return-value: 'no-session if there is no suitable session to switch to ...@@ -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)) ((null headers) (lyskom-format-insert 'no-mail-headers text-no))
(t (lyskom-format-insert 'mail-headers-for text-no) (t (lyskom-format-insert 'mail-headers-for text-no)
(mapcar (lambda (el) (mapcar (lambda (el)
(lyskom-format-insert "%#1t" (aux-item->data el)) (let ((kom-autowrap nil))
(lyskom-insert "\n")) (lyskom-format-insert "%#1t" (aux-item->data el))
(lyskom-insert "\n")))
headers))))) headers)))))
......
...@@ -9,10 +9,6 @@ ...@@ -9,10 +9,6 @@
;; Maybe move setting the membership priority to ;; Maybe move setting the membership priority to
;; lyskom-change-membership-priority. ;; 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 ;; 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 ;; the entries in the proper order. It's possible that we'll have to
...@@ -515,9 +511,10 @@ entry priority" ...@@ -515,9 +511,10 @@ entry priority"
"Return the last visible entry in the list." "Return the last visible entry in the list."
(let* ((pos (1- (length (lp--all-entries)))) (let* ((pos (1- (length (lp--all-entries))))
(entry (lp--get-entry pos))) (entry (lp--get-entry pos)))
(while (and entry (not (lp--entry->visible entry))) (while (and (> pos 0) entry (not (lp--entry->visible entry)))
(setq pos (1- pos))) (setq pos (1- pos))
entry)) (setq entry (lp--get-entry pos)))
(if (lp--entry->visible entry) entry nil)))
(defun lp--get-entry (pos) (defun lp--get-entry (pos)
"Return the entry at position POS in the list." "Return the entry at position POS in the list."
...@@ -908,16 +905,19 @@ Forces a mode line update" ...@@ -908,16 +905,19 @@ Forces a mode line update"
(defun lp--calculate-distance (pos delta) (defun lp--calculate-distance (pos delta)
"Return one more than the number of entries between POS and 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 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)) (let ((step (signum delta))
(num (abs delta)) (num (abs delta))
(result 0)) (result 0))
(while (> num 0) (while (> num 0)
(setq pos (+ step pos)) (setq pos (+ step pos))
(setq result (1+ result)) (if (< pos 0)
(let ((entry (lp--get-entry pos))) (setq num 0)
(cond ((null entry) (setq result (1+ result) num 0)) (setq result (1+ result))
((lp--entry->visible (lp--get-entry pos)) (setq num (1- num)))))) (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))) (* result step)))
...@@ -1157,18 +1157,19 @@ possible in the list." ...@@ -1157,18 +1157,19 @@ possible in the list."
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") (interactive "p")
(let* ((entry (lp--entry-at (point))) (let* ((entry (lp--entry-at (point)))
(pos (cond ((and (null entry) (< (point) (last-entry (lp--get-last-visible-entry))
(lp--entry->start-marker (first-entry (lp--next-visible-entry 0))
(lp--get-entry (pos (lp--entry-position entry))
(lp--next-visible-entry 0))))) (new-pos (cond ((null last-entry) nil)
0) ((and (null entry) (< (point)
((and (null entry) (> (point) (lp--entry->start-marker
(lp--entry->end-marker (lp--get-entry first-entry)))) 0)
(lp--get-last-visible-entry)))) ((and (null entry) (> (point)
(1- (length (lp--all-entries)))) (lp--entry->end-marker last-entry)))
(t (max 0 (- (lp--entry-position entry) count)))))) (1- (length (lp--all-entries))))
(t (max 0 (+ pos (lp--calculate-distance pos (- count))))))))
(condition-case nil (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)))) (error nil))))
(defun lp--next-entry (count) (defun lp--next-entry (count)
...@@ -1176,35 +1177,42 @@ The cursor will always move to the start of the target entry." ...@@ -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." The cursor will always move to the start of the target entry."
(interactive "p") (interactive "p")
(let* ((entry (lp--entry-at (point))) (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--entry->start-marker
(lp--get-entry (lp--get-entry
(lp--next-visible-entry 0))))) first-entry))))
0) 0)
((and (null entry) (> (point) ((and (null entry) (> (point)
(lp--entry->end-marker (lp--entry->end-marker
(lp--get-last-visible-entry)))) last-entry)))
(1- (length (lp--all-entries)))) (1- (length (lp--all-entries))))
(t (min (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 (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)))) (error nil))))
(defun lp--first-entry () (defun lp--first-entry ()
"Move point to the first entry in the membership list." "Move point to the first entry in the membership list."
(interactive) (interactive)
(condition-case nil (condition-case nil
(goto-char (lp--entry->start-marker (let ((entry (lp--get-entry (lp--next-visible-entry 0))))
(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))) (error nil)))
(defun lp--last-entry () (defun lp--last-entry ()
"Move point to the last entry in the membership list." "Move point to the last entry in the membership list."
(interactive) (interactive)
(condition-case nil (condition-case nil
(goto-char (let ((entry (lp--get-last-visible-entry)))
(lp--entry->start-marker (lp--get-last-visible-entry))) (cond ((null entry) (goto-char lp--list-end-marker))
(t (goto-char (lp--entry->start-marker entry)))))
(error nil))) (error nil)))
(defun lp--goto-priority (priority) (defun lp--goto-priority (priority)
...@@ -1260,20 +1268,24 @@ entry with an adjacent priority." ...@@ -1260,20 +1268,24 @@ entry with an adjacent priority."
(funcall fn) (funcall fn)
(when (and (boundp 'lyskom-buffer-category) (when (and (boundp 'lyskom-buffer-category)
lyskom-buffer-category 'prioritize) lyskom-buffer-category 'prioritize)
(cond ((> (point) (lp--entry->end-marker (lp--get-last-visible-entry))) (let ((last-entry (lp--get-last-visible-entry ))
(goto-char (lp--entry->end-marker (lp--get-last-visible-entry))) (first-entry (lp--next-visible-entry 0)))
(when (> (current-column) cur) (cond ((null last-entry)
(beginning-of-line) (goto-char lp--list-end-marker))
(forward-char cur))) ((> (point) (lp--entry->end-marker last-entry))
(goto-char (lp--entry->end-marker last-entry))
((< (point) (lp--entry->start-marker (when (> (current-column) cur)
(lp--get-entry (lp--next-visible-entry 0)))) (beginning-of-line)
(goto-char (lp--entry->start-marker (forward-char cur)))
(lp--get-entry (lp--next-visible-entry 0))))
(end-of-line) ((< (point) (lp--entry->start-marker
(when (> (current-column) cur) (lp--get-entry first-entry)))
(beginning-of-line) (goto-char (lp--entry->start-marker
(forward-char cur))))))) (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) (defadvice scroll-up-command (around lp--scroll-up-advice activate)
(lp--scroll-advice (lambda () ad-do-it))) (lp--scroll-advice (lambda () ad-do-it)))
...@@ -1417,7 +1429,9 @@ Entry to this mode runs lyskom-prioritize-mode-hook." ...@@ -1417,7 +1429,9 @@ Entry to this mode runs lyskom-prioritize-mode-hook."
(make-local-variable 'lp--entry-list) (make-local-variable 'lp--entry-list)
(make-local-variable 'lp--list-start-marker) (make-local-variable 'lp--list-start-marker)
(make-local-variable 'lp--list-end-marker) (make-local-variable 'lp--list-end-marker)
(make-local-variable 'lp--buffer-done)
(setq lp--entry-list nil) (setq lp--entry-list nil)
(setq lp--buffer-done nil)
(lyskom-format-insert "\ (lyskom-format-insert "\
Medlemskap för %#1M på %#2s Medlemskap för %#1M på %#2s
......
...@@ -61,9 +61,12 @@ ...@@ -61,9 +61,12 @@
(defun nfirst (n list) (defun nfirst (n list)
"Return a list of the N first elements of LIST." "Return a list of the N first elements of LIST."
(if (or (<= n 0) (not list)) (let ((result nil))
nil (while (and (> n 0) list)
(cons (car list) (nfirst (1- n) (cdr list))))) (setq result (cons (car list) result)
list (cdr list)
n (1- n)))
(nreverse result)))
(defun lyskom-rotate-list (list el) (defun lyskom-rotate-list (list el)
"Destructively rotate LIST so EL becomes the first element. "Destructively rotate LIST so EL becomes the first element.
......
...@@ -100,6 +100,7 @@ Note that this function must not be called asynchronously." ...@@ -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-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-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-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))) (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." ...@@ -164,7 +165,7 @@ Note that this function must not be called asynchronously."
;; Insert imported at ;; Insert imported at
(cond ((and mx-from (cond ((and (or mx-from mx-author mx-sender mx-headers)
(text-stat->author text-stat) (text-stat->author text-stat)
kom-show-imported-importer) kom-show-imported-importer)
(lyskom-format-insert 'text-imported-at-by (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