kmacro-x

a fork of vifon's kmacro-x
git clone https://git.trogloxene.org/kmacro-x.git
Log | Files | Refs | README | LICENSE

commit 10bdbdc187f8b879ca70b69cc04bb526117a7bbf
parent 46289ab15de89266e2e38f842e5a785a3e7c7899
Author: Wojciech Siewierski <wojciech@siewierski.eu>
Date:   Wed, 12 Jan 2022 00:30:03 +0100

Rename the package

Diffstat:
MREADME.md | 8++++----
Akmacro-mc.el | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dkmacro-multiple-cursors.el | 76----------------------------------------------------------------------------
3 files changed, 80 insertions(+), 80 deletions(-)

diff --git a/README.md b/README.md @@ -1,5 +1,5 @@ -kmacro-multiple-cursors -======================= +kmacro-mc +========= A set of Emacs commands to facilitate the usual multiple-cursors workflows with the use of regular keyboard macros (kmacros). This way @@ -14,7 +14,7 @@ INSTALLATION ------------ ```elisp -(use-package kmacro-multiple-cursors - :straight (:host github :repo "vifon/kmacro-multiple-cursors.el") +(use-package kmacro-mc + :straight (:host github :repo "vifon/kmacro-mc.el") :bind ("C-c k" . kmacro-mc-region)) ``` diff --git a/kmacro-mc.el b/kmacro-mc.el @@ -0,0 +1,76 @@ +;;; kmacro-mc.el --- Multiple cursors emulation with keyboard macros -*- lexical-binding: t; -*- + +;; Copyright (C) 2022 Wojciech Siewierski + +;; Author: Wojciech Siewierski +;; Keywords: convenience +;; Version: 0.9 +;; Package-Requires: ((emacs "27.2")) + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program 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 +;; along with this program. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; A set of commands to facilitate the usual multiple-cursors +;; workflows with the use of regular keyboard macros (kmacros). +;; This way all the pitfalls of rolling a custom implementation are +;; avoided, while all the kmacro facilities, such as counters, queries +;; and kmacro editing, are gained virtually for free. + +;; It is assumed the user didn't rebind the basic isearch commands, +;; otherwise the behavior may be unpredictable. + +;;; Code: + +(require 'kmacro) + + +(defgroup kmacro-mc nil + "Multiple cursors emulation with keyboard macros." + :group 'kmacro) + +(defface kmacro-mc-highlight-face + '((t (:inherit hi-yellow))) ;`highlight-regexp' hardcodes `hi-yellow' + "The face used by `kmacro-mc-region'.") + + +;;;###autoload +(defun kmacro-mc-region (start end &optional highlight) + "Record a keyboard macro emulating multiple cursors. + +The kmacro will first search for current region and then execute +the rest of the recorded kmacro. During the kmacro execution, +mark is always at the beginning of the match and point is at +the end. + +With prefix argument highlight the query using +`highlight-regexp'. Use `\\[unhighlight-regexp]' to remove the +highlight later." + (interactive "r\nP") + (let ((query (buffer-substring-no-properties start end))) + (when (< (point) (mark)) + (exchange-point-and-mark)) + (deactivate-mark) + (kmacro-push-ring) + (setq last-kbd-macro + (read-kbd-macro (format "C-s %s C-r RET 2*C-s RET" + (format-kbd-macro query)))) + (when highlight + (highlight-regexp (regexp-quote query) + 'kmacro-mc-highlight-face)) + (start-kbd-macro 'append 'no-exec))) + + +(provide 'kmacro-mc) +;;; kmacro-mc.el ends here diff --git a/kmacro-multiple-cursors.el b/kmacro-multiple-cursors.el @@ -1,76 +0,0 @@ -;;; kmacro-multiple-cursors.el --- Multiple cursors emulation with keyboard macros -*- lexical-binding: t; -*- - -;; Copyright (C) 2022 Wojciech Siewierski - -;; Author: Wojciech Siewierski -;; Keywords: convenience -;; Version: 0.9 -;; Package-Requires: ((emacs "27.2")) - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program 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 -;; along with this program. If not, see <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; A set of commands to facilitate the usual multiple-cursors -;; workflows with the use of regular keyboard macros (kmacros). -;; This way all the pitfalls of rolling a custom implementation are -;; avoided, while all the kmacro facilities, such as counters, queries -;; and kmacro editing, are gained virtually for free. - -;; It is assumed the user didn't rebind the basic isearch commands, -;; otherwise the behavior may be unpredictable. - -;;; Code: - -(require 'kmacro) - - -(defgroup kmacro-mc nil - "Multiple cursors emulation with keyboard macros." - :group 'kmacro) - -(defface kmacro-mc-highlight-face - '((t (:inherit hi-yellow))) ;`highlight-regexp' hardcodes `hi-yellow' - "The face used by `kmacro-mc-region'.") - - -;;;###autoload -(defun kmacro-mc-region (start end &optional highlight) - "Record a keyboard macro emulating multiple cursors. - -The kmacro will first search for current region and then execute -the rest of the recorded kmacro. During the kmacro execution, -mark is always at the beginning of the match and point is at -the end. - -With prefix argument highlight the query using -`highlight-regexp'. Use `\\[unhighlight-regexp]' to remove the -highlight later." - (interactive "r\nP") - (let ((query (buffer-substring-no-properties start end))) - (when (< (point) (mark)) - (exchange-point-and-mark)) - (deactivate-mark) - (kmacro-push-ring) - (setq last-kbd-macro - (read-kbd-macro (format "C-s %s C-r RET 2*C-s RET" - (format-kbd-macro query)))) - (when highlight - (highlight-regexp (regexp-quote query) - 'kmacro-mc-highlight-face)) - (start-kbd-macro 'append 'no-exec))) - - -(provide 'kmacro-multiple-cursors) -;;; kmacro-multiple-cursors.el ends here