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

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

[nongnu] elpa/sweeprolog e991b1a92c 097/166: ENHANCED: (sweep-load-buffe


From: ELPA Syncer
Subject: [nongnu] elpa/sweeprolog e991b1a92c 097/166: ENHANCED: (sweep-load-buffer): use read-buffer to choose a buffer
Date: Fri, 30 Sep 2022 04:59:29 -0400 (EDT)

branch: elpa/sweeprolog
commit e991b1a92c038b87ec490d1620fa7669a9b9045d
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    ENHANCED: (sweep-load-buffer): use read-buffer to choose a buffer
---
 sweep.el | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/sweep.el b/sweep.el
index ac15758d8f..47661511b1 100644
--- a/sweep.el
+++ b/sweep.el
@@ -867,9 +867,25 @@ module name, F is a functor name and N is its arity."
           (sweep-close-query)
           sol)))))
 
-(defun sweep-load-buffer (&optional buffer)
-  (interactive)
-  (with-current-buffer (or buffer (current-buffer))
+(defun sweep-load-buffer (buffer)
+  "Load the Prolog buffer BUFFER into the embedded SWI-Prolog runtime.
+
+Interactively, if the major mode of the current buffer is
+`sweep-mode' and the command is called without a prefix argument,
+load the current buffer.  Otherwise, prompt for a `sweep-mode'
+buffer to load."
+  (interactive (if (and (not current-prefix-arg)
+                        (eq major-mode 'sweep-mode))
+                   (list (current-buffer))
+                 (read-buffer "Load buffer: "
+                              (when (eq major-mode 'sweep-mode)
+                                (buffer-name))
+                              t
+                              (lambda (b)
+                                (let ((n (or (and (consp b) (car b)) b)))
+                                  (with-current-buffer n
+                                    (eq major-mode 'sweep-mode)))))))
+  (with-current-buffer buffer
     (let* ((beg (point-min))
            (end (point-max))
            (contents (buffer-substring-no-properties beg end)))



reply via email to

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