From 866030bdc6664fcd39fb50bbe5e9c8839c113f73 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 14 May 2018 01:22:33 +0200 Subject: [PATCH] feature/eval: reorganize; move settings into init.el --- modules/feature/eval/autoload/repl.el | 3 ++ modules/feature/eval/config.el | 52 ++------------------------- modules/feature/eval/init.el | 50 ++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 49 deletions(-) create mode 100644 modules/feature/eval/init.el diff --git a/modules/feature/eval/autoload/repl.el b/modules/feature/eval/autoload/repl.el index 687af1503..65cb3a63d 100644 --- a/modules/feature/eval/autoload/repl.el +++ b/modules/feature/eval/autoload/repl.el @@ -3,6 +3,9 @@ (defvar +eval-repl-buffer nil "The buffer of the last open repl.") +(define-minor-mode +eval-repl-mode + "A minor mode for REPL buffers.") + (defun +eval--ensure-in-repl-buffer (&optional command same-window-p) (cond ((eq (current-buffer) +eval-repl-buffer)) ((and +eval-repl-buffer diff --git a/modules/feature/eval/config.el b/modules/feature/eval/config.el index 3bf95ebf3..72b086d15 100644 --- a/modules/feature/eval/config.el +++ b/modules/feature/eval/config.el @@ -1,59 +1,13 @@ ;;; feature/eval/config.el -*- lexical-binding: t; -*- -;; -;; REPLs -;; - -(defvar +eval-repls nil - "An alist mapping major modes to plists that describe REPLs. Used by -`+eval/open-repl' and filled with the `:repl' setting.") - -(define-minor-mode +eval-repl-mode - "A minor mode for REPL buffers.") - -(def-setting! :repl (mode command) - "Define a REPL for a mode. MODE is a major mode symbol and COMMAND is a -function that creates and returns the REPL buffer." - `(push (cons ,mode ,command) +eval-repls)) - - -;; -;; Evaluation -;; - ;; remove ellipsis when printing sexps in message buffer (setq eval-expression-print-length nil eval-expression-print-level nil) -(defvar +eval-runners nil - "Alist mapping major modes to interactive runner functions.") -(def-setting! :eval (mode command) - "Define a code evaluator for major mode MODE with `quickrun'. - -1. If MODE is a string and COMMAND is the string, MODE is a file regexp and - COMMAND is a string key for an entry in `quickrun-file-alist'. -2. If MODE is not a string and COMMAND is a string, MODE is a major-mode symbol - and COMMAND is a key (for `quickrun--language-alist'), and will be registered - in `quickrun--major-mode-alist'. -3. If MODE is not a string and COMMAND is an alist, see `quickrun-add-command': - (quickrun-add-command MODE COMMAND :mode MODE). -4. If MODE is not a string and COMMANd is a symbol, add it to - `+eval-runners', which is used by `+eval/region'." - (let ((command (doom-unquote command))) - (cond ((symbolp command) - `(push (cons ,mode ',command) +eval-runners)) - ((stringp command) - `(after! quickrun - (push (cons ,mode ',command) - ,(if (stringp mode) - 'quickrun-file-alist - 'quickrun--major-mode-alist)))) - ((listp command) - `(after! quickrun - (quickrun-add-command - ,(symbol-name (doom-unquote mode)) - ',command :mode ,mode)))))) +;; +;; Plugin(s) +;; (def-package! quickrun :commands (quickrun diff --git a/modules/feature/eval/init.el b/modules/feature/eval/init.el new file mode 100644 index 000000000..291df33d4 --- /dev/null +++ b/modules/feature/eval/init.el @@ -0,0 +1,50 @@ +;;; feature/eval/init.el -*- lexical-binding: t; -*- + +;; +;; REPLs +;; + +(defvar +eval-repls nil + "An alist mapping major modes to plists that describe REPLs. Used by +`+eval/open-repl' and filled with the `:repl' setting.") + +(def-setting! :repl (mode command) + "Define a REPL for a mode. MODE is a major mode symbol and COMMAND is a +function that creates and returns the REPL buffer." + `(push (cons ,mode ,command) +eval-repls)) + + +;; +;; Evaluation +;; + + +(defvar +eval-runners nil + "Alist mapping major modes to interactive runner functions.") + +(def-setting! :eval (mode command) + "Define a code evaluator for major mode MODE with `quickrun'. + +1. If MODE is a string and COMMAND is the string, MODE is a file regexp and + COMMAND is a string key for an entry in `quickrun-file-alist'. +2. If MODE is not a string and COMMAND is a string, MODE is a major-mode symbol + and COMMAND is a key (for `quickrun--language-alist'), and will be registered + in `quickrun--major-mode-alist'. +3. If MODE is not a string and COMMAND is an alist, see `quickrun-add-command': + (quickrun-add-command MODE COMMAND :mode MODE). +4. If MODE is not a string and COMMANd is a symbol, add it to + `+eval-runners', which is used by `+eval/region'." + (let ((command (doom-unquote command))) + (cond ((symbolp command) + `(push (cons ,mode ',command) +eval-runners)) + ((stringp command) + `(after! quickrun + (push (cons ,mode ',command) + ,(if (stringp mode) + 'quickrun-file-alist + 'quickrun--major-mode-alist)))) + ((listp command) + `(after! quickrun + (quickrun-add-command + ,(symbol-name (doom-unquote mode)) + ',command :mode ,mode))))))