Emacs org-mode

  • 寫筆記
  • 做 Todo
  • 寫文章
  • 做計畫

Youtube 影片

基本語法

  • Outlines
  • bold italic verbatim, strikethrough
  • bulleted
    • list
    • items
  • links My Website
  • store link

Table

name email address
Jerry [email protected] xxx
Tim [email protected] yyy

Export to other format (C-c C-e)

source code

def fact(n)
  if n == 0
    1
  else
    n * fact(n - 1)
  end
end

org embed youtube

(defvar yt-iframe-format
;; You may want to change your width and height.
(concat ““))

(org-add-link-type
“yt”
(lambda (handle)
(browse-url
(concat “https://www.youtube.com/embed/”
handle)))
(lambda (path desc backend)
(cl-case backend
(html (format yt-iframe-format
path (or desc “”)))
(latex (format “\href{%s}{%s}”
path (or desc “video”))))))

Latex integration

  • characters: α → β
  • O(n \log n)

\begin{align*} 3 * 2 + 1 &= 6 + 1 &= 7 \end{align*}

有關 Latex 中文支援 (Mac OS)

  • Mac 最小安裝
    brew tap phinze/cask
    brew install brew-cask
    brew cask install basictex
    
  • 加 path
    # bash/zsh 等
    export PATH=/Library/TeX/texbin/:$PATH
    
  • 安裝中文 CTeX
    sudo tlmgr update --self --all
    sudo tlmgr install ctex environ trimspaces zhnumber
    sudo tlmgr install wrapfig capt-of
    
  • 在 org file 前加入
    #+LATEX_HEADER: \usepackage{ctex}
    #+LATEX_COMPILER: xelatex
    
  • 加入

    (defvar use-font (cond
    ((eq system-type ‘gnu/linux) “{Noto Sans TC Regular}”)
    ((eq system-type ‘darwin) “{PingFang TC}”)))

    (setq org-latex-classes (list (list “article” (format ”
    \\documentclass[12pt,a4paper]{article}
    \\usepackage{xeCJK}
    \\setCJKmainfont%s
    \\setCJKsansfont%s
    \\setCJKmonofont%s
    ” use-font use-font use-font))))

Literate Programming

(org-babel-load-file "~/.emacs.d/configuration.org")

(use-package org
:ensure t
:mode ((“\\.org\\'” . org-mode)
(“\\.txt\\'” . org-mode))
:config
(global-set-key (kbd “\C-c l”) ‘org-store-link)
(global-set-key (kbd “\C-c a”) ‘org-agenda)
(global-set-key (kbd “\C-c c”) ‘org-capture)
(setq org-hide-leading-stars t)
(setq org-src-fontify-natively t)
(setq org-log-done ‘time)
(setq org-agenda-files (list “~/org/todo.org”
“~/org/gcal.org”))
(use-package org-download
:ensure t)
(use-package org-bullets
:ensure t
:hook (org-mode . org-bullets-mode))
(org-babel-do-load-languages ‘org-babel-load-languages
‘((shell . t)
(python . t)
(sqlite . t)
(perl . t)
(C . t)
(ruby . t)
(js . t)
(emacs-lisp . t)
(lisp . t)
(latex . t)
(java . t)))
)

org2blog 直接寫部落格

  • 因 xml-rpc 不相容於 unicode, 需置換 unicode support
  • emacs-lisp 的 syntax highlight 參考 https://vxlabs.com/tag/syntaxhighlighter/
    • 加入 shBrushLips.jswp-content/plugins/syntaxhighlighter
    • 修改 syntaxhighlighter.php 插入
      // ...
      wp_register_script('syntaxhighlighter-brush-lisp', plugins_url('shBrushLisp.js',__FILE__),array('syntaxhighlighter-core'),'1.0.0');
      // ...
      $this->brushes = (array) apply_filters( 'syntaxhighlighter_brushes', array(
      'as3' => 'as3',
      <bunch of other aliases>,
      'lisp' => 'lisp',
      'emacs-lisp' => 'lisp',
      
  • 設定

    (use-package org2blog
    :ensure t
    :requires org
    :init
    (setq org2blog/wp-blog-alist
    ‘((“wordpress”
    :url “https://jerryhsieh01.wordpress.com/xmlrpc.php”
    :username “jerryhsieh01”
    )
    (“my-blog”
    :url “https://blog.onionstudio.com.tw/xmlrpc.php”
    :username “Jerry”
    )))
    :config
    (setq org2blog/wp-use-sourcecode-shortcode t)
    (setq org2blog/wp-sourcecode-langs
    ‘(“sh” “cpp” “css” “js” “javascript” “perl” “php” “python” “ruby” “emacs-lisp” “lisp” “go” “lua”))
    )

Todo

介紹 Todo

循環不同的狀態

Org Capture

(setq org-default-notes-file (concat org-directory “/notes.org”))
(setq org-agenda-files (list “~/org/gtd.org”
“~/org/gcal.org”
“~/org/blog.org”
))
(setq org-capture-templates
‘((“t” “Todo” entry (file+headline “~/org/gtd.org” “Tasks”)
“* TODO %?\n %i\n %a”)
(“j” “Journal” entry (file+olp+datetree “~/org/journal.org”)
“* %?\nEntered on %U\n %i\n %a”)
(“b” “Blog” entry (file+headline “~/org/blog.org”)
“* %?\n%T” :prepend t)
(“a” “Appointment” entry (file “~/org/gcal.org”)
“* %?\n\n%^T\n\n:PROPERTIES:\n\n:END:\n\n”)))

Sync with Google Calendar

(use-package auth-source
:ensure t
)
(use-package org-gcal
:ensure t
:config
(let (credentials)
(add-to-list ‘auth-sources “~/.netrc”)
(setq credentials (auth-source-user-and-password “org-gcal”))
(setq org-gcal-client-id (car credentials)
org-gcal-client-secret (cadr credentials)
org-gcal-file-alist ‘((“[email protected]” . “~/org/gcal.org”))
))
(add-hook ‘org-agenda-mode-hook (lambda () (org-gcal-sync) ))
(add-hook ‘org-capture-after-finalize-hook (lambda () (org-gcal-sync) ))
)

  • you need to add .netrc file
    machine org-gcal client-id xxxx secret yyyy
    

Org Reveal

  • 做簡報

    (use-package ox-reveal
    :ensure t
    )

Notice: compact(): Undefined variable: limits in /var/www/html/wp-includes/class-wp-comment-query.php on line 853 Notice: compact(): Undefined variable: groupby in /var/www/html/wp-includes/class-wp-comment-query.php on line 853

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *