all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* ERC: Gets buffer/channel name in erc-text-matched-hook ?
@ 2015-05-21 16:17 Mathieu Poussin
  2015-05-22  9:34 ` Mathieu Poussin
  0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Poussin @ 2015-05-21 16:17 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I wrote a simple system that send me a notification using pushover and
shows the revelant line in emacs.
Currently I get the nick and message, I would like to include the buffer
name / channel name in the notification message, but I don't know how can I
do this.

Here is my code :

(defcustom pushover-token nil
  "pushover application token")

(defcustom pushover-user-key nil
  "pushover user-key")

(defun pushover-notify (title msg)
  (let ((url-request-method "POST")
        (url-request-data (concat "token=" pushover-token
                                  "&user=" pushover-user-key
                                  "&title=" title
                                  "&message=" msg)))
    (url-retrieve "https://api.pushover.net/1/messages.json"
'pushover-kill-url-buffer)))

(defun pushover-kill-url-buffer (status)
  "Kill the buffer returned by `url-retrieve'."
    (kill-buffer (current-buffer)))

;; Notify my when someone mentions my nick.
(defun erc-global-notify (matched-type nick msg)
  (interactive)
  (when (eq matched-type 'current-nick)
    (pushover-notify "ERC Notification" (concat "<" (car (split-string nick
"!")) "> " message))
    (display-message-or-buffer (concat "<" (car (split-string nick "!")) ">
" message) "ERC Notifications")
   ))
(add-hook 'erc-text-matched-hook 'erc-global-notify)


How can I do this ?
Thank you.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ERC: Gets buffer/channel name in erc-text-matched-hook ?
  2015-05-21 16:17 ERC: Gets buffer/channel name in erc-text-matched-hook ? Mathieu Poussin
@ 2015-05-22  9:34 ` Mathieu Poussin
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Poussin @ 2015-05-22  9:34 UTC (permalink / raw)
  To: help-gnu-emacs

Looks like simply addons (buffer-name) in the concat is working :)

On 21 May 2015 at 18:17, Mathieu Poussin <mathieu.poussin@netyxia.net>
wrote:

> Hello,
>
> I wrote a simple system that send me a notification using pushover and
> shows the revelant line in emacs.
> Currently I get the nick and message, I would like to include the buffer
> name / channel name in the notification message, but I don't know how can I
> do this.
>
> Here is my code :
>
> (defcustom pushover-token nil
>   "pushover application token")
>
> (defcustom pushover-user-key nil
>   "pushover user-key")
>
> (defun pushover-notify (title msg)
>   (let ((url-request-method "POST")
>         (url-request-data (concat "token=" pushover-token
>                                   "&user=" pushover-user-key
>                                   "&title=" title
>                                   "&message=" msg)))
>     (url-retrieve "https://api.pushover.net/1/messages.json"
> 'pushover-kill-url-buffer)))
>
> (defun pushover-kill-url-buffer (status)
>   "Kill the buffer returned by `url-retrieve'."
>     (kill-buffer (current-buffer)))
>
> ;; Notify my when someone mentions my nick.
> (defun erc-global-notify (matched-type nick msg)
>   (interactive)
>   (when (eq matched-type 'current-nick)
>     (pushover-notify "ERC Notification" (concat "<" (car (split-string
> nick "!")) "> " message))
>     (display-message-or-buffer (concat "<" (car (split-string nick "!"))
> "> " message) "ERC Notifications")
>    ))
> (add-hook 'erc-text-matched-hook 'erc-global-notify)
>
>
> How can I do this ?
> Thank you.
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-22  9:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-21 16:17 ERC: Gets buffer/channel name in erc-text-matched-hook ? Mathieu Poussin
2015-05-22  9:34 ` Mathieu Poussin

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.