RIP TO A REAL 1

1 Elisp

1.1 Blog Post Fetch Functions

  ;; ---------------------------------------
  ;; 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")

1.2 Using a function to get subtree contents:

(cl-defun get-section(&optional (N 1))
(org-next-visible-heading N)
(my-org-copy-subtree-contents))
(get-section 2)

1.3 Greeting Maddie with a pop-up

  (defun greet-maddie?(x)
    (cond ((string= x "y") (message-box "Good morning, My Docchi!"))
	   ))

(greet-maddie? "y")