0addfbdb0ef4e9e75f32308360b9f34f5ef0587a
[riece] / lisp / riece-emacs.el
1 ;;; riece-emacs.el --- FSF Emacs specific functions
2 ;; Copyright (C) 1999 Daiki Ueno
3
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Created: 1999-08-21
6 ;; Keywords: emulation
7
8 ;; This file is part of Riece.
9
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (defalias 'riece-set-case-syntax-pair
28   'set-case-syntax-pair)
29
30 ;;; stolen (and renamed) from gnus-ems.el.
31
32 ;;; In GNU Emacs, user can intercept whole mouse tracking events by
33 ;;; assigning [mouse-X].  In XEmacs, however, which causes different
34 ;;; effect, that is, the command assigned to [mouse-X] only catches
35 ;;; button-release events.
36 (defvar riece-mouse-2 [mouse-2])
37
38 ;;; popup-menu compatibility stuff, stolen (and renamed) from
39 ;;; semi-def.el.
40 (defmacro riece-popup-menu-bogus-filter-constructor (menu)
41   ;; #### Kludge for FSF Emacs-style menu.
42   (let ((bogus-menu (make-symbol "bogus-menu")))
43     `(let (,bogus-menu selection function)
44        (easy-menu-define ,bogus-menu nil nil ,menu)
45        (setq selection (x-popup-menu t ,bogus-menu))
46        (when selection
47          (setq function (lookup-key ,bogus-menu (apply #'vector selection)))
48          ;; If a callback entry has no name, easy-menu wraps its value.
49          ;; See `easy-menu-make-symbol'.
50          (if (eq t (compare-strings "menu-function-" 0 nil
51                                     (symbol-name function) 0 14))
52              (car (last (symbol-function function)))
53            function)))))
54
55 (defun riece-popup-menu-popup (menu event)
56   (let ((function (riece-popup-menu-bogus-filter-constructor menu))
57         (pos (event-start event)))
58     (when (symbolp function)
59       (select-window (posn-window pos))
60       (goto-char (posn-point pos))
61       (funcall function))))
62
63 (provide 'riece-emacs)
64
65 ;;; riece-emacs.el ends here