This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-22
Channels
- # alda (2)
- # announcements (1)
- # babashka (32)
- # beginners (67)
- # calva (1)
- # cider (19)
- # clerk (11)
- # clj-commons (35)
- # clj-kondo (7)
- # cljsrn (2)
- # clojure (35)
- # clojure-europe (86)
- # clojure-nl (5)
- # clojure-norway (5)
- # clojure-russia (6)
- # clojurescript (16)
- # clr (21)
- # conjure (1)
- # core-async (10)
- # cryogen (1)
- # cursive (12)
- # data-science (1)
- # emacs (29)
- # events (4)
- # figwheel-main (2)
- # graalvm (9)
- # gratitude (7)
- # honeysql (4)
- # hugsql (3)
- # hyperfiddle (23)
- # jobs (1)
- # jobs-discuss (4)
- # joyride (9)
- # malli (2)
- # off-topic (81)
- # portal (7)
- # reagent (19)
- # reitit (1)
- # releases (4)
- # shadow-cljs (121)
- # xtdb (3)
Anyone else having problems with running external programs from emacs when using emacsclient
? E.g. doing a "As HTML file and open" export from org? Everything works fine with emacs
.
I'm starting the server as a systemd service (https://www.emacswiki.org/emacs/EmacsAsDaemon#h5o-2) and it feels like it's missing some environmental variables or something like that
interesting. Running async-shell-command
+ firefox <some url>
returns Error: no DISPLAY environment variable specified
. And the same with xdg-open
throws a xdg-open: no method available for opening '/home/lassemaatta/org-roam/20230321121039-<some file>.html'
.
yeah, this looks more like a "systemd user services don't inherit the environment" issue rather than anything to do with emacs
It may be because Emacs is starting before your X server. I think you can make it wait until graphical-session.target
is reached, depending on your desktop environment. I switched to just starting Emacs in my sway config
yeah, the arch article describing systemd user services has a bunch of notes and workarounds relating to environment variables and how to pass them to the user services
But I'm pretty sure those are all set by systemd when the service is launched as part of graphical-session.target
Argh, I'm frustrated by emacs lisp. How do I accomplish the following simple task?
I want to write a clj!
macro which sends its input expression to a process via stdin, and get the result back as a string. The rest I can figure out, but this part is confusing as hell.
(defmacro clj! (expr)
(let* ((expr-as-string (prin1-to-string expr))
(temp-buf "*el2clj-work*"))
(get-buffer-create temp-buf)
???
(shell-command-on-region (point-min) (point-max) "clj2el" temp-buf)
))
Finally, a macro to transpile and evaluate the code:
(defmacro clj! (expr)
(let* ((expr-as-string (prin1-to-string expr))
(temp-buf "*el2clj-work*"))
(get-buffer-create temp-buf)
(let* ((elisp-code (with-current-buffer temp-buf
(erase-buffer)
(insert expr-as-string)
(shell-command-on-region (point-min) (point-max) "clj2el" temp-buf)
(buffer-substring (point-min) (point-max))))
(read (read-from-string elisp-code))
(expr (car read)))
expr)))
(clj! (defn foo [x] (inc x)))
(foo 1) ;;=> 2
(or with scimacs as the dynamic module in which the transpiler is doing its work... it's already fast)
(clj! (progn (defn foo [x] (inc x))
(defn bar [x] (inc x))
(foo (bar 3)))) ;; => 5
> (or with scimacs as the dynamic module in which the transpiler is doing its work... it's already fast) Yes - avoiding the process startup/shutdown overhead would be best. But this is a good start!
I'm not 100 % sure about emacs lisp conventions, but in order to play nice with other Emacs code, we might consider prefixing all our public variables with the package name.
In other words, consider using clj2el!
or clj2el-clj!
as names for the clj!
macro.
Just noticed you just pushed that change 😅 😄 https://github.com/borkdude/clj2el/commit/49f602a2a5f441946f48fd0d0c3b53109eeba2e5
Would this be a common sense translation for hash-maps?
(def m {:a 1}) ;;=> (setq m (list (list :a 1)))
(:a m) ;;=> (cdr (assoc :a m))
matching https://github.com/clojure-emacs/parseedn output seems a useful definition of 'common sense' :) https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html can also be a useful guide
(assoc-default 'a `((a . ,(+ 1 1))))
2
Your m
is not really an alist right now. The element is a list but should be a cons pair