UP | HOME

Org-Mode Capture 使用
发布于 Aug 17, 2020 by ThinkCat.

Table of Contents

好久不拿org-mode写文字,总是忘记一些快捷键。

现在都是通过emacs来编辑文章,并且一站式发布到github page。虽然这套工作流用了比较久,但是架不住懒,不写东西,还是容易忘。记录一下。

工作流:

  1. C-c c,启用org-mode的capture。这个就是预制的文章模板,预定义了title,keywords,tags。
  2. 执行make [options] 命令预览或者发布到github page。

配置还是列一下,做个备份(虽然git里面已经有了)。

emacs 配置:

;;org
(setq org-html-validation-link nil)
(setq org-html-postamble nil)
(setq org-startup-indented t)
(setq org-startup-with-inline-images t)
(setq org-image-actual-width '(300))
(setq truncate-lines t)
(add-hook 'org-mode-hook 'toggle-truncate-lines)
(use-package org-bullets
  :ensure t
  :config
  (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
  )
(global-set-key (kbd "C-c a") 'org-agenda)

;; org capture
(defun create-blog-post ()
        "Create an org file in ~/source/myblog/posts."
        (interactive)
        (let ((name (read-string "Filename: ")))
        (expand-file-name (format "%s.org" name) "~/Documents/Blog/myblog/posts/")))
(setq org-capture-templates
        '(("p" "Post" plain
                (file create-blog-post)
                (file "~/Documents/Blog/myblog/capture-template/post.orgcaptmpl"))))
(define-key global-map (kbd "C-c c")
  (lambda () (interactive) (org-capture nil "p")))

Makefile 配置:


.PHONY: publish

EMACS = /Applications/Emacs.app/Contents/MacOS/Emacs

ifndef EMACS
EMACS = "emacs"
endif

all: publish deploy sources

publish: publish.el
        @echo "Publishing... with current Emacs configurations."
        ${EMACS} --batch --load publish.el --funcall org-publish-all

preview: 
        @python3.7 -m http.server --directory=public

deploy:
        @echo "Copy CNAME"
        @cp CNAME public/
        @echo "Copy CNAME Ok"
        @echo "Start Push Git Page"
        @cp -rf public/* ~/tmp/public/
        @cd ~/tmp/public && git add . && git commit -m "update" && git push
        @echo "Push Git Page Ok"

publish_no_init: publish.el
        @echo "Publishing... with --no-init."
        ${EMACS} --batch --no-init --load publish.el --funcall org-publish-all

sources:
        @echo "Backup Source"
        @git add . && git commit -m "update" && git push

clean:
        @echo "Cleaning up.."
        @rm -rvf *.elc
        @rm -rvf public
        @rm -rvf ~/.org-timestamps/*