unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Nathaniel Flath <flat0103@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: Overalays and point-entered
Date: Wed, 16 Sep 2009 16:46:33 -0400	[thread overview]
Message-ID: <5e3a506e0909161346w1d5a8bebp84f1d51f0f446f28@mail.gmail.com> (raw)
In-Reply-To: <jwvzl8x49un.fsf-monnier+emacs@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 1538 bytes --]

I wrote a patch to add point-left and point-entered to overlays.  I ended up
adding the implementation in command_loop_1.  The patch is attached - let me
know if anything needs to be fixed.

Thanks,
Nathaniel Flath

On Mon, Sep 14, 2009 at 3:22 PM, Stefan Monnier <monnier@iro.umontreal.ca>wrote:

> > By cursor motion, do you mean such as the cursor_to function in
> terminal.c?
>
> No, not exactly.  I mean more generally to trigger the code based on the
> motion that happen from command to command.  It could mean a hook in
> something like cursor_to, but it could also mean a hook in
> command_loop_1 (along the lines of what's done with
> adjust_point_for_property.
>
> > Adding these hook to that function seems to behave similarly to when I
> add
> > them to the point motion commands,
>
> The different between point-motion and cursor-motion can only be seen
> for operations that do a lot of internal movement.
> E.g. diff-context->unified.  Point-motion hooks will be triggered many
> times during a run of diff-context->unified (and may accidentally cause
> it to fail) whereas cursor motion hooks should only be triggered once
> after the command is done, so it can't cause it to fail.
>
> > in that modes or commands that do not appear to move the cursor( any
> > mode that traverses the buffer) will still trigger the hooks.
>
> If such a hook is run a bit more often than strictly needed, it's
> usually not considered a bug (tho it is recognized as a misfeature).
> So it might still be acceptable.
>
>
>        Stefan
>

[-- Attachment #1.2: Type: text/html, Size: 2047 bytes --]

[-- Attachment #2: overlay-properties.patch --]
[-- Type: text/x-patch, Size: 2673 bytes --]

--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1970,5 +1970,63 @@ command_loop_1 ()

     finalize:

+      /* Run point-entered and point-left hooks for overlays */
+      if (NILP (Vinhibit_point_motion_hooks))
+        {
+          int i, j;
+          int noverlays_cur, noverlays_prev;
+          Lisp_Object *overlay_cur_vec;
+          Lisp_Object *overlay_prev_vec;
+          extern Lisp_Object Qpoint_entered, Qpoint_left, Qwindow;
+          Lisp_Object point_left, point_entered;
+          Lisp_Object overlay_window;
+
+          GET_OVERLAYS_AT (current_buffer->pt,
+                           overlay_cur_vec,
+                           noverlays_cur,
+                           NULL,
+                           0);
+          GET_OVERLAYS_AT (last_point_position,
+                           overlay_prev_vec,
+                           noverlays_prev,
+                           NULL,
+                           0);
+
+          /* Go through each overlay that overlapped last_point_position and
+             run it's point_left hook only if the current location is not
+             overlapped by that overlay. */
+          for (i = 0; i < noverlays_prev; i++)
+            {
+              for (j = 0; j < noverlays_cur; j++)
+                {
+                  if (overlay_prev_vec[i] == overlay_cur_vec[j])
+                    goto next_overlay;
+                }
+              point_left = Foverlay_get (overlay_prev_vec[i], Qpoint_left);
+              overlay_window = Foverlay_get (overlay_prev_vec[i], Qwindow);
+              if (!NILP (point_left)
+                  && (NILP (overlay_window)
+                      || !NILP (Feq (overlay_window, Fselected_window()))))
+                call2 (point_left,
+                       make_number (last_point_position),
+                       make_number (current_buffer->pt));
+
+            next_overlay:
+              i = i;
+            }
+
+          /* Run point_entered functions for all overlays overlapping the
+             current point */
+          for (i = 0; i < noverlays_cur; i++)
+            {
+              point_entered = Foverlay_get (overlay_cur_vec[i], Qpoint_entered);
+              overlay_window = Foverlay_get (overlay_cur_vec[i], Qwindow);
+              if (!NILP (point_entered)
+                  && (NILP (overlay_window)
+                      || !NILP (Feq (overlay_window, Fselected_window()))))
+                call2 (point_entered, make_number (last_point_position), make_number (current_buffer->pt));
+            }
+        }
+
       if (current_buffer == prev_buffer
 	  && last_point_position != PT
 	  && NILP (Vdisable_point_adjustment)

  parent reply	other threads:[~2009-09-16 20:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-11  0:09 Overalays and point-entered Nathaniel Flath
2009-09-11  1:57 ` Stefan Monnier
     [not found]   ` <5e3a506e0909101902h72747299u2e306830ce63b11d@mail.gmail.com>
     [not found]     ` <jwvmy52p4re.fsf-monnier+emacs@gnu.org>
2009-09-11  4:08       ` Nathaniel Flath
2009-09-13 16:47         ` Nathaniel Flath
2009-09-14  1:16           ` Stefan Monnier
     [not found]             ` <5e3a506e0909140810r38a83a84l387fb6bafeb962c1@mail.gmail.com>
     [not found]               ` <jwvzl8x49un.fsf-monnier+emacs@gnu.org>
2009-09-16 20:46                 ` Nathaniel Flath [this message]
2009-09-17  1:05                   ` Stefan Monnier
2009-09-23 15:41                     ` Nathaniel Flath
2009-09-23 20:55                       ` Stefan Monnier
2009-09-24  1:07                         ` Stephen J. Turnbull
2009-09-24 14:31                           ` Overlays " Stefan Monnier
2009-09-24 13:47                         ` Overalays " Nathaniel Flath
2009-09-24 14:04                           ` Nathaniel Flath
2009-09-24 14:26                             ` Stefan Monnier
2009-10-06 18:33                               ` Nathaniel Flath
2009-10-17 17:00                                 ` Nathaniel Flath
2009-10-18  1:09                                   ` Stefan Monnier
2009-10-22  3:35                                     ` Nathaniel Flath
2009-10-22 15:37                                       ` Stefan Monnier
2009-10-23 15:43                                         ` Nathaniel Flath
2009-10-25  2:30                                           ` Stefan Monnier
2009-10-27  8:42                                             ` Nathaniel Flath
2009-10-27 13:28                                               ` Stefan Monnier
2009-10-28  0:44                                                 ` Miles Bader
2009-10-31 17:03                                                   ` Nathaniel Flath
2009-11-06 14:54                                                     ` Nathaniel Flath
2009-12-09 23:41                                                       ` Nathaniel Flath
2009-12-10  3:37                                                         ` Nathaniel Flath
2009-12-10  8:32                                                           ` Stefan Monnier
2009-12-20 23:39                                                             ` Nathaniel Flath
2010-01-02  3:34                                                               ` Nathaniel Flath
2010-01-08  7:19                                                                 ` Nathaniel Flath
2010-01-15  2:38                                                                   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5e3a506e0909161346w1d5a8bebp84f1d51f0f446f28@mail.gmail.com \
    --to=flat0103@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).