Mercurial > emacs
comparison lisp/textmodes/org.el @ 66987:4da59b0dd54b
(org-table-sort-lines): New command.
(org-tbl-menu): Add entry for `org-table-sort-lines'.
(org-add-file): Command removed, use `org-agenda-file-to-front'
instead.
(org-export-icalendar): Use `org-icalendar-combined-name'.
(org-cycle-agenda-files, org-agenda-file-to-end)
(org-agenda-file-to-front): New commands.
(org-table-tab-jumps-over-hlines,org-export-html-style): New
options.
(org-table-next-field): Use `org-table-tab-jumps-over-hlines'.
(org-at-table.el-p, org-set-autofill-regexps,org-html-protect):
New functions.
(org-fill-paragraph): Call `org-table-align' in tables.
(org-mode): Call `org-set-autofill-regexps'.
(org-export-as-html): Support for local handformatted lists.
Modified to produce valid HTML 4.0. Use `org-export-html-style'.
(org-export-local-list-max-depth): New option.
(org-html-expand): Use `org-html-protect'.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Fri, 18 Nov 2005 16:08:29 +0000 |
parents | 947d92b6000d |
children | 7286e01feef0 |
comparison
equal
deleted
inserted
replaced
66986:24b9342c0182 | 66987:4da59b0dd54b |
---|---|
1 ;;; org.el --- Outline-based notes management and organizer | 1 ;;; org.el --- Outline-based notes management and organize |
2 ;; Carstens outline-mode for keeping track of everything. | 2 ;; Carstens outline-mode for keeping track of everything. |
3 ;; Copyright (c) 2004, 2005 Free Software Foundation | 3 ;; Copyright (c) 2004, 2005 Free Software Foundation |
4 ;; | 4 ;; |
5 ;; Author: Carsten Dominik <dominik at science dot uva dot nl> | 5 ;; Author: Carsten Dominik <dominik at science dot uva dot nl> |
6 ;; Keywords: outlines, hypermedia, calendar | 6 ;; Keywords: outlines, hypermedia, calendar |
7 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ | 7 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ |
8 ;; Version: 3.19 | 8 ;; Version: 3.20 |
9 ;; | 9 ;; |
10 ;; This file is part of GNU Emacs. | 10 ;; This file is part of GNU Emacs. |
11 ;; | 11 ;; |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
13 ;; it under the terms of the GNU General Public License as published by | 13 ;; it under the terms of the GNU General Public License as published by |
78 ;; Org-mode, you can read the same text online as HTML. There is also an | 78 ;; Org-mode, you can read the same text online as HTML. There is also an |
79 ;; excellent reference card made by Philip Rooke. | 79 ;; excellent reference card made by Philip Rooke. |
80 ;; | 80 ;; |
81 ;; Changes: | 81 ;; Changes: |
82 ;; ------- | 82 ;; ------- |
83 ;; Version 3.20 | |
84 ;; - There is finally an option to make TAB jump over horizontal lines | |
85 ;; in tables instead of creating a new line before that line. | |
86 ;; The option is `org-table-tab-jumps-over-hlines', default nil. | |
87 ;; - New command for sorting tables, on `C-c ^'. | |
88 ;; - Changes to the HTML exporter | |
89 ;; - hand-formatted lists are exported correctly, similar to | |
90 ;; markdown lists. Nested lists are possible. See the docstring | |
91 ;; of the variable `org-export-local-list-max-depth'. | |
92 ;; - cleaned up to produce valid HTML 4.0 (transitional). | |
93 ;; - support for cascading style sheets. | |
94 ;; - New command to cycle through all agenda files, on C-, | |
95 ;; - C-c [ can now also be used to change the sequence of agenda files. | |
96 ;; | |
83 ;; Version 3.19 | 97 ;; Version 3.19 |
84 ;; - Bug fixes | 98 ;; - Bug fixes |
85 ;; | 99 ;; |
86 ;; Version 3.18 | 100 ;; Version 3.18 |
87 ;; - Export of calendar information in the standard iCalendar format. | 101 ;; - Export of calendar information in the standard iCalendar format. |
218 (defvar calc-embedded-open-formula) | 232 (defvar calc-embedded-open-formula) |
219 (defvar font-lock-unfontify-region-function) | 233 (defvar font-lock-unfontify-region-function) |
220 | 234 |
221 ;;; Customization variables | 235 ;;; Customization variables |
222 | 236 |
223 (defvar org-version "3.19" | 237 (defvar org-version "3.20" |
224 "The version number of the file org.el.") | 238 "The version number of the file org.el.") |
225 (defun org-version () | 239 (defun org-version () |
226 (interactive) | 240 (interactive) |
227 (message "Org-mode version %s" org-version)) | 241 (message "Org-mode version %s" org-version)) |
228 | 242 |
528 :tag "Org Agenda" | 542 :tag "Org Agenda" |
529 :group 'org) | 543 :group 'org) |
530 | 544 |
531 (defcustom org-agenda-files nil | 545 (defcustom org-agenda-files nil |
532 "A list of org files for agenda/diary display. | 546 "A list of org files for agenda/diary display. |
533 Entries are added to this list with \\[org-add-file] and removed with | 547 Entries are added to this list with \\[org-agenda-file-to-front] and removed with |
534 \\[org-remove-file]. You can also use customize to edit the list." | 548 \\[org-remove-file]. You can also use customize to edit the list." |
535 :group 'org-agenda | 549 :group 'org-agenda |
536 :type '(repeat file)) | 550 :type '(repeat file)) |
537 | 551 |
538 (defcustom org-select-timeline-window t | 552 (defcustom org-select-timeline-window t |
1126 :type '(choice | 1140 :type '(choice |
1127 (const :tag "off" nil) | 1141 (const :tag "off" nil) |
1128 (const :tag "on" t) | 1142 (const :tag "on" t) |
1129 (const :tag "on, optimized" optimized))) | 1143 (const :tag "on, optimized" optimized))) |
1130 | 1144 |
1145 ;; FIXME: We could have a third option which makes it jump onle over the first | |
1146 ;; hline in a table. | |
1147 (defcustom org-table-tab-jumps-over-hlines t | |
1148 "Non-nil means, tab in the last column of a table with jump over a hline. | |
1149 If a horizontal separator line is following the current line, | |
1150 `org-table-next-field' can either create a new row before that line, or jump | |
1151 over the line. When this option is nil, a new line will be created before | |
1152 this line." | |
1153 :group 'org-table | |
1154 :type 'boolean) | |
1155 | |
1131 (defcustom org-table-auto-blank-field t | 1156 (defcustom org-table-auto-blank-field t |
1132 "Non-nil means, automatically blank table field when starting to type into it. | 1157 "Non-nil means, automatically blank table field when starting to type into it. |
1133 This only happens when typing immediately after a field motion | 1158 This only happens when typing immediately after a field motion |
1134 command (TAB, S-TAB or RET). | 1159 command (TAB, S-TAB or RET). |
1135 Only relevant when `org-enable-table-editor' is equal to `optimized'." | 1160 Only relevant when `org-enable-table-editor' is equal to `optimized'." |
1311 (string :tag "Date") | 1336 (string :tag "Date") |
1312 (string :tag "Table of Contents")))) | 1337 (string :tag "Table of Contents")))) |
1313 | 1338 |
1314 (defcustom org-export-default-language "en" | 1339 (defcustom org-export-default-language "en" |
1315 "The default language of HTML export, as a string. | 1340 "The default language of HTML export, as a string. |
1316 This should have an association in `org-export-language-setup'" | 1341 This should have an association in `org-export-language-setup'." |
1342 :group 'org-export | |
1343 :type 'string) | |
1344 | |
1345 (defcustom org-export-html-style "" | |
1346 "The default style specification for exported HTML files. | |
1347 Since there are different ways of setting style information, this variable | |
1348 needs to contain the full HTML structure to provide a style, including the | |
1349 surrounding HTML tags. For example, legal values would be | |
1350 | |
1351 <style type=\"text/css\"> | |
1352 p {font-weight: normal; color: gray; } | |
1353 h1 {color: black; } | |
1354 </style> | |
1355 | |
1356 or | |
1357 | |
1358 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\"> | |
1359 | |
1360 As the value of this option simply gets inserted into the HTML <head> header, | |
1361 you can \"misuse\" it to add arbitrary text to the header. | |
1362 " | |
1317 :group 'org-export | 1363 :group 'org-export |
1318 :type 'string) | 1364 :type 'string) |
1319 | 1365 |
1320 (defcustom org-export-headline-levels 3 | 1366 (defcustom org-export-headline-levels 3 |
1321 "The last level which is still exported as a headline. | 1367 "The last level which is still exported as a headline. |
1344 In HTML output, the TOC will be clickable. | 1390 In HTML output, the TOC will be clickable. |
1345 | 1391 |
1346 This option can also be set with the +OPTIONS line, e.g. \"toc:nil\"." | 1392 This option can also be set with the +OPTIONS line, e.g. \"toc:nil\"." |
1347 :group 'org-export | 1393 :group 'org-export |
1348 :type 'boolean) | 1394 :type 'boolean) |
1395 | |
1396 (defcustom org-export-local-list-max-depth 1 | |
1397 "Maximum depth of hand-formatted lists in HTML export. | |
1398 Org-mode parses hand-formatted enumeration and bullet lists and | |
1399 transforms them to HTML open export. Different indentation of the bullet | |
1400 or number indicates different list nesting levels. To avoid confusion, | |
1401 only a single level is allowed by default. This means that a list is started | |
1402 with an item, and that all further items are consitered as long as the | |
1403 indentation is larger or equal to the indentation of the first item. When this | |
1404 is larger than 1, deeper indentation leads to deeper list nesting. | |
1405 If you are careful with hand formatting, you can increase this limit and | |
1406 get lists of arbitrary depth. For example, by setting this option to 3, the | |
1407 following list would look correct in HTML: | |
1408 | |
1409 * Fruit | |
1410 - Apple | |
1411 - Banana | |
1412 1. from Africa | |
1413 2. from South America | |
1414 - Pineapple | |
1415 * Bread | |
1416 * Dairy products" | |
1417 :group 'org-export | |
1418 :type 'integer) | |
1349 | 1419 |
1350 (defcustom org-export-preserve-breaks nil | 1420 (defcustom org-export-preserve-breaks nil |
1351 "Non-nil means, preserve all line breaks when exporting. | 1421 "Non-nil means, preserve all line breaks when exporting. |
1352 Normally, in HTML output paragraphs will be reformatted. In ASCII | 1422 Normally, in HTML output paragraphs will be reformatted. In ASCII |
1353 export, line breaks will always be preserved, regardless of this variable. | 1423 export, line breaks will always be preserved, regardless of this variable. |
1872 ;; Activate before-change-function | 1942 ;; Activate before-change-function |
1873 (set (make-local-variable 'org-table-may-need-update) t) | 1943 (set (make-local-variable 'org-table-may-need-update) t) |
1874 (make-local-hook 'before-change-functions) ;; needed for XEmacs | 1944 (make-local-hook 'before-change-functions) ;; needed for XEmacs |
1875 (add-hook 'before-change-functions 'org-before-change-function nil | 1945 (add-hook 'before-change-functions 'org-before-change-function nil |
1876 'local) | 1946 'local) |
1877 ;; Paragraph regular expressions | 1947 ;; Paragraphs and auto-filling |
1878 (set (make-local-variable 'paragraph-separate) "\f\\|[ ]*$\\|\\([*\f]+\\)") | 1948 (org-set-autofill-regexps) |
1879 (set (make-local-variable 'paragraph-start) "\f\\|[ ]*$\\|\\([*\f]+\\)") | |
1880 ;; Inhibit auto-fill for headers, tables and fixed-width lines. | |
1881 (set (make-local-variable 'auto-fill-inhibit-regexp) | |
1882 (concat "\\*\\|#" | |
1883 (if (or org-enable-table-editor org-enable-fixed-width-editor) | |
1884 (concat | |
1885 "\\|[ \t]*[" | |
1886 (if org-enable-table-editor "|" "") | |
1887 (if org-enable-fixed-width-editor ":" "") | |
1888 "]")))) | |
1889 (set (make-local-variable 'fill-paragraph-function) 'org-fill-paragraph) | |
1890 ;; Settings for Calc embedded mode | 1949 ;; Settings for Calc embedded mode |
1891 (set (make-local-variable 'calc-embedded-open-formula) "|\\|\n") | 1950 (set (make-local-variable 'calc-embedded-open-formula) "|\\|\n") |
1892 (set (make-local-variable 'calc-embedded-close-formula) "|\\|\n") | 1951 (set (make-local-variable 'calc-embedded-close-formula) "|\\|\n") |
1893 (if (and org-insert-mode-line-in-empty-file | 1952 (if (and org-insert-mode-line-in-empty-file |
1894 (interactive-p) | 1953 (interactive-p) |
1915 ((eq org-startup-folded t) | 1974 ((eq org-startup-folded t) |
1916 (org-cycle '(4))) | 1975 (org-cycle '(4))) |
1917 ((eq org-startup-folded 'content) | 1976 ((eq org-startup-folded 'content) |
1918 (let ((this-command 'org-cycle) (last-command 'org-cycle)) | 1977 (let ((this-command 'org-cycle) (last-command 'org-cycle)) |
1919 (org-cycle '(4)) (org-cycle '(4)))))))) | 1978 (org-cycle '(4)) (org-cycle '(4)))))))) |
1920 | |
1921 (defun org-fill-paragraph (&optional justify) | |
1922 "Re-align a table, pass through to fill-paragraph if no table." | |
1923 (save-excursion | |
1924 (beginning-of-line 1) | |
1925 (looking-at "\\s-*\\(|\\|\\+-+\\)"))) | |
1926 | 1979 |
1927 (defsubst org-current-line (&optional pos) | 1980 (defsubst org-current-line (&optional pos) |
1928 (+ (if (bolp) 1 0) (count-lines (point-min) (or pos (point))))) | 1981 (+ (if (bolp) 1 0) (count-lines (point-min) (or pos (point))))) |
1929 | 1982 |
1930 ;;; Font-Lock stuff | 1983 ;;; Font-Lock stuff |
4228 (condition-case nil | 4281 (condition-case nil |
4229 (add-to-diary-list original-date "Org-mode dummy" "") | 4282 (add-to-diary-list original-date "Org-mode dummy" "") |
4230 (error | 4283 (error |
4231 (add-to-diary-list original-date "Org-mode dummy" "" nil))))) | 4284 (add-to-diary-list original-date "Org-mode dummy" "" nil))))) |
4232 | 4285 |
4233 (defun org-add-file (&optional file) | 4286 (defun org-cycle-agenda-files () |
4234 "Add current file to the list of files in variable `org-agenda-files'. | 4287 "Cycle through the files in `org-agenda-files'. |
4235 These are the files which are being checked for agenda entries. | 4288 If the current buffer visits an agenda file, find the next one in the list. |
4236 Optional argument FILE means, use this file instead of the current. | 4289 If the current buffer does not, find the first agenda file." |
4237 It is possible (but not recommended) to add this function to the | |
4238 `org-mode-hook'." | |
4239 (interactive) | 4290 (interactive) |
4240 (catch 'exit | 4291 (let ((files (append org-agenda-files (list (car org-agenda-files)))) |
4241 (let* ((file (or file (buffer-file-name) | 4292 (tcf (if (buffer-file-name) (file-truename (buffer-file-name)))) |
4242 (if (interactive-p) | 4293 file) |
4243 (error "Buffer is not visiting a file") | 4294 (unless files (error "No agenda files")) |
4244 (throw 'exit nil)))) | 4295 (catch 'exit |
4245 (true-file (file-truename file)) | 4296 (while (setq file (pop files)) |
4246 (afile (abbreviate-file-name file)) | 4297 (if (equal (file-truename file) tcf) |
4247 (present (delq nil (mapcar | 4298 (when (car files) |
4248 (lambda (x) | 4299 (find-file (car files)) |
4249 (equal true-file (file-truename x))) | 4300 (throw 'exit t)))) |
4250 org-agenda-files)))) | 4301 (find-file (car org-agenda-files))))) |
4251 (if (not present) | 4302 |
4252 (progn | 4303 (defun org-agenda-file-to-end (&optional file) |
4253 (setq org-agenda-files | 4304 "Move/add the current file to the end of the agenda fiole list. |
4254 (cons afile org-agenda-files)) | 4305 I the file is not present in the list, it is appended ot the list. If it is |
4255 ;; Make sure custom.el does not end up with Org-mode | 4306 present, it is moved there." |
4256 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode)) | 4307 (interactive) |
4257 (customize-save-variable 'org-agenda-files org-agenda-files)) | 4308 (org-agenda-file-to-front 'to-end file)) |
4258 (org-install-agenda-files-menu) | 4309 |
4259 (message "Added file: %s" afile)) | 4310 (defun org-agenda-file-to-front (&optional to-end file) |
4260 (message "File was already in list: %s" afile))))) | 4311 "Move/add the current file to the top of the agenda file list. |
4312 If the file is not present in the list, it is added to the front. If it is | |
4313 present, it is moved there. With optional argument TO-END, add/move to the | |
4314 end of the list." | |
4315 (interactive "P") | |
4316 (let ((file-alist (mapcar (lambda (x) | |
4317 (cons (file-truename x) x)) | |
4318 org-agenda-files)) | |
4319 (ctf (file-truename (buffer-file-name))) | |
4320 x had) | |
4321 (setq x (assoc ctf file-alist) had x) | |
4322 | |
4323 (if (not x) (setq x (cons ctf (abbreviate-file-name (buffer-file-name))))) | |
4324 (if to-end | |
4325 (setq file-alist (append (delq x file-alist) (list x))) | |
4326 (setq file-alist (cons x (delq x file-alist)))) | |
4327 (setq org-agenda-files (mapcar 'cdr file-alist)) | |
4328 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode)) | |
4329 (customize-save-variable 'org-agenda-files org-agenda-files)) | |
4330 (org-install-agenda-files-menu) | |
4331 (message "File %s to %s of agenda file list" | |
4332 (if had "moved" "added") (if to-end "end" "front")))) | |
4261 | 4333 |
4262 (defun org-remove-file (&optional file) | 4334 (defun org-remove-file (&optional file) |
4263 "Remove current file from the list of files in variable `org-agenda-files'. | 4335 "Remove current file from the list of files in variable `org-agenda-files'. |
4264 These are the files which are being checked for agenda entries. | 4336 These are the files which are being checked for agenda entries. |
4265 Optional argument FILE means, use this file instead of the current." | 4337 Optional argument FILE means, use this file instead of the current." |
6298 (replace-match n)))) | 6370 (replace-match n)))) |
6299 (setq org-table-may-need-update t)) | 6371 (setq org-table-may-need-update t)) |
6300 (goto-char pos)))))) | 6372 (goto-char pos)))))) |
6301 | 6373 |
6302 (defun org-table-next-field () | 6374 (defun org-table-next-field () |
6303 "Go to the next field in the current table. | 6375 "Go to the next field in the current table, creating new lines as needed. |
6304 Before doing so, re-align the table if necessary." | 6376 Before doing so, re-align the table if necessary." |
6305 (interactive) | 6377 (interactive) |
6306 (org-table-maybe-eval-formula) | 6378 (org-table-maybe-eval-formula) |
6307 (org-table-maybe-recalculate-line) | 6379 (org-table-maybe-recalculate-line) |
6308 (if (and org-table-automatic-realign | 6380 (if (and org-table-automatic-realign |
6309 org-table-may-need-update) | 6381 org-table-may-need-update) |
6310 (org-table-align)) | 6382 (org-table-align)) |
6311 (if (org-at-table-hline-p) | 6383 (let ((end (org-table-end))) |
6312 (end-of-line 1)) | 6384 (if (org-at-table-hline-p) |
6313 (condition-case nil | 6385 (end-of-line 1)) |
6314 (progn | 6386 (condition-case nil |
6315 (re-search-forward "|" (org-table-end)) | 6387 (progn |
6316 (if (looking-at "[ \t]*$") | 6388 (re-search-forward "|" end) |
6317 (re-search-forward "|" (org-table-end))) | 6389 (if (looking-at "[ \t]*$") |
6318 (if (looking-at "-") | 6390 (re-search-forward "|" end)) |
6319 (progn | 6391 (if (and (looking-at "-") |
6320 (beginning-of-line 0) | 6392 org-table-tab-jumps-over-hlines |
6321 (org-table-insert-row 'below)) | 6393 (re-search-forward "^[ \t]*|\\([^-]\\)" end t)) |
6322 (if (looking-at " ") (forward-char 1)))) | 6394 (goto-char (match-beginning 1))) |
6323 (error | 6395 (if (looking-at "-") |
6324 (org-table-insert-row 'below)))) | 6396 (progn |
6397 (beginning-of-line 0) | |
6398 (org-table-insert-row 'below)) | |
6399 (if (looking-at " ") (forward-char 1)))) | |
6400 (error | |
6401 (org-table-insert-row 'below))))) | |
6325 | 6402 |
6326 (defun org-table-previous-field () | 6403 (defun org-table-previous-field () |
6327 "Go to the previous field in the table. | 6404 "Go to the previous field in the table. |
6328 Before doing so, re-align the table if necessary." | 6405 Before doing so, re-align the table if necessary." |
6329 (interactive) | 6406 (interactive) |
6470 "Move the cursor to the Nth column in the current table line. | 6547 "Move the cursor to the Nth column in the current table line. |
6471 With optional argument ON-DELIM, stop with point before the left delimiter | 6548 With optional argument ON-DELIM, stop with point before the left delimiter |
6472 of the field. | 6549 of the field. |
6473 If there are less than N fields, just go to after the last delimiter. | 6550 If there are less than N fields, just go to after the last delimiter. |
6474 However, when FORCE is non-nil, create new columns if necessary." | 6551 However, when FORCE is non-nil, create new columns if necessary." |
6552 (interactive "p") | |
6475 (let ((pos (point-at-eol))) | 6553 (let ((pos (point-at-eol))) |
6476 (beginning-of-line 1) | 6554 (beginning-of-line 1) |
6477 (when (> n 0) | 6555 (when (> n 0) |
6478 (while (and (> (setq n (1- n)) -1) | 6556 (while (and (> (setq n (1- n)) -1) |
6479 (or (search-forward "|" pos t) | 6557 (or (search-forward "|" pos t) |
6488 (backward-char 1) | 6566 (backward-char 1) |
6489 (if (looking-at " ") (forward-char 1)))))) | 6567 (if (looking-at " ") (forward-char 1)))))) |
6490 | 6568 |
6491 (defun org-at-table-p (&optional table-type) | 6569 (defun org-at-table-p (&optional table-type) |
6492 "Return t if the cursor is inside an org-type table. | 6570 "Return t if the cursor is inside an org-type table. |
6493 If TABLE-TYPE is non-nil, also chack for table.el-type tables." | 6571 If TABLE-TYPE is non-nil, also check for table.el-type tables." |
6494 (if org-enable-table-editor | 6572 (if org-enable-table-editor |
6495 (save-excursion | 6573 (save-excursion |
6496 (beginning-of-line 1) | 6574 (beginning-of-line 1) |
6497 (looking-at (if table-type org-table-any-line-regexp | 6575 (looking-at (if table-type org-table-any-line-regexp |
6498 org-table-line-regexp))) | 6576 org-table-line-regexp))) |
6499 nil)) | 6577 nil)) |
6578 | |
6579 (defun org-at-table.el-p () | |
6580 "Return t if and only if we are at a table.el table." | |
6581 (and (org-at-table-p 'any) | |
6582 (save-excursion | |
6583 (goto-char (org-table-begin 'any)) | |
6584 (looking-at org-table1-hline-regexp)))) | |
6500 | 6585 |
6501 (defun org-table-recognize-table.el () | 6586 (defun org-table-recognize-table.el () |
6502 "If there is a table.el table nearby, recognize it and move into it." | 6587 "If there is a table.el table nearby, recognize it and move into it." |
6503 (if org-table-tab-recognizes-table.el | 6588 (if org-table-tab-recognizes-table.el |
6504 (if (org-at-table.el-p) | 6589 (if (org-at-table.el-p) |
6521 (message "recognizing table.el table...done"))) | 6606 (message "recognizing table.el table...done"))) |
6522 (error "This should not happen...")) | 6607 (error "This should not happen...")) |
6523 t) | 6608 t) |
6524 nil) | 6609 nil) |
6525 nil)) | 6610 nil)) |
6526 | |
6527 (defun org-at-table.el-p () | |
6528 "Return t if the cursor is inside a table.el-type table." | |
6529 (save-excursion | |
6530 (if (org-at-table-p 'any) | |
6531 (progn | |
6532 (goto-char (org-table-begin 'any)) | |
6533 (looking-at org-table1-hline-regexp)) | |
6534 nil))) | |
6535 | 6611 |
6536 (defun org-at-table-hline-p () | 6612 (defun org-at-table-hline-p () |
6537 "Return t if the cursor is inside a hline in a table." | 6613 "Return t if the cursor is inside a hline in a table." |
6538 (if org-enable-table-editor | 6614 (if org-enable-table-editor |
6539 (save-excursion | 6615 (save-excursion |
6743 (let ((col (current-column))) | 6819 (let ((col (current-column))) |
6744 (kill-region (point-at-bol) (min (1+ (point-at-eol)) (point-max))) | 6820 (kill-region (point-at-bol) (min (1+ (point-at-eol)) (point-max))) |
6745 (if (not (org-at-table-p)) (beginning-of-line 0)) | 6821 (if (not (org-at-table-p)) (beginning-of-line 0)) |
6746 (move-to-column col))) | 6822 (move-to-column col))) |
6747 | 6823 |
6824 (defun org-table-sort-lines (beg end numericp) | |
6825 "Sort table lines in region. | |
6826 Point and mark define the first and last line to include. Both point and | |
6827 mark should be in the column that is used for sorting. For example, to | |
6828 sort according to column 3, put the mark in the first line to sort, in | |
6829 table column 3. Put point into the last line to be included in the sorting, | |
6830 also in table column 3. The command will prompt for the sorting method (n for | |
6831 numerical, a for alphanumeric)." | |
6832 (interactive "r\nsSorting method: [n]=numeric [a]=alpha: ") | |
6833 (setq numericp (string-match "[nN]" numericp)) | |
6834 (org-table-align) ;; Just to be safe | |
6835 (let* (bcol ecol cmp column lns) | |
6836 (goto-char beg) | |
6837 (org-table-check-inside-data-field) | |
6838 (setq column (org-table-current-column) | |
6839 beg (move-marker (make-marker) (point-at-bol))) | |
6840 (goto-char end) | |
6841 (org-table-check-inside-data-field) | |
6842 (setq end (move-marker (make-marker) (1+ (point-at-eol)))) | |
6843 (untabify beg end) | |
6844 (goto-char beg) | |
6845 (org-table-goto-column column) | |
6846 (skip-chars-backward "^|") | |
6847 (setq bcol (current-column)) | |
6848 (org-table-goto-column (1+ column)) | |
6849 (skip-chars-backward "^|") | |
6850 (setq ecol (1- (current-column))) | |
6851 (setq cmp (if numericp | |
6852 (lambda (a b) (< (car a) (car b))) | |
6853 (lambda (a b) (string< (car a) (car b))))) | |
6854 (setq lns (mapcar (lambda(x) (cons (org-trim (substring x bcol ecol)) x)) | |
6855 (split-string (buffer-substring beg end) "\n"))) | |
6856 (if numericp | |
6857 (setq lns (mapcar (lambda(x) | |
6858 (cons (string-to-number (car x)) (cdr x))) | |
6859 lns))) | |
6860 (delete-region beg end) | |
6861 (move-marker beg nil) | |
6862 (move-marker end nil) | |
6863 (insert (mapconcat 'cdr (setq lns (sort lns cmp)) "\n") "\n") | |
6864 (message "%d lines sorted %s based on column %d" | |
6865 (length lns) | |
6866 (if numericp "numerically" "alphabetically") column))) | |
6748 | 6867 |
6749 (defun org-table-cut-region (beg end) | 6868 (defun org-table-cut-region (beg end) |
6750 "Copy region in table to the clipboard and blank all relevant fields." | 6869 "Copy region in table to the clipboard and blank all relevant fields." |
6751 (interactive "r") | 6870 (interactive "r") |
6752 (org-table-copy-region beg end 'cut)) | 6871 (org-table-copy-region beg end 'cut)) |
8011 '("\C-c+" org-table-sum) | 8130 '("\C-c+" org-table-sum) |
8012 '("\C-c|" org-table-toggle-vline-visibility) | 8131 '("\C-c|" org-table-toggle-vline-visibility) |
8013 '("\C-c=" org-table-eval-formula) | 8132 '("\C-c=" org-table-eval-formula) |
8014 '("\C-c'" org-table-edit-formulas) | 8133 '("\C-c'" org-table-edit-formulas) |
8015 '("\C-c*" org-table-recalculate) | 8134 '("\C-c*" org-table-recalculate) |
8135 '("\C-c^" org-table-sort-lines) | |
8016 '([(control ?#)] org-table-rotate-recalc-marks))) | 8136 '([(control ?#)] org-table-rotate-recalc-marks))) |
8017 elt key fun cmd) | 8137 elt key fun cmd) |
8018 (while (setq elt (pop bindings)) | 8138 (while (setq elt (pop bindings)) |
8019 (setq nfunc (1+ nfunc)) | 8139 (setq nfunc (1+ nfunc)) |
8020 (setq key (car elt) | 8140 (setq key (car elt) |
8061 ("Row" | 8181 ("Row" |
8062 ["Move Row Up" org-metaup :active (org-at-table-p) :keys "M-<up>"] | 8182 ["Move Row Up" org-metaup :active (org-at-table-p) :keys "M-<up>"] |
8063 ["Move Row Down" org-metadown :active (org-at-table-p) :keys "M-<down>"] | 8183 ["Move Row Down" org-metadown :active (org-at-table-p) :keys "M-<down>"] |
8064 ["Delete Row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"] | 8184 ["Delete Row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"] |
8065 ["Insert Row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"] | 8185 ["Insert Row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"] |
8186 ["Sort lines in region" org-table-sort-lines (org-at-table-p) :keys "C-c ^"] | |
8066 "--" | 8187 "--" |
8067 ["Insert Hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"]) | 8188 ["Insert Hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"]) |
8068 ("Rectangle" | 8189 ("Rectangle" |
8069 ["Copy Rectangle" org-copy-special :active (org-at-table-p)] | 8190 ["Copy Rectangle" org-copy-special :active (org-at-table-p)] |
8070 ["Cut Rectangle" org-cut-special :active (org-at-table-p)] | 8191 ["Cut Rectangle" org-cut-special :active (org-at-table-p)] |
8836 headlines. The default is 3. Lower levels will become bulleted lists." | 8957 headlines. The default is 3. Lower levels will become bulleted lists." |
8837 (interactive "P") | 8958 (interactive "P") |
8838 (setq-default org-todo-line-regexp org-todo-line-regexp) | 8959 (setq-default org-todo-line-regexp org-todo-line-regexp) |
8839 (setq-default org-deadline-line-regexp org-deadline-line-regexp) | 8960 (setq-default org-deadline-line-regexp org-deadline-line-regexp) |
8840 (setq-default org-done-string org-done-string) | 8961 (setq-default org-done-string org-done-string) |
8841 (let* ((region-p (org-region-active-p)) | 8962 (let* ((style org-export-html-style) |
8963 (region-p (org-region-active-p)) | |
8842 (region | 8964 (region |
8843 (buffer-substring | 8965 (buffer-substring |
8844 (if region-p (region-beginning) (point-min)) | 8966 (if region-p (region-beginning) (point-min)) |
8845 (if region-p (region-end) (point-max)))) | 8967 (if region-p (region-end) (point-max)))) |
8846 (all_lines | 8968 (all_lines |
8857 (author user-full-name) | 8979 (author user-full-name) |
8858 (title (buffer-name)) | 8980 (title (buffer-name)) |
8859 (options nil) | 8981 (options nil) |
8860 (quote-re (concat "^\\*+[ \t]*" org-quote-string "\\>")) | 8982 (quote-re (concat "^\\*+[ \t]*" org-quote-string "\\>")) |
8861 (inquote nil) | 8983 (inquote nil) |
8984 (infixed nil) | |
8985 (in-local-list nil) | |
8986 (local-list-num nil) | |
8987 (local-list-indent nil) | |
8862 (email user-mail-address) | 8988 (email user-mail-address) |
8863 (language org-export-default-language) | 8989 (language org-export-default-language) |
8864 (text nil) | 8990 (text nil) |
8865 (lang-words nil) | 8991 (lang-words nil) |
8866 (head-count 0) cnt | 8992 (head-count 0) cnt |
8873 (save-buffer-coding-system (or coding-system save-buffer-coding-system)) | 8999 (save-buffer-coding-system (or coding-system save-buffer-coding-system)) |
8874 (charset (and coding-system | 9000 (charset (and coding-system |
8875 (coding-system-get coding-system 'mime-charset))) | 9001 (coding-system-get coding-system 'mime-charset))) |
8876 table-open type | 9002 table-open type |
8877 table-buffer table-orig-buffer | 9003 table-buffer table-orig-buffer |
9004 ind start-is-num starter | |
8878 ) | 9005 ) |
8879 (message "Exporting...") | 9006 (message "Exporting...") |
8880 | 9007 |
8881 (setq org-last-level 1) | 9008 (setq org-last-level 1) |
8882 (org-init-section-numbers) | 9009 (org-init-section-numbers) |
8897 (setq umax (if arg (prefix-numeric-value arg) | 9024 (setq umax (if arg (prefix-numeric-value arg) |
8898 org-export-headline-levels)) | 9025 org-export-headline-levels)) |
8899 | 9026 |
8900 ;; File header | 9027 ;; File header |
8901 (insert (format | 9028 (insert (format |
8902 "<html lang=\"%s\"><head> | 9029 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" |
9030 \"http://www.w3.org/TR/REC-html40/loose.dtd\"> | |
9031 <html lang=\"%s\"><head> | |
8903 <title>%s</title> | 9032 <title>%s</title> |
8904 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"> | 9033 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"> |
8905 <meta name=generator content=\"Org-mode\"> | 9034 <meta name=generator content=\"Org-mode\"> |
8906 <meta name=generated content=\"%s %s\"> | 9035 <meta name=generated content=\"%s %s\"> |
8907 <meta name=author content=\"%s\"> | 9036 <meta name=author content=\"%s\"> |
9037 %s | |
8908 </head><body> | 9038 </head><body> |
8909 " | 9039 " |
8910 language (org-html-expand title) (or charset "iso-8859-1") | 9040 language (org-html-expand title) (or charset "iso-8859-1") |
8911 date time author)) | 9041 date time author style)) |
8912 (if title (insert (concat "<H1 align=\"center\">" | 9042 (if title (insert (concat "<H1 align=\"center\">" |
8913 (org-html-expand title) "</H1>\n"))) | 9043 (org-html-expand title) "</H1>\n"))) |
8914 (if author (insert (concat (nth 1 lang-words) ": " author "\n"))) | 9044 (if author (insert (concat (nth 1 lang-words) ": " author "\n"))) |
8915 (if email (insert (concat "<a href=\"mailto:" email "\"><" | 9045 (if email (insert (concat "<a href=\"mailto:" email "\"><" |
8916 email "></a>\n"))) | 9046 email "></a>\n"))) |
8957 (insert "</ul>")) | 9087 (insert "</ul>")) |
8958 (insert "\n"))) | 9088 (insert "\n"))) |
8959 (insert | 9089 (insert |
8960 (format | 9090 (format |
8961 (if todo | 9091 (if todo |
8962 "<li><a href=\"#sec-%d\"><span style='color:red'>%s</span></a></li>\n" | 9092 "<li><a href=\"#sec-%d\"><span style='color:red'>%s</span></a>\n" |
8963 "<li><a href=\"#sec-%d\">%s</a></li>\n") | 9093 "<li><a href=\"#sec-%d\">%s</a>\n") |
8964 head-count txt)) | 9094 head-count txt)) |
8965 (setq org-last-level level)) | 9095 (setq org-last-level level)) |
8966 )))) | 9096 )))) |
8967 lines) | 9097 lines) |
8968 (while (> org-last-level 0) | 9098 (while (> org-last-level 0) |
8971 )) | 9101 )) |
8972 (setq head-count 0) | 9102 (setq head-count 0) |
8973 (org-init-section-numbers) | 9103 (org-init-section-numbers) |
8974 | 9104 |
8975 (while (setq line (pop lines) origline line) | 9105 (while (setq line (pop lines) origline line) |
8976 ;; end of quote? | 9106 (catch 'nextline |
8977 (when (and inquote (string-match "^\\*+" line)) | 9107 |
8978 (insert "</pre>\n") | 9108 ;; end of quote section? |
8979 (setq inquote nil)) | 9109 (when (and inquote (string-match "^\\*+" line)) |
8980 ;; inquote | 9110 (insert "</pre>\n") |
8981 (if inquote | 9111 (setq inquote nil)) |
8982 (progn | 9112 ;; inside a quote section? |
8983 (insert line "\n") | 9113 (when inquote |
8984 (setq line (org-html-expand line))) ;;????? FIXME: not needed? | 9114 (insert (org-html-protect line) "\n") |
9115 (throw 'nextline nil)) | |
9116 | |
9117 ;; verbatim lines | |
9118 (when (and org-export-with-fixed-width | |
9119 (string-match "^[ \t]*:\\(.*\\)" line)) | |
9120 (when (not infixed) | |
9121 (setq infixed t) | |
9122 (insert "<pre>\n")) | |
9123 (insert (org-html-protect (match-string 1 line)) "\n") | |
9124 (when (and lines | |
9125 (not (string-match "^[ \t]+\\(:.*\\)" | |
9126 (car lines)))) | |
9127 (setq infixed nil) | |
9128 (insert "</pre>\n")) | |
9129 (throw 'nextline nil)) | |
8985 | 9130 |
8986 ;; Protect the links | 9131 ;; Protect the links |
8987 (setq start 0) | 9132 (setq start 0) |
8988 (while (string-match org-link-maybe-angles-regexp line start) | 9133 (while (string-match org-link-maybe-angles-regexp line start) |
8989 (setq start (match-end 0)) | 9134 (setq start (match-end 0)) |
8990 (setq line (replace-match | 9135 (setq line (replace-match |
8991 (concat "\000" (match-string 1 line) "\000") | 9136 (concat "\000" (match-string 1 line) "\000") |
8992 t t line))) | 9137 t t line))) |
8993 | 9138 |
8994 ;; replace "<" and ">" by "<" and ">" | 9139 ;; replace "&" by "&", "<" and ">" by "<" and ">" |
8995 ;; handle @<..> HTML tags (replace "@>..<" by "<..>") | 9140 ;; handle @<..> HTML tags (replace "@>..<" by "<..>") |
8996 (setq line (org-html-expand line)) | 9141 (setq line (org-html-expand line)) |
8997 | 9142 |
8998 ;; Verbatim lines | 9143 ;; Format the links |
8999 (if (and org-export-with-fixed-width | 9144 (setq start 0) |
9000 (string-match "^[ \t]*:\\(.*\\)" line)) | 9145 (while (string-match org-protected-link-regexp line start) |
9146 (setq start (- (match-end 0) 2)) | |
9147 (setq type (match-string 1 line)) | |
9148 (cond | |
9149 ((member type '("http" "https" "ftp" "mailto" "news")) | |
9150 ;; standard URL | |
9151 (setq line (replace-match | |
9152 ; "<a href=\"\\1:\\2\"><\\1:\\2></a>" | |
9153 "<a href=\"\\1:\\2\">\\1:\\2</a>" | |
9154 nil nil line))) | |
9155 ((string= type "file") | |
9156 ;; FILE link | |
9157 (let* ((filename (match-string 2 line)) | |
9158 (abs-p (file-name-absolute-p filename)) | |
9159 (thefile (if abs-p (expand-file-name filename) filename)) | |
9160 (thefile (save-match-data | |
9161 (if (string-match ":[0-9]+$" thefile) | |
9162 (replace-match "" t t thefile) | |
9163 thefile))) | |
9164 (file-is-image-p | |
9165 (save-match-data | |
9166 (string-match (org-image-file-name-regexp) thefile)))) | |
9167 (setq line (replace-match | |
9168 (if (and org-export-html-inline-images | |
9169 file-is-image-p) | |
9170 (concat "<img src=\"" thefile "\"/>") | |
9171 (concat "<a href=\"" thefile "\">\\1:\\2</a>")) | |
9172 nil nil line)))) | |
9173 | |
9174 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell")) | |
9175 (setq line (replace-match | |
9176 "<i><\\1:\\2></i>" nil nil line))))) | |
9177 | |
9178 ;; TODO items | |
9179 (if (and (string-match org-todo-line-regexp line) | |
9180 (match-beginning 2)) | |
9181 (if (equal (match-string 2 line) org-done-string) | |
9182 (setq line (replace-match | |
9183 "<span style='color:green'>\\2</span>" | |
9184 nil nil line 2)) | |
9185 (setq line (replace-match "<span style='color:red'>\\2</span>" | |
9186 nil nil line 2)))) | |
9187 | |
9188 ;; DEADLINES | |
9189 (if (string-match org-deadline-line-regexp line) | |
9001 (progn | 9190 (progn |
9002 (let ((l (match-string 1 line))) | 9191 (if (save-match-data |
9003 (while (string-match " " l) | 9192 (string-match "<a href" |
9004 (setq l (replace-match " " t t l))) | 9193 (substring line 0 (match-beginning 0)))) |
9005 (insert "\n<span style='font-family:Courier'>" | 9194 nil ; Don't do the replacement - it is inside a link |
9006 l "</span>" | 9195 (setq line (replace-match "<span style='color:red'>\\&</span>" |
9007 (if (and lines | 9196 nil nil line 1))))) |
9008 (not (string-match "^[ \t]+\\(:.*\\)" | 9197 |
9009 (car lines)))) | 9198 (cond |
9010 "<br>\n" "\n")))) | 9199 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) |
9011 | 9200 ;; This is a headline |
9012 (setq start 0) | 9201 (setq level (- (match-end 1) (match-beginning 1)) |
9013 (while (string-match org-protected-link-regexp line start) | 9202 txt (match-string 2 line)) |
9014 (setq start (- (match-end 0) 2)) | 9203 (if (<= level umax) (setq head-count (+ head-count 1))) |
9015 (setq type (match-string 1 line)) | 9204 (when in-local-list |
9205 ;; Close any local lists before inserting a new header line | |
9206 (while local-list-num | |
9207 (insert (if (car local-list-num) "</ol>\n" "</ul>")) | |
9208 (pop local-list-num)) | |
9209 (setq local-list-indent nil | |
9210 in-local-list nil)) | |
9211 (org-html-level-start level txt umax | |
9212 (and org-export-with-toc (<= level umax)) | |
9213 head-count) | |
9214 ;; QUOTES | |
9215 (when (string-match quote-re line) | |
9216 (insert "<pre>") | |
9217 (setq inquote t))) | |
9218 | |
9219 ((and org-export-with-tables | |
9220 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line)) | |
9221 (if (not table-open) | |
9222 ;; New table starts | |
9223 (setq table-open t table-buffer nil table-orig-buffer nil)) | |
9224 ;; Accumulate lines | |
9225 (setq table-buffer (cons line table-buffer) | |
9226 table-orig-buffer (cons origline table-orig-buffer)) | |
9227 (when (or (not lines) | |
9228 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" | |
9229 (car lines)))) | |
9230 (setq table-open nil | |
9231 table-buffer (nreverse table-buffer) | |
9232 table-orig-buffer (nreverse table-orig-buffer)) | |
9233 (insert (org-format-table-html table-buffer table-orig-buffer)))) | |
9234 (t | |
9235 ;; Normal lines | |
9236 (when (and (> org-export-local-list-max-depth 0) | |
9237 (string-match | |
9238 "^\\( *\\)\\(\\([-+*]\\)\\|\\([0-9]+\\.\\)\\)? *\\([^ \t\n\r]\\)" | |
9239 line)) | |
9240 (setq ind (- (match-end 1) (match-beginning 1)) | |
9241 start-is-num (match-beginning 4) | |
9242 starter (if (match-beginning 2) (match-string 2 line))) | |
9243 (while (and in-local-list | |
9244 (or (and (= ind (car local-list-indent)) | |
9245 (not starter)) | |
9246 (< ind (car local-list-indent)))) | |
9247 (insert (if (car local-list-num) "</ol>\n" "</ul>")) | |
9248 (pop local-list-num) (pop local-list-indent) | |
9249 (setq in-local-list local-list-indent)) | |
9250 | |
9016 (cond | 9251 (cond |
9017 ((member type '("http" "https" "ftp" "mailto" "news")) | 9252 ((and starter |
9018 ;; standard URL | 9253 (or (not in-local-list) |
9019 (setq line (replace-match | 9254 (> ind (car local-list-indent))) |
9020 ; "<a href=\"\\1:\\2\"><\\1:\\2></a>" | 9255 (< (length local-list-indent) |
9021 "<a href=\"\\1:\\2\">\\1:\\2</a>" | 9256 org-export-local-list-max-depth)) |
9022 nil nil line))) | 9257 ;; Start new (level of ) list |
9023 ((string= type "file") | 9258 (insert (if start-is-num "<ol>\n<li>\n" "<ul>\n<li>\n")) |
9024 ;; FILE link | 9259 (push start-is-num local-list-num) |
9025 (let* ((filename (match-string 2 line)) | 9260 (push ind local-list-indent) |
9026 (abs-p (file-name-absolute-p filename)) | 9261 (setq in-local-list t)) |
9027 (thefile (if abs-p (expand-file-name filename) filename)) | 9262 (starter |
9028 (thefile (save-match-data | 9263 ;; continue current list |
9029 (if (string-match ":[0-9]+$" thefile) | 9264 (insert "<li>\n"))) |
9030 (replace-match "" t t thefile) | 9265 (setq line (substring line (match-beginning 5)))) |
9031 thefile))) | 9266 ;; Empty lines start a new paragraph. If hand-formatted lists |
9032 (file-is-image-p | 9267 ;; are not fully interpreted, lines starting with "-", "+", "*" |
9033 (save-match-data | 9268 ;; also start a new paragraph. |
9034 (string-match (org-image-file-name-regexp) thefile)))) | 9269 (if (string-match "^ [-+*]-\\|^[ \t]*$" line) (insert "<p>")) |
9035 (setq line (replace-match | 9270 (insert line (if org-export-preserve-breaks "<br>\n" "\n")))) |
9036 (if (and org-export-html-inline-images | 9271 )) |
9037 file-is-image-p) | 9272 (if org-export-html-with-timestamp |
9038 (concat "<img src=\"" thefile "\"/>") | 9273 (insert org-export-html-html-helper-timestamp)) |
9039 (concat "<a href=\"" thefile "\">\\1:\\2</a>")) | 9274 (insert "</body>\n</html>\n") |
9040 nil nil line)))) | 9275 (normal-mode) |
9041 | 9276 (save-buffer) |
9042 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell")) | 9277 (goto-char (point-min))))) |
9043 (setq line (replace-match | |
9044 "<i><\\1:\\2></i>" nil nil line))))) | |
9045 | |
9046 ;; TODO items | |
9047 (if (and (string-match org-todo-line-regexp line) | |
9048 (match-beginning 2)) | |
9049 (if (equal (match-string 2 line) org-done-string) | |
9050 (setq line (replace-match | |
9051 "<span style='color:green'>\\2</span>" | |
9052 nil nil line 2)) | |
9053 (setq line (replace-match "<span style='color:red'>\\2</span>" | |
9054 nil nil line 2)))) | |
9055 | |
9056 ;; DEADLINES | |
9057 (if (string-match org-deadline-line-regexp line) | |
9058 (progn | |
9059 (if (save-match-data | |
9060 (string-match "<a href" | |
9061 (substring line 0 (match-beginning 0)))) | |
9062 nil ; Don't do the replacement - it is inside a link | |
9063 (setq line (replace-match "<span style='color:red'>\\&</span>" | |
9064 nil nil line 1))))) | |
9065 | |
9066 | |
9067 (cond | |
9068 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) | |
9069 ;; This is a headline | |
9070 (setq level (- (match-end 1) (match-beginning 1)) | |
9071 txt (match-string 2 line)) | |
9072 (if (<= level umax) (setq head-count (+ head-count 1))) | |
9073 (org-html-level-start level txt umax | |
9074 (and org-export-with-toc (<= level umax)) | |
9075 head-count) | |
9076 ;; QUOTES | |
9077 (when (string-match quote-re line) | |
9078 (insert "<pre>") | |
9079 (setq inquote t))) | |
9080 | |
9081 ((and org-export-with-tables | |
9082 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line)) | |
9083 (if (not table-open) | |
9084 ;; New table starts | |
9085 (setq table-open t table-buffer nil table-orig-buffer nil)) | |
9086 ;; Accumulate lines | |
9087 (setq table-buffer (cons line table-buffer) | |
9088 table-orig-buffer (cons origline table-orig-buffer)) | |
9089 (when (or (not lines) | |
9090 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" | |
9091 (car lines)))) | |
9092 (setq table-open nil | |
9093 table-buffer (nreverse table-buffer) | |
9094 table-orig-buffer (nreverse table-orig-buffer)) | |
9095 (insert (org-format-table-html table-buffer table-orig-buffer)))) | |
9096 (t | |
9097 ;; Normal lines | |
9098 ;; Lines starting with "-", and empty lines make new paragraph. | |
9099 ;; FIXME: Should we add + and *? | |
9100 (if (string-match "^ *-\\|^[ \t]*$" line) (insert "<p>")) | |
9101 (insert line (if org-export-preserve-breaks "<br>\n" "\n")))) | |
9102 ))) | |
9103 (if org-export-html-with-timestamp | |
9104 (insert org-export-html-html-helper-timestamp)) | |
9105 (insert "</body>\n</html>\n") | |
9106 (normal-mode) | |
9107 (save-buffer) | |
9108 (goto-char (point-min))))) | |
9109 | 9278 |
9110 (defun org-format-table-html (lines olines) | 9279 (defun org-format-table-html (lines olines) |
9111 "Find out which HTML converter to use and return the HTML code." | 9280 "Find out which HTML converter to use and return the HTML code." |
9112 (if (string-match "^[ \t]*|" (car lines)) | 9281 (if (string-match "^[ \t]*|" (car lines)) |
9113 ;; A normal org table | 9282 ;; A normal org table |
9233 (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer)) | 9402 (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer)) |
9234 (table-generate-source 'html " org-tmp2 ") | 9403 (table-generate-source 'html " org-tmp2 ") |
9235 (set-buffer " org-tmp2 ") | 9404 (set-buffer " org-tmp2 ") |
9236 (buffer-substring (point-min) (point-max)))) | 9405 (buffer-substring (point-min) (point-max)))) |
9237 | 9406 |
9407 (defun org-html-protect (s) | |
9408 ;; convert & to &, < to < and > to > | |
9409 (let ((start 0)) | |
9410 (while (string-match "&" s start) | |
9411 (setq s (replace-match "&" t t s) | |
9412 start (1+ (match-beginning 0)))) | |
9413 (while (string-match "<" s) | |
9414 (setq s (replace-match "<" t t s))) | |
9415 (while (string-match ">" s) | |
9416 (setq s (replace-match ">" t t s)))) | |
9417 s) | |
9418 | |
9238 (defun org-html-expand (string) | 9419 (defun org-html-expand (string) |
9239 "Prepare STRING for HTML export. Applies all active conversions." | 9420 "Prepare STRING for HTML export. Applies all active conversions." |
9240 ;; First check if there is a link in the line - if yes, apply conversions | 9421 ;; First check if there is a link in the line - if yes, apply conversions |
9241 ;; only before the start of the link. | 9422 ;; only before the start of the link. |
9423 ;; FIXME: This is no longer correct, because links now have an end. | |
9242 (let* ((m (string-match org-link-regexp string)) | 9424 (let* ((m (string-match org-link-regexp string)) |
9243 (s (if m (substring string 0 m) string)) | 9425 (s (if m (substring string 0 m) string)) |
9244 (r (if m (substring string m) ""))) | 9426 (r (if m (substring string m) ""))) |
9245 ;; convert < to < and > to > | 9427 ;; convert & to &, < to < and > to > |
9246 (while (string-match "<" s) | 9428 (setq s (org-html-protect s)) |
9247 (setq s (replace-match "<" t t s))) | |
9248 (while (string-match ">" s) | |
9249 (setq s (replace-match ">" t t s))) | |
9250 (if org-export-html-expand | 9429 (if org-export-html-expand |
9251 (while (string-match "@<\\([^&]*\\)>" s) | 9430 (while (string-match "@<\\([^&]*\\)>" s) |
9252 (setq s (replace-match "<\\1>" nil nil s)))) | 9431 (setq s (replace-match "<\\1>" nil nil s)))) |
9253 (if org-export-with-emphasize | 9432 (if org-export-with-emphasize |
9254 (setq s (org-export-html-convert-emphasize s))) | 9433 (setq s (org-export-html-convert-emphasize s))) |
9444 (if (string-match "\\(\\.0\\)+\\'" string) | 9623 (if (string-match "\\(\\.0\\)+\\'" string) |
9445 (setq string (replace-match "" nil nil string)))) | 9624 (setq string (replace-match "" nil nil string)))) |
9446 string)) | 9625 string)) |
9447 | 9626 |
9448 | 9627 |
9449 | |
9450 | |
9451 | |
9452 (defun org-export-icalendar-this-file () | 9628 (defun org-export-icalendar-this-file () |
9453 "Export current file as an iCalendar file. | 9629 "Export current file as an iCalendar file. |
9454 The iCalendar file will be located in the same directory as the Org-mode | 9630 The iCalendar file will be located in the same directory as the Org-mode |
9455 file, but with extension `.ics'." | 9631 file, but with extension `.ics'." |
9456 (interactive) | 9632 (interactive) |
9494 (file-name-nondirectory (buffer-file-name))))) | 9670 (file-name-nondirectory (buffer-file-name))))) |
9495 (if (symbolp category) (setq category (symbol-name category))) | 9671 (if (symbolp category) (setq category (symbol-name category))) |
9496 (let ((standard-output ical-buffer)) | 9672 (let ((standard-output ical-buffer)) |
9497 (if combine | 9673 (if combine |
9498 (and (not started) (setq started t) | 9674 (and (not started) (setq started t) |
9499 (org-start-icalendar-file "OrgMode")) | 9675 (org-start-icalendar-file org-icalendar-combined-name)) |
9500 (org-start-icalendar-file category)) | 9676 (org-start-icalendar-file category)) |
9501 (org-print-icalendar-entries combine category) | 9677 (org-print-icalendar-entries combine category) |
9502 (when (or (and combine (not files)) (not combine)) | 9678 (when (or (and combine (not files)) (not combine)) |
9503 (org-finish-icalendar-file) | 9679 (org-finish-icalendar-file) |
9504 (set-buffer ical-buffer) | 9680 (set-buffer ical-buffer) |
9538 deadlinep (string-match org-deadline-regexp tmp) | 9714 deadlinep (string-match org-deadline-regexp tmp) |
9539 scheduledp (string-match org-scheduled-regexp tmp) | 9715 scheduledp (string-match org-scheduled-regexp tmp) |
9540 donep (org-entry-is-done-p))) | 9716 donep (org-entry-is-done-p))) |
9541 (if (or (string-match org-tr-regexp hd) | 9717 (if (or (string-match org-tr-regexp hd) |
9542 (string-match org-ts-regexp hd)) | 9718 (string-match org-ts-regexp hd)) |
9543 (setq hd (replace-match "" t t hd))) | 9719 (setq hd (replace-match "" t t hd))) |
9544 (if combine | 9720 (if combine |
9545 (setq hd (concat hd " (category " category ")"))) | 9721 (setq hd (concat hd " (category " category ")"))) |
9546 (if deadlinep (setq hd (concat "DL: " hd " This is a deadline"))) | 9722 (if deadlinep (setq hd (concat "DL: " hd " This is a deadline"))) |
9547 (if scheduledp (setq hd (concat "S: " hd " Scheduled for this date"))) | 9723 (if scheduledp (setq hd (concat "S: " hd " Scheduled for this date"))) |
9548 (princ (format "BEGIN:VEVENT | 9724 (princ (format "BEGIN:VEVENT |
9691 (define-key org-mode-map "\C-c!" 'org-time-stamp-inactive) ; Minor-mode r. | 9867 (define-key org-mode-map "\C-c!" 'org-time-stamp-inactive) ; Minor-mode r. |
9692 (define-key org-mode-map "\C-c," 'org-priority) ; Minor-mode reserved | 9868 (define-key org-mode-map "\C-c," 'org-priority) ; Minor-mode reserved |
9693 (define-key org-mode-map "\C-c\C-y" 'org-evaluate-time-range) | 9869 (define-key org-mode-map "\C-c\C-y" 'org-evaluate-time-range) |
9694 (define-key org-mode-map "\C-c>" 'org-goto-calendar) | 9870 (define-key org-mode-map "\C-c>" 'org-goto-calendar) |
9695 (define-key org-mode-map "\C-c<" 'org-date-from-calendar) | 9871 (define-key org-mode-map "\C-c<" 'org-date-from-calendar) |
9696 (define-key org-mode-map "\C-c[" 'org-add-file) | 9872 (define-key org-mode-map [(control ?,)] 'org-cycle-agenda-files) |
9873 (define-key org-mode-map "\C-c[" 'org-agenda-file-to-front) | |
9697 (define-key org-mode-map "\C-c]" 'org-remove-file) | 9874 (define-key org-mode-map "\C-c]" 'org-remove-file) |
9698 (define-key org-mode-map "\C-c\C-r" 'org-timeline) | 9875 (define-key org-mode-map "\C-c\C-r" 'org-timeline) |
9699 (define-key org-mode-map "\C-c-" 'org-table-insert-hline) | 9876 (define-key org-mode-map "\C-c-" 'org-table-insert-hline) |
9877 (define-key org-mode-map "\C-c^" 'org-table-sort-lines) | |
9700 (define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) | 9878 (define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) |
9701 (define-key org-mode-map "\C-m" 'org-return) | 9879 (define-key org-mode-map "\C-m" 'org-return) |
9702 (define-key org-mode-map "\C-c?" 'org-table-current-column) | 9880 (define-key org-mode-map "\C-c?" 'org-table-current-column) |
9703 (define-key org-mode-map "\C-c " 'org-table-blank-field) | 9881 (define-key org-mode-map "\C-c " 'org-table-blank-field) |
9704 (define-key org-mode-map "\C-c+" 'org-table-sum) | 9882 (define-key org-mode-map "\C-c+" 'org-table-sum) |
9805 (while commands | 9983 (while commands |
9806 (setq old (pop commands) new (pop commands)) | 9984 (setq old (pop commands) new (pop commands)) |
9807 (if (fboundp 'command-remapping) | 9985 (if (fboundp 'command-remapping) |
9808 (define-key map (vector 'remap old) new) | 9986 (define-key map (vector 'remap old) new) |
9809 (substitute-key-definition old new map global-map))))) | 9987 (substitute-key-definition old new map global-map))))) |
9810 | 9988 |
9811 (when (eq org-enable-table-editor 'optimized) | 9989 (when (eq org-enable-table-editor 'optimized) |
9812 ;; If the user wants maximum table support, we need to hijack | 9990 ;; If the user wants maximum table support, we need to hijack |
9813 ;; some standard editing functions | 9991 ;; some standard editing functions |
9814 (org-remap org-mode-map | 9992 (org-remap org-mode-map |
9815 'self-insert-command 'org-self-insert-command | 9993 'self-insert-command 'org-self-insert-command |
10042 ("Row" | 10220 ("Row" |
10043 ["Move Row Up" org-metaup (org-at-table-p)] | 10221 ["Move Row Up" org-metaup (org-at-table-p)] |
10044 ["Move Row Down" org-metadown (org-at-table-p)] | 10222 ["Move Row Down" org-metadown (org-at-table-p)] |
10045 ["Delete Row" org-shiftmetaup (org-at-table-p)] | 10223 ["Delete Row" org-shiftmetaup (org-at-table-p)] |
10046 ["Insert Row" org-shiftmetadown (org-at-table-p)] | 10224 ["Insert Row" org-shiftmetadown (org-at-table-p)] |
10225 ["Sort lines in region" org-table-sort-lines (org-at-table-p)] | |
10047 "--" | 10226 "--" |
10048 ["Insert Hline" org-table-insert-hline (org-at-table-p)]) | 10227 ["Insert Hline" org-table-insert-hline (org-at-table-p)]) |
10049 ("Rectangle" | 10228 ("Rectangle" |
10050 ["Copy Rectangle" org-copy-special (org-at-table-p)] | 10229 ["Copy Rectangle" org-copy-special (org-at-table-p)] |
10051 ["Cut Rectangle" org-cut-special (org-at-table-p)] | 10230 ["Cut Rectangle" org-cut-special (org-at-table-p)] |
10183 (easy-menu-change | 10362 (easy-menu-change |
10184 '("Org") "File List for Agenda" | 10363 '("Org") "File List for Agenda" |
10185 (append | 10364 (append |
10186 (list | 10365 (list |
10187 ["Edit File List" (customize-variable 'org-agenda-files) t] | 10366 ["Edit File List" (customize-variable 'org-agenda-files) t] |
10188 ["Add Current File to List" org-add-file t] | 10367 ["Add/Move Current File to Front of List" org-agenda-file-to-front t] |
10189 ["Remove Current File from List" org-remove-file t] | 10368 ["Remove Current File from List" org-remove-file t] |
10369 ["Cycle through agenda files" org-cycle-agenda-files t] | |
10190 "--") | 10370 "--") |
10191 (mapcar 'org-file-menu-entry org-agenda-files)))) | 10371 (mapcar 'org-file-menu-entry org-agenda-files)))) |
10192 | 10372 |
10193 ;;; Documentation | 10373 ;;; Documentation |
10194 | 10374 |
10240 (beginning-of-line (- arg)) | 10420 (beginning-of-line (- arg)) |
10241 (setq pos (move-marker (make-marker) (point))) | 10421 (setq pos (move-marker (make-marker) (point))) |
10242 (insert (delete-and-extract-region beg end)) | 10422 (insert (delete-and-extract-region beg end)) |
10243 (goto-char pos) | 10423 (goto-char pos) |
10244 (move-to-column col))) | 10424 (move-to-column col))) |
10425 | |
10426 ;; Paragraph filling stuff. | |
10427 ;; We want this to be just right, so use the full arsenal. | |
10428 ;; FIXME: This very likely does not work correctly for XEmacs, because the | |
10429 ;; filladapt package works slightly differently. | |
10430 | |
10431 (defun org-set-autofill-regexps () | |
10432 (interactive) | |
10433 ;; In the paragraph separator we include headlines, because filling | |
10434 ;; text in a line directly attached to a headline would otherwise | |
10435 ;; fill the headline as well. | |
10436 (set (make-local-variable 'paragraph-separate) "\f\\|\\*\\|[ ]*$\\|[ \t]*[:|]") | |
10437 ;; The paragraph starter includes hand-formatted lists. | |
10438 (set (make-local-variable 'paragraph-start) | |
10439 "\f\\|[ ]*$\\|\\([*\f]+\\)\\|[ \t]*\\([-+*]\\|[0-9]+\\.[ \t]+\\)\\|[ \t]*[:|]") | |
10440 ;; Inhibit auto-fill for headers, tables and fixed-width lines. | |
10441 ;; But only if the user has not turned off tables or fixed-width regions | |
10442 (set (make-local-variable 'auto-fill-inhibit-regexp) | |
10443 (concat "\\*\\|#" | |
10444 (if (or org-enable-table-editor org-enable-fixed-width-editor) | |
10445 (concat | |
10446 "\\|[ \t]*[" | |
10447 (if org-enable-table-editor "|" "") | |
10448 (if org-enable-fixed-width-editor ":" "") | |
10449 "]")))) | |
10450 ;; We use our own fill-paragraph function, to make sure that tables | |
10451 ;; and fixed-width regions are not wrapped. That function will pass | |
10452 ;; through to `fill-paragraph' when appropriate. | |
10453 (set (make-local-variable 'fill-paragraph-function) 'org-fill-paragraph) | |
10454 ;; Adaptive filling: To get full control, first make sure that | |
10455 ;; `adaptive-fill-regexp' never matches. Then install our won matcher. | |
10456 (setq adaptive-fill-regexp "\000") | |
10457 (setq adaptive-fill-function 'org-adaptive-fill-function)) | |
10458 | |
10459 (defun org-fill-paragraph (&optional justify) | |
10460 "Re-align a table, pass through to fill-paragraph if no table." | |
10461 (let ((table-p (org-at-table-p)) | |
10462 (table.el-p (org-at-table.el-p))) | |
10463 (cond ((equal (char-after (point-at-bol)) ?*) t) ; skip headlines | |
10464 (table.el-p t) ; skip table.el tables | |
10465 (table-p (org-table-align) t) ; align org-mode tables | |
10466 (t nil)))) ; call paragraph-fill | |
10467 | |
10468 ;; For reference, this is the default value of adaptive-fill-regexp | |
10469 ;; "[ \t]*\\([-|#;>*]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*" | |
10470 | |
10471 (defun org-adaptive-fill-function () | |
10472 "Return a fill prefix for org-mode files. | |
10473 In particular, this makes sure hanging paragraphs for hand-formatted lists | |
10474 work correctly." | |
10475 (if (looking-at " *\\([-*+] \\|[0-9]+\\. \\)?") | |
10476 (make-string (- (match-end 0) (match-beginning 0)) ?\ ))) | |
10245 | 10477 |
10246 ;; Functions needed for Emacs/XEmacs region compatibility | 10478 ;; Functions needed for Emacs/XEmacs region compatibility |
10247 | 10479 |
10248 (defun org-region-active-p () | 10480 (defun org-region-active-p () |
10249 "Is `transient-mark-mode' on and the region active? | 10481 "Is `transient-mark-mode' on and the region active? |
10472 | 10704 |
10473 (run-hooks 'org-load-hook) | 10705 (run-hooks 'org-load-hook) |
10474 | 10706 |
10475 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd | 10707 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd |
10476 ;;; org.el ends here | 10708 ;;; org.el ends here |
10709 |