emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/racket-mode 2d1fb865e0 2/3: racket-repl-mode and racket-xp


From: ELPA Syncer
Subject: [nongnu] elpa/racket-mode 2d1fb865e0 2/3: racket-repl-mode and racket-xp-mode: set next-error-last-buffer
Date: Tue, 21 Nov 2023 13:00:43 -0500 (EST)

branch: elpa/racket-mode
commit 2d1fb865e0a2c5a3946a2bcd73b2a73ef4e05d7a
Author: Greg Hendershott <git@greghendershott.com>
Commit: Greg Hendershott <git@greghendershott.com>

    racket-repl-mode and racket-xp-mode: set next-error-last-buffer
    
    Set next-error-last-buffer:
    
    1. On each run, to the racket-repl-mode buffer used by the run.
    
    This means next-error-find-buffer will look to that REPL buffer (as
    opposed to e.g. some compilation-mode buffer that happens to exist).
    
    2. On each racket-xp-mode annotation, to the edit buffer IFF there were
    expansion errors.
    
    This means the standard next-error and previous-error will work to
    show racket-xp-mode expansion errors, if any, else they'll defer to
    some other buffer such as racket-repl-mode.
    
    As a result we can mark our special racket-xp-{next previous}-error
    commands as obsolete. Change the menu and default keymap to use
    {next previous}-error.
    
    Fix obsolete.
---
 racket-repl.el |  8 +++++---
 racket-xp.el   | 49 ++++++++++++++++++++++++++++---------------------
 2 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/racket-repl.el b/racket-repl.el
index df128f2f21..f7edbe212e 100644
--- a/racket-repl.el
+++ b/racket-repl.el
@@ -1491,14 +1491,16 @@ See also the command 
`racket-repl-clear-leaving-last-prompt'."
 (defun racket--repl-forget-errors ()
   "Forget existing errors in the REPL.
 Although they remain clickable they will be ignored by
-`next-error' and `previous-error'"
+`next-error' and `previous-error'."
   (with-racket-repl-buffer
     (setq racket--errors-reset t)
-    (setq racket--errors-point-min (point-max))))
+    (setq racket--errors-point-min (point-max))
+    ;; Set this so `next-error-find-buffer' chooses us.
+    (setq next-error-last-buffer (current-buffer))))
 (add-hook 'racket--repl-before-run-hook #'racket--repl-forget-errors)
 
 (defun racket-repl-next-error (count reset)
-  "A value for `next-error-function'."
+  "A value for the variable `next-error-function'."
   (let ((prop 'racket-error-loc))
     (cl-flet* ((get () (get-text-property (point) prop))
                (next () (next-single-property-change (point) prop))
diff --git a/racket-xp.el b/racket-xp.el
index 95a20c7491..902cceaef8 100644
--- a/racket-xp.el
+++ b/racket-xp.el
@@ -53,8 +53,8 @@ everything. If you find that too \"noisy\", set this to nil.")
      (">" ,#'racket-xp-tail-next-sibling)
      ("<" ,#'racket-xp-tail-previous-sibling)
      ("g" ,#'racket-xp-annotate)
-     ("N" ,#'racket-xp-next-error)
-     ("P" ,#'racket-xp-previous-error))))
+     ("N" ,#'next-error)
+     ("P" ,#'previous-error))))
 
 (defvar racket-xp-mode-map
   (racket--easy-keymap-define
@@ -67,8 +67,8 @@ everything. If you find that too \"noisy\", set this to nil.")
 (easy-menu-define racket-xp-mode-menu racket-xp-mode-map
   "Menu for `racket-xp-mode'."
   '("Racket-XP"
-    ["Next Error" racket-xp-next-error]
-    ["Previous Error" racket-xp-previous-error]
+    ["Next Error" next-error]
+    ["Previous Error" previous-error]
     "---"
     ["Next Definition" racket-xp-next-definition]
     ["Previous Definition" racket-xp-previous-definition]
@@ -225,10 +225,10 @@ and use the `racket-xp-annotate' command manually.
 The mode line changes to reflect the current status of
 annotations, and whether or not you had a syntax error.
 
-If you have one or more syntax errors, `racket-xp-next-error' and
-`racket-xp-previous-error' navigate among them. Although most
-languages will stop after the first syntax error, some like Typed
-Racket will try to collect and report multiple errors.
+If you have one or more syntax errors, `next-error' and
+`previous-error' navigate among them. Although most languages
+will stop after the first syntax error, some like Typed Racket
+will try to collect and report multiple errors.
 
 You may use `xref-find-definitions' \\[xref-find-definitions],
 `xref-pop-marker-stack' \\[xref-pop-marker-stack], and
@@ -283,6 +283,7 @@ commands directly to whatever keys you prefer.
                    #'racket-xp-xref-backend-function
                    nil t)
          (setq-local imenu-create-index-function 
#'racket-xp-imenu-create-index-function)
+         (setq-local next-error-function #'racket-xp-next-error-function)
          (add-hook 'pre-redisplay-functions
                    #'racket-xp-pre-redisplay
                    nil t))
@@ -298,6 +299,7 @@ commands directly to whatever keys you prefer.
          (add-hook 'completion-at-point-functions
                    #'racket-complete-at-point
                    t t)
+         (setq-local next-error-function nil)
          (setq-local imenu-create-index-function 
#'racket-imenu-create-index-function)
          (remove-hook 'xref-backend-functions
                       #'racket-xp-xref-backend-function
@@ -417,6 +419,11 @@ manually."
               (completions . ,completions)
               (imenu       . ,imenu)
               (annotations . ,annotations))
+            ;; We have no errors; allow `next-error-find-buffer' to
+            ;; pick some other buffer, such as a `racket-repl-mode'
+            ;; buffer that set this when it ran.
+            (when (equal next-error-last-buffer (current-buffer))
+              (setq next-error-last-buffer nil))
             (racket--xp-clear)
             (setq racket--xp-binding-completions completions)
             (setq racket--xp-imenu-index imenu)
@@ -427,6 +434,8 @@ manually."
            (`(check-syntax-errors
               (errors      . ,errors)
               (annotations . ,annotations))
+            ;; Set this so `next-error-find-buffer' chooses us.
+            (setq next-error-last-buffer (current-buffer))
             ;; Don't do full `racket--xp-clear': The old completions and
             ;; some old annotations may be helpful to user while editing
             ;; to correct the error. However do clear things related to
@@ -976,20 +985,16 @@ Moving before/after the first/last tail wraps around."
         (vconcat racket--xp-errors
                  (vector (list path beg str)))))
 
-(defun racket--xp-next-error (&optional amt reset)
+(defun racket-xp-next-error-function (&optional amt reset)
   "Move AMT errors, if any.
 
-If there are any check-syntax errors, moves among them, wrapping
-around at the first and last errors.
+A value for the variable `next-error-function'.
 
-Otherwise delegate to `next-error'. That way, things still work
-as you would want when using `racket-run' -- e.g. for runtime
-evaluation errors that won't be found merely from expansion -- or
-`compilation-mode'."
+If there are any check-syntax errors, moves among them, wrapping
+around at the first and last errors."
   (interactive)
   (let ((len (length racket--xp-errors)))
-    (if (zerop len)
-        (next-error amt reset)
+    (unless (zerop len)
       (if reset
           (setq racket--xp-errors-index 0)
         (setq racket--xp-errors-index
@@ -1005,15 +1010,17 @@ evaluation errors that won't be found merely from 
expansion -- or
                (goto-char pos)))
         (message "%s" str)))))
 
+(make-obsolete 'racket-xp-next-error 'next-error "2023-11-20")
 (defun racket-xp-next-error ()
-  "Go to the next error."
+  "An obsolete alias for `next-error'."
   (interactive)
-  (racket--xp-next-error 1 nil))
+  (next-error))
 
+(make-obsolete 'racket-xp-previous-error 'previous-error "2023-11-20")
 (defun racket-xp-previous-error ()
-  "Go to the previous error."
+  "An obsolete alias for `previous-error'."
   (interactive)
-  (racket--xp-next-error -1 nil))
+  (previous-error))
 
 ;;; xref
 



reply via email to

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