| 1 |
(require 'cl) |
| 2 |
|
| 3 |
(defun replace-in-files (matches files) |
| 4 |
(save-excursion |
| 5 |
(mapc (lambda (file) |
| 6 |
(switch-to-buffer (or (find-buffer-visiting file) (find-file file))) |
| 7 |
(mapc (lambda (x) |
| 8 |
(beginning-of-buffer) |
| 9 |
(let ((case-fold-search nil)) |
| 10 |
(print x) |
| 11 |
(while (search-forward-regexp (car x) nil t) |
| 12 |
(replace-match (cdr x) nil t))) |
| 13 |
(save-buffer) |
| 14 |
) |
| 15 |
matches)) |
| 16 |
files))) |
| 17 |
|
| 18 |
(defun ecl-load-symbols () |
| 19 |
(interactive) |
| 20 |
(beginning-of-buffer) |
| 21 |
(while (re-search-forward ";;; Address = \\([0-9a-f]*\\)" nil t) |
| 22 |
(let ((address (buffer-substring (match-beginning 1) |
| 23 |
(match-end 1)))) |
| 24 |
(re-search-backward ";;; Loading \\(/.*\.o\\)$") |
| 25 |
(let ((file (buffer-substring (match-beginning 1) |
| 26 |
(match-end 1)))) |
| 27 |
(print file) (print address) |
| 28 |
(save-excursion |
| 29 |
(gud-call (format "add-symbol-file %s 0x%s" file address)))) |
| 30 |
(next-line 2)))) |
| 31 |
|
| 32 |
(defvar ecl-search-string) |
| 33 |
|
| 34 |
(defun query-replace-ecl (from-string to-string &optional delimited start end) |
| 35 |
(interactive (query-replace-read-args "Query replace" nil)) |
| 36 |
(setq ecl-search-string from-string) |
| 37 |
(let ((remaining (member (buffer-file-name (current-buffer)) ecl-files))) |
| 38 |
(dolist (i (or remaining ecl-files)) |
| 39 |
(let ((b (find-buffer-visiting i))) |
| 40 |
(unless (equal b (current-buffer)) |
| 41 |
(switch-to-buffer b) |
| 42 |
(beginning-of-buffer))) |
| 43 |
(perform-replace from-string to-string t nil delimited nil nil |
| 44 |
start end)))) |
| 45 |
|
| 46 |
(defun query-replace-regexp-ecl (from-string to-string &optional delimited start end) |
| 47 |
(interactive (query-replace-read-args "Query replace" nil)) |
| 48 |
(setq ecl-search-string from-string) |
| 49 |
(let ((remaining (member (buffer-file-name (current-buffer)) ecl-files))) |
| 50 |
(dolist (i (or remaining ecl-files)) |
| 51 |
(let ((b (find-buffer-visiting i))) |
| 52 |
(unless (equal b (current-buffer)) |
| 53 |
(switch-to-buffer b) |
| 54 |
(beginning-of-buffer))) |
| 55 |
(query-replace-regexp from-string to-string delimited start end)))) |
| 56 |
|
| 57 |
(defun search-ecl (string) |
| 58 |
(interactive "sString: ") |
| 59 |
(setq ecl-search-string string) |
| 60 |
(let ((remaining (member (buffer-file-name (current-buffer)) ecl-files))) |
| 61 |
(dolist (i (or remaining ecl-files)) |
| 62 |
(let ((b (find-buffer-visiting i))) |
| 63 |
(unless (equal b (current-buffer)) |
| 64 |
(print b) |
| 65 |
(switch-to-buffer b) |
| 66 |
(beginning-of-buffer))) |
| 67 |
(print '*) |
| 68 |
(setq case-fold-search t) |
| 69 |
(if (search-forward string nil t) |
| 70 |
(return))))) |
| 71 |
|
| 72 |
(defun search-next-ecl () |
| 73 |
(interactive) |
| 74 |
(search-ecl ecl-search-string)) |
| 75 |
|
| 76 |
(defun back-to-emacs () |
| 77 |
(interactive) |
| 78 |
(switch-to-buffer "emacs.el")) |
| 79 |
|
| 80 |
(defun next-ecl () |
| 81 |
(interactive) |
| 82 |
(let ((remaining (member (buffer-file-name (current-buffer)) ecl-files))) |
| 83 |
(when (cdr remaining) |
| 84 |
(switch-to-buffer (find-buffer-visiting (cadr remaining)))))) |
| 85 |
|
| 86 |
(global-set-key [?\M-p ?\C-i] 'back-to-emacs) |
| 87 |
(global-set-key [?\M-p ?\C-s] 'search-ecl) |
| 88 |
(global-set-key [?\M-p ?\C-n] 'search-next-ecl) |
| 89 |
(global-set-key [?\M-p ?\C-m] 'next-ecl) |
| 90 |
(global-set-key [?\M-p ?\C-p] 'ecl-load-symbols) |
| 91 |
|
| 92 |
(setq auto-mode-alist (acons "\\.d\\'" 'c-mode auto-mode-alist)) |
| 93 |
|
| 94 |
(setq ecl-files |
| 95 |
(mapcar (lambda (x) |
| 96 |
(set-buffer "emacs.el") |
| 97 |
(concat (subseq (buffer-file-name (current-buffer)) 0 -13) x)) |
| 98 |
'( |
| 99 |
"c/all_symbols.d" |
| 100 |
"c/alloc_2.d" |
| 101 |
"c/apply.d" |
| 102 |
"c/array.d" |
| 103 |
"c/assignment.d" |
| 104 |
"c/backq.d" |
| 105 |
"c/big.d" |
| 106 |
"c/big_ll.d" |
| 107 |
"c/cfun.d" |
| 108 |
"c/cfun_dispatch.d" |
| 109 |
"c/char_ctype.d" |
| 110 |
"c/character.d" |
| 111 |
"c/cinit.d" |
| 112 |
"c/clos/accessor.d" |
| 113 |
"c/clos/cache.d" |
| 114 |
"c/clos/gfun.d" |
| 115 |
"c/clos/instance.d" |
| 116 |
"c/cmpaux.d" |
| 117 |
"c/compiler.d" |
| 118 |
"c/cons.d" |
| 119 |
"c/disassembler.d" |
| 120 |
"c/ecl_constants.h" |
| 121 |
"c/ecl_features.h" |
| 122 |
"c/error.d" |
| 123 |
"c/eval.d" |
| 124 |
"c/ffi/backtrace.d" |
| 125 |
"c/ffi/cdata.d" |
| 126 |
"c/ffi/libraries.d" |
| 127 |
"c/ffi/mmap.d" |
| 128 |
"c/ffi.d" |
| 129 |
"c/file.d" |
| 130 |
"c/format.d" |
| 131 |
"c/gbc.d" |
| 132 |
"c/hash.d" |
| 133 |
"c/interpreter.d" |
| 134 |
"c/iso_latin_names.h" |
| 135 |
"c/list.d" |
| 136 |
"c/load.d" |
| 137 |
"c/macros.d" |
| 138 |
"c/main.d" |
| 139 |
"c/Makefile.in" |
| 140 |
"c/mapfun.d" |
| 141 |
"c/multival.d" |
| 142 |
"c/newhash.h" |
| 143 |
"c/num_arith.d" |
| 144 |
"c/num_co.d" |
| 145 |
"c/num_log.d" |
| 146 |
"c/num_pred.d" |
| 147 |
"c/num_rand.d" |
| 148 |
"c/number.d" |
| 149 |
"c/numbers/abs.d" |
| 150 |
"c/numbers/atan.d" |
| 151 |
"c/numbers/conjugate.d" |
| 152 |
"c/numbers/cos.d" |
| 153 |
"c/numbers/cosh.d" |
| 154 |
"c/numbers/divide.d" |
| 155 |
"c/numbers/exp.d" |
| 156 |
"c/numbers/expt.d" |
| 157 |
"c/numbers/float_fix_compare.d" |
| 158 |
"c/numbers/log.d" |
| 159 |
"c/numbers/minmax.d" |
| 160 |
"c/numbers/minus.d" |
| 161 |
"c/numbers/minusp.d" |
| 162 |
"c/numbers/negate.d" |
| 163 |
"c/numbers/number_compare.d" |
| 164 |
"c/numbers/number_equalp.d" |
| 165 |
"c/numbers/one_minus.d" |
| 166 |
"c/numbers/one_plus.d" |
| 167 |
"c/numbers/plus.d" |
| 168 |
"c/numbers/plusp.d" |
| 169 |
"c/numbers/sin.d" |
| 170 |
"c/numbers/sinh.d" |
| 171 |
"c/numbers/sqrt.d" |
| 172 |
"c/numbers/tan.d" |
| 173 |
"c/numbers/tanh.d" |
| 174 |
"c/numbers/times.d" |
| 175 |
"c/numbers/zerop.d" |
| 176 |
"c/package.d" |
| 177 |
"c/pathname.d" |
| 178 |
"c/predicate.d" |
| 179 |
"c/print.d" |
| 180 |
"c/printer/float_string_old.d" |
| 181 |
"c/printer/float_to_digits.d" |
| 182 |
"c/printer/float_to_string.d" |
| 183 |
"c/printer/integer_to_string.d" |
| 184 |
"c/printer/print_unreadable.d" |
| 185 |
"c/printer/write_array.d" |
| 186 |
"c/printer/write_code.d" |
| 187 |
"c/printer/write_list.d" |
| 188 |
"c/printer/write_object.d" |
| 189 |
"c/printer/write_sse.d" |
| 190 |
"c/printer/write_symbol.d" |
| 191 |
"c/printer/write_ugly.d" |
| 192 |
"c/read.d" |
| 193 |
"c/reader/parse_integer.d" |
| 194 |
"c/reader/parse_number.d" |
| 195 |
"c/reference.d" |
| 196 |
"c/sequence.d" |
| 197 |
"c/serialize.d" |
| 198 |
"c/sse2.d" |
| 199 |
"c/stacks.d" |
| 200 |
"c/string.d" |
| 201 |
"c/structure.d" |
| 202 |
"c/symbol.d" |
| 203 |
"c/symbols_list.h" |
| 204 |
"c/tcp.d" |
| 205 |
"c/threads/atomic.d" |
| 206 |
"c/threads/barrier.d" |
| 207 |
"c/threads/condition_variable.d" |
| 208 |
"c/threads/mailbox.d" |
| 209 |
"c/threads/mutex.d" |
| 210 |
"c/threads/process.d" |
| 211 |
"c/threads/rwlock.d" |
| 212 |
"c/threads/semaphore.d" |
| 213 |
"c/time.d" |
| 214 |
"c/typespec.d" |
| 215 |
"c/unixfsys.d" |
| 216 |
"c/unixint.d" |
| 217 |
"c/unixsys.d" |
| 218 |
"c/vector_push.d" |
| 219 |
"h/bytecodes.h" |
| 220 |
"h/cache.h" |
| 221 |
"h/config.h.in" |
| 222 |
"h/cons.h" |
| 223 |
"h/cs.h" |
| 224 |
"h/ecl-cmp.h" |
| 225 |
"h/ecl-inl.h" |
| 226 |
"h/ecl_atomics.h" |
| 227 |
"h/ecl.h" |
| 228 |
"h/external.h" |
| 229 |
"h/impl/math_dispatch.h" |
| 230 |
"h/impl/math_dispatch2.h" |
| 231 |
"h/impl/math_fenv.h" |
| 232 |
"h/impl/math_fenv_msvc.h" |
| 233 |
"h/internal.h" |
| 234 |
"h/legacy.h" |
| 235 |
"h/number.h" |
| 236 |
"h/object.h" |
| 237 |
"h/page.h" |
| 238 |
"h/stacks.h" |
| 239 |
"h/threads.h" |
| 240 |
"lsp/arraylib.lsp" |
| 241 |
"lsp/assert.lsp" |
| 242 |
"lsp/autoload.lsp" |
| 243 |
"lsp/cdr-5.lsp" |
| 244 |
"lsp/cmdline.lsp" |
| 245 |
"lsp/cmpinit.lsp" |
| 246 |
"lsp/cmuutil.lsp" |
| 247 |
"lsp/config.lsp.in" |
| 248 |
"lsp/defmacro.lsp" |
| 249 |
"lsp/defpackage.lsp" |
| 250 |
"lsp/defstruct.lsp" |
| 251 |
"lsp/describe.lsp" |
| 252 |
"lsp/evalmacros.lsp" |
| 253 |
"lsp/export.lsp" |
| 254 |
"lsp/ffi.lsp" |
| 255 |
"lsp/format.lsp" |
| 256 |
"lsp/helpfile.lsp" |
| 257 |
"lsp/init.lsp" |
| 258 |
"lsp/iolib.lsp" |
| 259 |
"lsp/listlib.lsp" |
| 260 |
"lsp/load.lsp.in" |
| 261 |
"lsp/loop.lsp" |
| 262 |
"lsp/mislib.lsp" |
| 263 |
"lsp/module.lsp" |
| 264 |
"lsp/mp.lsp" |
| 265 |
"lsp/numlib.lsp" |
| 266 |
"lsp/packlib.lsp" |
| 267 |
"lsp/pprint.lsp" |
| 268 |
"lsp/predlib.lsp" |
| 269 |
"lsp/process.lsp" |
| 270 |
"lsp/proclaim.lsp" |
| 271 |
"lsp/seq.lsp" |
| 272 |
"lsp/seqlib.lsp" |
| 273 |
"lsp/seqmacros.lsp" |
| 274 |
"lsp/setf.lsp" |
| 275 |
"lsp/top.lsp" |
| 276 |
"lsp/trace.lsp" |
| 277 |
"lsp/unicode.lsp" |
| 278 |
"clos/boot.lsp" |
| 279 |
"clos/builtin.lsp" |
| 280 |
"clos/change.lsp" |
| 281 |
"clos/cmpinit.lsp" |
| 282 |
"clos/combin.lsp" |
| 283 |
"clos/conditions.lsp" |
| 284 |
"clos/cpl.lsp" |
| 285 |
"clos/defclass.lsp" |
| 286 |
"clos/fixup.lsp" |
| 287 |
"clos/generic.lsp" |
| 288 |
"clos/hierarchy.lsp" |
| 289 |
"clos/init.lsp" |
| 290 |
"clos/inspect.lsp" |
| 291 |
"clos/kernel.lsp" |
| 292 |
"clos/load.lsp.in" |
| 293 |
"clos/macros.lsp" |
| 294 |
"clos/method.lsp" |
| 295 |
"clos/package.lsp" |
| 296 |
"clos/print.lsp" |
| 297 |
"clos/slot.lsp" |
| 298 |
"clos/slotvalue.lsp" |
| 299 |
"clos/standard.lsp" |
| 300 |
"clos/std-accessors.lsp" |
| 301 |
"clos/std-slot-value.lsp" |
| 302 |
"clos/stdmethod.lsp" |
| 303 |
"clos/streams.lsp" |
| 304 |
"clos/walk.lsp" |
| 305 |
"cmp/cmparray.lsp" |
| 306 |
"cmp/cmpbind.lsp" |
| 307 |
"cmp/cmpblock.lsp" |
| 308 |
"cmp/cmpc-inliner.lsp" |
| 309 |
"cmp/cmpc-wt.lsp" |
| 310 |
"cmp/cmpcall.lsp" |
| 311 |
"cmp/cmpcatch.lsp" |
| 312 |
"cmp/cmpcbk.lsp" |
| 313 |
"cmp/cmpclos.lsp" |
| 314 |
"cmp/cmpct.lsp" |
| 315 |
"cmp/cmpdefs.lsp" |
| 316 |
"cmp/cmpenv-api.lsp" |
| 317 |
"cmp/cmpenv-declaim.lsp" |
| 318 |
"cmp/cmpenv-declare.lsp" |
| 319 |
"cmp/cmpenv-fun.lsp" |
| 320 |
"cmp/cmpenv-proclaim.lsp" |
| 321 |
"cmp/cmpeval.lsp" |
| 322 |
"cmp/cmpexit.lsp" |
| 323 |
"cmp/cmpffi.lsp" |
| 324 |
"cmp/cmpflet.lsp" |
| 325 |
"cmp/cmpform.lsp" |
| 326 |
"cmp/cmpfun.lsp" |
| 327 |
"cmp/cmpglobals.lsp" |
| 328 |
"cmp/cmpif.lsp" |
| 329 |
"cmp/cmpinline.lsp" |
| 330 |
"cmp/cmplam.lsp" |
| 331 |
"cmp/cmplet.lsp" |
| 332 |
"cmp/cmploc.lsp" |
| 333 |
"cmp/cmpmac.lsp" |
| 334 |
"cmp/cmpmain.lsp" |
| 335 |
"cmp/cmpmap.lsp" |
| 336 |
"cmp/cmpmulti.lsp" |
| 337 |
"cmp/cmpname.lsp" |
| 338 |
"cmp/cmpnum.lsp" |
| 339 |
"cmp/cmpopt-bits.lsp" |
| 340 |
"cmp/cmpopt-clos.lsp" |
| 341 |
"cmp/cmpopt-cons.lsp" |
| 342 |
"cmp/cmpopt-constant.lsp" |
| 343 |
"cmp/cmpopt-printer.lsp" |
| 344 |
"cmp/cmpopt-sequence.lsp" |
| 345 |
"cmp/cmpopt-type.lsp" |
| 346 |
"cmp/cmpopt.lsp" |
| 347 |
"cmp/cmpos-features.lsp" |
| 348 |
"cmp/cmpos-run.lsp" |
| 349 |
"cmp/cmppackage.lsp" |
| 350 |
"cmp/cmppolicy.lsp" |
| 351 |
"cmp/cmpprop.lsp" |
| 352 |
"cmp/cmpspecial.lsp" |
| 353 |
"cmp/cmpstack.lsp" |
| 354 |
"cmp/cmpstructures.lsp" |
| 355 |
"cmp/cmptables.lsp" |
| 356 |
"cmp/cmptag.lsp" |
| 357 |
"cmp/cmptest.lsp" |
| 358 |
"cmp/cmptop.lsp" |
| 359 |
"cmp/cmptype-arith.lsp" |
| 360 |
"cmp/cmptype-assert.lsp" |
| 361 |
"cmp/cmptype-prop.lsp" |
| 362 |
"cmp/cmptype.lsp" |
| 363 |
"cmp/cmptypes.lsp" |
| 364 |
"cmp/cmputil.lsp" |
| 365 |
"cmp/cmpvar.lsp" |
| 366 |
"cmp/cmpwt.lsp" |
| 367 |
"cmp/load.lsp.in" |
| 368 |
"cmp/proclamations.lsp" |
| 369 |
"cmp/sysfun.lsp" |
| 370 |
"../msvc/ecl/config.h.msvc6" |
| 371 |
))) |
| 372 |
|
| 373 |
(mapcar 'find-file ecl-files) |
| 374 |
|
| 375 |
(defun ecl-revert () |
| 376 |
(interactive) |
| 377 |
(mapcar '(lambda (x) (let ((a (find-buffer-visiting x))) |
| 378 |
(and a (switch-to-buffer a) |
| 379 |
(revert-buffer t t)))) |
| 380 |
ecl-files)) |
| 381 |
|
| 382 |
(defun ecl-save () |
| 383 |
(interactive) |
| 384 |
(mapcar '(lambda (x) (let ((a (find-buffer-visiting x))) |
| 385 |
(and a (switch-to-buffer a) |
| 386 |
(save-buffer 0)))) |
| 387 |
ecl-files)) |