annotate lisp/energize/energize-mode.el @ 28:1917ad0d78d7 r19-15b97

Import from CVS: tag r19-15b97
author cvs
date Mon, 13 Aug 2007 08:51:55 +0200
parents 376386a54a3c
children ec9a17fef872
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; -*- Mode:Emacs-Lisp -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Copyright © 1991-1993 by Lucid, Inc. All Rights Reserved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 (require 'etags))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; true if current-buffer is an energize buffer that does not support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; the real write-file and so has to do the special energize way of doing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; write-file that loses the annotations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 (defun energize-write-file-buffer-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; (and (energize-buffer-p (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; (not (eq major-mode 'energize-project-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 (energize-buffer-p (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 (defun energize-beginning-of-defun (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 "Move point to the beginning of the current top-level form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 With a numeric argument, move back that many forms."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 (interactive "_p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (or arg (setq arg 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 (if (not (energize-buffer-p (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (error "Not an Energize buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 (if (< arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 (energize-end-of-defun (- arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (or (bobp) (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (while (and (not (bobp)) (null (energize-extent-at (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (let ((pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (map-extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (lambda (extent dummy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (if (< (setq pos (extent-start-position extent)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (goto-char pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (current-buffer) (point) (point) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (setq arg (1- arg))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defun energize-end-of-defun (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "Move point to the end of the current top-level form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 With a numeric argument, move forward over that many forms."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (interactive "_p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (or arg (setq arg 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (if (not (energize-buffer-p (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (error "Not an Energize buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (if (< arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (energize-beginning-of-defun (- arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (or (eobp) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (while (and (not (eobp)) (null (energize-extent-at (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (let ((pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (map-extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (lambda (extent dummy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (if (> (setq pos (extent-end-position extent)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (goto-char pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (current-buffer) (point) (point) nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (setq arg (1- arg))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; Patching Energize into file I/O via the standard hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defun energize-write-data-hook (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; for use as the last element of write-file-data-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; in energize buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (if (energize-buffer-p (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (message "saving %s to Energize..." name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (energize-execute-command "save")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (energize-update-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (message "saved %s to Energize." name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defun energize-revert-buffer-insert-file-contents-hook (file noconfirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; for use as the value of revert-buffer-insert-file-contents-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; in energize buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (if (not (energize-buffer-p (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (error "energize-revert-buffer-hook called for a non-energize buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (cond ((equal file buffer-file-name) ; reverting from energize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; Do the default as in files.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (if (file-exists-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; Bind buffer-file-name to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; so that we don't try to lock the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (let ((buffer-file-name nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (unlock-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (insert-file-contents file t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; Then asks the extents from Energize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (energize-execute-command "revert"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (t ; reverting from autosave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if (not (file-exists-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (error "File %s no longer exists!" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (insert-file-contents file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defun energize-kill-buffer-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; for use as the value of kill-buffer-hook in energize buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (if (energize-buffer-p (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (energize-request-kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (error "energize-kill-buffer-hook called on a non-energize buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (defun energize-edit-definition-default ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (if (not (memq (char-syntax (preceding-char)) '(?w ?_)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (while (not (looking-at "\\sw\\|\\s_\\|\\'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (while (looking-at "\\sw\\|\\s_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (if (re-search-backward "\\sw\\|\\s_" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (progn (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (progn (forward-sexp -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (while (looking-at "\\s'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; This prompts in the minibuffer, ##### with no completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defun energize-edit-definition (def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 "If connected to Energize, the Energize database is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 Otherwise, `find-tag' is invoked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 The X selection is used as a default, if it exists and contains no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 newlines. Otherwise, the preceeding token is used as a default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 If invoked from a mouse command, prompting happens with a dialog box;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 otherwise, the minibuffer is used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (if (and (connected-to-energize-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (or (menu-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (button-press-event-p last-command-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (button-release-event-p last-command-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 '(nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (let (default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (cond ((x-selection-owner-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq default (x-get-selection))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (while (string-match "\\`[ \t\n]+" default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq default (substring default (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (while (string-match "[ \t\n]+\\'" default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (setq default (substring default 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (if (string-match "[ \t\n]" default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (setq default nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (or default (setq default (energize-edit-definition-default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (if (connected-to-energize-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (if default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (format "Edit definition [%s]: " default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 "Edit definition: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 nil nil; 'energize-edit-def-predicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (or (and (fboundp 'find-tag-tag) (fboundp 'find-tag-default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (require 'tags "etags"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (find-tag-tag "Edit definition: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (if (or (equal "" def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (equal '("") def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (setq def default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 def))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (if (connected-to-energize-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; FIXME - this should fall back on tags if it fails...we might be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; searching for elisp or something...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (energize-execute-command "editdef" () (if (consp def) (car def) def) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (find-tag def)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (define-key global-map "\M-." 'energize-edit-definition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (define-key global-map "\M-B" 'energize-build-a-target) ; M-Sh-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (defun disconnect-from-energize-query ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "Disconnect this emacs from the Energize server, after confirming."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (or (y-or-n-p "Disconnect from Energize? ") (error "not confirmed"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (disconnect-from-energize))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; Functions to add commands to the project buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (defun energize-insert-slots (got-to-top-p l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if (not (eq major-mode 'energize-project-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (error "Command available only in project buffers"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; move to a suitable place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (if got-to-top-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; go before "Associated Projects" and "Related Files"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if (or (search-backward "Related Projects:" () t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (search-backward "Associated Files:" () t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (looking-at "Related Projects:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (looking-at "Associated Files:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (previous-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;; find empty space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (while (and (not (looking-at "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (not (eq (point) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (next-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (mapcar '(lambda (i) (insert i) (newline)) l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; this is magic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (forward-char 18))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (defun energize-insert-rule ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (energize-insert-slots
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 '(" Rules:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 " <rule>: lcc -Xez -c -g -Xa -o $object $source")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defun energize-insert-object-file-target ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (energize-insert-slots
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 '(" Object File: <object-file>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 " Source File: <source-file>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 " Build Rule: <rule>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defun energize-insert-executable-target ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (energize-insert-slots
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 '(" Executable: <executable>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 " Build Command: lcc -Xf -Xez -o $object <object-file> ...")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun energize-insert-library-target ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (energize-insert-slots
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 '(" Library: <library>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 " Build Command: energize_ar -Xez -remove -ranlib clq $object \\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 " <object-file> ...")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defun energize-insert-collection-target ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (energize-insert-slots
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 '(" Collection: <collection>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 " Build Command: energize_collect -Xez -o $object <object-file> ...")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (defun energize-insert-file-target ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (energize-insert-slots
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 '(" File Target: <target>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 " Dependencies: <target> ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 " Build Command: <shell-command>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defun energize-insert-target-target ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (energize-insert-slots
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 '(" Target: <target>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 " Dependencies: <target> ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 " Build Command: <shell-command>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;;; Keymaps for Energize buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defvar energize-map nil "*Parent keymap for all Energize buffers")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (defvar energize-top-level-map nil "*Keymap for the Energize top-level buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (defvar energize-debugger-map nil "*Keymap for Energize debugger buffers")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defvar energize-breakpoint-map nil "*Keymap for Energize breakpoint-lists")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (defvar energize-browser-map nil "*Keymap for Energize browser buffers")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (defvar energize-project-map nil "*Keymap for Energize project buffers")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (defvar energize-no-file-project-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "*Keymap for Energize project buffers not associated with a file")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (defvar energize-source-map nil "*Keymap for Energize source buffers")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (defvar energize-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "Hook called when each energize buffer is created.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (defvar energize-top-level-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 "Hook called when the energize top-level buffer is created.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defvar energize-project-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "Hook called when an Energize project buffer is created.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (defvar energize-no-file-project-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "Hook called when an Energize project buffer with no file is created.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defvar energize-breakpoint-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "Hook called when an Energize breakpoint-list buffer is created.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defvar energize-browser-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "Hook called when an Energize browser buffer is created.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (defvar energize-log-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "Hook called when an Energize log buffer is created.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (defvar energize-manual-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 "Hook called when an Energize manual buffer is created.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (defvar energize-source-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 "Hook called when any source buffer is placed in the Energize minor-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (if energize-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (setq energize-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (set-keymap-name energize-map 'energize-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (define-key energize-map "\^C\^F" 'energize-find-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (define-key energize-map "\^C\^B\^E" 'energize-browse-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (define-key energize-map "\^C\^B\^L" 'energize-browse-language-elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (define-key energize-map "\^C\^B\^T" 'energize-browse-tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (define-key energize-map "\^C\^B\^C" 'energize-browse-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; now in global-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;; (define-key energize-map "\M-B" 'energize-build-a-target) ; M-Sh-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (define-key energize-map "\M-C" 'energize-default-compile-file) ; M-Sh-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (define-key energize-map 'button3 'energize-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (if energize-top-level-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (setq energize-top-level-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (set-keymap-name energize-top-level-map 'energize-top-level-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (set-keymap-parent energize-top-level-map energize-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (suppress-keymap energize-top-level-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (define-key energize-top-level-map "?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (define-key energize-top-level-map " " 'energize-top-next-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (define-key energize-top-level-map "n" 'energize-top-next-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (define-key energize-top-level-map "p" 'energize-top-prev-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (define-key energize-top-level-map "N" 'energize-top-next-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (define-key energize-top-level-map "P" 'energize-top-prev-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (define-key energize-top-level-map "\t" 'energize-top-next-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (define-key energize-top-level-map '(shift tab) 'energize-top-prev-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (define-key energize-top-level-map '(control I) 'energize-top-prev-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (define-key energize-top-level-map "Q" 'disconnect-from-energize-query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (define-key energize-top-level-map "d" 'energize-top-debug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (define-key energize-top-level-map "\^D" 'energize-top-delete-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (define-key energize-top-level-map "e" 'energize-top-edit-project)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (if energize-project-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (setq energize-project-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (set-keymap-name energize-project-map 'energize-project-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (set-keymap-parent energize-project-map energize-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;;(suppress-keymap energize-project-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;;(define-key energize-project-map "\t" 'energize-project-next-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;;(define-key energize-project-map '(shift tab) 'energize-project-prev-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;;(define-key energize-project-map '(control I) 'energize-project-prev-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (define-key energize-project-map "\^C\^I" 'energize-import-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (define-key energize-project-map "\^C\^E" 'energize-project-edit-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (define-key energize-project-map "\^C\^S\^A" 'energize-project-sort-alpha)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (define-key energize-project-map "\^C\^S\^L" 'energize-project-sort-link)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (define-key energize-project-map "\^C\^V\^N" 'energize-project-view-names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ; (define-key energize-project-map "\^C\^V\^L" 'energize-project-view-long)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (define-key energize-project-map "\^C\^V\^C" 'energize-project-view-options)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (if energize-no-file-project-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (setq energize-no-file-project-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (set-keymap-name energize-no-file-project-map 'energize-no-file-project-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (set-keymap-parent energize-no-file-project-map energize-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if energize-breakpoint-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (setq energize-breakpoint-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (set-keymap-name energize-breakpoint-map 'energize-breakpoint-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (set-keymap-parent energize-breakpoint-map energize-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (if energize-browser-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (setq energize-browser-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (set-keymap-name energize-browser-map 'energize-browser-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (set-keymap-parent energize-browser-map energize-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (if energize-source-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq energize-source-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (set-keymap-name energize-source-map 'energize-source-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (set-keymap-parent energize-source-map energize-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;; There are too many problems with using extents to determine where the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;; top level forms are...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; (define-key energize-source-map "\M-\C-a" 'energize-beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;; (define-key energize-source-map "\M-\C-e" 'energize-end-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defvar energize-menu-state nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 "State of the energize menu items of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 Automatically updated by the kernel when the state changes")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defvar energize-default-menu-state nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "State of the energize default menu items.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 Automatically updated by the kernel when the state changes")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defun energize-mode-internal ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;; initialize stuff common to all energize buffers (hooks, etc).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (make-local-hook 'write-file-data-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (add-hook 'write-file-data-hooks 'energize-write-data-hook t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (make-local-variable 'revert-buffer-insert-file-contents-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (setq revert-buffer-insert-file-contents-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 'energize-revert-buffer-insert-file-contents-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (make-local-hook 'kill-buffer-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (add-hook 'kill-buffer-hook 'energize-kill-buffer-hook nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (make-local-variable 'require-final-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (setq require-final-newline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (make-local-variable 'energize-menu-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (run-hooks 'energize-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (defun energize-non-file-mode-internal ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; do magic associated with energize-modes for buffers which are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;; and cannot be associated with files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ; (or (null buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ; (equal buffer-file-name mode-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ; (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ; "This buffer is associated with a file, it can't be placed in %s mode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ; mode-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 ;; hack so that save-file doesn't prompt for a filename.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (or buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (setq buffer-file-name (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (set (make-local-variable 'version-control) 'never)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;; don't create random new buffers in these modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (put 'energize-top-level-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (put 'energize-project-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (put 'energize-no-file-project-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (put 'energize-breakpoint-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (put 'energize-browser-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (put 'energize-log-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (defun energize-top-level-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 "Major mode for the Energize top-level buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 In addition to normal cursor-motion commands, the following keys are bound:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 \\{energize-top-level-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (energize-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (use-local-map energize-top-level-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (setq major-mode 'energize-top-level-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 mode-name "Energize")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (energize-non-file-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;; the default of "energize: Energize" is not very attractive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if (equal frame-title-format "%S: %b")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (set (make-local-variable 'frame-title-format) "%S: Top-Level"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (run-hooks 'energize-top-level-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun energize-project-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "Major mode for the Energize Project buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 In addition to the normal editing commands, the following keys are bound:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 \\{energize-project-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (energize-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (use-local-map energize-project-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (setq major-mode 'energize-project-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 mode-name "Project")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; in later revisions of the kernel the project is really a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (if (< (cdr (energize-protocol-level)) 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (energize-non-file-mode-internal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (run-hooks 'energize-project-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun energize-no-file-project-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 "Major mode for the Energize Project buffers not associated with a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 In addition to the normal editing commands, the following keys are bound:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 \\{energize-no-file-project-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (energize-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (use-local-map energize-no-file-project-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (setq major-mode 'energize-no-file-project-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 mode-name "NoFileProject")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (energize-non-file-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (run-hooks 'energize-no-file-project-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defun energize-breakpoint-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 "Major mode for the Energize Breakpoint-list buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 In addition to the normal editing commands, the following keys are bound:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 \\{energize-breakpoint-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (energize-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (use-local-map energize-breakpoint-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (setq major-mode 'energize-breakpoint-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 mode-name "Breakpoint")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (energize-non-file-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (run-hooks 'energize-breakpoint-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (defun energize-browser-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 "Major mode for the Energize Browser buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 In addition to the normal editing commands, the following keys are bound:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 \\{energize-browser-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (energize-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (use-local-map energize-browser-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (setq major-mode 'energize-browser-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 mode-name "Browser")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (energize-non-file-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (run-hooks 'energize-browser-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (defun energize-log-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 "Major mode for the Energize Error Log and System Log buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 In addition to the normal editing commands, the following keys are bound:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 \\{energize-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (energize-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (use-local-map energize-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setq major-mode 'energize-log-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 mode-name "Energize-Log")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (energize-non-file-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (run-hooks 'energize-log-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (defun energize-manual-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 "Major mode for the Energize UNIX Manual buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 In addition to the normal editing commands, the following keys are bound:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 \\{energize-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (energize-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (use-local-map energize-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (setq major-mode 'energize-manual-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 mode-name "Energize-Manual")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (energize-non-file-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (run-hooks 'energize-manual-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (defvar energize-source-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;;(put 'energize-source-mode 'permanent-local t) ; persists beyond mode-change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ;;; Add energize-source-mode to minor-mode-alist so that it shows up in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;;; the modeline when true.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (or (assq 'energize-source-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (setq minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (append minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 '((energize-source-mode " Energize")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (defun energize-source-minor-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 "Minor mode for adding additional keybindings to Energize source buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 The following key bindings are added:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 \\{energize-source-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 Since this minor mode defines keys, once it gets turned on you can't really
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 turn it off."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (energize-mode-internal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (make-local-variable 'energize-source-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (setq energize-source-mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (let ((source-map energize-source-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (dest-map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (set-keymap-parent dest-map (current-local-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (set-keymap-name dest-map 'energize-minor-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (while source-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (let (mapper prefixes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (setq mapper (function (lambda (key val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (if (keymapp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (let ((prefixes (append prefixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (cons key nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (map-keymap val mapper))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (define-key dest-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (apply 'vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (append prefixes (cons key nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (map-keymap source-map mapper))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (setq source-map (keymap-parent source-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (use-local-map dest-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (run-hooks 'energize-source-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;;; Commands in source buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (defun recenter-definition ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 "Position the beginning of the current definition at the top of the frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (if (eq major-mode 'c++-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (c++-beginning-of-defun 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (beginning-of-defun 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (recenter 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (define-key global-map "\M-\C-r" 'recenter-definition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (defun energize-hide-error-glyphs-in-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 "Hides the error icons in the current toplevel form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 You cannot get them back until you recompile the file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (let ((start (progn (energize-beginning-of-defun) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (end (progn (energize-end-of-defun) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (setq e (extent-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (while (and e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (< (extent-end-position e) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (if (extent-property e 'begin-glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (set-extent-begin-glyph e nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (setq e (next-extent e)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 ;;; Dired-like commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (defun energize-next-extent-for (command prev not-this-one)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (let ((last-e (if not-this-one 'none nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 e result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (while (not (or result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (if prev (bobp) (eobp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (setq e (extent-at (point) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (if (and (not (eq e last-e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (not (eq last-e 'none)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (energize-menu-item-for-name e command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (forward-char (if prev -1 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (setq last-e e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (if result e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (defun energize-next-extent-on-line-for (command not-this-one)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (narrow-to-region (point) (progn (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (energize-next-extent-for command nil not-this-one))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;;; commands in the top-level buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (defun energize-top-next-project ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 "Position the cursor at the beginning of the following project."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (let ((p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (let ((e (energize-next-extent-for "editproject" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (if (and e (= p (extent-start-position e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (forward-char (extent-length e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (setq e (energize-next-extent-for "editproject" nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (if e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (goto-char (extent-start-position e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (error "no next project")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (defun energize-top-prev-project ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 "Position the cursor at the beginning of the preceeding project."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (let ((p (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (let ((e (energize-next-extent-for "editproject" t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (and e (= p (extent-start-position e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq e (energize-next-extent-for "editproject" t t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (if e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (goto-char (extent-start-position e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (error "no previous project")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (defun energize-top-execute-command (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (let ((e (or (energize-next-extent-on-line-for command nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (concat "no following field on this line that handles the `"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 command "' Energize command.")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (energize-execute-command command e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (defun energize-top-debug ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 "Execute the `Debug' command on the project at or following point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (energize-top-execute-command "debugprogram"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (defun energize-top-delete-project ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 "Delete the project at or following point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (energize-top-execute-command "deleteproject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (defun energize-top-edit-project ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 "Edit the project at or following point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (energize-top-execute-command "editproject"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;;; commands in the project buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (defun energize-project-next-field (&optional prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (let ((e (extent-at (point) (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (if e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (if prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (goto-char (1- (extent-start-position e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (goto-char (1+ (extent-end-position e)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (while (null (extent-at (point) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (forward-char (if prev -1 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (while (extent-at (point) (current-buffer) 'write-protected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (forward-char (if prev -1 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (if prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (if (setq e (extent-at (point) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (goto-char (extent-start-position e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (while (not (extent-at (point) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (forward-char -1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (defun energize-project-prev-field () (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (energize-project-next-field t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (defun energize-project-edit-file () (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (energize-top-execute-command "editfile"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (defun energize-project-prune-unused-rules ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 "Deletes all unused rules from the Rules: part of a Project buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 and renumbers the remaining rules sequentially."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (re-search-forward "^[ \t]+Rules:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (let ((rules-regexp "^[ \t]*\\(\\.[a-zA-Z]+\\(([0-9]+)\\)?\\):")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (all-rules nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 eor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ;; Gather the contents of the Rule section, and find its end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (while (looking-at rules-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (setq all-rules (cons (list (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 all-rules))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (while (progn (end-of-line) (= (preceding-char) ?\\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (setq eor (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (setq all-rules (nreverse all-rules))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (let ((rest all-rules)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 rule)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 ;; Walk through the buffer gathering references to the rules.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (while rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (setq rule (car rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (goto-char eor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (let ((pattern (concat "^[ \t]+" (regexp-quote (car rule)) ":")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (while (re-search-forward pattern nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (setcdr (cdr rule)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (cons (set-marker (make-marker) (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (cdr (cdr rule))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (setq rest (cdr rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 ;; Delete those rules that have no references.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (goto-char eor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (setq rest all-rules)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (while rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (setq rule (car rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (if (null (cdr (cdr rule)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (let ((p (nth 1 rule)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (while (progn (end-of-line) (= (preceding-char) ?\\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (delete-region p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (set-marker p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (setq all-rules (delq rule all-rules))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (setq rest (cdr rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ;; Renumber the remaining rules sequentially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (goto-char eor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (setq rest all-rules)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (let ((i 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (while rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (setq rule (car rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (let ((referents (cdr rule))) ; including definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (while referents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (goto-char (car referents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (or (and (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (concat "^[ \t]+" (regexp-quote (car rule)) ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (looking-at "[^:(]+\\((\\([0-9]+\\))\\|\\):"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (error "internal error"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (if (null (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (insert "(" (int-to-string i) ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (goto-char (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (delete-region (match-beginning 2) (match-end 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (insert (int-to-string i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (set-marker (car referents) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (setq referents (cdr referents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (setq rest (cdr rest))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 ;; TODO:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ;; - order the Rule Users list in the same order as the Rules list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 ;; - or, order the Rule Users list by number of files, and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;; order the Rules list the same as that (numbered sequentially.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 ;; - or, order the Rules list by length-of-rule (= complicatedness.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (set-marker eor nil))))