Created
January 1, 2014 18:16
-
-
Save vermiculus/8210123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'cl) ; place your cursor after this paren and pres C-x C-e | |
(defun **strip-stuff (file &optional environments) | |
"Takes the current file and strips every environment from | |
`ENVIRONMENTS` into `FILE`." | |
(interactive "FFile name: \nxList of Environments (\"one\" \"two\" \"etc\"): ") | |
(if (every 'stringp environments) | |
(progn | |
(beginning-of-buffer) | |
(let ((search-regex (concat "\\\\begin{" | |
(mapconcat 'identity | |
environments | |
"\\|") | |
"}"))) | |
(while (search-forward-regexp search-regex nil t) | |
(LaTeX-mark-environment) | |
(copy-region-as-kill (point) (mark)) | |
(save-excursion | |
(find-file file) | |
(end-of-buffer) | |
(yank) | |
(newline 2) | |
(save-buffer) | |
(previous-buffer)) | |
(exchange-point-and-mark))) | |
(message "Strip complete. Check %s for the output." file)) | |
(message (concat "The environment variable you provided" | |
" was not a list of strings.")))) ; here too |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment