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

Loads of changes.

Implemented kom-* synonyms for almost all lyskom-* hooks. The old names
shall be considered obsolede.

Highilghting of asynchronous messages as with texts.

Support overlays when doing lyskom-insert on the result of lyskom-format.

Fix lyskom-insert to handle special-insert properties that are adjacent to each other.

Fix lyskom-unicase so it isn't fooled by a lying Emacs.

Hopefully guard against missing diff command when calling ediff-buffers.

Added user-hooks.el, a new place for hook functions that users
might want to use elsewhere. Added some kom-change-conf-hook and
kom-after-change-conf-hook functions to this file.
parent 8aa0c642
2002-05-06 David Byers <david.byers@swipnet.se>
* utilities.el (lyskom-unicase): Get the length from the converted
string and not the string, because for some reason they don't come
out the same every time (and this is *probably* an Emacs bug).
2002-05-05 David Byers <david.byers@swipnet.se>
* commands2.el (kom-compare-texts): Catch the file-error that
occurs when the external diff command is missing.
* vars.el.in: Changed all hooks that are for users to play with
from lyskom-<foo> to kom-<foo>. The lyskom-<foo> versions still
work but are discouraged. Created dummy variables for some
configuration variables that I did not dare change right now. It
should now be possible to get all the user-accessible
configuration parameters and hooks when doing apropos on ^kom.
* async.el (lyskom-default-new-text-hook): Run kom-new-text-hook
when running lyskom-new-text-hook.
(lyskom-default-deleted-text-hook): Run kom-deleted-text-hook when
running lyskom-deleted-text-hook.
(lyskom-default-new-recipient-hook): Run kom-new-recipient-hook
when running lyskom-new-recipient-hook.
(lyskom-show-personal-message): Run kom-personal-message-hook when
running lyskom-personal-message-hook.
* edit-text.el (lyskom-edit-send): Run kom-create-text-hook when
running lyskom-create-text-hook.
* vars.el.in (kom-filter-outgoing-messages): Renamed from
lyskom-filter-outgoing-messages.
* commands1.el (lyskom-go-to-empty-conf): Run
kom-after-change-conf-hook when running
lyskom-after-change-conf-hook.
* user-hooks.el: Changed docstring references to
lyskom-change-conf-hook to kom-change-conf-hook. Changed docstring
references to lyskom-after-change-conf-hook to
kom-after-change-conf-hook.
* startup.el (kom-start-anew): Run kom-change-conf-hook when
running lyskom-change-conf-hook.
* commands1.el (lyskom-go-to-empty-conf): Run kom-change-conf-hook
when running lyskom-change-conf-hook.
* lyskom-rest.el: Run kom-after-load-hook when running
lyskom-after-load-hook.
* commands2.el (lyskom-send-message): Call kom-send-message-hook
when calling lyskom-send-message-hook.
(lyskom-send-message-minibuffer-setup-hook): Call
kom-send-message-setup-hook when calling
lyskom-send-message-setup-hook.
(lyskom-send-message-minibuffer-exit-hook): run
kom-send-message-exit-hook when calling
lyskom-send-message-exit-hook.
(lyskom-send-message-turn-off-resize-on-exit): Use
kom-send-message-exit-hook instead of
lyskom-send-message-exit-hook.
(lyskom-send-message-resize-minibuffer): Same here.
* view-text.el: Changed all docstring references to
lyskom-view-text-hook to kom-view-text-hook. Call
kom-view-text-hook when lyskom-view-text-hook is called.
* lyskom-rest.el (lyskom-do-insert): Allow special-insert to be a
list, where the car is the function to call and cdr are the
arguments to the function.
(lyskom-format-transform-result): New function.
(lyskom-special-insert-overlay): New function.
(lyskom-do-insert): We were unable to handle special-insert
properties that were adjacent to each others.
* async.el (lyskom-format-as-personal-message): Updated to handle
new format strings that have overlays for text and dashed lines.
* commands2.el (lyskom-send-message): Same here.
* startup.el (lyskom): Optionally highlight motd-of-lyskom
Added my hook functions:
* user-hooks.el (kom-read-last-text-hook): New function.
(kom-list-summary-hook): New function.
(kom-read-last-text-hook-conf-list): New variable.
(kom-list-summary-hook-conf-list): New variable.
2002-05-05 Ulrik Haugen <qha@lysator.liu.se>
* commands2.el (kom-obsolete-extended-command-binding): Balanced
......
......@@ -103,8 +103,9 @@ SOURCES = komtypes.el \
option-edit.el \
talkback.el \
faqs.el \
user-hooks.el \
lyskom-rest.el
# lyskom-rest.el should be the last file!
# lyskom-rest.el must be the last file!
# Included in the source distribution archive.
EXTRA-SRCDIST = \
......
......@@ -466,7 +466,8 @@ Args: SENDER: conf-stat for the person sending the message.
lyskom-pers-no)))
(conf-stat->name recipient)
nil))
(run-hooks 'lyskom-personal-message-hook))
(run-hooks 'lyskom-personal-message-hook)
(run-hooks 'kom-personal-message-hook))
(defun lyskom-insert-personal-message (sender recipient message
......@@ -524,7 +525,9 @@ Non-nil NOBEEP means don't beep."
(sender sender)
(t (lyskom-get-string 'unknown)))
message
when))
when
'(face kom-dashed-lines-face)
'(face kom-text-body-face)))
((= (conf-stat->conf-no recipient) lyskom-pers-no) ; Private
(if (not nobeep) (lyskom-beep kom-ding-on-personal-messages sender))
(lyskom-format (lyskom-get-string-sol 'message-from)
......@@ -533,7 +536,9 @@ Non-nil NOBEEP means don't beep."
(sender sender)
(t (lyskom-get-string 'unknown)))
message
when))
when
'(face kom-dashed-lines-face)
'(face kom-text-body-face)))
(t ; Group message
(if (not nobeep) (lyskom-beep kom-ding-on-group-messages recipient))
(lyskom-format (lyskom-get-string-sol 'message-from-to)
......@@ -546,7 +551,9 @@ Non-nil NOBEEP means don't beep."
((stringp recipient) recipient)
(recipient recipient)
(t (lyskom-get-string 'unknown)))
when)))))
when
'(face kom-dashed-lines-face)
'(face kom-text-body-face))))))
......@@ -631,7 +638,8 @@ converted, before insertion."
(when (and (not lyskom-dont-change-prompt) ;We shall change it
(not lyskom-executing-command)) ;We have time to do it.
(lyskom-update-prompt))
(run-hooks 'lyskom-new-recipient-hook))
(run-hooks 'lyskom-new-recipient-hook)
(run-hooks 'kom-new-recipient-hook))
......@@ -647,6 +655,7 @@ converted, before insertion."
(let ((no-message nil))
(run-hooks 'lyskom-new-text-hook)
(run-hooks 'kom-new-text-hook)
(if (and (not no-message)
lyskom-is-waiting
......@@ -659,7 +668,8 @@ converted, before insertion."
(if (and (not lyskom-dont-change-prompt) ;We shall change it
(not lyskom-executing-command)) ;We have time to do it.
(lyskom-update-prompt))
(run-hooks 'lyskom-deleted-text-hook))
(run-hooks 'lyskom-deleted-text-hook)
(run-hooks 'kom-deleted-text-hook))
(defun lyskom-async-new-text (text-stat)
"Take care of a message that a new text has been created."
......
......@@ -1538,12 +1538,18 @@ Args: CONF-STAT MEMBERSHIP"
(lyskom-run-hook-with-args 'lyskom-change-conf-hook
lyskom-current-conf
(conf-stat->conf-no conf-stat))
(lyskom-run-hook-with-args 'kom-change-conf-hook
lyskom-current-conf
(conf-stat->conf-no conf-stat))
(setq lyskom-current-conf (conf-stat->conf-no conf-stat))
(lyskom-format-insert 'conf-all-read
conf-stat)
(lyskom-run-hook-with-args 'lyskom-after-change-conf-hook
lyskom-current-conf
(conf-stat->conf-no conf-stat))
(lyskom-run-hook-with-args 'kom-after-change-conf-hook
lyskom-current-conf
(conf-stat->conf-no conf-stat))
(lyskom-change-conf-check-faqs conf-stat))
......
......@@ -587,13 +587,17 @@ author of that text will be shown."
(defun lyskom-send-message-minibuffer-setup-hook ()
(unwind-protect
(run-hooks 'lyskom-send-message-setup-hook)
(progn
(run-hooks 'lyskom-send-message-setup-hook)
(run-hooks 'kom-send-message-setup-hook))
(remove-hook 'minibuffer-setup-hook
'lyskom-send-message-minibuffer-setup-hook)))
(defun lyskom-send-message-minibuffer-exit-hook ()
(unwind-protect
(run-hooks 'lyskom-send-message-exit-hook)
(progn
(run-hooks 'lyskom-send-message-exit-hook)
(run-hooks 'kom-send-message-exit-hook))
(remove-hook 'minibuffer-exit-hook
'lyskom-send-message-minibuffer-exit-hook)))
......@@ -622,6 +626,7 @@ send. If DONTSHOW is non-nil, don't display the sent message."
pers-no)))
(run-hooks 'lyskom-send-message-hook)
(run-hooks 'kom-send-message-hook)
(if lyskom-message-string
(progn
(setq reply (blocking-do 'send-message pers-no
......@@ -630,16 +635,16 @@ send. If DONTSHOW is non-nil, don't display the sent message."
(if reply
(if (not dontshow)
(lyskom-handle-as-personal-message
(if lyskom-message-recipient
(lyskom-format (lyskom-get-string-sol
'message-sent-to-user)
lyskom-message-string
lyskom-message-recipient)
(lyskom-format (lyskom-get-string-sol
'message-sent-to-all)
lyskom-message-string))
(lyskom-format
(if lyskom-message-recipient
(lyskom-get-string-sol 'message-sent-to-user)
(lyskom-get-string-sol 'message-sent-to-all))
lyskom-message-string
lyskom-message-recipient
'(face kom-dashed-lines-face)
'(face kom-text-body-face))
lyskom-pers-no
lyskom-filter-outgoing-messages))
kom-filter-outgoing-messages))
(lyskom-format-insert-before-prompt
'message-nope
(or lyskom-message-recipient
......@@ -667,7 +672,7 @@ send. If DONTSHOW is non-nil, don't display the sent message."
(defun lyskom-send-message-turn-off-resize-on-exit ()
(resize-minibuffer-mode -1)
(remove-hook 'lyskom-send-message-exit-hook
(remove-hook 'kom-send-message-exit-hook
'lyskom-send-message-turn-off-resize-on-exit))
(defvar resize-minibuffer-mode)
......@@ -676,8 +681,8 @@ send. If DONTSHOW is non-nil, don't display the sent message."
(unless resize-minibuffer-mode
(resize-minibuffer-mode 1)
(resize-minibuffer-setup)
(add-hook 'lyskom-send-message-exit-hook
'lyskom-send-message-turn-off-resize-on-exit)))
(add-hook 'kom-send-message-exit-hook
'kom-send-message-turn-off-resize-on-exit)))
(defun lyskom-send-message-auto-fill ()
......@@ -2515,6 +2520,7 @@ configurable variable `kom-review-marks-texts-as-read' in the current buffer."
(set-buffer-modified-p nil)
buf))
(defvar diff-command)
(def-kom-command kom-compare-texts (old new)
"Show differences between text OLD and NEW.
When called interactively, it will prompt for the NEW text first,
......@@ -2533,9 +2539,14 @@ to the first text that NEW is a comment or footnote to."
(new-text (get-text new))
(old-text-stat (get-text-stat old))
(new-text-stat (get-text-stat new)))
(ediff-buffers
(lyskom-create-text-buffer old old-text old-text-stat)
(lyskom-create-text-buffer new new-text new-text-stat))))
(condition-case nil
(ediff-buffers
(lyskom-create-text-buffer old old-text old-text-stat)
(lyskom-create-text-buffer new new-text new-text-stat))
(file-error (lyskom-error (lyskom-get-string 'external-program-missing)
(if (boundp 'diff-command)
diff-command
"diff"))))))
;;; ================================================================
;;; Se diff - View diff
......
......@@ -505,10 +505,10 @@ anonymously and take actions to avoid revealing the sender."
;; Run user hooks
;; ####: ++++: FIXME: We should quit more graciously.
(if (not (run-hook-with-args-until-failure
'lyskom-send-text-hook))
(if (and (not (run-hook-with-args-until-failure 'kom-send-text-hook))
(not (run-hook-with-args-until-failure 'lyskom-send-text-hook)))
(signal 'lyskom-edit-text-abort nil))
;;
;; Transform the message text
;;
......@@ -582,6 +582,20 @@ anonymously and take actions to avoid revealing the sender."
aux-list)
buffer
is-anonymous)
(run-hook-with-args 'kom-create-text-hook
full-message
misc-list
(if (not is-anonymous)
(cons (lyskom-create-aux-item
0 15 0 0
(lyskom-create-aux-item-flags
nil nil nil nil nil nil nil nil)
0 (concat "lyskom.el "
lyskom-clientversion))
aux-list)
aux-list)
buffer
is-anonymous)
(funcall send-function
'sending
......@@ -632,7 +646,7 @@ anonymously and take actions to avoid revealing the sender."
(defun lyskom-ispell-text ()
"Check spelling of the text body.
Put this in lyskom-send-text-hook"
Put this in kom-send-text-hook"
(kom-ispell-message)
t)
......
......@@ -664,33 +664,37 @@ Read all about it at http://www.lysator.liu.se/history/")
(his-total-unread . "\n%#1M has a total of %#2d unread texts.\n")
(message-prompt . "Message: ")
(message-sent-to-user . "\
================================================================
Your message for %#2M:
%[%#3$================================================================
%]%[%#4$Your message for %#2M:
%#1t
----------------------------------------------------------------
")
%]%[%#3$----------------------------------------------------------------
%]")
(message-sent-to-all . "\
================================================================
Your public message:
%[%#3$================================================================
%]%[%#4$Your public message
%#1t
----------------------------------------------------------------
")
%]%[%#3$----------------------------------------------------------------
%]")
(message-sent-to-user-long . "\
%[%#3$\
===============================================================================
Your message for %#2M:
%]%[%#4$Your message for %#2M:
%#1t
%]%[%#3$\
-------------------------------------------------------------------------------
")
%]")
(message-sent-to-all-long . "\
%[%#3$\
===============================================================================
Your public message:
%]%[%#4$Your public message
%#1t
%]%[%#3$\
-------------------------------------------------------------------------------
")
%]")
(message-use-alarm-instead . "Use %#1s to send alarm messages.\n")
(message-all-info . "Send alarm\n")
(message-recipient-info . "Send message to %#1M\n")
......@@ -986,47 +990,62 @@ the command 'Join conference' to accept the invitation.\n")
(message-broadcast . "\
%[%#4$\
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%]%[%#5$\
Alarm from %#1P (%#3s):
%#2t
%]%[%#4$\
----------------------------------------------------------------
")
%]")
(message-broadcast-long . "\
%[%#4$\
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alarm from %#1P (%#3s):
%]%[%#5$Alarm from %#1P (%#3s):
%#2t
%]%[%#4$\
-------------------------------------------------------------------------------
")
%]")
(message-from . "\
%[%#4$\
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Personal message from %#1P (%#3s):
%]%[%#5$Personal message from %#1P (%#3s):
%#2t
%]%[%#4$\
----------------------------------------------------------------
")
%]")
(message-from-long . "\
%[%#4$\
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Personal message from %#1P (%#3s):
%]%[%#5$Personal message from %#1P (%#3s):
%#2t
%]%[%#4$\
-------------------------------------------------------------------------------
")
%]")
(message-from-to ."\
%[%#5$\
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Group message to %#3M\nfrom %#2P (%#4s):
%]%[%#6$Group message to %#3M\nfrom %#2P (%#4s):
%#1t
%]%[%#5$\
----------------------------------------------------------------
")
%]")
(message-from-to-long ."\
%[%#5$\
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Group message to %#3M\nfrom %#2P (%#4s):
%]%[%#6$Group message to %#3M\nfrom %#2P (%#4s):
%#1t
%]%[%#5$\
-------------------------------------------------------------------------------
")
%]")
(text-is-created . "Text %#1n has been created!")
; Used in mode-line-process
......@@ -1707,6 +1726,8 @@ Number of sessions: %21#1d (total)
(kom-redirect-comments-e49 . "You do not have permission to perform this redirection")
(kom-redirect-comments-e48 . "Comment redirection is not supported by the server")
(external-program-missing . "Can't find the external program \"%#1s\", that was required for this command.")
))
......@@ -3158,7 +3179,7 @@ be saved in the server. Otherwise it will be saved in your .emacs.")
recently received group message; or the sender of the most recently
received personal message.")
(lyskom-filter-outgoing-messages-doc . "\
(kom-filter-outgoing-messages-doc . "\
If this is on, messages that are sent automatically, such as automatic
replies and replies to remote control commands, will be shown as if you
had sent them manually.")
......@@ -3573,7 +3594,7 @@ be saved in the server. Otherwise it will be saved in your .emacs.")
(kom-ding-on-personal-messages-tag . "When a personal message arrives: ")
(kom-ding-on-no-subject-tag . "When you forget the subject line: ")
(lyskom-filter-outgoing-messages-tag . "Show automatic messages:")
(kom-filter-outgoing-messages-tag . "Show automatic messages:")
(kom-friends-tag . "Friends and other special people:")
(kom-morons-tag . "Morons and other \"special\" people:")
(kom-url-viewer-preferences-tag . "Open URLs using the following program:")
......
......@@ -989,10 +989,17 @@ The position lyskom-last-viewed will always remain visible."
(remove-text-properties (car bounds) (cdr bounds)
'(special-insert))
(condition-case val
(funcall fn (car bounds) (cdr bounds))
(funcall (if (listp fn)
(car fn)
fn)
(car bounds)
(cdr bounds)
(if (listp fn)
(cdr fn)
nil))
(error (apply 'message "%S" val)))
(setq start next)
(setq bounds (next-text-property-bounds 1 start
(setq bounds (next-text-property-bounds 1 (1- start)
'special-insert))))
(error (lyskom-ignore var)))))
......@@ -1112,8 +1119,32 @@ Args: FORMAT-STRING &rest ARGS"
(lyskom-insert atom)
(lyskom-insert (lyskom-get-string atom))))
(defun lyskom-format-transform-result (state)
"Convert a format-state to a string."
(let ((result (format-state->result state)))
(lyskom-traverse overlay (format-state->delayed-overlays state)
(add-text-properties (aref overlay 0)
(aref overlay 1)
(list 'special-insert
(cons 'lyskom-special-insert-overlay
(aref overlay 2)))
result))
result))
(defun lyskom-special-insert-overlay (start end args)
(lyskom-xemacs-or-gnu
(let ((overlay (make-extent start end)))
(while args
(set-extent-property overlay (car args) (car (cdr args)))
(setq args (nthcdr 2 args)))
(set-extent-priority overlay 1000))
(let ((overlay (make-overlay start end)))
(while args
(overlay-put overlay (car args) (car (cdr args)))
(setq args (nthcdr 2 args))))))
(defun lyskom-format (format-string &rest argl)
(format-state->result (lyskom-do-format format-string argl)))
(lyskom-format-transform-result (lyskom-do-format format-string argl)))
(defun lyskom-format-insert-overlays (start format-state)
"Insert delayed overlays according to FORMAT-STATE."
......@@ -1176,9 +1207,9 @@ The string is inserted just before the prompt, and if the prompt is not
currently visible the text is queued to be inserted when the prompt
reappears.
Deferred insertions and overlays are not supported."
Deferred insertions are not supported."
(lyskom-insert-before-prompt
(format-state->result (lyskom-do-format format-string argl))))
(lyskom-format-transform-result (lyskom-do-format format-string argl))))
(defun lyskom-do-format (format-string &optional argl allow-defer)
......@@ -1899,7 +1930,7 @@ Deferred insertions and overlays are not supported."
tmp))
tmp)))))
(defun lyskom-postprocess-text (start end)
(defun lyskom-postprocess-text (start end &rest args)
(condition-case nil
(smiley-region start (min (point-max) (1+ end)))
(error nil)))
......@@ -1915,7 +1946,7 @@ in lyskom-messages."
(lyskom-external-function w3-finish-drawing)
(defun lyskom-w3-region (start end)
(defun lyskom-w3-region (start end &rest args)
(unwind-protect
(condition-case var
(save-restriction
......@@ -3925,6 +3956,7 @@ One parameter - the prompt string."
(lyskom-set-queue-priority 'async 3)
(lyskom-set-queue-priority 'prefetch 0)
(run-hooks 'lyskom-after-load-hook)
(run-hooks 'kom-after-load-hook)
(setq lyskom-is-loaded t))
......@@ -3932,7 +3964,7 @@ One parameter - the prompt string."
(provide 'lyskom-rest)
;;; This should be the very last lines of lyskom.el Everything should
;;; be loaded now, so it's time to run the lyskom-after-load-hook.
;;; be loaded now, so it's time to run the kom-after-load-hook.
(lyskom-end-of-compilation)
......
......@@ -198,7 +198,7 @@
[kom-ignore-message-senders]
[kom-ignore-message-recipients]
[kom-show-personal-message-date]
[lyskom-filter-outgoing-messages]
[kom-filter-outgoing-messages]
"\n\n"
section
(writing bold centered)
......@@ -616,7 +616,7 @@ customize buffer but do not save them to the server."
(const (group-rcpt group))
(const (sender-rcpt sender))
(const (last-recipient-recpt last-recipient)))))
(lyskom-filter-outgoing-messages (noggle (yes no)))
(kom-filter-outgoing-messages (noggle (yes no)))
(kom-friends (repeat (person nil :tag name) :indent 4))
(kom-morons (repeat (person nil :tag name) :indent 4))
(kom-url-viewer-preferences (repeat (url-viewer nil :tag viewer-program)
......
......@@ -293,11 +293,12 @@ clients of the event. See lyskom-mode for details on lyskom."
(text-stat (get-text-stat
(server-info->motd-of-lyskom
lyskom-server-info))))
(lyskom-format-insert "%#1t"
(lyskom-format-insert "%#1t\n"
(if (and text text-stat)
(text->decoded-text-mass text text-stat)
(lyskom-get-string 'lyskom-motd-was-garbed)))
(lyskom-insert "\n")))
(lyskom-get-string 'lyskom-motd-was-garbed))
(when kom-highlight-text-body
'(face kom-text-body-face)))))
;; Can't use lyskom-end-of-command here.
(setq lyskom-executing-command nil)
......@@ -540,6 +541,9 @@ shown to other users."
(lyskom-run-hook-with-args 'lyskom-change-conf-hook
lyskom-current-conf
0)
(lyskom-run-hook-with-args 'kom-change-conf-hook
lyskom-current-conf
0)
(setq lyskom-current-conf 0)
;; (cache-initiate-who-info-buffer (blocking-do 'who-is-on))
(cache-set-marked-texts (blocking-do 'get-marks))
......
......@@ -646,33 +646,45 @@ i svensk datorhistoria. L