Org-mode is an Emacs mode for note keeping, project planning, TODO lists and authoring. It is included from Emacs 22.1 onward as default.
Org-mode’s manual, compact guide, the community maintained Worg (which includes tutorials, ideas, code snippets, Org Syntax, etc.,) and can be accessed at its homepage. Paperback manual is also available.
The development version is at:
git clone https://code.orgmode.org/bzg/org-mode.git
There is a Ubuntu repository with the latest for non-cvs Emacs. Add the following to your
deb http://ppa.launchpad.net/hexmode/ubuntu gutsy main deb-src http://ppa.launchpad.net/hexmode/ubuntu gutsy main
David O’Toole has written a general tutorial with screenshots. It has been translated into Chinese, French, Hungarian, Japanese and Korean. Worg has many tutorials on specific features. Charles Cave has has written on using date and times. Bernt Hansen describes his use and customizations of Org-mode in 70(!) pages long document, which assumes basic familiarity with Org.
One of the major influences in 2006/2007 on task organization has been the book Getting Things Done (GTD). Using Org-mode for GTD has been described by Charles Cave and a modest example configuration has been given here.
You can publish to HTML using
‘C-c C-e h’, or you can use BhlMode for LaTeX or HTML output. Just switch modes before exporting (
‘M-x bhl-mode’). BhlMode should automatically recognize the asterisks as marking sections and subsections. See EmacsOutlineToHtml for other alternatives.
org-publish.el (this comes in the latest version of org-mode) by DavidOtoole is a publishing management system for creating websites composed of all the files within a project (including OrgMode files, images, and source code, if desired).
Obviously, default HTML output does not look nice at all. Here are some themes you can use:
(setq org-replace-disputed-keys t)
(This need to be done before org.el is loaded, or requires a restart of Emacs to be effective.)
This will result in the following replacements:
If AllOut from Emacs 21 is loaded before org.el, you will be getting a
Wrong type argument ((keymapp nil)) error. This was fixed in Emacs 22.
If you are forced to use Emacs 21, either install a newer version of allout.el, or make sure that org.el is loaded before allout.el. For example, use
(require 'org) before requiring allout.
If you’re using session.el (EmacsSession), you need to excempt a circular data structure from saving:
(add-to-list 'session-globals-exclude 'org-mark-ring)
If you’re using Emacs 23 and Org 7.5, then you can also have some pseudo-compatability while maintaining CUA support with Lisp:org-cua-dwim.el
If you publish external sources to org mode agenda files, you’ll need to refresh those files after changes occur. Try this snippet to reload those files.
(defun org-reload () (interactive) (switch-to-buffer "mail.org") (revert-buffer nil 1) (org-agenda nil "a") (delete-other-windows))
This function uses org-mode support for plain list to facilitate dragging URLs from a webbrowser (or other apps) to an org-mode buffer:
(defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate) (if (eq major-mode 'org-mode) (progn (cond ;; if this is the end of the line then just insert text here ((eolp) (skip-chars-backward " \t") (kill-region (point) (point-at-eol)) (unless (looking-back ":") (insert ":")) (insert " ")) ;; if this is the beginning of the line then insert before ((and (looking-at " \\|\t") (save-excursion (skip-chars-backward " \t") (bolp))) (beginning-of-line) (looking-at "[ \t]*") (open-line 1) (indent-to (- (match-end 0) (match-beginning 0))) (insert "+ ")) ;; if this is a middle of the line, then insert after (t (end-of-line) (newline t) (indent-relative) (insert "+ "))) (insert text) (beginning-of-line)) ad-do-it))
(setq org-agenda-files (file-expand-wildcards "~/org/*.org"))
To make header lines more apparently visible in the buffer, set them a background color and change this part of
‘org-set-font-lock-defaults’, so that the header line is drawn across the screen:
;; Headlines '("^\\(\\**\\)\\(\\* \\)\\(.*\xa\\)" (1 (org-get-level-face 1)) (2 (org-get-level-face 2)) (3 (org-get-level-face 3)))
The only change is the `\xa’ character is added before the last closing paren. This feature has been added to org-mode; see
To follow links with RET, rather than a 2 key combo:
(setq org-return-follows-link t)
You can also make TAB follow links in a similar way.
To open links of type [~/test.pdf::3] i.e. open file at page 3:
(delete '("\\.pdf\\'" . default) org-file-apps) (add-to-list 'org-file-apps '("\\.pdf::\\([0-9]+\\)\\'" . "evince \"%s\" -p %1"))
To open a link with a program other than the default(e.g. modify a pdf rather than read it):
(defun my-org-open-at-point() (interactive) (let ((org-file-apps '(("\\.pdf\\'" . "xournal %s")))) (org-open-at-point) ))
Org-Mode provide org-table-sort-lines
C-c ^ to sort all the table lines based on a column. But sometime one need to sort just one column :
(defun org-table-sort-column () "Sort table column at point." (interactive) (let* ((thisline (org-current-line)) (thiscol (org-table-current-column)) (otc org-table-overlay-coordinates) beg end bcol ecol tend tbeg column lns pos) (when (equal thiscol 0) (if (org-called-interactively-p 'any) (setq thiscol (string-to-number (read-string "Use column N for sorting: "))) (setq thiscol 1)) (org-table-goto-column thiscol)) (org-table-check-inside-data-field) (if (org-region-active-p) (progn (setq beg (region-beginning) end (region-end)) (goto-char beg) (setq column (org-table-current-column) beg (point-at-bol)) (goto-char end) (setq end (point-at-bol 2))) (setq column (org-table-current-column) pos (point) tbeg (org-table-begin) tend (org-table-end)) (if (re-search-backward org-table-hline-regexp tbeg t) (setq beg (point-at-bol 2)) (goto-char tbeg) (setq beg (point-at-bol 1))) (goto-char pos) (if (re-search-forward org-table-hline-regexp tend t) (setq end (point-at-bol 1)) (goto-char tend) (setq end (point-at-bol)))) (setq beg (move-marker (make-marker) beg) end (move-marker (make-marker) end)) (untabify beg end) (goto-char beg) (org-table-goto-column column) (skip-chars-backward "^|") (setq bcol (point)) (goto-char end) (previous-line) (org-table-goto-column column) (skip-chars-forward "^|") (setq ecol (point)) (org-table-copy-region bcol ecol nil) (setq lns (mapcar (lambda (x) (cons (org-sort-remove-invisible (substring-no-properties x) ) x)) ( mapcar 'car org-table-clip))) (setq lns (org-do-sort lns "Column" )) (setq org-table-clip (mapcar 'list (mapcar 'cdr lns))) (goto-char beg) (org-table-goto-column column) (org-table-paste-rectangle) (org-goto-line thisline) (org-table-goto-column thiscol) (when otc (org-table-toggle-coordinate-overlays)) (message "%d element sorted in column %d" (length lns) column)))
Org Mode can be easily configured to help edit Wikipedia articles by changing outline-regexp in the mode hook:
(add-hook 'org-mode-hook '(lambda () (setq outline-regexp "=+")))
If you use WThreeM, add the following instead:
(setq w3m-form-textarea-edit-mode 'org-mode) (add-hook 'w3m-form-input-textarea-mode-hook '(lambda nil (setq outline-regexp "=+")))
This snippet turns
- [X] into ☑ and
- [ ] into ☐.
(defun sacha/org-html-checkbox (checkbox) "Format CHECKBOX into HTML." (case checkbox (on "<span class=\"check\">☑</span>") ; checkbox (checked) (off "<span class=\"checkbox\">☐</span>") (trans "<code>[-]</code>") (t ""))) (defadvice org-html-checkbox (around sacha activate) (setq ad-return-value (sacha/org-html-checkbox (ad-get-arg 0))))
The following codes allow refile to opened orgmode buffer files. (Currently set at level 1, to avoid too many refile targets when there are lots of orgmode files opened).
(defun ixp/org-buffer-files () "Return list of opened orgmode buffer files" (mapcar (function buffer-file-name) (org-buffer-list 'files))) (setq org-refile-targets (quote ((nil :maxlevel . 3) (ixp/org-buffer-files :maxlevel . 1) (org-agenda-files :maxlevel . 3))))
The following code snippet allows you to run
org-todo as though it had been executed at some prior time that is interactively selected using
org-read-date. This is particularly useful if you use the org-habits module and you are late to file the completion of a habit. If you complete the habit with org-todo it will be completed for the current day, and scheduled to repeat at the next repeat interval based on the current date. If you use
org-todo-at-date and set the appropriate date, the task will be scheduled to repeat as though the task had been completed on the specified date.
(defun org-todo-at-date (date) (interactive (list (org-time-string-to-time (org-read-date)))) (cl-flet ((org-current-effective-time (&rest r) date) (org-today (&rest r) (time-to-days date))) (org-todo)))
Discussion moved to Talk page