Last active
December 30, 2015 22:09
-
-
Save cehter/7892706 to your computer and use it in GitHub Desktop.
To generate a shopping-list for the recipes I want to cook.
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
(defun flush-blank-lines () | |
"Removes all blank lines from buffer or region" | |
(interactive) | |
(save-excursion | |
(let (min max) | |
(if (equal (region-active-p) nil) | |
(mark-whole-buffer)) | |
(setq min (region-beginning) max (region-end)) | |
(flush-lines "^ *$" min max t)))) | |
(defun food/gen-shopping-list () | |
(interactive) | |
(goto-line 0) | |
(let ((start-shopping-list (search-forward "* Einkaufsliste" nil t))) | |
(while (search-forward "** TOCOOK" nil t) | |
(show-subtree) | |
(outline-next-visible-heading 1) | |
(next-line) | |
(let ((start (point))) | |
(outline-next-visible-heading 1) | |
;;(previous-line) | |
(copy-region-as-kill start (point))) | |
(save-excursion | |
(goto-char start-shopping-list) | |
(newline) | |
(yank) | |
(show-subtree) | |
(delete-blank-lines))) | |
(goto-char start-shopping-list) | |
(org-mark-subtree) | |
(next-line) | |
(flush-blank-lines)) | |
(org-table-align) | |
(previous-line) | |
(org-shifttab)) | |
(defun food/clear-shopping-list () | |
(interactive) | |
(save-excursion | |
(goto-line 0) | |
(let ((start-shopping-list (search-forward "* Einkaufsliste" nil t))) | |
(show-subtree) | |
(outline-next-visible-heading 1) | |
(previous-line) | |
(end-of-line) | |
(kill-region start-shopping-list (point))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment