[slime-cvs] CVS slime
trittweiler
trittweiler at common-lisp.net
Sat Jul 19 11:34:20 UTC 2008
Update of /project/slime/cvsroot/slime
In directory clnet:/tmp/cvs-serv30883
Modified Files:
slime.el ChangeLog
Log Message:
REPL shortcuts now leave an appropriate Common Lisp form in the
REPL history.
* slime.el (slime-within-repl-shortcut-handler-p): New global. T
if truly inside a repl shortcut handler invoked by ,foo on the
REPL.
(slime-handle-repl-shortcut): Bind above global appropriatly.
(slime-repl-shortcut-eval): New; should be used in repl shortcut
handlers instead of `slime-eval'.
(slime-repl-shortcut-eval-async): New; should be used in repl
shortcut handlers instead of `slime-eval-async'.
(defslime-repl-shortcut): Update docstring.
(slime-repl-set-package): Use slime-repl-shortcut-eval.
(slime-set-default-directory): Ditto.
(slime-sync-package-and-default-directory): Ditto.
--- /project/slime/cvsroot/slime/slime.el 2008/07/17 22:49:36 1.948
+++ /project/slime/cvsroot/slime/slime.el 2008/07/19 11:34:19 1.949
@@ -3190,7 +3190,7 @@
(with-current-buffer (slime-output-buffer)
(let ((unfinished-input (slime-repl-current-input)))
(destructuring-bind (name prompt-string)
- (slime-eval `(swank:set-package ,package))
+ (slime-repl-shortcut-eval `(swank:set-package ,package))
(setf (slime-lisp-package) name)
(setf (slime-lisp-package-prompt-string) prompt-string)
(slime-repl-insert-prompt)
@@ -3500,6 +3500,9 @@
(defvar slime-repl-shortcut-history '()
"History list of shortcut command names.")
+(defvar slime-within-repl-shortcut-handler-p nil
+ "Bound to T if we're in a REPL shortcut handler invoked from the REPL.")
+
(defun slime-handle-repl-shortcut ()
(interactive)
(if (> (point) slime-repl-input-start-mark)
@@ -3510,7 +3513,9 @@
(slime-list-all-repl-shortcuts))
nil t nil
'slime-repl-shortcut-history))))
- (call-interactively (slime-repl-shortcut.handler shortcut)))))
+ (with-struct (slime-repl-shortcut. handler) shortcut
+ (let ((slime-within-repl-shortcut-handler-p t))
+ (call-interactively handler))))))
(defun slime-list-all-repl-shortcuts ()
(loop for shortcut in slime-repl-shortcut-table
@@ -3522,10 +3527,13 @@
(defmacro defslime-repl-shortcut (elisp-name names &rest options)
"Define a new repl shortcut. ELISP-NAME is a symbol specifying
- the name of the interactive function to create, or NIL if no
- function should be created. NAMES is a list of (full-name .
- aliases). OPTIONS is an olist specifying the handler and the
- help text."
+the name of the interactive function to create, or NIL if no
+function should be created.
+
+NAMES is a list of \(full-name . aliases\).
+
+OPTIONS is an plist specifying the handler doing the actual work
+of the shortcut \(`:handler'\), and a help text \(`:one-liner'\)."
`(progn
,(when elisp-name
`(defun ,elisp-name ()
@@ -3542,6 +3550,23 @@
(push new-shortcut slime-repl-shortcut-table)
',elisp-name)))
+(defun slime-repl-shortcut-eval (sexp &optional package)
+ "This function should be used by REPL shortcut handlers instead
+of `slime-eval' to evaluate their final expansion. (This
+expansion will be added to the REPL's history.)"
+ (when slime-within-repl-shortcut-handler-p ; were we invoked via ,foo?
+ (slime-repl-add-to-input-history (prin1-to-string sexp)))
+ (slime-eval sexp package))
+
+(defun slime-repl-shortcut-eval-async (sexp &optional cont package)
+ "This function should be used by REPL shortcut handlers instead
+of `slime-eval-async' to evaluate their final expansion. (This
+expansion will be added to the REPL's history.)"
+ (when slime-within-repl-shortcut-handler-p ; were we invoked via ,foo?
+ (slime-repl-add-to-input-history (prin1-to-string sexp)))
+ (slime-eval-async sexp cont package))
+
+
(defun slime-list-repl-short-cuts ()
(interactive)
(slime-with-output-to-temp-buffer ("*slime-repl-help*") nil
@@ -3567,6 +3592,7 @@
(not (null buffer-file-name)))))
(save-some-buffers)))
+
(defslime-repl-shortcut slime-repl-shortcut-help ("help" "?")
(:handler 'slime-list-repl-short-cuts)
(:one-liner "Display the help."))
@@ -3663,7 +3689,7 @@
(interactive (list (expand-file-name
(read-file-name "File: " nil nil nil nil))))
(slime-save-some-lisp-buffers)
- (slime-eval-async
+ (slime-repl-shortcut-eval-async
`(swank:compile-file-if-needed
,(slime-to-lisp-filename filename) t)
(slime-make-compilation-finished-continuation (current-buffer)))))
@@ -5300,6 +5326,10 @@
(t (message "%s" value)))))
fn)))
+(defun slime-show-description (string package)
+ (slime-with-output-to-temp-buffer ("*SLIME Description*")
+ package (princ string)))
+
(defun slime-eval-describe (form)
"Evaluate FORM in Lisp and display the result in a new buffer."
(lexical-let ((package (slime-current-package)))
@@ -5765,10 +5795,6 @@
'common-lisp-hyperspec-history)))))
(hyperspec-lookup symbol-name))
-(defun slime-show-description (string package)
- (slime-with-output-to-temp-buffer ("*SLIME Description*")
- package (princ string)))
-
(defun slime-describe-symbol (symbol-name)
"Describe the symbol at point."
(interactive (list (slime-read-symbol-name "Describe symbol: ")))
@@ -6081,9 +6107,6 @@
(lexical-let ((type type)
(symbol symbol)
(package (slime-current-package))
- ;; We have to take the snapshot here, because SLIME-EVAL-ASYNC
- ;; is invoking its continuation within the extent of a different
- ;; buffer. (2007-08-14)
(snapshot (slime-current-emacs-snapshot)))
(lambda (result)
(let ((file-alist (cadr (slime-analyze-xrefs result))))
@@ -6104,7 +6127,7 @@
(save-excursion
(beginning-of-line 1)
(with-syntax-table lisp-mode-syntax-table
- (forward-sexp)
+ (forward-sexp) ; skip initial whitespaces
(backward-sexp)
(slime-sexp-at-point))))
@@ -6395,20 +6418,20 @@
(let ((dir (expand-file-name directory)))
(message "default-directory: %s"
(slime-from-lisp-filename
- (slime-eval `(swank:set-default-directory
- ,(slime-to-lisp-filename dir)))))
+ (slime-repl-shortcut-eval `(swank:set-default-directory
+ ,(slime-to-lisp-filename dir)))))
(with-current-buffer (slime-output-buffer)
(setq default-directory dir))))
(defun slime-sync-package-and-default-directory ()
"Set Lisp's package and directory to the values in current buffer."
(interactive)
- (let ((package (slime-eval `(swank:set-package
- ,(slime-find-buffer-package))))
+ (let ((package (slime-repl-shortcut-eval `(swank:set-package
+ ,(slime-find-buffer-package))))
(directory (slime-from-lisp-filename
- (slime-eval `(swank:set-default-directory
- ,(slime-to-lisp-filename
- default-directory))))))
+ (slime-repl-shortcut-eval `(swank:set-default-directory
+ ,(slime-to-lisp-filename
+ default-directory))))))
(let ((dir default-directory))
;; Sync REPL dir
(with-current-buffer (slime-output-buffer)
--- /project/slime/cvsroot/slime/ChangeLog 2008/07/17 22:49:36 1.1371
+++ /project/slime/cvsroot/slime/ChangeLog 2008/07/19 11:34:19 1.1372
@@ -1,3 +1,21 @@
+2008-07-19 Tobias C. Rittweiler <tcr at freebits.de>
+
+ REPL shortcuts now leave an appropriate Common Lisp form in the
+ REPL history.
+
+ * slime.el (slime-within-repl-shortcut-handler-p): New global. T
+ if truly inside a repl shortcut handler invoked by ,foo on the
+ REPL.
+ (slime-handle-repl-shortcut): Bind above global appropriatly.
+ (slime-repl-shortcut-eval): New; should be used in repl shortcut
+ handlers instead of `slime-eval'.
+ (slime-repl-shortcut-eval-async): New; should be used in repl
+ shortcut handlers instead of `slime-eval-async'.
+ (defslime-repl-shortcut): Update docstring.
+ (slime-repl-set-package): Use slime-repl-shortcut-eval.
+ (slime-set-default-directory): Ditto.
+ (slime-sync-package-and-default-directory): Ditto.
+
2008-07-18 Tobias C. Rittweiler <tcr at freebits.de>
* slime.el (slime-recompile-locations): Locations were potentially
More information about the slime-cvs
mailing list