Giter VIP home page Giter VIP logo

sly-asdf's Introduction

MELPA ci License: GPL v3

About

SLY-ASDF is a contrib for SLY that adds support for editing ASDF systems, exposing several utilities for working with and loading systems. When using the built-in system load utlity, accessed via , + load-system from the repl, ASDF system compilation and load errors will be trapped and recorded as with other sly compilation errors, as opposed to dumping into the debugger like with calling asdf:load-system directly.

Ported from slime with changes to support package-inferred-system. Potentially I'd like to make some future changes to improve debugging ASDF systems (e.g., cut off stack trace at system boundaries, etc.)

Installation

Now available from MELPA

Installing manually will require the contrib be registered in SLY's sly-contrib variable.

(add-to-list 'sly-contribs 'sly-asdf 'append)

sly-asdf's People

Contributors

zulu-inuoe avatar fade avatar olce2 avatar ambrevar avatar uthar avatar ruricolist avatar zellerin avatar

Stargazers

 avatar Tiger avatar  avatar  avatar kilokon avatar Joel Boehland avatar Bastien Rivière avatar Jorge Gomez avatar  avatar Jason Robinson avatar Lisp student avatar Thomas Jacob Trabue avatar Valeriy Litkovskyy avatar Cameron Chaparro avatar Chip Koziara avatar Santiago Payà Miralta avatar Jonathan McHugh avatar Andrea Richiardi avatar  avatar  avatar João Távora avatar  avatar

Watchers

James Cloos avatar  avatar Matt George avatar

sly-asdf's Issues

`sly-asdf-isearch-system` does not work as intended

The function sly-asdf-isearch-system is currently not working. It locally binds multi-isearch-next-buffer-function but calls isearch instead of multi-isearch afterwards. Moreover, and as far as I can tell, the function could use the following definition:

(defun sly-asdf-isearch-system (sys-name)
      "Run function `multi-isearch-files' on the files of an ASDF system SYS-NAME."
      (interactive (list (sly-asdf-read-system-name nil nil)))
      (let ((files (mapcar 'sly-from-lisp-filename
                           (sly-eval `(slynk-asdf:asdf-system-files ,sys-name)))))
        (multi-isearch-files files)))

Unless I am mistaken, the current code is somewhat re-implementing a built-in function.

Fails to load with ECL

Hi, it fails to load with ECL on my machine. I think the problem is asdf/parse-defsystem:bad-system-name which is not present in ECL's asdf.

Because with this patch xFA25E@0c85447 , it seems working to me.

I don't know the codebase very well, so I'm afraid that this patch might break things. What do you think? Thanks!

Byte-compile warnings


Compiling file c:/Users/JenChieh/AppData/Roaming/.emacs.d/elpa/sly-asdf-20221119.2235/sly-asdf-flymake-base.el at Sun Apr  7 01:19:19 2024
Entering directory ‘c:/Users/JenChieh/AppData/Roaming/.emacs.d/elpa/sly-asdf-20221119.2235/’
sly-asdf-flymake-base.el:66:2: Warning: custom-declare-variable
    `sly-asdf-flymake-base-error-bitmap' docstring wider than 80 characters
sly-asdf-flymake-base.el:81:2: Warning: custom-declare-variable
    `sly-asdf-flymake-base-warning-bitmap' docstring wider than 80 characters
sly-asdf-flymake-base.el:95:2: Warning: custom-declare-variable
    `sly-asdf-flymake-base-note-bitmap' docstring wider than 80 characters
sly-asdf-flymake-base.el:109:2: Warning: custom-declare-variable
    `sly-asdf-flymake-base-fringe-indicator-position' docstring wider than 80
    characters
sly-asdf-flymake-base.el:361:2: Warning: defvar
    `sly-asdf-flymake-base-diagnostic-functions' docstring wider than 80
    characters

In sly-asdf-flymake-base-mode:
sly-asdf-flymake-base.el:800:2: Warning: docstring wider than 80 characters

Compiling file c:/Users/JenChieh/AppData/Roaming/.emacs.d/elpa/sly-asdf-20221119.2235/sly-asdf-flymake.el at Sun Apr  7 01:19:19 2024

In sly-asdf-flymake--handle-report:
sly-asdf-flymake.el:138:11: Warning: Unused lexical variable `first-report'

In sly-asdf-flymake-backend:
sly-asdf-flymake.el:195:2: Warning: docstring wider than 80 characters

In sly-asdf--flymake-highlight-around-hook:
sly-asdf-flymake.el:284:2: Warning: docstring wider than 80 characters

In end of data:
sly-asdf-flymake.el:69:25: Warning: the function
    ‘sly-asdf-find-current-system’ is not known to be defined.
sly-asdf-flymake.el:57:28: Warning: the function
    ‘sly-asdf--current-lisp-buffers’ is not known to be defined.

Compiling file c:/Users/JenChieh/AppData/Roaming/.emacs.d/elpa/sly-asdf-20221119.2235/sly-asdf.el at Sun Apr  7 01:19:28 2024
sly-asdf.el:38:2: Warning: defvar `sly-asdf-find-system-file-max-depth'
    docstring wider than 80 characters

In sly-asdf--current-lisp-buffers:
sly-asdf.el:72:2: Warning: docstring wider than 80 characters

In sly-asdf-query-replace-system-and-dependents:
sly-asdf.el:208:2: Warning: docstring wider than 80 characters

In sly-asdf-find-system-file:
sly-asdf.el:307:2: Warning: docstring wider than 80 characters

In sly-asdf-determine-asdf-system:
sly-asdf.el:318:2: Warning: docstring wider than 80 characters

Compiling internal form(s) at Sun Apr  7 01:19:50 2024

Cleanup flymake integration

Currently this is pretty hacked to make it system aware. This should be refactored to just pull out the parts we need

New release

Could we please have a new release? It has been a while since 2019. Thank you.

`sly-asdf-load-system` doesn't trigger the debugger

I've noticed that issuing (asdf:load-system :foo) in the sly REPL isn't equivalent to issuing (sly-asdf-load-system :foo) since the latter doesn't trigger the debugger on compilation errors.

Am I missing something? Can I configure it? @Ambrevar

Output on (asdf:load-system :foo)

CL-USER> (asdf:load-system :nyxt/gi-gtk)
; compiling file "/home/aadcg/common-lisp/nyxt/source/configuration.lisp" (written 01 NOV 2022 01:07:59 PM):
; 
; caught ERROR:
;   READ error during COMPILE-FILE:
;   
;     The symbol "*DEST-SOURCE-DIR*" is not external in the NYXT-ASDF package.
;   
;       Line: 97, Column: 35, File-Position: 3807
;   
;       Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /home/aadcg/common-lisp/nyxt/source/configuration.lisp" {100ABE2F63}>

; compilation aborted after 0:00:00.040
; Debugger entered on #<UIOP/LISP-BUILD:COMPILE-FILE-ERROR {100B47D433}>

Output on (sly-asdf-load-system :foo)

; 
; compilation unit aborted
;   caught 2 fatal ERROR conditions
;   caught 1 ERROR condition

; Evaluation aborted on #<UIOP/LISP-BUILD:COMPILE-FILE-ERROR {100B47D433}>
; compiling file "/home/aadcg/common-lisp/nyxt/source/configuration.lisp" (written 01 NOV 2022 01:07:59 PM):
; compilation aborted after 0:00:00.040
; 
; compilation unit aborted
;   caught 2 fatal ERROR conditions

Duplicate items in sly-asdf-system-history

I noticed that when calling load-system et al, I get many repeated, duplicate entries for my input history.

eg (as seen by helm):
image

I think it would make more sense to instead remove duplicates from this list instead.
Adding

(delete-dups sly-asdf-system-history)

right before calling completing-read seems to do the trick, but I don't know if this is idiomatic elisp.

Add test-coverage

Currently tests pretty nonexistent. At the bare minimum, we need tests for slynk-asdf, esp. for earlier versions of ASDF/SBCL. Emacs tests would be great too, need to look into what the typical patterns are there.

  • Load/compilation test with checks for undefined in compilation output
  • Expand load/compilation tests to multiple versions of SBCL
  • Add slynk-asdf unit tests
  • Add sly-asdf unit tests

Misleading errors if file fails to compile

Hello!

I noticed that if I load a system through sly-asdf, then if a file fails to compile properly, it continues loading the rest of the system.

This can lead to a top of misleading errors arising from failing to load a file you depend on.
For example:

with foo.asd:

(defsystem #:foo
  :serial t
  :components
  ((:file "foo")
   (:file "bar")))

a foo.lisp:

(defpackage #:foo
  (:use #:cl)
  (:export #:foo))
(in-package #:foo)

(defun foo ()
  t)
(defun foo ()
  nil)

and bar.lisp:

(defpackage #:bar
  (:use #:cl))
(in-package #:bar)

(foo:foo)

loading the system from sly-asdf's load-system results in these compiler notes:

cd c:/Users/zulu/common-lisp/foo/
3 compiler notes:

bar.lisp:1:1:
  error: The function FOO:FOO is undefined.

foo.lisp:1:1:
  error: 
    Couldn't load
    #P"C:/Users/zulu/AppData/Local/cache/common-lisp/sbcl-1.5.8-win-x64/C/Users/zulu/common-lisp/foo/foo.fasl":
    file does not exist.

foo.lisp:10:1:
  warning: 
    Duplicate definition for FOO found in one file.
    --> PROGN 
    ==>
      (EVAL-WHEN (:COMPILE-TOPLEVEL) (SB-C:%COMPILER-DEFUN 'FOO:FOO T NIL NIL))
    

Compilation failed.

So it looks like it:

  1. Is trying to load foo.fasl, even though compiling foo.lisp failed
  2. Trying to load bar.lisp, even though compiling/loading foo failed

I would instead expect the compilation log to look like this:

cd c:/Users/zulu/common-lisp/foo/
1 compiler notes:

foo.lisp:10:1:
  warning: 
    Duplicate definition for FOO found in one file.
    --> PROGN 
    ==>
      (EVAL-WHEN (:COMPILE-TOPLEVEL) (SB-C:%COMPILER-DEFUN 'FOO:FOO T NIL NIL))
    

Compilation failed.

Depropertize the system

With ws-butler, ,load-system RET whatever crashes the Lisp.

Simple fix:

(defun sly-asdf-read-system-name (&optional prompt default-value)
  "Read a system name from the minibuffer, prompting with PROMPT.
If no DEFAULT-VALUE is given, one is tried to be determined: if
DETERMINE-DEFAULT-ACCURATELY is true, by an RPC request which
grovels through all defined systems; if it's not true, by looking
in the directory of the current buffer."
  (let* ((completion-ignore-case nil)
         (prompt (or prompt "System"))
         (system-names (sly-eval `(slynk-asdf:list-asdf-systems)))
         (default-value
           (or default-value (sly-asdf-find-current-system) (car sly-asdf-system-history)))
         (prompt (concat prompt (if default-value
                                    (format " (default `%s'): " default-value)
                                  ": "))))
    (let ((history-delete-duplicates t)
          (result (completing-read prompt (sly-asdf-bogus-completion-alist system-names)
                                   nil nil nil
                                   'sly-asdf-system-history default-value)))
      (when result 
        (substring-no-properties result)))))

Fixes joaotavora/sly#311.

See also joaotavora/sly#370 for a more general fix, but I guess this patch can't do any harm.

Fails to load with CCL 1.12-dev.5

I get this error:

There is no package named "SB-INT" .
   [Condition of type CCL::NO-SUCH-PACKAGE]

Restarts:
 0: [CONTINUE] Retry finding package with name "SB-INT".
 1: [USE-VALUE] Find specified package instead of "SB-INT" .
 2: [MAKE-NICKNAME] Make "SB-INT" be a nickname for package "SLYNK-ASDF".
 3: [RETRY-COMPILE-FILE] Retry compiling #P"/gnu/store/9n45xls8ggjcv9l2aapicnbkibypzmqf-emacs-sly-asdf-0.1.0-3.ad24805/share/emacs/site-lisp/slynk-asdf.lisp"
 4: [SKIP-COMPILE-FILE] Skip compiling #P"/gnu/store/9n45xls8ggjcv9l2aapicnbkibypzmqf-emacs-sly-asdf-0.1.0-3.ad24805/share/emacs/site-lisp/slynk-asdf.lisp"
 5: [RETRY] Retry compiling #<CL-SOURCE-FILE "slynk-asdf" "slynk-asdf">.

I guess the easy fix is to add #+sbcl before the breakpoint defuns.

Don't force-compile systems

When systems are installed in a read-only location (like in Guix and maybe in Nix), sly-asdf-load-system and sly-asdf-reload-system will fail, complaining they cannot write the .fasl.

I suggest disabling :force t by default, only forcing the build if, say, the prefix argument is used.

Logical pathnames are not translated

Reporting warnings and errors when compiling logical pathnames results in the *sly-compilation* buffer listing the logical pathnames (e.g. SYS:SRC;foo.lisp) instead of the physical path. Calling next-error or clicking on the compiler note then results in the source not being found.

Easy fix:

(defun replace-location-if-error (location)
  (if (and (eq (car location) :error)
           *current-source-file*)
      (slynk-backend:make-location
       `(:file ,(namestring (translate-logical-pathname (asdf:component-pathname *current-source-file*))))
       `(:position 0))
      location))

wrong-type-argument stringp nil - when load-system from mrepl

I got this error when invoking 'load-system' at the mrepl:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-name-directory(nil)
  sly-asdf-find-current-system()
  (or default-value (car sly-asdf-system-history) (sly-asdf-find-current-system))
  (funcall orig-function prompt (or default-value (car sly-asdf-system-history) (sly-asdf-find-current-system)))
...

Looks like this is in

(cl-defun sly-asdf-find-current-system (&optional (buffer (car (sly-asdf--current-lisp-buffers))))
  "Find the name of the current asd system."
  (when buffer
    (let* ((buffer-file-name (buffer-file-name buffer ))
           (directory (file-name-directory buffer-file-name))
           (system-file (sly-asdf-find-system-file directory)))
      (when system-file
        (file-name-base system-file)))))

This happens if the first thing in sly-asdf--current-lisp-buffers is a buffer without a backing file.

Error when searching for default system name

When invoking any sly-asdf-* command that looks for the default system name from the current dir, and being on a dir that's relatively "far" from a system I receive this error:

Debugger entered--Lisp error: (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
  file-name-extension("$Recycle.Bin")
  (string-equal "asd" (file-name-extension file))
  (closure ((fname . "c:/") (directory . "c:/") sly-asdf--contrib sly-asdf--path t) (file) (string-equal "asd" (file-name-extension file)))("$Recycle.Bin")
  cl--position(nil ("$Recycle.Bin" "AMD" "Config.Msi" "Documents and Settings" "OpenSSL-Win64" "PerfLogs" "Program Files" "Program Files (x86)" "ProgramData" "Python27" "Recovery" "System Volume Information" "Users" "Windows" "hiberfil.sys" "pagefile.sys" "sbcl" "sbcl-test" "swapfile.sys") 0 nil nil)
  cl-position(nil ("$Recycle.Bin" "AMD" "Config.Msi" "Documents and Settings" "OpenSSL-Win64" "PerfLogs" "Program Files" "Program Files (x86)" "ProgramData" "Python27" "Recovery" "System Volume Information" "Users" "Windows" "hiberfil.sys" "pagefile.sys" "sbcl" "sbcl-test" "swapfile.sys") :if (closure ((

I think there needs to be either a reasonable 'best effort' default (probably don't want to end up scanning entire file system) or an implementation that doesn't break the stack.

Works fine when visiting a typical lisp file near a system though.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.