Function: mc/toggle-cursor-on-click

mc/toggle-cursor-on-click is an interactive and natively compiled function defined in mc-mark-more.el.

Signature

(mc/toggle-cursor-on-click EVENT)

Documentation

Add a cursor where you click, or remove a fake cursor that is already there.

Key Bindings

This command is not in any keymaps.

Aliases

mc/add-cursor-on-click

Source Code

;; Defined in /nix/store/5q7a78ihkz25lf4xmxaa9m7b2ym63m36-emacs-packages-deps/share/emacs/site-lisp/elpa/multiple-cursors-20260419.931/mc-mark-more.el
;;;###autoload
(defun mc/toggle-cursor-on-click (event)
  "Add a cursor where you click, or remove a fake cursor that is
already there."
  (interactive "e")
  (mouse-minibuffer-check event)
  ;; Use event-end in case called from mouse-drag-region.
  ;; If EVENT is a click, event-end and event-start give same value.
  (let ((position (event-end event)))
    (if (not (windowp (posn-window position)))
        (error "Position not in text area of window"))
    (select-window (posn-window position))
    (let ((pt (posn-point position)))
      (if (numberp pt)
          ;; is there a fake cursor with the actual *point* right where we are?
          (let ((existing (mc/fake-cursor-at-point pt)))
            (if existing
                (mc/remove-fake-cursor existing)
              (save-excursion
                (goto-char pt)
                (mc/create-fake-cursor-at-point))))))
    (mc/maybe-multiple-cursors-mode)))