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

Fixed bug 301.

Detailed changes:
> 	* view-text.el (lyskom-get-text-belongs-to): New function.
>
> 	Fix bug 301:
> 	* commands1.el (kom-move-text): Move attachments and footnotes
> 	together with the text.
> 	(kom-sub-recipient): Remove recipient from attachments and
> 	footnotes too.
> 	(lyskom-add-helper): Add recipients to attachments and footnotes
> 	too.
>
parent b84d2329
2003-08-15 David Byers <byers@lysator.liu.se>
* view-text.el (lyskom-get-text-belongs-to): New function.
Fix bug 301:
* commands1.el (kom-move-text): Move attachments and footnotes
together with the text.
(kom-sub-recipient): Remove recipient from attachments and
footnotes too.
(lyskom-add-helper): Add recipients to attachments and footnotes
too.
Fix bug 623:
* commands2.el (kom-set-unread): Delete conf-stat from cache
before prompting. Fixed error handling.
......
......@@ -103,7 +103,6 @@ return non-nil if the item is to be included in the list."
(setq item-list (cdr item-list)))
(nreverse result)))
(defun lyskom-get-aux-item (item-list tag)
"Return all aux-items in ITEM-LIST with tag TAG."
(lyskom-match-aux-items item-list
......
......@@ -3613,7 +3613,12 @@ This command accepts text number prefix arguments (see
(defun lyskom-add-helper (text-no last-variable who-prompt
doing-prompt type)
(let* ((conf (blocking-do 'get-conf-stat
(let* ((text-stat (blocking-do 'get-text-stat text-no))
(attachments (lyskom-attachments-for-sub text-no))
(footnotes (lyskom-footnotes-for-sub text-no))
(move-footnotes nil)
(move-attachments nil)
(conf (blocking-do 'get-conf-stat
(lyskom-default-value last-variable)))
(target (lyskom-read-conf-stat
(lyskom-get-string who-prompt)
......@@ -3626,14 +3631,19 @@ This command accepts text number prefix arguments (see
(when (and (eq type 'RECPT)
kom-confirm-add-recipients
(not (lyskom-j-or-n-p (lyskom-format 'really-add-as-recpt-q
target))))
(setq type 'CC-RECPT
doing-prompt 'adding-name-as-copy))
(not (lyskom-j-or-n-p
(lyskom-format 'really-add-as-recpt-q target))))
(setq type 'CC-RECPT doing-prompt 'adding-name-as-copy))
(lyskom-set-default last-variable (conf-stat->conf-no target))
(lyskom-format-insert doing-prompt target text-no)
(lyskom-move-recipient text-no nil target type))))
(setq move-footnotes (and footnotes (lyskom-j-or-n-p 'add-footnotes-too-q)))
(setq move-attachments (and attachments (lyskom-j-or-n-p 'add-attachments-too-q)))
(lyskom-traverse text (append (list (cons text-no text-stat))
(and move-footnotes footnotes)
(and move-attachments attachments))
(lyskom-format-insert doing-prompt target (car text))
(lyskom-move-recipient (car text) nil target type)))))
(defun lyskom-default-recpt-for-sub (recipients)
"Select the default recipient for removal from RECIPIENTS.
......@@ -3650,6 +3660,39 @@ The value of RECIPIENTS should be the result of a call to
(blocking-do 'get-conf-stat (car (car recipients))))))))
(defun lyskom-footnotes-for-sub (text-no)
"Return the list of footnotes to remove recipient from."
(let ((result nil)
(worklist (list text-no)))
(while worklist
(setq text-no (car worklist))
(setq worklist (cdr worklist))
(unless (assq text-no result)
(let ((text-stat (blocking-do 'get-text-stat text-no)))
(setq result (cons (cons text-no text-stat) result)
worklist (nconc (mapcar 'misc-info->footn-in
(lyskom-misc-infos-from-list
'FOOTN-IN (text-stat->misc-info-list
text-stat)))
worklist)))))
(cdr (nreverse result))))
(defun lyskom-attachments-for-sub (text-no)
"Return the list of attachments to remove recipient from."
(let ((result nil)
(worklist (list text-no)))
(while worklist
(setq text-no (car worklist))
(setq worklist (cdr worklist))
(unless (assq text-no result)
(let ((text-stat (blocking-do 'get-text-stat text-no)))
(setq result (cons (cons text-no text-stat) result)
worklist (nconc (lyskom-get-text-attachments text-stat)
worklist)))))
(cdr (nreverse result))))
(def-kom-command kom-sub-recipient (text-no)
"Remove a recipient from the selected text. Take care not to remove
the last recipient, since this will make the text unreadable.
......@@ -3657,7 +3700,11 @@ the last recipient, since this will make the text unreadable.
This command accepts text number prefix arguments (see
`lyskom-read-text-no-prefix-arg')."
(interactive (list (lyskom-read-text-no-prefix-arg 'text-to-delete-recipient)))
(let ((text-stat (blocking-do 'get-text-stat text-no)))
(let* ((text-stat (blocking-do 'get-text-stat text-no))
(attachments (lyskom-attachments-for-sub text-no))
(footnotes (lyskom-footnotes-for-sub text-no))
(move-footnotes nil)
(move-attachments nil))
(if text-stat
(let ((recipients (lyskom-text-recipients text-stat t)))
(if recipients
......@@ -3669,10 +3716,17 @@ This command accepts text number prefix arguments (see
(and conf (cons (conf-stat->name conf) 0))
t)))
(when source
(lyskom-format-insert 'remove-name-as-recipient source text-no)
(setq move-footnotes (and footnotes (lyskom-j-or-n-p 'sub-footnotes-too-q)))
(setq move-attachments (and attachments (lyskom-j-or-n-p 'sub-attachments-too-q)))
(lyskom-set-default 'lyskom-last-sub-rcpt (conf-stat->conf-no source))
(lyskom-move-recipient text-no source nil nil)
))
(lyskom-traverse text (append (list (cons text-no text-stat))
(and move-footnotes footnotes)
(and move-attachments attachments))
(lyskom-format-insert 'remove-name-as-recipient source (cdr text))
(if (memq (conf-stat->conf-no source) (lyskom-text-recipients (cdr text)))
(lyskom-move-recipient (car text) source nil nil)
(lyskom-insert 'move-text-not-recipient)))))
(lyskom-format-insert 'text-has-no-recipients-r text-no)))
(lyskom-format-insert 'no-such-text-no text-no))))
......@@ -3690,36 +3744,49 @@ CONTINUATION is the function that does the actual moving. It is called
with three arguments: source, target and text-stat, where source is the
recipient to remove and target the recipient to add to text-stat."
(interactive (list (lyskom-read-text-no-prefix-arg 'text-to-move)))
(let ((text-stat (blocking-do 'get-text-stat text-no)))
(if text-stat
(let* ((recipients (lyskom-text-recipients text-stat t))
(default-from (lyskom-default-recpt-for-sub recipients))
(default-to (blocking-do 'get-conf-stat
(or (lyskom-default-value 'lyskom-last-added-rcpt)
lyskom-current-conf))))
(if (null default-from)
(lyskom-format-insert 'text-has-no-recipients-r text-no)
(let ((source (lyskom-read-conf-stat
'who-to-move-from-q
(list (cons 'restrict
(mapcar 'car
recipients)))
nil
(and default-from
(cons (conf-stat->name default-from) 0))
t))
(target (lyskom-read-conf-stat
'who-to-move-to-q '(all)
nil
(and default-to
(cons (conf-stat->name default-to) 0))
t)))
(when (and source target)
(lyskom-format-insert 'moving-name source target text-stat)
(lyskom-set-default 'lyskom-last-added-rcpt (conf-stat->conf-no target))
(lyskom-set-default 'lyskom-last-sub-rcpt (conf-stat->conf-no source))
(lyskom-move-recipient text-no source target 'RECPT)))))
(lyskom-format-insert 'no-such-text-no text-no))))
(let* ((text-stat (blocking-do 'get-text-stat text-no))
(attachments (lyskom-attachments-for-sub text-no))
(footnotes (lyskom-footnotes-for-sub text-no))
(move-footnotes nil)
(move-attachments nil))
(if (null text-stat)
(lyskom-format-insert 'no-such-text-no text-no)
(let* ((recipients (lyskom-text-recipients text-stat t))
(default-from (lyskom-default-recpt-for-sub recipients))
(default-to (blocking-do 'get-conf-stat
(or (lyskom-default-value 'lyskom-last-added-rcpt)
lyskom-current-conf))))
(if (null default-from)
(lyskom-format-insert 'text-has-no-recipients-r text-no)
(let ((source (lyskom-read-conf-stat
'who-to-move-from-q
(list (cons 'restrict
(mapcar 'car
recipients)))
nil
(and default-from
(cons (conf-stat->name default-from) 0))
t))
(target (lyskom-read-conf-stat
'who-to-move-to-q '(all)
nil
(and default-to
(cons (conf-stat->name default-to) 0))
t)))
(when (and source target)
(setq move-footnotes (and footnotes (lyskom-j-or-n-p 'move-footnotes-too-q)))
(setq move-attachments (and attachments (lyskom-j-or-n-p 'move-attachments-too-q)))
(lyskom-set-default 'lyskom-last-added-rcpt (conf-stat->conf-no target))
(lyskom-set-default 'lyskom-last-sub-rcpt (conf-stat->conf-no source))
(lyskom-traverse text (append (list (cons text-no text-stat))
(and move-footnotes footnotes)
(and move-attachments attachments))
(lyskom-format-insert 'moving-name source target (cdr text))
(if (memq (conf-stat->conf-no source) (lyskom-text-recipients (cdr text)))
(lyskom-move-recipient (car text) source target 'RECPT)
(lyskom-insert 'move-text-not-recipient))
))))))))
(def-kom-command kom-move-text-tree (text-no)
......
......@@ -526,11 +526,20 @@ Read all about it at http://www.lysator.liu.se/history/")
(who-to-add-q . "Add whom/what as a recipient? ")
(who-to-add-copy-q . "Add which conference/user as carbon copy recipient? ")
(who-to-add-bcc-q . "Add which conference/user as blind carbon copy recipient? ")
(add-footnotes-too-q . "Try to add recipient to footnotes? ")
(add-attachments-too-q . "Try to add recipient to attachments? ")
(really-add-as-recpt-q . "Send future comments to the text to %#1M too? ")
(who-to-sub-q . "Remove whom/what as a recipient? ")
(sub-footnotes-too-q . "Try to remove recipient from footnotes? ")
(sub-attachments-too-q . "Try to remove recipient from attachments? ")
(who-to-move-from-q . "Move from where? ")
(who-to-move-to-q . "Move to where? ")
(who-to-move-to-or-sub-q . "Move to where (empty to just remove recipient)? ")
(move-footnotes-too-q . "Try to move footnotes? ")
(move-attachments-too-q . "Try to move attachments? ")
(move-text-not-recipient . "incorrect recipient.\n")
(adding-name-as-recipient . "Adding %#1M as recipient of text %#2n...")
(adding-name-as-copy . "%#1M will receive a carbon copy of text %#2n...")
......
......@@ -540,11 +540,20 @@ i svensk datorhistoria. L
(who-to-add-q . "Vilket mte/person vill du addera som mottagare? ")
(who-to-add-copy-q . "Vilket mte/person vill du addera som kopiemottagare? ")
(who-to-add-bcc-q . "Vilket mte/person vill du addera som mottagare av en dold kopia? ")
(add-footnotes-too-q . "Frsk addera mottagare till fotnoter ocks? ")
(add-attachments-too-q . "Frsk addera mottagare till bilagor ocks? ")
(really-add-as-recpt-q . "Skall framtida kommentarer till inlgget ocks skickas till %#1M? ")
(who-to-sub-q . "Vilket mte/person vill du subtrahera som mottagare? ")
(sub-footnotes-too-q . "Frsk subtrahera mottagare frn fotnoter ocks? ")
(sub-attachments-too-q . "Frsk subtrahera mottagare frn bilagor ocks? ")
(who-to-move-from-q . "Frn vilket mte vill du flytta texten? ")
(who-to-move-to-q . "Vart vill du flytta texten? ")
(who-to-move-to-or-sub-q . "Vart vill du flytta texten (tomt fr att bara subtrahera)? ")
(move-footnotes-too-q . "Frsk flytta fotnoter ocks? ")
(move-attachments-too-q . "Frsk flytta bilagor ocks? ")
(move-text-not-recipient . "har ej rtt mottagare.\n")
(adding-name-as-recipient . "Adderar %#1M som mottagare till text %#2n...")
(adding-name-as-copy . "Adderar %#1M som kopiemottagare till text %#2n...")
......
......@@ -525,6 +525,13 @@ lyskom-reading-list."
(string-to-number (aux-item->data el)))
(lyskom-get-aux-item (text-stat->aux-items text-stat) 10101)))
(defun lyskom-get-text-belongs-to (text-stat)
"Return a list of all texts TEXT-STAT is an attachment to."
(mapcar
(lambda (el) (string-to-number (aux-item->data el)))
(lyskom-get-aux-item (text-stat->aux-items text-stat) 10100)))
(defun lyskom-skip-attachments (text-no mark-as-read)
"Skip the hierarchy of attachments starting at text-no"
(let ((queue (list text-no))
......
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