/usr/share/emacs/site-lisp/riece/riece-signal.el is in riece 9.0.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | ;;; riece-signal.el --- "signal-slot" abstraction for routing display events -*- lexical-binding: t -*-
;; Copyright (C) 1998-2003 Daiki Ueno
;; Author: Daiki Ueno <ueno@unixuser.org>
;; Created: 1998-09-28
;; Keywords: IRC, riece
;; This file is part of Riece.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; This module implements Qt like "signal-slot" abstraction for
;;; routing display events.
;;; Code:
(require 'riece-options)
(require 'riece-debug)
(defvar riece-signal-slot-obarray
(make-vector 31 0))
(defun riece-make-slot (function &optional filter handback)
"Make an instance of slot object.
Arguments are corresponding to callback function, filter function, and
a handback object, respectively.
This function is for internal use only."
(vector function filter handback))
(defun riece-slot-function (slot)
"Return the callback function of SLOT.
This function is for internal use only."
(aref slot 0))
(defun riece-slot-filter (slot)
"Return the filter function of SLOT.
This function is for internal use only."
(aref slot 1))
(defun riece-slot-handback (slot)
"Return the handback object of SLOT.
This function is for internal use only."
(aref slot 2))
(defun riece-make-signal (name args)
"Make an instance of signal object.
The 1st arguments is the name of the signal and the rest of arguments
are the data of the signal.
This function is for internal use only."
(vector name args))
(defun riece-signal-name (signal)
"Return the name of SIGNAL."
(aref signal 0))
(defun riece-signal-args (signal)
"Return the data of SIGNAL."
(aref signal 1))
(defun riece-connect-signal (signal-name function &optional filter handback)
"Add FUNCTION as a listener of a signal identified by SIGNAL-NAME."
(let ((symbol (intern (symbol-name signal-name) riece-signal-slot-obarray)))
(set symbol (cons (riece-make-slot function filter handback)
(if (boundp symbol)
(symbol-value symbol))))))
(defun riece-disconnect-signal (signal-name function)
"Remove FUNCTION from the listener of the signal identified by SIGNAL-NAME."
(let* ((symbol (intern-soft (symbol-name signal-name)
riece-signal-slot-obarray))
(slots (symbol-value symbol)))
(while slots
(if (eq (riece-slot-function (car slots))
function)
(set symbol (delq (car slots) (symbol-value symbol))))
(setq slots (cdr slots)))))
(defun riece-clear-signal-slots ()
"Remove all functions from listeners list."
(fillarray riece-signal-slot-obarray 0))
(defun riece-emit-signal (signal-name &rest args)
"Emit SIGNAL."
(let ((symbol (intern-soft (symbol-name signal-name)
riece-signal-slot-obarray))
signal
slots)
(when symbol
(setq signal (riece-make-signal signal-name args)
slots (symbol-value symbol))
(while slots
(if (or (null (riece-slot-filter (car slots)))
(riece-funcall-ignore-errors (format "signal filter for \"%S\""
signal-name)
(riece-slot-filter (car slots))
signal))
(riece-funcall-ignore-errors (format "slot function for \"%S\""
signal-name)
(riece-slot-function (car slots))
signal
(riece-slot-handback (car slots))))
(setq slots (cdr slots))))))
(provide 'riece-signal)
;;; riece-signal.el ends here
|