1 ;;; GNU Mes --- Maxwell Equations of Software
2 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
4 ;;; This file is part of GNU Mes.
6 ;;; GNU Mes is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Mes is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
21 ((indent-tabs-mode . nil)
25 (let ((top (locate-dominating-file default-directory ".dir-locals.el"))))
27 (defun guile--manual-look-up (id mod)
28 (message "guile--manual-look-up id=%s => %s mod=%s" id (symbol-name id) mod)
29 (let ((info-lookup-other-window-flag
30 geiser-guile-manual-lookup-other-window-p))
31 (info-lookup-symbol (symbol-name id) 'scheme-mode))
32 (when geiser-guile-manual-lookup-other-window-p
33 (switch-to-buffer-other-window "*info*"))
34 (search-forward (format "%s" id) nil t))
36 (add-hook 'before-save-hook 'delete-trailing-whitespace nil t)
38 (defun guix-switch-profile (&optional profile)
39 "reset Emacs' environment by snarfing PROFILE/etc/profile"
41 (defun matches-in-string (regexp string)
42 "return a list of matches of REGEXP in STRING."
46 (while (string-match regexp string (match-end 0))
47 (push (or (match-string 1 string) (match-string 0 string)) matches)))
50 (interactive "fprofile: ")
51 (let* ((output (shell-command-to-string (concat "GUIX_PROFILE= /bin/sh -x " profile "/etc/profile")))
52 (exports (matches-in-string "^[+] export \\(.*\\)" output)))
53 (mapcar (lambda (line) (apply #'setenv (split-string line "="))) exports )))
55 (defun shell-args-to-string (&rest args)
56 (shell-command-to-string (mapconcat 'identity args " ")))
58 (defun as (string &optional arch)
59 (let* ((arch (or arch "--64"))
60 (asm (subst-char-in-string ?_ ?\s string))
61 (foo (message "asm:%S" asm))
62 (result (shell-args-to-string "as" arch (concat "<(echo '" asm "')")))
63 (disassembly (shell-args-to-string "objdump" "-d" "a.out"))
64 (foo (message "disassembly: %S" disassembly))
65 (match (string-match "^ 0:[\t]\\([^\t]*\\)" disassembly))
66 (code (match-string 1 disassembly))
67 (code (apply 'concat (split-string code " " t))))
71 (defun as-32 (point mark)
73 (let* ((string (buffer-substring point mark))
74 (code (as string "--32")))
78 (defun as-64 (point mark)
80 (let* ((string (buffer-substring point mark))
81 (code (as string "--64")))
85 (indent-tabs-mode . t))
88 ((geiser-active-implementations . (guile))
92 (defun prefix-dir-locals-dir (elt)
93 (concat (locate-dominating-file buffer-file-name ".dir-locals.el") elt))
95 (lambda (dir) (add-to-list 'geiser-guile-load-path dir))
97 #'prefix-dir-locals-dir
98 '("scripts" "module")))))))
99 (texinfo-mode . ((indent-tabs-mode . nil)
100 (fill-column . 72))))