Skip to content

Commit

Permalink
added elips file to edit mlx
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierr committed Jan 22, 2024
1 parent 49f6aa1 commit e739e4d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Documentation/utils/util.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

(defun edit-mlx (mlxfilename editfunc)
"Unpack mlxfilename in a the directory Temp (should be created
apriori), run the function editfunc in the matlab/document.xml
file, pack the result again and delete the unpacked files in
Temp."
(let ((command-str ""))
(setq command-str (concat "unzip " mlxfilename " -d Temp\n"))
(shell-command command-str)
(with-temp-buffer
(insert-file "Temp/matlab/document.xml")
(beginning-of-buffer)
(funcall editfunc)
(write-region (point-min) (point-max) "Temp/matlab/document.xml")
)
(setq command-str "cd Temp \n")
(setq command-str (concat command-str "zip -r temp.mlx * \n"))
(setq command-str (concat command-str "mv temp.mlx .. \n"))
(setq command-str (concat command-str "cd .. \n"))
(setq command-str (concat command-str "rm -r Temp/* \n"))
(shell-command command-str)
)
)


;; example
(defun editfunc ()
(while (re-search-forward (rx "Introduction") nil t)
(replace-match "hello")
)
)

;; example
;; (edit-and-compress "tutorial_2_changing_control_protocol_live.mlx" #'editfunc)


0 comments on commit e739e4d

Please sign in to comment.