25904
|
1 ;; @(#) ada-support.el --- Override some standard Emacs functions
|
|
2
|
|
3 ;; Copyright (C) 1994-1999 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: Emmanuel Briot <briot@gnat.com>
|
|
6 ;; Maintainer: Emmanuel Briot <briot@gnat.com>
|
|
7 ;; Ada Core Technologies's version: $Revision: 1.3 $
|
|
8 ;; Keywords: languages ada xref
|
|
9
|
|
10 ;; This file is not part of GNU Emacs.
|
|
11
|
|
12 ;; This program is free software; you can redistribute it and/or modify
|
|
13 ;; it under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; This program is distributed in the hope that it will be useful,
|
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 ;; GNU General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
25
|
|
26 ;;; Commentary:
|
|
27 ;;; This file overrides some functions that are defined in Emacs/XEmacs,
|
|
28 ;;; since some of them have known bugs in old versions.
|
|
29 ;;; This is intended as a support package for older Emacs versions, and
|
|
30 ;;; should not be needed for the latest version of Emacs (currently 20.4)
|
|
31 ;;; where these bugs have been fixed
|
|
32
|
|
33
|
|
34
|
|
35 ;;; Some functions have been renamed from one version to the other
|
|
36 ;;; `easy-menu-create-keymaps' has been renamed `easy-menu-create-menu'
|
|
37 ;;; from Emacs >= 20.3
|
|
38 ;;; Do nothing for XEmacs
|
|
39
|
|
40 (unless (or (ada-check-emacs-version 20 3)
|
|
41 (not (ada-check-emacs-version 1 1 t)))
|
|
42
|
|
43 (if (and (not (fboundp 'easy-menu-create-menu))
|
|
44 (fboundp 'easy-menu-create-keymaps))
|
|
45 (defun easy-menu-create-menu (menu-name menu-items)
|
|
46 "Alias redefined in ada-support.el"
|
|
47 (easy-menu-create-keymaps menu-name menu-items))))
|
|
48
|
|
49
|
|
50
|
|
51 ;;; A fix for Emacs <= 20.3
|
|
52 ;;; Imenu does not support name overriding in submenus (the first such name
|
|
53 ;;; is always selected, whichever the user actually chose).
|
|
54 ;;; This has been fixed in Emacs 20.4
|
|
55 ;;; Fix was: use assq instead of assoc in the submenus
|
|
56
|
|
57 (unless (ada-check-emacs-version 20 4)
|
|
58
|
|
59 (defun imenu--mouse-menu (index-alist event &optional title)
|
|
60 "Overrides the default imenu--mouse-menu from imenu.el, that has a bug.
|
|
61 The default one does not know anything about overriding in submenus, since
|
|
62 it is using assoc instead of assq"
|
|
63 (set 'index-alist (imenu--split-submenus index-alist))
|
|
64 (let* ((menu (imenu--split-menu index-alist
|
|
65 (or title (buffer-name))))
|
|
66 position)
|
|
67 (set 'menu (imenu--create-keymap-1 (car menu)
|
|
68 (if (< 1 (length (cdr menu)))
|
|
69 (cdr menu)
|
|
70 (cdr (car (cdr menu))))))
|
|
71 (set 'position (x-popup-menu event menu))
|
|
72 (cond ((eq position nil)
|
|
73 position)
|
|
74 ;; If one call to x-popup-menu handled the nested menus,
|
|
75 ;; find the result by looking down the menus here.
|
|
76 ((and (listp position)
|
|
77 (numberp (car position))
|
|
78 (stringp (nth (1- (length position)) position)))
|
|
79 (let ((final menu))
|
|
80 (while position
|
|
81 (set 'final (assq (car position) final))
|
|
82 (set 'position (cdr position)))
|
|
83 (or (string= (car final) (car imenu--rescan-item))
|
|
84 (nthcdr 3 final))))
|
|
85 ;; If x-popup-menu went just one level and found a leaf item,
|
|
86 ;; return the INDEX-ALIST element for that.
|
|
87 ((and (consp position)
|
|
88 (stringp (car position))
|
|
89 (null (cdr position)))
|
|
90 (or (string= (car position) (car imenu--rescan-item))
|
|
91 (assq (car position) index-alist)))
|
|
92 ;; If x-popup-menu went just one level
|
|
93 ;; and found a non-leaf item (a submenu),
|
|
94 ;; recurse to handle the rest.
|
|
95 ((listp position)
|
|
96 (imenu--mouse-menu position event
|
|
97 (if title
|
|
98 (concat title imenu-level-separator
|
|
99 (car (rassq position index-alist)))
|
|
100 (car (rassq position index-alist))))))))
|
|
101 )
|
|
102
|
|
103 (provide 'ada-support) |