|
4 | 4 |
|
5 | 5 | ;; Author: Oleh Krehel <[email protected]>
|
6 | 6 | ;; URL: https://github.com/abo-abo/lispy
|
7 |
| -;; Version: 0.22.0 |
| 7 | +;; Version: 0.23.0 |
8 | 8 | ;; Keywords: lisp
|
9 | 9 |
|
10 | 10 | ;; This file is not part of GNU Emacs
|
@@ -2682,33 +2682,18 @@ When ARG isn't nil, try to pretty print the sexp."
|
2682 | 2682 | (format "%s: nil" (propertize "cond" 'face 'font-lock-keyword-face))
|
2683 | 2683 | "Message to echo when the current `cond' branch is nil.")
|
2684 | 2684 |
|
2685 |
| -(defvar lispy-eval--active-window nil |
2686 |
| - "Source window for `lispy-eval-other-window'.") |
2687 |
| -(defvar lispy-eval--eval-window nil |
| 2685 | +(defvar lispy-eval-other--window nil |
2688 | 2686 | "Target window for `lispy-eval-other-window'.")
|
2689 |
| -(defvar lispy-eval--eval-buffer nil |
| 2687 | + |
| 2688 | +(defvar lispy-eval-other--buffer nil |
2690 | 2689 | "Target buffer for `lispy-eval-other-window'.")
|
2691 |
| -(defvar lispy-eval--expr nil |
2692 |
| - "The expression for`lispy-eval-other-window'.") |
2693 |
| - |
2694 |
| -(defun lispy--eval-in-window (aj-data) |
2695 |
| - "Eval in the context of AJ-DATA." |
2696 |
| - (let ((frame (aj-position-frame aj-data)) |
2697 |
| - (window (aj-position-window aj-data))) |
2698 |
| - (when (and (frame-live-p frame) |
2699 |
| - (not (eq frame (selected-frame)))) |
2700 |
| - (select-frame-set-input-focus frame)) |
2701 |
| - (select-window window) |
2702 |
| - (setq lispy-eval--eval-window window) |
2703 |
| - (setq lispy-eval--eval-buffer (current-buffer)) |
2704 |
| - (let ((res (condition-case e |
2705 |
| - (eval lispy-eval--expr lexical-binding) |
2706 |
| - (error |
2707 |
| - (message "error: %s" (error-message-string e)))))) |
2708 |
| - (if (equal res lispy--eval-cond-msg) |
2709 |
| - (message res) |
2710 |
| - (message "%S" res)) |
2711 |
| - (select-window lispy-eval--active-window)))) |
| 2690 | + |
| 2691 | +(defun lispy-eval--last-live-p () |
| 2692 | + (and (window-live-p |
| 2693 | + lispy-eval-other--window) |
| 2694 | + (equal (window-buffer |
| 2695 | + lispy-eval-other--window) |
| 2696 | + lispy-eval-other--buffer))) |
2712 | 2697 |
|
2713 | 2698 | (defun lispy-eval-other-window ()
|
2714 | 2699 | "Eval current expression in the context of other window.
|
@@ -2749,9 +2734,21 @@ In case the point is on a let-bound variable, add a `setq'."
|
2749 | 2734 | (t (read str)))))
|
2750 | 2735 | res)
|
2751 | 2736 | (goto-char pt)
|
2752 |
| - (other-window 1) |
2753 |
| - (setq res (eval expr lexical-binding)) |
2754 |
| - (other-window -1) |
| 2737 | + (let* ((source-window (selected-window)) |
| 2738 | + (target-window |
| 2739 | + (if (lispy-eval--last-live-p) |
| 2740 | + lispy-eval-other--window |
| 2741 | + (if (setq lispy-eval-other--window |
| 2742 | + (aw-select " Ace - Eval in Window")) |
| 2743 | + (progn |
| 2744 | + (setq lispy-eval-other--buffer |
| 2745 | + (window-buffer lispy-eval-other--window)) |
| 2746 | + lispy-eval-other--window) |
| 2747 | + (setq lispy-eval-other--buffer nil) |
| 2748 | + source-window)))) |
| 2749 | + (select-window target-window) |
| 2750 | + (setq res (eval expr lexical-binding)) |
| 2751 | + (select-window source-window)) |
2755 | 2752 | (if (equal res lispy--eval-cond-msg)
|
2756 | 2753 | (message res)
|
2757 | 2754 | (message "%S" res))))
|
|
0 commit comments