Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
7f2c2edd
Commit
7f2c2edd
authored
Sep 20, 1992
by
Richard M. Stallman
Browse files
entered into RCS
parent
4dcb1d26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
14 deletions
+57
-14
lisp/subr.el
lisp/subr.el
+57
-14
No files found.
lisp/subr.el
View file @
7f2c2edd
...
...
@@ -134,22 +134,65 @@ but optional second arg NODIGITS non-nil treats them like other chars."
; (copy-sequence keymap)
; (copy-alist keymap)))
(
defun
substitute-key-definition
(
olddef
newdef
keymap
)
(
defun
substitute-key-definition
(
olddef
newdef
keymap
&optional
oldmap
prefix
)
"Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF.
In other words, OLDDEF is replaced with NEWDEF where ever it appears.
Prefix keymaps reached from KEYMAP are not checked recursively;
perhaps they ought to be."
(
if
(
arrayp
keymap
)
(
let
((
len
(
length
keymap
))
(
i
0
))
(
while
(
<
i
len
)
(
if
(
eq
(
aref
keymap
i
)
olddef
)
(
aset
keymap
i
newdef
))
(
setq
i
(
1+
i
))))
(
while
keymap
(
if
(
eq
(
cdr-safe
(
car-safe
keymap
))
olddef
)
(
setcdr
(
car
keymap
)
newdef
))
(
setq
keymap
(
cdr
keymap
)))))
If optional fourth argument OLDMAP is specified, we redefine
in KEYMAP as NEWDEF those chars which are defined as OLDDEF in OLDMAP."
(
or
prefix
(
setq
prefix
""
))
(
let*
((
scan
(
or
oldmap
keymap
))
(
vec1
(
vector
nil
))
(
prefix1
(
vconcat
prefix
vec1
)))
;; Scan OLDMAP, finding each char or event-symbol that
;; has any definition, and act on it with hack-key.
(
while
(
consp
scan
)
(
if
(
consp
(
car
scan
))
(
let
((
char
(
car
(
car
scan
)))
(
defn
(
cdr
(
car
scan
))))
;; The inside of this let duplicates exactly
;; the inside of the following let that handles array elements.
(
aset
vec1
0
char
)
(
aset
prefix1
(
length
prefix
)
char
)
(
let
(
inner-def
)
;; Skip past menu-prompt.
(
while
(
stringp
(
car-safe
defn
))
(
setq
defn
(
cdr
defn
)))
(
setq
inner-def
defn
)
(
while
(
and
(
symbolp
inner-def
)
(
fboundp
inner-def
))
(
setq
inner-def
(
symbol-function
inner-def
)))
(
if
(
eq
defn
olddef
)
(
define-key
keymap
prefix1
newdef
)
(
if
(
keymapp
defn
)
(
substitute-key-definition
olddef
newdef
keymap
inner-def
prefix1
)))))
(
if
(
arrayp
(
car
scan
))
(
let*
((
array
(
car
scan
))
(
len
(
length
array
))
(
i
0
))
(
while
(
<
i
len
)
(
let
((
char
i
)
(
defn
(
aref
array
i
)))
;; The inside of this let duplicates exactly
;; the inside of the previous let.
(
aset
vec1
0
char
)
(
aset
prefix1
(
length
prefix
)
char
)
(
let
(
inner-def
)
;; Skip past menu-prompt.
(
while
(
stringp
(
car-safe
defn
))
(
setq
defn
(
cdr
defn
)))
(
setq
inner-def
defn
)
(
while
(
and
(
symbolp
inner-def
)
(
fboundp
inner-def
))
(
setq
inner-def
(
symbol-function
inner-def
)))
(
if
(
eq
defn
olddef
)
(
define-key
keymap
prefix1
newdef
)
(
if
(
keymapp
defn
)
(
substitute-key-definition
olddef
newdef
keymap
inner-def
prefix1
)))))
(
setq
i
(
1+
i
))))))
(
setq
scan
(
cdr
scan
)))))
(
defmacro
save-match-data
(
&rest
body
)
"Execute the BODY forms, restoring the global value of the match data."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment