Function: tutorial--find-changed-keys
tutorial--find-changed-keys is a byte-compiled function defined in
tutorial.el.gz.
Signature
(tutorial--find-changed-keys DEFAULT-KEYS)
Documentation
Find the key bindings used in the tutorial that have changed.
Return a list with elements of the form
(KEY DEF-FUN DEF-FUN-TXT WHERE REMARK QUIET)
where
KEY is a key sequence whose standard binding has been changed
DEF-FUN is the standard binding of KEY
DEF-FUN-TXT is a short descriptive text for DEF-FUN
WHERE is a text describing the key sequences to which DEF-FUN is
bound now (or, if it is remapped, a key sequence
for the function it is remapped to)
REMARK is a list with info about rebinding. It has either of
these formats:
(TEXT cua-mode)
(TEXT current-binding KEY-FUN DEF-FUN KEY WHERE)
Here TEXT is a link text to show to the user. The
rest of the list is used to show information when
the user clicks the link.
KEY-FUN is the actual binding for KEY.
QUIET is t if this changed keybinding should be handled quietly.
This is used by tutorial--display-changes.
Source Code
;; Defined in /usr/src/emacs/lisp/tutorial.el.gz
(defun tutorial--find-changed-keys (default-keys)
"Find the key bindings used in the tutorial that have changed.
Return a list with elements of the form
(KEY DEF-FUN DEF-FUN-TXT WHERE REMARK QUIET)
where
KEY is a key sequence whose standard binding has been changed
DEF-FUN is the standard binding of KEY
DEF-FUN-TXT is a short descriptive text for DEF-FUN
WHERE is a text describing the key sequences to which DEF-FUN is
bound now (or, if it is remapped, a key sequence
for the function it is remapped to)
REMARK is a list with info about rebinding. It has either of
these formats:
(TEXT cua-mode)
(TEXT current-binding KEY-FUN DEF-FUN KEY WHERE)
Here TEXT is a link text to show to the user. The
rest of the list is used to show information when
the user clicks the link.
KEY-FUN is the actual binding for KEY.
QUIET is t if this changed keybinding should be handled quietly.
This is used by `tutorial--display-changes'."
(let (changed-keys remark)
;; Look up the bindings in a Fundamental mode buffer
;; so we do not get fooled by some other major mode.
(with-temp-buffer
(fundamental-mode)
(dolist (kdf default-keys)
;; The variables below corresponds to those with the same names
;; described in the doc string.
(let* ((key (nth 1 kdf))
(def-fun (nth 0 kdf))
(def-fun-txt (format "%s" def-fun))
(rem-fun (command-remapping def-fun))
;; Handle prefix definitions specially
;; so that a mode that rebinds some subcommands
;; won't make it appear that the whole prefix is gone.
(key-fun (if (keymapp def-fun)
(lookup-key global-map key)
(key-binding key)))
(where (where-is-internal (if rem-fun rem-fun def-fun)))
cwhere)
(if where
(progn
(setq cwhere (car where)
where (key-description cwhere))
(when (and (< 10 (length where))
(string= (substring where 0 (length "<menu-bar>"))
"<menu-bar>"))
(setq where
(if (and (vectorp cwhere)
(setq cwhere (elt cwhere 1))
(setq cwhere
(cadr
(assoc cwhere
(lookup-key global-map
[menu-bar]))))
(stringp cwhere))
(format-message "the `%s' menu" cwhere)
"the menus"))))
(setq where ""))
(setq remark nil)
(unless
(cond ((eq key-fun def-fun)
;; No rebinding, return t
t)
((and key-fun
(eq key-fun (command-remapping def-fun)))
;; Just a remapping, return t
t)
;; cua-mode specials:
((and cua-mode
(or (and
(equal key [?\C-v])
(eq key-fun 'cua-paste))
(and
(equal key [?\C-z])
(eq key-fun 'undo))))
(setq remark (list "cua-mode, more info" 'cua-mode))
nil)
((and cua-mode
(or (and (eq def-fun 'ESC-prefix)
(equal key-fun
'(keymap
(118 . cua-repeat-replace-region)))
(setq def-fun-txt "\"ESC prefix\""))
(and (eq def-fun 'mode-specific-command-prefix)
(equal key-fun
'(keymap
(timeout . copy-region-as-kill)))
(setq def-fun-txt "\"C-c prefix\""))
(and (eq def-fun 'Control-X-prefix)
(equal key-fun
'(keymap (timeout . kill-region)))
(setq def-fun-txt "\"C-x prefix\""))))
(setq remark (list "cua-mode replacement" 'cua-mode))
(setq where "Same key")
nil)
;; viper-mode specials:
((and (boundp 'viper-mode-string)
(boundp 'viper-current-state)
(eq viper-current-state 'vi-state)
(or (and (eq def-fun 'isearch-forward)
(eq key-fun 'viper-isearch-forward))
(and (eq def-fun 'isearch-backward)
(eq key-fun 'viper-isearch-backward))))
;; These bindings works as the default bindings,
;; return t
t)
((when normal-erase-is-backspace
(or (and (equal key [C-delete])
(equal key-fun 'kill-word))
(and (equal key [C-backspace])
(equal key-fun 'backward-kill-word))))
;; This is the strange handling of C-delete and
;; C-backspace, return t
t)
(t
;; This key has indeed been rebound. Put information
;; in `remark' and return nil
(setq remark
(list "more info" 'current-binding
key-fun def-fun key where))
nil))
(push (list key def-fun def-fun-txt where remark nil)
changed-keys)))))
changed-keys))