chris613
2020-1-29 10:24:39

this is a sort of emacs one ….. but ive got racket-mode setup (via spacemacs) and when i want to run my program i have to first save all the modified buffers, then switch to my main.rkt then C-c C-c to run the program. Is there a shorter way ?


chris613
2020-1-29 10:28:07

i.e. in intellij i set up run-configs, so something similar maybe?


soegaard2
2020-1-29 11:11:17

Hi Chris. I think the way to go is to write an elisp function that changes the buffer to “mail.rkt” and then runs it.

For how to write small functions and bind them to keys, you can get some ideas from my .emacs.


soegaard2
2020-1-29 11:12:05

;;; ;;; General Editing ;;; ;; 1. Use M-x package-install to install math-symbol-lists ;;; ;;; Packages ;;; ;; The Emacs package repository is called Melpa. (require 'package) ;; You might already have this line (setq package-check-signature nil) (add-to-list 'package-archives '("melpa" . "<https://melpa.org/packages/>") t) (add-to-list 'package-archives '("gnu" . "<http://elpa.gnu.org/packages/>") t) (package-initialize) ;; Installed Packages ;; racket-mode mode for editing Racket programs ;; tabbar tabs (like a browser) at the top of the screen to switch between buffers ;; solarized-theme nicer colors ;; power-line ;; When a region is highlighted, typed text should replace the selection. (delete-selection-mode 1) ;; Bind cmd-z to undo. (global-set-key (kbd "s-z") #'undo) ;; Bind cmd-w to kill-buffer (which closes the buffer) (global-set-key (kbd "s-w") #'kill-buffer) ;; Make control-\ insert an λ (defun insert-lambda () "Insert the character λ" (interactive) (insert-char ?\λ)) (global-set-key (kbd "s-\\") #'insert-lambda) ;; Show Paren mode - matching parenthesis (show-paren-mode 1) ;;; The package math-symbol-lists contains all symbols defined in unicode-math. (package-initialize) (require 'math-symbol-lists) (quail-define-package "math" "UTF-8" "Ω" t) (quail-define-rules ; add whatever extra rules you want to define here... ("\\aa" "å") ("\\Aa" "Å") ("\\ae" "æ") ("\\Ae" "Æ") ("\\oe" "ø") ("\\Oe" "Ø")) (mapc (lambda (x) (if (cddr x) (quail-defrule (cadr x) (car (cddr x))))) (append math-symbol-list-basic math-symbol-list-extended)) ;; Laptop: up-arrow key is broken, so we need an alternative. (global-set-key (kbd "M-p") #'beginning-of-buffer) (global-set-key (kbd "&lt;f1&gt;") #'delete-other-windows) (global-set-key (kbd "&lt;f2&gt;") #'other-buffer) (global-set-key (kbd "&lt;f3&gt;") #'switch-to-buffer) (global-set-key (kbd "&lt;f7&gt;") #'tabbar-backward) (global-set-key (kbd "&lt;f8&gt;") #'tabbar-forward) ;; Desktop: (global-set-key (kbd "&lt;f13&gt;") #'delete-other-windows) (global-set-key (kbd "&lt;f14&gt;") #'other-window) (global-set-key (kbd "&lt;f15&gt;") #'split-window-below) (global-set-key (kbd "&lt;f16&gt;") #'tabbar-backward) (global-set-key (kbd "&lt;f17&gt;") #'tabbar-forward) (global-set-key (kbd "&lt;f18&gt;") #'switch-to-buffer) ;;; ;;; File Extension -&gt; Mode ;;; (add-to-list 'auto-mode-alist '("\\.scrbl\\'" . racket-mode)) (add-to-list 'auto-mode-alist '("\\.mscrbl\\'" . racket-mode)) ;;; ;;; Color Themes ;;; ;; The package solarized-theme provides solarized-dark and solarized-light ;; Use M-x load-theme to try them interactively. (add-to-list 'load-path "~/.emacs.d/lisp/") (add-to-list 'custom-theme-load-path "~/.emacs.d/themes") (load-theme 'solarized-light t) ;; make the fringe stand out from the background ;(setq solarized-distinct-fringe-background t) ;;; ;;; Tabbar ;;; ;; A bar (line) with tabs representing the open buffers. (require 'tabbar) (customize-set-variable 'tabbar-background-color "gray20") (customize-set-variable 'tabbar-separator '(0.5)) (customize-set-variable 'tabbar-use-images nil) (tabbar-mode 1) ;; My preferred keys ; note: s means super aka cmd (i.e. it does not mean shift) (define-key global-map (kbd "s-{") 'tabbar-backward) ; shift cmd { (define-key global-map (kbd "s-}") 'tabbar-forward) ; shift cmd } ;; Colors (set-face-attribute 'tabbar-default nil :background "gray20" :foreground "gray60" :distant-foreground "gray50" :family "Helvetica Neue" :box nil) (set-face-attribute 'tabbar-unselected nil :background "gray80" :foreground "black" :box nil) (set-face-attribute 'tabbar-modified nil :foreground "red4" :box nil :inherit 'tabbar-unselected) (set-face-attribute 'tabbar-selected nil :background "#4090c0" :foreground "white" :box nil) (set-face-attribute 'tabbar-selected-modified nil :inherit 'tabbar-selected :foreground "GoldenRod2" :box nil) (set-face-attribute 'tabbar-button nil :box nil) ;; Use Powerline to make tabs look nicer ;; (this needs to run *after* the colors are set) (require 'powerline) (defvar my/tabbar-height 24) ; needs to be +6 (when font size is 18) (defvar my/tabbar-left (powerline-wave-right 'tabbar-default nil my/tabbar-height)) (defvar my/tabbar-right (powerline-wave-left nil 'tabbar-default my/tabbar-height)) (defun my/tabbar-tab-label-function (tab) (powerline-render (list my/tabbar-left (format " %s " (car tab)) my/tabbar-right))) (setq tabbar-tab-label-function #'my/tabbar-tab-label-function) ;;; ;;; Key Bindings ;;; ;; For key bindings always use small named functions rather than lambda expressions. (require 'racket-mode) (defun my-racket-switch-from-repl-to-editor () "Switch from the Racket repl to the editor. Hide the repl." (interactive) (racket-repl-switch-to-edit) (delete-other-windows)) (defun my-racket-switch-from-editor-to-repl () "Switch from the Racket (editor) buffer to the repl. Hide the editor." (interactive) (racket-repl) (delete-other-windows)) (defun my-racket-repl-also-display-editor () "Display editor window owning repl" (interactive) (racket-repl-switch-to-edit)) (defun my-racket-run-from-editor () "Run program in editor buffer. Switch to repl." (interactive) (racket-run) (other-window 1)) ; number of windows to skip (defun my-racket-indent-whole-buffer () "Indent whole buffer" (interactive) (save-excursion ;; Use point-min and point-max to respect narrowing. (indent-region (point-min) (point-max)))) ;; Note: In keybinding s means cmd (super). ;; Use hooks to add key bindings to a particular mode only. ;; Hooks for racket related modes: ;; racket-mode-hook ;; racket-repl-mode-hook ;; racket-repl-mode-map (add-hook 'racket-mode-hook (lambda () (define-key racket-mode-map (kbd "M-&lt;left&gt;") #'backward-sexp) (define-key racket-mode-map (kbd "M-&lt;right&gt;") #'forward-sexp) (define-key racket-mode-map (kbd "s-r") #'my-racket-run-from-editor) (define-key racket-mode-map (kbd "s-e") #'racket-repl) (define-key racket-mode-map (kbd "s-d") #'my-racket-switch-from-editor-to-repl) (define-key racket-mode-map (kbd "s-i") #'my-racket-indent-whole-buffer) (define-key racket-mode-map (kbd "s-&lt;left&gt;") #'move-beginning-of-line) (define-key racket-mode-map (kbd "s-&lt;right&gt;") #'move-end-of-line) (define-key racket-mode-map (kbd "s-&lt;down&gt;") #'scroll-up-command) (show-paren-mode))) (add-hook 'racket-repl-mode-hook (lambda () (define-key racket-repl-mode-map (kbd "s-e") #'my-racket-switch-from-repl-to-editor) (define-key racket-repl-mode-map (kbd "s-d") #'delete-other-windows))) (add-hook 'racket-repl-mode-hook #'racket-unicode-input-method-enable) (add-hook 'racket-mode-hook #'racket-unicode-input-method-enable) ;; Use global-set-key to add global key bindings ; (global-set-key (quote [f1]] (quote help-for-help)) ;;; ;;; Customization ;;; (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. '(ansi-color-faces-vector [default default default italic underline success warning error]) '(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"]) '(column-number-mode t) '(custom-safe-themes (quote ("0598c6a29e13e7112cfbc2f523e31927ab7dce56ebb2016b567e1eff6dc1fd4f" "d91ef4e714f05fff2070da7ca452980999f5361209e679ee988e3c432df24347" default))) '(default-input-method "math") '(line-number-mode nil) '(package-selected-packages (quote (math-symbol-lists markdown-preview-mode markdown-mode powerline solarized-theme tabbar racket-mode))) '(racket-program "/Applications/Racket v7.5/bin/racket") '(racket-raco-program "/Applications/Racket v7.5/bin/raco") '(show-paren-mode t) '(tabbar-background-color "gray20") '(tabbar-mode t nil (tabbar)) '(tabbar-separator (quote (0.5))) '(tabbar-use-images nil) '(tool-bar-mode nil)) (custom-set-faces ;; custom-set-faces 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. ) (put 'narrow-to-region 'disabled nil)


chris613
2020-1-29 11:25:23

awesome thanks


mflatt
2020-1-29 12:52:22

make client-from-site does use distro-build, but only the distro-build-client subset. Note that it’s going to build a fresh Racket executable, and only use the existing site for its packages. Nothing will start out signed.


mflatt
2020-1-29 12:53:54

The makefile variables SIGN_IDENTITY (Mac OS) and OSSLSIGNCODE_ARGS_BASE64 (Windows) trigger the signing steps that distro-build-client knows how to take. That doesn’t cover notarization on Mac OS, though.


gknauth
2020-1-29 13:09:11

Yes, thanks for all these!


soegaard2
2020-1-29 13:42:07

The keybindings were an attempt to get something close to the keybindings I was used to from DrRacket.


greg
2020-1-29 14:11:53

Another Emacs-y approach is to use M-x compile, which prompts you for some command, saves all your files, then does the command displaying the output. If there are error messages, then M-x next-error takes you to each one.


greg
2020-1-29 14:12:52

When it prompts you for the command, it remembers what you typed last time (indeed there’s a whole history fi you want) so you can normally just press return. So that’s pretty easy, I find.


chris613
2020-1-29 14:12:59

@greg ahhh the compile will auto save all buffers?


greg
2020-1-29 14:13:04

Yep.


greg
2020-1-29 14:13:26

The command could be something like “racket main.rkt”.


chris613
2020-1-29 14:13:38

i might try an figure that out then (as spacemacs has a lot of “of the shelf” stuff like that)


greg
2020-1-29 14:13:53

Or raco setup &amp;&amp; do-something-to-run. Or make if you have a Makefile.


greg
2020-1-29 14:15:58

Depending on how big your project is, and if it’s a package you’re releasing, you might even want to make a simple Makefile for it e.g. https://www.greghendershott.com/2017/04/racket-makefiles.html