emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making edebug work with Follow Mode


From: Alan Mackenzie
Subject: Making edebug work with Follow Mode
Date: Sun, 15 Mar 2015 13:55:27 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]