Codebase list slime / b56eb28
Import upstream version 2.27 Debian Janitor 2 years ago
32 changed file(s) with 393 addition(s) and 285 deletion(s). Raw diff Collapse all Expand all
1212 matrix:
1313 lisp: [ccl, sbcl]
1414 os: [ubuntu-latest]
15 emacs_version: [24-5, 25-3, 26-3, snapshot]
15 emacs_version: [24-5, 25-3, 26-3, 27-1, snapshot]
1616 fail-fast: false
1717 steps:
1818
1919 - uses: cachix/install-nix-action@v12
20 with:
21 nix_path: nixpkgs=channel:nixos-unstable
2022 - uses: purcell/setup-emacs@master
2123 with:
2224 version: ${{ matrix.emacs_version }}
2325 - uses: actions/checkout@v2
24 - run: nix-env -i ${{ matrix.lisp }}
26 - run: nix-env -i ${{ matrix.lisp }} -f '<nixpkgs>'
2527 - run: make LISP="${{ matrix.lisp }}" check
0 15cf0609d30255405957bf0612fd6291fea438bc
0 cf30941e5858e93eb91574ad91499075222a447b
00 * SLIME News -*- mode: outline; coding: utf-8 -*-
1 * 2.27 (January 2022)
2 ** Mostly improved compatibility with different implementations and bug fixes.
3
14 * 2.26.1 (December 2020)
25 ** SBCL compatibility
36
6363 ;;; alias devgnu '(echo -n "\!* "; cat -; echo -n "")'
6464 ;;;
6565 ;;; ls | devgnu *scratch*
66
67 (eval-when-compile
68 (require 'cl))
6966
7067 ;;;%Parameters
7168 (defvar bridge-hook nil
289286 ;; equivalent sections have the same numbers here;
290287 ;; we fold them together in this code.
291288
292 (block bridge-filter
289 (cl-block bridge-filter
293290 (unwind-protect
294291 (while (< end (length output))
295292
348345 (bridge-insert pass-on))))
349346
350347 (if (and b-start-end (not b-end))
351 (return-from bridge-filter t) ; when last bit has prematurely ending message, exit early.
348 (cl-return-from bridge-filter t) ; when last bit has prematurely ending message, exit early.
352349 (progn
353350 ;;3 find handler (in b-start, b-end) if none current
354351 (if (and b-start (not bridge-in-progress))
4242
4343 (require 'slime) ; only for its cl-lib loading smartness
4444 (require 'cl-lib)
45 (eval-when-compile (require 'cl))
4645
4746 (defgroup lisp-indent nil
4847 "Indentation in Lisp."
228227 ;;;; explicitly, however, and offers name completion, etc.
229228
230229 ;;; Convenience accessors
231 (defun common-lisp-style-name (style) (first style))
232 (defun common-lisp-style-inherits (style) (second style))
233 (defun common-lisp-style-variables (style) (third style))
234 (defun common-lisp-style-indentation (style) (fourth style))
235 (defun common-lisp-style-hook (style) (fifth style))
236 (defun common-lisp-style-docstring (style) (sixth style))
230 (defun common-lisp-style-name (style) (cl-first style))
231 (defun common-lisp-style-inherits (style) (cl-second style))
232 (defun common-lisp-style-variables (style) (cl-third style))
233 (defun common-lisp-style-indentation (style) (cl-fourth style))
234 (defun common-lisp-style-hook (style) (cl-fifth style))
235 (defun common-lisp-style-docstring (style) (cl-sixth style))
237236
238237 (defun common-lisp-make-style (stylename inherits variables indentation hook
239238 documentation)
305304 (push (list name (common-lisp-style-docstring style)) all))
306305 common-lisp-styles)
307306 (dolist (info (sort all (lambda (a b) (string< (car a) (car b)))))
308 (let ((style-name (first info))
309 (style-doc (second info)))
307 (let ((style-name (cl-first info))
308 (style-doc (cl-second info)))
310309 (if style-doc
311310 (setq doc (concat doc
312311 "\n " style-name "\n"
326325 (common-lisp-activate-style basename methods))
327326 ;; Copy methods
328327 (dolist (spec (common-lisp-style-indentation style))
329 (puthash (first spec) (second spec) methods))
328 (puthash (cl-first spec) (cl-second spec) methods))
330329 ;; Bind variables.
331330 (dolist (var (common-lisp-style-variables style))
332 (set (make-local-variable (first var)) (second var)))
331 (set (make-local-variable (cl-first var)) (cl-second var)))
333332 ;; Run hook.
334333 (let ((hook (common-lisp-style-hook style)))
335334 (when hook
617616 (let ((guess nil)
618617 (guess-n 0)
619618 (package (common-lisp-symbol-package full)))
620 (dolist (info system-info guess)
619 (cl-dolist (info system-info guess)
621620 (let* ((pkgs (cdr info))
622621 (n (length pkgs)))
623622 (cond ((member package pkgs)
624623 ;; This is it.
625 (return (car info)))
624 (cl-return (car info)))
626625 ((> n guess-n)
627626 ;; If we can't find the real thing, go with the one
628627 ;; accessible in most packages.
758757 ;;; boot, and sufficient for our needs.
759758 (defun common-lisp-looking-back (string)
760759 (let ((len (length string)))
761 (dotimes (i len t)
760 (cl-dotimes (i len t)
762761 (unless (eql (elt string (- len i 1)) (char-before (- (point) i)))
763 (return nil)))))
762 (cl-return nil)))))
764763
765764 (defvar common-lisp-feature-expr-regexp "#!?\\(+\\|-\\)")
766765
13361335 (backward-sexp)
13371336 (looking-at "nil\\|("))))
13381337 (+ sexp-column
1339 (case (car path)
1338 (cl-case (car path)
13401339 ((1 3) 4)
13411340 (2 4)
13421341 (t 2))))
13431342 ;; Short form.
13441343 (t
13451344 (+ sexp-column
1346 (case (car path)
1345 (cl-case (car path)
13471346 (1 4)
13481347 (2 4)
13491348 (t 2)))))
13751374 (when (setq nskip (lisp-beginning-of-defmethod-qualifiers))
13761375 (skip-chars-forward " \t\n")
13771376 (while (looking-at "\\sw\\|\\s_")
1378 (incf nskip)
1377 (cl-incf nskip)
13791378 (forward-sexp)
13801379 (skip-chars-forward " \t\n"))
13811380 t))
17021701
17031702 (defun common-lisp-indent-if*-advance-past-keyword-on-line ()
17041703 (forward-word 1)
1705 (block move-forward
1706 (while (and (looking-at "\\s-") (not (eolp)))
1707 (forward-char 1)))
1704 (while (and (looking-at "\\s-") (not (eolp)))
1705 (forward-char 1))
17081706 (if (eolp)
17091707 nil
17101708 (current-column)))
0 ;;;; -*- lexical-binding: t -*-
1
02 (require 'slime)
13 (require 'slime-repl)
24 (require 'cl-lib)
3 (eval-when-compile
4 (require 'cl)) ; lexical-let
55
66 (define-slime-contrib slime-clipboard
77 "This add a few commands to put objects into a clipboard and to
8282 (defun slime-clipboard-redisplay ()
8383 "Update the clipboard buffer."
8484 (interactive)
85 (lexical-let ((saved (point)))
86 (slime-eval-async
87 `(swank-clipboard:entries)
88 (lambda (entries)
85 (let ((saved (point)))
86 (slime-eval-async
87 `(swank-clipboard:entries)
88 (lambda (entries)
8989 (let ((inhibit-read-only t))
9090 (erase-buffer)
9191 (slime-clipboard-insert-entries entries)
7373 ;; count sexps until either '(' or comment is found at first column
7474 (while (and (not (looking-at "^[(;]"))
7575 (ignore-errors (backward-up-list 1) t))
76 (incf sexp-level))))
76 (cl-incf sexp-level))))
7777 (when (> sexp-level 0)
7878 ;; insert correct number of right parens
7979 (goto-char point)
111111 (replace-match ""))))
112112 (while (> arg 0)
113113 (backward-char 1)
114 (cond ((looking-at ")") (incf arg))
115 ((looking-at "(") (decf arg))))
114 (cond ((looking-at ")") (cl-incf arg))
115 ((looking-at "(") (cl-decf arg))))
116116 (insert "#|")
117117 (forward-sexp)
118118 (insert "|#")))
181181 (point)))))
182182 (cl-values (or (/= beg orig-beg) (/= end orig-end)) beg end)))
183183
184
184
185185 (defun slime-activate-font-lock-magic ()
186186 (if (featurep 'xemacs)
187187 (let ((pattern `((slime-search-suppressed-forms
202202 (let ((byte-compile-warnings '()))
203203 (mapc (lambda (sym)
204204 (cond ((fboundp sym)
205 (unless (byte-code-function-p (symbol-function sym))
205 (unless (or (byte-code-function-p (symbol-function sym))
206 (subrp (symbol-function sym)))
206207 (byte-compile sym)))
207208 (t (error "%S is not fbound" sym))))
208209 '(slime-extend-region-for-font-lock
125125 fuzzy completions in the target buffer. Most of the bindings will
126126 do an implicit select in the completion window and let the
127127 keypress be processed in the target buffer."
128 nil
129 nil
130 slime-target-buffer-fuzzy-completions-map)
128 :init-value nil
129 :lighter nil
130 :keymap slime-target-buffer-fuzzy-completions-map)
131131
132132 (add-to-list 'minor-mode-alist
133133 '(slime-fuzzy-target-buffer-completions-mode
0 ;;;; -*- lexical-binding: t -*-
1
02 (require 'slime)
13 (require 'url-http)
24 (require 'browse-url)
3 (eval-when-compile (require 'cl)) ; lexical-let
45
5 (defvar slime-old-documentation-lookup-function
6 (defvar slime-old-documentation-lookup-function
67 slime-documentation-lookup-function)
78
89 (define-slime-contrib slime-hyperdoc
2021
2122 (defun slime-hyperdoc-lookup-rpc (symbol-name)
2223 (slime-eval-async `(swank:hyperdoc ,symbol-name)
23 (lexical-let ((symbol-name symbol-name))
24 (let ((symbol-name symbol-name))
2425 #'(lambda (result)
2526 (slime-log-event result)
2627 (cl-loop with foundp = nil
111111
112112 (mapc (lambda (sym)
113113 (cond ((fboundp sym)
114 (unless (byte-code-function-p (symbol-function sym))
114 (unless (or (byte-code-function-p (symbol-function sym))
115 (subrp (symbol-function sym)))
115116 (byte-compile sym)))
116117 (t (error "%S is not fbound" sym))))
117118 '(slime-parse-form-upto-point
00 (require 'slime)
11 (require 'bridge)
22 (require 'cl-lib)
3 (eval-when-compile
4 (require 'cl))
53
64 (define-slime-contrib slime-presentations
75 "Imitate LispM presentations."
5351 ;; FIXME: This conditional is not right - just used because the code
5452 ;; here does not work in XEmacs.
5553 (when (boundp 'text-property-default-nonsticky)
56 (pushnew '(slime-repl-presentation . t) text-property-default-nonsticky
57 :test 'equal)
58 (pushnew '(slime-repl-result-face . t) text-property-default-nonsticky
59 :test 'equal))
54 (cl-pushnew '(slime-repl-presentation . t) text-property-default-nonsticky
55 :test 'equal)
56 (cl-pushnew '(slime-repl-result-face . t) text-property-default-nonsticky
57 :test 'equal))
6058
6159 (make-variable-buffer-local
6260 (defvar slime-presentation-start-to-point (make-hash-table)))
121119 syntax-table ,slime-presentation-syntax-table
122120 rear-nonsticky t))
123121 ;; Use the presentation as the key of a text property
124 (case (- end start)
122 (cl-case (- end start)
125123 (0)
126124 (1
127125 (add-text-properties start end
186184
187185 (defun slime-presentation-whole-p (presentation start end &optional object)
188186 (let ((object (or object (current-buffer))))
189 (string= (etypecase object
187 (string= (cl-etypecase object
190188 (buffer (with-current-buffer object
191189 (buffer-substring-no-properties start end)))
192190 (string (substring-no-properties object start end)))
194192
195193 (defun slime-presentations-around-point (point &optional object)
196194 (let ((object (or object (current-buffer))))
197 (loop for (key value . rest) on (text-properties-at point object) by 'cddr
198 when (slime-presentation-p key)
199 collect key)))
195 (cl-loop for (key value . rest) on (text-properties-at point object) by 'cddr
196 when (slime-presentation-p key)
197 collect key)))
200198
201199 (defun slime-presentation-start-p (tag)
202200 (memq tag '(:start :start-and-end)))
213211 (let ((change-point (previous-single-property-change
214212 point presentation object (point-min))))
215213 (unless change-point
216 (return-from slime-presentation-start
217 (values (etypecase object
218 (buffer (with-current-buffer object 1))
219 (string 0))
220 nil)))
214 (cl-return-from slime-presentation-start
215 (cl-values (cl-etypecase object
216 (buffer (with-current-buffer object 1))
217 (string 0))
218 nil)))
221219 (setq this-presentation (get-text-property change-point
222220 presentation object))
223221 (unless this-presentation
224 (return-from slime-presentation-start
225 (values point nil)))
222 (cl-return-from slime-presentation-start
223 (cl-values point nil)))
226224 (setq point change-point)))
227 (values point t)))
225 (cl-values point t)))
228226
229227 (cl-defun slime-presentation-end (point presentation
230228 &optional (object (current-buffer)))
236234 (let ((change-point (next-single-property-change
237235 point presentation object)))
238236 (unless change-point
239 (return-from slime-presentation-end
240 (values (etypecase object
241 (buffer (with-current-buffer object (point-max)))
242 (string (length object)))
243 nil)))
237 (cl-return-from slime-presentation-end
238 (cl-values (cl-etypecase object
239 (buffer (with-current-buffer object (point-max)))
240 (string (length object)))
241 nil)))
244242 (setq point change-point)
245243 (setq this-presentation (get-text-property point
246244 presentation object))))
248246 (let ((after-end (next-single-property-change point
249247 presentation object)))
250248 (if (not after-end)
251 (values (etypecase object
252 (buffer (with-current-buffer object (point-max)))
253 (string (length object)))
254 t)
255 (values after-end t)))
256 (values point nil))))
249 (cl-values (cl-etypecase object
250 (buffer (with-current-buffer object (point-max)))
251 (string (length object)))
252 t)
253 (cl-values after-end t)))
254 (cl-values point nil))))
257255
258256 (cl-defun slime-presentation-bounds (point presentation
259257 &optional (object (current-buffer)))
260258 "Return start index and end index of `presentation' around `point'
261259 in `object', and whether the presentation is complete."
262 (multiple-value-bind (start good-start)
260 (cl-multiple-value-bind (start good-start)
263261 (slime-presentation-start point presentation object)
264 (multiple-value-bind (end good-end)
262 (cl-multiple-value-bind (end good-end)
265263 (slime-presentation-end point presentation object)
266 (values start end
267 (and good-start good-end
268 (slime-presentation-whole-p presentation
269 start end object))))))
264 (cl-values start end
265 (and good-start good-end
266 (slime-presentation-whole-p presentation
267 start end object))))))
270268
271269 (defun slime-presentation-around-point (point &optional object)
272270 "Return presentation, start index, end index, and whether the
276274 (innermost-start 0)
277275 (innermost-end most-positive-fixnum))
278276 (dolist (presentation (slime-presentations-around-point point object))
279 (multiple-value-bind (start end whole-p)
277 (cl-multiple-value-bind (start end whole-p)
280278 (slime-presentation-bounds point presentation object)
281279 (when whole-p
282280 (when (< (- end start) (- innermost-end innermost-start))
283281 (setq innermost-start start
284282 innermost-end end
285283 innermost-presentation presentation)))))
286 (values innermost-presentation
287 innermost-start innermost-end)))
284 (cl-values innermost-presentation
285 innermost-start innermost-end)))
288286
289287 (defun slime-presentation-around-or-before-point (point &optional object)
290288 (let ((object (or object (current-buffer))))
291 (multiple-value-bind (presentation start end whole-p)
289 (cl-multiple-value-bind (presentation start end whole-p)
292290 (slime-presentation-around-point point object)
293291 (if (or presentation (= point (point-min)))
294 (values presentation start end whole-p)
292 (cl-values presentation start end whole-p)
295293 (slime-presentation-around-point (1- point) object)))))
296294
297295 (defun slime-presentation-around-or-before-point-or-error (point)
298 (multiple-value-bind (presentation start end whole-p)
296 (cl-multiple-value-bind (presentation start end whole-p)
299297 (slime-presentation-around-or-before-point point)
300298 (unless presentation
301299 (error "No presentation at point"))
302 (values presentation start end whole-p)))
300 (cl-values presentation start end whole-p)))
303301
304302 (cl-defun slime-for-each-presentation-in-region (from to function
305303 &optional (object (current-buffer)))
307305 `whole-p' for every presentation in the region `from'--`to' in the
308306 string or buffer `object'."
309307 (cl-labels ((handle-presentation (presentation point)
310 (multiple-value-bind (start end whole-p)
308 (cl-multiple-value-bind (start end whole-p)
311309 (slime-presentation-bounds point presentation object)
312310 (funcall function presentation start end whole-p))))
313311 ;; Handle presentations active at `from'.
361359 (let ((point (if (featurep 'xemacs) (event-point event) (posn-point (event-end event))))
362360 (window (if (featurep 'xemacs) (event-window event) (caadr event))))
363361 (with-current-buffer (window-buffer window)
364 (multiple-value-bind (presentation start end)
362 (cl-multiple-value-bind (presentation start end)
365363 (slime-presentation-around-point point)
366364 (unless presentation
367365 (error "No presentation at click"))
368 (values presentation start end (current-buffer))))))
366 (cl-values presentation start end (current-buffer))))))
369367
370368 (defun slime-check-presentation (from to buffer presentation)
371369 (unless (slime-eval `(cl:nth-value 1 (swank:lookup-presented-object
375373
376374 (defun slime-copy-or-inspect-presentation-at-mouse (event)
377375 (interactive "e") ; no "@" -- we don't want to select the clicked-at window
378 (multiple-value-bind (presentation start end buffer)
376 (cl-multiple-value-bind (presentation start end buffer)
379377 (slime-presentation-around-click event)
380378 (slime-check-presentation start end buffer presentation)
381379 (if (with-current-buffer buffer
392390
393391 (defun slime-inspect-presentation-at-mouse (event)
394392 (interactive "e")
395 (multiple-value-bind (presentation start end buffer)
393 (cl-multiple-value-bind (presentation start end buffer)
396394 (slime-presentation-around-click event)
397395 (slime-inspect-presentation presentation start end buffer)))
398396
399397 (defun slime-inspect-presentation-at-point (point)
400398 (interactive "d")
401 (multiple-value-bind (presentation start end)
399 (cl-multiple-value-bind (presentation start end)
402400 (slime-presentation-around-or-before-point-or-error point)
403401 (slime-inspect-presentation presentation start end (current-buffer))))
404402
418416
419417 (defun slime-M-.-presentation-at-mouse (event)
420418 (interactive "e")
421 (multiple-value-bind (presentation start end buffer)
419 (cl-multiple-value-bind (presentation start end buffer)
422420 (slime-presentation-around-click event)
423421 (slime-M-.-presentation presentation start end buffer)))
424422
425423 (defun slime-M-.-presentation-at-point (point)
426424 (interactive "d")
427 (multiple-value-bind (presentation start end)
425 (cl-multiple-value-bind (presentation start end)
428426 (slime-presentation-around-or-before-point-or-error point)
429427 (slime-M-.-presentation presentation start end (current-buffer))))
430428
431429 (defun slime-edit-presentation (name &optional where)
432430 (if (or current-prefix-arg (not (equal (slime-symbol-at-point) name)))
433431 nil ; NAME came from user explicitly, so decline.
434 (multiple-value-bind (presentation start end whole-p)
432 (cl-multiple-value-bind (presentation start end whole-p)
435433 (slime-presentation-around-or-before-point (point))
436434 (when presentation
437435 (slime-M-.-presentation presentation start end (current-buffer) where)))))
460458
461459 (defun slime-copy-presentation-at-mouse-to-repl (event)
462460 (interactive "e")
463 (multiple-value-bind (presentation start end buffer)
461 (cl-multiple-value-bind (presentation start end buffer)
464462 (slime-presentation-around-click event)
465463 (slime-copy-presentation-to-repl presentation start end buffer)))
466464
467465 (defun slime-copy-presentation-at-point-to-repl (point)
468466 (interactive "d")
469 (multiple-value-bind (presentation start end)
467 (cl-multiple-value-bind (presentation start end)
470468 (slime-presentation-around-or-before-point-or-error point)
471469 (slime-copy-presentation-to-repl presentation start end (current-buffer))))
472470
473471 (defun slime-copy-presentation-at-mouse-to-point (event)
474472 (interactive "e")
475 (multiple-value-bind (presentation start end buffer)
473 (cl-multiple-value-bind (presentation start end buffer)
476474 (slime-presentation-around-click event)
477475 (let ((presentation-text
478476 (with-current-buffer buffer
494492
495493 (defun slime-copy-presentation-at-mouse-to-kill-ring (event)
496494 (interactive "e")
497 (multiple-value-bind (presentation start end buffer)
495 (cl-multiple-value-bind (presentation start end buffer)
498496 (slime-presentation-around-click event)
499497 (slime-copy-presentation-to-kill-ring presentation start end buffer)))
500498
501499 (defun slime-copy-presentation-at-point-to-kill-ring (point)
502500 (interactive "d")
503 (multiple-value-bind (presentation start end)
501 (cl-multiple-value-bind (presentation start end)
504502 (slime-presentation-around-or-before-point-or-error point)
505503 (slime-copy-presentation-to-kill-ring presentation start end (current-buffer))))
506504
511509
512510 (defun slime-describe-presentation-at-mouse (event)
513511 (interactive "@e")
514 (multiple-value-bind (presentation) (slime-presentation-around-click event)
512 (cl-multiple-value-bind (presentation) (slime-presentation-around-click event)
515513 (slime-describe-presentation presentation)))
516514
517515 (defun slime-describe-presentation-at-point (point)
518516 (interactive "d")
519 (multiple-value-bind (presentation)
517 (cl-multiple-value-bind (presentation)
520518 (slime-presentation-around-or-before-point-or-error point)
521519 (slime-describe-presentation presentation)))
522520
528526
529527 (defun slime-pretty-print-presentation-at-mouse (event)
530528 (interactive "@e")
531 (multiple-value-bind (presentation) (slime-presentation-around-click event)
529 (cl-multiple-value-bind (presentation) (slime-presentation-around-click event)
532530 (slime-pretty-print-presentation presentation)))
533531
534532 (defun slime-pretty-print-presentation-at-point (point)
535533 (interactive "d")
536 (multiple-value-bind (presentation)
534 (cl-multiple-value-bind (presentation)
537535 (slime-presentation-around-or-before-point-or-error point)
538536 (slime-pretty-print-presentation presentation)))
539537
540538 (defun slime-mark-presentation (point)
541539 (interactive "d")
542 (multiple-value-bind (presentation start end)
540 (cl-multiple-value-bind (presentation start end)
543541 (slime-presentation-around-or-before-point-or-error point)
544542 (goto-char start)
545543 (push-mark end nil t)))
559557 (interactive "p")
560558 (unless arg (setq arg 1))
561559 (cond
562 ((plusp arg)
560 ((cl-plusp arg)
563561 (dotimes (i arg)
564562 ;; First skip outside the current surrounding presentation (if any)
565 (multiple-value-bind (presentation start end)
563 (cl-multiple-value-bind (presentation start end)
566564 (slime-presentation-around-point (point))
567565 (when presentation
568566 (goto-char end)))
569567 (let ((p (next-single-property-change (point) 'slime-repl-presentation)))
570568 (unless p
571569 (error "No next presentation"))
572 (multiple-value-bind (presentation start end)
570 (cl-multiple-value-bind (presentation start end)
573571 (slime-presentation-around-or-before-point-or-error p)
574572 (goto-char start)))))
575 ((minusp arg)
573 ((cl-minusp arg)
576574 (dotimes (i (- arg))
577575 ;; First skip outside the current surrounding presentation (if any)
578 (multiple-value-bind (presentation start end)
576 (cl-multiple-value-bind (presentation start end)
579577 (slime-presentation-around-point (point))
580578 (when presentation
581579 (goto-char start)))
582580 (let ((p (previous-single-property-change (point) 'slime-repl-presentation)))
583581 (unless p
584582 (error "No previous presentation"))
585 (multiple-value-bind (presentation start end)
583 (cl-multiple-value-bind (presentation start end)
586584 (slime-presentation-around-or-before-point-or-error p)
587585 (goto-char start)))))))
588586
609607 (let ((sym (cl-gensym)))
610608 (setf (gethash sym choice-to-lambda) f)
611609 sym)))
612 (etypecase choices
610 (cl-etypecase choices
613611 (list
614612 `(,(format "Presentation %s" (truncate-string-to-width
615613 (slime-presentation-text presentation)
626624 ,@(let ((nchoice 0))
627625 (mapcar
628626 (lambda (choice)
629 (incf nchoice)
627 (cl-incf nchoice)
630628 (cons choice
631629 (savel `(lambda ()
632630 (interactive)
648646 (window (if (featurep 'xemacs) (event-window event) (caadr event)))
649647 (buffer (window-buffer window))
650648 (choice-to-lambda (make-hash-table)))
651 (multiple-value-bind (presentation from to)
649 (cl-multiple-value-bind (presentation from to)
652650 (with-current-buffer buffer
653651 (slime-presentation-around-point point))
654652 (unless presentation
663661 "Return a string that contains a CL s-expression accessing
664662 the presented object."
665663 (let ((id (slime-presentation-id presentation)))
666 (etypecase id
664 (cl-etypecase id
667665 (number
668666 ;; Make sure it works even if *read-base* is not 10.
669667 (format "(swank:lookup-presented-object-or-lose %d.)" id))
680678 (let ((pos (slime-property-position 'slime-repl-presentation str-props)))
681679 (if (null pos)
682680 str-no-props
683 (multiple-value-bind (presentation start-pos end-pos whole-p)
681 (cl-multiple-value-bind (presentation start-pos end-pos whole-p)
684682 (slime-presentation-around-point pos str-props)
685683 (if (not presentation)
686684 str-no-props
697695 "Resend the old REPL output at point.
698696 If replace it non-nil the current input is replaced with the old
699697 output; otherwise the new input is appended."
700 (multiple-value-bind (presentation beg end)
698 (cl-multiple-value-bind (presentation beg end)
701699 (slime-presentation-around-or-before-point (point))
702700 (slime-check-presentation beg end (current-buffer) presentation)
703701 (let ((old-output (buffer-substring beg end))) ;;keep properties
732730 (define-key slime-prefix-map "\C-v" slime-presentation-command-map))
733731
734732 (defun slime-presentation-around-or-before-point-p ()
735 (multiple-value-bind (presentation beg end)
733 (cl-multiple-value-bind (presentation beg end)
736734 (slime-presentation-around-or-before-point (point))
737735 presentation))
738736
793791 (slime-repl-show-maximum-output)))
794792
795793 (defun slime-presentation-write (string &optional target)
796 (case target
794 (cl-case target
797795 ((nil) ; Regular process output
798796 (slime-repl-emit string))
799797 (:repl-result
825823 (setq bridge-destination-insert nil)
826824 (setq bridge-source-insert nil)
827825 (setq bridge-handlers
828 (list* '("<" . slime-mark-presentation-start-handler)
829 '(">" . slime-mark-presentation-end-handler)
830 bridge-handlers)))
826 (cl-list* '("<" . slime-mark-presentation-start-handler)
827 '(">" . slime-mark-presentation-end-handler)
828 bridge-handlers)))
831829
832830 (defun slime-clear-presentations ()
833831 "Forget all objects associated to SLIME presentations.
1616 (require 'slime)
1717 (require 'slime-parse)
1818 (require 'cl-lib)
19 (eval-when-compile (require 'cl)) ; slime-def-connection-var, which
20 ; expands to defsetf not in cl-lib
2119
2220 (define-slime-contrib slime-repl
2321 "Read-Eval-Print Loop written in Emacs Lisp.
192190
193191 (defun slime-output-filter (process string)
194192 (with-current-buffer (process-buffer process)
195 (when (and (plusp (length string))
193 (when (and (cl-plusp (length string))
196194 (eq (process-status slime-buffer-connection) 'open))
197195 (slime-write-string string))))
198196
253251 (funcall slime-write-string-function string target))
254252
255253 (defun slime-repl-write-string (string &optional target)
256 (case target
254 (cl-case target
257255 ((nil) (slime-repl-emit string))
258256 (:repl-result (slime-repl-emit-result string t))
259257 (t (slime-repl-emit-to-target string target))))
324322 (set-marker marker (point)))))))
325323
326324 (defun slime-repl-output-target-marker (target)
327 (case target
325 (cl-case target
328326 ((nil)
329327 (with-current-buffer (slime-output-buffer)
330328 slime-output-end))
426424
427425 (defvar slime-repl-mode-map
428426 (let ((map (make-sparse-keymap)))
429 (set-keymap-parent map lisp-mode-map)
427 (set-keymap-parent map (copy-keymap lisp-mode-map))
430428 map))
431429
432430 (slime-define-keys slime-prefix-map
480478 (define-minor-mode slime-repl-map-mode
481479 "Minor mode which makes slime-repl-mode-map available.
482480 \\{slime-repl-mode-map}"
483 nil
484 nil
485 slime-repl-mode-map)
481 :init-value nil
482 :lighter nil
483 :keymap slime-repl-mode-map)
486484
487485 (defun slime-repl-mode ()
488486 "Major mode for interacting with a superior Lisp.
771769 (add-text-properties slime-repl-input-start-mark
772770 (point)
773771 `(slime-repl-old-input
774 ,(incf slime-repl-old-input-counter))))
772 ,(cl-incf slime-repl-old-input-counter))))
775773 (let ((overlay (make-overlay slime-repl-input-start-mark end)))
776774 ;; These properties are on an overlay so that they won't be taken
777775 ;; by kill/yank.
787785 If replace is non-nil the current input is replaced with the old
788786 input; otherwise the new input is appended. The old input has the
789787 text property `slime-repl-old-input'."
790 (multiple-value-bind (beg end) (slime-property-bounds 'slime-repl-old-input)
788 (cl-multiple-value-bind (beg end) (slime-property-bounds 'slime-repl-old-input)
791789 (let ((old-input (buffer-substring beg end)) ;;preserve
792790 ;;properties, they will be removed later
793791 (offset (- (point) beg)))
931929 (with-current-buffer (slime-output-buffer)
932930 (let ((previouse-point (- (point) slime-repl-input-start-mark))
933931 (previous-prompt (slime-lisp-package-prompt-string)))
934 (destructuring-bind (name prompt-string)
932 (cl-destructuring-bind (name prompt-string)
935933 (slime-repl-shortcut-eval `(swank:set-package ,package))
936934 (setf (slime-lisp-package) name)
937935 (setf slime-buffer-package name)
938936 (unless (equal previous-prompt prompt-string)
939937 (setf (slime-lisp-package-prompt-string) prompt-string)
940938 (slime-repl-insert-prompt))
941 (when (plusp previouse-point)
939 (when (cl-plusp previouse-point)
942940 (goto-char (+ previouse-point slime-repl-input-start-mark)))))))
943941
944942
10161014 Return -1 resp. the length of the history if no item matches.
10171015 If EXCLUDE-STRING is specified then it's excluded from the search."
10181016 ;; Loop through the history list looking for a matching line
1019 (let* ((step (ecase direction
1017 (let* ((step (cl-ecase direction
10201018 (forward -1)
10211019 (backward 1)))
10221020 (history slime-repl-input-history)
10231021 (len (length history)))
1024 (loop for pos = (+ start-pos step) then (+ pos step)
1025 if (< pos 0) return -1
1026 if (<= len pos) return len
1027 for history-item = (nth pos history)
1028 if (and (string-match regexp history-item)
1029 (not (equal history-item exclude-string)))
1030 return pos)))
1022 (cl-loop for pos = (+ start-pos step) then (+ pos step)
1023 if (< pos 0) return -1
1024 if (<= len pos) return len
1025 for history-item = (nth pos history)
1026 if (and (string-match regexp history-item)
1027 (not (equal history-item exclude-string)))
1028 return pos)))
10311029
10321030 (defun slime-repl-previous-input ()
10331031 "Cycle backwards through input history.
12241222 (define-minor-mode slime-repl-read-mode
12251223 "Mode to read input from Emacs
12261224 \\{slime-repl-read-mode-map}"
1227 nil
1228 "[read]")
1225 :init-value nil
1226 :lighter "[read]")
12291227
12301228 (make-variable-buffer-local
12311229 (defvar slime-read-string-threads nil))
12901288 (call-interactively handler))))))
12911289
12921290 (defun slime-list-all-repl-shortcuts ()
1293 (loop for shortcut in slime-repl-shortcut-table
1294 append (slime-repl-shortcut.names shortcut)))
1291 (cl-loop for shortcut in slime-repl-shortcut-table
1292 append (slime-repl-shortcut.names shortcut)))
12951293
12961294 (defun slime-lookup-shortcut (name)
12971295 (cl-find-if (lambda (s) (member name (slime-repl-shortcut.names s)))
13101308 ,(when elisp-name
13111309 `(defun ,elisp-name ()
13121310 (interactive)
1313 (call-interactively ,(second (assoc :handler options)))))
1311 (call-interactively ,(cl-second (assoc :handler options)))))
13141312 (let ((new-shortcut (make-slime-repl-shortcut
13151313 :symbol ',elisp-name
13161314 :names (list ,@names)
15161514 (let ((buffer (get-buffer-create (slime-buffer-name :trace))))
15171515 (with-current-buffer buffer
15181516 (let ((marker (copy-marker (buffer-size)))
1519 (target (incf slime-last-output-target-id)))
1517 (target (cl-incf slime-last-output-target-id)))
15201518 (puthash target marker slime-output-target-to-marker)
15211519 (slime-eval `(swank-repl:redirect-trace-output ,target))))
15221520 ;; Note: We would like the entries in
17161714 (error "Can't find suitable coding-system"))))
17171715
17181716 (defun slime-repl-connected-hook-function ()
1719 (destructuring-bind (package prompt)
1717 (cl-destructuring-bind (package prompt)
17201718 (let ((slime-current-thread t)
17211719 (cs (slime-repl-choose-coding-system)))
17221720 (slime-eval `(swank-repl:create-repl nil :coding-system ,cs)))
17311729 (slime-write-string output target)
17321730 t)
17331731 ((:read-string thread tag)
1734 (assert thread)
1732 (cl-assert thread)
17351733 (slime-repl-read-string thread tag)
17361734 t)
17371735 ((:read-aborted thread tag)
3030 (browse-url (format "http://bugs.launchpad.net/sbcl/+bug/%s"
3131 (substring bug 1))))
3232
33 (defun slime-indent-define-vop (path state indent-point sexp-column normal-indent)
34 (if (save-excursion
35 (backward-sexp)
36 (ignore-errors (down-list))
37 (looking-at ":generator"))
38 (+ sexp-column 2)
39 (lisp-indent-259 '((&whole 4) &body)
40 path state indent-point sexp-column normal-indent)))
41
42 (put 'define-vop 'common-lisp-indent-function
43 'slime-indent-define-vop)
44
3345 (provide 'slime-sbcl-exts)
0 ;;;; -*- lexical-binding: t -*-
1
02 (require 'slime)
13 (require 'cl-lib)
2 (eval-when-compile (require 'cl)) ; lexical-let*
34
45 (define-slime-contrib slime-sprof
56 "Integration with SBCL's sb-sprof."
138139 (delete-char 1)))))
139140
140141 (defun slime-sprof-browser-expand ()
141 (lexical-let* ((buffer (current-buffer))
142 (point (point))
143 (index (get-text-property point 'profile-index)))
142 (let* ((buffer (current-buffer))
143 (point (point))
144 (index (get-text-property point 'profile-index)))
144145 (slime-eval-async `(swank:swank-sprof-expand-node ,index)
145146 (lambda (data)
146147 (with-current-buffer buffer
147 (save-excursion
148 (destructuring-bind (&key callers calls)
148 (save-excursion
149 (cl-destructuring-bind (&key callers calls)
149150 data
150151 (slime-sprof-browser-add-expansion callers
151152 "Callers"
134134
135135 (define-minor-mode slime-trace-dialog-hide-details-mode
136136 "Hide details in `slime-trace-dialog-mode'"
137 nil " Brief"
137 :init-value nil
138 :lighter " Brief"
138139 :group 'slime-trace-dialog
139140 (unless (derived-mode-p 'slime-trace-dialog-mode)
140141 (error "Not a SLIME Trace Dialog buffer"))
142143
143144 (define-minor-mode slime-trace-dialog-autofollow-mode
144145 "Automatically open buffers with trace details from `slime-trace-dialog-mode'"
145 nil " Autofollow"
146 :init-value nil
147 :lighter " Autofollow"
146148 :group 'slime-trace-dialog
147149 (unless (derived-mode-p 'slime-trace-dialog-mode)
148150 (error "Not a SLIME Trace Dialog buffer")))
0 ;;;; -*- lexical-binding: t -*-
1
02 (require 'slime)
13 (require 'tramp)
2 (eval-when-compile (require 'cl)) ; lexical-let
34
45 (define-slime-contrib slime-tramp
56 "Filename translations for tramp"
9596 should login with.
9697 The functions created here expect your tramp-default-method or
9798 tramp-default-method-alist to be setup correctly."
98 (lexical-let ((remote-host (or remote-host machine-instance))
99 (username (or username (user-login-name))))
99 (let ((remote-host (or remote-host machine-instance))
100 (username (or username (user-login-name))))
100101 (list (concat "^" machine-instance "$")
101102 (lambda (emacs-filename)
102103 (tramp-file-name-localname
109110
110111 (defun slime-tramp-to-lisp-filename (filename)
111112 (funcall (if (slime-connected-p)
112 (first (slime-find-filename-translators (slime-machine-instance)))
113 (cl-first (slime-find-filename-translators (slime-machine-instance)))
113114 'identity)
114115 (expand-file-name filename)))
115116
116117 (defun slime-tramp-from-lisp-filename (filename)
117 (funcall (second (slime-find-filename-translators (slime-machine-instance)))
118 (funcall (cl-second (slime-find-filename-translators (slime-machine-instance)))
118119 filename))
119120
120121 (provide 'slime-tramp)
726726 (defmethod emacs-inspect ((package package))
727727 (let ((package-name (package-name package))
728728 (package-nicknames (package-nicknames package))
729 (local-nicknames (package-local-nicknames package))
729730 (package-use-list (package-use-list package))
730731 (package-used-by-list (package-used-by-list package))
731732 (shadowed-symbols (package-shadowing-symbols package))
762763 `("" ;; dummy to preserve indentation.
763764 "Name: " (:value ,package-name) (:newline)
764765
765 "Nick names: " ,@(common-seperated-spec package-nicknames) (:newline)
766 "Nicknames: " ,@(common-seperated-spec package-nicknames) (:newline)
767
768 ,@(when local-nicknames
769 `("Package-local nicknames: " (:value ,local-nicknames) (:newline)))
766770
767771 ,@(when (documentation package t)
768772 `("Documentation:" (:newline)
2323 ;; The arglist of INST is (instruction ...INSTR-ARGLIST...).
2424 (push 'sb-assem::instruction (arglist.required-args decoded-arglist))
2525 (values decoded-arglist
26 (list instr-name)
26 (list (string-downcase instr-name))
2727 t))))
2828 (if (null argument-forms)
2929 (call-next-method)
3434 (arglist-dummy
3535 (string-upcase (arglist-dummy.string-representation instruction)))
3636 (symbol
37 (string-downcase instruction))))
37 (string-upcase instruction))))
3838 (instr-fn
39 #+#.(swank/backend:with-symbol 'op-encoder-name 'sb-assem)
40 (or (sb-assem::op-encoder-name instr-name)
41 (sb-assem::op-encoder-name (string-upcase instr-name)))
42 #+#.(swank/backend:with-symbol 'inst-emitter-symbol 'sb-assem)
43 (sb-assem::inst-emitter-symbol instr-name)
4439 #+(and
45 (not #.(swank/backend:with-symbol 'inst-emitter-symbol 'sb-assem))
46 #.(swank/backend:with-symbol '*assem-instructions* 'sb-assem))
47 (gethash instr-name sb-assem:*assem-instructions*)))
40 #.(swank/backend:with-symbol '*inst-encoder* 'sb-assem)
41 #.(swank/backend:with-symbol '*backend-instruction-set-package* 'sb-assem))
42 (or (gethash (find-symbol instr-name sb-assem::*backend-instruction-set-package*)
43 sb-assem::*inst-encoder*)
44 (find-symbol (format nil "M:~A" instr-name)
45 sb-assem::*backend-instruction-set-package*))))
46 (when (consp instr-fn)
47 (setf instr-fn (car instr-fn)))
4848 (cond ((functionp instr-fn)
4949 (with-available-arglist (arglist) (arglist instr-fn)
50 (decode-instruction-arglist instr-name arglist)))
50 (decode-instruction-arglist instr-name (cdr arglist))))
5151 ((fboundp instr-fn)
5252 (with-available-arglist (arglist) (arglist instr-fn)
5353 ;; SB-ASSEM:INST invokes a symbolic INSTR-FN with
5656 (if (or (get instr-fn :macro)
5757 (macro-function instr-fn))
5858 arglist
59 (cddr arglist)))))
59 (cdr arglist)))))
6060 (t
6161 (call-next-method))))))))
6262
20102010 after the first one (default: @code{NIL}). For ``long-running'' lisp processes
20112011 to which you want to be able to connect from time to time,
20122012 specify @code{:dont-close t}
2013 @item :CODING-SYSTEM
2014 String designating the encoding to be used to communicate between the
2015 Emacs and Lisp.
20162013 @end table
20172014
20182015 So the more complete example will be
20192016 @example
2020 (swank:create-server :port 4005 :dont-close t :coding-system "utf-8-unix")
2017 (swank:create-server :port 4005 :dont-close t)
20212018 @end example
20222019 On the emacs side you will use something like
20232020 @example
136136 (forward-line)))
137137
138138 (defun common-lisp-hyperspec--parse-map-file (file)
139 (with-current-buffer (find-file-noselect file)
139 (with-temp-buffer
140 (insert-file-contents file)
140141 (goto-char (point-min))
141142 (let ((result '()))
142143 (while (< (point) (point-max))
13151316 "Function that creates a URL for a glossary term.")
13161317
13171318 (define-obsolete-variable-alias 'common-lisp-glossary-fun
1318 'common-lisp-hyperspec-glossary-function)
1319 'common-lisp-hyperspec-glossary-function "2015-12-29")
13191320
13201321 (defvar common-lisp-hyperspec--glossary-terms (make-hash-table :test #'equal)
13211322 "Collection of glossary terms and relative URLs.")
496496 quit and return to normal editing.
497497
498498 \\{macrostep-keymap}"
499 nil " Macro-Stepper"
499 :init-value nil
500 :lighter " Macro-Stepper"
500501 :keymap macrostep-keymap
501502 :group macrostep
502503 (if macrostep-mode
0 ;;; slime-tests.el --- Automated tests for slime.el
0 ;;; slime-tests.el --- Automated tests for slime.el -*- lexical-binding: t -*-
11 ;;
22 ;;;; License
33 ;; Copyright (C) 2003 Eric Marsden, Luke Gorrie, Helmut Eller
2929 (require 'ert "lib/ert" t) ;; look for bundled version for Emacs 23
3030 (require 'cl-lib)
3131 (require 'bytecomp) ; byte-compile-current-file
32 (eval-when-compile
33 (require 'cl)) ; lexical-let
3432
3533 (defun slime-shuffle-list (list)
3634 (let* ((len (length list))
5351 (slime-background-message-function #'ignore))
5452 (slime)
5553 ;; Block until we are up and running.
56 (lexical-let (timed-out)
54 (let (timed-out)
5755 (run-with-timer timeout nil
5856 (lambda () (setq timed-out t)))
5957 (while (not (slime-connected-p))
105103 (if (not (featurep 'ert))
106104 (warn "No ert.el found: not defining test %s"
107105 name)
108 (let* ((docstring (and (stringp (second args))
109 (second args)))
106 (let* ((docstring (and (stringp (cl-second args))
107 (cl-second args)))
110108 (args (if docstring
111109 (cddr args)
112110 (cdr args)))
115113 :tags ',tags
116114 ,@args))))
117115
118 (defun slime-test-ert-test-for (name input i doc body fails-for style fname)
116 (defun slime-test-ert-test-for (name input i doc _body fails-for style fname)
119117 `(define-slime-ert-test
120118 ,(intern (format "%s-%d" name i)) ()
121119 ,(format "For input %s, %s" (truncate-string-to-width
203201 (while (not (funcall predicate))
204202 (let ((now (current-time)))
205203 (message "waiting for condition: %s [%s.%06d]" name
206 (format-time-string "%H:%M:%S" now) (third now)))
204 (format-time-string "%H:%M:%S" now) (cl-third now)))
207205 (cond ((time-less-p end (current-time))
208206 (error "Timeout waiting for condition: %S" name))
209207 (t
271269
272270 (def-slime-test symbol-at-point.3 (sym)
273271 "fancy symbol-name with leading ,"
274 (remove-if (lambda (s) (eq (aref (car s) 0) ?@)) slime-test-symbols)
272 (cl-remove-if (lambda (s) (eq (aref (car s) 0) ?@)) slime-test-symbols)
275273 (slime-check-symbol-at-point "," sym ""))
276274
277275 (def-slime-test symbol-at-point.4 (sym)
740738 ;;(encode-coding-string (string #x304a #x306f #x3088 #x3046)
741739 ;; 'utf-8)
742740 (string (decode-coding-string bytes 'utf-8-unix)))
743 (assert (equal bytes (encode-coding-string string 'utf-8-unix)))
741 (cl-assert (equal bytes (encode-coding-string string 'utf-8-unix)))
744742 (list (concat "(defun cl-user::foo () \"" string "\")")
745743 string)))
746744 (slime-eval `(cl:eval (cl:read-from-string ,input)))
784782 (def-slime-test async-eval-debugging (depth)
785783 "Test recursive debugging of asynchronous evaluation requests."
786784 '((1) (2) (3))
787 (lexical-let ((depth depth)
788 (debug-hook-max-depth 0))
785 (let ((depth depth)
786 (debug-hook-max-depth 0))
789787 (let ((debug-hook
790788 (lambda ()
791789 (with-current-buffer (sldb-get-default-buffer)
808806 "Test recursive debugging and returning to lower SLDB levels."
809807 '((2 1) (4 2))
810808 (slime-check-top-level)
811 (lexical-let ((level2 level2)
812 (level1 level1)
813 (state 'enter)
814 (max-depth 0))
809 (let ((level2 level2)
810 (level1 level1)
811 (state 'enter)
812 (max-depth 0))
815813 (let ((debug-hook
816814 (lambda ()
817815 (with-current-buffer (sldb-get-default-buffer)
818816 (setq max-depth (max sldb-level max-depth))
819 (ecase state
817 (cl-ecase state
820818 (enter
821819 (cond ((= sldb-level level2)
822820 (setq state 'leave)
886884 "Test interactive eval and continuing from the debugger."
887885 '(())
888886 (slime-check-top-level)
889 (lexical-let ((done nil))
887 (let ((done nil))
890888 (let ((sldb-hook (lambda () (sldb-continue) (setq done t))))
891889 (slime-interactive-eval
892890 "(progn\
909907 ("~a" "(let ((x (cons (make-string 100000 :initial-element #\\X) nil)))\
910908 (setf (cdr x) x))"))
911909 (slime-check-top-level)
912 (lexical-let ((done nil))
910 (let ((done nil))
913911 (let ((sldb-hook (lambda () (sldb-continue) (setq done t))))
914912 (slime-interactive-eval
915913 (format "(with-standard-io-syntax (cerror \"foo\" \"%s\" %s) (+ 1 2))"
10811079 buffer-content
10821080 (substring-no-properties (buffer-string)))))
10831081
1082 (def-slime-test indentation.2 (buffer-content point-markers)
1083 "Check indentation update to work correctly."
1084 '(("
1085 \(in-package :swank)
1086
1087 \(defmacro lolipop (&body body)
1088 `(progn ,@body))
1089
1090 \(defmacro lolipop (&rest body)
1091 `(progn ,@body))
1092
1093 \(lolipop 1
1094 2
1095 23)
1096 "
1097 ("23")))
1098 (with-temp-buffer
1099 (lisp-mode)
1100 (slime-lisp-mode-hook)
1101 (insert buffer-content)
1102 (slime-compile-region (point-min) (point-max))
1103 (slime-sync-to-top-level 3)
1104 (slime-update-indentation)
1105 (slime-sync-to-top-level 3)
1106 (dolist (marker point-markers)
1107 (search-backward marker)
1108 (beginning-of-defun)
1109 (indent-sexp))
1110 (slime-test-expect "Correct buffer content"
1111 buffer-content
1112 (substring-no-properties (buffer-string)))))
1113
10841114 (def-slime-test break
10851115 (times exp)
10861116 "Test whether BREAK invokes SLDB."
12781308 (with-current-buffer (process-buffer p)
12791309 (erase-buffer))
12801310 (delete-process c)
1281 (assert (equal (process-status c) 'closed) nil "Connection not closed")
1311 (cl-assert (equal (process-status c) 'closed) nil "Connection not closed")
12821312 (accept-process-output nil 0.1)
1283 (assert (equal (process-status p) 'run) nil "Subprocess not running")
1313 (cl-assert (equal (process-status p) 'run) nil "Subprocess not running")
12841314 (with-current-buffer (process-buffer p)
1285 (assert (< (buffer-size) 500) nil "Unusual output"))
1315 (cl-assert (< (buffer-size) 500) nil "Unusual output"))
12861316 (slime-inferior-connect p (slime-inferior-lisp-args p))
1287 (lexical-let ((hook nil) (p p))
1317 (let ((hook nil) (p p))
12881318 (setq hook (lambda ()
12891319 (slime-test-expect
12901320 "We are connected again" p (slime-inferior-process))
13041334 (let ((success nil)
13051335 (test-file (make-temp-file "slime-recipe-" nil ".el"))
13061336 (test-forms
1307 `((require 'cl)
1308 (labels
1337 `((require 'cl-lib)
1338 (cl-labels
13091339 ((die
13101340 (reason &optional more)
13111341 (princ reason)
13701400 (setq slime-contribs '(slime-fancy)))
13711401 :takeoff `((call-interactively 'slime))
13721402 :landing `((unless (and (featurep 'slime-repl)
1373 (find 'swank-repl slime-required-modules))
1403 (cl-find 'swank-repl slime-required-modules))
13741404 (die "slime-repl not loaded properly"))
13751405 (with-current-buffer (slime-repl-buffer)
13761406 (unless (and (string-match "^; +SLIME" (buffer-string))
13881418 (slime-setup '(slime-fancy)))
13891419 :takeoff `((call-interactively 'slime))
13901420 :landing `((unless (and (featurep 'slime-repl)
1391 (find 'swank-repl slime-required-modules))
1421 (cl-find 'swank-repl slime-required-modules))
13921422 (die "slime-repl not loaded properly"))
13931423 (with-current-buffer (slime-repl-buffer)
13941424 (unless (and (string-match "^; +SLIME" (buffer-string))
14101440 (die "Expected SLIME to be fully loaded by now")))))
14111441
14121442 (defun slime-test-eval-now (string)
1413 (second (slime-eval `(swank:eval-and-grab-output ,string))))
1443 (cl-second (slime-eval `(swank:eval-and-grab-output ,string))))
14141444
14151445 (def-slime-test (slime-recompile-all-xrefs (:fails-for "cmucl")) ()
14161446 "Test recompilation of all references within an xref buffer."
22 ;; URL: https://github.com/slime/slime
33 ;; Package-Requires: ((cl-lib "0.5") (macrostep "0.9"))
44 ;; Keywords: languages, lisp, slime
5 ;; Version: 2.26.1
5 ;; Version: 2.27
66
77 ;;;; License and Commentary
88
6262 ;; For emacs 23, look for bundled version
6363 (require 'cl-lib "lib/cl-lib"))
6464
65 (eval-when-compile (require 'cl)) ; defsetf, lexical-let
66
6765 (eval-and-compile
6866 (if (< emacs-major-version 23)
6967 (error "Slime requires an Emacs version of 23, or above")))
7775 (require 'arc-mode)
7876 (require 'etags)
7977 (require 'compile)
78 (require 'gv)
8079
8180 (eval-when-compile
8281 (require 'apropos)
672671 (define-minor-mode slime-editing-mode
673672 "Minor mode which makes slime-editing-map available.
674673 \\{slime-editing-map}"
675 nil
676 nil
677 slime-editing-map)
674 :init-value nil
675 :lighter nil
676 :keymap slime-editing-map)
678677
679678
680679 ;;;; Framework'ey bits
858857 (list (previous-single-char-property-change end prop) end)))
859858
860859 (defun slime-curry (fun &rest args)
861 "Partially apply FUN to ARGS. The result is a new function.
862 This idiom is preferred over `lexical-let'."
860 "Partially apply FUN to ARGS. The result is a new function."
863861 `(lambda (&rest more) (apply ',fun (append ',args more))))
864862
865863 (defun slime-rcurry (fun &rest args)
920918
921919 (define-minor-mode slime-popup-buffer-mode
922920 "Mode for displaying read only stuff"
923 nil nil nil
921 :init-value nil
922 :lighter nil
923 :keymap nil
924924 (setq buffer-read-only t))
925925
926926 (add-to-list 'minor-mode-alist
17761776 (defun ,varname (&optional process)
17771777 (slime-with-connection-buffer (process) ,real-var))
17781778 ;; Setf
1779 (defsetf ,varname (&optional process) (store)
1779 (gv-define-setter ,varname (store &optional process)
17801780 `(slime-with-connection-buffer (,process)
17811781 (setq (\, (quote (\, real-var))) (\, store))))
17821782 '(\, varname))))
20392039 versions cannot deal with that."
20402040 (declare (indent 2))
20412041 (let ((result (cl-gensym)))
2042 `(lexical-let ,(cl-loop for var in saved-vars
2043 collect (cl-etypecase var
2044 (symbol (list var var))
2045 (cons var)))
2042 `(let ,(cl-loop for var in saved-vars
2043 collect (cl-etypecase var
2044 (symbol (list var var))
2045 (cons var)))
20462046 (slime-dispatch-event
20472047 (list :emacs-rex ,sexp ,package ,thread
20482048 (lambda (,result)
36353635 "History list of expressions read from the minibuffer.")
36363636
36373637 (defun slime-minibuffer-setup-hook ()
3638 (cons (lexical-let ((package (slime-current-package))
3639 (connection (slime-connection)))
3638 (cons (let ((package (slime-current-package))
3639 (connection (slime-connection)))
36403640 (lambda ()
36413641 (setq slime-buffer-package package)
36423642 (setq slime-buffer-connection connection)
41604160 in Lisp when committed with \\[slime-edit-value-commit]."
41614161 (interactive
41624162 (list (slime-read-from-minibuffer "Edit value (evaluated): "
4163 (slime-sexp-at-point))))
4163 (slime-sexp-at-point))))
41644164 (slime-eval-async `(swank:value-for-editing ,form-string)
4165 (lexical-let ((form-string form-string)
4166 (package (slime-current-package)))
4165 (let ((form-string form-string)
4166 (package (slime-current-package)))
41674167 (lambda (result)
41684168 (slime-edit-value-callback form-string result
41694169 package)))))
41744174
41754175 (define-minor-mode slime-edit-value-mode
41764176 "Mode for editing a Lisp value."
4177 nil
4178 " Edit-Value"
4179 '(("\C-c\C-c" . slime-edit-value-commit)))
4177 :init-value nil
4178 :lighter " Edit-Value"
4179 :keymap '(("\C-c\C-c" . slime-edit-value-commit)))
41804180
41814181 (defun slime-edit-value-callback (form-string current-value package)
41824182 (let* ((name (generate-new-buffer-name (format "*Edit %s*" form-string)))
42014201 (if (null slime-edit-form-string)
42024202 (error "Not editing a value.")
42034203 (let ((value (buffer-substring-no-properties (point-min) (point-max))))
4204 (lexical-let ((buffer (current-buffer)))
4204 (let ((buffer (current-buffer)))
42054205 (slime-eval-async `(swank:commit-edited-value ,slime-edit-form-string
42064206 ,value)
42074207 (lambda (_)
48574857
48584858 (define-minor-mode slime-macroexpansion-minor-mode
48594859 "SLIME mode for macroexpansion"
4860 nil
4861 " Macroexpand"
4862 '(("g" . slime-macroexpand-again)))
4860 :init-value nil
4861 :lighter " Macroexpand"
4862 :keymap '(("g" . slime-macroexpand-again)))
48634863
48644864 (cl-macrolet ((remap (from to)
48654865 `(dolist (mapping
49304930 (interactive)
49314931 (let* ((bounds (or (slime-bounds-of-sexp-at-point)
49324932 (user-error "No sexp at point"))))
4933 (lexical-let* ((start (copy-marker (car bounds)))
4934 (end (copy-marker (cdr bounds)))
4935 (point (point))
4936 (package (slime-current-package))
4937 (buffer (current-buffer)))
4933 (let* ((start (copy-marker (car bounds)))
4934 (end (copy-marker (cdr bounds)))
4935 (point (point))
4936 (buffer (current-buffer)))
49384937 (slime-eval-async
49394938 `(,expander ,(buffer-substring-no-properties start end))
49404939 (lambda (expansion)
53425341 (dolist (window (window-list))
53435342 (when (window-parameter window 'sldb-last-window)
53445343 (set-window-parameter window 'sldb-last-window nil)))
5345 (set-window-parameter (selected-window) 'sldb-last-window t))
5344 (set-window-parameter window 'sldb-last-window t))
53465345
53475346 (defun sldb-exit (thread _level &optional stepping)
53485347 "Exit from the debug level LEVEL."
60736072 (interactive "P")
60746073 (slime-eval-async
60756074 `(swank:frame-source-location ,(sldb-frame-number-at-point))
6076 (lexical-let ((policy (slime-compute-policy raw-prefix-arg)))
6075 (let ((policy (slime-compute-policy raw-prefix-arg)))
60776076 (lambda (source-location)
60786077 (slime-dcase source-location
60796078 ((:error message)
64966495 2. If point is on an action then call that action.
64976496 3. If point is on a range-button fetch and insert the range."
64986497 (interactive)
6499 (let ((opener (lexical-let ((point (slime-inspector-position)))
6498 (let ((opener (let ((point (slime-inspector-position)))
65006499 (lambda (parts)
65016500 (when parts
65026501 (slime-open-inspector parts point)))))
66466645 (defun slime-inspector-reinspect ()
66476646 (interactive)
66486647 (slime-eval-async `(swank:inspector-reinspect)
6649 (lexical-let ((point (slime-inspector-position)))
6648 (let ((point (slime-inspector-position)))
66506649 (lambda (parts)
66516650 (slime-open-inspector parts point)))))
66526651
66536652 (defun slime-inspector-toggle-verbose ()
66546653 (interactive)
66556654 (slime-eval-async `(swank:inspector-toggle-verbose)
6656 (lexical-let ((point (slime-inspector-position)))
6655 (let ((point (slime-inspector-position)))
66576656 (lambda (parts)
66586657 (slime-open-inspector parts point)))))
66596658
74417440 (:and #'cl-every)
74427441 (:or #'cl-some)
74437442 (:not
7444 (lexical-let ((feature-expression e))
7443 (let ((feature-expression e))
74457444 (lambda (f l)
74467445 (cond
74477446 ((slime-length= l 0) t)
76177616 (defun slime--compile-hotspots ()
76187617 (mapc (lambda (sym)
76197618 (cond ((fboundp sym)
7620 (unless (byte-code-function-p (symbol-function sym))
7619 (unless (or (byte-code-function-p (symbol-function sym))
7620 (subrp (symbol-function sym)))
76217621 (slime--byte-compile sym)))
76227622 (t (error "%S is not fbound" sym))))
76237623 '(slime-alistify
475475 (backtrace start end)))
476476
477477 ;; Don't count on JSS being loaded, but if it is then there's some more stuff we can do
478 +#+#.(swank/backend:with-symbol 'invoke-restargs 'jss)
478 #+#.(swank/backend:with-symbol 'invoke-restargs 'jss)
479479 (defun jss-p ()
480480 (and (member "JSS" *modules* :test 'string=) (intern "INVOKE-RESTARGS" "JSS")))
481481
482 +#+#.(swank/backend:with-symbol 'invoke-restargs 'jss)
482 #+#.(swank/backend:with-symbol 'invoke-restargs 'jss)
483483 (defun matches-jss-call (form)
484484 (flet ((gensymp (s) (and (symbolp s) (null (symbol-package s))))
485485 (invokep (s) (and (symbolp s) (eq s (jss-p)))))
10041004 (when (atom what)
10051005 (setq what (list what sym)))
10061006 (list (definition-specifier what)
1007 (if (ext:pathname-jar-p path2)
1007 (if (ext:pathname-jar-p (pathname path2))
10081008 `(:location
10091009 (:zip ,@(split-string (subseq path2 (length "jar:file:")) "!/"))
10101010 ;; pos never seems right. Use function name.
13661366 `(" " (:label ,(string-downcase (string name))) ": " (:value ,value) (:newline))))
13671367 `("No slots available for inspection."))))
13681368
1369 #+#.(swank/backend:with-symbol 'get-java-field 'jss)
13691370 (defmethod emacs-inspect ((object sys::structure-class))
13701371 (let* ((name (jss::get-java-field object "name" t))
13711372 (def (get name 'system::structure-definition)))
106106 ;;;; Misc
107107
108108 (defimplementation arglist (symbol)
109 (handler-case (excl:arglist symbol)
109 (handler-case
110 (let ((lambda-expression (ignore-errors
111 (function-lambda-expression
112 (symbol-function symbol)))))
113 ;; LAMBDA-EXPRESSION, if available, has the default values of
114 ;; optional and keyword arguments of compiled functions while
115 ;; EXCL:ARGLIST doesn't.
116 (if lambda-expression
117 (second lambda-expression)
118 (excl:arglist symbol)))
110119 (simple-error () :not-available)))
111120
112121 (defimplementation macroexpand-all (form &optional env)
10831092
10841093 (defimplementation wrapped-p (spec indicator)
10851094 (getf (excl:fwrap-order (process-fspec-for-allegro spec)) indicator))
1095
1096 ;;;; Packages
1097
1098 #+package-local-nicknames
1099 (defimplementation package-local-nicknames (package)
1100 (excl:package-local-nicknames package))
588588 (method (ccl:name-of object))
589589 (t (list (ccl:definition-type-name type) (ccl:name-of object)))))
590590
591 ;;; Packages
592
593 #+package-local-nicknames
594 (defimplementation package-local-nicknames (package)
595 (ccl:package-local-nicknames package))
596
591597 ;;; Utilities
592598
593599 (defimplementation describe-symbol-for-emacs (symbol)
6262 :type :stream
6363 :protocol :tcp)))
6464 (setf (sb-bsd-sockets:sockopt-reuse-address socket) t)
65 (sb-bsd-sockets:socket-bind socket (resolve-hostname host) port)
65 (handler-bind
66 ((SB-BSD-SOCKETS:ADDRESS-IN-USE-ERROR (lambda (err)
67 (declare (ignore err))
68 (invoke-restart 'use-value))))
69 (sb-bsd-sockets:socket-bind socket (resolve-hostname host) port))
6670 (sb-bsd-sockets:socket-listen socket (or backlog 5))
6771 socket))
6872
165169 (namestring (ext:getcwd)))
166170
167171 (defimplementation quit-lisp ()
168 (core:quit))
172 (sys:quit))
169173
170174
171175
223227 (reader-error :read-error)
224228 (error :error)))
225229
230 (defun %condition-location (origin)
231 ;; NOTE: If we're compiling in a buffer, the origin
232 ;; will already be set up with the offset correctly
233 ;; due to the :source-debug parameters from
234 ;; swank-compile-string (below).
235 (make-file-location
236 (sys:file-scope-pathname
237 (sys:file-scope origin))
238 (sys:source-pos-info-filepos origin)))
239
226240 (defun condition-location (origin)
227 (if (null origin)
228 (make-error-location "No error location available")
229 ;; NOTE: If we're compiling in a buffer, the origin
230 ;; will already be set up with the offset correctly
231 ;; due to the :source-debug parameters from
232 ;; swank-compile-string (below).
233 (make-file-location
234 (core:file-scope-pathname
235 (core:file-scope origin))
236 (core:source-pos-info-filepos origin))))
241 (typecase origin
242 (null (make-error-location "No error location available"))
243 (cons (%condition-location (car origin)))
244 (t (%condition-location origin))))
237245
238246 (defun signal-compiler-condition (condition origin)
239247 (signal 'compiler-condition
316324
317325 (defimplementation arglist (name)
318326 (multiple-value-bind (arglist foundp)
319 (core:function-lambda-list name) ;; Uses bc-split
327 (sys:function-lambda-list name) ;; Uses bc-split
320328 (if foundp arglist :not-available)))
321329
322330 (defimplementation function-name (f)
345353 nil)
346354 ((macro-function (car form) environment)
347355 (push form macro-forms))
348 ((not (eq form (core:compiler-macroexpand-1 form environment)))
356 ((not (eq form (sys:compiler-macroexpand-1 form environment)))
349357 (push form compiler-macro-forms))))
350358 form)
351359 form environment)
697705 (slime-dbg "receive-if condition-variable-timedwait")
698706 (mp:condition-variable-wait (mailbox.cvar mbox) mutex) ; timedwait 0.2
699707 (slime-dbg "came out of condition-variable-timedwait")
700 (core:check-pending-interrupts)))))
708 (sys:check-pending-interrupts)))))
701709
702710 ) ; #+threads (progn ...
703711
704712
705 (defmethod emacs-inspect ((object core:cxx-object))
706 (let ((encoded (core:encode object)))
713 (defmethod emacs-inspect ((object sys:cxx-object))
714 (let ((encoded (sys:encode object)))
707715 (loop for (key . value) in encoded
708716 append (list (string key) ": " (list :value value) (list :newline)))))
709717
710 (defmethod emacs-inspect ((object core:va-list))
711 (emacs-inspect (core:list-from-va-list object)))
718 (defmethod emacs-inspect ((object sys:vaslist))
719 (emacs-inspect (sys:list-from-vaslist object)))
720
721 ;;; Packages
722
723 #+package-local-nicknames
724 (defimplementation package-local-nicknames (package)
725 (ext:package-local-nicknames package))
250250
251251 ;;;; Swank functions
252252
253 (defimplementation function-name (f)
254 (check-type f function)
255 (system::function-name f))
256
253257 (defimplementation arglist (fname)
254258 (block nil
255259 (or (ignore-errors
256 (let ((exp (function-lambda-expression fname)))
257 (and exp (return (second exp)))))
260 (return (ext:arglist fname)))
261 ;; For traced functions this returns the entire encapsulating
262 ;; lambda.
258263 (ignore-errors
259 (return (ext:arglist fname)))
264 (let ((exp (function-lambda-expression fname)))
265 (and exp (return (second exp)))))
260266 :not-available)))
261267
262268 (defimplementation macroexpand-all (form &optional env)
2626 stream-unread-char
2727 stream-clear-input
2828 stream-line-column
29 stream-read-char-no-hang))
29 stream-read-char-no-hang
30
31 #+sbcl stream-file-position))
3032 nil)
3133
3234 (defpackage swank/gray
128130 (cond ((zerop column) nil)
129131 (t (terpri stream) t))))
130132
133 #+sbcl
134 (defmethod stream-file-position ((stream slime-output-stream) &optional position)
135 (declare (ignore position))
136 nil)
137
131138 (defclass slime-input-stream (fundamental-character-input-stream)
132139 ((input-fn :initarg :input-fn)
133140 (buffer :initform "") (index :initform 0)
188195 (when (< index (length buffer))
189196 (prog1 (aref buffer index) (incf index)))))))
190197
198 #+sbcl
199 (defmethod stream-file-position ((stream slime-input-stream) &optional position)
200 (declare (ignore position))
201 nil)
202
191203
192204 ;;;
193205
10171017
10181018 (defimplementation make-weak-value-hash-table (&rest args)
10191019 (apply #'make-hash-table :weak-kind :value args))
1020
1021 ;;;; Packages
1022
1023 #+package-local-nicknames
1024 (defimplementation package-local-nicknames (package)
1025 (hcl:package-local-nicknames package))
21602160 (*print-pretty* t)
21612161 (*print-right-margin* 65)
21622162 (*print-circle* t)
2163 (*print-length* (or *print-length* limit))
2164 (*print-level* (or *print-level* limit))
2163 (*print-length* (or *print-length* 64))
2164 (*print-level* (or *print-level* 6))
21652165 (*print-lines* (or *print-lines* limit)))
21662166 (print-condition condition stream))
21672167 (serious-condition (c)
22832283 (invoke-restart (find 'abort *sldb-restarts* :key #'restart-name)))
22842284
22852285 (defslimefun sldb-continue ()
2286 (continue))
2286 (invoke-restart (find 'continue *sldb-restarts* :key #'restart-name)))
22872287
22882288 (defun coerce-to-condition (datum args)
22892289 (etypecase datum
36403640 (let ((alist '()))
36413641 (flet ((consider (symbol)
36423642 (let ((indent (symbol-indentation symbol)))
3643 (when indent
3643 (when (or indent (gethash symbol cache))
36443644 (unless (equal (gethash symbol cache) indent)
36453645 (setf (gethash symbol cache) indent)
36463646 (let ((pkgs (mapcar #'package-name