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