Mercurial > hg > xemacs
annotate shared/repl-comment.el @ 63:e7c2deb7de20
old changes ??,
get add-white working
author | Henry S Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Mon, 16 Dec 2024 18:19:39 +0000 |
parents | 107d592c5f4a |
children |
rev | line source |
---|---|
0
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
1 ;; Universal (?) replace comment in function |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
2 |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
3 ;; Last edited: Thu Oct 7 09:39:50 1993 |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
4 (defun repl-comment (fn comment) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
5 "replace/install as FN's comment COMMENT, no matter what emacs/compiler" |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
6 (let ((defn (symbol-function fn))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
7 (if (consp defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
8 (if (eq (car defn) 'autoload) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
9 (progn (load-library (car (cdr defn))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
10 (if (equal defn (symbol-function fn)) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
11 (error "autoloading didn't help define %s" fn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
12 (repl-comment fn comment))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
13 ;; either symbolic or old byte-compiler |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
14 (if (eq (car defn) 'lambda) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
15 (if (stringp (car (cdr (cdr defn)))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
16 (rplaca (cdr (cdr defn)) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
17 comment) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
18 (rplacd (cdr defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
19 (cons comment |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
20 (cdr (cdr defn))))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
21 (error "can't diagnose defn %s" defn))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
22 ;; array or not |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
23 (if (compiled-function-p defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
24 (fset fn (if (fboundp 'compiled-function-arglist) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
25 (progn (make-byte-code |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
26 (compiled-function-arglist defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
27 (compiled-function-instructions defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
28 (compiled-function-constants defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
29 (compiled-function-stack-depth defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
30 comment |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
31 (compiled-function-interactive defn)) defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
32 (repl-byte fn (list (cons 4 comment))))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
33 (error "unrecognised defn %s" defn))))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
34 |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
35 (defun repl-byte (fn alist) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
36 "compute a new byte-code defn for FN, replacing |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
37 elements using ALIST, which is interpreted as (index . newbit). |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
38 Elements are 0: arglist 1: byte-codes 2: symbols 3: stack-depth 4: comment" |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
39 (let |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
40 ((defn (symbol-function fn))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
41 (let ((ln (if (sequencep defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
42 (length defn) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
43 ;; hack otherwise |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
44 6)) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
45 (i 0) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
46 new entry) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
47 (apply (function make-byte-code) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
48 (progn (while (< i ln) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
49 (setq new |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
50 (cons |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
51 (if (setq entry (assoc i alist)) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
52 (cdr entry) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
53 (aref defn i)) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
54 new)) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
55 (setq i (1+ i))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
56 (nreverse new)))))) |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
57 |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
58 |
107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
59 (provide 'repl-comment) |