Commit 66c40ced authored by David Kågedal's avatar David Kågedal
Browse files

Skapade def-kom-command

Gjorde så att blocking-do går att avbryta
parent 2663602c
No preview for this file type
......@@ -274,6 +274,9 @@ Args: SENDER: conf-stat for the person issuing the broadcast message or a
(lyskom-insert-personal-message sender recipient message)
(setq lyskom-last-personal-message-sender (if (stringp sender) sender
(conf-stat->name sender)))
(setq lyskom-last-group-message-recipient (if recipient
(conf-stat->name recipient)
nil))
(run-hooks 'lyskom-personal-message-hook))
......@@ -286,7 +289,7 @@ MESSAGE is a string containing the message.
INSERT-FUNCTION is a function that given a string inserts it into the
current buffer."
(lyskom-handle-as-personal-message
(cond ((eq recipient 0)
(cond ((eq recipient 0) ; Public message
(if (eq t kom-ding-on-personal-messages) (beep))
(lyskom-format 'message-broadcast
(cond
......@@ -295,7 +298,7 @@ current buffer."
(t (lyskom-get-string 'unknown)))
message
(substring (current-time-string) 11 19)))
((= (conf-stat->conf-no recipient) lyskom-pers-no)
((= (conf-stat->conf-no recipient) lyskom-pers-no) ; Private
(if (memq kom-ding-on-personal-messages '(t personal)) (beep))
(lyskom-format 'message-from
(cond
......@@ -304,7 +307,7 @@ current buffer."
(t (lyskom-get-string 'unknown)))
message
(substring (current-time-string) 11 19)))
(t
(t ; Group message
(if (memq kom-ding-on-personal-messages '(t group)) (beep))
(lyskom-format 'message-from-to
message
......
This diff is collapsed.
This diff is collapsed.
......@@ -298,9 +298,10 @@ to conf-no translator."
(list (conf-stat->name
(blocking-do 'get-conf-stat no)))))
mappedlist)))
(if (and (= (length strings) 1)
(string= string (car (car strings))))
t ; Exact
(if (= (length strings) 1)
(if (string= string (car (car strings)))
t ; Exact
(car (car strings)))
(lyskom-try-complete-partials string strings)))))))
......
......@@ -160,7 +160,7 @@ Email-address:\n\nOther:\t")
; No entries.
; From services.el:
; No entries.
(interrupted . "Interrupted")
; From cache.el:
; No entries.
......@@ -304,7 +304,7 @@ and you have finished reading. Please come back later.
(go-to-conf . "Go to conference %#1M.\n")
(cant-go-to-his-mailbox . "You are not allowed to go to %#1s's mailbox.\n")
(not-member-of-conf . "You are not subscribed to %#1s.\n")
(about-to-change-name-from . "%#1s\n")
(about-to-change-name-from . "%#1P\n")
(change-name-done . "Done. New name: %#1s.\n")
(change-name-nope . "Didn't work. Error code %#3d. %#2s.\n")
(change-supervisor-from-to . "Change supervisor of %#1s to %#2s...")
......
No preview for this file type
......@@ -66,6 +66,51 @@ Value returned is always nil."
forms)
'(set-buffer __buffer__))))
;; The following is equal to this:
;; (eval-when-compile (require 'edebug))
;; (def-edebug-spec lyskom-save-excursion t)
(put 'lyskom-save-excursion 'edebug-form-spec t)
;;;; LysKOM user commands
;; The new, blocking commands have a very similar structure
;;
;; (defun kom-cmd (args)
;; "Documentation"
;; (interactive "...")
;; (lyskom-start-of-command 'kom-cmd)
;; (unwind-protect
;; (progn ...)
;; (lyskom-end-of-command)))
;;
;; This can now be written as
;;
;; (def-kom-command kom-cmd (args)
;; "Documentation"
;; (interactive "...")
;; ...)
(defmacro def-kom-command (cmd args doc interactive-decl &rest forms)
(list 'defun cmd args doc interactive-decl
(list 'lyskom-start-of-command (list 'quote cmd))
(list 'unwind-protect
(cons 'progn
forms)
(list 'lyskom-end-of-command))))
;;(def-edebug-spec def-kom-command
;; (&define name lambda-list
;; [&optional stringp] ; Match the doc string, if present.
;; ("interactive" interactive)
;; def-body))
(put 'def-kom-command 'edebug-form-spec
'(&define name lambda-list
[&optional stringp] ; Match the doc string, if present.
("interactive" interactive)
def-body))
;;;; Some useful macros to make the code more readable.
......
......@@ -810,13 +810,14 @@ functions and variables that are connected with the lyskom-buffer."
(normal-exit nil))
(unwind-protect
(progn
(cond
((eq key ?=) ;The call succeeded.
(lyskom-parse-success (lyskom-parse-num) lyskom-buffer))
((eq key ?%) ;The call was not successful.
(lyskom-parse-error (lyskom-parse-num) lyskom-buffer))
((eq key ?:) ;An asynchronous message.
(lyskom-parse-async (lyskom-parse-num) lyskom-buffer)))
(let ((inhibit-quit nil))
(cond
((eq key ?=) ;The call succeeded.
(lyskom-parse-success (lyskom-parse-num) lyskom-buffer))
((eq key ?%) ;The call was not successful.
(lyskom-parse-error (lyskom-parse-num) lyskom-buffer))
((eq key ?:) ;An asynchronous message.
(lyskom-parse-async (lyskom-parse-num) lyskom-buffer))))
(setq normal-exit t))
;; In case the command changes buffer.
;; One reply is now parsed. Check if there is yet
......@@ -826,7 +827,6 @@ functions and variables that are connected with the lyskom-buffer."
(goto-char (point-min))
(while (looking-at "[ \t\n\r]")
(delete-char 1))
(setq inhibit-quit nil) ;We are allowed to break here.
))))
(store-match-data match-data)))
......@@ -214,7 +214,7 @@ Descends recursively in the comment-tree without marking the texts as read.
The tree is forgotten when a kom-go-to-next-conf command is issued.
If optional prefix argument TEXT-NO is present view tree from that text
instead. In this case the text TEXT-NO is first shown."
(interactive (list
(interactive (list
(cond
((null current-prefix-arg)
lyskom-current-text)
......@@ -223,15 +223,16 @@ instead. In this case the text TEXT-NO is first shown."
(t
(signal 'lyskom-internat-error '(kom-review-tree))))))
(lyskom-start-of-command 'kom-review-tree)
(lyskom-tell-internat 'kom-tell-review)
(if text-no
(unwind-protect
(progn
(initiate-get-text-stat 'main 'lyskom-follow-comments text-no
nil 'review
(lyskom-get-current-priority)
t)
(lyskom-run 'mail 'lyskom-end-of-command))
(lyskom-insert-string 'read-text-first)
(lyskom-tell-internat 'kom-tell-review)
(if text-no
(let ((ts (blocking-do 'get-text-stat text-no)))
(lyskom-follow-comments ts
nil 'review
(lyskom-get-current-priority)
t))
(lyskom-insert-string 'read-text-first)))
(lyskom-end-of-command)))
......@@ -239,23 +240,21 @@ instead. In this case the text TEXT-NO is first shown."
"Finds the root text of the tree containing the text in lyskom-current-text."
(interactive)
(lyskom-start-of-command 'kom-find-root)
(lyskom-tell-internat 'kom-tell-review)
(cond
(lyskom-current-text
(lyskom-collect 'review)
(initiate-get-text-stat 'review nil lyskom-current-text)
(initiate-get-text-stat 'review nil lyskom-current-text)
(lyskom-use 'review 'lyskom-find-root 'kom-find-root-2))
(t
(lyskom-insert-string 'read-text-first)
(lyskom-end-of-command))))
(defun kom-find-root-2 (text-no)
"Runs lyskom-view-text with the text-no that lyskom-find-root produced
and then runs lyskom-end-of-command."
(lyskom-view-text text-no)
(lyskom-end-of-command))
(unwind-protect
(progn
(lyskom-tell-internat 'kom-tell-review)
(cond
(lyskom-current-text
(let* ((ts (blocking-do 'get-text-stat lyskom-current-text))
(r (lyskom-find-root ts ts)))
(if r
(lyskom-view-text r)
(signal 'lyskom-internal-error "Could not find root"))
)
)
(t
(lyskom-insert-string 'read-text-first))))
(lyskom-end-of-command)))
(defun kom-find-root-review ()
......@@ -275,7 +274,7 @@ reviews the whole tree in deep-first order."
(lyskom-end-of-command))))
(defun lyskom-find-root (text-stat old-text-stat thendo)
(defun lyskom-find-root (text-stat old-text-stat)
"Finds the root text of the tree containing the text TEXT-STAT.
Args: TEXT-STAT OLD-TEXT-STAT THENDO
If TEXT-STAT is nil and OLD-TEXT-STAT contains a text-stat
......@@ -283,14 +282,13 @@ then this means that the parent of the text in OLD-TEXT-STAT is not readable
and the text in OLD-TEXT-STAT is to be used instead.
If both TEXT-STAT and OLD-TEXT-STAT is nil then this means we are not allowed
to read the text we are trying to find the root of. This just returns with a
message.
If the third argument THENDO is non-nil then call the function with the text-no
of the root text as argument."
message."
(let* ((ts text-stat)
(misclist (and ts (text-stat->misc-info-list ts)))
(todo t))
(res nil))
(cond
(ts ;+++ Smartare errorhantering hit.
(setq res 'noparents)
(while misclist
(let* ((type (misc-info->type (car misclist)))
(comm (eq type 'COMM-TO))
......@@ -301,17 +299,16 @@ of the root text as argument."
(misc-info->footn-to (car misclist)))))
(cond
(yes
(initiate-get-text-stat 'main 'lyskom-find-root
parent-no ts thendo)
(setq todo nil)
(setq misclist nil))))
(setq misclist (cdr misclist)))
(if todo (apply thendo (list (text-stat->text-no ts)))))
(let* ((pts (blocking-do 'get-text-stat parent-no)))
(if (setq res (lyskom-find-root pts ts))
(setq misclist nil))))
(t
(setq misclist (cdr misclist))))))
(if (eq res 'noparents) (text-stat->text-no ts) res))
(old-text-stat
(apply thendo (list (text-stat->text-no old-text-stat))))
(text-stat->text-no old-text-stat))
(t
(lyskom-insert-string 'cannot-get-last-text)
(lyskom-end-of-command)))))
nil))))
(defun lyskom-review-tree (text)
......
......@@ -663,8 +663,11 @@ or get-text-stat."
(symbol-name command)))
'blocking 'blocking-return
data)
(while (eq lyskom-blocking-return 'not-yet-gotten)
(while (and (eq lyskom-blocking-return 'not-yet-gotten)
(not lyskom-quit-flag))
(accept-process-output))
(if lyskom-quit-flag (error (lyskom-get-string 'interrupted)))
(setq lyskom-quit-flag nil)
lyskom-blocking-return)))
......@@ -166,7 +166,7 @@ Email-adress:\n\nAnnat:\t")
; No entries.
; From services.el:
; No entries.
(interrupted . "Kommandot avbrutet")
; From cache.el:
; No entries.
......
......@@ -176,8 +176,11 @@ kom-show-personal-messages-in-buffer decides which buffer to pop.")
Non-nil and non-t means only ding when they really are personal.")
(defvar kom-send-message-to-last-sender t
"*Non-nil means default recipient of personal messages is the sender of
the last message received. Nil means default is everybody.")
"*Who to send messages to.
Non-nil means default recipient of messages is the sender of the last
personal message received. If the last message was a group message,
the default recipient will be the recipient of that message, unless
this variable is 'always. Nil means default is everybody.")
(defvar kom-text-properties t
"*Non-nil means to insert text properties in the Emacs buffer for
......@@ -488,6 +491,9 @@ priority) is copied from this list to lyskom-reading-list.
The first element is a dummy.")
(defvar lyskom-quit-flag nil
"A flag indicating if the filter was interrupted by C-g.
It is set to the same value as quit-flag on filter exit.")
;;; These variables control prefetch of conf-stats, text-stats and texts:
......@@ -644,6 +650,9 @@ unread texts in list-unread.")
(defvar lyskom-last-personal-message-sender ""
"Name of sender of last personal message received")
(defvar lyskom-last-group-message-recipient ""
"Name of target for last group message received")
;;;; lyskom-tell-phrases-validation-keyword-list
;;; This is a list of keywords for kom-tell-phrases.
......
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