I want to put together a standard environment for exploring Clojure with Emacs. Has anyone got a recipe that would suit this? I'm thinking of a Vagrant system running a flavour of Ubuntu, with NREPL and some useful EMACS support plugins.
vagrant box add preciseMinimal http://goo.gl/wxdwM
Change to Clojure vagrant base folder
vagrant init preciseMinimal
vagrant up
vagrant ssh
or ssh to 127.0.0.1 port 2222 (or other port mentioned in "vagrant up" output)
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:cassou/emacs
sudo apt-get update
sudo apt-get install emacs24 emacs24-el emacs24-common-non-dfsg
sudo apt-get install clojure
cd ~/
mkdir bin
sed '$ a\
export PATH=~/bin:$PATH' ~/.bashrc
exit and reconnect to ssh
cd ~/bin
wget https://raw.github.com/technomancy/leiningen/preview/bin/lein
chmod +x lein
./lein
cd ~
cat >.emacs
; Package.el customization
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
;; install packages
(defvar my-packages '(
auto-complete
clojure-mode
clojure-test-mode
nrepl
ac-nrepl
paredit
rainbow-delimiters
))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-refresh-contents)
(package-install p)))
;; The following line can be removed after first install to speed up startup
(byte-recompile-directory (expand-file-name "~/.emacs.d") 0)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(auto-save-default nil)
'(backup-inhibited t t)
'(cursor-type 'bar t)
'(column-number-mode t)
'(delete-selection-mode t)
'(inhibit-startup-screen t)
'(initial-scratch-message nil)
'(tool-bar-mode nil)
'(xterm-mouse-mode 1))
;; rainbow delimiters
(require 'rainbow-delimiters)
(global-rainbow-delimiters-mode)
;; paredit
(add-hook 'clojure-mode-hook 'paredit-mode)
(add-hook 'nrepl-mode-hook 'paredit-mode)
(global-set-key [f7] 'paredit-mode)
;; clojure-mode
(global-set-key [f9] 'nrepl-jack-in)
;; nrepl
(add-hook 'nrepl-interaction-mode-hook 'nrepl-turn-on-eldoc-mode)
(setq nrepl-popup-stacktraces nil)
(add-to-list 'same-window-buffer-names "*nrepl*")
(add-hook 'nrepl-mode-hook 'paredit-mode)
;; Auto complete
(require 'auto-complete-config)
(ac-config-default)
(define-key ac-completing-map "\M-/" 'ac-stop)
;; ac-nrepl
(require 'ac-nrepl)
(add-hook 'nrepl-mode-hook 'ac-nrepl-setup)
(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete" '(add-to-list 'ac-modes 'nrepl-mode))
#CTRL-D to finish
Grateful attributions:
http://blog.worldcognition.com/2012/07/setting-up-emacs-for-clojure-programming.html
A Github hosted, shell provisioned vagrant setup is located here:
https://github.com/pattinsont/Ukelele
All that should be required is a checkout and vagrant up.
Once the VM is up, ssh onto box.
Run emacs to complete install.
Then M-x cider-jack-in
Related
emacsclient 26.1
emacs 26.1
Magit 20180604.958, Git 2.17.1, Emacs 26.1, gnu/linux
My emacs is configured to work in a daemon mode
when I'm trying to commit a staged file, I get this:
GitError! There was a problem with the editor '/usr/bin/emacsclient --socket-name=/tmp/emacs1000/server
and inside magit process window I see this
0 git … add -u .
1 git … commit --all --no-verify
hint: Waiting for your editor to close the file...
Waiting for Emacs...
*ERROR*: Symbol’s function definition is void: magit-process
error: There was a problem with the editor '/usr/bin/emacsclient --socket-name=/tmp/emacs1000/server'.
Please supply the message using either -m or -F option.
~/.config/systemd/user/emacsd.service
[Unit]
Description=Emacs: the extensible, self-documenting text editor
Documentation=man:emacs(1) info:Emacs
[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook nil) (kill emacs))"
Environment=DISPLAY=:%i
TimeoutStartSec=0
Restart=on-failure
[Install]
WantedBy=default.target
I have the following variables
alias emacs='lc_collate=c emacsclient -c -n "$#"'
and
➜ frontend git:(experiment) ✗ echo $EDITOR
/usr/bin/eclient
➜ frontend git:(experiment) ✗ cat /usr/bin/eclient
#!/bin/bash
/usr/bin/emacsclient -c -nw "$#"
I also get these messages
Revert buffer from file /home/dmitry/Projects/p/frontend/.git/COMMIT_EDITMSG? (y or n)
I had the same problem after upgrading Emacs from 26 to 27. Problem was resolved after I cleaned .emacs.d folder (git clean -xdf will do the trick if configs are saved in git).
I'm running emacs 24.5 installed via homebrew.
for some weird reason my emacs gets stuck on Contacting host: melpa.org:80
I even tried a fresh install of emacs (removed .emacs.d folder as well)
Also i'm able to ping the url melpa.org through terminal.
Any ideas on how to fix this.
Can you try switching to HTTPS? I have
(setq package-archives '(("org" . "http://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
;; from https://glyph.twistedmatrix.com/2015/11/editor-malware.html
;; needs "brew install gnutls" and "pip install certifi", perhaps with sudo
(let ((trustfile
(replace-regexp-in-string
"\\\\" "/"
(replace-regexp-in-string
"\n" ""
(shell-command-to-string "python -m certifi")))))
(setq tls-program
(list
(format "/usr/local/bin/gnutls-cli --insecure --x509cafile %s -p %%p %%h"
trustfile)))
(setq gnutls-verify-error t))
This question already has answers here:
How do I run a sudo command in Emacs?
(8 answers)
Closed 9 years ago.
I know how to open/edit files in Emacs as root with sudo, using Tramp. I wonder if there is a way to run Emacs commands with sudo too, without opening a shell?
Something like:
sudo M-x find-name-dired
or
M-x sudo find-name-dired
for example.
If your command involves some path on the filesystem it is possible to take advantage of tramp like this: M-x find-name-dired RET /sudo::/your/path.
I am trying to use desktop functionality (http://www.emacswiki.org/emacs/DeskTop) in emacs.
I added following code to my .emacs:
(require 'desktop)
(setq desktop-save t)
(setq desktop-load-locked-desktop t)
(setq *desktop-dir* (list (expand-file-name "~/.emacs.d/desktop")))
(setq desktop-base-file-name ".emacs.desktop")
(setq desktop-path *desktop-dir*)
(setq desktop-dir *desktop-dir*)
(desktop-save-mode 1)
(desktop-read)
If I use emacs like a standalone application, calling like "$emacs -nw", everything is fine, but when I try to use the same config with emacsclient, emacs just hangs on server starting.
Commenting out two last lines make emacs server start as expected.
See part of official Gentoo script from /etc/init.d to start emacs daemon.
: ${EMACS:=/usr/bin/emacs}
: ${EMACS_OPTS:=--daemon}
: ${EMACS_SHELL=/bin/bash}
: ${EMACS_START:=/usr/libexec/emacs/emacs-wrapper.sh}
: ${EMACS_TIMEOUT:=30}
: ${EMACS_SHUTDOWN_TIMEOUT:=10}
USER=${SVCNAME#*.}
PIDFILE_DIR=/var/run/emacs/${USER}
PIDFILE=${PIDFILE_DIR}/emacs.pid
...
local home
checkconfig || return 1
eval home="~${USER}"
SHELL=${EMACS_SHELL:-$(awk -F: "\$1 == \"${USER}\" { print \$7 }" \
/etc/passwd)}
export SHELL EMACS EMACS_TIMEOUT
ebegin "Starting Emacs daemon for user ${USER}"
if [ -z "${RC_SVCNAME}" ]; then
# baselayout-1
start-stop-daemon --start \
--user "${USER}" --exec "${EMACS}" --pidfile "${PIDFILE}" \
--chuid "${USER}" --chdir "${home}" --env HOME="${home}" \
--startas "${EMACS_START}" -- ${EMACS_OPTS}
else
# OpenRC
start-stop-daemon --start \
--user "${USER}" --pidfile "${PIDFILE}" --chdir "${home}" \
--exec "${EMACS_START}" -- ${EMACS_OPTS}
fi
eend $?
Is possible to debug emacsclient problems somehow?
Maybe someone could give a hint?
P.S. I am on Gentoo Linux, emacs-vcs-23.2.9999 package, terminal only.
This question was asked and answered by ayrnieu at
How can ECL include ASDF dependencies in an executable?
But the example code he linked to does not actually involve any dependencies. I've tried copying the model in the stumpwm code he refers to but I can't get it to work. He are my files.
---- ecl-test.asd ----
(defsystem "ecl-test"
:description "test of asdf:make-build"
:depends-on (:mydefs)
:components ((:file "package")
(:file "ecl-test" :depends-on ("package"))
(:file "main" :depends-on ("package" "ecl-test"))
)
)
---- ecl-test.lisp ----
(in-package :ecl-test)
(defun test ()
(format t "testing...~%")
;; Note that with the next line commented out,
;; the program never uses the package "mydefs".
;; (format t (write-to-string (mydefs:number-sequence :from 2 :to 7)))
(format t "...done~%"))
---- package.lisp ----
(defpackage :ecl-test
(:use :cl
:mydefs
)
(:export :test))
---- main.lisp ----
(ecl-test:test)
(ext:quit)
This compiles successfully (in slime):
CL-USER> (asdf:make-build 'ecl-test :type :program :monolithic t :epilogue-code '(ext:quit 0))
; loading system definition from /home/dabrowsa/lisp/ecl-test/ecl-test.asd into
; #<ASDF0 package>
;;; Loading "/home/dabrowsa/lisp/ecl-test/ecl-test.asd"
;;; Compiling /home/dabrowsa/lisp/ecl-test/package.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; End of Pass 1.
;;; Note: Creating tag: "_eclitxZgyvjVscp1_KzxnJ9z" for #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/package.c" -o "/home/dabrowsa/lisp/ecl-test/package.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/package.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Found tag: "_eclitxZgyvjVscp1_KzxnJ9z" for /home/dabrowsa/lisp/ecl-test/package.o
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITMs8gOO.c" -o "/tmp/ECLINITMs8gOO.o"
;;; Note: Invoking external command:
;;; gcc -o "/home/dabrowsa/lisp/ecl-test/package.fas" -L"/usr/lib/" "/tmp/ECLINITMs8gOO.o" "/home/dabrowsa/lisp/ecl-test/package.o" -shared -lecl -lgmp -lgc -ldl -lm
;;; Loading "/home/dabrowsa/lisp/ecl-test/package.fas"
;;; Compiling /home/dabrowsa/lisp/ecl-test/ecl-test.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; Compiling (DEFUN TEST ...).
;;; End of Pass 1.
;;; Note: Creating tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Emitting code for TEST.
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/ecl-test.c" -o "/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/ecl-test.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Note: Found tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for /home/dabrowsa/lisp/ecl-test/ecl-test.o
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITg28qfo.c" -o "/tmp/ECLINITg28qfo.o"
;;; Note: Invoking external command:
;;; gcc -o "/home/dabrowsa/lisp/ecl-test/ecl-test.fas" -L"/usr/lib/" "/tmp/ECLINITg28qfo.o" "/home/dabrowsa/lisp/ecl-test/ecl-test.o" -shared -lecl -lgmp -lgc -ldl -lm
;;; Loading "/home/dabrowsa/lisp/ecl-test/ecl-test.fas"
;;; Compiling /home/dabrowsa/lisp/ecl-test/main.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; End of Pass 1.
;;; Note: Creating tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/main.c" -o "/home/dabrowsa/lisp/ecl-test/main.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/main.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Found tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITeop9MY.c" -o "/tmp/ECLINITeop9MY.o"
;;; Note: Invoking external command:
;;; gcc -o "/home/dabrowsa/lisp/ecl-test/main.fas" -L"/usr/lib/" "/tmp/ECLINITeop9MY.o" "/home/dabrowsa/lisp/ecl-test/main.o" -shared -lecl -lgmp -lgc -ldl -lm
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Found tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Note: Found tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for /home/dabrowsa/lisp/ecl-test/ecl-test.o
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Found tag: "_eclitxZgyvjVscp1_KzxnJ9z" for /home/dabrowsa/lisp/ecl-test/package.o
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITsLgWth.c" -o "/tmp/ECLINITsLgWth.o"
;;; Note: Invoking external command:
;;; ar cr /home/dabrowsa/lisp/ecl-test/libecl-test.a /tmp/ECLINITsLgWth.o /home/dabrowsa/lisp/ecl-test/package.o /home/dabrowsa/lisp/ecl-test/ecl-test.o /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Invoking external command:
;;; ranlib /home/dabrowsa/lisp/ecl-test/libecl-test.a
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITTF1dqA.c" -o "/tmp/ECLINITTF1dqA.o"
;;; Note: Invoking external command:
;;; gcc -o "/home/dabrowsa/lisp/ecl-test/ecl-test-mono" -L"/usr/lib/" "/tmp/ECLINITTF1dqA.o" "/home/dabrowsa/lisp/ecl-test/libecl-test.a" -lecl -lgmp -lgc -ldl -lm #<ASDF::PROGRAM-OP NIL 38147728>
But executing ecl-test-mono produces an error.
~/lisp/ecl-test$ ./ecl-test-mono
The function ASDF::SYSTEM-REGISTERED-P is undefined.
No restarts available.
Broken at NIL.
ECL-TEST>>
SYSTEM-REGISTERED-P seems to be an unexported function in ASDF, I have no idea why that's popping up here, but then, I'm a newbie so what do I know.
You're better off asking this on ecls-list.
Or try this in your call to MAKE-BUILD:
:prologue-code '(require :asdf)