Mercurial > emacs
annotate lisp/cedet/mode-local.el @ 110095:d87b30cb5a6f
gnus.texi (HTML): Document gnus-max-image-proportion.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Wed, 01 Sep 2010 23:57:53 +0000 |
parents | 1d1d5d9bd884 |
children | 516f3d80dac6 |
rev | line source |
---|---|
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1 ;;; mode-local.el --- Support for mode local facilities |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 ;; |
106815 | 3 ;; Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 ;; Author: David Ponce <david@dponce.com> |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 ;; Maintainer: David Ponce <david@dponce.com> |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; Created: 27 Apr 2004 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 ;; Keywords: syntax |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 ;; (at your option) any later version. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;;; Commentary: |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; Each major mode will want to support a specific set of behaviors. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 ;; Usually generic behaviors that need just a little bit of local |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;; specifics. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; This library permits the setting of override functions for tasks of |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; that nature, and also provides reasonable defaults. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 ;; There are buffer local variables, and frame local variables. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 ;; This library gives the illusion of mode specific variables. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ;; You should use a mode-local variable or override to allow extension |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 ;; only if you expect a mode author to provide that extension. If a |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 ;; user might wish to customize a give variable or function then |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 ;; the existing customization mechanism should be used. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 ;; To Do: |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 ;; Allow customization of a variable for a specific mode? |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 ;; Add macro for defining the '-default' functionality. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 ;;; Code: |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 (eval-when-compile (require 'cl)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 ;;; Misc utilities |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 (defun mode-local-map-file-buffers (function &optional predicate buffers) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 "Run FUNCTION on every file buffer found. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 FUNCTION does not have arguments; when it is entered `current-buffer' |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 is the currently selected file buffer. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 If optional argument PREDICATE is non nil, only select file buffers |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 for which the function PREDICATE return non-nil. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 If optional argument BUFFERS is non-nil, it is a list of buffers to |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 walk through. It defaults to `buffer-list'." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 (dolist (b (or buffers (buffer-list))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 (and (buffer-live-p b) (buffer-file-name b) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 (with-current-buffer b |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 (when (or (not predicate) (funcall predicate)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 (funcall function)))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 (defsubst get-mode-local-parent (mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 "Return the mode parent of the major mode MODE. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 Return nil if MODE has no parent." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 (or (get mode 'mode-local-parent) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 (get mode 'derived-mode-parent))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 |
105833 | 73 ;; FIXME doc (and function name) seems wrong. |
74 ;; Return a list of MODE and all its parent modes, if any. | |
75 ;; Lists parent modes first. | |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 (defun mode-local-equivalent-mode-p (mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 "Is the major-mode in the current buffer equivalent to a mode in MODES." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 (let ((modes nil)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 (while mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 (setq modes (cons mode modes) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 mode (get-mode-local-parent mode))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 modes)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 (defun mode-local-map-mode-buffers (function modes) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 "Run FUNCTION on every file buffer with major mode in MODES. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 MODES can be a symbol or a list of symbols. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 FUNCTION does not have arguments." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 (or (listp modes) (setq modes (list modes))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 (mode-local-map-file-buffers |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 function #'(lambda () |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 (let ((mm (mode-local-equivalent-mode-p major-mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 (ans nil)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 (while (and (not ans) mm) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 (setq ans (memq (car mm) modes) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 mm (cdr mm)) ) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 ans)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 ;;; Hook machinery |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 (defvar mode-local-init-hook nil |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 "Hook run after a new file buffer is created. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 The current buffer is the newly created file buffer.") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 (defvar mode-local-changed-mode-buffers nil |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 "List of buffers whose `major-mode' has changed recently.") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 (defvar mode-local--init-mode nil) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 (defsubst mode-local-initialized-p () |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 "Return non-nil if mode local is initialized in current buffer. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 That is, if the current `major-mode' is equal to the major mode for |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 which mode local bindings have been activated." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 (eq mode-local--init-mode major-mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 (defun mode-local-post-major-mode-change () |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 "Initialize mode-local facilities. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 This is run from `find-file-hook', and from `post-command-hook' |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 after changing the major mode." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 (remove-hook 'post-command-hook 'mode-local-post-major-mode-change nil) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 (let ((buffers mode-local-changed-mode-buffers)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 (setq mode-local-changed-mode-buffers nil) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 (mode-local-map-file-buffers |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 (lambda () |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 ;; Make sure variables are set up for this mode. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 (activate-mode-local-bindings) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 (run-hooks 'mode-local-init-hook)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 (lambda () |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 (not (mode-local-initialized-p))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 buffers))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 (defun mode-local-on-major-mode-change () |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 "Function called in `change-major-mode-hook'." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 (add-to-list 'mode-local-changed-mode-buffers (current-buffer)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 (add-hook 'post-command-hook 'mode-local-post-major-mode-change t nil)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 ;;; Mode lineage |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 (defsubst set-mode-local-parent (mode parent) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 "Set parent of major mode MODE to PARENT mode. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 To work properly, this function should be called after PARENT mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 local variables have been defined." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 (put mode 'mode-local-parent parent) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 ;; Refresh mode bindings to get mode local variables inherited from |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 ;; PARENT. To work properly, the following should be called after |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 ;; PARENT mode local variables have been defined. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (mode-local-map-mode-buffers #'activate-mode-local-bindings mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 (defmacro define-child-mode (mode parent &optional docstring) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 "Make major mode MODE inherits behavior from PARENT mode. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 DOCSTRING is optional and not used. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 To work properly, this should be put after PARENT mode local variables |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 definition." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 `(set-mode-local-parent ',mode ',parent)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 (defun mode-local-use-bindings-p (this-mode desired-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 "Return non-nil if THIS-MODE can use bindings of DESIRED-MODE." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 (let ((ans nil)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 (while (and (not ans) this-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 (setq ans (eq this-mode desired-mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 (setq this-mode (get-mode-local-parent this-mode))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 ans)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 ;;; Core bindings API |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 (defvar mode-local-symbol-table nil |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 "Buffer local mode bindings. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 These symbols provide a hook for a `major-mode' to specify specific |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 behaviors. Use the function `mode-local-bind' to define new bindings.") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 (make-variable-buffer-local 'mode-local-symbol-table) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 (defvar mode-local-active-mode nil |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 "Major mode in which bindings are active.") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 (defsubst new-mode-local-bindings () |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 "Return a new empty mode bindings symbol table." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 (make-vector 13 0)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 (defun mode-local-bind (bindings &optional plist mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 "Define BINDINGS in the specified environment. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 BINDINGS is a list of (VARIABLE . VALUE). |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 Optional argument PLIST is a property list each VARIABLE symbol will |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 be set to. The following properties have special meaning: |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 - `constant-flag' if non-nil, prevent to rebind variables. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 - `mode-variable-flag' if non-nil, define mode variables. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 - `override-flag' if non-nil, define override functions. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 The `override-flag' and `mode-variable-flag' properties are mutually |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 exclusive. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 If optional argument MODE is non-nil, it must be a major mode symbol. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 BINDINGS will be defined globally for this major mode. If MODE is |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 nil, BINDINGS will be defined locally in the current buffer, in |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 variable `mode-local-symbol-table'. The later should be done in MODE |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 hook." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 ;; Check plist consistency |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 (and (plist-get plist 'mode-variable-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 (plist-get plist 'override-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 (error "Bindings can't be both overrides and mode variables")) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 (let (table variable varname value binding) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 (if mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 (progn |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 ;; Install in given MODE symbol table. Create a new one if |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 ;; needed. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 (setq table (or (get mode 'mode-local-symbol-table) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 (new-mode-local-bindings))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 (put mode 'mode-local-symbol-table table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 ;; Fail if trying to bind mode variables in local context! |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 (if (plist-get plist 'mode-variable-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 (error "Mode required to bind mode variables")) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 ;; Install in buffer local symbol table. Create a new one if |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 ;; needed. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 (setq table (or mode-local-symbol-table |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 (setq mode-local-symbol-table |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 (new-mode-local-bindings))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 (while bindings |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 (setq binding (car bindings) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 bindings (cdr bindings) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 varname (symbol-name (car binding)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 value (cdr binding)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 (if (setq variable (intern-soft varname table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 ;; Binding already exists |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 ;; Check rebind consistency |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 (cond |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 ((equal (symbol-value variable) value) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 ;; Just ignore rebind with the same value. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 ) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 ((get variable 'constant-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 (error "Can't change the value of constant `%s'" |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 variable)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 ((and (get variable 'mode-variable-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 (plist-get plist 'override-flag)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 (error "Can't rebind override `%s' as a mode variable" |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 variable)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 ((and (get variable 'override-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 (plist-get plist 'mode-variable-flag)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 (error "Can't rebind mode variable `%s' as an override" |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 variable)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 (t |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 ;; Merge plist and assign new value |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 (setplist variable (append plist (symbol-plist variable))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 (set variable value))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 ;; New binding |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 (setq variable (intern varname table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 ;; Set new plist and assign initial value |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 (setplist variable plist) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 (set variable value))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 ;; Return the symbol table used |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 (defsubst mode-local-symbol (symbol &optional mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 "Return the mode local symbol bound with SYMBOL's name. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 Return nil if the mode local symbol doesn't exist. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 If optional argument MODE is nil, lookup first into locally bound |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 symbols, then in those bound in current `major-mode' and its parents. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 If MODE is non-nil, lookup into symbols bound in that major mode and |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 its parents." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 (let ((name (symbol-name symbol)) bind) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 (or mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (setq mode mode-local-active-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 (setq mode major-mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 bind (and mode-local-symbol-table |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 (intern-soft name mode-local-symbol-table)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 (while (and mode (not bind)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 (or (and (get mode 'mode-local-symbol-table) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 (setq bind (intern-soft |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 name (get mode 'mode-local-symbol-table)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 (setq mode (get-mode-local-parent mode)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 bind)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 (defsubst mode-local-symbol-value (symbol &optional mode property) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 "Return the value of the mode local symbol bound with SYMBOL's name. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 If optional argument MODE is non-nil, restrict lookup to that mode and |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 its parents (see the function `mode-local-symbol' for more details). |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 If optional argument PROPERTY is non-nil the mode local symbol must |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 have that property set. Return nil if the symbol doesn't exist, or |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 doesn't have PROPERTY set." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 (and (setq symbol (mode-local-symbol symbol mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 (or (not property) (get symbol property)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 (symbol-value symbol))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 ;;; Mode local variables |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 (defun activate-mode-local-bindings (&optional mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 "Activate variables defined locally in MODE and its parents. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 That is, copy mode local bindings into corresponding buffer local |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 variables. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 If MODE is not specified it defaults to current `major-mode'. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 Return the alist of buffer-local variables that have been changed. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 Elements are (SYMBOL . PREVIOUS-VALUE), describing one variable." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 ;; Hack - |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 ;; do not do this if we are inside set-auto-mode as we may be in |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 ;; an initialization race condition. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 (if (or (and (featurep 'emacs) (boundp 'keep-mode-if-same)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 (and (featurep 'xemacs) (boundp 'just-from-file-name))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 ;; We are inside set-auto-mode, as this is an argument that is |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 ;; vaguely unique. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 ;; This will make sure that when everything is over, this will get |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 ;; called and we won't be under set-auto-mode anymore. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 (mode-local-on-major-mode-change) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 ;; Do the normal thing. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 (let (modes table old-locals) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 (unless mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 (set (make-local-variable 'mode-local--init-mode) major-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 (setq mode major-mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 ;; Get MODE's parents & MODE in the right order. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (while mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 (setq modes (cons mode modes) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 mode (get-mode-local-parent mode))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 ;; Activate mode bindings following parent modes order. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 (dolist (mode modes) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 (when (setq table (get mode 'mode-local-symbol-table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 (mapatoms |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 #'(lambda (var) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 (when (get var 'mode-variable-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 (let ((v (intern (symbol-name var)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 ;; Save the current buffer-local value of the |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 ;; mode-local variable. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 (and (local-variable-p v (current-buffer)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 (push (cons v (symbol-value v)) old-locals)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 (set (make-local-variable v) (symbol-value var))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 table))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 old-locals))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 (defun deactivate-mode-local-bindings (&optional mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 "Deactivate variables defined locally in MODE and its parents. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 That is, kill buffer local variables set from the corresponding mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 local bindings. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 If MODE is not specified it defaults to current `major-mode'." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 (unless mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 (kill-local-variable 'mode-local--init-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 (setq mode major-mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 (let (table) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 (while mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 (when (setq table (get mode 'mode-local-symbol-table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 (mapatoms |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 #'(lambda (var) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 (when (get var 'mode-variable-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 (kill-local-variable (intern (symbol-name var))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 (setq mode (get-mode-local-parent mode))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 (defmacro with-mode-local-symbol (mode &rest body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 "With the local bindings of MODE symbol, evaluate BODY. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 The current mode bindings are saved, BODY is evaluated, and the saved |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 bindings are restored, even in case of an abnormal exit. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 Value is what BODY returns. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 This is like `with-mode-local', except that MODE's value is used. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 To use the symbol MODE (quoted), use `with-mode-local'." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (let ((old-mode (make-symbol "mode")) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 (old-locals (make-symbol "old-locals")) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 (new-mode (make-symbol "new-mode")) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 (local (make-symbol "local"))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 `(let ((,old-mode mode-local-active-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 (,old-locals nil) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 (,new-mode ,mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 ) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 (unwind-protect |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (progn |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 (deactivate-mode-local-bindings ,old-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 (setq mode-local-active-mode ,new-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 ;; Save the previous value of buffer-local variables |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 ;; changed by `activate-mode-local-bindings'. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 (setq ,old-locals (activate-mode-local-bindings ,new-mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 ,@body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 (deactivate-mode-local-bindings ,new-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 ;; Restore the previous value of buffer-local variables. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 (dolist (,local ,old-locals) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 (set (car ,local) (cdr ,local))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 ;; Restore the mode local variables. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 (setq mode-local-active-mode ,old-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 (activate-mode-local-bindings ,old-mode))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 (put 'with-mode-local-symbol 'lisp-indent-function 1) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 (defmacro with-mode-local (mode &rest body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 "With the local bindings of MODE, evaluate BODY. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 The current mode bindings are saved, BODY is evaluated, and the saved |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 bindings are restored, even in case of an abnormal exit. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 Value is what BODY returns. |
105833 | 383 This is like `with-mode-local-symbol', except that MODE is quoted |
105834
a120770e3f00
(with-mode-local): Another doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105833
diff
changeset
|
384 and is not evaluated." |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 `(with-mode-local-symbol ',mode ,@body)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 (put 'with-mode-local 'lisp-indent-function 1) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 (defsubst mode-local-value (mode sym) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 "Return the value of the MODE local variable SYM." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (or mode (error "Missing major mode symbol")) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 (mode-local-symbol-value sym mode 'mode-variable-flag)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 (defmacro setq-mode-local (mode &rest args) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 "Assign new values to variables local in MODE. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 MODE must be a major mode symbol. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 ARGS is a list (SYM VAL SYM VAL ...). |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 The symbols SYM are variables; they are literal (not evaluated). |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 The values VAL are expressions; they are evaluated. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 Set each SYM to the value of its VAL, locally in buffers already in |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 MODE, or in buffers switched to that mode. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 Return the value of the last VAL." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 (when args |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 (let (i ll bl sl tmp sym val) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 (setq i 0) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 (while args |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 (setq tmp (make-symbol (format "tmp%d" i)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 i (1+ i) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 sym (car args) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 val (cadr args) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 ll (cons (list tmp val) ll) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 bl (cons `(cons ',sym ,tmp) bl) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 sl (cons `(set (make-local-variable ',sym) ,tmp) sl) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 args (cddr args))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 `(let* ,(nreverse ll) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 ;; Save mode bindings |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 (mode-local-bind (list ,@bl) '(mode-variable-flag t) ',mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 ;; Assign to local variables in all existing buffers in MODE |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 (mode-local-map-mode-buffers #'(lambda () ,@sl) ',mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
420 ;; Return the last value |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 ,tmp) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 ))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
424 (defmacro defvar-mode-local (mode sym val &optional docstring) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 "Define MODE local variable SYM with value VAL. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 DOCSTRING is optional." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 `(progn |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 (setq-mode-local ,mode ,sym ,val) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
429 (put (mode-local-symbol ',sym ',mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
430 'variable-documentation ,docstring) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 ',sym)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 (put 'defvar-mode-local 'lisp-indent-function 'defun) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 (defmacro defconst-mode-local (mode sym val &optional docstring) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 "Define MODE local constant SYM with value VAL. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 DOCSTRING is optional." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 (let ((tmp (make-symbol "tmp"))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 `(let (,tmp) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
439 (setq-mode-local ,mode ,sym ,val) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
440 (setq ,tmp (mode-local-symbol ',sym ',mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
441 (put ,tmp 'constant-flag t) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
442 (put ,tmp 'variable-documentation ,docstring) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
443 ',sym))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
444 (put 'defconst-mode-local 'lisp-indent-function 'defun) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
445 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
446 ;;; Function overloading |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
447 ;; |
105789
6df5ff499103
* cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
448 (defun make-obsolete-overload (old new when) |
6df5ff499103
* cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
449 "Mark OLD overload as obsoleted by NEW overload. |
6df5ff499103
* cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
450 WHEN is a string describing the first release where it was made obsolete." |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
451 (put old 'overload-obsoleted-by new) |
105789
6df5ff499103
* cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
452 (put old 'overload-obsoleted-since when) |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
453 (put old 'mode-local-overload t) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
454 (put new 'overload-obsolete old)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
455 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
456 (defsubst overload-obsoleted-by (overload) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
457 "Get the overload symbol obsoleted by OVERLOAD. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
458 Return the obsolete symbol or nil if not found." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
459 (get overload 'overload-obsolete)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
460 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
461 (defsubst overload-that-obsolete (overload) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
462 "Return the overload symbol that obsoletes OVERLOAD. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
463 Return the symbol found or nil if OVERLOAD is not obsolete." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
464 (get overload 'overload-obsoleted-by)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
465 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
466 (defsubst fetch-overload (overload) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
467 "Return the current OVERLOAD function, or nil if not found. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
468 First, lookup for OVERLOAD into locally bound mode local symbols, then |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 in those bound in current `major-mode' and its parents." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 (or (mode-local-symbol-value overload nil 'override-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 ;; If an obsolete overload symbol exists, try it. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
472 (and (overload-obsoleted-by overload) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 (mode-local-symbol-value |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
474 (overload-obsoleted-by overload) nil 'override-flag)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
475 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 (defun mode-local--override (name args body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 "Return the form that handles overloading of function NAME. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
478 ARGS are the arguments to the function. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
479 BODY is code that would be run when there is no override defined. The |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
480 default is to call the function `NAME-default' with the appropriate |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
481 arguments. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
482 See also the function `define-overload'." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
483 (let* ((default (intern (format "%s-default" name))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
484 (overargs (delq '&rest (delq '&optional (copy-sequence args)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
485 (override (make-symbol "override"))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 `(let ((,override (fetch-overload ',name))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
487 (if ,override |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
488 (funcall ,override ,@overargs) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
489 ,@(or body `((,default ,@overargs))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
490 )) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
491 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
492 (defun mode-local--expand-overrides (name args body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
493 "Expand override forms that overload function NAME. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
494 ARGS are the arguments to the function NAME. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
495 BODY is code where override forms are searched for expansion. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
496 Return result of expansion, or BODY if no expansion occurred. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
497 See also the function `define-overload'." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
498 (let ((forms body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
499 (ditto t) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 form xbody) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
501 (while forms |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 (setq form (car forms)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
503 (cond |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
504 ((atom form)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
505 ((eq (car form) :override) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
506 (setq form (mode-local--override name args (cdr form)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
507 ((eq (car form) :override-with-args) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
508 (setq form (mode-local--override name (cadr form) (cddr form)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
509 ((setq form (mode-local--expand-overrides name args form)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
510 (setq ditto (and ditto (eq (car forms) form)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
511 xbody (cons form xbody) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 forms (cdr forms))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
513 (if ditto body (nreverse xbody)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
514 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
515 (defun mode-local--overload-body (name args body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
516 "Return the code that implements overloading of function NAME. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
517 ARGS are the arguments to the function NAME. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
518 BODY specifies the overload code. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
519 See also the function `define-overload'." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
520 (let ((result (mode-local--expand-overrides name args body))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
521 (if (eq body result) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
522 (list (mode-local--override name args body)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 result))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
525 (defmacro define-overloadable-function (name args docstring &rest body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
526 "Define a new function, as with `defun' which can be overloaded. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
527 NAME is the name of the function to create. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
528 ARGS are the arguments to the function. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
529 DOCSTRING is a documentation string to describe the function. The |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
530 docstring will automatically had details about its overload symbol |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
531 appended to the end. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
532 BODY is code that would be run when there is no override defined. The |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
533 default is to call the function `NAME-default' with the appropriate |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
534 arguments. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
535 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
536 BODY can also include an override form that specifies which part of |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
537 BODY is specifically overridden. This permits to specify common code |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
538 run for both default and overridden implementations. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
539 An override form is one of: |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
540 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
541 1. (:override [OVERBODY]) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
542 2. (:override-with-args OVERARGS [OVERBODY]) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
543 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
544 OVERBODY is the code that would be run when there is no override |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
545 defined. The default is to call the function `NAME-default' with the |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
546 appropriate arguments deduced from ARGS. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
547 OVERARGS is a list of arguments passed to the override and |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 `NAME-default' function, in place of those deduced from ARGS." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
549 `(eval-and-compile |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
550 (defun ,name ,args |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
551 ,docstring |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 ,@(mode-local--overload-body name args body)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
553 (put ',name 'mode-local-overload t))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 (put :override-with-args 'lisp-indent-function 1) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
555 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
556 (defalias 'define-overload 'define-overloadable-function) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
557 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
558 (defsubst function-overload-p (symbol) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
559 "Return non-nil if SYMBOL is a function which can be overloaded." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 (and symbol (symbolp symbol) (get symbol 'mode-local-overload))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
561 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 (defmacro define-mode-local-override |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 (name mode args docstring &rest body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 "Define a mode specific override of the function overload NAME. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
565 Has meaning only if NAME has been created with `define-overload'. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 MODE is the major mode this override is being defined for. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
567 ARGS are the function arguments, which should match those of the same |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
568 named function created with `define-overload'. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
569 DOCSTRING is the documentation string. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 BODY is the implementation of this function." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
571 (let ((newname (intern (format "%s-%s" name mode)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
572 `(progn |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
573 (eval-and-compile |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
574 (defun ,newname ,args |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
575 ,(format "%s\n\nOverride %s in `%s' buffers." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
576 docstring name mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
577 ;; The body for this implementation |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
578 ,@body) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
579 ;; For find-func to locate the definition of NEWNAME. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
580 (put ',newname 'definition-name ',name)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
581 (mode-local-bind '((,name . ,newname)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
582 '(override-flag t) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
583 ',mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
584 )) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
585 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
586 ;;; Read/Query Support |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
587 (defun mode-local-read-function (prompt &optional initial hist default) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
588 "Interactively read in the name of a mode-local function. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
589 PROMPT, INITIAL, HIST, and DEFAULT are the same as for `completing-read'." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
590 (completing-read prompt obarray 'function-overload-p t initial hist default)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
591 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
592 ;;; Help support |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
593 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
594 (defun overload-docstring-extension (overload) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
595 "Return the doc string that augments the description of OVERLOAD." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
596 (let ((doc "\n\This function can be overloaded\ |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
597 with `define-mode-local-override'.") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
598 (sym (overload-obsoleted-by overload))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
599 (when sym |
105789
6df5ff499103
* cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
600 (setq doc (format "%s\nIt has made the overload `%s' obsolete since %s." |
6df5ff499103
* cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
601 doc sym (get sym 'overload-obsoleted-since)))) |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 (setq sym (overload-that-obsolete overload)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
603 (when sym |
105789
6df5ff499103
* cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
604 (setq doc (format "%s\nThis overload is obsolete since %s;\nUse `%s' instead." |
6df5ff499103
* cedet/mode-local.el (make-obsolete-overload): Add `when' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
605 doc (get overload 'overload-obsoleted-since) sym))) |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
606 doc)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
608 (defun mode-local-augment-function-help (symbol) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
609 "Augment the *Help* buffer for SYMBOL. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 SYMBOL is a function that can be overridden." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
611 (with-current-buffer "*Help*" |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 (pop-to-buffer (current-buffer)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 (unwind-protect |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
614 (progn |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
615 (toggle-read-only -1) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
616 (goto-char (point-min)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
617 (unless (re-search-forward "^$" nil t) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
618 (goto-char (point-max)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
619 (beginning-of-line) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
620 (forward-line -1)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 (insert (overload-docstring-extension symbol) "\n") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 ;; NOTE TO SELF: |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
623 ;; LIST ALL LOADED OVERRIDES FOR SYMBOL HERE |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
624 ) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
625 (toggle-read-only 1)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
626 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
627 ;; Help for mode-local bindings. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
628 (defun mode-local-print-binding (symbol) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 "Print the SYMBOL binding." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
630 (let ((value (symbol-value symbol))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
631 (princ (format "\n `%s' value is\n " symbol)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 (if (and value (symbolp value)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
633 (princ (format "`%s'" value)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
634 (let ((pt (point))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 (pp value) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 (save-excursion |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 (goto-char pt) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
638 (indent-sexp)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
639 (or (bolp) (princ "\n")))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
640 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
641 (defun mode-local-print-bindings (table) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
642 "Print bindings in TABLE." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
643 (let (us ;; List of unpecified symbols |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
644 mc ;; List of mode local constants |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 mv ;; List of mode local variables |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
646 ov ;; List of overloaded functions |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
647 fo ;; List of final overloaded functions |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
648 ) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 ;; Order symbols by type |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
650 (mapatoms |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
651 #'(lambda (s) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
652 (add-to-list (cond |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
653 ((get s 'mode-variable-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
654 (if (get s 'constant-flag) 'mc 'mv)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
655 ((get s 'override-flag) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
656 (if (get s 'constant-flag) 'fo 'ov)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
657 ('us)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
658 s)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
659 table) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
660 ;; Print symbols by type |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 (when us |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
662 (princ "\n !! Unpecified symbols\n") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
663 (mapc 'mode-local-print-binding us)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
664 (when mc |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
665 (princ "\n ** Mode local constants\n") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
666 (mapc 'mode-local-print-binding mc)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
667 (when mv |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
668 (princ "\n ** Mode local variables\n") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
669 (mapc 'mode-local-print-binding mv)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
670 (when fo |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
671 (princ "\n ** Final overloaded functions\n") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
672 (mapc 'mode-local-print-binding fo)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
673 (when ov |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
674 (princ "\n ** Overloaded functions\n") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
675 (mapc 'mode-local-print-binding ov)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
676 )) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
677 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
678 (defun mode-local-describe-bindings-2 (buffer-or-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
679 "Display mode local bindings active in BUFFER-OR-MODE." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
680 (let (table mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
681 (princ "Mode local bindings active in ") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
682 (cond |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
683 ((bufferp buffer-or-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
684 (with-current-buffer buffer-or-mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
685 (setq table mode-local-symbol-table |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 mode major-mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 (princ (format "%S\n" buffer-or-mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 ) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
689 ((symbolp buffer-or-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
690 (setq mode buffer-or-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
691 (princ (format "`%s'\n" buffer-or-mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
692 ) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
693 ((signal 'wrong-type-argument |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
694 (list 'buffer-or-mode buffer-or-mode)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 (when table |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 (princ "\n- Buffer local\n") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
697 (mode-local-print-bindings table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 (while mode |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 (setq table (get mode 'mode-local-symbol-table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
700 (when table |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
701 (princ (format "\n- From `%s'\n" mode)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
702 (mode-local-print-bindings table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
703 (setq mode (get-mode-local-parent mode))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
705 (defun mode-local-describe-bindings-1 (buffer-or-mode &optional interactive-p) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
706 "Display mode local bindings active in BUFFER-OR-MODE. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
707 Optional argument INTERACTIVE-P is non-nil if the calling command was |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
708 invoked interactively." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
709 (if (fboundp 'with-displaying-help-buffer) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
710 ;; XEmacs |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
711 (with-displaying-help-buffer |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
712 #'(lambda () |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 (with-current-buffer standard-output |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
714 (mode-local-describe-bindings-2 buffer-or-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
715 (when (fboundp 'frob-help-extents) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 (goto-char (point-min)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
717 (frob-help-extents standard-output))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
718 ;; GNU Emacs |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
719 (when (fboundp 'help-setup-xref) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
720 (help-setup-xref |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
721 (list 'mode-local-describe-bindings-1 buffer-or-mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
722 interactive-p)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 (with-output-to-temp-buffer (help-buffer) ; "*Help*" |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 (with-current-buffer standard-output |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
725 (mode-local-describe-bindings-2 buffer-or-mode))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
726 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
727 (defun describe-mode-local-bindings (buffer) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
728 "Display mode local bindings active in BUFFER." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
729 (interactive "b") |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
730 (when (setq buffer (get-buffer buffer)) |
106197
019d906c8f48
* cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents:
105834
diff
changeset
|
731 (mode-local-describe-bindings-1 buffer (called-interactively-p 'any)))) |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
732 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
733 (defun describe-mode-local-bindings-in-mode (mode) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
734 "Display mode local bindings active in MODE hierarchy." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 (interactive |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 (list (completing-read |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
737 "Mode: " obarray |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 #'(lambda (s) (get s 'mode-local-symbol-table)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 t (symbol-name major-mode)))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
740 (when (setq mode (intern-soft mode)) |
106197
019d906c8f48
* cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents:
105834
diff
changeset
|
741 (mode-local-describe-bindings-1 mode (called-interactively-p 'any)))) |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
743 ;; ;;; find-func support (Emacs 21.4, or perhaps 22.1) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
744 ;; ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
745 ;; (condition-case nil |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
746 ;; ;; Try to get find-func so we can modify it. |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
747 ;; (require 'find-func) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
748 ;; (error nil)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
749 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
750 ;; (when (boundp 'find-function-regexp) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
751 ;; (unless (string-match "ine-overload" find-function-regexp) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
752 ;; (if (string-match "(def\\\\(" find-function-regexp) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
753 ;; (let ((end (match-end 0)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
754 ;; ) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
755 ;; (setq find-function-regexp |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
756 ;; (concat (substring find-function-regexp 0 end) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
757 ;; "ine-overload\\|ine-mode-local-override\\|" |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 ;; "ine-child-mode\\|" |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 ;; (substring find-function-regexp end))))))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
760 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
761 ;;; edebug support |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
762 ;; |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
763 (defun mode-local-setup-edebug-specs () |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
764 "Define edebug specification for mode local macros." |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
765 (def-edebug-spec setq-mode-local |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
766 (symbolp &rest symbolp form)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
767 (def-edebug-spec defvar-mode-local |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
768 (&define symbolp name def-form [ &optional stringp ] )) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 (def-edebug-spec defconst-mode-local |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 defvar-mode-local) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
771 (def-edebug-spec define-overload |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 (&define name lambda-list stringp def-body)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
773 (def-edebug-spec define-overloadable-function |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 (&define name lambda-list stringp def-body)) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 (def-edebug-spec define-mode-local-override |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
776 (&define name symbolp lambda-list stringp def-body))) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
777 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
778 (add-hook 'edebug-setup-hook 'mode-local-setup-edebug-specs) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
779 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
780 (add-hook 'find-file-hook 'mode-local-post-major-mode-change) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
781 (add-hook 'change-major-mode-hook 'mode-local-on-major-mode-change) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
782 |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
783 (provide 'mode-local) |
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
784 |
105377 | 785 ;; arch-tag: 14b77823-f93c-4b3d-9116-495f69a6ec07 |
105242
bcef064b8a00
* cedet/mode-local.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 ;;; mode-local.el ends here |