Make multiline notify

This commit is contained in:
Kirill A. Korinskiy 2010-01-08 12:42:11 +03:00
parent 7d67638dfb
commit 532939f971
12 changed files with 80 additions and 78 deletions

View File

@ -31,11 +31,11 @@
jabber-message-scroll)
"Hooks run when a new message arrives.
Arguments are FROM, BUFFER, TEXT and PROPOSED-ALERT. FROM is the JID
of the sender, BUFFER is the the buffer where the message can be read,
and TEXT is the text of the message. PROPOSED-ALERT is the string
returned by `jabber-alert-message-function' for these arguments, so that
hooks do not have to call it themselves.
Arguments are FROM, BUFFER, TEXT and TITLE. FROM is the JID of
the sender, BUFFER is the the buffer where the message can be
read, and TEXT is the text of the message. TITLE is the string
returned by `jabber-alert-message-function' for these arguments,
so that hooks do not have to call it themselves.
This hook is meant for user customization of message alerts. For
other uses, see `jabber-message-hooks'."
@ -56,7 +56,7 @@ it's not meant to be customized by the user.")
(defcustom jabber-alert-message-function
'jabber-message-default-message
"Function for constructing message alert messages.
"Function for constructing short message alert messages.
Arguments are FROM, BUFFER, and TEXT. This function should return a
string containing an appropriate text message, or nil if no message
@ -71,12 +71,12 @@ every time."
(defcustom jabber-alert-muc-hooks '(jabber-muc-echo jabber-muc-scroll)
"Hooks run when a new MUC message arrives.
Arguments are NICK, GROUP, BUFFER, TEXT and PROPOSED-ALERT. NICK
is the nickname of the sender. GROUP is the JID of the group.
BUFFER is the the buffer where the message can be read, and TEXT
is the text of the message. PROPOSED-ALERT is the string
returned by `jabber-alert-muc-function' for these arguments,
so that hooks do not have to call it themselves."
Arguments are NICK, GROUP, BUFFER, TEXT and TITLE. NICK is the
nickname of the sender. GROUP is the JID of the group. BUFFER
is the the buffer where the message can be read, and TEXT is the
text of the message. TITLE is the string returned by
`jabber-alert-muc-function' for these arguments, so that hooks do
not have to call it themselves."
:type 'hook
:options '(jabber-muc-beep
jabber-muc-wave
@ -94,7 +94,7 @@ it's not meant to be customized by the user.")
(defcustom jabber-alert-muc-function
'jabber-muc-default-message
"Function for constructing message alert messages.
"Function for constructing short message alert messages.
Arguments are NICK, GROUP, BUFFER, and TEXT. This function
should return a string containing an appropriate text message, or
@ -115,7 +115,7 @@ PROPOSED-ALERT. WHO is a symbol whose text is the JID of the contact,
and which has various interesting properties. OLDSTATUS is the old
presence or nil if disconnected. NEWSTATUS is the new presence, or
one of \"subscribe\", \"unsubscribe\", \"subscribed\" and
\"unsubscribed\". PROPOSED-ALERT is the string returned by
\"unsubscribed\". TITLE is the string returned by
`jabber-alert-presence-message-function' for these arguments."
:type 'hook
:options '(jabber-presence-beep
@ -133,7 +133,7 @@ it's not meant to be customized by the user.")
(defcustom jabber-alert-presence-message-function
'jabber-presence-default-message
"Function for constructing presence alert messages.
"Function for constructing title of presence alert messages.
Arguments are WHO, OLDSTATUS, NEWSTATUS and STATUSTEXT. See
`jabber-alert-presence-hooks' for documentation. This function
@ -249,30 +249,30 @@ Examples:
(pres (intern (format "jabber-presence-%s" sn)))
(info (intern (format "jabber-info-%s" sn))))
`(progn
(defun ,msg (from buffer text proposed-alert)
(defun ,msg (from buffer text title)
,docstring
(when proposed-alert
(funcall ,function proposed-alert)))
(when title
(funcall ,function text title)))
(pushnew (quote ,msg) (get 'jabber-alert-message-hooks 'custom-options))
(defun ,muc (nick group buffer text proposed-alert)
(defun ,muc (nick group buffer text title)
,docstring
(when proposed-alert
(funcall ,function proposed-alert)))
(when title
(funcall ,function text title)))
(pushnew (quote ,muc) (get 'jabber-alert-muc-hooks 'custom-options))
(defun ,pres (who oldstatus newstatus statustext proposed-alert)
(defun ,pres (who oldstatus newstatus statustext title)
,docstring
(when proposed-alert
(funcall ,function proposed-alert)))
(when title
(funcall ,function statustext title)))
(pushnew (quote ,pres) (get 'jabber-alert-presence-hooks 'custom-options))
(defun ,info (infotype buffer proposed-alert)
(defun ,info (infotype buffer text)
,docstring
(when proposed-alert
(funcall ,function proposed-alert)))
(when text
(funcall ,function text)))
(pushnew (quote ,info) (get 'jabber-alert-info-message-hooks 'custom-options))))))
;; Alert hooks
(define-jabber-alert echo "Show a message in the echo area"
(lambda (msg) (message "%s" msg)))
(lambda (text &optional title) (message "%s" (or title text))))
(define-jabber-alert beep "Beep on event"
(lambda (&rest ignore) (beep)))
@ -296,9 +296,9 @@ Examples:
:type 'boolean
:group 'jabber-alerts)
(defun jabber-message-wave (from buffer text proposed-alert)
(defun jabber-message-wave (from buffer text title)
"Play the wave file specified in `jabber-alert-message-wave'"
(when proposed-alert
(when title
(let* ((case-fold-search t)
(bare-jid (jabber-jid-user from))
(sound-file (or (dolist (entry jabber-alert-message-wave-alist)
@ -308,17 +308,17 @@ Examples:
(unless (equal sound-file "")
(funcall jabber-play-sound-file sound-file)))))
(defun jabber-message-display (from buffer text proposed-alert)
(defun jabber-message-display (from buffer text title)
"Display the buffer where a new message has arrived."
(when proposed-alert
(when title
(display-buffer buffer)))
(defun jabber-message-switch (from buffer text proposed-alert)
(defun jabber-message-switch (from buffer text title)
"Switch to the buffer where a new message has arrived."
(when proposed-alert
(when title
(switch-to-buffer buffer)))
(defun jabber-message-scroll (from buffer text proposed-alert)
(defun jabber-message-scroll (from buffer text title)
"Scroll all nonselected windows where the chat buffer is displayed."
;; jabber-chat-buffer-display will DTRT with point in the buffer.
;; But this change will not take effect in nonselected windows.
@ -350,22 +350,22 @@ Examples:
group)))
(format "Message in %s" (jabber-jid-displayname group)))))
(defun jabber-muc-wave (nick group buffer text proposed-alert)
(defun jabber-muc-wave (nick group buffer text title)
"Play the wave file specified in `jabber-alert-muc-wave'"
(when proposed-alert
(when title
(funcall jabber-play-sound-file jabber-alert-muc-wave)))
(defun jabber-muc-display (nick group buffer text proposed-alert)
(defun jabber-muc-display (nick group buffer text title)
"Display the buffer where a new message has arrived."
(when proposed-alert
(when title
(display-buffer buffer)))
(defun jabber-muc-switch (nick group buffer text proposed-alert)
(defun jabber-muc-switch (nick group buffer text title)
"Switch to the buffer where a new message has arrived."
(when proposed-alert
(when title
(switch-to-buffer buffer)))
(defun jabber-muc-scroll (nick group buffer text proposed-alert)
(defun jabber-muc-scroll (nick group buffer text title)
"Scroll buffer even if it is in an unselected window."
(jabber-message-scroll nil buffer nil nil))
@ -394,12 +394,8 @@ This function is not called directly, but is the default for
(concat " is now "
(or
(cdr (assoc newstatus jabber-presence-strings))
newstatus))))
(formattedtext
(if (> (length statustext) 0)
(concat " (" statustext ")")
"")))
(concat formattedname formattedstatus formattedtext)))))
newstatus)))))
(concat formattedname formattedstatus)))))
(defun jabber-presence-only-chat-open-message (who oldstatus newstatus statustext)
"This function returns the same as `jabber-presence-default-message' but only
@ -469,9 +465,9 @@ This function uses `jabber-info-message-alist' to find a message."
(let ((sn (symbol-name name)))
(let ((func (intern (format "%s-personal" sn))))
`(progn
(defun ,func (nick group buffer text proposed-alert)
(defun ,func (nick group buffer text title)
(if (jabber-muc-looks-like-personal-p text group)
(,name nick group buffer text proposed-alert)))
(,name nick group buffer text title)))
(pushnew (quote ,func) (get 'jabber-alert-muc-hooks 'custom-options)))))
)

View File

@ -25,12 +25,13 @@
:type 'string
:group 'jabber-alerts)
(defun jabber-awesome-message (msg)
(defun jabber-awesome-message (text &optional title)
"Show MSG in Awesome"
;; Possible errors include not finding the awesome binary.
(condition-case e
(let ((process-connection-type))
(shell-command-to-string (format "echo 'naughty.notify({text = \"%s\" %s})' | awesome-client -" msg jabber-awesome-args))
(shell-command-to-string (format "echo 'naughty.notify({text = \"%s\" %s})' | awesome-client -"
(or title text) jabber-awesome-args))
)
(error nil)))

View File

@ -26,7 +26,7 @@
;; Most people don't have Festival, so this will often fail
(require 'festival)
(define-jabber-alert festival "Voice messages through Festival"
'festival-say-string))
(lambda (text &optional title) (festival-say-string (or title text)))))
(error nil))
(provide 'jabber-festival)

View File

@ -60,7 +60,7 @@
"Return the next notification id."
(setq jabber-libnotify-id (+ jabber-libnotify-id 1)))
(defun jabber-libnotify-message (msg)
(defun jabber-libnotify-message (text &optional title)
"Show MSG using libnotify"
(cond
((eq jabber-libnotify-method 'shell)
@ -71,8 +71,10 @@
"-t" (format "%s" jabber-libnotify-timeout)
"-i" (or jabber-libnotify-icon "\"\"")
"-u" jabber-libnotify-urgency
(or jabber-libnotify-message-header " ") msg))
(error nil)))
(or title
(or jabber-libnotify-message-header " ")
text))
(error nil))))
((eq jabber-libnotify-method 'dbus)
(condition-case e
(dbus-call-method
@ -84,8 +86,9 @@
(jabber-libnotify-next-id)
jabber-libnotify-icon
':string (encode-coding-string
jabber-libnotify-message-header 'utf-8)
':string (encode-coding-string msg 'utf-8)
(or title jabber-libnotify-message-header)
'utf-8)
':string (encode-coding-string text 'utf-8)
'(:array)
'(:array :signature "{sv}")
':int32 jabber-libnotify-timeout)

View File

@ -95,7 +95,7 @@ Optional argument GROUP to look."
(modify-alist group (modify-alist nick time room-activity)
*jabber-muc-participant-last-speaking*)))))
(defun jabber-muc-track-message-time (nick group buffer text proposed-alert)
(defun jabber-muc-track-message-time (nick group buffer text &optional title)
"Tracks time of NICK's last speaking in GROUP."
(when nick
(let ((time (float-time)))

View File

@ -25,9 +25,9 @@
(progn
;; Most people don't have osd.el, so this will often fail
(require 'osd)
(define-jabber-alert osd "Display a message in osd" 'osd-show-string)
(define-personal-jabber-alert jabber-muc-osd)
)
(define-jabber-alert osd "Display a message in osd"
(lambda (text &optional title) (osd-show-string (or title text))))
(define-personal-jabber-alert jabber-muc-osd))
(error nil))
(provide 'jabber-osd)

View File

@ -20,12 +20,12 @@
(eval-when-compile (require 'jabber-alert))
(defun jabber-ratpoison-message (msg)
(defun jabber-ratpoison-message (text &optional title)
"Show MSG in Ratpoison"
;; Possible errors include not finding the ratpoison binary.
(condition-case e
(let ((process-connection-type))
(call-process "ratpoison" nil 0 nil "-c" (concat "echo " msg)))
(call-process "ratpoison" nil 0 nil "-c" (concat "echo " (or title text))))
(error nil)))
(define-jabber-alert ratpoison "Show a message through the Ratpoison window manager"

View File

@ -26,13 +26,13 @@ Sawfish window manager."
:type 'integer
:group 'jabber-alerts)
(defun jabber-sawfish-display-message (message)
(defun jabber-sawfish-display-message (text &optional title)
"Displays MESSAGE through the Sawfish window manager."
(let ((process-connection-type nil))
(start-process-shell-command
"jabber-sawfish" nil "echo"
(concat "'(progn (require (quote timers)) (display-message \""
message
(or title text)
"\")(make-timer (lambda () (display-message nil)) "
(number-to-string jabber-sawfish-display-time)
"))' | sawfish-client - &> /dev/null"))))

View File

@ -20,9 +20,9 @@
(eval-when-compile (require 'jabber-alert))
(defun jabber-screen-message (msg)
(defun jabber-screen-message (text &optional title)
"Show MSG in screen"
(call-process "screen" nil nil nil "-X" "echo" msg))
(call-process "screen" nil nil nil "-X" "echo" (or title text)))
(define-jabber-alert screen "Show a message through the Screen terminal manager"
'jabber-screen-message)

View File

@ -19,15 +19,20 @@
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(require 'jabber-chat)
(eval-when-compile (require 'cl))
(require 'jabber-alert)
(require 'cl)
(defvar jabber-log-lines-to-keep 1000
"Maximum number of lines in chat buffer")
(defun jabber-truncate-top ()
"Clean old history from a chat buffer.
`jabber-log-lines-to-keep' specifies the number of lines to
keep."
`jabber-log-lines-to-keep' specifies the number of lines to keep.
Note that this might interfer with
`jabber-chat-display-more-backlog': you ask for more history, you
get it, and then it just gets deleted."
(interactive)
(let ((inhibit-read-only t)
(delete-before
@ -61,9 +66,6 @@ Note that this might interfer with
get it, and then it just gets deleted."
(jabber-truncate-top))
(pushnew 'jabber-truncate-muc (get 'jabber-alert-muc-hooks 'custom-options))
(pushnew 'jabber-truncate-chat (get 'jabber-alert-message-hooks 'custom-options))
(provide 'jabber-truncate)
;; arch-tag: 3d1e3428-f598-11db-a314-000a95c2fcd0

View File

@ -35,13 +35,13 @@
(call-process "wmiir" nil nil nil "remove" "/rbar/jabber")
(error nil)))
(defun jabber-wmii-message (msg)
(defun jabber-wmii-message (text &optional title)
"Show MSG in wmii."
(when jabber-wmii-timer
(cancel-timer jabber-wmii-timer))
(let ((tmp (make-temp-file temporary-file-directory)))
(with-temp-file tmp
(insert jabber-wmii-color " " msg))
(insert jabber-wmii-color " " (or title text)))
;; Possible errors include not finding the wmiir binary, and
;; too many pipes open because of message flood.
(condition-case e

View File

@ -28,12 +28,12 @@ Set this to nil to have no timeout."
(const :tag "No timeout" nil))
:group 'jabber-alerts)
(defun jabber-xmessage-display-message (message)
(defun jabber-xmessage-display-message (text &optional title)
"Displays MESSAGE using the xmessage program."
(let* ((process-connection-type nil)
(timeout-args (when jabber-xmessage-timeout
(list "-timeout" (number-to-string jabber-xmessage-timeout))))
(args (append timeout-args (list message))))
(args (append timeout-args (list (or title text)))))
(apply 'start-process "xmessage" nil "xmessage" args)))
(define-jabber-alert xmessage "Display a message using the xmessage program."