Hi, I am finding hard to use Nyxt commands via Common Lisp. I guess this is by design (what is the reason btw?).
I was thinking to make a macro/function with-prompt-value that emulates a user inserting a string in the prompt, so that I can use commands like open-file like this (with-prompt-value "/tmp/myfile.txt" (open-file)).
Am I going in the wrong way? Do you know if such a macro/function is already around?
The reason you can only see some commands in the prompt is because only commands for active modes are visible. If a mode is not active, it’s commands are not visible. Perhaps this could be a setting/configuration!
Mmm, thanks. I see that prompt takes an :input that I could use:
(define-command set-url (&key (prefill-current-url-p t))
"Set the URL for the current buffer, completing with history."
...
(prompt
:prompt "Open URL"
:input (if prefill-current-url-p
(render-url (url (current-buffer))) "")
...))
I am not sure I explained myself well. I will try again.
I wanted to open a QR code I generated with Nyxt (see Extending Nyxt via Emacs: how to leverage Common Lisp wealth to get your links as QR codes - Where parallels cross).
I want to do this via the Slime REPL, ideally with (open-file "myQRcode").
But open-file does not take a path argument. So I was thinking to somehow mimic the user input to skip the interactive bit.
In ELisp you have interactive functions: they would look like (defun x (arg) (interactive (list (ask-for-input)) ...), where the function input arg is used unless the function is called as a commnad: is not possible to have something like that in Nyxt?
I mean that the function prompt is called only if I invoke the command from Nyxt, but I can pass an input when I am invoking the command from a Lisp REPL?
It is thanks. Just a last push though: this is how open-file is defined. (define-command open-file (&key (default-directory *default-pathname-defaults*)) ...
If I call it with (open-file :default-directory "/home/andrea/workspace/nyxt/source/file-manager.lisp"), I get Slime’s REPL to hang and an open prompt in Nyxt.
I would like Nyxt to just open the file if I provide the argument.
Do you suggest I redefine open-file to take another optional argument that if present skips to call prompt?
Edit: the reason I wanted that is that I would like to open the QR code when I invoke the command “make a QR code for current URL”, and it should not prompt me for the file because Nyxt knows where to find the QR code.
It is an output file. Imagine you are on a page and want to open it with your phone. With my extension you can make a QR code image that gets stored on the file system. I would like that once you invoke the command “make QR code”, that QR code appears on your screen.
The command open-file does that, but only works interactively. Is there a better function?
And again, if I use that interactively from Nyxt, would not be easier to use that also from a REPL? You see, now I need to know two functions to open files
Ah okay! I get I should leverage Common Lisp for displaying a file instead of relying on Nyxt. I totally not think about that because I was so focused on using Nyxt built-in operations.
It would be ideal for me if all commands could be used both interactively and through Common Lisp. That is why I was mentioning the (interactive) feature of Emacs Lisp.