all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: emacs-devel@gnu.org
Subject: Making edebug work with Follow Mode
Date: Sun, 15 Mar 2015 13:55:27 +0000	[thread overview]
Message-ID: <20150315135527.GA3800@acm.fritz.box> (raw)

Hi, Emacs.

Right now, edebug doesn't work with Follow Mode.  In particular, when
stepping through a file.el in two or three side by side Follow Mode
windows, edebug restricts its activities to just one window.  This is
undesirable.

There are two reasons for this failure.  The main one is that edebug
binds post-command-hook to nil, switching off Follow Mode's mechanism.
A subsidiary reason is the calling, from edebug--display-1 of
edebug-adjust-window; this usurps redisplay's scrolling functionality,
and is also the cause of the (to me) irritating recentring of the buffer
when point goes off the bottom of the window, regardless of the user's
setting of scroll-conservatively.

As the main fix, I have introduced two new customisable options,
edebug-OK-functions-for-post-command-hook, and (purely for symmetry)
edebug-OK-functions-for-pre-command-hook.  Any functions listed in these
variables are left on the pertinent hook by edebug.  Currently only
follow-post-command-hook is there.

As the subsidiary fix, I've commented out edebug-adjust-windows and the
call to it.  It seems redundant; redisplay is quite capable of setting
an appropriate window-start.

Here's the patch.  Comments?



diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 1091877..dec46a3 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -232,6 +232,25 @@ If the result is non-nil, then break.  Errors are ignored."
   :type 'number
   :group 'edebug)
 
+(defcustom edebug-OK-functions-for-pre-command-hook nil
+  "A list of functions edebug will leave on `pre-command-hook'
+whilst edebug is active.  All other elements of
+`pre-command-hook' are removed from the hook.
+
+Do not include in this list any functions you will be edebugging."
+  :type '(repeat function)
+  :group 'edebug)
+
+(defcustom edebug-OK-functions-for-post-command-hook
+  '(follow-post-command-hook)
+  "A list of functions edebug will leave on `post-command-hook'
+whilst edebug is active.  All other elements of
+`post-command-hook' are removed from the hook.
+
+Do not include in this list any functions you will be edebugging."
+  :type '(repeat function)
+  :group 'edebug)
+
 ;;; Form spec utilities.
 
 (defun get-edebug-spec (symbol)
@@ -2446,8 +2465,11 @@ MSG is printed after `::::} '."
                               edebug-function)
                 ))
 
-	  (setcdr edebug-window-data
-		  (edebug-adjust-window (cdr edebug-window-data)))
+	  ;; The following usurps redisplay's functionality, and
+	  ;; doesn't seem to be needed; redisplay will perform any
+	  ;; needed scrolling at the next `recursive-edit'.  2015-03.
+	  ;; (setcdr edebug-window-data
+	  ;; 	  (edebug-adjust-window (cdr edebug-window-data)))
 
 	  ;; Test if there is input, not including keyboard macros.
 	  (if (input-pending-p)
@@ -2677,11 +2699,15 @@ MSG is printed after `::::} '."
 	      (defining-kbd-macro
 		(if edebug-continue-kbd-macro defining-kbd-macro))
 
-	      ;; Disable command hooks.  This is essential when
-	      ;; a hook function is instrumented - to avoid infinite loop.
-	      ;; This may be more than we need, however.
-	      (pre-command-hook nil)
-	      (post-command-hook nil)
+	      ;; Remove from the command hooks all but allowed functions.
+	      ;; An instrumented function may not be on either of these
+	      ;; hooks.
+	      (pre-command-hook
+	       (cl-intersection pre-command-hook
+				edebug-OK-functions-for-pre-command-hook))
+	      (post-command-hook
+	       (cl-intersection post-command-hook
+				edebug-OK-functions-for-post-command-hook))
 
 	      ;; others??
 	      )
@@ -2722,28 +2748,28 @@ MSG is printed after `::::} '."
 
 ;;; Display related functions
 
-(defun edebug-adjust-window (old-start)
-  ;; If pos is not visible, adjust current window to fit following context.
-  ;; (message "window: %s old-start: %s window-start: %s pos: %s"
-  ;;          (selected-window) old-start (window-start) (point)) (sit-for 5)
-  (if (not (pos-visible-in-window-p))
-      (progn
-	;; First try old-start
-	(if old-start
-	    (set-window-start (selected-window) old-start))
-	(if (not (pos-visible-in-window-p))
-	    (progn
-	;; (message "resetting window start") (sit-for 2)
-	(set-window-start
-	 (selected-window)
-	 (save-excursion
-	   (forward-line
-	    (if (< (point) (window-start)) -1	; one line before if in back
-	      (- (/ (window-height) 2)) ; center the line moving forward
-	      ))
-	   (beginning-of-line)
-	   (point)))))))
-  (window-start))
+;; (defun edebug-adjust-window (old-start)
+;;   ;; If pos is not visible, adjust current window to fit following context.
+;;   ;; (message "window: %s old-start: %s window-start: %s pos: %s"
+;;   ;;          (selected-window) old-start (window-start) (point)) (sit-for 5)
+;;   (if (not (pos-visible-in-window-p))
+;;       (progn
+;; 	;; First try old-start
+;; 	(if old-start
+;; 	    (set-window-start (selected-window) old-start))
+;; 	(if (not (pos-visible-in-window-p))
+;; 	    (progn
+;; 	;; (message "resetting window start") (sit-for 2)
+;; 	(set-window-start
+;; 	 (selected-window)
+;; 	 (save-excursion
+;; 	   (forward-line
+;; 	    (if (< (point) (window-start)) -1	; one line before if in back
+;; 	      (- (/ (window-height) 2)) ; center the line moving forward
+;; 	      ))
+;; 	   (beginning-of-line)
+;; 	   (point)))))))
+;;   (window-start))
 
 
 
-- 
Alan Mackenzie (Nuremberg, Germany).



             reply	other threads:[~2015-03-15 13:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-15 13:55 Alan Mackenzie [this message]
2015-03-15 14:20 ` Making edebug work with Follow Mode vibhavp
2015-03-15 19:12 ` Stefan Monnier
2015-03-16 17:20   ` Alan Mackenzie

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

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

  git send-email \
    --in-reply-to=20150315135527.GA3800@acm.fritz.box \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.