[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors dc22766 108/434: Macros must be defined b
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors dc22766 108/434: Macros must be defined before they are used to be expanded properly |
Date: |
Sat, 7 Aug 2021 09:20:05 -0400 (EDT) |
branch: elpa/multiple-cursors
commit dc22766af5f18961e34559719fe2d3ef1082e6e4
Author: Mon ouïe <mon.ouie@gmail.com>
Commit: Mon ouïe <mon.ouie@gmail.com>
Macros must be defined before they are used to be expanded properly
---
multiple-cursors-core.el | 75 ++++++++++++++++++++++++------------------------
1 file changed, 37 insertions(+), 38 deletions(-)
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index 4d8d652..fbf7c24 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -37,6 +37,43 @@
"The face used for fake regions"
:group 'multiple-cursors)
+(defmacro mc/add-fake-cursor-to-undo-list (&rest forms)
+ "Make sure point is in the right place when undoing"
+ `(let ((undo-cleaner (cons 'apply (cons 'deactivate-cursor-after-undo (list
id)))))
+ (setq buffer-undo-list (cons undo-cleaner buffer-undo-list))
+ ,@forms
+ (if (eq undo-cleaner (car buffer-undo-list)) ;; if nothing has been added
to the undo-list
+ (setq buffer-undo-list (cdr buffer-undo-list)) ;; then pop the
cleaner right off again
+ (setq buffer-undo-list ;; otherwise add a function to activate this
cursor
+ (cons (cons 'apply (cons 'activate-cursor-for-undo (list id)))
buffer-undo-list)))))
+
+(defmacro mc/for-each-fake-cursor (&rest forms)
+ "Runs the body for each fake cursor, bound to the name cursor"
+ `(mapc #'(lambda (cursor)
+ (when (mc/fake-cursor-p cursor)
+ ,@forms))
+ (overlays-in (point-min) (point-max))))
+
+(defmacro mc/save-excursion (&rest forms)
+ "Saves and restores all the state that multiple-cursors cares about."
+ `(let ((current-state (mc/store-current-state-in-overlay
+ (make-overlay (point) (point) nil nil t))))
+ (overlay-put current-state 'type 'original-cursor)
+ (save-excursion ,@forms)
+ (mc/pop-state-from-overlay current-state)))
+
+(defmacro mc/save-window-scroll (&rest forms)
+ "Saves and restores the window scroll position"
+ `(let ((p (set-marker (make-marker) (point)))
+ (start (set-marker (make-marker) (window-start)))
+ (hscroll (window-hscroll)))
+ ,@forms
+ (goto-char p)
+ (set-window-start nil start)
+ (set-window-hscroll nil hscroll)
+ (set-marker p nil)
+ (set-marker start nil)))
+
(defun mc/make-cursor-overlay-at-eol (pos)
"Create overlay to look like cursor at end of line."
(let ((overlay (make-overlay pos pos nil nil nil)))
@@ -100,7 +137,6 @@ highlights the entire width of the window."
"Restore the state stored in given overlay and then remove the overlay."
(mc/restore-state-from-overlay o)
(mc/remove-fake-cursor o))
-
(defun mc/delete-region-overlay (o)
"Remove the dependent region overlay for a given cursor overlay."
(ignore-errors
@@ -151,16 +187,6 @@ cursor with updated info."
(mc/execute-command cmd)
(mc/create-fake-cursor-at-point id)))))))))
-(defmacro mc/add-fake-cursor-to-undo-list (&rest forms)
- "Make sure point is in the right place when undoing"
- `(let ((undo-cleaner (cons 'apply (cons 'deactivate-cursor-after-undo (list
id)))))
- (setq buffer-undo-list (cons undo-cleaner buffer-undo-list))
- ,@forms
- (if (eq undo-cleaner (car buffer-undo-list)) ;; if nothing has been added
to the undo-list
- (setq buffer-undo-list (cdr buffer-undo-list)) ;; then pop the
cleaner right off again
- (setq buffer-undo-list ;; otherwise add a function to activate this
cursor
- (cons (cons 'apply (cons 'activate-cursor-for-undo (list id)))
buffer-undo-list)))))
-
(defun mc/fake-cursor-p (o)
"Predicate to check if an overlay is a fake cursor"
(eq (overlay-get o 'type) 'fake-cursor))
@@ -189,33 +215,6 @@ cursor with updated info."
(mc/pop-state-from-overlay mc--stored-state-for-undo)
(setq mc--stored-state-for-undo nil)))
-(defmacro mc/for-each-fake-cursor (&rest forms)
- "Runs the body for each fake cursor, bound to the name cursor"
- `(mapc #'(lambda (cursor)
- (when (mc/fake-cursor-p cursor)
- ,@forms))
- (overlays-in (point-min) (point-max))))
-
-(defmacro mc/save-excursion (&rest forms)
- "Saves and restores all the state that multiple-cursors cares about."
- `(let ((current-state (mc/store-current-state-in-overlay
- (make-overlay (point) (point) nil nil t))))
- (overlay-put current-state 'type 'original-cursor)
- (save-excursion ,@forms)
- (mc/pop-state-from-overlay current-state)))
-
-(defmacro mc/save-window-scroll (&rest forms)
- "Saves and restores the window scroll position"
- `(let ((p (set-marker (make-marker) (point)))
- (start (set-marker (make-marker) (window-start)))
- (hscroll (window-hscroll)))
- ,@forms
- (goto-char p)
- (set-window-start nil start)
- (set-window-hscroll nil hscroll)
- (set-marker p nil)
- (set-marker start nil)))
-
(defun mc/prompt-for-inclusion-in-whitelist (original-command)
"Asks the user, then adds the command either to the once-list or the
all-list."
(let ((all-p (y-or-n-p (format "Do %S for all cursors?" original-command))))
- [nongnu] elpa/multiple-cursors 038815b 414/434: Make "no more matches found." user-error, fix #218, (continued)
- [nongnu] elpa/multiple-cursors 038815b 414/434: Make "no more matches found." user-error, fix #218, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d27870d 421/434: Load mc/list-file as late as possible, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors fc6a6a7 422/434: Merge pull request #355 from flatwhatson/lazy-list-file, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 7763f4f 429/434: Load mc-cycle-cursors and mc-hide-unmatched-lines-mode after loading multiple-cursors-core, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a9d7764 431/434: Add option to disable bar-style fake cursors (#367), ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 616fbdd 434/434: Document existing functions in Readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 7ab8a8c 067/434: Better support for undo., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 608ceb4 069/434: Disable multiple-cursors-mode if there's only one cursor (the real one)., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 61280ae 100/434: autoload integration for package.el compatibility, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d82e252 106/434: Don't let fake cursors scroll the buffer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors dc22766 108/434: Macros must be defined before they are used to be expanded properly,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 7a655b0 117/434: Disable emacs-snapshot tests until it is in order., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 067063a 118/434: Split multiline kill-ring entry over cursors when num lines match, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors bdc4d9a 124/434: Add some more commands to default run-once/run-for-all lists., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 0f54f98 133/434: Bump to 1.1.1 for bugfix, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a0f771f 151/434: Include interactive commands for deselecting prev/next, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 8a12e97 148/434: Mention region-bindings-mode in README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 19b1a83 160/434: Refactor mc/first-cursor-after and mc/last-cursor-before to not use extreme., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 9ac7675 155/434: Added tests for mc/cycle-forward and mc/cycle-backward with their new looping behaviour, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors dce196c 167/434: Merge pull request #28 from gvol/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors c3b2d84 164/434: Merge pull request #23 from segv/master, ELPA Syncer, 2021/08/07