Skip to content

Commit

Permalink
Add command eval
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Mar 19, 2022
1 parent 42c3d24 commit a3d8cd5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
36 changes: 36 additions & 0 deletions cmds/eval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (C) 2022 Jen-Chieh Shen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Emacs; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/

"use strict";

const util = require("../src/util");

exports.command = 'eval [form]';
exports.desc = 'evaluate lisp form with a proper PATH';
exports.builder = {
form: {
description: 'lisp form',
requiresArg: false,
type: 'string',
},
};

exports.handler = async ({ form }) => {
await util.e_call('eval', '\"' + form.replace(/[\\$'"]/g, "\\$&") + '\"');
};
10 changes: 6 additions & 4 deletions lisp/eval.el
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
;;; eval.el --- Print path to package directory -*- lexical-binding: t; -*-
;;; eval.el --- Evaluate lisp form with a proper PATH -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Print path to package directory,
;; Evaluate lisp form with a proper PATH,
;;
;; $ eask eval
;; $ eask eval [form]
;;

;;; Code:
Expand All @@ -14,6 +14,8 @@
(file-name-directory (nth 1 (member "-scriptload" command-line-args)))))

(eask-start
)
(eask-pkg-init)
(let ((form (eask-argv 0)))
(with-temp-buffer (insert form) (eval-buffer))))

;;; eval.el ends here

0 comments on commit a3d8cd5

Please sign in to comment.