Sergey Astanin  committed f18b2fd

obraz.el: Add <Write a new post> button on the top of list of posts

  • Participants
  • Parent commits 84cc51c

Comments (0)

Files changed (1)

File emacs/obraz.el

     (obraz:open-post file-path post-title tags-list)))
+(defun obraz:new-post-in-blog (post-title tags)
+  "Asks for post title and tags, and creates a new post file in a
+  blog location bound to *obraz:current-blog-location* dynamic variable."
+  (interactive "sPost title: \nsTags (white-space separated): ")
+  (when *obraz:current-blog-location*
+    (obraz:new-post *obraz:current-blog-location*  post-title tags)))
 (defun obraz:parse-header (header)
     (let* ((title (and (string-match "title: \\([^\r\n]+\\)" header)
                          'file   (get 'file p)
                          'face   `((:underline nil)))
           (goto-char (point-min))))
+      (let ((new-post-label (format "%s  %s\n" "---------- --:--:--" "< Write a new post >")))
+        (insert-button new-post-label
+                       'action (lambda (x)
+                                 (let ((*obraz:current-blog-location* (button-get x 'blog-path)))
+                                   (call-interactively 'obraz:new-post-in-blog)))
+                       'blog-path blog-path
+                       'face   `((:underline nil)))
+        (goto-char (point-min)))
       (read-only-mode 't)
       (set-buffer-modified-p nil)
       (if (fboundp 'hl-line-mode)