;; ---------------------------------------
;; Blog Post Fetch Functions
;; ---------------------------------------
(cl-defun get-headings(&optional (N 5))
(setq my-list '())
(if (org-before-first-heading-p)
(org-next-visible-heading 1))
(while (< 0 N)
(push (get_current_heading_text) my-list)
(org-forward-heading-same-level 1)
(setq N (1- N)))
(print my-list))
(get-headings 2)
(cl-defun reverse-subset-list(_list &optional(N 0))
;; reverse a subset of N elements of a list.
;; If no subset is provided, the subset is the set.
(cl-assert (>= (length _list) N) t
"ERROR: number of elements chosen is larger than length of list.")
(setq _list (seq-subseq _list (- N)))
(setq _newlist '())
(while (> (length _list) 0)
(push (pop _list) _newlist))
(cl-assert (eq _list nil) t
"ERROR: _list still has element on the stack.")
(print _newlist)
)
(cl-defun get-blog-headers(&optional (N 5))
(setq _header-list (get-headings N))
(setq _header-list (reverse-subset-list _header-list N))
(print _header-list))
(get-blog-headers 7)
(org-link-open-from-string
(format "[[%s]]" (expand-file-name "blog-posts.org")))
(re-search-forward "^\*\s.+\n" nil t 5)
(with-temp-buffer
(insert-file-contents "./blog-posts.org")
(while (search-forward-regexp "^\*\s.+\n" nil t 5)
(match-string 0)
))
#+BEGIN_SRC emacs-lisp :exports none
(defun get-string-from-file (filePath)
"Return file content as string."
(with-temp-buffer
(insert-file-contents filePath)
(while (search-forward-regexp "^\*\s.+\n" nil t 5)
(buffer-string))))
(get-string-from-file "./blog-posts.org")