From heller at common-lisp.net Fri Oct 1 09:30:34 2010 From: heller at common-lisp.net (CVS User heller) Date: Fri, 01 Oct 2010 05:30:34 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv21431 Modified Files: ChangeLog slime.el Log Message: Save result in kill ring for M-- C-x C-e. For C-u C-x C-e set mark before inserting. * slime.el (slime-eval-save): New function. (slime-eval-print): Set mark before inserting. (slime-interactive-eval): Use it. --- /project/slime/cvsroot/slime/ChangeLog 2010/09/22 19:17:35 1.2144 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/01 09:30:34 1.2145 @@ -1,3 +1,12 @@ +2010-10-01 Helmut Eller + + Save result in kill ring for M-- C-x C-e. + For C-u C-x C-e set mark before inserting. + + * slime.el (slime-eval-save): New function. + (slime-eval-print): Set mark before inserting. + (slime-interactive-eval): Use it. + 2010-09-22 Stas Boukarev * swank.lisp (eval-for-emacs): Send (:abort condition) where --- /project/slime/cvsroot/slime/slime.el 2010/09/22 19:17:35 1.1340 +++ /project/slime/cvsroot/slime/slime.el 2010/10/01 09:30:34 1.1341 @@ -4055,26 +4055,22 @@ Note: If a prefix argument is in effect then the result will be inserted in the current buffer." (interactive (list (slime-read-from-minibuffer "Slime Eval: "))) - (cond ((not current-prefix-arg) - (slime-eval-with-transcript `(swank:interactive-eval ,string))) - (t - (slime-eval-print string)))) - -(defun slime-display-eval-result (value) - (slime-message "%s" value)) - -(defun slime-eval-print (string) - "Eval STRING in Lisp; insert any output and the result at point." - (slime-eval-async `(swank:eval-and-grab-output ,string) - (lambda (result) - (destructuring-bind (output value) result - (insert output value))))) + (case current-prefix-arg + ((nil) + (slime-eval-with-transcript `(swank:interactive-eval ,string))) + ((-) + (slime-eval-save string)) + (t + (slime-eval-print string)))) (defvar slime-transcript-start-hook nil "Hook run before start an evalution.") (defvar slime-transcript-stop-hook nil "Hook run after finishing a evalution.") +(defun slime-display-eval-result (value) + (slime-message "%s" value)) + (defun slime-eval-with-transcript (form) "Eval FROM in Lisp. Display output, if any." (run-hooks 'slime-transcript-start-hook) @@ -4085,6 +4081,23 @@ ((:abort condition) (run-hooks 'slime-transcript-stop-hook) (message "Evaluation aborted on %s." condition)))) + +(defun slime-eval-print (string) + "Eval STRING in Lisp; insert any output and the result at point." + (slime-eval-async `(swank:eval-and-grab-output ,string) + (lambda (result) + (destructuring-bind (output value) result + (push-mark) + (insert output value))))) + +(defun slime-eval-save (string) + "Evaluate STRING in Lisp and save the result in the kill ring." + (slime-eval-async `(swank:eval-and-grab-output ,string) + (lambda (result) + (destructuring-bind (output value) result + (let ((string (concat output value))) + (kill-new string) + (message "Evaluation finished; pushed result to kill ring.")))))) (defun slime-eval-describe (form) "Evaluate FORM in Lisp and display the result in a new buffer." From heller at common-lisp.net Fri Oct 1 09:30:43 2010 From: heller at common-lisp.net (CVS User heller) Date: Fri, 01 Oct 2010 05:30:43 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv21469 Modified Files: ChangeLog slime.el Log Message: Don't use indent-sexp for macroexpanded code. indent-sexp is potentially slow and usually redundant. * slime.el (slime-initialize-macroexpansion-buffer): Don't use indent-sexp. (slime-eval-macroexpand-inplace): Avoid indent-sexp but use slime-insert-indented. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/01 09:30:34 1.2145 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/01 09:30:43 1.2146 @@ -1,5 +1,15 @@ 2010-10-01 Helmut Eller + Don't use indent-sexp for macroexpanded code. + indent-sexp is potentially slow and usually redundant. + + * slime.el (slime-initialize-macroexpansion-buffer): Don't use + indent-sexp. + (slime-eval-macroexpand-inplace): Avoid indent-sexp but + use slime-insert-indented. + +2010-10-01 Helmut Eller + Save result in kill ring for M-- C-x C-e. For C-u C-x C-e set mark before inserting. --- /project/slime/cvsroot/slime/slime.el 2010/10/01 09:30:34 1.1341 +++ /project/slime/cvsroot/slime/slime.el 2010/10/01 09:30:43 1.1342 @@ -4955,7 +4955,6 @@ (erase-buffer) (insert expansion) (goto-char (point-min)) - (indent-sexp) (font-lock-fontify-buffer))) (defun slime-create-macroexpansion-buffer () @@ -4988,9 +4987,7 @@ (slime-remove-edits (point-min) (point-max))) (goto-char start) (delete-region start end) - (insert expansion) - (goto-char start) - (indent-sexp) + (slime-insert-indented expansion) (goto-char point)))))))) (defun slime-macroexpand-1 (&optional repeatedly) @@ -8065,7 +8062,8 @@ (slime-execute-as-command 'slime-macroexpand-1) (slime-wait-condition "Macroexpansion buffer visible" (lambda () - (slime-buffer-visible-p (slime-buffer-name :macroexpansion))) + (slime-buffer-visible-p + (slime-buffer-name :macroexpansion))) 5) (with-current-buffer (get-buffer (slime-buffer-name :macroexpansion)) (slime-test-expect "Initial macroexpansion is correct" From heller at common-lisp.net Sat Oct 2 11:16:55 2010 From: heller at common-lisp.net (CVS User heller) Date: Sat, 02 Oct 2010 07:16:55 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv8101 Modified Files: ChangeLog slime.el swank.lisp Log Message: Rename slime-macro/compiler-macro-expand-1 => slime-expand-1 * slime.el (slime-expand-1): Renamed from slime-macro/compiler-macro-expand-1. (slime-expand-1-inplace): Renamed from slime-macro/compiler-macro-expand-1-inplace. * swank.lisp (swank-expand-1): Renamed from swank-macro/compiler-macro-expand-1. (swank-expand): Renamed from swank-macro/compiler-macro-expand. (expand-1): Renamed from macro/compiler-macro-expand-1. (expand): Renamed from macro/compiler-macro-expand. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/01 09:30:43 1.2146 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/02 11:16:54 1.2147 @@ -1,3 +1,18 @@ +2010-10-02 Helmut Eller + + Rename slime-macro/compiler-macro-expand-1 => slime-expand-1 + + * slime.el (slime-expand-1): Renamed from + slime-macro/compiler-macro-expand-1. + (slime-expand-1-inplace): Renamed from + slime-macro/compiler-macro-expand-1-inplace. + + * swank.lisp (swank-expand-1): Renamed from + swank-macro/compiler-macro-expand-1. + (swank-expand): Renamed from swank-macro/compiler-macro-expand. + (expand-1): Renamed from macro/compiler-macro-expand-1. + (expand): Renamed from macro/compiler-macro-expand. + 2010-10-01 Helmut Eller Don't use indent-sexp for macroexpanded code. --- /project/slime/cvsroot/slime/slime.el 2010/10/01 09:30:43 1.1342 +++ /project/slime/cvsroot/slime/slime.el 2010/10/02 11:16:54 1.1343 @@ -550,7 +550,7 @@ ;;("\C-x\M-e" slime-eval-last-expression-display-output :inferior t) ("\C-c\C-p" slime-pprint-eval-last-expression) ;; Macroexpand - ("\C-c\C-m" slime-macro/compiler-macro-expand-1) + ("\C-c\C-m" slime-expand-1) ("\C-c\M-m" slime-macroexpand-all) ;; Misc ("\C-c\C-u" slime-undefine-function) @@ -4892,8 +4892,8 @@ (remap 'slime-macroexpand-1 'slime-macroexpand-1-inplace) (remap 'slime-macroexpand-all 'slime-macroexpand-all-inplace) (remap 'slime-compiler-macroexpand-1 'slime-compiler-macroexpand-1-inplace) - (remap 'slime-macro/compiler-macro-expand-1 - 'slime-macro/compiler-macro-expand-1-inplace) + (remap 'slime-expand-1 + 'slime-expand-1-inplace) (remap 'advertised-undo 'slime-macroexpand-undo) (remap 'undo 'slime-macroexpand-undo)) @@ -5029,25 +5029,25 @@ 'swank:swank-compiler-macroexpand 'swank:swank-compiler-macroexpand-1))) -(defun slime-macro/compiler-macro-expand-1 (&optional repeatedly) +(defun slime-expand-1 (&optional repeatedly) "Display the macro expansion of the form at point. The form is expanded with CL:MACROEXPAND-1 or, if a prefix argument is given, with CL:MACROEXPAND." (interactive "P") (slime-eval-macroexpand (if repeatedly - 'swank:swank-macro/compiler-macro-expand - 'swank:swank-macro/compiler-macro-expand-1))) + 'swank:swank-expand + 'swank:swank-expand-1))) -(defun slime-macro/compiler-macro-expand-1-inplace (&optional repeatedly) +(defun slime-expand-1-inplace (&optional repeatedly) "Display the macro expansion of the form at point. The form is expanded with CL:MACROEXPAND-1 or, if a prefix argument is given, with CL:MACROEXPAND." (interactive "P") (slime-eval-macroexpand-inplace (if repeatedly - 'swank:swank-macro/compiler-macro-expand - 'swank:swank-macro/compiler-macro-expand-1))) + 'swank:swank-expand + 'swank:swank-expand-1))) (defun slime-format-string-expand () "Expand the format-string at point and display it." --- /project/slime/cvsroot/slime/swank.lisp 2010/09/22 19:17:35 1.729 +++ /project/slime/cvsroot/slime/swank.lisp 2010/10/02 11:16:54 1.730 @@ -2975,20 +2975,20 @@ (defslimefun swank-compiler-macroexpand (string) (apply-macro-expander #'compiler-macroexpand string)) -(defslimefun swank-macro/compiler-macro-expand-1 (string) - (apply-macro-expander #'macro/compiler-macro-expand-1 string)) +(defslimefun swank-expand-1 (string) + (apply-macro-expander #'expand-1 string)) -(defslimefun swank-macro/compiler-macro-expand (string) - (apply-macro-expander #'macro/compiler-macro-expand string)) +(defslimefun swank-expand (string) + (apply-macro-expander #'expand string)) -(defun macro/compiler-macro-expand-1 (form) +(defun expand-1 (form) (multiple-value-bind (expansion expanded?) (macroexpand-1 form) (if expanded? (values expansion t) (compiler-macroexpand-1 form)))) -(defun macro/compiler-macro-expand (form) - (expand-repeatedly #'macro/compiler-macro-expand-1 form)) +(defun expand (form) + (expand-repeatedly #'expand-1 form)) (defun expand-repeatedly (expander form) (loop From nsiivola at common-lisp.net Thu Oct 7 17:15:07 2010 From: nsiivola at common-lisp.net (CVS User nsiivola) Date: Thu, 07 Oct 2010 13:15:07 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv19896 Modified Files: ChangeLog swank-sbcl.lisp Log Message: SBCL: null *log-output* when saving core Hanging on to a *log-output* from a previous image is bad on SBCL at least: it is initialized to an FD-STREAM, which cannot be reused from one image to another. Deal with this by using sb-ext:*save-hooks* to clear the stream. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/02 11:16:54 1.2147 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/07 17:15:07 1.2148 @@ -1,3 +1,13 @@ +2010-10-07 Nikodemus Siivola + + Hanging on to a *log-output* from a previous image is bad on SBCL + at least: it is initialized to an FD-STREAM, which cannot be + reused from one image to another. + + Deal with this by using sb-ext:*save-hooks* to clear the stream. + + * swank-sbcl.lisp (deinit-log-output): New function. + 2010-10-02 Helmut Eller Rename slime-macro/compiler-macro-expand-1 => slime-expand-1 --- /project/slime/cvsroot/slime/swank-sbcl.lisp 2010/09/01 13:18:55 1.277 +++ /project/slime/cvsroot/slime/swank-sbcl.lisp 2010/10/07 17:15:07 1.278 @@ -1657,3 +1657,9 @@ (assert (sb-posix:wifexited status)) (funcall completion-function (zerop (sb-posix:wexitstatus status)))))))))))) + +(defun deinit-log-output () + ;; Can't hang on to an fd-stream from a previous session. + (setf *log-output* nil)) + +(pushnew 'deinit-log-output sb-ext:*save-hooks*) From crhodes at common-lisp.net Fri Oct 8 09:03:25 2010 From: crhodes at common-lisp.net (CVS User crhodes) Date: Fri, 08 Oct 2010 05:03:25 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv19842 Modified Files: ChangeLog slime.el swank-backend.lisp swank.lisp Log Message: add richer location information to the position arg in compile-string-for-emacs R's source location recording infrastructure works with line/column offsets rather than with character offsets, so to get the right srcrefs associated with some string source we need to communicate line and column information from the source buffer. Unfortunately, only the emacs side can do that -- in principle, the R side has no direct access to the source file at all. This means a protocol change, converting the position argument in swank:compile-string-for-emacs to a list of s in the slime source location grammar. At present, pass in both :position and :line kinds, and have swank:compile-string-for-emacs extract just the :position for passing on to swank-compile-string. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/07 17:15:07 1.2148 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/08 09:03:24 1.2149 @@ -1,3 +1,19 @@ +2010-10-08 Christophe Rhodes + + Pass more detailed source location information to + swank:compile-string-for-emacs. Motivated by R's source location + needs (where srcrefs are line/column based). + + * slime.el (slime-compile-string): Generate :line location format + from start-offset, passing it through to + swank:compile-file-for-emacs. + (find-definition.2): Use new-style position. + + * swank.lisp (compile-string-for-emacs): Use only the offset from + the position argument. + + * swank-backend.lisp (swank-compile-string): Fix docstring typo. + 2010-10-07 Nikodemus Siivola Hanging on to a *log-output* from a previous image is bad on SBCL --- /project/slime/cvsroot/slime/slime.el 2010/10/02 11:16:54 1.1343 +++ /project/slime/cvsroot/slime/slime.el 2010/10/08 09:03:24 1.1344 @@ -2639,14 +2639,18 @@ (run-with-timer (or timeout 0.2) nil 'delete-overlay overlay))) (defun slime-compile-string (string start-offset) - (slime-eval-async - `(swank:compile-string-for-emacs - ,string - ,(buffer-name) - ,start-offset - ,(if (buffer-file-name) (slime-to-lisp-filename (buffer-file-name))) - ',slime-compilation-policy) - #'slime-compilation-finished)) + (let* ((line (save-excursion + (goto-char start-offset) + (list (line-number-at-pos) (1+ (current-column))))) + (position `((:position ,start-offset) (:line , at line)))) + (slime-eval-async + `(swank:compile-string-for-emacs + ,string + ,(buffer-name) + ',position + ,(if (buffer-file-name) (slime-to-lisp-filename (buffer-file-name))) + ',slime-compilation-policy) + #'slime-compilation-finished))) (defun slime-compilation-finished (result) (with-struct (slime-compilation-result. notes duration successp @@ -7727,7 +7731,7 @@ `(swank:compile-string-for-emacs ,buffer-content ,(buffer-name) - ,0 + '((:position 0) (:line 1 1)) ,nil ,nil)) (let ((bufname (buffer-name))) --- /project/slime/cvsroot/slime/swank-backend.lisp 2010/09/18 09:34:05 1.201 +++ /project/slime/cvsroot/slime/swank-backend.lisp 2010/10/08 09:03:24 1.202 @@ -434,7 +434,7 @@ implementations to compile with optimization qualities of its value. -Should return T on successfull compilation, NIL otherwise. +Should return T on successful compilation, NIL otherwise. ") (definterface swank-compile-file (input-file output-file load-p --- /project/slime/cvsroot/slime/swank.lisp 2010/10/02 11:16:54 1.730 +++ /project/slime/cvsroot/slime/swank.lisp 2010/10/08 09:03:24 1.731 @@ -2853,15 +2853,16 @@ (defslimefun compile-string-for-emacs (string buffer position filename policy) "Compile STRING (exerpted from BUFFER at POSITION). Record compiler notes signalled as `compiler-condition's." - (with-buffer-syntax () - (collect-notes - (lambda () - (let ((*compile-print* t) (*compile-verbose* nil)) - (swank-compile-string string - :buffer buffer - :position position - :filename filename - :policy policy)))))) + (let ((offset (cadr (assoc :position position)))) + (with-buffer-syntax () + (collect-notes + (lambda () + (let ((*compile-print* t) (*compile-verbose* nil)) + (swank-compile-string string + :buffer buffer + :position offset + :filename filename + :policy policy))))))) (defslimefun compile-multiple-strings-for-emacs (strings policy) "Compile STRINGS (exerpted from BUFFER at POSITION). From rtoy at common-lisp.net Sat Oct 9 23:02:33 2010 From: rtoy at common-lisp.net (CVS User rtoy) Date: Sat, 09 Oct 2010 19:02:33 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv8210 Modified Files: ChangeLog swank-backend.lisp swank-cmucl.lisp swank-rpc.lisp Log Message: Add CODEPOINT-LENGTH function to return the number of codepoints in a string. Needed to make sure that Emacs and Lisp agree on the length of a string. Emacs wants codepoints and some lisps give code units. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/08 09:03:24 1.2149 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/09 23:02:32 1.2150 @@ -1,3 +1,16 @@ +2010-10-09 Raymond Toy + + * swank-cmucl.lisp (codepoint-length): Implement codepoint-length + to return the number of codepoints in cmucl's utf-16 strings. + + * swank-backend.lisp (:swank-backend): Export codepoint-length. + (codepoint-length): definterface codepoint-length. Default is to + use LENGTH. + + * swank-rpc.lisp (write-message): Call + swank-backend:codepoint-length to get the correct length for + emacs. + 2010-10-08 Christophe Rhodes Pass more detailed source location information to --- /project/slime/cvsroot/slime/swank-backend.lisp 2010/10/08 09:03:24 1.202 +++ /project/slime/cvsroot/slime/swank-backend.lisp 2010/10/09 23:02:33 1.203 @@ -1317,3 +1317,12 @@ "Request saving a heap image to the file FILENAME. RESTART-FUNCTION, if non-nil, should be called when the image is loaded. COMPLETION-FUNCTION, if non-nil, should be called after saving the image.") + +;;; Codepoint length + +(definterface codepoint-length (string) + "Return the number of codepoints in STRING. +With some Lisps, like cmucl, LENGTH returns the number of UTF-16 code +units, but other Lisps return the number of codepoints. The slime +protocol wants string lengths in terms of codepoints." + (length string)) --- /project/slime/cvsroot/slime/swank-cmucl.lisp 2010/09/20 16:09:13 1.231 +++ /project/slime/cvsroot/slime/swank-cmucl.lisp 2010/10/09 23:02:33 1.232 @@ -2576,3 +2576,16 @@ (loop for n in names when (funcall matchp prefix n) collect n))) + +(defimplementation codepoint-length (string) + "Return the number of code points in the string. The string MUST be + a valid UTF-16 string." + (do ((len (length string)) + (index 0 (1+ index)) + (count 0 (1+ count))) + ((>= index len) + count) + (multiple-value-bind (codepoint wide) + (lisp:codepoint string index) + (declare (ignore codepoint)) + (when wide (incf index))))) --- /project/slime/cvsroot/slime/swank-rpc.lisp 2010/04/14 17:51:30 1.6 +++ /project/slime/cvsroot/slime/swank-rpc.lisp 2010/10/09 23:02:33 1.7 @@ -92,7 +92,7 @@ (defun write-message (message package stream) (let* ((string (prin1-to-string-for-emacs message package)) - (length (length string))) + (length (swank-backend:codepoint-length string))) (let ((*print-pretty* nil)) (format stream "~6,'0x" length)) (write-string string stream) From alendvai at common-lisp.net Fri Oct 15 16:09:07 2010 From: alendvai at common-lisp.net (CVS User alendvai) Date: Fri, 15 Oct 2010 12:09:07 -0400 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory cl-net:/tmp/cvs-serv22560 Modified Files: swank-fuzzy.lisp Log Message: Fuzzy completion: speed up by 2-4 times (on sbcl) --- /project/slime/cvsroot/slime/contrib/swank-fuzzy.lisp 2010/09/04 00:32:14 1.11 +++ /project/slime/cvsroot/slime/contrib/swank-fuzzy.lisp 2010/10/15 16:09:07 1.12 @@ -465,8 +465,9 @@ Once a word has been completely matched, the chunks are pushed onto the special variable *ALL-CHUNKS* and the function returns." - (declare ;(optimize speed) - (fixnum short-index initial-full-index) + (declare (optimize speed) + (type fixnum short-index initial-full-index) + (type list current-chunk) (simple-string short full) (special *all-chunks*)) (flet ((short-cur () @@ -485,10 +486,13 @@ "Collects the current chunk to CHUNKS and prepares for a new chunk." (when current-chunk - (push (list current-chunk-pos - (coerce (reverse current-chunk) 'string)) chunks) - (setf current-chunk nil - current-chunk-pos nil)))) + (let ((current-chunk-as-string (nreverse + (make-array (length current-chunk) + :element-type 'character + :initial-contents current-chunk)))) + (push (list current-chunk-pos current-chunk-as-string) chunks) + (setf current-chunk nil + current-chunk-pos nil))))) ;; If there's an outstanding chunk coming in collect it. Since ;; we're recursively called on skipping an input character, the ;; chunk can't possibly continue on. From alendvai at common-lisp.net Fri Oct 15 16:16:11 2010 From: alendvai at common-lisp.net (CVS User alendvai) Date: Fri, 15 Oct 2010 12:16:11 -0400 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory cl-net:/tmp/cvs-serv23755 Modified Files: slime-fuzzy.el Log Message: Clean up fuzzy.el's keymap code, drop mimic-key-bindings --- /project/slime/cvsroot/slime/contrib/slime-fuzzy.el 2010/08/21 21:34:12 1.21 +++ /project/slime/cvsroot/slime/contrib/slime-fuzzy.el 2010/10/15 16:16:11 1.22 @@ -72,44 +72,32 @@ ;;;;;;; slime-target-buffer-fuzzy-completions-mode ;; NOTE: this mode has to be able to override key mappings in slime-mode -;; FIXME: clean this up - -(defun slime-mimic-key-bindings (from-keymap to-keymap bindings-or-operation operation) - "Iterate on BINDINGS-OR-OPERATION. If an element is a symbol then -try to look it up (as an operation) in FROM-KEYMAP. Non symbols are taken -as default key bindings when none to be mimiced was found in FROM-KEYMAP. -Set the resulting list of keys in TO-KEYMAP to OPERATION." - (let ((mimic-keys nil) - (direct-keys nil)) - (dolist (key-or-operation bindings-or-operation) - (if (symbolp key-or-operation) - (setf mimic-keys (append mimic-keys (where-is-internal key-or-operation from-keymap nil t))) - (push key-or-operation direct-keys))) - (dolist (key (or mimic-keys direct-keys)) - (define-key to-keymap key operation)))) - (defvar slime-target-buffer-fuzzy-completions-map - (let* ((map (make-sparse-keymap))) - (flet ((remap (keys to) - (slime-mimic-key-bindings global-map map keys to))) - - (remap (list 'keyboard-quit (kbd "C-g")) 'slime-fuzzy-abort) - - (remap (list 'slime-fuzzy-indent-and-complete-symbol - 'slime-indent-and-complete-symbol - (kbd "")) - 'slime-fuzzy-select-or-update-completions) - (remap (list 'previous-line (kbd "")) 'slime-fuzzy-prev) - (remap (list 'next-line (kbd "")) 'slime-fuzzy-next) - (remap (list 'isearch-forward (kbd "C-s")) - (lambda () - (interactive) - (select-window (get-buffer-window (slime-get-fuzzy-buffer))) - (call-interactively 'isearch-forward))) - + (let ((map (make-sparse-keymap))) + (flet ((def (keys command) + (unless (listp keys) + (setq keys (list keys))) + (dolist (key keys) + (define-key map key command)))) + (def `([remap keyboard-quit] + ,(kbd "C-g")) + 'slime-fuzzy-abort) + (def `([remap slime-fuzzy-indent-and-complete-symbol] + [remap slime-indent-and-complete-symbol] + ,(kbd "")) + 'slime-fuzzy-select-or-update-completions) + (def `([remap previous-line] + ,(kbd "")) + 'slime-fuzzy-prev) + (def `([remap next-line] + ,(kbd "")) + 'slime-fuzzy-next) + (def `([remap isearch-forward] + ,(kbd "C-s")) + 'slime-fuzzy-continue-isearch-in-fuzzy-buffer) ;; some unconditional direct bindings - (dolist (key (list (kbd "") (kbd "RET") (kbd "") "(" ")" "[" "]")) - (define-key map key 'slime-fuzzy-select-and-process-event-in-target-buffer))) + (def (list (kbd "") (kbd "RET") (kbd "") "(" ")" "[" "]") + 'slime-fuzzy-select-and-process-event-in-target-buffer)) map) "Keymap for slime-target-buffer-fuzzy-completions-mode. This will override the key bindings in the target buffer temporarily during completion.") @@ -122,6 +110,10 @@ (eq a 'slime-fuzzy-target-buffer-completions-mode)) :key #'car)) +(defun slime-fuzzy-continue-isearch-in-fuzzy-buffer () + (interactive) + (select-window (get-buffer-window (slime-get-fuzzy-buffer))) + (call-interactively 'isearch-forward)) (define-minor-mode slime-fuzzy-target-buffer-completions-mode "This minor mode is intented to override key bindings during fuzzy @@ -183,33 +175,35 @@ (make-overlay (point) (point) nil t nil))) (defvar slime-fuzzy-completions-map - (let* ((map (make-sparse-keymap))) - (flet ((remap (keys to) - (slime-mimic-key-bindings global-map map keys to))) - (remap (list 'keyboard-quit (kbd "C-g")) 'slime-fuzzy-abort) - (define-key map "q" 'slime-fuzzy-abort) - - (remap (list 'previous-line (kbd "")) 'slime-fuzzy-prev) - (remap (list 'next-line (kbd "")) 'slime-fuzzy-next) - - (define-key map "n" 'slime-fuzzy-next) - (define-key map "\M-n" 'slime-fuzzy-next) - - (define-key map "p" 'slime-fuzzy-prev) - (define-key map "\M-p" 'slime-fuzzy-prev) - - (define-key map "\d" 'scroll-down) - - (remap (list 'slime-fuzzy-indent-and-complete-symbol - 'slime-indent-and-complete-symbol - (kbd "")) - 'slime-fuzzy-select) - - (define-key map (kbd "") 'slime-fuzzy-select/mouse)) - - (define-key map (kbd "RET") 'slime-fuzzy-select) - (define-key map (kbd "") 'slime-fuzzy-select) - + (let ((map (make-sparse-keymap))) + (flet ((def (keys command) + (unless (listp keys) + (setq keys (list keys))) + (dolist (key keys) + (define-key map key command)))) + (def `([remap keyboard-quit] + "q" + ,(kbd "C-g")) + 'slime-fuzzy-abort) + (def `([remap previous-line] + "p" + "\M-p" + ,(kbd "")) + 'slime-fuzzy-prev) + (def `([remap next-line] + "n" + "\M-n" + ,(kbd "")) + 'slime-fuzzy-next) + (def "\d" 'scroll-down) + (def `([remap slime-fuzzy-indent-and-complete-symbol] + [remap slime-indent-and-complete-symbol] + ,(kbd "")) + 'slime-fuzzy-select) + (def (kbd "") 'slime-fuzzy-select/mouse) + (def `(,(kbd "RET") + ,(kbd "")) + 'slime-fuzzy-select)) map) "Keymap for slime-fuzzy-completions-mode when in the completion buffer.") From alendvai at common-lisp.net Fri Oct 15 16:21:32 2010 From: alendvai at common-lisp.net (CVS User alendvai) Date: Fri, 15 Oct 2010 12:21:32 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv26265 Modified Files: slime.el Log Message: Added separate host and port history for slime-connect. --- /project/slime/cvsroot/slime/slime.el 2010/10/08 09:03:24 1.1344 +++ /project/slime/cvsroot/slime/slime.el 2010/10/15 16:21:32 1.1345 @@ -198,6 +198,9 @@ :type 'integer :group 'slime-lisp) +(defvar slime-connect-host-history (list slime-lisp-host)) +(defvar slime-connect-port-history (list (prin1-to-string slime-port))) + (defvar slime-net-valid-coding-systems '((iso-latin-1-unix nil "iso-latin-1-unix") (iso-8859-1-unix nil "iso-latin-1-unix") @@ -1170,9 +1173,12 @@ (defun slime-connect (host port &optional coding-system) "Connect to a running Swank server. Return the connection." - (interactive (list (read-from-minibuffer "Host: " slime-lisp-host) - (read-from-minibuffer "Port: " (format "%d" slime-port) - nil t))) + (interactive (list (read-from-minibuffer + "Host: " (first slime-connect-host-history) + nil nil '(slime-connect-host-history . 1)) + (read-from-minibuffer + "Port: " (first slime-connect-port-history) + nil nil '(slime-connect-port-history . 1)))) (when (and (interactive-p) slime-net-processes (y-or-n-p "Close old connections first? ")) (slime-disconnect-all)) From alendvai at common-lisp.net Fri Oct 15 16:25:50 2010 From: alendvai at common-lisp.net (CVS User alendvai) Date: Fri, 15 Oct 2010 12:25:50 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv26654 Modified Files: slime.el Log Message: slime-lookup-lisp-implementation has better error reporting and allows using a functionp to generate the arguments --- /project/slime/cvsroot/slime/slime.el 2010/10/15 16:21:32 1.1345 +++ /project/slime/cvsroot/slime/slime.el 2010/10/15 16:25:50 1.1346 @@ -1129,8 +1129,14 @@ (list :program program :program-args args)))))) (defun slime-lookup-lisp-implementation (table name) - (destructuring-bind (name (prog &rest args) &rest keys) (assoc name table) - (list* :name name :program prog :program-args args keys))) + (let ((arguments (rest (assoc name table)))) + (unless arguments + (error "Could not find lisp implementation with the name '%S'" name)) + (when (and (= (length arguments) 1) + (functionp (first arguments))) + (setf arguments (funcall (first arguments)))) + (destructuring-bind ((prog &rest args) &rest keys) arguments + (list* :name name :program prog :program-args args keys)))) (defun* slime-start (&key (program inferior-lisp-program) program-args directory From alendvai at common-lisp.net Fri Oct 15 22:42:14 2010 From: alendvai at common-lisp.net (CVS User alendvai) Date: Fri, 15 Oct 2010 18:42:14 -0400 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory cl-net:/tmp/cvs-serv27538/contrib Modified Files: slime-presentations.el Log Message: Smarten up the label-value-line macros. - support a :label emacs font property - added key args: padding-length, display-nil-value, hide-when-nil, splice-as-ispec, value-text - label-value-line* will evaluate and splice the result of the form after a @ character --- /project/slime/cvsroot/slime/contrib/slime-presentations.el 2010/07/28 15:28:21 1.37 +++ /project/slime/cvsroot/slime/contrib/slime-presentations.el 2010/10/15 22:42:14 1.38 @@ -830,6 +830,8 @@ 'mouse-face 'highlight 'face 'slime-inspector-value-face) (slime-insert-presentation string `(:inspected-part ,id) t))) + ((:label string) + (insert (slime-inspector-fontify label string))) ((:action string id) (slime-insert-propertized (list 'slime-action-number id 'mouse-face 'highlight From alendvai at common-lisp.net Fri Oct 15 22:42:14 2010 From: alendvai at common-lisp.net (CVS User alendvai) Date: Fri, 15 Oct 2010 18:42:14 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv27538 Modified Files: ChangeLog slime.el swank-backend.lisp swank.lisp Log Message: Smarten up the label-value-line macros. - support a :label emacs font property - added key args: padding-length, display-nil-value, hide-when-nil, splice-as-ispec, value-text - label-value-line* will evaluate and splice the result of the form after a @ character --- /project/slime/cvsroot/slime/ChangeLog 2010/10/09 23:02:32 1.2150 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/15 22:42:14 1.2151 @@ -1,3 +1,22 @@ +2010-10-16 Attila Lendvai + + * swank-fuzzy.lisp: speed up by 2-4 times (on sbcl). + + * fuzzy.el: Clean up fuzzy completion's keymap code, drop + mimic-key-bindings. + + * slime.el: Added separate host and port history for + slime-connect. + (slime-lookup-lisp-implementation): better error reporting and + allow using a functionp to generate the arguments. + + * swank.lisp: Smarten up the label-value-line macros: + - support a :label emacs font property + - added key args: padding-length, display-nil-value, + hide-when-nil, splice-as-ispec, value-text + - label-value-line* will evaluate and splice the result + of the form after a @ character + 2010-10-09 Raymond Toy * swank-cmucl.lisp (codepoint-length): Implement codepoint-length --- /project/slime/cvsroot/slime/slime.el 2010/10/15 16:25:50 1.1346 +++ /project/slime/cvsroot/slime/slime.el 2010/10/15 22:42:14 1.1347 @@ -6463,6 +6463,8 @@ 'mouse-face 'highlight 'face 'slime-inspector-value-face) (insert string))) + ((:label string) + (insert (slime-inspector-fontify label string))) ((:action string id) (slime-insert-propertized (list 'slime-action-number id 'mouse-face 'highlight --- /project/slime/cvsroot/slime/swank-backend.lisp 2010/10/09 23:02:33 1.203 +++ /project/slime/cvsroot/slime/swank-backend.lisp 2010/10/15 22:42:14 1.204 @@ -1053,17 +1053,45 @@ ;;; Utilities for inspector methods. ;;; - -(defun label-value-line (label value &key (newline t)) - "Create a control list which prints \"LABEL: VALUE\" in the inspector. -If NEWLINE is non-NIL a `(:newline)' is added to the result." - - (list* (princ-to-string label) ": " `(:value ,value) - (if newline '((:newline)) nil))) +(defun label-value-line (label value &key padding-length display-nil-value hide-when-nil + splice-as-ispec value-text (newline t)) + "Create a control list which prints \"LABEL: VALUE\" in the inspector." + (if (or value (not hide-when-nil)) + `((:label ,(princ-to-string label) ":") + ,@(when (or value display-nil-value) + (list " ")) + ,@(when (and (or value display-nil-value) + padding-length) + (list (make-array padding-length + :element-type 'character + :initial-element #\Space))) + ,@(when (or value display-nil-value) + (if splice-as-ispec + (if (listp value) value (list value)) + `((:value ,value ,@(when value-text (list value-text)))))) + ,@(if newline '((:newline)) nil)) + (values))) (defmacro label-value-line* (&rest label-values) - ` (append ,@(loop for (label value) in label-values - collect `(label-value-line ,label ,value)))) + (let ((longest-label-length (loop + :for (label value) :in label-values + :maximize (if (stringp label) + (length label) + 0)))) + `(append ,@(loop + :for entry :in label-values + :if (and (consp entry) + (not (consp (first entry))) + (string= (first entry) '@)) + :appending (rest entry) + :else + :collect (destructuring-bind + (label value &rest args &key &allow-other-keys) entry + `(label-value-line ,label ,value + :padding-length ,(when (stringp label) + (- longest-label-length + (length label))) + , at args)))))) (definterface describe-primitive-type (object) "Return a string describing the primitive type of object." --- /project/slime/cvsroot/slime/swank.lisp 2010/10/08 09:03:24 1.731 +++ /project/slime/cvsroot/slime/swank.lisp 2010/10/15 22:42:14 1.732 @@ -3479,6 +3479,8 @@ ((:newline) (list newline)) ((:value obj &optional str) (list (value-part obj str (istate.parts istate)))) + ((:label &rest strs) + (list (list :label (apply #'concatenate 'string (mapcar #'string strs))))) ((:action label lambda &key (refreshp t)) (list (action-part label lambda refreshp (istate.actions istate)))) From alendvai at common-lisp.net Fri Oct 15 22:53:45 2010 From: alendvai at common-lisp.net (CVS User alendvai) Date: Fri, 15 Oct 2010 18:53:45 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv29005 Modified Files: ChangeLog swank-loader.lisp Log Message: Better integration with ASDF. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/15 22:42:14 1.2151 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/15 22:53:45 1.2152 @@ -17,6 +17,10 @@ - label-value-line* will evaluate and splice the result of the form after a @ character + * swank-loader.lisp: Optional integration with ASDF. When ASDF is + available, store slime fasl's where ASDF would store them. Also + make sure swank.asd is visible to ASDF. + 2010-10-09 Raymond Toy * swank-cmucl.lisp (codepoint-length): Implement codepoint-length --- /project/slime/cvsroot/slime/swank-loader.lisp 2010/06/22 10:02:49 1.106 +++ /project/slime/cvsroot/slime/swank-loader.lisp 2010/10/15 22:53:45 1.107 @@ -124,12 +124,21 @@ (and s (symbol-name (read s))))) (defun default-fasl-dir () - (merge-pathnames - (make-pathname - :directory `(:relative ".slime" "fasl" - ,@(if (slime-version-string) (list (slime-version-string))) - ,(unique-dir-name))) - (user-homedir-pathname))) + (or + ;; If ASDF is available then store Slime's fasl's where ASDF stores them. + (let ((translate-fn (find-symbol "COMPILE-FILE-PATHNAME*" :asdf))) + (when translate-fn + (make-pathname + :name nil :type nil + :defaults (funcall translate-fn + (make-pathname :name "foo" + :defaults *source-directory*))))) + (merge-pathnames + (make-pathname + :directory `(:relative ".slime" "fasl" + ,@(if (slime-version-string) (list (slime-version-string))) + ,(unique-dir-name))) + (user-homedir-pathname)))) (defvar *fasl-directory* (default-fasl-dir) "The directory where fasl files should be placed.") @@ -234,6 +243,16 @@ (defun load-swank (&key (src-dir *source-directory*) (fasl-dir *fasl-directory*)) + (when (find-package :asdf) + ;; Make sure our swank.asd is visible to ASDF. + (eval + (let ((*package* (find-package :swank-loader))) + (read-from-string + "(let ((swank-system (asdf:find-system :swank nil))) + (unless (and swank-system + (equal (asdf:component-pathname swank-system) + (merge-pathnames \"swank.asd\" *source-directory*))) + (push *source-directory* asdf:*central-registry*)))")))) (compile-files (src-files *swank-files* src-dir) fasl-dir t) (funcall (q "swank::before-init") (slime-version-string) From sboukarev at common-lisp.net Sat Oct 16 10:10:38 2010 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Sat, 16 Oct 2010 06:10:38 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv10545 Modified Files: ChangeLog swank-loader.lisp Log Message: * swank-loader.lisp (default-fasl-dir): Guard against using :asdf package if it doesn't exist. Patch by Anton Vodonosov. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/15 22:53:45 1.2152 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/16 10:10:38 1.2153 @@ -1,3 +1,9 @@ +2010-10-16 Stas Boukarev + + * swank-loader.lisp (default-fasl-dir): Guard against using :asdf + package if it doesn't exist. + Patch by Anton Vodonosov. + 2010-10-16 Attila Lendvai * swank-fuzzy.lisp: speed up by 2-4 times (on sbcl). --- /project/slime/cvsroot/slime/swank-loader.lisp 2010/10/15 22:53:45 1.107 +++ /project/slime/cvsroot/slime/swank-loader.lisp 2010/10/16 10:10:38 1.108 @@ -126,7 +126,8 @@ (defun default-fasl-dir () (or ;; If ASDF is available then store Slime's fasl's where ASDF stores them. - (let ((translate-fn (find-symbol "COMPILE-FILE-PATHNAME*" :asdf))) + (let ((translate-fn (and (find-package :asdf) + (find-symbol "COMPILE-FILE-PATHNAME*" :asdf)))) (when translate-fn (make-pathname :name nil :type nil From heller at common-lisp.net Sun Oct 17 10:17:31 2010 From: heller at common-lisp.net (CVS User heller) Date: Sun, 17 Oct 2010 06:17:31 -0400 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory cl-net:/tmp/cvs-serv29636/contrib Modified Files: ChangeLog swank-kawa.scm Log Message: Some updates to the Kawa backend. * swank-kawa.scm (%%runnable): Use standard gnu.mapping.RunnableClosure but print the stacktrace on exceptions. (listener-loop): Invoke debugger on unhandled exceptions. The debugger will use stacksnapshots if the exception matches. (invoke-debugger, break, breakpoint, request-breakpoint): New. Used to "invoke" the debugger from normal code. (process-vm-event, debug-info, event-stacktrace): Handle breakpoint events. (interrupt-thread, throwable-stacktrace, breakpoint-condition): New. (throw-to-toplevel): For breakpoint events use Thread#forceEarlyReturn. (typecase): Add support for or and eql types. (bytemethod>src-loc): New. (src-loc>elisp): Use stratum "java" as this seems to work better. (print-object, print-unreadable-object): New (pprint-to-string): Use it. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2010/09/26 18:10:33 1.423 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2010/10/17 10:17:31 1.424 @@ -1,3 +1,26 @@ +2010-10-17 Helmut Eller + + Some updates to the Kawa backend. + + * swank-kawa.scm (%%runnable): Use standard + gnu.mapping.RunnableClosure but print the stacktrace on + exceptions. + (listener-loop): Invoke debugger on unhandled exceptions. The + debugger will use stacksnapshots if the exception matches. + (invoke-debugger, break, breakpoint, request-breakpoint): New. + Used to "invoke" the debugger from normal code. + (process-vm-event, debug-info, event-stacktrace): Handle + breakpoint events. + (interrupt-thread, throwable-stacktrace, breakpoint-condition): + New. + (throw-to-toplevel): For breakpoint events use + Thread#forceEarlyReturn. + (typecase): Add support for or and eql types. + (bytemethod>src-loc): New. + (src-loc>elisp): Use stratum "java" as this seems to work better. + (print-object, print-unreadable-object): New + (pprint-to-string): Use it. + 2010-09-26 Stas Boukarev * slime-repl.el (slime-repl-history-pattern): Match \t too, --- /project/slime/cvsroot/slime/contrib/swank-kawa.scm 2010/09/03 07:25:24 1.23 +++ /project/slime/cvsroot/slime/contrib/swank-kawa.scm 2010/10/17 10:17:31 1.24 @@ -24,9 +24,9 @@ (defun kawa-slime-init (file _) (setq slime-protocol-version 'ignore) - (let ((zip ".../slime/contrib/swank-kawa.zip")) ; <-- insert the right path + (let ((swank ".../slime/contrib/swank-kawa.scm")) ; <-- insert the right path (format "%S\n" - `(begin (load ,(expand-file-name zip)) (start-swank ,file))))) + `(begin (require ,(expand-file-name swank)) (start-swank ,file))))) |# ;; 4. Start everything with M-- M-x slime kawa ;; @@ -34,7 +34,7 @@ ;;;; Module declaration -(module-export start-swank create-swank-server swank-java-source-path) +(module-export start-swank create-swank-server swank-java-source-path break) (module-static #t) @@ -51,9 +51,9 @@ (define-syntax df (syntax-rules (=>) ((df name (args ... => return-type) body ...) - (define (name args ...) :: return-type body ...)) + (define (name args ...) :: return-type (seq body ...))) ((df name (args ...) body ...) - (define (name args ...) body ...)))) + (define (name args ...) (seq body ...))))) (define-syntax fun (syntax-rules () @@ -67,7 +67,9 @@ (define-syntax seq (syntax-rules () - ((seq body ...) + ((seq) + (begin #!void)) + ((seq body ...) (begin body ...)))) (define-syntax esc @@ -192,8 +194,8 @@ (result #!null)) (if (instance? tmp ) (let ((tmp :: tmp)) - (mif (p (@ car tmp)) - (mif (ps (@ cdr tmp)) + (mif (p (! get-car tmp)) + (mif (ps (! get-cdr tmp)) (set! result then) (set! fail? -1)) (set! fail? -1))) @@ -205,8 +207,8 @@ (tmp value)) (if (instance? tmp ) (let ((tmp :: tmp)) - (mif (p (@ car tmp)) - (mif (ps (@ cdr tmp)) + (mif (p (! get-car tmp)) + (mif (ps (! get-cdr tmp)) then (fail)) (fail))) @@ -241,20 +243,42 @@ ((mlet* ((pattern value) ms ...) body ...) (mlet (pattern value) (mlet* (ms ...) body ...))))) -(define-syntax typecase - (syntax-rules (::) - ((typecase var (type body ...) ...) +(define-syntax typecase% + (syntax-rules (eql or) + ((typecase% var (#t body ...) more ...) + (seq body ...)) + ((typecase% var ((eql value) body ...) more ...) + (cond ((eqv? var 'value) body ...) + (else (typecase% var more ...)))) + ((typecase% var ((or type) body ...) more ...) + (typecase% var (type body ...) more ...)) + ((typecase% var ((or type ...) body ...) more ...) + (let ((f (lambda (var) body ...))) + (typecase% var + (type (f var)) ... + (#t (typecase% var more ...))))) + ((typecase% var (type body ...) more ...) (cond ((instance? var type) (let ((var :: type var)) body ...)) - ... - (else (error "typecase failed" var - (! getClass (as var)))))))) + (else (typecase% var more ...)))) + ((typecase% var) + (error "typecase% failed" var + (! getClass (as var)))))) + +(define-syntax-case typecase + () + ((_ exp more ...) (identifier? (syntax exp)) + #`(typecase% exp more ...)) + ((_ exp more ...) + #`(let ((tmp exp)) + (typecase% tmp more ...)))) (define-syntax ignore-errors (syntax-rules () ((ignore-errors body ...) (try-catch (begin body ...) + (v #f) (v #f))))) ;;(define-syntax dc @@ -307,6 +331,7 @@ (define-alias ) (define-alias ) (define-alias ) +(define-alias ) (define-alias ) (define-simple-class () @@ -348,6 +373,7 @@ (define-variable *the-vm* #f) (define-variable *last-exception* #f) (define-variable *last-stacktrace* #f) +(df %vm (=> ) *the-vm*) ;; FIXME: this needs factorization. But I guess the whole idea of ;; using bidirectional channels just sucks. Mailboxes owned by a @@ -425,7 +451,7 @@ ((_ (':emacs-interrupt id)) (let* ((vm (vm)) (t (find-thread id (map cdr threads) repl-thread vm))) - (send dbg `(debug-thread ,t)))) + (send dbg `(interrupt-thread ,t)))) ((_ (':emacs-rex form _ _ id)) (send listener `(,form ,id))) ((_ ('get-vm c)) @@ -567,16 +593,25 @@ (df listener ((c ) (env )) (! set-name (current-thread) "swank-listener") - (log "listener: ~s ~s ~s ~s\n" + (log "listener: ~s ~s ~s ~s\n" (current-thread) ((current-thread):hashCode) c env) (let ((out (make-swank-outport (rpc c `(get-channel))))) ;;(set (current-output-port) out) (let ((vm (as (rpc c `(get-vm))))) (send c `(set-listener ,(vm-mirror vm (current-thread)))) - (enable-uncaught-exception-events vm)) + (request-uncaught-exception-events vm) + (request-caught-exception-events vm) + ) (rpc c `(get-vm)) (listener-loop c env out))) +(define-simple-class () + ((*init*) + (invoke-special (this) '*init* )) + ((abort) :: void + (primitive-throw (this)) + #!void)) + (df listener-loop ((c ) (env ) port) (while (not (nul? c)) ;;(log "listener-loop: ~s ~s\n" (current-thread) c) @@ -595,10 +630,19 @@ (let* ((val (%eval form env))) (force-output) (reply c val id)) + (ex (invoke-debugger ex) (restart)) + (ex (invoke-debugger ex) (restart)) (ex (let ((flag (java.lang.Thread:interrupted))) (log "listener-abort: ~s ~a\n" ex flag)) - (restart))))))) + (restart)) + ))))) + +(df invoke-debugger (condition) + ;;(log "should now invoke debugger: ~a" condition) + (try-catch + (break condition) + (ex (seq)))) (defslimefun create-repl (env #!rest _) (list "user" "user")) @@ -636,7 +680,8 @@ (df values-for-echo-area (values) (let ((values (values-to-list values))) - (format "~:[=> ~{~s~^, ~}~;; No values~]" (null? values) values))) + (cond ((null? values) "; No value") + (#t (format "~{~a~^, ~}" (map pprint-to-string values)))))) ;;;; Compilation @@ -839,6 +884,7 @@ (df all-definitions (o) (typecase o ( (list o)) + ( (list o)) ( (append (mappend all-definitions (gf-methods o)) (let ((s (! get-setter o))) (if s (all-definitions s) '())))) @@ -857,10 +903,12 @@ (df src-loc (o => ) (typecase o + ( (src-loc (@ method o))) ( (module-method>src-loc o)) ( ( #f #f)) ( (class>src-loc o)) - ( ( #f #f)))) + ( ( #f #f)) + ( (bytemethod>src-loc o)))) (df module-method>src-loc ((f )) (! location (module-method>meth-ref f))) @@ -878,18 +926,28 @@ name))) (df class>src-loc ((c ) => ) - (let* ((type (! reflectedType (as - (vm-mirror *the-vm* c)))) + (let* ((type (class>class-ref c)) (locs (! all-line-locations type))) (cond ((not (! isEmpty locs)) (1st locs)) - (#t ( (1st (! source-paths type #!null)) + (#t ( (1st (! source-paths type "Java")) #f))))) +(df class>class-ref ((class ) => ) + (! reflectedType (as + (vm-mirror *the-vm* class)))) + +(df bytemethod>src-loc ((m ) => ) + (let* ((cls (class>class-ref (! get-reflect-class (! get-declaring-class m)))) + (name (! get-name m)) + (sig (! get-signature m)) + (meth (! concrete-method-by-name cls name sig))) + (! location meth))) + (df src-loc>elisp ((l )) (df src-loc>list ((l )) - (list (ignore-errors (! source-name l)) - (ignore-errors (! source-path l)) - (ignore-errors (! line-number l)))) + (list (ignore-errors (! source-name l "Java")) + (ignore-errors (! source-path l "Java")) + (ignore-errors (! line-number l "Java")))) (mcase (src-loc>list l) ((name path line) (cond ((not path) @@ -906,7 +964,6 @@ path name (source-path))) (:line ,(or line -1)) ())))))) - (df src-loc>str ((l )) (cond ((nul? l) "") (#t (format "~a ~a ~a" @@ -917,10 +974,13 @@ (ignore-errors (! lineNumber l)))))) (df ferror (fstring #!rest args) - (primitive-throw ( (to-str (apply format fstring args))))) + (let ((err ( (to-str (apply format fstring args))))) + (primitive-throw err))) ;;;;;; class-path hacking +;; (find-file-in-path "kawa/lib/kawa/hashtable.scm" (source-path)) + (df find-file-in-path ((filename ) (path )) (let ((f ( filename))) (cond ((! isAbsolute f) `(:file ,filename)) @@ -973,9 +1033,9 @@ (let ((f (eval name env))) (typecase f ( - (disassemble (module-method>meth-ref f)))))))) + (disassemble-to-string (module-method>meth-ref f)))))))) -(df disassemble ((mr ) => ) +(df disassemble-to-string ((mr ) => ) (with-sink #f (fun (out) (disassemble-meth-ref mr out)))) (df disassemble-meth-ref ((mr ) (out )) @@ -1039,9 +1099,9 @@ ;;;; Macroexpansion -(defslimefun swank-macroexpand-1 (env s) (%swank-macroexpand s)) -(defslimefun swank-macroexpand (env s) (%swank-macroexpand s)) -(defslimefun swank-macroexpand-all (env s) (%swank-macroexpand s)) +(defslimefun swank-expand-1 (env s) (%swank-macroexpand s)) +(defslimefun swank-expand (env s) (%swank-macroexpand s)) +(defslimefun swank-expand-all (env s) (%swank-macroexpand s)) (df %swank-macroexpand (string) (pprint-to-string (%macroexpand (read-from-string string)))) @@ -1180,7 +1240,7 @@ (set! builder:length 0)))) ; pure magic (closed #f)) (while (not closed) - (mcase (! poll q 200 :MILLISECONDS) + (mcase (! poll q (as long 200) :MILLISECONDS) ('#!null (flush)) (('write s) (! append builder (as s)) @@ -1202,11 +1262,14 @@ ;;;; Monitor +;;(define-simple-class () +;; (threadmap type: (tab))) + (df vm-monitor ((c )) (! set-name (current-thread) "swank-vm-monitor") (let ((vm (vm-attach))) (log-vm-props vm) - ;;(enable-uncaught-exception-events vm) + (request-breakpoint vm) (mlet* (((ev . _) (spawn/chan/catch (fun (c) (let ((q (! eventQueue vm))) @@ -1235,12 +1298,12 @@ (reply c (thread-frames thread from to state) id)) ((,c . ('list-threads id)) (reply c (list-threads vm state) id)) - ((,c . ('debug-thread ref)) - (set state (debug-thread ref state c))) + ((,c . ('interrupt-thread ref)) + (set state (interrupt-thread ref state c))) ((,c . ('debug-nth-thread n)) (let ((t (nth (get state 'all-threads #f) n))) ;;(log "thread ~d : ~a\n" n t) - (set state (debug-thread t state c)))) + (set state (interrupt-thread t state c)))) ((,c . ('quit-thread-browser id)) (reply c 't id) (set state (del state 'all-threads))) @@ -1262,35 +1325,40 @@ (send c `(forward (:return (:ok ,value) ,id)))) (df reply-abort ((c ) id) - (send c `(forward (:return (:abort) ,id)))) + (send c `(forward (:return (:abort nil) ,id)))) (df process-vm-event ((e ) (c ) state) - (log "vm-event: ~s\n" e) + ;;(log "vm-event: ~s\n" e) (typecase e ( - (log "exception-location: ~s\n" (src-loc>str (! location e))) - (log "exception-catch-location: ~s\n" (src-loc>str (! catch-location e))) - (let ((l (! catch-location e))) - (cond ((or (nul? l) - ;; (member (! source-path l) '("gnu/expr/ModuleExp.java")) - ) - (process-exception e c state)) - (#t - (let* ((t (! thread e)) - (r (! request e)) - (ex (! exception e))) - (unless (eq? *last-exception* ex) - (set *last-exception* ex) - (set *last-stacktrace* (copy-stack t))) - (! resume t)) - state)))) + ;;(log "exception: ~s\n" (! exception e)) + ;;(log "exception-message: ~s\n" + ;; (exception-message (vm-demirror *the-vm* (! exception e)))) + ;;(log "exception-location: ~s\n" (src-loc>str (! location e))) + ;;(log "exception-catch-location: ~s\n" (src-loc>str (! catch-location e))) + (cond ((! notifyUncaught (as + (! request e))) + (process-exception e c state)) + (#t + (let* ((t (! thread e)) + (r (! request e)) + (ex (! exception e))) + (unless (eq? *last-exception* ex) + (set *last-exception* ex) + (set *last-stacktrace* (copy-stack t))) + (! resume t)) + state))) ( (let* ((r (! request e)) (k (! get-property r 'continuation))) (! disable r) (log "k: ~s\n" k) (k e)) - state))) + state) [356 lines skipped] From sboukarev at common-lisp.net Tue Oct 19 11:59:26 2010 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Tue, 19 Oct 2010 07:59:26 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv21531 Modified Files: ChangeLog swank-sbcl.lisp Log Message: * swank-sbcl.lisp (deinit-log-output): Use the right symbol for *LOG-OUTPUT*, swank package isn't available at the time swank-backend is compiled. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/16 10:10:38 1.2153 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/19 11:59:25 1.2154 @@ -1,3 +1,9 @@ +2010-10-19 Stas Boukarev + + * swank-sbcl.lisp (deinit-log-output): Use the right symbol for + *LOG-OUTPUT*, swank package isn't available at the time + swank-backend is compiled. + 2010-10-16 Stas Boukarev * swank-loader.lisp (default-fasl-dir): Guard against using :asdf --- /project/slime/cvsroot/slime/swank-sbcl.lisp 2010/10/07 17:15:07 1.278 +++ /project/slime/cvsroot/slime/swank-sbcl.lisp 2010/10/19 11:59:25 1.279 @@ -1660,6 +1660,7 @@ (defun deinit-log-output () ;; Can't hang on to an fd-stream from a previous session. - (setf *log-output* nil)) + (setf (symbol-value (find-symbol "*LOG-OUTPUT*" 'swank)) + nil)) (pushnew 'deinit-log-output sb-ext:*save-hooks*) From sboukarev at common-lisp.net Tue Oct 19 16:57:32 2010 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Tue, 19 Oct 2010 12:57:32 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv16435 Modified Files: ChangeLog swank.lisp Log Message: * swank.lisp (invoke-nth-restart): Make sure there is such restart before invoking it. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/19 11:59:25 1.2154 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/19 16:57:32 1.2155 @@ -1,5 +1,10 @@ 2010-10-19 Stas Boukarev + * swank.lisp (invoke-nth-restart): Make sure there is such restart + before invoking it. + +2010-10-19 Stas Boukarev + * swank-sbcl.lisp (deinit-log-output): Use the right symbol for *LOG-OUTPUT*, swank package isn't available at the time swank-backend is compiled. --- /project/slime/cvsroot/slime/swank.lisp 2010/10/15 22:42:14 1.732 +++ /project/slime/cvsroot/slime/swank.lisp 2010/10/19 16:57:32 1.733 @@ -2668,7 +2668,9 @@ (nth index *sldb-restarts*)) (defslimefun invoke-nth-restart (index) - (invoke-restart-interactively (nth-restart index))) + (let ((restart (nth-restart index))) + (when restart + (invoke-restart-interactively restart)))) (defslimefun sldb-abort () (invoke-restart (find 'abort *sldb-restarts* :key #'restart-name))) From sboukarev at common-lisp.net Wed Oct 20 11:42:20 2010 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Wed, 20 Oct 2010 07:42:20 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv7766 Modified Files: ChangeLog slime.el Log Message: * slime.el (slime-connect): Convert the port number read from minibuffer to an integer, passing it as a string to `make-network-process' isn't portable. Patch by Marko Kocic. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/19 16:57:32 1.2155 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/20 11:42:19 1.2156 @@ -1,3 +1,10 @@ +2010-10-20 Stas Boukarev + + * slime.el (slime-connect): Convert the port number read from + minibuffer to an integer, passing it as a string to + `make-network-process' isn't portable. + Patch by Marko Kocic. + 2010-10-19 Stas Boukarev * swank.lisp (invoke-nth-restart): Make sure there is such restart --- /project/slime/cvsroot/slime/slime.el 2010/10/15 22:42:14 1.1347 +++ /project/slime/cvsroot/slime/slime.el 2010/10/20 11:42:20 1.1348 @@ -1182,9 +1182,9 @@ (interactive (list (read-from-minibuffer "Host: " (first slime-connect-host-history) nil nil '(slime-connect-host-history . 1)) - (read-from-minibuffer + (string-to-int (read-from-minibuffer "Port: " (first slime-connect-port-history) - nil nil '(slime-connect-port-history . 1)))) + nil nil '(slime-connect-port-history . 1))))) (when (and (interactive-p) slime-net-processes (y-or-n-p "Close old connections first? ")) (slime-disconnect-all)) From heller at common-lisp.net Thu Oct 21 08:06:55 2010 From: heller at common-lisp.net (CVS User heller) Date: Thu, 21 Oct 2010 04:06:55 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv18684 Modified Files: ChangeLog swank-abcl.lisp Log Message: Require ABCL 0.22 and remove obsolete conditionalisation. * swank-abcl.lisp (call-with-debugger-hook) (install-debugger-globally) (call-with-debugging-environment, backtrace, print-frame, spawn): Remove #+/#- stuff. (preferred-communication-style): Return :spawn unconditionally. (sys::break): Removed. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/20 11:42:19 1.2156 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/21 08:06:55 1.2157 @@ -1,3 +1,14 @@ +2010-10-21 Helmut Eller + + Require ABCL 0.22 and remove obsolete conditionalisation. + + * swank-abcl.lisp (call-with-debugger-hook) + (install-debugger-globally) + (call-with-debugging-environment, backtrace, print-frame, spawn): + Remove #+/#- stuff. + (preferred-communication-style): Return :spawn unconditionally. + (sys::break): Removed. + 2010-10-20 Stas Boukarev * slime.el (slime-connect): Convert the port number read from --- /project/slime/cvsroot/slime/swank-abcl.lisp 2010/03/04 13:22:29 1.83 +++ /project/slime/cvsroot/slime/swank-abcl.lisp 2010/10/21 08:06:55 1.84 @@ -12,25 +12,10 @@ (eval-when (:compile-toplevel :load-toplevel :execute) (require :collect) ;just so that it doesn't spoil the flying letters - (require :pprint)) - -;;; The introduction of SYS::*INVOKE-DEBUGGER-HOOK* obliterates the -;;; need for redefining BREAK. The following should thus be removed at -;;; some point in the future. -#-#.(swank-backend:with-symbol '*invoke-debugger-hook* 'sys) -(defun sys::break (&optional (format-control "BREAK called") - &rest format-arguments) - (let ((sys::*saved-backtrace* - #+#.(swank-backend:with-symbol 'backtrace 'sys) - (sys:backtrace) - #-#.(swank-backend:with-symbol 'backtrace 'sys) - (ext:backtrace-as-list))) - (with-simple-restart (continue "Return from BREAK.") - (invoke-debugger - (sys::%make-condition 'simple-condition - (list :format-control format-control - :format-arguments format-arguments)))) - nil)) + (require :pprint) + (assert (>= (read-from-string (subseq (lisp-implementation-version) 0 4)) + 0.22) + () "This file needs ABCL version 0.22 or newer")) (defimplementation make-output-stream (write-string) (ext:make-slime-output-stream write-string)) @@ -144,11 +129,7 @@ (defimplementation preferred-communication-style () -#+#.(cl:if (cl:find-package :threads) '(:and) '(:or)) - :spawn -#-#.(cl:if (cl:find-package :threads) '(:and) '(:or)) - nil -) + :spawn) (defimplementation create-socket (host port) (ext:make-server-socket port)) @@ -266,7 +247,6 @@ (doc 'class))) result))) - (defimplementation describe-definition (symbol namespace) (ecase namespace (:variable @@ -285,29 +265,27 @@ (:class (describe (find-class symbol))))) - + ;;;; Debugger -;;; Copied from swank-sbcl.lisp. +;; Copied from swank-sbcl.lisp. +;; +;; Notice that *INVOKE-DEBUGGER-HOOK* is tried before *DEBUGGER-HOOK*, +;; so we have to make sure that the latter gets run when it was +;; established locally by a user (i.e. changed meanwhile.) (defun make-invoke-debugger-hook (hook) - #'(lambda (condition old-hook) - ;; Notice that *INVOKE-DEBUGGER-HOOK* is tried before - ;; *DEBUGGER-HOOK*, so we have to make sure that the latter gets - ;; run when it was established locally by a user (i.e. changed - ;; meanwhile.) - (if *debugger-hook* - (funcall *debugger-hook* condition old-hook) - (funcall hook condition old-hook)))) + (lambda (condition old-hook) + (if *debugger-hook* + (funcall *debugger-hook* condition old-hook) + (funcall hook condition old-hook)))) (defimplementation call-with-debugger-hook (hook fun) (let ((*debugger-hook* hook) - #+#.(swank-backend:with-symbol '*invoke-debugger-hook* 'sys) (sys::*invoke-debugger-hook* (make-invoke-debugger-hook hook))) (funcall fun))) (defimplementation install-debugger-globally (function) (setq *debugger-hook* function) - #+#.(swank-backend:with-symbol '*invoke-debugger-hook* 'sys) (setq sys::*invoke-debugger-hook* (make-invoke-debugger-hook function))) (defvar *sldb-topframe*) @@ -315,25 +293,14 @@ (defimplementation call-with-debugging-environment (debugger-loop-fn) (let* ((magic-token (intern "SWANK-DEBUGGER-HOOK" 'swank)) (*sldb-topframe* - #+#.(swank-backend:with-symbol 'backtrace 'sys) (second (member magic-token (sys:backtrace) - :key #'(lambda (frame) - (first (sys:frame-to-list frame))))) - #-#.(swank-backend:with-symbol 'backtrace 'sys) - (second (member magic-token (ext:backtrace-as-list) - :key #'(lambda (frame) - (first frame)))) - )) + :key (lambda (frame) + (first (sys:frame-to-list frame))))))) (funcall debugger-loop-fn))) (defun backtrace (start end) "A backtrace without initial SWANK frames." - (let ((backtrace - #+#.(swank-backend:with-symbol 'backtrace 'sys) - (sys:backtrace) - #-#.(swank-backend:with-symbol 'backtrace 'sys) - (ext:backtrace-as-list) - )) + (let ((backtrace (sys:backtrace))) (subseq (or (member *sldb-topframe* backtrace) backtrace) start end))) @@ -345,12 +312,8 @@ (backtrace start end))) (defimplementation print-frame (frame stream) - (write-string - #+#.(swank-backend:with-symbol 'backtrace 'sys) - (sys:frame-to-string frame) - #-#.(swank-backend:with-symbol 'backtrace 'sys) - (string-trim '(#\space #\newline) (prin1-to-string frame)) - stream)) + (write-string (sys:frame-to-string frame) + stream)) (defimplementation frame-locals (index) `(,(list :name "??" :id 0 :value "??"))) @@ -577,85 +540,83 @@ ;;;; Multithreading -#+#.(cl:if (cl:find-package :threads) '(:and) '(:or)) -(progn - (defimplementation spawn (fn &key name) - (threads:make-thread (lambda () (funcall fn)) :name name)) - - (defvar *thread-plists* (make-hash-table) ; should be a weak table - "A hashtable mapping threads to a plist.") - - (defvar *thread-id-counter* 0) - - (defimplementation thread-id (thread) - (threads:synchronized-on *thread-plists* - (or (getf (gethash thread *thread-plists*) 'id) - (setf (getf (gethash thread *thread-plists*) 'id) +(defimplementation spawn (fn &key name) + (threads:make-thread (lambda () (funcall fn)) :name name)) + +(defvar *thread-plists* (make-hash-table) ; should be a weak table + "A hashtable mapping threads to a plist.") + +(defvar *thread-id-counter* 0) + +(defimplementation thread-id (thread) + (threads:synchronized-on *thread-plists* + (or (getf (gethash thread *thread-plists*) 'id) + (setf (getf (gethash thread *thread-plists*) 'id) (incf *thread-id-counter*))))) - (defimplementation find-thread (id) - (find id (all-threads) +(defimplementation find-thread (id) + (find id (all-threads) :key (lambda (thread) - (getf (gethash thread *thread-plists*) 'id)))) + (getf (gethash thread *thread-plists*) 'id)))) - (defimplementation thread-name (thread) - (threads:thread-name thread)) +(defimplementation thread-name (thread) + (threads:thread-name thread)) - (defimplementation thread-status (thread) - (format nil "Thread is ~:[dead~;alive~]" (threads:thread-alive-p thread))) +(defimplementation thread-status (thread) + (format nil "Thread is ~:[dead~;alive~]" (threads:thread-alive-p thread))) - (defimplementation make-lock (&key name) - (declare (ignore name)) - (threads:make-thread-lock)) - - (defimplementation call-with-lock-held (lock function) - (threads:with-thread-lock (lock) (funcall function))) - - (defimplementation current-thread () - (threads:current-thread)) - - (defimplementation all-threads () - (copy-list (threads:mapcar-threads #'identity))) - - (defimplementation thread-alive-p (thread) - (member thread (all-threads))) - - (defimplementation interrupt-thread (thread fn) - (threads:interrupt-thread thread fn)) - - (defimplementation kill-thread (thread) - (threads:destroy-thread thread)) - - (defstruct mailbox - (queue '())) - - (defun mailbox (thread) - "Return THREAD's mailbox." - (threads:synchronized-on *thread-plists* - (or (getf (gethash thread *thread-plists*) 'mailbox) - (setf (getf (gethash thread *thread-plists*) 'mailbox) - (make-mailbox))))) - - (defimplementation send (thread message) - (let ((mbox (mailbox thread))) - (threads:synchronized-on mbox - (setf (mailbox-queue mbox) - (nconc (mailbox-queue mbox) (list message))) - (threads:object-notify-all mbox)))) - - (defimplementation receive-if (test &optional timeout) - (let* ((mbox (mailbox (current-thread)))) - (assert (or (not timeout) (eq timeout t))) - (loop - (check-slime-interrupts) - (threads:synchronized-on mbox - (let* ((q (mailbox-queue mbox)) - (tail (member-if test q))) - (when tail - (setf (mailbox-queue mbox) (nconc (ldiff q tail) (cdr tail))) - (return (car tail))) +(defimplementation make-lock (&key name) + (declare (ignore name)) + (threads:make-thread-lock)) + +(defimplementation call-with-lock-held (lock function) + (threads:with-thread-lock (lock) (funcall function))) + +(defimplementation current-thread () + (threads:current-thread)) + +(defimplementation all-threads () + (copy-list (threads:mapcar-threads #'identity))) + +(defimplementation thread-alive-p (thread) + (member thread (all-threads))) + +(defimplementation interrupt-thread (thread fn) + (threads:interrupt-thread thread fn)) + +(defimplementation kill-thread (thread) + (threads:destroy-thread thread)) + +(defstruct mailbox + (queue '())) + +(defun mailbox (thread) + "Return THREAD's mailbox." + (threads:synchronized-on *thread-plists* + (or (getf (gethash thread *thread-plists*) 'mailbox) + (setf (getf (gethash thread *thread-plists*) 'mailbox) + (make-mailbox))))) + +(defimplementation send (thread message) + (let ((mbox (mailbox thread))) + (threads:synchronized-on mbox + (setf (mailbox-queue mbox) + (nconc (mailbox-queue mbox) (list message))) + (threads:object-notify-all mbox)))) + +(defimplementation receive-if (test &optional timeout) + (let* ((mbox (mailbox (current-thread)))) + (assert (or (not timeout) (eq timeout t))) + (loop + (check-slime-interrupts) + (threads:synchronized-on mbox + (let* ((q (mailbox-queue mbox)) + (tail (member-if test q))) + (when tail + (setf (mailbox-queue mbox) (nconc (ldiff q tail) (cdr tail))) + (return (car tail))) (when (eq timeout t) (return (values nil t))) - (threads:object-wait mbox 0.3))))))) + (threads:object-wait mbox 0.3)))))) (defimplementation quit-lisp () (ext:exit)) From heller at common-lisp.net Thu Oct 21 08:07:03 2010 From: heller at common-lisp.net (CVS User heller) Date: Thu, 21 Oct 2010 04:07:03 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv18707 Modified Files: ChangeLog swank-abcl.lisp Log Message: In ABCL, try harder to find the source of stack frames. * swank-abcl.lisp (source-location): Now a GF. (source-location [java-stack-frame]): New. (source-location [lisp-stack-frame]): New. (source-location [function]): New. (frame-source-location, find-definitions): Use them. (*source-path*, find-definitions): New. (system-property, pathname-parent, pathname-absolute-p) (split-string, path-separator, search-path-property) (jdk-source-path, class-path, zipfile-contains-p) (find-file-in-path): Noise for filename frobbing. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/21 08:06:55 1.2157 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/21 08:07:03 1.2158 @@ -1,5 +1,20 @@ 2010-10-21 Helmut Eller + In ABCL, try harder to find the source of stack frames. + + * swank-abcl.lisp (source-location): Now a GF. + (source-location [java-stack-frame]): New. + (source-location [lisp-stack-frame]): New. + (source-location [function]): New. + (frame-source-location, find-definitions): Use them. + (*source-path*, find-definitions): New. + (system-property, pathname-parent, pathname-absolute-p) + (split-string, path-separator, search-path-property) + (jdk-source-path, class-path, zipfile-contains-p) + (find-file-in-path): Noise for filename frobbing. + +2010-10-21 Helmut Eller + Require ABCL 0.22 and remove obsolete conditionalisation. * swank-abcl.lisp (call-with-debugger-hook) --- /project/slime/cvsroot/slime/swank-abcl.lisp 2010/10/21 08:06:55 1.84 +++ /project/slime/cvsroot/slime/swank-abcl.lisp 2010/10/21 08:07:03 1.85 @@ -323,8 +323,9 @@ (disassemble (debugger:frame-function (nth-frame index)))) (defimplementation frame-source-location (index) - (list :error (format nil "Cannot find source for frame: ~A" - (nth-frame index)))) + (let ((frame (nth-frame index))) + (or (source-location (nth-frame index)) + `(:error ,(format nil "No source for frame: ~a" frame))))) #+nil (defimplementation eval-in-frame (form frame-number) @@ -435,22 +436,118 @@ (defimplementation find-definitions (symbol) (fspec-definition-locations symbol)) - |# -(defun source-location (symbol) +(defgeneric source-location (object)) + +(defmethod source-location ((symbol symbol)) (when (pathnamep (ext:source-pathname symbol)) (let ((pos (ext:source-file-position symbol))) - `(((,symbol) - (:location - (:file ,(namestring (ext:source-pathname symbol))) - ,(if pos - (list :position (1+ pos)) - (list :function-name (string symbol))) - (:align t))))))) + `(:location + (:file ,(namestring (ext:source-pathname symbol))) + ,(if pos + (list :position (1+ pos)) + (list :function-name (string symbol))) + (:align t))))) + +(defmethod source-location ((frame sys::java-stack-frame)) + (destructuring-bind (&key class method file line) (sys:frame-to-list frame) + (declare (ignore method)) + (let ((file (or (find-file-in-path file *source-path*) + (let ((f (format nil "~{~a/~}~a" + (butlast (split-string class "\\.")) + file))) + (find-file-in-path f *source-path*))))) + (and file + `(:location ,file (:line ,line) ()))))) + +(defmethod source-location ((frame sys::lisp-stack-frame)) + (destructuring-bind (operator &rest args) (sys:frame-to-list frame) + (declare (ignore args)) + (etypecase operator + (function (source-location operator)) + (list nil) + (symbol (source-location operator))))) + +(defmethod source-location ((fun function)) + (let ((name (function-name fun))) + (and name (source-location name)))) + +(defun system-property (name) + (java:jstatic "getProperty" "java.lang.System" name)) + +(defun pathname-parent (pathname) + (make-pathname :directory (butlast (pathname-directory pathname)))) + +(defun pathname-absolute-p (pathname) + (eq (car (pathname-directory pathname)) ':absolute)) + +(defun split-string (string regexp) + (coerce + (java:jcall (java:jmethod "java.lang.String" "split" "java.lang.String") + string regexp) + 'list)) + +(defun path-separator () + (java:jfield "java.io.File" "pathSeparator")) + +(defun search-path-property (prop-name) + (let ((string (system-property prop-name))) + (and string + (remove nil + (mapcar #'truename + (split-string string (path-separator))))))) + +(defun jdk-source-path () + (let* ((jre-home (truename (system-property "java.home"))) + (src-zip (merge-pathnames "src.zip" (pathname-parent jre-home))) + (truename (probe-file src-zip))) + (and truename (list truename)))) + +(defun class-path () + (append (search-path-property "java.class.path") + (search-path-property "sun.boot.class.path"))) + +(defvar *source-path* + (append (search-path-property "user.dir") + (jdk-source-path) + ;;(list (truename "/scratch/abcl/src")) + ) + "List of directories to search for source files.") + +(defun zipfile-contains-p (zipfile-name entry-name) + (let ((zipfile (java:jnew (java:jconstructor "java.util.zip.ZipFile" + "java.lang.String") + zipfile-name))) + (java:jcall + (java:jmethod "java.util.zip.ZipFile" "getEntry" "java.lang.String") + zipfile entry-name))) + +;; (find-file-in-path "java/lang/String.java" *source-path*) +;; (find-file-in-path "Lisp.java" *source-path*) + +;; Try fo find FILENAME in PATH. If found, return a file spec as +;; needed by Emacs. We also look in zip files. +(defun find-file-in-path (filename path) + (labels ((try (dir) + (cond ((not (pathname-type dir)) + (let ((f (probe-file (merge-pathnames filename dir)))) + (and f `(:file ,(namestring f))))) + ((equal (pathname-type dir) "zip") + (try-zip dir)) + (t (error "strange path element: ~s" path)))) + (try-zip (zip) + (let* ((zipfile-name (namestring (truename zip)))) + (and (zipfile-contains-p zipfile-name filename) + `(:dir ,zipfile-name ,filename))))) + (cond ((pathname-absolute-p filename) (probe-file filename)) + (t + (loop for dir in path + if (try dir) return it))))) (defimplementation find-definitions (symbol) - (source-location symbol)) + (let ((srcloc (source-location symbol))) + (and srcloc `((,symbol ,srcloc))))) #| Uncomment this if you have patched xref.lisp, as in From sboukarev at common-lisp.net Sat Oct 23 12:18:28 2010 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Sat, 23 Oct 2010 08:18:28 -0400 Subject: [slime-cvs] CVS slime Message-ID: Update of /project/slime/cvsroot/slime In directory cl-net:/tmp/cvs-serv4858 Modified Files: ChangeLog slime.el Log Message: * slime.el (slime-goto-location-position): In case of (:function-name name) go to (point-min) before searching for function. Remove redundant regexp and regexp-quote function name before inserting it into a regexp. --- /project/slime/cvsroot/slime/ChangeLog 2010/10/21 08:07:03 1.2158 +++ /project/slime/cvsroot/slime/ChangeLog 2010/10/23 12:18:28 1.2159 @@ -1,3 +1,10 @@ +2010-10-23 Stas Boukarev + + * slime.el (slime-goto-location-position): In case of + (:function-name name) go to (point-min) before searching for + function. Remove redundant regexp and regexp-quote function name + before inserting it into a regexp. + 2010-10-21 Helmut Eller In ABCL, try harder to find the source of stack frames. --- /project/slime/cvsroot/slime/slime.el 2010/10/20 11:42:20 1.1348 +++ /project/slime/cvsroot/slime/slime.el 2010/10/23 12:18:28 1.1349 @@ -3275,12 +3275,12 @@ ((:function-name name) (let ((case-fold-search t) (name (regexp-quote name))) - (when (or - (re-search-forward - (format "\\s *(def\\(\\s_\\|\\sw\\)*\\s +%s\\S_" name) nil t) - (re-search-forward - (format "\\s *(def\\(\\s_\\|\\sw\\)*\\s +(*%s\\S_" name) nil t) - (re-search-forward + (goto-char (point-min)) + (when (or + (re-search-forward + (format "\\s *(def\\(\\s_\\|\\sw\\)*\\s +(*%s\\S_" + (regexp-quote name)) nil t) + (re-search-forward (format "[( \t]%s\\>\\(\\s \\|$\\)" name) nil t)) (goto-char (match-beginning 0))))) ((:method name specializers &rest qualifiers) From sboukarev at common-lisp.net Thu Oct 28 13:30:31 2010 From: sboukarev at common-lisp.net (CVS User sboukarev) Date: Thu, 28 Oct 2010 09:30:31 -0400 Subject: [slime-cvs] CVS slime/contrib Message-ID: Update of /project/slime/cvsroot/slime/contrib In directory cl-net:/tmp/cvs-serv24827 Modified Files: ChangeLog swank-package-fu.lisp Log Message: * swank-package-fu.lisp (list-structure-symbols): Include the name of the structure too. --- /project/slime/cvsroot/slime/contrib/ChangeLog 2010/10/17 10:17:31 1.424 +++ /project/slime/cvsroot/slime/contrib/ChangeLog 2010/10/28 13:30:31 1.425 @@ -1,3 +1,8 @@ +2010-10-28 Stas Boukarev + + * swank-package-fu.lisp (list-structure-symbols): Include the name + of the structure too. + 2010-10-17 Helmut Eller Some updates to the Kawa backend. --- /project/slime/cvsroot/slime/contrib/swank-package-fu.lisp 2010/07/24 23:39:24 1.4 +++ /project/slime/cvsroot/slime/contrib/swank-package-fu.lisp 2010/10/28 13:30:31 1.5 @@ -21,7 +21,8 @@ #+sbcl (defun list-structure-symbols (name) (let ((dd (sb-kernel:find-defstruct-description name ))) - (list* (sb-kernel:dd-default-constructor dd) + (list* name + (sb-kernel:dd-default-constructor dd) (sb-kernel:dd-predicate-name dd) (sb-kernel::dd-copier-name dd) (mapcar #'sb-kernel:dsd-accessor-name @@ -30,7 +31,8 @@ #+ccl (defun list-structure-symbols (name) (let ((definition (gethash name ccl::%defstructs%))) - (list* (ccl::sd-constructor definition) + (list* name + (ccl::sd-constructor definition) (ccl::sd-refnames definition)))) (defun list-class-symbols (name)