-;; Time-stamp: <2015-06-17 11:39:05 kmodi>
+;; Time-stamp: <2015-07-16 12:35:51 kmodi>
 
 ;; Outshine
 ;; https://github.com/tj64/outshine

          (while (re-search-forward
                  (concat "^\\(?1:" ; beginning of line
                          outline-comment-start
                          "\\s-\\{1\\}\\)" ; SINGLE white space
                          "\\*\\(?2:\\**\\) " ; one or more * chars followed by space
                          "\\(?3:.+\\)") ; followed by heading
                  nil :noerror)
            (setq parsed-outline-comment-start (match-string-no-properties 1))
            ;; Note that the below `star' var stores one less * than the actual;
            ;; that's intentional
            (setq star                         (match-string-no-properties 2))
            (setq heading                      (match-string-no-properties 3))
            ;; (message "%s %s %s" parsed-outline-comment-start star heading)
            (when (not (string= heading "Revision Control"))
              (setq stars-list    (cons star stars-list))

                           (delete-region p1 p2))))
                     (not (looking-at "^\n"))))
            ;; Then print table of contents
            (let ((content-comment-prefix
                   (if el-mode
                       ";; " ; 2 consecutive ; in `emacs-lisp-mode'
                     parsed-outline-comment-start)))
              (insert (format "%s\n" content-comment-prefix))
              (let ((n 1))
                (dolist (h headings-list)
                  ;; (insert (format "// %2d. %s\n" n heading))
                  (insert (format "%s %s%s\n"
                                  content-comment-prefix
                                  (replace-regexp-in-string
                                   (if el-mode ";" "\\*") "  " (pop stars-list))
                                  h))
                  (setq n (1+ n)))))))))

    (defvar modi/outline-mode-hooks '(verilog-mode-hook
                                      emacs-lisp-mode-hook)
