2021-04-10 16:18:22 +00:00
|
|
|
|
;;; edmacro.el --- keyboard macro editor -*- lexical-binding: t; -*-
|
1992-07-16 21:47:34 +00:00
|
|
|
|
|
2021-01-01 09:13:56 +00:00
|
|
|
|
;; Copyright (C) 1993-1994, 2001-2021 Free Software Foundation, Inc.
|
1992-07-22 04:22:30 +00:00
|
|
|
|
|
1993-09-21 03:44:04 +00:00
|
|
|
|
;; Author: Dave Gillespie <daveg@synaptics.com>
|
1993-03-18 21:29:42 +00:00
|
|
|
|
;; Keywords: abbrev
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1990-10-22 07:14:13 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;;; Commentary:
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
1993-09-21 03:44:04 +00:00
|
|
|
|
;;; Usage:
|
|
|
|
|
;;
|
2004-12-08 01:10:13 +00:00
|
|
|
|
;; The `C-x C-k e' (`edit-kbd-macro') command edits a keyboard macro
|
1993-09-21 03:44:04 +00:00
|
|
|
|
;; in a special buffer. It prompts you to type a key sequence,
|
|
|
|
|
;; which should be one of:
|
|
|
|
|
;;
|
2003-02-04 11:26:42 +00:00
|
|
|
|
;; * RET or `C-x e' (call-last-kbd-macro), to edit the most
|
1993-09-21 03:44:04 +00:00
|
|
|
|
;; recently defined keyboard macro.
|
|
|
|
|
;;
|
|
|
|
|
;; * `M-x' followed by a command name, to edit a named command
|
|
|
|
|
;; whose definition is a keyboard macro.
|
|
|
|
|
;;
|
2008-10-11 18:43:38 +00:00
|
|
|
|
;; * `C-h l' (view-lossage), to edit the 300 most recent keystrokes
|
1993-09-21 03:44:04 +00:00
|
|
|
|
;; and install them as the "current" macro.
|
|
|
|
|
;;
|
|
|
|
|
;; * any key sequence whose definition is a keyboard macro.
|
|
|
|
|
;;
|
|
|
|
|
;; This file includes a version of `insert-kbd-macro' that uses the
|
|
|
|
|
;; more readable format defined by these routines.
|
|
|
|
|
;;
|
|
|
|
|
;; Also, the `read-kbd-macro' command parses the region as
|
|
|
|
|
;; a keyboard macro, and installs it as the "current" macro.
|
|
|
|
|
;; This and `format-kbd-macro' can also be called directly as
|
|
|
|
|
;; Lisp functions.
|
|
|
|
|
|
|
|
|
|
;; Type `C-h m', or see the documentation for `edmacro-mode' below,
|
|
|
|
|
;; for information about the format of written keyboard macros.
|
|
|
|
|
|
|
|
|
|
;; `edit-kbd-macro' formats the macro with one command per line,
|
|
|
|
|
;; including the command names as comments on the right. If the
|
|
|
|
|
;; formatter gets confused about which keymap was used for the
|
|
|
|
|
;; characters, the command-name comments will be wrong but that
|
|
|
|
|
;; won't hurt anything.
|
|
|
|
|
|
|
|
|
|
;; With a prefix argument, `edit-kbd-macro' will format the
|
|
|
|
|
;; macro in a more concise way that omits the comments.
|
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;;; Code:
|
1993-09-21 03:44:04 +00:00
|
|
|
|
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(require 'cl-lib)
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(require 'kmacro)
|
|
|
|
|
|
1990-10-22 07:14:13 +00:00
|
|
|
|
;;; The user-level commands for editing macros.
|
|
|
|
|
|
2011-02-20 00:16:54 +00:00
|
|
|
|
(defcustom edmacro-eight-bits nil
|
|
|
|
|
"Non-nil if `edit-kbd-macro' should leave 8-bit characters intact.
|
|
|
|
|
Default nil means to write characters above \\177 in octal notation."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'kmacro)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
|
2010-10-10 23:12:30 +00:00
|
|
|
|
(defvar edmacro-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
2021-04-10 16:18:22 +00:00
|
|
|
|
(define-key map "\C-c\C-c" #'edmacro-finish-edit)
|
|
|
|
|
(define-key map "\C-c\C-q" #'edmacro-insert-key)
|
2010-10-10 23:12:30 +00:00
|
|
|
|
map))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
|
1996-02-02 06:13:55 +00:00
|
|
|
|
(defvar edmacro-store-hook)
|
|
|
|
|
(defvar edmacro-finish-hook)
|
|
|
|
|
(defvar edmacro-original-buffer)
|
|
|
|
|
|
1991-05-09 21:50:55 +00:00
|
|
|
|
;;;###autoload
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(defun edit-kbd-macro (keys &optional prefix finish-hook store-hook)
|
|
|
|
|
"Edit a keyboard macro.
|
|
|
|
|
At the prompt, type any key sequence which is bound to a keyboard macro.
|
2017-11-27 00:16:16 +00:00
|
|
|
|
Or, type `\\[kmacro-end-and-call-macro]' or RET to edit the last
|
|
|
|
|
keyboard macro, `\\[view-lossage]' to edit the last 300
|
|
|
|
|
keystrokes as a keyboard macro, or `\\[execute-extended-command]'
|
|
|
|
|
to edit a macro by its command name.
|
1993-09-21 03:44:04 +00:00
|
|
|
|
With a prefix argument, format the macro in a more concise way."
|
2017-11-27 00:16:16 +00:00
|
|
|
|
(interactive
|
|
|
|
|
(list (read-key-sequence (substitute-command-keys "Keyboard macro to edit \
|
|
|
|
|
\(\\[kmacro-end-and-call-macro], \\[execute-extended-command], \\[view-lossage],\
|
|
|
|
|
or keys): "))
|
|
|
|
|
current-prefix-arg))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(when keys
|
|
|
|
|
(let ((cmd (if (arrayp keys) (key-binding keys) keys))
|
2017-11-27 00:16:16 +00:00
|
|
|
|
(cmd-noremap (when (arrayp keys) (key-binding keys nil t)))
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(mac nil) (mac-counter nil) (mac-format nil)
|
|
|
|
|
kmacro)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(cond (store-hook
|
|
|
|
|
(setq mac keys)
|
|
|
|
|
(setq cmd nil))
|
2017-11-27 00:16:16 +00:00
|
|
|
|
((or (memq cmd '(call-last-kbd-macro kmacro-call-macro kmacro-end-or-call-macro kmacro-end-and-call-macro))
|
|
|
|
|
(memq cmd-noremap '(call-last-kbd-macro kmacro-call-macro kmacro-end-or-call-macro kmacro-end-and-call-macro))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(member keys '("\r" [return])))
|
|
|
|
|
(or last-kbd-macro
|
2021-09-22 18:26:40 +00:00
|
|
|
|
(y-or-n-p "No keyboard macro defined. Create one?")
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(keyboard-quit))
|
|
|
|
|
(setq mac (or last-kbd-macro ""))
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(setq keys nil)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(setq cmd 'last-kbd-macro))
|
2017-11-27 00:16:16 +00:00
|
|
|
|
((memq 'execute-extended-command (list cmd cmd-noremap))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(setq cmd (read-command "Name of keyboard macro to edit: "))
|
1996-01-28 03:07:15 +00:00
|
|
|
|
(if (string-equal cmd "")
|
|
|
|
|
(error "No command name given"))
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(setq keys nil)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(setq mac (symbol-function cmd)))
|
2017-11-27 00:16:16 +00:00
|
|
|
|
((or (memq cmd '(view-lossage electric-view-lossage))
|
|
|
|
|
(memq cmd-noremap '(view-lossage electric-view-lossage)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(setq mac (recent-keys))
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(setq keys nil)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(setq cmd 'last-kbd-macro))
|
1995-05-22 22:08:18 +00:00
|
|
|
|
((null cmd)
|
|
|
|
|
(error "Key sequence %s is not defined" (key-description keys)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
((symbolp cmd)
|
|
|
|
|
(setq mac (symbol-function cmd)))
|
|
|
|
|
(t
|
|
|
|
|
(setq mac cmd)
|
|
|
|
|
(setq cmd nil)))
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(when (setq kmacro (kmacro-extract-lambda mac))
|
|
|
|
|
(setq mac (car kmacro)
|
|
|
|
|
mac-counter (nth 1 kmacro)
|
|
|
|
|
mac-format (nth 2 kmacro)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(unless (arrayp mac)
|
1995-05-22 22:08:18 +00:00
|
|
|
|
(error "Key sequence %s is not a keyboard macro"
|
|
|
|
|
(key-description keys)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(message "Formatting keyboard macro...")
|
|
|
|
|
(let* ((oldbuf (current-buffer))
|
|
|
|
|
(mmac (edmacro-fix-menu-commands mac))
|
|
|
|
|
(fmt (edmacro-format-keys mmac 1))
|
|
|
|
|
(fmtv (edmacro-format-keys mmac (not prefix)))
|
|
|
|
|
(buf (get-buffer-create "*Edit Macro*")))
|
|
|
|
|
(message "Formatting keyboard macro...done")
|
|
|
|
|
(switch-to-buffer buf)
|
|
|
|
|
(kill-all-local-variables)
|
|
|
|
|
(use-local-map edmacro-mode-map)
|
|
|
|
|
(setq buffer-read-only nil)
|
|
|
|
|
(setq major-mode 'edmacro-mode)
|
|
|
|
|
(setq mode-name "Edit Macro")
|
2020-12-09 08:44:38 +00:00
|
|
|
|
(setq-local edmacro-original-buffer oldbuf)
|
|
|
|
|
(setq-local edmacro-finish-hook finish-hook)
|
|
|
|
|
(setq-local edmacro-store-hook store-hook)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(erase-buffer)
|
|
|
|
|
(insert ";; Keyboard Macro Editor. Press C-c C-c to finish; "
|
|
|
|
|
"press C-x k RET to cancel.\n")
|
|
|
|
|
(insert ";; Original keys: " fmt "\n")
|
|
|
|
|
(unless store-hook
|
|
|
|
|
(insert "\nCommand: " (if cmd (symbol-name cmd) "none") "\n")
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(let ((gkeys (where-is-internal (or cmd mac) '(keymap))))
|
|
|
|
|
(if (and keys (not (member keys gkeys)))
|
|
|
|
|
(setq gkeys (cons keys gkeys)))
|
|
|
|
|
(if gkeys
|
|
|
|
|
(while gkeys
|
|
|
|
|
(insert "Key: " (edmacro-format-keys (pop gkeys) 1) "\n"))
|
|
|
|
|
(insert "Key: none\n")))
|
|
|
|
|
(when (and mac-counter mac-format)
|
|
|
|
|
(insert (format "Counter: %d\nFormat: \"%s\"\n" mac-counter mac-format))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(insert "\nMacro:\n\n")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(insert fmtv "\n"))
|
|
|
|
|
(recenter '(4))
|
|
|
|
|
(when (eq mac mmac)
|
|
|
|
|
(set-buffer-modified-p nil))
|
|
|
|
|
(run-hooks 'edmacro-format-hook)))))
|
|
|
|
|
|
2021-04-10 16:18:22 +00:00
|
|
|
|
;; The next two commands are provided for convenience and backward
|
|
|
|
|
;; compatibility.
|
1993-09-21 03:44:04 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun edit-last-kbd-macro (&optional prefix)
|
1990-10-22 07:14:13 +00:00
|
|
|
|
"Edit the most recently defined keyboard macro."
|
|
|
|
|
(interactive "P")
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(edit-kbd-macro 'call-last-kbd-macro prefix))
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
1991-05-09 21:50:55 +00:00
|
|
|
|
;;;###autoload
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(defun edit-named-kbd-macro (&optional prefix)
|
|
|
|
|
"Edit a keyboard macro which has been given a name by `name-last-kbd-macro'."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(edit-kbd-macro 'execute-extended-command prefix))
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
1991-05-09 21:50:55 +00:00
|
|
|
|
;;;###autoload
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(defun read-kbd-macro (start &optional end)
|
1990-10-22 07:14:13 +00:00
|
|
|
|
"Read the region as a keyboard macro definition.
|
1991-02-28 19:32:54 +00:00
|
|
|
|
The region is interpreted as spelled-out keystrokes, e.g., \"M-x abc RET\".
|
1993-09-21 03:44:04 +00:00
|
|
|
|
See documentation for `edmacro-mode' for details.
|
|
|
|
|
Leading/trailing \"C-x (\" and \"C-x )\" in the text are allowed and ignored.
|
1990-10-22 07:14:13 +00:00
|
|
|
|
The resulting macro is installed as the \"current\" keyboard macro.
|
|
|
|
|
|
1993-09-21 03:44:04 +00:00
|
|
|
|
In Lisp, may also be called with a single STRING argument in which case
|
|
|
|
|
the result is returned rather than being installed as the current macro.
|
|
|
|
|
The result will be a string if possible, otherwise an event vector.
|
|
|
|
|
Second argument NEED-VECTOR means to return an event vector always."
|
1990-10-22 07:14:13 +00:00
|
|
|
|
(interactive "r")
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(if (stringp start)
|
|
|
|
|
(edmacro-parse-keys start end)
|
|
|
|
|
(setq last-kbd-macro (edmacro-parse-keys (buffer-substring start end)))))
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
1993-09-21 03:44:04 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun format-kbd-macro (&optional macro verbose)
|
|
|
|
|
"Return the keyboard macro MACRO as a human-readable string.
|
|
|
|
|
This string is suitable for passing to `read-kbd-macro'.
|
|
|
|
|
Second argument VERBOSE means to put one command per line with comments.
|
|
|
|
|
If VERBOSE is `1', put everything on one line. If VERBOSE is omitted
|
|
|
|
|
or nil, use a compact 80-column format."
|
|
|
|
|
(and macro (symbolp macro) (setq macro (symbol-function macro)))
|
|
|
|
|
(edmacro-format-keys (or macro last-kbd-macro) verbose))
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
1993-09-21 03:44:04 +00:00
|
|
|
|
;;; Commands for *Edit Macro* buffer.
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
|
|
|
|
(defun edmacro-finish-edit ()
|
|
|
|
|
(interactive)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(unless (eq major-mode 'edmacro-mode)
|
|
|
|
|
(error
|
|
|
|
|
"This command is valid only in buffers created by `edit-kbd-macro'"))
|
|
|
|
|
(run-hooks 'edmacro-finish-hook)
|
|
|
|
|
(let ((cmd nil) (keys nil) (no-keys nil)
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(mac-counter nil) (mac-format nil)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(top (point-min)))
|
|
|
|
|
(goto-char top)
|
|
|
|
|
(let ((case-fold-search nil))
|
|
|
|
|
(while (cond ((looking-at "[ \t]*\\($\\|;;\\|REM[ \t\n]\\)")
|
|
|
|
|
t)
|
|
|
|
|
((looking-at "Command:[ \t]*\\([^ \t\n]*\\)[ \t]*$")
|
|
|
|
|
(when edmacro-store-hook
|
|
|
|
|
(error "\"Command\" line not allowed in this context"))
|
2021-04-10 16:18:22 +00:00
|
|
|
|
(let ((str (match-string 1)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(unless (equal str "")
|
1995-08-27 17:50:39 +00:00
|
|
|
|
(setq cmd (and (not (equal str "none"))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(intern str)))
|
|
|
|
|
(and (fboundp cmd) (not (arrayp (symbol-function cmd)))
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(not (get cmd 'kmacro))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(not (y-or-n-p
|
2021-09-22 18:26:40 +00:00
|
|
|
|
(format
|
|
|
|
|
"Command %s is already defined; proceed?"
|
|
|
|
|
cmd)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(keyboard-quit))))
|
|
|
|
|
t)
|
|
|
|
|
((looking-at "Key:\\(.*\\)$")
|
|
|
|
|
(when edmacro-store-hook
|
|
|
|
|
(error "\"Key\" line not allowed in this context"))
|
|
|
|
|
(let ((key (edmacro-parse-keys
|
2021-04-10 16:18:22 +00:00
|
|
|
|
(match-string 1))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(unless (equal key "")
|
1995-08-27 17:50:39 +00:00
|
|
|
|
(if (equal key "none")
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(setq no-keys t)
|
|
|
|
|
(push key keys)
|
|
|
|
|
(let ((b (key-binding key)))
|
|
|
|
|
(and b (commandp b) (not (arrayp b))
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(not (kmacro-extract-lambda b))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(or (not (fboundp b))
|
2004-12-08 01:10:13 +00:00
|
|
|
|
(not (or (arrayp (symbol-function b))
|
|
|
|
|
(get b 'kmacro))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(not (y-or-n-p
|
2021-09-22 18:26:40 +00:00
|
|
|
|
(format
|
|
|
|
|
"Key %s is already defined; proceed?"
|
|
|
|
|
(edmacro-format-keys key 1))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(keyboard-quit))))))
|
|
|
|
|
t)
|
2004-09-30 13:27:35 +00:00
|
|
|
|
((looking-at "Counter:[ \t]*\\([^ \t\n]*\\)[ \t]*$")
|
|
|
|
|
(when edmacro-store-hook
|
|
|
|
|
(error "\"Counter\" line not allowed in this context"))
|
2021-04-10 16:18:22 +00:00
|
|
|
|
(let ((str (match-string 1)))
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(unless (equal str "")
|
2005-05-16 11:34:49 +00:00
|
|
|
|
(setq mac-counter (string-to-number str))))
|
2004-09-30 13:27:35 +00:00
|
|
|
|
t)
|
|
|
|
|
((looking-at "Format:[ \t]*\"\\([^\n]*\\)\"[ \t]*$")
|
|
|
|
|
(when edmacro-store-hook
|
|
|
|
|
(error "\"Format\" line not allowed in this context"))
|
2021-04-10 16:18:22 +00:00
|
|
|
|
(let ((str (match-string 1)))
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(unless (equal str "")
|
|
|
|
|
(setq mac-format str)))
|
|
|
|
|
t)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
((looking-at "Macro:[ \t\n]*")
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
nil)
|
|
|
|
|
((eobp) nil)
|
|
|
|
|
(t (error "Expected a `Macro:' line")))
|
|
|
|
|
(forward-line 1))
|
|
|
|
|
(setq top (point)))
|
|
|
|
|
(let* ((buf (current-buffer))
|
|
|
|
|
(str (buffer-substring top (point-max)))
|
|
|
|
|
(modp (buffer-modified-p))
|
|
|
|
|
(obuf edmacro-original-buffer)
|
|
|
|
|
(store-hook edmacro-store-hook)
|
|
|
|
|
(finish-hook edmacro-finish-hook))
|
|
|
|
|
(unless (or cmd keys store-hook (equal str ""))
|
|
|
|
|
(error "No command name or keys specified"))
|
|
|
|
|
(when modp
|
|
|
|
|
(when (buffer-name obuf)
|
|
|
|
|
(set-buffer obuf))
|
|
|
|
|
(message "Compiling keyboard macro...")
|
|
|
|
|
(let ((mac (edmacro-parse-keys str)))
|
|
|
|
|
(message "Compiling keyboard macro...done")
|
|
|
|
|
(if store-hook
|
|
|
|
|
(funcall store-hook mac)
|
|
|
|
|
(when (eq cmd 'last-kbd-macro)
|
|
|
|
|
(setq last-kbd-macro (and (> (length mac) 0) mac))
|
|
|
|
|
(setq cmd nil))
|
|
|
|
|
(when cmd
|
|
|
|
|
(if (= (length mac) 0)
|
|
|
|
|
(fmakunbound cmd)
|
2004-09-30 13:27:35 +00:00
|
|
|
|
(fset cmd
|
|
|
|
|
(if (and mac-counter mac-format)
|
|
|
|
|
(kmacro-lambda-form mac mac-counter mac-format)
|
|
|
|
|
mac))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(if no-keys
|
|
|
|
|
(when cmd
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-loop for key in (where-is-internal cmd '(keymap)) do
|
|
|
|
|
(global-unset-key key)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(when keys
|
|
|
|
|
(if (= (length mac) 0)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-loop for key in keys do (global-unset-key key))
|
|
|
|
|
(cl-loop for key in keys do
|
|
|
|
|
(global-set-key key
|
|
|
|
|
(or cmd
|
|
|
|
|
(if (and mac-counter mac-format)
|
|
|
|
|
(kmacro-lambda-form
|
|
|
|
|
mac mac-counter mac-format)
|
|
|
|
|
mac))))))))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(kill-buffer buf)
|
|
|
|
|
(when (buffer-name obuf)
|
|
|
|
|
(switch-to-buffer obuf))
|
|
|
|
|
(when finish-hook
|
|
|
|
|
(funcall finish-hook)))))
|
|
|
|
|
|
|
|
|
|
(defun edmacro-insert-key (key)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Insert the written name of a KEY in the buffer."
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(interactive "kKey to insert: ")
|
|
|
|
|
(if (bolp)
|
|
|
|
|
(insert (edmacro-format-keys key t) "\n")
|
|
|
|
|
(insert (edmacro-format-keys key) " ")))
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
|
|
|
|
(defun edmacro-mode ()
|
2008-10-23 23:52:14 +00:00
|
|
|
|
"\\<edmacro-mode-map>Keyboard Macro Editing mode. Press \
|
1993-09-21 03:44:04 +00:00
|
|
|
|
\\[edmacro-finish-edit] to save and exit.
|
1991-02-28 19:32:54 +00:00
|
|
|
|
To abort the edit, just kill this buffer with \\[kill-buffer] RET.
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
1993-09-21 03:44:04 +00:00
|
|
|
|
Press \\[edmacro-insert-key] to insert the name of any key by typing the key.
|
|
|
|
|
|
|
|
|
|
The editing buffer contains a \"Command:\" line and any number of
|
|
|
|
|
\"Key:\" lines at the top. These are followed by a \"Macro:\" line
|
|
|
|
|
and the macro itself as spelled-out keystrokes: `C-x C-f foo RET'.
|
|
|
|
|
|
|
|
|
|
The \"Command:\" line specifies the command name to which the macro
|
|
|
|
|
is bound, or \"none\" for no command name. Write \"last-kbd-macro\"
|
|
|
|
|
to refer to the current keyboard macro (as used by \\[call-last-kbd-macro]).
|
|
|
|
|
|
|
|
|
|
The \"Key:\" lines specify key sequences to which the macro is bound,
|
|
|
|
|
or \"none\" for no key bindings.
|
|
|
|
|
|
|
|
|
|
You can edit these lines to change the places where the new macro
|
|
|
|
|
is stored.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Format of keyboard macros during editing:
|
|
|
|
|
|
|
|
|
|
Text is divided into \"words\" separated by whitespace. Except for
|
|
|
|
|
the words described below, the characters of each word go directly
|
|
|
|
|
as characters of the macro. The whitespace that separates words
|
|
|
|
|
is ignored. Whitespace in the macro must be written explicitly,
|
|
|
|
|
as in \"foo SPC bar RET\".
|
|
|
|
|
|
|
|
|
|
* The special words RET, SPC, TAB, DEL, LFD, ESC, and NUL represent
|
|
|
|
|
special control characters. The words must be written in uppercase.
|
|
|
|
|
|
|
|
|
|
* A word in angle brackets, e.g., <return>, <down>, or <f1>, represents
|
|
|
|
|
a function key. (Note that in the standard configuration, the
|
|
|
|
|
function key <return> and the control key RET are synonymous.)
|
|
|
|
|
You can use angle brackets on the words RET, SPC, etc., but they
|
|
|
|
|
are not required there.
|
|
|
|
|
|
|
|
|
|
* Keys can be written by their ASCII code, using a backslash followed
|
|
|
|
|
by up to six octal digits. This is the only way to represent keys
|
|
|
|
|
with codes above \\377.
|
|
|
|
|
|
|
|
|
|
* One or more prefixes M- (meta), C- (control), S- (shift), A- (alt),
|
|
|
|
|
H- (hyper), and s- (super) may precede a character or key notation.
|
|
|
|
|
For function keys, the prefixes may go inside or outside of the
|
|
|
|
|
brackets: C-<down> = <C-down>. The prefixes may be written in
|
|
|
|
|
any order: M-C-x = C-M-x.
|
|
|
|
|
|
|
|
|
|
Prefixes are not allowed on multi-key words, e.g., C-abc, except
|
|
|
|
|
that the Meta prefix is allowed on a sequence of digits and optional
|
|
|
|
|
minus sign: M--123 = M-- M-1 M-2 M-3.
|
|
|
|
|
|
|
|
|
|
* The `^' notation for control characters also works: ^M = C-m.
|
|
|
|
|
|
|
|
|
|
* Double angle brackets enclose command names: <<next-line>> is
|
|
|
|
|
shorthand for M-x next-line RET.
|
|
|
|
|
|
|
|
|
|
* Finally, REM or ;; causes the rest of the line to be ignored as a
|
|
|
|
|
comment.
|
|
|
|
|
|
|
|
|
|
Any word may be prefixed by a multiplier in the form of a decimal
|
|
|
|
|
number and `*': 3*<right> = <right> <right> <right>, and
|
|
|
|
|
10*foo = foofoofoofoofoofoofoofoofoofoo.
|
|
|
|
|
|
|
|
|
|
Multiple text keys can normally be strung together to form a word,
|
|
|
|
|
but you may need to add whitespace if the word would look like one
|
|
|
|
|
of the above notations: `; ; ;' is a keyboard macro with three
|
|
|
|
|
semicolons, but `;;;' is a comment. Likewise, `\\ 1 2 3' is four
|
|
|
|
|
keys but `\\123' is a single key written in octal, and `< right >'
|
|
|
|
|
is seven keys but `<right>' is a single function key. When in
|
|
|
|
|
doubt, use whitespace."
|
1990-10-22 07:14:13 +00:00
|
|
|
|
(interactive)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(error "This mode can be enabled only by `edit-kbd-macro'"))
|
1990-10-22 07:14:13 +00:00
|
|
|
|
(put 'edmacro-mode 'mode-class 'special)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
|
|
|
|
|
;;; Formatting a keyboard macro as human-readable text.
|
1990-10-22 07:14:13 +00:00
|
|
|
|
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(defun edmacro-format-keys (macro &optional verbose)
|
|
|
|
|
(setq macro (edmacro-fix-menu-commands macro))
|
2007-05-25 16:43:24 +00:00
|
|
|
|
(let* ((maps (current-active-maps))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(pkeys '(end-macro ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?- ?\C-u
|
|
|
|
|
?\M-- ?\M-0 ?\M-1 ?\M-2 ?\M-3 ?\M-4 ?\M-5 ?\M-6
|
|
|
|
|
?\M-7 ?\M-8 ?\M-9))
|
|
|
|
|
(mdigs (nthcdr 13 pkeys))
|
|
|
|
|
(maxkey (if edmacro-eight-bits 255 127))
|
|
|
|
|
(case-fold-search nil)
|
|
|
|
|
(res-words '("NUL" "TAB" "LFD" "RET" "ESC" "SPC" "DEL" "REM"))
|
|
|
|
|
(rest-mac (vconcat macro [end-macro]))
|
|
|
|
|
(res "")
|
|
|
|
|
(len 0)
|
|
|
|
|
(one-line (eq verbose 1)))
|
|
|
|
|
(if one-line (setq verbose nil))
|
|
|
|
|
(when (stringp macro)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-loop for i below (length macro) do
|
|
|
|
|
(when (>= (aref rest-mac i) 128)
|
|
|
|
|
(cl-incf (aref rest-mac i) (- ?\M-\^@ 128)))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(while (not (eq (aref rest-mac 0) 'end-macro))
|
|
|
|
|
(let* ((prefix
|
|
|
|
|
(or (and (integerp (aref rest-mac 0))
|
|
|
|
|
(memq (aref rest-mac 0) mdigs)
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(memq (key-binding (cl-subseq rest-mac 0 1))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
'(digit-argument negative-argument))
|
|
|
|
|
(let ((i 1))
|
|
|
|
|
(while (memq (aref rest-mac i) (cdr mdigs))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-incf i))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(and (not (memq (aref rest-mac i) pkeys))
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(prog1 (vconcat "M-" (cl-subseq rest-mac 0 i) " ")
|
|
|
|
|
(cl-callf cl-subseq rest-mac i)))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(and (eq (aref rest-mac 0) ?\C-u)
|
|
|
|
|
(eq (key-binding [?\C-u]) 'universal-argument)
|
|
|
|
|
(let ((i 1))
|
|
|
|
|
(while (eq (aref rest-mac i) ?\C-u)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-incf i))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(and (not (memq (aref rest-mac i) pkeys))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(prog1 (cl-loop repeat i concat "C-u ")
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(cl-callf cl-subseq rest-mac i)))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(and (eq (aref rest-mac 0) ?\C-u)
|
|
|
|
|
(eq (key-binding [?\C-u]) 'universal-argument)
|
|
|
|
|
(let ((i 1))
|
|
|
|
|
(when (eq (aref rest-mac i) ?-)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-incf i))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(while (memq (aref rest-mac i)
|
|
|
|
|
'(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-incf i))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(and (not (memq (aref rest-mac i) pkeys))
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(prog1 (vconcat "C-u " (cl-subseq rest-mac 1 i) " ")
|
|
|
|
|
(cl-callf cl-subseq rest-mac i)))))))
|
2021-04-10 16:18:22 +00:00
|
|
|
|
(bind-len (apply #'max 1
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-loop for map in maps
|
|
|
|
|
for b = (lookup-key map rest-mac)
|
|
|
|
|
when b collect b)))
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(key (cl-subseq rest-mac 0 bind-len))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(fkey nil) tlen tkey
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(bind (or (cl-loop for map in maps for b = (lookup-key map key)
|
|
|
|
|
thereis (and (not (integerp b)) b))
|
2005-10-29 11:50:12 +00:00
|
|
|
|
(and (setq fkey (lookup-key local-function-key-map rest-mac))
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(setq tlen fkey tkey (cl-subseq rest-mac 0 tlen)
|
2005-10-29 11:50:12 +00:00
|
|
|
|
fkey (lookup-key local-function-key-map tkey))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-loop for map in maps
|
|
|
|
|
for b = (lookup-key map fkey)
|
|
|
|
|
when (and (not (integerp b)) b)
|
|
|
|
|
do (setq bind-len tlen key tkey)
|
|
|
|
|
and return b
|
|
|
|
|
finally do (setq fkey nil)))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(first (aref key 0))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(text
|
|
|
|
|
(cl-loop for i from bind-len below (length rest-mac)
|
|
|
|
|
for ch = (aref rest-mac i)
|
|
|
|
|
while (and (integerp ch)
|
|
|
|
|
(> ch 32) (< ch maxkey) (/= ch 92)
|
|
|
|
|
(eq (key-binding (char-to-string ch))
|
|
|
|
|
'self-insert-command)
|
|
|
|
|
(or (> i (- (length rest-mac) 2))
|
|
|
|
|
(not (eq ch (aref rest-mac (+ i 1))))
|
|
|
|
|
(not (eq ch (aref rest-mac (+ i 2))))))
|
|
|
|
|
finally return i))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
desc)
|
|
|
|
|
(if (stringp bind) (setq bind nil))
|
2021-04-10 16:18:22 +00:00
|
|
|
|
(cond ((and (eq bind #'self-insert-command) (not prefix)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(> text 1) (integerp first)
|
|
|
|
|
(> first 32) (<= first maxkey) (/= first 92)
|
|
|
|
|
(progn
|
|
|
|
|
(if (> text 30) (setq text 30))
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(setq desc (concat (cl-subseq rest-mac 0 text)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(when (string-match "^[ACHMsS]-." desc)
|
|
|
|
|
(setq text 2)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-callf substring desc 0 2))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(not (string-match
|
|
|
|
|
"^;;\\|^<.*>$\\|^\\\\[0-9]+$\\|^[0-9]+\\*."
|
|
|
|
|
desc))))
|
|
|
|
|
(when (or (string-match "^\\^.$" desc)
|
|
|
|
|
(member desc res-words))
|
2021-04-10 16:18:22 +00:00
|
|
|
|
(setq desc (mapconcat #'char-to-string desc " ")))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(when verbose
|
|
|
|
|
(setq bind (format "%s * %d" bind text)))
|
|
|
|
|
(setq bind-len text))
|
2021-04-10 16:18:22 +00:00
|
|
|
|
((and (eq bind #'execute-extended-command)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(> text bind-len)
|
|
|
|
|
(memq (aref rest-mac text) '(return 13))
|
|
|
|
|
(progn
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(setq desc (concat (cl-subseq rest-mac bind-len text)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(commandp (intern-soft desc))))
|
|
|
|
|
(if (commandp (intern-soft desc)) (setq bind desc))
|
|
|
|
|
(setq desc (format "<<%s>>" desc))
|
|
|
|
|
(setq bind-len (1+ text)))
|
|
|
|
|
(t
|
|
|
|
|
(setq desc (mapconcat
|
2020-11-17 17:42:38 +00:00
|
|
|
|
(lambda (ch)
|
|
|
|
|
(cond
|
|
|
|
|
((integerp ch)
|
|
|
|
|
(concat
|
|
|
|
|
(cl-loop for pf across "ACHMsS"
|
|
|
|
|
for bit in '(?\A-\^@ ?\C-\^@ ?\H-\^@
|
|
|
|
|
?\M-\^@ ?\s-\^@ ?\S-\^@)
|
|
|
|
|
when (/= (logand ch bit) 0)
|
|
|
|
|
concat (format "%c-" pf))
|
|
|
|
|
(let ((ch2 (logand ch (1- (ash 1 18)))))
|
|
|
|
|
(cond ((<= ch2 32)
|
|
|
|
|
(pcase ch2
|
|
|
|
|
(0 "NUL") (9 "TAB") (10 "LFD")
|
|
|
|
|
(13 "RET") (27 "ESC") (32 "SPC")
|
|
|
|
|
(_
|
|
|
|
|
(format "C-%c"
|
|
|
|
|
(+ (if (<= ch2 26) 96 64)
|
|
|
|
|
ch2)))))
|
|
|
|
|
((= ch2 127) "DEL")
|
|
|
|
|
((<= ch2 maxkey) (char-to-string ch2))
|
|
|
|
|
(t (format "\\%o" ch2))))))
|
|
|
|
|
((symbolp ch)
|
|
|
|
|
(format "<%s>" ch))
|
|
|
|
|
(t
|
|
|
|
|
(error "Unrecognized item in macro: %s" ch))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(or fkey key) " "))))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(if prefix
|
|
|
|
|
(setq desc (concat (edmacro-sanitize-for-string prefix) desc)))
|
Use string-search instead of string-match[-p]
`string-search` is easier to understand, less error-prone, much
faster, does not pollute the regexp cache, and does not mutate global
state. Use it where applicable and obviously safe (erring on the
conservative side).
* admin/authors.el (authors-canonical-file-name)
(authors-scan-change-log):
* lisp/apropos.el (apropos-command)
(apropos-documentation-property, apropos-symbols-internal):
* lisp/arc-mode.el (archive-arc-summarize)
(archive-zoo-summarize):
* lisp/calc/calc-aent.el (math-read-factor):
* lisp/calc/calc-ext.el (math-read-big-expr)
(math-format-nice-expr, math-format-number-fancy):
* lisp/calc/calc-forms.el (math-read-angle-brackets):
* lisp/calc/calc-graph.el (calc-graph-set-range):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/calc/calc-lang.el (tex, latex, math-read-big-rec):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-user-define-permanent, math-define-exp):
* lisp/calc/calc.el (calc-record, calcDigit-key)
(calc-count-lines):
* lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots)
(math-do-integral):
* lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum)
(calc-get-fit-variables):
* lisp/cedet/ede/speedbar.el (ede-tag-expand):
* lisp/cedet/semantic/java.el (semantic-java-expand-tag):
* lisp/cedet/semantic/sb.el (semantic-sb-show-extra)
(semantic-sb-expand-group):
* lisp/cedet/semantic/wisent/python.el
(semantic-python-instance-variable-p):
* lisp/cus-edit.el (get):
* lisp/descr-text.el (describe-text-sexp):
* lisp/dired-aux.el (dired-compress-file):
* lisp/dired-x.el (dired-make-relative-symlink):
* lisp/dired.el (dired-glob-regexp):
* lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename):
* lisp/edmacro.el (edmacro-format-keys):
* lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand):
* lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand):
* lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/emulation/viper-ex.el (viper-ex-read-file-name)
(ex-print-display-lines):
* lisp/env.el (read-envvar-name, setenv):
* lisp/epa-mail.el (epa-mail-encrypt):
* lisp/epg.el (epg--start):
* lisp/erc/erc-backend.el (erc-parse-server-response):
* lisp/erc/erc-dcc.el (erc-dcc-member):
* lisp/erc/erc-speedbar.el (erc-speedbar-expand-server)
(erc-speedbar-expand-channel, erc-speedbar-expand-user):
* lisp/erc/erc.el (erc-send-input):
* lisp/eshell/em-glob.el (eshell-glob-entries):
* lisp/eshell/esh-proc.el (eshell-needs-pipe-p):
* lisp/eshell/esh-util.el (eshell-convert):
* lisp/eshell/esh-var.el (eshell-envvar-names):
* lisp/faces.el (x-resolve-font-name):
* lisp/ffap.el (ffap-file-at-point):
* lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern):
* lisp/forms.el (forms--update):
* lisp/frameset.el (frameset-filter-unshelve-param):
* lisp/gnus/gnus-art.el (article-decode-charset):
* lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc)
(gnus-inews-insert-gcc):
* lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body):
* lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output)
(gnus-search--complete-key-data):
* lisp/gnus/gnus-spec.el (gnus-parse-simple-format):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-extract-address-components)
(gnus-newsgroup-directory-form):
* lisp/gnus/gnus-uu.el (gnus-uu-grab-view):
* lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name):
* lisp/gnus/message.el (message-check-news-header-syntax)
(message-make-message-id, message-user-mail-address)
(message-make-fqdn, message-get-reply-headers, message-followup):
* lisp/gnus/mm-decode.el (mm-dissect-buffer):
* lisp/gnus/nnheader.el (nnheader-insert):
* lisp/gnus/nnimap.el (nnimap-process-quirk)
(nnimap-imap-ranges-to-gnus-ranges):
* lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix):
* lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path):
* lisp/gnus/nnrss.el (nnrss-match-macro):
* lisp/gnus/nntp.el (nntp-find-group-and-number):
* lisp/help-fns.el (help--symbol-completion-table-affixation):
* lisp/help.el (help-function-arglist):
* lisp/hippie-exp.el (he-concat-directory-file-name):
* lisp/htmlfontify.el (hfy-relstub):
* lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word)
(ido-exhibit):
* lisp/image/image-converter.el (image-convert-p):
* lisp/info-xref.el (info-xref-docstrings):
* lisp/info.el (Info-toc-build, Info-follow-reference)
(Info-backward-node, Info-finder-find-node)
(Info-speedbar-expand-node):
* lisp/international/mule-diag.el (print-fontset-element):
* lisp/language/korea-util.el (default-korean-keyboard):
* lisp/linum.el (linum-after-change):
* lisp/mail/ietf-drums.el (ietf-drums-parse-address):
* lisp/mail/mail-utils.el (mail-dont-reply-to):
* lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rmailkwd.el (rmail-set-label):
* lisp/mail/rmailsum.el (rmail-header-summary):
* lisp/mail/smtpmail.el (smtpmail-maybe-append-domain)
(smtpmail-user-mail-address):
* lisp/mail/uce.el (uce-reply-to-uce):
* lisp/man.el (Man-default-man-entry):
* lisp/mh-e/mh-alias.el (mh-alias-gecos-name)
(mh-alias-minibuffer-confirm-address):
* lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject):
* lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output):
* lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter)
(mh-folder-completion-function):
* lisp/minibuffer.el (completion--make-envvar-table)
(completion-file-name-table, completion-flex-try-completion)
(completion-flex-all-completions):
* lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p)
(mpc-constraints-tag-lookup):
* lisp/net/ange-ftp.el (ange-ftp-send-cmd)
(ange-ftp-allow-child-lookup):
* lisp/net/mailcap.el (mailcap-mime-types):
* lisp/net/mairix.el (mairix-search-thread-this-article):
* lisp/net/pop3.el (pop3-open-server):
* lisp/net/soap-client.el (soap-decode-xs-complex-type):
* lisp/net/socks.el (socks-filter):
* lisp/nxml/nxml-outln.el (nxml-highlighted-qname):
* lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype):
* lisp/nxml/rng-uri.el (rng-uri-file-name-1):
* lisp/obsolete/complete.el (partial-completion-mode)
(PC-do-completion):
* lisp/obsolete/longlines.el (longlines-encode-string):
* lisp/obsolete/nnir.el (nnir-compose-result):
* lisp/obsolete/terminal.el (te-quote-arg-for-sh):
* lisp/obsolete/tpu-edt.el (tpu-check-search-case):
* lisp/obsolete/url-ns.el (isPlainHostName):
* lisp/pcmpl-unix.el (pcomplete/scp):
* lisp/play/dunnet.el (dun-listify-string2, dun-get-path)
(dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface):
* lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment):
* lisp/progmodes/gdb-mi.el (gdb-var-delete)
(gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result):
* lisp/progmodes/gud.el (gud-find-expr):
* lisp/progmodes/idlw-help.el (idlwave-do-context-help1):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode)
(idlwave-shell-filter-hidden-output, idlwave-shell-filter):
* lisp/progmodes/idlwave.el (idlwave-skip-label-or-case)
(idlwave-routine-info):
* lisp/progmodes/octave.el (inferior-octave-completion-at-point):
* lisp/progmodes/sh-script.el (sh-add-completer):
* lisp/progmodes/sql.el (defun):
* lisp/progmodes/xscheme.el (xscheme-process-filter):
* lisp/replace.el (query-replace-compile-replacement)
(map-query-replace-regexp):
* lisp/shell.el (shell--command-completion-data)
(shell-environment-variable-completion):
* lisp/simple.el (display-message-or-buffer):
* lisp/speedbar.el (speedbar-dired, speedbar-tag-file)
(speedbar-tag-expand):
* lisp/subr.el (split-string-and-unquote):
* lisp/tar-mode.el (tar-extract):
* lisp/term.el (term-command-hook, serial-read-name):
* lisp/textmodes/bibtex.el (bibtex-print-help-message):
* lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter)
(ispell-parse-output, ispell-buffer-local-parsing):
* lisp/textmodes/reftex-cite.el (reftex-do-citation):
* lisp/textmodes/reftex-parse.el (reftex-notice-new):
* lisp/textmodes/reftex-ref.el (reftex-show-entry):
* lisp/textmodes/reftex.el (reftex-compile-variables):
* lisp/textmodes/tex-mode.el (tex-send-command)
(tex-start-tex, tex-append):
* lisp/thingatpt.el (thing-at-point-url-at-point):
* lisp/tmm.el (tmm-add-one-shortcut):
* lisp/transient.el (transient-format-key):
* lisp/url/url-auth.el (url-basic-auth)
(url-digest-auth-directory-id-assoc):
* lisp/url/url-news.el (url-news):
* lisp/url/url-util.el (url-parse-query-string):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/wid-browse.el (widget-browse-sexp):
* lisp/woman.el (woman-parse-colon-path, woman-mini-help)
(WoMan-getpage-in-background, woman-negative-vertical-space):
* lisp/xml.el:
* test/lisp/emacs-lisp/check-declare-tests.el
(check-declare-tests-warn):
* test/lisp/files-tests.el
(files-tests-file-name-non-special-dired-compress-handler):
* test/lisp/net/network-stream-tests.el (server-process-filter):
* test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode):
Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 09:20:00 +00:00
|
|
|
|
(unless (string-search " " desc)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(let ((times 1) (pos bind-len))
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(while (not (cl-mismatch rest-mac rest-mac
|
2013-07-15 19:45:22 +00:00
|
|
|
|
:start1 0 :end1 bind-len
|
|
|
|
|
:start2 pos :end2 (+ bind-len pos)))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-incf times)
|
|
|
|
|
(cl-incf pos bind-len))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(when (> times 1)
|
|
|
|
|
(setq desc (format "%d*%s" times desc))
|
|
|
|
|
(setq bind-len (* bind-len times)))))
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(setq rest-mac (cl-subseq rest-mac bind-len))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(if verbose
|
|
|
|
|
(progn
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(unless (equal res "") (cl-callf concat res "\n"))
|
|
|
|
|
(cl-callf concat res desc)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(when (and bind (or (stringp bind) (symbolp bind)))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-callf concat res
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(make-string (max (- 3 (/ (length desc) 8)) 1) 9)
|
|
|
|
|
";; " (if (stringp bind) bind (symbol-name bind))))
|
|
|
|
|
(setq len 0))
|
|
|
|
|
(if (and (> (+ len (length desc) 2) 72) (not one-line))
|
|
|
|
|
(progn
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-callf concat res "\n ")
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(setq len 1))
|
|
|
|
|
(unless (equal res "")
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-callf concat res " ")
|
|
|
|
|
(cl-incf len)))
|
|
|
|
|
(cl-callf concat res desc)
|
|
|
|
|
(cl-incf len (length desc)))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
res))
|
|
|
|
|
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(defun edmacro-sanitize-for-string (seq)
|
2008-10-23 23:52:14 +00:00
|
|
|
|
"Convert a key sequence vector SEQ into a string.
|
2004-04-16 12:51:06 +00:00
|
|
|
|
The string represents the same events; Meta is indicated by bit 7.
|
|
|
|
|
This function assumes that the events can be stored in a string."
|
|
|
|
|
(setq seq (copy-sequence seq))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-loop for i below (length seq) do
|
|
|
|
|
(when (logand (aref seq i) 128)
|
|
|
|
|
(setf (aref seq i) (logand (aref seq i) 127))))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
seq)
|
|
|
|
|
|
2002-06-21 09:53:01 +00:00
|
|
|
|
(defun edmacro-fix-menu-commands (macro &optional noerror)
|
|
|
|
|
(if (vectorp macro)
|
|
|
|
|
(let (result)
|
|
|
|
|
;; Make a list of the elements.
|
|
|
|
|
(setq macro (append macro nil))
|
|
|
|
|
(dolist (ev macro)
|
|
|
|
|
(cond ((atom ev)
|
|
|
|
|
(push ev result))
|
|
|
|
|
((eq (car ev) 'help-echo))
|
2006-08-02 22:37:17 +00:00
|
|
|
|
((eq (car ev) 'switch-frame))
|
2002-06-21 09:53:01 +00:00
|
|
|
|
((equal ev '(menu-bar))
|
|
|
|
|
(push 'menu-bar result))
|
2021-07-28 11:42:05 +00:00
|
|
|
|
((equal (cadadr ev) '(menu-bar))
|
2002-06-21 09:53:01 +00:00
|
|
|
|
(push (vector 'menu-bar (car ev)) result))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
;; It would be nice to do pop-up menus, too, but not enough
|
|
|
|
|
;; info is recorded in macros to make this possible.
|
2018-12-30 19:37:28 +00:00
|
|
|
|
((or (mouse-event-p ev) (mouse-movement-p ev)
|
|
|
|
|
(memq (event-basic-type ev)
|
|
|
|
|
(list mouse-wheel-down-event mouse-wheel-up-event
|
|
|
|
|
mouse-wheel-right-event
|
|
|
|
|
mouse-wheel-left-event)))
|
2002-06-21 09:53:01 +00:00
|
|
|
|
nil)
|
2018-12-30 19:37:28 +00:00
|
|
|
|
(noerror nil)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(t
|
2018-12-30 19:37:28 +00:00
|
|
|
|
(error "`edmacro-fix-menu-commands': Unsupported event: %S"
|
|
|
|
|
ev))))
|
2002-06-21 09:53:01 +00:00
|
|
|
|
;; Reverse them again and make them back into a vector.
|
|
|
|
|
(vconcat (nreverse result)))
|
|
|
|
|
macro))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
|
|
|
|
|
;;; Parsing a human-readable keyboard macro.
|
|
|
|
|
|
|
|
|
|
(defun edmacro-parse-keys (string &optional need-vector)
|
|
|
|
|
(let ((case-fold-search nil)
|
2008-08-19 21:44:56 +00:00
|
|
|
|
(len (length string)) ; We won't alter string in the loop below.
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(pos 0)
|
|
|
|
|
(res []))
|
2008-08-19 21:44:56 +00:00
|
|
|
|
(while (and (< pos len)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(string-match "[^ \t\n\f]+" string pos))
|
2008-08-19 21:44:56 +00:00
|
|
|
|
(let* ((word-beg (match-beginning 0))
|
|
|
|
|
(word-end (match-end 0))
|
|
|
|
|
(word (substring string word-beg len))
|
|
|
|
|
(times 1)
|
|
|
|
|
key)
|
|
|
|
|
;; Try to catch events of the form "<as df>".
|
2009-05-26 20:19:26 +00:00
|
|
|
|
(if (string-match "\\`<[^ <>\t\n\f][^>\t\n\f]*>" word)
|
2008-08-19 21:44:56 +00:00
|
|
|
|
(setq word (match-string 0 word)
|
|
|
|
|
pos (+ word-beg (match-end 0)))
|
|
|
|
|
(setq word (substring string word-beg word-end)
|
|
|
|
|
pos word-end))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(when (string-match "\\([0-9]+\\)\\*." word)
|
2005-05-16 11:34:49 +00:00
|
|
|
|
(setq times (string-to-number (substring word 0 (match-end 1))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(setq word (substring word (1+ (match-end 1)))))
|
|
|
|
|
(cond ((string-match "^<<.+>>$" word)
|
|
|
|
|
(setq key (vconcat (if (eq (key-binding [?\M-x])
|
|
|
|
|
'execute-extended-command)
|
|
|
|
|
[?\M-x]
|
|
|
|
|
(or (car (where-is-internal
|
|
|
|
|
'execute-extended-command))
|
|
|
|
|
[?\M-x]))
|
|
|
|
|
(substring word 2 -2) "\r")))
|
|
|
|
|
((and (string-match "^\\(\\([ACHMsS]-\\)*\\)<\\(.+\\)>$" word)
|
|
|
|
|
(progn
|
2021-04-10 16:18:22 +00:00
|
|
|
|
(setq word (concat (match-string 1 word)
|
|
|
|
|
(match-string 3 word)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(not (string-match
|
|
|
|
|
"\\<\\(NUL\\|RET\\|LFD\\|ESC\\|SPC\\|DEL\\)$"
|
|
|
|
|
word))))
|
|
|
|
|
(setq key (list (intern word))))
|
|
|
|
|
((or (equal word "REM") (string-match "^;;" word))
|
|
|
|
|
(setq pos (string-match "$" string pos)))
|
|
|
|
|
(t
|
|
|
|
|
(let ((orig-word word) (prefix 0) (bits 0))
|
|
|
|
|
(while (string-match "^[ACHMsS]-." word)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-incf bits (cdr (assq (aref word 0)
|
1995-02-08 03:50:54 +00:00
|
|
|
|
'((?A . ?\A-\^@) (?C . ?\C-\^@)
|
|
|
|
|
(?H . ?\H-\^@) (?M . ?\M-\^@)
|
|
|
|
|
(?s . ?\s-\^@) (?S . ?\S-\^@)))))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-incf prefix 2)
|
|
|
|
|
(cl-callf substring word 2))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(when (string-match "^\\^.$" word)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-incf bits ?\C-\^@)
|
|
|
|
|
(cl-incf prefix)
|
|
|
|
|
(cl-callf substring word 1))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(let ((found (assoc word '(("NUL" . "\0") ("RET" . "\r")
|
|
|
|
|
("LFD" . "\n") ("TAB" . "\t")
|
|
|
|
|
("ESC" . "\e") ("SPC" . " ")
|
|
|
|
|
("DEL" . "\177")))))
|
|
|
|
|
(when found (setq word (cdr found))))
|
|
|
|
|
(when (string-match "^\\\\[0-7]+$" word)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-loop for ch across word
|
|
|
|
|
for n = 0 then (+ (* n 8) ch -48)
|
|
|
|
|
finally do (setq word (vector n))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(cond ((= bits 0)
|
|
|
|
|
(setq key word))
|
1995-02-08 03:50:54 +00:00
|
|
|
|
((and (= bits ?\M-\^@) (stringp word)
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(string-match "^-?[0-9]+$" word))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(setq key (cl-loop for x across word
|
|
|
|
|
collect (+ x bits))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
((/= (length word) 1)
|
|
|
|
|
(error "%s must prefix a single character, not %s"
|
|
|
|
|
(substring orig-word 0 prefix) word))
|
1995-02-08 03:50:54 +00:00
|
|
|
|
((and (/= (logand bits ?\C-\^@) 0) (stringp word)
|
1997-01-31 07:48:16 +00:00
|
|
|
|
;; We used to accept . and ? here,
|
|
|
|
|
;; but . is simply wrong,
|
|
|
|
|
;; and C-? is not used (we use DEL instead).
|
|
|
|
|
(string-match "[@-_a-z]" word))
|
1995-02-08 03:50:54 +00:00
|
|
|
|
(setq key (list (+ bits (- ?\C-\^@)
|
1997-02-05 01:33:07 +00:00
|
|
|
|
(logand (aref word 0) 31)))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(t
|
|
|
|
|
(setq key (list (+ bits (aref word 0)))))))))
|
|
|
|
|
(when key
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-loop repeat times do (cl-callf vconcat res key)))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(when (and (>= (length res) 4)
|
|
|
|
|
(eq (aref res 0) ?\C-x)
|
|
|
|
|
(eq (aref res 1) ?\()
|
|
|
|
|
(eq (aref res (- (length res) 2)) ?\C-x)
|
|
|
|
|
(eq (aref res (- (length res) 1)) ?\)))
|
2013-07-12 03:54:57 +00:00
|
|
|
|
(setq res (cl-subseq res 2 -2)))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
(if (and (not need-vector)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(cl-loop for ch across res
|
|
|
|
|
always (and (characterp ch)
|
|
|
|
|
(let ((ch2 (logand ch (lognot ?\M-\^@))))
|
|
|
|
|
(and (>= ch2 0) (<= ch2 127))))))
|
|
|
|
|
(concat (cl-loop for ch across res
|
|
|
|
|
collect (if (= (logand ch ?\M-\^@) 0)
|
|
|
|
|
ch (+ ch 128))))
|
1993-09-21 03:44:04 +00:00
|
|
|
|
res)))
|
|
|
|
|
|
|
|
|
|
(provide 'edmacro)
|
1992-05-30 23:54:21 +00:00
|
|
|
|
|
|
|
|
|
;;; edmacro.el ends here
|