Org-mode is an Emacs mode for note keeping, projecxt planning, TODO lists and authoring. It is included from Emacs 22.1 onward as default. Its Home page is: http://orgmode.org
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. There is also This month in Org which summarizes interesting developments from the Org mode mailing list.
Org-mode is included by default from Emacs 22.1 onward. So no additional steps are required to install it.
However, you can install the latest development version. Clone the repository with:
git clone https://code.orgmode.org/bzg/org-mode.git
Moreover, there is an Ubuntu repository with the latest for non-cvs Emacs. Add the following to your /etc/apt/sources.list
:
deb http://ppa.launchpad.net/hexmode/ubuntu gutsy main deb-src http://ppa.launchpad.net/hexmode/ubuntu gutsy main
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:
If you’re using WindMove, CuaMode or MTorus (with default keybindings), you might want to disable the Org Mode keybindings for Shift+arrow keys:
(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))
Package to change the graphical interface of org-agenda.
Libraries and packages to find a specific portion of an Org text.
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 ‘org-fontify-whole-heading-line’
.
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.
Org-mode can identify other URL schema (such as “gemini” in gemini://geminiprotocol.net/) or any invented (such as “copy+gemini” in “copy+gemini://geminiprotocol.net/”).
The following code is an example to register the gemini schema for all Org-mode buffers. In this case, browse-url will open the registered browser (Elpher or any other) with the URL. The follow function will be called with the URL without the schema. For example, when using C-c C-o at “gemini://geminiprotocol.net”, the “url” parameter will store “//geminiprotocol.net”.
(defun org-geminilinks-switch-link-follow (url &optional arg) "Open gemini link with `browser-url'." (browse-url (concat "gemini:" url) arg)) (org-link-set-parameters "gemini" :follow #'org-geminilinks-switch-link-follow)
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
CategoryOutline CategoryPersonalInformationManager CategoryCalendar CategoryNeedsAttention CategoryWriting CategoryTables CategoryHypermedia