From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#22873: Can we support multiple Cursors? Date: Wed, 09 Mar 2016 18:03:25 +0200 Message-ID: <83h9gfprjm.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1457539463 20280 80.91.229.3 (9 Mar 2016 16:04:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Mar 2016 16:04:23 +0000 (UTC) Cc: jwiegley@gmail.com, mbork@mbork.pl, rms@gnu.org, 22873@debbugs.gnu.org To: Keith David Bershatsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 09 17:04:11 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1adgao-0000nD-Cs for geb-bug-gnu-emacs@m.gmane.org; Wed, 09 Mar 2016 17:04:10 +0100 Original-Received: from localhost ([::1]:42310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adgan-0004F7-QY for geb-bug-gnu-emacs@m.gmane.org; Wed, 09 Mar 2016 11:04:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adgaj-0004Ez-Cv for bug-gnu-emacs@gnu.org; Wed, 09 Mar 2016 11:04:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adgag-0003nL-5c for bug-gnu-emacs@gnu.org; Wed, 09 Mar 2016 11:04:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adgag-0003nH-3P for bug-gnu-emacs@gnu.org; Wed, 09 Mar 2016 11:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1adgaf-0000zi-Sq for bug-gnu-emacs@gnu.org; Wed, 09 Mar 2016 11:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Mar 2016 16:04: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.14575394153762 (code B ref 22873); Wed, 09 Mar 2016 16:04:01 +0000 Original-Received: (at 22873) by debbugs.gnu.org; 9 Mar 2016 16:03:35 +0000 Original-Received: from localhost ([127.0.0.1]:41693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1adgaF-0000yc-Bk for submit@debbugs.gnu.org; Wed, 09 Mar 2016 11:03:35 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45139) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1adgaD-0000yO-8x for 22873@debbugs.gnu.org; Wed, 09 Mar 2016 11:03:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adga2-0003aw-1l for 22873@debbugs.gnu.org; Wed, 09 Mar 2016 11:03:28 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adga1-0003as-Uu; Wed, 09 Mar 2016 11:03:21 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3664 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1adgZu-00044l-BG; Wed, 09 Mar 2016 11:03:14 -0500 In-reply-to: (message from Keith David Bershatsky on Tue, 08 Mar 2016 22:27:02 -0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:114644 Archived-At: > Date: Tue, 08 Mar 2016 22:27:02 -0800 > From: Keith David Bershatsky > Cc: 22873@debbugs.gnu.org > > The second draft of the proposed feature for multiple fake cursors is attached. For the record, I'm not a programmer -- just a hobbyist -- and the draft patch is not meant to be a proposed official patch -- it is just a working proof concept. The patch contains a few extra things that I use for debugging and also for drawing my solid vertical line that tracks the cursor position. It has been tested to some extent on Emacs built for OSX 10.6.8 and Windows XP (SP-3). Different colors for each fake cursor have already been implemented on Emacs for OSX, but I haven't yet looked into how to accomplish that objective on Emacs for Windows. The draft concept patch is for the master branch as of March 8, 2016 bearing commit "e0400b72a24d67b53f71c8b97915cae599e36c37". After applying the patc h, the new feature can be tested as follows: Looks like quite a few of the changes in the patch are not really related to multiple cursors. Did you produce diffs for all of your other local changes? > diff --git a/src/buffer.h b/src/buffer.h > index 5783bfb..01c3755 100644 > --- a/src/buffer.h > +++ b/src/buffer.h > @@ -643,6 +643,15 @@ struct buffer > cache are enabled. See search.c, indent.c and bidi.c for details. */ > Lisp_Object cache_long_scans_; > > + /* The name of the hook. */ > + Lisp_Object window_start_end_hook_; > + > + /* The name of list. */ > + Lisp_Object posn_list_; > + > + /* The name of list used by multiple cursors for next redisplay. */ > + Lisp_Object mc_list_; > + > /* If the width run cache is enabled, this table contains the > character widths width_run_cache (see above) assumes. When we > do a thorough redisplay, we compare this against the buffer's > @@ -885,6 +894,21 @@ struct buffer > buffer. (Some setters that are private to a single .c file are > defined as static in those files.) */ > INLINE void > +bset_window_start_end_hook (struct buffer *b, Lisp_Object val) > +{ > + b->window_start_end_hook_ = val; > +} The above inline function and the corresponding member of struct buffer seems unrelated. > diff --git a/src/keyboard.c b/src/keyboard.c > index 4e1ac15..329cba0 100644 > --- a/src/keyboard.c > +++ b/src/keyboard.c > @@ -1244,6 +1244,15 @@ static int read_key_sequence (Lisp_Object *, int, Lisp_Object, > bool, bool, bool, bool); > static void adjust_point_for_property (ptrdiff_t, bool); > > +static void > +set_window_start_end_hook (void) > +{ > + Lisp_Object window = (selected_window); > + struct window *w = decode_live_window (window); > + w->window_start_end_hook_force = true; > + w->window_start_end_hook_pending = true; > +} > + > Lisp_Object > command_loop_1 (void) > { > @@ -1269,6 +1278,8 @@ command_loop_1 (void) > if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks)) > safe_run_hooks (Qpost_command_hook); > > + set_window_start_end_hook (); > + > /* If displaying a message, resize the echo area window to fit > that message's size exactly. */ > if (!NILP (echo_area_buffer[0])) > @@ -1485,6 +1496,8 @@ command_loop_1 (void) > > safe_run_hooks (Qpost_command_hook); > > + set_window_start_end_hook (); > + > /* If displaying a message, resize the echo area window to fit > that message's size exactly. */ > if (!NILP (echo_area_buffer[0])) Likewise. > diff --git a/src/xdisp.c b/src/xdisp.c > index 5b96144..102ac23 100644 > --- a/src/xdisp.c > +++ b/src/xdisp.c > @@ -13414,6 +13414,93 @@ do { if (! polling_stopped_here) stop_polling (); \ > do { if (polling_stopped_here) start_polling (); \ > polling_stopped_here = false; } while (false) > > +static void > +run_window_start_end_hook (Lisp_Object window, struct text_pos startp, EMACS_INT posint, struct it it, char *string, bool force) > +{ Likewise. > + case 'w': > + { > + ptrdiff_t window_start = marker_position (w->start); > + pint2str (decode_mode_spec_buf, width, window_start); > + return decode_mode_spec_buf; > + } > + > + case 'W': > + { > + ptrdiff_t window_end = BUF_Z (b) - w->window_end_pos; > + pint2str (decode_mode_spec_buf, width, window_end); > + return decode_mode_spec_buf; > + } > + Likewise. > +static const char * > +internal_line_number_at_position (struct window *w, register int c, int field_width, Lisp_Object *string) > +{ Likewise. > +DEFUN ("line-number-at-position", Fline_number_at_position, Sline_number_at_position, 1, 2, 0, > + doc: /* Return line number at position. */) > + (Lisp_Object window, Lisp_Object pos) > +{ Likewise. Thanks.