mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 13:03:03 +00:00
introduce function mc/disable-multiple-cursors-mode
This commit is contained in:
parent
4975afedb3
commit
b139bb6b30
@ -355,9 +355,7 @@ With zero ARG, skip the last one and mark next."
|
|||||||
(when point-first (exchange-point-and-mark)))))
|
(when point-first (exchange-point-and-mark)))))
|
||||||
(if (> (mc/num-cursors) 1)
|
(if (> (mc/num-cursors) 1)
|
||||||
(multiple-cursors-mode 1)
|
(multiple-cursors-mode 1)
|
||||||
(progn
|
(mc/disable-multiple-cursors-mode)))
|
||||||
(multiple-cursors-mode 0)
|
|
||||||
(run-hooks 'multiple-cursors-mode-disabled-hook))))
|
|
||||||
|
|
||||||
(defun mc--select-thing-at-point (thing)
|
(defun mc--select-thing-at-point (thing)
|
||||||
(let ((bound (bounds-of-thing-at-point thing)))
|
(let ((bound (bounds-of-thing-at-point thing)))
|
||||||
@ -404,9 +402,7 @@ With zero ARG, skip the last one and mark next."
|
|||||||
(mc/pop-state-from-overlay first)))
|
(mc/pop-state-from-overlay first)))
|
||||||
(if (> (mc/num-cursors) 1)
|
(if (> (mc/num-cursors) 1)
|
||||||
(multiple-cursors-mode 1)
|
(multiple-cursors-mode 1)
|
||||||
(progn
|
(mc/disable-multiple-cursors-mode))))))
|
||||||
(multiple-cursors-mode 0)
|
|
||||||
(run-hooks 'multiple-cursors-mode-disabled-hook)))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun mc/mark-all-in-region-regexp (beg end)
|
(defun mc/mark-all-in-region-regexp (beg end)
|
||||||
@ -431,9 +427,7 @@ With zero ARG, skip the last one and mark next."
|
|||||||
(error "Search failed for %S" search)))
|
(error "Search failed for %S" search)))
|
||||||
(goto-char (match-end 0))
|
(goto-char (match-end 0))
|
||||||
(if (< (mc/num-cursors) 3)
|
(if (< (mc/num-cursors) 3)
|
||||||
(progn
|
(mc/disable-multiple-cursors-mode)
|
||||||
(multiple-cursors-mode 0)
|
|
||||||
(run-hooks 'multiple-cursors-mode-disabled-hook))
|
|
||||||
(mc/pop-state-from-overlay (mc/furthest-cursor-before-point))
|
(mc/pop-state-from-overlay (mc/furthest-cursor-before-point))
|
||||||
(multiple-cursors-mode 1))))))
|
(multiple-cursors-mode 1))))))
|
||||||
|
|
||||||
|
@ -106,8 +106,7 @@
|
|||||||
(progn
|
(progn
|
||||||
(mc/mark-next-lines 1)
|
(mc/mark-next-lines 1)
|
||||||
(mc/reverse-regions)
|
(mc/reverse-regions)
|
||||||
(multiple-cursors-mode 0)
|
(mc/disable-multiple-cursors-mode)
|
||||||
(multiple-cursors-mode-disabled-hook)
|
|
||||||
)
|
)
|
||||||
(unless (use-region-p)
|
(unless (use-region-p)
|
||||||
(mc/execute-command-for-all-cursors 'mark-sexp))
|
(mc/execute-command-for-all-cursors 'mark-sexp))
|
||||||
|
@ -433,9 +433,7 @@ the original cursor, to inform about the lack of support."
|
|||||||
(unless mc--executing-command-for-fake-cursor
|
(unless mc--executing-command-for-fake-cursor
|
||||||
|
|
||||||
(if (eq 1 (mc/num-cursors)) ;; no fake cursors? disable mc-mode
|
(if (eq 1 (mc/num-cursors)) ;; no fake cursors? disable mc-mode
|
||||||
(progn
|
(mc/disable-multiple-cursors-mode)
|
||||||
(multiple-cursors-mode 0)
|
|
||||||
(run-hooks 'multiple-cursors-mode-disabled-hook))
|
|
||||||
(when this-original-command
|
(when this-original-command
|
||||||
(let ((original-command (or mc--this-command
|
(let ((original-command (or mc--this-command
|
||||||
(command-remapping this-original-command)
|
(command-remapping this-original-command)
|
||||||
@ -489,9 +487,7 @@ you should disable multiple-cursors-mode."
|
|||||||
"Deactivate mark if there are any active, otherwise exit multiple-cursors-mode."
|
"Deactivate mark if there are any active, otherwise exit multiple-cursors-mode."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (not (use-region-p))
|
(if (not (use-region-p))
|
||||||
(progn
|
(mc/disable-multiple-cursors-mode)
|
||||||
(multiple-cursors-mode 0)
|
|
||||||
(run-hooks 'multiple-cursors-mode-disabled-hook))
|
|
||||||
(deactivate-mark)))
|
(deactivate-mark)))
|
||||||
|
|
||||||
(defun mc/repeat-command ()
|
(defun mc/repeat-command ()
|
||||||
@ -592,18 +588,18 @@ They are temporarily disabled when multiple-cursors are active.")
|
|||||||
(mc/enable-temporarily-disabled-minor-modes)
|
(mc/enable-temporarily-disabled-minor-modes)
|
||||||
(run-hooks 'multiple-cursors-mode-disabled-hook)))
|
(run-hooks 'multiple-cursors-mode-disabled-hook)))
|
||||||
|
|
||||||
(add-hook 'after-revert-hook
|
(defun mc/disable-multiple-cursors-mode ()
|
||||||
#'(lambda () (progn
|
"Disable multiple-cursors-mode and run the corresponding hook."
|
||||||
(multiple-cursors-mode 0)
|
(multiple-cursors-mode 0)
|
||||||
(run-hooks 'multiple-cursors-mode-disabled-hook))))
|
(run-hooks 'multiple-cursors-mode-disabled-hook))
|
||||||
|
|
||||||
|
(add-hook 'after-revert-hook 'mc/disable-multiple-cursors-mode)
|
||||||
|
|
||||||
(defun mc/maybe-multiple-cursors-mode ()
|
(defun mc/maybe-multiple-cursors-mode ()
|
||||||
"Enable multiple-cursors-mode if there is more than one currently active cursor."
|
"Enable multiple-cursors-mode if there is more than one currently active cursor."
|
||||||
(if (> (mc/num-cursors) 1)
|
(if (> (mc/num-cursors) 1)
|
||||||
(multiple-cursors-mode 1)
|
(multiple-cursors-mode 1)
|
||||||
(progn
|
(mc/disable-multiple-cursors-mode)))
|
||||||
(multiple-cursors-mode 0)
|
|
||||||
(run-hooks 'multiple-cursors-mode-disabled-hook))))
|
|
||||||
|
|
||||||
(defmacro unsupported-cmd (cmd msg)
|
(defmacro unsupported-cmd (cmd msg)
|
||||||
"Adds command to list of unsupported commands and prevents it
|
"Adds command to list of unsupported commands and prevents it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user