From 3251077cc760129314d6c1bed6c2721c4ed2d451 Mon Sep 17 00:00:00 2001 From: System Administrator Date: Wed, 19 Feb 2020 08:13:56 -0800 Subject: [PATCH 1/6] [+] Allow usage of formulador straight from emacs when using roswell --- formulador.el | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 formulador.el diff --git a/formulador.el b/formulador.el new file mode 100644 index 0000000..873df1b --- /dev/null +++ b/formulador.el @@ -0,0 +1,45 @@ + +(require 's) +(require 'pos-tip) + +(defun formulador--import() + (concat + "(load \"" + (concat (current-buffer-path) + "formulador.asd\")\n (require `formulador)" + ) + )) + + +(defmacro formulador--ros-commands (&rest commands) + `(shell-command-to-string + (concat + (concat "ros --eval '" ,@commands) + "'"))) + + +(defmacro formulador-command (&rest commands) + `(let ((command + (car(s-split "with" (car(cdr (s-split ":CANVAS" + (formulador--ros-commands + (concat + ,(formulador--import) ,@commands) + ) + ))))) + )) + (pos-tip-show command) + (kill-new command) + )) + + + + +(formulador-command + + " +(defun pow (a b) + (formulador:script-box a :superscript b)) + +(print (formulador:draw (pow (formulador:box \" | \") (formulador:box \"r\"))))" + ) + From 5648fda4dd5772813534821cb995c85c50bcd5a3 Mon Sep 17 00:00:00 2001 From: Serialdev Date: Wed, 19 Feb 2020 08:20:25 -0800 Subject: [PATCH 2/6] [+] Added usage example & elisp provide --- formulador.el | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/formulador.el b/formulador.el index 873df1b..dd34156 100644 --- a/formulador.el +++ b/formulador.el @@ -1,3 +1,29 @@ +;;; formulador.el --- Allow usage of formulador from within emacs -*- lexical-binding: t -*- + +;; Copyright (C) 2019- Andres Mariscal + +;; Author: Andres Mariscal + +;; URL: https://github.com/serialdev/tiqsi-emacs +;; Keywords: lisp +;; Version: 0 +;; Package-Requires: ((cl-lib "0.5") (emacs "24")) + +;; 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 of the License, 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 this program. If not, see . + + +;;; Commentary: (require 's) (require 'pos-tip) @@ -13,7 +39,7 @@ (defmacro formulador--ros-commands (&rest commands) `(shell-command-to-string - (concat + (concat (concat "ros --eval '" ,@commands) "'"))) @@ -31,15 +57,21 @@ (kill-new command) )) - -(formulador-command +; ------------------------------------------------------------------------- ; +; Usage Example ; +; ------------------------------------------------------------------------- ; + +;; (formulador-command + +;; " +;; (defun pow (a b) +;; (formulador:script-box a :superscript b)) - " -(defun pow (a b) - (formulador:script-box a :superscript b)) +;; (print (formulador:draw (pow (formulador:box \" | \") (formulador:box \"r\"))))" +;; ) -(print (formulador:draw (pow (formulador:box \" | \") (formulador:box \"r\"))))" - ) +(provide 'formulador) +;;; formulador.el ends here From c1a8b3572db4102f44c4aa6acb1fdb38f40e6a84 Mon Sep 17 00:00:00 2001 From: Serialdev Date: Thu, 20 Feb 2020 07:40:21 -0800 Subject: [PATCH 3/6] [+] Automatically handle draw and print calls so its more ergonomic --- formulador.el | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/formulador.el b/formulador.el index dd34156..c69f81f 100644 --- a/formulador.el +++ b/formulador.el @@ -32,7 +32,27 @@ (concat "(load \"" (concat (current-buffer-path) - "formulador.asd\")\n (require `formulador)" + "formulador.asd\")\n (require `formulador) + + +(defun pow (a b) + (formulador:script-box a :superscript b)) + + + +(defun sub (a b) + (formulador:script-box a :subscript b)) + +(defun frak (a b) + (formulador:frac-box (formulador:box a) + (formulador:box b))) + +(defun rowb (a b) + (formulador:row-box (list (formulador:box a) (formulador:box b)))) + +(print +(formulador:draw +" ) )) @@ -49,7 +69,8 @@ (car(s-split "with" (car(cdr (s-split ":CANVAS" (formulador--ros-commands (concat - ,(formulador--import) ,@commands) + ,(formulador--import) + (concat ,@commands " ))")) ) ))))) )) @@ -63,14 +84,9 @@ ; Usage Example ; ; ------------------------------------------------------------------------- ; -;; (formulador-command +;; (formulador-command "(frak \"2\" \"efr\")") -;; " -;; (defun pow (a b) -;; (formulador:script-box a :superscript b)) -;; (print (formulador:draw (pow (formulador:box \" | \") (formulador:box \"r\"))))" -;; ) (provide 'formulador) From d3f632fbe621edeee423c81cdace642e801fe2f8 Mon Sep 17 00:00:00 2001 From: Serialdev Date: Thu, 20 Feb 2020 08:19:54 -0800 Subject: [PATCH 4/6] [+] formulador utility functions and examples --- formulador.el | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/formulador.el b/formulador.el index c69f81f..e1584da 100644 --- a/formulador.el +++ b/formulador.el @@ -36,12 +36,12 @@ (defun pow (a b) - (formulador:script-box a :superscript b)) + (formulador:script-box (formulador:box a) :superscript (formulador:box b ))) (defun sub (a b) - (formulador:script-box a :subscript b)) + (formulador:script-box (formulador:box a) :subscript (formulador:box b))) (defun frak (a b) (formulador:frac-box (formulador:box a) @@ -87,6 +87,41 @@ ;; (formulador-command "(frak \"2\" \"efr\")") +;; (formulador-command +;; " +;; (rowb (frak \"1\" \"2\") (formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E)\")) +;; " +;; ) + +;; (formulador-command "(rowb +;; (frak \"1\" \"2\") (formulador:box\"(i,j)∈E)\" ) +;; )") + + + +;; (formulador-command "(rowb +;; (frak \"1\" \"2\") + +;; (rowb +;; (formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E\") ) + +;; (rowb \"(\" (sub (formulador:box \"W\") (formulador:box \"ij \")) ) + + +;; ) + +;; )") + + +;; +---------------+ +;; | === | +;; | 1 \ | +;; |--- > (W | +;; | 2 / ij | +;; | === | +;; | (i,j)∈E | +;; +---------------+ + (provide 'formulador) From a801b8d6b22c0e0d9dde40e10306462f0fb2d306 Mon Sep 17 00:00:00 2001 From: Serialdev Date: Thu, 27 Feb 2020 03:11:15 -0800 Subject: [PATCH 5/6] [+] fn() Formulador create scratch buffer --- formulador.el | 64 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/formulador.el b/formulador.el index e1584da..36ec8a2 100644 --- a/formulador.el +++ b/formulador.el @@ -56,6 +56,16 @@ ) )) +(defun formulador/scratch () + (interactive) + + (let ((buf (get-buffer-create "*formulador-scratch*" )) + (data (formulador--import))) + (with-current-buffer buf + (pop-to-buffer buf) + (common-lisp-mode) + (insert data) + ))) (defmacro formulador--ros-commands (&rest commands) `(shell-command-to-string @@ -99,20 +109,58 @@ -;; (formulador-command "(rowb -;; (frak \"1\" \"2\") +(formulador-command "(rowb + (frak \"1\" \"2\") -;; (rowb -;; (formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E\") ) +(rowb +(formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E\") ) -;; (rowb \"(\" (sub (formulador:box \"W\") (formulador:box \"ij \")) ) +(rowb (rowb \"(\" (sub (formulador:box \"W\") (formulador:box \"ij \")) ) +(rowb \"-< \" (sub \"Y\" \"i,\" )))) +)) + + +") + + +(formulador-command +" + (rowb + (rowb \"φ(Y,λ) = \" + (frak \"1\" \"2\") ) + + + (rowb + (rowb + (rowb + (formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E\") ) + + + (rowb (rowb + (rowb + + (rowb (rowb \"(\" (sub (formulador:box \"W\") (formulador:box \"ij \")) ) + (rowb \"-< \" (sub \"Y\" \"i,\" ))) + (rowb + (sub \"Y\" \"j\" ) + (pow \">(\" \"2\" ))) + (rowb \"+\" (formulador:frac-box (formulador:box \"λ\") (formulador:box \"2\") ) )) + + (formulador:limits-box formulador:+sigma+ :below (formulador:box \"i\") )) + + + ) + (rowb \"||\" (sub \"Y\" \"i\"))) + (rowb \"|\" (rowb (pow \"|\" \"2\") \",\"))) + + ) + +" + ) -;; ) -;; )") - ;; +---------------+ ;; | === | ;; | 1 \ | From 2ff2f5a6dce96e3419dd61d2f560216c8dfedf6b Mon Sep 17 00:00:00 2001 From: root Date: Sat, 29 Feb 2020 08:44:45 +0000 Subject: [PATCH 6/6] [!] Use only standard elisp functionality --- formulador.el | 340 ++++++++++++++++++++++++-------------------------- 1 file changed, 164 insertions(+), 176 deletions(-) diff --git a/formulador.el b/formulador.el index 36ec8a2..bcff5f6 100644 --- a/formulador.el +++ b/formulador.el @@ -1,176 +1,164 @@ -;;; formulador.el --- Allow usage of formulador from within emacs -*- lexical-binding: t -*- - -;; Copyright (C) 2019- Andres Mariscal - -;; Author: Andres Mariscal - -;; URL: https://github.com/serialdev/tiqsi-emacs -;; Keywords: lisp -;; Version: 0 -;; Package-Requires: ((cl-lib "0.5") (emacs "24")) - -;; 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 of the License, 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 this program. If not, see . - - -;;; Commentary: - -(require 's) -(require 'pos-tip) - -(defun formulador--import() - (concat - "(load \"" - (concat (current-buffer-path) - "formulador.asd\")\n (require `formulador) - - -(defun pow (a b) - (formulador:script-box (formulador:box a) :superscript (formulador:box b ))) - - - -(defun sub (a b) - (formulador:script-box (formulador:box a) :subscript (formulador:box b))) - -(defun frak (a b) - (formulador:frac-box (formulador:box a) - (formulador:box b))) - -(defun rowb (a b) - (formulador:row-box (list (formulador:box a) (formulador:box b)))) - -(print -(formulador:draw -" - ) - )) - -(defun formulador/scratch () - (interactive) - - (let ((buf (get-buffer-create "*formulador-scratch*" )) - (data (formulador--import))) - (with-current-buffer buf - (pop-to-buffer buf) - (common-lisp-mode) - (insert data) - ))) - -(defmacro formulador--ros-commands (&rest commands) - `(shell-command-to-string - (concat - (concat "ros --eval '" ,@commands) - "'"))) - - -(defmacro formulador-command (&rest commands) - `(let ((command - (car(s-split "with" (car(cdr (s-split ":CANVAS" - (formulador--ros-commands - (concat - ,(formulador--import) - (concat ,@commands " ))")) - ) - ))))) - )) - (pos-tip-show command) - (kill-new command) - )) - - - -; ------------------------------------------------------------------------- ; -; Usage Example ; -; ------------------------------------------------------------------------- ; - -;; (formulador-command "(frak \"2\" \"efr\")") - - -;; (formulador-command -;; " -;; (rowb (frak \"1\" \"2\") (formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E)\")) -;; " -;; ) - -;; (formulador-command "(rowb -;; (frak \"1\" \"2\") (formulador:box\"(i,j)∈E)\" ) -;; )") - - - -(formulador-command "(rowb - (frak \"1\" \"2\") - -(rowb -(formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E\") ) - -(rowb (rowb \"(\" (sub (formulador:box \"W\") (formulador:box \"ij \")) ) -(rowb \"-< \" (sub \"Y\" \"i,\" )))) - -)) - - -") - - -(formulador-command -" - (rowb - (rowb \"φ(Y,λ) = \" - (frak \"1\" \"2\") ) - - - (rowb - (rowb - (rowb - (formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E\") ) - - - (rowb (rowb - (rowb - - (rowb (rowb \"(\" (sub (formulador:box \"W\") (formulador:box \"ij \")) ) - (rowb \"-< \" (sub \"Y\" \"i,\" ))) - (rowb - (sub \"Y\" \"j\" ) - (pow \">(\" \"2\" ))) - (rowb \"+\" (formulador:frac-box (formulador:box \"λ\") (formulador:box \"2\") ) )) - - (formulador:limits-box formulador:+sigma+ :below (formulador:box \"i\") )) - - - ) - (rowb \"||\" (sub \"Y\" \"i\"))) - (rowb \"|\" (rowb (pow \"|\" \"2\") \",\"))) - - ) - -" - ) - - - -;; +---------------+ -;; | === | -;; | 1 \ | -;; |--- > (W | -;; | 2 / ij | -;; | === | -;; | (i,j)∈E | -;; +---------------+ - - -(provide 'formulador) - -;;; formulador.el ends here +;;; formulador.el --- Allow usage of formulador from within emacs -*- lexical-binding: t -*- + +;; Copyright (C) 2019- Andres Mariscal + +;; Author: Andres Mariscal + +;; URL: https://github.com/serialdev/tiqsi-emacs +;; Keywords: lisp +;; Version: 0 +;; Package-Requires: ((cl-lib "0.5") (emacs "24")) + +;; 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 of the License, 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 this program. If not, see . + + +;;; Commentary: + +(require 's) + + +(defun current-buffer-path() + (file-name-directory (buffer-file-name))) + + +(defun formulador--import() + (concat + "(load \"" + (concat (current-buffer-path) + "formulador.asd\")\n (require `formulador) + + +(defun pow (a b) + (formulador:script-box (formulador:box a) :superscript (formulador:box b ))) + + + +(defun sub (a b) + (formulador:script-box (formulador:box a) :subscript (formulador:box b))) + +(defun frak (a b) + (formulador:frac-box (formulador:box a) + (formulador:box b))) + +(defun rowb (a b) + (formulador:row-box (list (formulador:box a) (formulador:box b)))) + +(print +(formulador:draw +" + ) + )) + +(defun formulador/scratch () + (interactive) + (let ((buf (get-buffer-create "*formulador-scratch*" )) + (data (formulador--import))) + (with-current-buffer buf + (pop-to-buffer buf) + (common-lisp-mode) + (insert data) + ))) + +(defmacro formulador--ros-commands (&rest commands) + `(shell-command-to-string + (concat + (concat "ros --eval '" ,@commands) + "'"))) + + +(defmacro formulador-command (&rest commands) + `(let ((command + (car(s-split "with" + (car + (cdr + (s-split ":CANVAS" + (formulador--ros-commands + (concat + ,(formulador--import) + (concat ,@commands " ))")) + )))))))) + (message command) + (kill-new command) + )) + + + +; ------------------------------------------------------------------------- ; +; Usage Example ; +; ------------------------------------------------------------------------- ; + +;; (formulador-command "(frak \"2\" \"efr\")") + + +;; (formulador-command +;; " +;; (rowb (frak \"1\" \"2\") (formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E)\")) +;; " +;; ) + +;; (formulador-command "(rowb +;; (frak \"1\" \"2\") (formulador:box\"(i,j)∈E)\" ) +;; )") + + +;; (formulador-command +;; " +;; (rowb +;; (rowb \"φ(Y,λ) = \" +;; (frak \"1\" \"2\") ) + + +;; (rowb +;; (rowb +;; (rowb +;; (formulador:limits-box formulador:+sigma+ :below (formulador:box \"(i,j)∈E\") ) + + +;; (rowb (rowb +;; (rowb + +;; (rowb (rowb \"(\" (sub (formulador:box \"W\") (formulador:box \"ij \")) ) +;; (rowb \"-< \" (sub \"Y\" \"i,\" ))) +;; (rowb +;; (sub \"Y\" \"j\" ) +;; (pow \">(\" \"2\" ))) +;; (rowb \"+\" (formulador:frac-box (formulador:box \"λ\") (formulador:box \"2\") ) )) + +;; (formulador:limits-box formulador:+sigma+ :below (formulador:box \"i\") )) + + +;; ) +;; (rowb \"||\" (sub \"Y\" \"i\"))) +;; (rowb \"|\" (rowb (pow \"|\" \"2\") \",\"))) + +;; ) + +;; " +;; ) + + + +;; +---------------+ +;; | === | +;; | 1 \ | +;; |--- > (W | +;; | 2 / ij | +;; | === | +;; | (i,j)∈E | +;; +---------------+ + + +(provide 'formulador) + +;;; formulador.el ends here