Commit da434a8c authored by Johan Sundström's avatar Johan Sundström
Browse files

Touched up the [lys]kom-(add|sub|move)-* functions and added the hook

lyskom-add-sub-recipients-hook and an example hook
lyskom-annoying-verify-add-rcpt for it.
parent f518853c
2000-06-10 Johan Sundstrm <jhs@lysator.liu.se>
* vars.el.in (lyskom-add-sub-recipients-hook): New hook.
* commands1.el (lyskom-add-recipient): New macro.
(kom-add-recipient): Standard prefix-arguments. Uses above macro.
(lyskom-sub-recipient): New macro.
(kom-sub-recipient): Standard prefix-arguments. Uses above macro.
(lyskom-add-copy): New macro.
(kom-add-copy): Standard prefix-arguments. Uses above macro.
(lyskom-add-bcc): New macro.
(kom-add-bcc): Standard prefix-arguments. Uses above macro.
(kom-move-text): Standard prefix-arguments.
(lyskom-annoying-verify-add-rcpt): New function.
(lyskom-add-sub-recipient): Arguments changed. Runs the hook
lyskom-add-sub-recipients-hook, which may alter the new variables
lyskom-add-sub-recipient-action,
lyskom-add-sub-recipient-source-conf and/or
lyskom-add-sub-recipient-target-conf.
2000-06-06 Joel Rosdahl <joel@lysator.liu.se>
* commands1.el (lyskom-comment-recipients): Don't send footnotes
......@@ -6,7 +26,7 @@
* commands1.el (lyskom-comment-recipients): Fixed a bug that
sometimes prevented the author's mailbox from being added as
recipient when it should.
2000-06-05 David Byers <davby@ida.liu.se>
* utilities.el (lyskom-read-text-no-prefix-arg): Don't use zerop
......
......@@ -2874,58 +2874,58 @@ footnotes) to it as read in the server."
;;; Addera mottagare - Add recipient
;;; Subtrahera mottagare - Subtract recipient
;;; Author: David Byers & David K}gedal
;;; Author: David Byers, David Kågedal and Johan Sundström
;;; Based on code by Inge Wallin
(def-kom-command kom-add-recipient (text-no-arg)
"Add a recipient to a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
(interactive "P")
;(macroexpand '(lyskom-sub-recipient 1 2))
(defmacro lyskom-defmacro-lyskom-add-sub-rcpt (name action description)
"Defines a macro lyskom-NAME (text-no conf) for calling
lyskom-add-sub-recipient in a more readable fashion."
`(defmacro
,(intern (concat "lyskom-" (symbol-name name)))
(text-no conf)
,(concat description " a text TEXT-NO.")
(list 'lyskom-add-sub-recipient text-no ',action conf)))
(lyskom-defmacro-lyskom-add-sub-rcpt add-recipient 'add-rcpt
"Add a recipient CONF to")
(lyskom-defmacro-lyskom-add-sub-rcpt sub-recipient 'sub
"Subtract a recipient (of any type) CONF from")
(lyskom-defmacro-lyskom-add-sub-rcpt add-copy 'add-copy
"Add a cc (carbon copy) recipient CONF to")
(lyskom-defmacro-lyskom-add-sub-rcpt add-bcc 'add-bcc
"Add a bcc (blind carbon copy) recipient CONF to")
(def-kom-command kom-add-recipient (text-no)
"Add a recipient to a text."
(interactive (list (lyskom-read-text-no-prefix-arg 'text-to-add-recipient)))
(let ((conf (blocking-do 'get-conf-stat lyskom-last-added-rcpt)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-add-recipient)
'add-rcpt
conf)))
(def-kom-command kom-add-copy (text-no-arg)
"Add a cc recipient to a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
(interactive "P")
(lyskom-add-recipient text-no conf)))
(def-kom-command kom-add-copy (text-no)
"Add a cc (carbon copy) recipient to a text."
(interactive (list (lyskom-read-text-no-prefix-arg 'text-to-add-copy)))
(let ((conf (blocking-do 'get-conf-stat lyskom-last-added-ccrcpt)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-add-copy)
'add-copy
conf)))
(def-kom-command kom-add-bcc (text-no-arg)
"Add a cc recipient to a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
(interactive "P")
(lyskom-add-copy text-no conf)))
(def-kom-command kom-add-bcc (text-no)
"Add a bcc (blind carbon copy) recipient to a text."
(interactive (list (lyskom-read-text-no-prefix-arg 'text-to-add-bcc)))
(let ((conf (blocking-do 'get-conf-stat lyskom-last-added-bccrcpt)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-add-bcc)
'add-bcc
conf)))
(def-kom-command kom-sub-recipient (text-no-arg)
"Subtract a recipient from a text. If the argument TEXT-NO-ARG is non-nil,
the user has used a prefix command argument."
(interactive "P")
(lyskom-add-bcc text-no conf)))
(def-kom-command kom-sub-recipient (text-no)
"Subtract a recipient from a text."
(interactive (list (lyskom-read-text-no-prefix-arg 'text-to-delete-recipient)))
(let ((conf (blocking-do 'get-conf-stat lyskom-current-conf)))
(lyskom-add-sub-recipient text-no-arg
(lyskom-get-string 'text-to-delete-recipient)
'sub
conf)))
(def-kom-command kom-move-text (text-no-arg)
"Subtract a recipient from a text and add another.
If the argument TEXT-NO-ARG is non-nil, the user has used a prefix
command argument."
(interactive "P")
(let* ((text-no (lyskom-read-number (lyskom-get-string 'text-to-move)
(or text-no-arg lyskom-current-text)))
(text-stat (blocking-do 'get-text-stat text-no))
(lyskom-sub-recipient text-no conf)))
(def-kom-command kom-move-text (text-no)
"Subtract a recipient from a text and add another."
(interactive (list (lyskom-read-text-no-prefix-arg 'text-to-move)))
(let* ((text-stat (blocking-do 'get-text-stat text-no))
default-recpt found)
(lyskom-traverse misc-item
......@@ -2940,7 +2940,7 @@ command argument."
(cond ((null text-stat)
(lyskom-format-insert 'no-such-text-no text-no))
((null default-recpt)
((null default-recpt)
(lyskom-format-insert 'text-has-no-recipients-r text-no))
(t (blocking-do-multiple
((default-from (get-conf-stat default-recpt))
......@@ -2948,133 +2948,149 @@ command argument."
(or lyskom-last-added-rcpt
lyskom-current-conf))))
(lyskom-add-sub-recipient text-no
(lyskom-get-string 'text-to-move)
'move
default-to
default-from t))))))
;;; NOTE: If you add an action you need to add an foo-action-name
default-from))))))
(defvar lyskom-add-sub-recipient-action)
(defvar lyskom-add-sub-recipient-source-conf)
(defvar lyskom-add-sub-recipient-target-conf)
(defun lyskom-annoying-verify-add-rcpt ()
"Make sure the (l?)user really does mean to add a recipient
conference instead of just adding a carbon copy as (s?)he most likely
ought to. Useful as a lyskom-add-sub-recipient-hook only."
(when (and
(eq lyskom-add-sub-recipient-action 'add-rcpt)
lyskom-add-sub-recipient-target-conf
(not
(lyskom-j-or-n-p
(lyskom-format
'really-add-as-recpt-q
lyskom-add-sub-recipient-target-conf)
t)))
(setq lyskom-add-sub-recipient-action 'add-copy)))
;;; NOTE: If you add an action you need to add a foo-action-name
;;; string to the strings files.
(defun lyskom-add-sub-recipient (text-no-arg
prompt
action
conf
&optional conf2 text-no-is-read)
(defun lyskom-add-sub-recipient (text-no action conf
&optional conf2)
"Add or remove a recipient.
TEXT-NO-ARG is the prefix argument from (interactive \"P\"); PROMPT is
the prompt string to use when reading the text number; ACTION is what
to do (one of add-rcpt, add-copy, add-bcc, sub or move), CONF is the
conference to add, remove or move from, CONF2 is thee conference to
move to (for move) and a non-nil TEXT-NO-IS-READ means that the user has
already been prompted for a text number so TEXT-NO-ARG contains the
actual text to do whatever on."
(let ((text-no (if (and text-no-is-read text-no-arg)
text-no-arg
(let ((current-prefix-arg text-no-arg))
(lyskom-read-text-no-prefix-arg prompt)))))
(if text-no
(let* ((text-stat (blocking-do 'get-text-stat text-no))
(was-read (lyskom-text-read-p text-stat))
;; Only for moving
(conf-to-move-from (if (eq action 'move)
(lyskom-read-conf-stat
(lyskom-get-string 'who-to-move-from-q)
'(all)
nil
(cons (if conf2 (conf-stat->name conf2) "") 0)
t)))
(conf-to-add-to (lyskom-read-conf-stat
(lyskom-get-string
(cond ((eq action 'add-rcpt) 'who-to-add-q)
((eq action 'add-copy) 'who-to-add-copy-q)
((eq action 'add-bcc) 'who-to-add-bcc-q)
((eq action 'sub) 'who-to-sub-q)
((eq action 'move) 'who-to-move-to-q)
(t (lyskom-error "internal error"))))
'(all)
nil
(cons (if conf (conf-stat->name conf) "") 0)
t))
(result nil))
;; Confirm add a full recipient
(when (and (eq action 'add-rcpt)
conf-to-add-to
(not (lyskom-j-or-n-p (lyskom-format 'really-add-as-recpt-q conf-to-add-to) t)))
(setq action 'add-copy))
(setq result
(cond ((eq action 'add-rcpt)
(lyskom-format-insert 'adding-name-as-recipient
conf-to-add-to
text-stat)
(setq lyskom-last-added-rcpt
(conf-stat->conf-no conf-to-add-to))
(blocking-do 'add-recipient
text-no
(conf-stat->conf-no conf-to-add-to)
'recpt))
((eq action 'add-copy)
(lyskom-format-insert 'adding-name-as-copy
conf-to-add-to
text-stat)
(setq lyskom-last-added-ccrcpt
(conf-stat->conf-no conf-to-add-to))
(blocking-do 'add-recipient
text-no
(conf-stat->conf-no conf-to-add-to)
'cc-recpt))
((eq action 'add-bcc)
(lyskom-format-insert 'adding-name-as-copy
conf-to-add-to
text-stat)
(setq lyskom-last-added-bccrcpt
(conf-stat->conf-no conf-to-add-to))
(blocking-do 'add-recipient
text-no
(conf-stat->conf-no conf-to-add-to)
'bcc-recpt))
((eq action 'sub)
(lyskom-format-insert 'remove-name-as-recipient
conf-to-add-to
text-stat)
(blocking-do 'sub-recipient
text-no
(conf-stat->conf-no conf-to-add-to)))
((eq action 'move)
(lyskom-format-insert 'moving-name
conf-to-move-from
conf-to-add-to
text-stat)
(setq lyskom-last-added-rcpt
(conf-stat->conf-no conf-to-add-to))
(blocking-do-multiple
((add (add-recipient
text-no
(conf-stat->conf-no conf-to-add-to)
'recpt))
(sub (sub-recipient
text-no
(conf-stat->conf-no conf-to-move-from))))
(and add sub)))
(t (lyskom-error "internal error"))))
(cache-del-text-stat text-no)
(if was-read (lyskom-mark-as-read (blocking-do 'get-text-stat text-no)))
(lyskom-report-command-answer result))
(lyskom-format-insert 'confusion-what-to-add-sub-recipient
(lyskom-get-string (intern (concat (symbol-name action)
"-action-name")))))))
TEXT-NO is the text being operated on; ACTION is what to do (one of
add-rcpt, add-copy, add-bcc, sub or move), CONF is the conference to
add, remove or move from, CONF2 is the conference to move to (for
move)."
(if text-no
(let* ((text-stat (blocking-do 'get-text-stat text-no))
(was-read (lyskom-text-read-p text-stat))
;; Only for moving
(lyskom-add-sub-recipient-source-conf
(when (eq action 'move)
(lyskom-read-conf-stat
(lyskom-get-string 'who-to-move-from-q)
'(all)
nil
(cons (if conf2 (conf-stat->name conf2) "") 0)
t)))
(lyskom-add-sub-recipient-target-conf
(lyskom-read-conf-stat
(lyskom-get-string
(cond ((eq action 'add-rcpt) 'who-to-add-q)
((eq action 'add-copy) 'who-to-add-copy-q)
((eq action 'add-bcc) 'who-to-add-bcc-q)
((eq action 'sub) 'who-to-sub-q)
((eq action 'move) 'who-to-move-to-q)
(t (lyskom-error "internal error"))))
'(all)
nil
(cons (if conf (conf-stat->name conf) "") 0)
t))
(lyskom-add-sub-recipient-action action)
(result nil))
; hooks for doing nasty questions like "really sure about adding conf?"
(run-hooks 'lyskom-add-sub-recipients-hook)
(setq result
(cond ((eq lyskom-add-sub-recipient-action 'add-rcpt)
(lyskom-format-insert 'adding-name-as-recipient
lyskom-add-sub-recipient-target-conf
text-stat)
(setq lyskom-last-added-rcpt
(conf-stat->conf-no
lyskom-add-sub-recipient-target-conf))
(blocking-do 'add-recipient
text-no
(conf-stat->conf-no
lyskom-add-sub-recipient-target-conf)
'recpt))
((eq lyskom-add-sub-recipient-action 'add-copy)
(lyskom-format-insert 'adding-name-as-copy
lyskom-add-sub-recipient-target-conf
text-stat)
(setq lyskom-last-added-ccrcpt
(conf-stat->conf-no
lyskom-add-sub-recipient-target-conf))
(blocking-do 'add-recipient
text-no
(conf-stat->conf-no
lyskom-add-sub-recipient-target-conf)
'cc-recpt))
((eq lyskom-add-sub-recipient-action 'add-bcc)
(lyskom-format-insert 'adding-name-as-copy
lyskom-add-sub-recipient-target-conf
text-stat)
(setq lyskom-last-added-bccrcpt
(conf-stat->conf-no
lyskom-add-sub-recipient-target-conf))
(blocking-do 'add-recipient
text-no
(conf-stat->conf-no
lyskom-add-sub-recipient-target-conf)
'bcc-recpt))
((eq lyskom-add-sub-recipient-action 'sub)
(lyskom-format-insert 'remove-name-as-recipient
lyskom-add-sub-recipient-target-conf
text-stat)
(blocking-do 'sub-recipient
text-no
(conf-stat->conf-no
lyskom-add-sub-recipient-target-conf)))
((eq lyskom-add-sub-recipient-action 'move)
(lyskom-format-insert 'moving-name
lyskom-add-sub-recipient-source-conf
lyskom-add-sub-recipient-target-conf
text-stat)
(setq lyskom-last-added-rcpt
(conf-stat->conf-no
lyskom-add-sub-recipient-target-conf))
(blocking-do-multiple
((add (add-recipient
text-no
(conf-stat->conf-no
lyskom-add-sub-recipient-target-conf)
'recpt))
(sub (sub-recipient
text-no
(conf-stat->conf-no
lyskom-add-sub-recipient-source-conf))))
(and add sub)))
(t (lyskom-error "internal error"))))
(cache-del-text-stat text-no)
(if was-read (lyskom-mark-as-read (blocking-do 'get-text-stat text-no)))
(lyskom-report-command-answer result))
(lyskom-format-insert 'confusion-what-to-add-sub-recipient
(lyskom-get-string (intern (concat (symbol-name action)
"-action-name"))))))
......@@ -3183,4 +3199,3 @@ DO-ADD: NIL if a footnote should be subtracted.
;;; Local Variables:
;;; eval: (put 'lyskom-traverse 'lisp-indent-hook 2)
;;; end:
Du måste läsa ett inlägg först.
......@@ -430,7 +430,7 @@ long as there are sessions with unread texts.
server)
(def-kom-var lyskom-view-text-hook nil
"*Hook that is called before a text is shown. When the hooks is
"*Hook that is called before a text is shown. When the hooks are
called, lyskom-view-text-text is bound to the text mass of the
text and lyskom-view-text-text-stat to the text-stat of the text
to be shown.")
......@@ -476,6 +476,15 @@ This is a list of commands that are executed after we have logged in but before
any command is accepted from the keyboard. See also lyskom-login-hook."
server)
(def-kom-var lyskom-add-sub-recipients-hook '(lyskom-annoying-verify-add-rcpt)
"*Hook that is called when adding and removing recipients. When the
hooks are called, lyskom-add-sub-recipient-action is bound to the
action in progress, lyskom-add-sub-recipient-source-conf to the
conference being moved from (when lyskom-add-sub-recipient-action is
'move) and lyskom-add-sub-recipient-target-conf to the conference
being movedd to/added to/subtracted from. See also
`lyskom-add-sub-recipient'.")
(def-kom-var kom-do-when-done '(kom-review-all-marked-texts kom-display-time)
"*What to do when all texts are read.
......
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