Next: Switch Emacs Init, Previous: Create and Update Projects, Up: Build Scripts [Index]
(defun get-parsed-tree (buf) "Given a buffer BUF, return a parsed tree." (with-current-buffer buf (org-element-parse-buffer 'headline))) (defun oep (p e) "Given a property P and element E, return that property's value." (org-element-property p e)) (defun start-end (buf prop) "Given a buffer BUF and a property PROP, return the starting and ending points." (org-element-map (get-parsed-tree buf) 'headline (lambda (e) (when (string= (oep :CUSTOM_ID e) prop) (list (oep :begin e) (oep :end e)))) nil t)) (defun update-old-project (&optional title author bucket) "Update an old project with new code." (with-current-buffer (car (find-file-noselect "./*.org" nil nil t)) (save-excursion (goto-char (point-min)) ;; (when title ;; (re-search-forward "^#[+]title:\s*\\(.*\\)$") ;; (replace-match title t nil nil 1)) ;; (when author ;; (re-search-forward "^#[+]author:\s*\\(.*\\)$") ;; (replace-match author t nil nil 1)) ;; (when bucket ;; (re-search-forward "^#[+]bucket:\s*\\(.*\\)$") ;; (replace-match bucket t nil nil 1)) (let* ((curbuf (current-buffer)) (orgsyncbuf (find-file-noselect (expand-file-name "Template.org" "/usr/local/dev/Templates/Org"))) (start-end-curbuf (start-end curbuf "build-tools")) (start-end-sync (start-end orgsyncbuf "build-tools"))) (list start-end-curbuf start-end-sync)))))
(update-old-project)
((4928 36833) (4928 36833))