Coverage report: /home/ellis/comp/core/lib/cli/ed.lisp
Kind | Covered | All | % |
expression | 0 | 189 | 0.0 |
branch | 0 | 6 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; lib/cli/ed.lisp --- Editor functions
8
(defvar *user-emacs-directory* (merge-pathnames ".emacs.d/" (user-homedir-pathname)))
10
(defmacro with-emacs-printer (&body body)
11
"Eval BODY with Emacs Lisp printer settings."
12
`(let ((*print-case* :downcase)
13
(*print-readably* nil))
16
(defun run-emacs (args &key file create-frame eval client wait batch function)
17
(if (or client (not batch))
18
(run-emacsclient args :file file :create-frame create-frame :eval eval :wait wait)
20
(when file (push (format nil "~S" file) keys))
21
(when create-frame (push "-c" keys))
22
(when function (appendf keys (list "-f" (string-downcase function))))
23
(when batch (push "--batch" keys))
26
(appendf keys (list "-e" (format nil "~S" eval)))))
27
(sb-ext:run-program (find-exe "emacs") (append keys args)))))
29
(defun run-emacsclient (args &key file (create-frame t) function eval wait)
31
(when file (push (format nil "~S" file) keys))
32
(when create-frame (push "-c" keys))
33
(when function (appendf keys (list "-f" (string-downcase function))))
37
(appendf keys (list "-e" (format nil "~S" eval)))))
38
(sb-ext:run-program (find-exe "emacsclient")
43
(defun eval-emacs (form &key (client t) args file wait create-frame batch function)
44
(run-emacs args :eval form
48
:create-frame create-frame
52
(defun ielm (&optional buf-name)
53
(eval-emacs `(ielm ,@(when buf-name `(,buf-name)))))
55
(defun slime (&optional command coding-system)
56
(eval-emacs `(slime ,command ,coding-system)))
59
(eval-emacs `(ediff ,(namestring a) ,(namestring b))))
62
(eval-emacs `(ediff ,(namestring a) ,(namestring b) ,(namestring c))))
64
(defun vc-ediff (&optional rev-a rev-b)
65
"Show differences between REV1 and REV2 of FILES using ediff.
66
This compares two revisions of the files in FILES. Currently,
67
only a single file's revisions can be compared, i.e. FILES can
68
specify only one file name.
69
If REV1 is nil, it defaults to the current revision, i.e. revision
71
If REV2 is nil, it defaults to the work tree, i.e. the current
72
state of each file in FILES."
75
`(vc-version-ediff nil ,rev-a ,rev-b)
80
(push #'run-emacsclient sb-ext:*ed-functions*)
81
(push #'run-emacs sb-ext:*ed-functions*)
84
(defconfig editor-config (ast) ())
86
(defmethod make-config ((fmt (eql :editor)) &rest initargs &key type &allow-other-keys)
90
(apply 'make-config type initargs))
91
(make-instance 'editor-config)))
93
(defconfig emacs-config (editor-config)
94
((path :initform *user-emacs-directory* :initarg :path :accessor path)))
96
(defun load-emacs-config (&optional (path *user-emacs-directory*))
97
(make-config :emacs :path path))
99
(defmethod make-config ((fmt (eql :emacs)) &key ast path)
100
(make-instance 'emacs-config :ast ast :path path))
103
;; ref: https://orgmode.org/worg/org-contrib/org-protocol.html
105
;; On GNU/Linux, Emacs is now the default application for
106
;; 'org-protocol'. (startup change in Emacs 30.1)
107
(defun org-store-link (url title)
108
(run-emacsclient (format nil "org-protocol://store-link?url=~a&title=~a"
111
(defun emacs-find-file (path &key (position 0) (wait t) create-frame (client t))
112
(eval-emacs `(progn (find-file ,path) (goto-char ,position)) :wait wait :create-frame create-frame :client client))
115
(defmacro with-emacs ((var &key (eval t) (client t) create-frame file (wait t) batch function args) &body body)
117
`(progn (eval-emacs '(progn ,@body) :client ,client :args ,args :wait ,wait :batch ,batch :function ,function))
118
`(let ((,var (run-emacs ,args :eval ,eval
120
:create-frame ,create-frame
123
:function ,function)))