Viewing the Common Lisp HyperSpec offline via Emacs - common-lisp

I'm using Emacs as my Lisp environment, and would like to have offline access to the Common Lisp HyperSpec. I downloaded it, and put the folders into my emacs.d directory. I then put the following code into my .emacs:
(global-set-key [(f2)] 'slime-hyperspec-lookup)
(setq common-lisp-hyperspec-root "/.emacs.d/HyperSpec/")
However, every time I try to search for something in it, my query ends up being malformed. Specifically, suppose I search for dotimes; what gets dumped into my browser is file:///.emacs.d/HyperSpec/Body/m_dolist.htm, which doesn't match the directory structure in the HyperSpec folder, causing the query to fail. The HyperSpec lookup instead formats to suit the web version (in that case, it works absolutely fine).
Is there any way I can fix this, and if so, how? I basically just want to be able to look up the HyperSpec even when I'm not online.

You might like to try my CLHS ASDF wrapper, which is specifically designed to download the CLHS into a standard location (basically the quicklisp directory) and then help you setup emacs to point to it.
Simply invoke (ql:quickload "clhs") and follow the instructions.
Hope this helps!
edit: #JigarParekh I think you may have skimmed my answer a little too fast.
The question's title is "Viewing the Common Lisp HyperSpec offline via Emacs". The question's body basically gets bogged down in the details of manually installing the CLHS and pointing emacs to it, and asks how to solve an immediate subproblem related to that. The selected answer solves the user's immediate subproblem, but is less than optimal given what's available today.
My answer does include the essential part of the answer, which is:
Simply invoke (ql:quickload "clhs") and follow the instructions.
This downloads the CLHS from Quicklisp in a way that should remain available for the foreseeable future, regardless of the helpful but optional additional information I included for reference in the first paragraph. My answer would remain useful even if the reference links' content changed or even if, god forbid, they became 404 Not Found or otherwise unavailable. (I note in passing that since the referenced page is part of a public domain website and available on github, anyone could easily mirror it and provide a replacement link to it here should that ever come to pass. But as I said, it's optional additional reference information anyway.)

Please replace
(setq common-lisp-hyperspec-root "/.emacs.d/HyperSpec/")
with
(setq common-lisp-hyperspec-root "~/.emacs.d/HyperSpec/")
or even
(setq common-lisp-hyperspec-root (expand-file-name "~/.emacs.d/HyperSpec/"))

Related

`find_theorems` in the AFP

How can I use the find_theorems mechanism to search the whole Archive of Formal Proofs (AFP)?
I have downloaded the archive to my machine, and I am able to import theories from it. For instance, if I write imports Kleene_Algebra.Kleene_Algebra_Models then all the theorems in that theory are successfully made available to me. But if I then type find_theorems <expression>, I only get search results from the specific theory I imported. What if I want to search the whole archive? For instance, perhaps somebody has proved a theorem that is useful to me, but I don't know what they called their theory.
find_theorems only works with the loaded theories. You can use any text search tool if you have an idea of the theorem name. On macOS, the Splotlight Search (cmd + space) can be useful.
To put it plain and simple, you can't, unless you import the entirety of the AFP into your theory (which probably won't work).
I'm unsure whether someone is currently working on making what you want happen.

Finding the system of a package

I am in the design phase of building a deployment tool for CL projects.
I imagine the typical workflow to be like so:
(ql:quickload :yolo)
(yolo:configure)
Developer adds remote machine user and host, etc...
Developer goes to bed. Turns off the PC
In the morning: hack hack hack
Time to deploy. Developer commits changes and goes to the REPL and types (yolo:deploy)
What I want is for my library to know which system the developer wants deployed based on the current package. (*package*)
My question: Is it possible to find the system that loaded a particular package? Naturally I am talking about ASDF.
Bonus question: Is such a tool even needed? Perhaps there is a better workflow. I am also planning to make the library an executable, but then the default project can be obtain by the current directory.
First, read about packages, systems, libraries etc. here.
I do not think that it makes much sense to infer the intended system. You need at least one additional parameter anyway (the target where to deploy).
A few ideas:
I imagine that a deployment tool would deploy a system. It would then perhaps sensibly be defined as an extension for ASDF.
For example, you might devise such an extension so that you can specify deployment configuration in the defsystem form like this:
(defsystem #:foo
:defsystem-depends-on (#:your-awesome-asdf-deploy)
;; ...
:deploy-targets (:test (:host "test.example.org"
:user "foo"
:env (:backend-url "https://test.foo.org/api"
:dev t))
:prod (:host "prod.example.org"
:user "bar"
:env (:backend-url "https://foo.org/api"
:dev nil))))
This information could then be used in a new op deploy-op, that you might invoke like:
(asdf:oos 'asdf-deploy:deploy-op 'foo :target :test)
There is no builtin way to answer your question, but if, right after you load asdf, you hook into (defmethod perform :after ((o load-op) (s system)) ...) a function that diffs the list of new entries from the list of all packages, then you could build an index of which systems create which packages.

Is it possible to include the os library in lua 4.0?

I'm stuck using the 4.0 version of lua which does not seem to support the os library. Is there a way to include this library into my project?
Or get another way to use the functionality contained within pertaining to date time calculations?
Preferably by using a *.lua file and not a *.c file since I don't have complete access to the code.
When I run the following line,
print(os.time{year=1970, month=1, day=1, hour=0})
I get an error stating:
attempt to index global 'os'(a nil value)
As #Colonel Thirty Two said it's not possible to use the os library. So the time() funciton is not available for me.
Adding to the (totally correct) currently accepted answer (that if "os" access was not allowed to you, you're generally done), there's some very slight chance the Original Programmer may have provided you with some alternative facilities to do your thing (fingers crossed). In a perfect world, those would be described in some kind of a User's Manual for your scripting environment. But if the manual was lost to time (or never existed in the first place), you might possibly try your luck at exploring any preloaded libraries by digging through the result of the globals() Basic Function. (At least I hope that's how it was done in 4.0 too.) That is, if the Original Programmer didn't block globals() for you too...

How do I delete a directory in common lisp

To delete a file in Common Lisp I can do:
(delete-file "c:\\path\\to\\file")
But for some reason I'm unable to find out how to delete a directory. There is no delete-directory, and when I pass a directory path to delete-file I get:
couldn't delete c:\path\to\folder: Unknown error
[Condition of type SB-INT:SIMPLE-FILE-ERROR]
Googling didn't help either.
I'm using Steel Banks Common Lisp on Windows, installed using Lispstick.
Uiop comes with ASDF 3 and has delete-empty-directory and delete-directory-tree.
Please do use this kind of wrapper library for portability.
Google with common lisp delete directory suggested me immediately cl-fad. I guess it could be useful (but I never tried it)
I found the solution myself. I looked at the source code of cl-fad (mentioned in other answers), and saw that it basically used different extensions for the different Common Lisp implementations. Since I was using Steel Banks Common Lisp my solution was:
(sb-ext:delete-directory "c:\\path\\to\\folder\\")
For most other implementations you basically have to swap out sb-ext with the name of the extension package for the implementation in question.

ASDF optional system dependencies

I have a system I wrote that uses lparallel when possible, and otherwise works around it. Problem is, I'm now trying to test it on ECL, which errors upon merely loading lparallel.
Is there a way (other than #-ecl ) to specify system dependencies parameterized by implementation type? I've looked at Madiera Port but it seems to work only for subcomponents, not system dependencies. I wish to keep my .asd file as a simple machine-readable form, without reader conditionals etc.
( aside: lparallel loads fine on a current ECL. mine was just outdated. )
To my knowledge there is no direct way to do that in ASDF apart from reader conditionals. You could use XCVB instead, or write a defsystem* macro that adds new syntax, or (maybe) hook into the existing defsystem as madeira does.
Without knowing your motivation, I wonder why the simple solution of #-ecl is being avoided. Do you wish to store metadata that links ECL to the nonexistence of lparallel? Note #-lparallel and #+lparallel may be used in lisp files.
By the way lparallel loads fine for me in ECL. Are you running the latest ECL? There is a known bug in ECL that causes the lparallel tests to eventually hang, however this may not affect all platforms.

Resources