From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.bugs Subject: bug#22873: #22873 (multiple fake cursors) Date: Wed, 27 Dec 2017 17:26:21 -0800 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1514424320 25517 195.159.176.226 (28 Dec 2017 01:25:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 28 Dec 2017 01:25:20 +0000 (UTC) Cc: Marcin Borkowski , 22873@debbugs.gnu.org, Richard Stallman To: John Wiegley Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 28 02:25:15 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUMwZ-0005ku-8g for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Dec 2017 02:25:12 +0100 Original-Received: from localhost ([::1]:56383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUMyW-0004LH-A0 for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Dec 2017 20:27:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUMyP-0004Ku-UP for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2017 20:27:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eUMyM-0006rI-Ir for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2017 20:27:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45655) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eUMyM-0006qs-0H for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2017 20:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eUMyL-0008AT-K3 for bug-gnu-emacs@gnu.org; Wed, 27 Dec 2017 20:27:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Dec 2017 01:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22873 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22873-submit@debbugs.gnu.org id=B22873.151442439031356 (code B ref 22873); Thu, 28 Dec 2017 01:27:01 +0000 Original-Received: (at 22873) by debbugs.gnu.org; 28 Dec 2017 01:26:30 +0000 Original-Received: from localhost ([127.0.0.1]:54336 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUMxp-00089f-CK for submit@debbugs.gnu.org; Wed, 27 Dec 2017 20:26:30 -0500 Original-Received: from gateway20.websitewelcome.com ([192.185.58.11]:23135) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUMxm-00089W-0K for 22873@debbugs.gnu.org; Wed, 27 Dec 2017 20:26:26 -0500 Original-Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway20.websitewelcome.com (Postfix) with ESMTP id B0C27400C46EC for <22873@debbugs.gnu.org>; Wed, 27 Dec 2017 19:26:23 -0600 (CST) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id UMxjeO4QeBUMKUMxjeYO4o; Wed, 27 Dec 2017 19:26:23 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date: Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Gm6M+5hvubWjS33TbtqXChVwvEkMn6kMuXGr6scF5No=; b=jPiU3oE2bp64lRms12JULT/ga+ NnGEcBgNvAbQBuhr3o6uzsNubYYUtomvvMLWfpBp+8H86Iq1C2mMGZHIty19MrswxvrQAIC2b0MvC 9KTgrlvfTDUD1fNmo4QH4sbloV8485y9eq+3q8S1he7veUx3QyIN3Kta1g41RAD+WmzWcBW4OGIut cuUM4pakhGz98exFmwd/ogJCrmEKN1XnMLqTenzoTLRvcOZvI1fkKSzqEv64KuEwVZ9fHD+zy5p7R Snx10jJBXxTs8n1fExi4OPSDvzQ/syn8D8OihMDHopAMn+Fgd3Yjm5WlE+n4zm0oJl2ZkAR2uAXWt Q+y0fMEw==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:52512 helo=server.private) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.89) (envelope-from ) id 1eUMxi-000uzJ-FA; Wed, 27 Dec 2017 19:26:22 -0600 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Source-L: No X-Exim-ID: 1eUMxi-000uzJ-FA X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private) [45.48.239.195]:52512 X-Source-Auth: lawlist X-Email-Count: 9 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:141555 Archived-At: John: I had an extra function in the previous email, sorry. Here is the shortened version: (require 'multiple-cursors-core) (require 'cl) ;; for oddp and evenp (add-hook 'multiple-cursors-mode-disabled-hook (lambda () (kill-local-variable 'mc-glyph-list))) (defvar mc/use-built-in-cursors t "Whether to use the built-in fake cursors.") (defun mc/create-fake-cursor-at-point (&optional id) "Add a fake cursor and possibly a fake active region overlay based on point and mark. Saves the current state in the overlay to be restored later." (unless mc--max-cursors-original (setq mc--max-cursors-original mc/max-cursors)) (when mc/max-cursors (unless (< (mc/num-cursors) mc/max-cursors) (if (yes-or-no-p (format "%d active cursors. Continue? " (mc/num-cursors))) (setq mc/max-cursors (read-number "Enter a new, temporary maximum: ")) (mc/remove-fake-cursors) (error "Aborted: too many cursors")))) (let ((overlay (if mc/use-built-in-cursors (make-overlay (point) (point)) (mc/make-cursor-overlay-at-point)))) (overlay-put overlay 'mc-id (or id (mc/create-cursor-id))) (overlay-put overlay 'type 'fake-cursor) (overlay-put overlay 'priority 100) (mc/store-current-state-in-overlay overlay) (when (use-region-p) (overlay-put overlay 'region-overlay (mc/make-region-overlay-between-point-and-mark))) overlay)) (defun mc/execute-this-command-for-all-cursors-1 () "Used with post-command-hook to execute supported commands for all cursors. It uses two lists of commands to know what to do: the run-once list and the run-for-all list. If a command is in neither of these lists, it will prompt for the proper action and then save that preference. Some commands are so unsupported that they are even prevented for the original cursor, to inform about the lack of support." (unless mc--executing-command-for-fake-cursor (if (eq 1 (mc/num-cursors)) ;; no fake cursors? disable mc-mode (multiple-cursors-mode 0) (when this-original-command (let ((original-command (or mc--this-command (command-remapping this-original-command) this-original-command))) ;; skip keyboard macros, since they will generate actual commands that are ;; also run in the command loop - we'll handle those later instead. (when (functionp original-command) ;; if it's a lambda, we can't know if it's supported or not ;; - so go ahead and assume it's ok, because we're just optimistic like that (if (or (not (symbolp original-command)) ;; lambda registered by smartrep (string-prefix-p "(" (symbol-name original-command))) (mc/execute-command-for-all-fake-cursors original-command) ;; smartrep `intern's commands into own obarray to help ;; `describe-bindings'. So, let's re-`intern' here to ;; make the command comparable by `eq'. (setq original-command (intern (symbol-name original-command))) ;; otherwise it's a symbol, and we can be more thorough (if (get original-command 'mc--unsupported) (message "%S is not supported with multiple cursors%s" original-command (get original-command 'mc--unsupported)) (when (and original-command (not (memq original-command mc--default-cmds-to-run-once)) (not (memq original-command mc/cmds-to-run-once)) (or mc/always-run-for-all (memq original-command mc--default-cmds-to-run-for-all) (memq original-command mc/cmds-to-run-for-all) (mc/prompt-for-inclusion-in-whitelist original-command))) (mc/execute-command-for-all-fake-cursors original-command)))))) (when mc/use-built-in-cursors (let* ((win (selected-window)) (window-start (window-start win)) (window-end (window-end win)) (overlays (mc/all-fake-cursors)) (lst (mapcar (lambda (x) (let* ((pos (overlay-start x)) (current-column (if (and (>= pos window-start) (<= pos window-end)) (save-excursion (goto-char pos) (current-column)) 0))) (cond ((oddp current-column) (list pos "bar" "#FF0000")) ;; red or [1.0 0.0 0.0] ((evenp current-column) (list pos "bar" "yellow"))))) ;; [1.0 1.0 0.0] overlays))) (setq mc-glyph-list lst))) ))))