Commit 0f660621 authored by Pontus Freyhult's avatar Pontus Freyhult
Browse files

Multiple enhancments for kom-prioritize:

Flag toggles work on selected entries (or the current if none is
selected).

Postpone and only last functions.
parent 29aaeb55
2004-10-31 Pontus Freyhult <pont@soua.net>
* mship-edit.el (lp--selected-or-current-arg): New function.
(lp--toggle-flag): New function.
(lp--postpone): New function.
(lp--set-unread): New function.
(lp--toggle-message-flag, lp--toggle-invitiation,
lp--toggle-secret, lp--toggle-passive): Use
lp--selected-or-current-arg and lp--toggle-flag.
* english-strings.el, swedish-strings.el (local):
Added lp--only-last and lp-skipping-missing-meeting.
Changed lp-footer-help.
(global): Added lp--set-unread.
(lyskom-prioritize-mode-map): Added keyboard mappings
for lp--postpone and lp--set-unread.
2004-10-29 Pontus Freyhult <pont@soua.net>
* mship-edit.el (lp--entry-set-background): Use
......
......@@ -768,6 +768,8 @@ The message you were sending to %#1M was:
(initial-unread . "Initial number of unread (empty for all texts): ")
(only-error . "Something went wrong. Sorry.\n")
(lp--only-last . "Number of text to read: ")
(you-have-unreads . "You have %#1d unread text%#1?d%[%]%[s%] in %#2M\n")
(you-have-unreads-special . "You have %#1d uncommented text%#1?d%[%]%[s%] in %#2M\n")
(you-have-no-unreads . "You have read everything in %#1M\n")
......@@ -2085,10 +2087,12 @@ Change privileges for %#1P (%#1p)...")
Select membership: SPC Select region: C-w Flytta markerade: C-y
Set priority: p Increase prio: + Decrease prio: -
Move up: M-p Move down: M-n Toggle flags: I,H,P,M
Postpone reading: P Only last: o
Quit: C-c C-c More help: C-h m
")
(lp-hide-read-after . "Hide memberships read after: ")
(lp-hide-read-since . "Hide memberships not read since: ")
(lp-skipping-missing-meeting . "Conference %#1M no longer exists, skipping.")
))
......@@ -2545,6 +2549,7 @@ Change privileges for %#1P (%#1p)...")
(lp--toggle-passive . "Toggle passive")
(lp--toggle-message-flag . "Toggle messages")
(lp--toggle-secret . "Toggle secret")
(lp--set-unread . "Only last")
(lp--quit . "Quit")
))
......@@ -2855,6 +2860,8 @@ Change privileges for %#1P (%#1p)...")
(define-key lyskom-en-prioritize-mode-map (kbd "H") 'lp--toggle-secret)
(define-key lyskom-en-prioritize-mode-map (kbd "P") 'lp--toggle-passive)
(define-key lyskom-en-prioritize-mode-map (kbd "M") 'lp--toggle-message-flag)
(define-key lyskom-en-prioritize-mode-map (kbd "o") 'lp--set-unread)
(define-key lyskom-en-prioritize-mode-map (kbd "P") 'lp--postpone)
(define-key lyskom-en-prioritize-mode-map (kbd "C-c C-c") 'lp--quit)
(define-key lyskom-en-prioritize-mode-map (kbd "q") 'lp--quit)
(define-key lyskom-en-prioritize-mode-map (kbd "(") 'lp--expand-entry)
......
......@@ -854,46 +854,149 @@ clicked on."
(blocking-do 'get-conf-stat (membership->conf-no mship))))
(lp--redraw-entry entry))))
(defun lp--toggle-invitation ()
"Toggle the invitation bit of the current entry"
(interactive)
(defun lp--selected-or-current-arg ()
"Return a list of selected entries or the current entry.
This function is suitable to call from interactive."
(if (and lp--selected-entry-list
(not (zerop (length lp--selected-entry-list))))
lp--selected-entry-list
(list (lp--entry-at (point)))))
(defun lp--postpone (arg entries)
"Postpone reading of all but the last ENTRIES text in selected/
current conferences."
(interactive (list current-prefix-arg
(lp--selected-or-current-arg)))
(lyskom-with-lyskom-buffer
(let ((n (or (and arg
(prefix-numeric-value arg))
(lyskom-read-number
(lyskom-get-string 'postpone-prompt)
kom-postpone-default)))
(l (mapcar
(lambda (i)
(if (eq 'CONF (read-info->type i))
(list (read-info->conf-stat i)
(read-info->text-list i))
'(nil nil)))
(read-list->all-entries lyskom-to-do-list))))
(lyskom-traverse cur entries
(unless cur
(error (lyskom-get-string 'lp-no-entry)))
(let* ((conf-no (membership->conf-no (lp--entry->membership cur)))
(conf-stat (blocking-do 'get-conf-stat conf-no)))
(if (null conf-stat)
(lyskom-message (lyskom-format (lyskom-get-string
'lp-skipping-missing-meeting)
conf-no))
(let ((rl (assoc conf-stat l)))
(when (and (nth 1 rl) ; Handle passive conferences
(< n (text-list->length (nth 1 rl))))
(text-list->trim-head (nth 1 rl) n)
(lp--update-buffer conf-no)
(when (= lyskom-current-conf conf-no)
(lyskom-go-to-conf conf-no t))))))))
(read-list-delete-text nil lyskom-reading-list)
(read-list-delete-text nil lyskom-to-do-list)))
(defun lp--set-unread (arg entries)
"Set number of unread messages in selected/current conference(s)."
; Should probably unify with
(interactive (list current-prefix-arg
(lp--selected-or-current-arg)))
(let ((num-unread (or (and arg
(prefix-numeric-value arg))
(lyskom-read-num-range-or-date
0
; Does this really promote the user experience? Would it
; be better to fix lyskom-read-num-range-or-date to
; be able to get a number or a date (ignoring ther range)?
(let ((max-unread 0))
(lyskom-traverse cur entries
(when cur
(setq max-unread
(max max-unread
(conf-stat->no-of-texts
(blocking-do 'get-conf-stat
(membership->conf-no
(lp--entry->membership cur))))))))
max-unread)
(lyskom-format 'lp--only-last)))))
(lyskom-with-lyskom-buffer
(lyskom-traverse cur entries
(unless cur
(error (lyskom-get-string 'lp-no-entry)))
(let* ((conf-no (membership->conf-no (lp--entry->membership cur)))
(conf-stat (progn (cache-del-conf-stat conf-no)
(blocking-do 'get-conf-stat conf-no))))
(if (null conf-stat)
(lyskom-message (lyskom-format (lyskom-get-string
'lp-skipping-missing-meeting)
conf-no))
(let ((num-unread-this-conf (if (listp num-unread)
num-unread
(min num-unread
(conf-stat->no-of-texts conf-stat)))))
(cond ((listp num-unread-this-conf)
(lyskom-format-insert 'set-unread-date
(elt num-unread-this-conf 0)
(car (rassq (elt num-unread-this-conf 1)
lyskom-month-names))
(elt num-unread-this-conf 2))
(let* ((target-date (lyskom-create-time 0 0 0
(elt num-unread-this-conf 2)
(elt num-unread-this-conf 1)
(elt num-unread-this-conf 0)
0 0 nil))
(text (lyskom-find-text-by-date conf-stat target-date)))
(when text
(blocking-do 'set-last-read
(conf-stat->conf-no conf-stat)
(car text)))))
((numberp num-unread-this-conf)
(blocking-do 'set-unread conf-no num-unread-this-conf)))
; FIXME: Does not handle the current conf right,
; prefetch problem?
(lyskom-replace-membership (lp--entry->membership cur))
(when (= conf-no lyskom-current-conf)
(read-list-delete-read-info conf-no lyskom-reading-list))
(read-list-delete-read-info conf-no lyskom-to-do-list)
(lyskom-prefetch-one-membership conf-no lyskom-pers-no)
(when (and (= conf-no lyskom-current-conf)
(not (zerop num-unread-this-conf)))
(lyskom-go-to-conf conf-no t))))))
(read-list-delete-text nil lyskom-reading-list)
(read-list-delete-text nil lyskom-to-do-list))))
(defun lp--toggle-flag (flag entries)
"Toggle the given FLAG for given ENTRIES."
(lp--save-excursion
(let ((cur (lp--entry-at (point))))
(lyskom-traverse cur entries
(cond ((null cur) (error (lyskom-get-string 'lp-no-entry)))
(t (lyskom-prioritize-flag-toggle (current-buffer)
(list cur 'invitation)
(list cur flag)
""))))))
(defun lp--toggle-passive ()
"Toggle the passive bit of the current entry"
(interactive)
(lp--save-excursion
(let ((cur (lp--entry-at (point))))
(cond ((null cur) (error (lyskom-get-string 'lp-no-entry)))
(t (lyskom-prioritize-flag-toggle (current-buffer)
(list cur 'passive)
""))))))
(defun lp--toggle-invitation (entries)
"Toggle the invitation bit of the current entry"
(interactive (list (lp--selected-or-current-arg)))
(lp--toggle-flag 'invitation entries))
(defun lp--toggle-message-flag ()
(defun lp--toggle-passive (entries)
"Toggle the passive bit of the current entry"
(interactive)
(lp--save-excursion
(let ((cur (lp--entry-at (point))))
(cond ((null cur) (error (lyskom-get-string 'lp-no-entry)))
(t (lyskom-prioritize-flag-toggle (current-buffer)
(list cur 'message-flag)
""))))))
(interactive (list (lp--selected-or-current-arg)))
(lp--toggle-flag 'passive entries))
(defun lp--toggle-secret ()
"Toggle the secret bit of the current entry"
(interactive)
(lp--save-excursion
(let ((cur (lp--entry-at (point))))
(cond ((null cur) (error (lyskom-get-string 'lp-no-entry)))
(t (lyskom-prioritize-flag-toggle (current-buffer)
(list cur 'secret)
""))))))
(defun lp--toggle-message-flag (entries)
"Toggle the message flag bit of current or selected entries"
(interactive (list (lp--selected-or-current-arg)))
(lp--toggle-flag 'message-flag entries))
(defun lp--toggle-secret (entries)
"Toggle the secret bit of the current entry"
(interactive (list (lp--selected-or-current-arg)))
(lp--toggle-flag 'secret entries))
;;; ============================================================
......
......@@ -772,6 +772,8 @@ Meddelandet du f
(initial-unread . "Initialt antal olsta (tomt fr alla): ")
(only-error . "Ngot gick galet. Ledsen.\n")
(lp--only-last . "Antal texter att lsa: ")
(you-have-unreads . "Du har %#1d olst%#1?d%[%]%[a%] inlgg i %#2M\n")
(you-have-unreads-special . "Du har %#1d okommentera%#1?d%[t%]%[de%] inlgg i %#2M\n")
(you-have-no-unreads . "Du har inget olst i %#1M\n")
......@@ -2112,10 +2114,12 @@ Nuvarande r
Markera medlemskap: SPC Markera omrde: C-w Flytta markerade: C-y
Stt prioritet: p ka prioritet: + Minska prioritet: -
Flytta upp: M-p Flytta ned: M-n ndra flaggor: I,H,P,M
Uppskjuta lsning: u Endast: e
Avsluta: C-c C-c Mer hjlp: C-h m
")
(lp-hide-read-after . "Dlj medlemskap lsta efter: ")
(lp-hide-read-since . "Dlj medlemskap ej lsta sedan: ")
(lp-skipping-missing-meeting . "Mtet %#1M finns inte lngre, hoppar ver.")
))
(lyskom-language-var local lyskom-month-names sv
......@@ -2576,6 +2580,7 @@ Nuvarande r
(lp--toggle-passive . "Vxla passiv")
(lp--toggle-message-flag . "Vxla meddelanden")
(lp--toggle-secret . "Vxla hemlig")
(lp--set-unread . "Endast")
(lp--quit . "Avsluta")
))
......@@ -2961,6 +2966,8 @@ Nuvarande r
(define-key lyskom-sv-prioritize-mode-map (kbd "H") 'lp--toggle-secret)
(define-key lyskom-sv-prioritize-mode-map (kbd "P") 'lp--toggle-passive)
(define-key lyskom-sv-prioritize-mode-map (kbd "M") 'lp--toggle-message-flag)
(define-key lyskom-sv-prioritize-mode-map (kbd "e") 'lp--set-unread)
(define-key lyskom-sv-prioritize-mode-map (kbd "u") 'lp--postpone)
(define-key lyskom-sv-prioritize-mode-map (kbd "C-c C-c") 'lp--quit)
(define-key lyskom-sv-prioritize-mode-map (kbd "q") 'lp--quit)
(define-key lyskom-sv-prioritize-mode-map (kbd "(") 'lp--expand-entry)
......
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