How to set emacs as external editor ( in a Guix system )?

Hello fellow Nyxt hackers ! May i ask you how to instruct nyxt to use emacs as external editor in a Guix system ?

I’ve unsuccesfully tried to do so like this ( in both my ~/.config/nyxt/init.el and …/auto-config.lisp files) :

(define-configuration  browser
  ((external-editor-program "/home/fenix/.guix-home/profile/bin/emacsclient")))

FYI, i’m getting Nyxt message saying :

" WARNING : the value is not of type list when binding SB-IMPL::X  "

What am i missing ?

thanks, thanks thanks

Try putting this string into a list, like

(define-configuration  browser
  ((external-editor-program '("/home/fenix/.guix-home/profile/bin/emacsclient"))))

That should probably fix it.

The problem is likely due to uiop:launch-program (the function we use for external editor invokations) accepting only a list of strings. I’ve just pushed a fix on master, now a mere string should be fine too.

By the way, why init.el instead of init.lisp? Nyxt is written in Common Lisp, not Emacs Lisp. :upside_down_face:

@fenix Note that specifying the program as a list of strings is handy since you can also declare arguments. For instance, here’s how I set external-editor-program:

(define-configuration browser
  ((external-editor-program (list "emacsclient" "-c"))))

Nice to know @aadcg !

Oh, yes, … i knew. Super Nyxt browser is made not of Emacs Lisp but Common Lisp, @aartaka . Thanks for the reminder.

Happy hacking

Common Lisp > Emacs Lisp :stuck_out_tongue:

The default value for external-editor-program is (or (uiop:getenv "VISUAL") (uiop:getenv "EDITOR")). I’ve already defined these in my bash_profile as

export EDITOR="emacsclient --create-frame --tty"
export VISUAL="emacsclient --create-frame"

I then set external-editor-program as

(define-configuration browser
  ((external-editor-program (str:split #\space (uiop/os:getenv "VISUAL")))))

Which will set it to (list "emacsclient" "--create-frame").

This works for me, and I don’t have to do anything special. Maybe chaging the default to (str:split #\space (or (uiop:getenv "VISUAL") (uiop:getenv "EDITOR"))) would be beneficial.

EDIT: I should note that I’m running emacs as a server using shepherd. I have the following configuration which basically runs emacs --fg-daemon, and that’s the key in getting emacsclient to work properly.
I start shepherd when logging in by executing shepherd & in my StumpWM configuration.

In my StumpWM config:

(unless (probe-file "/run/user/1000/shepherd/socket")
  (run-shell-command "shepherd &"))

Which reads the following file


(use-modules (shepherd service)
             ((ice-9 ftw) #:select (scandir)))

;; Load all the files in the directory 'init.d' with a suffix '.scm'.
  (lambda (file)
    (load (string-append "init.d/" file)))
  (scandir (string-append (dirname (current-filename)) "/init.d")
           (lambda (file)
             (string-suffix? ".scm" file))))

;; Send shepherd into the background
(action 'shepherd 'daemonize)

And this loads my emacs setup and starts emacs as a server.


(use-modules (shepherd support))

(define emacs-daemon
  (make <service>
    #:provides '(emacs-daemon)
    #:docstring "Starts emacs as a daemon"
    #:start (lambda ()
              (let ((socket (string-append %user-runtime-dir "/emacs/server")))
                (unless (file-exists? socket)
                  (fork+exec-command (list "emacs" "--fg-daemon")))))
    #:stop (make-kill-destructor)
    #:respawn? #t))

(register-services emacs-daemon)
(start emacs-daemon)

@simendsjo I think your observation is spot on! Would you like to open a PR? :slight_smile:

Sure, bash to uiop syntax for external-editor-program by simendsjo · Pull Request #2980 · atlas-engineer/nyxt · GitHub