diff options
| author | Carsten Dominik | 2005-11-18 16:08:29 +0000 |
|---|---|---|
| committer | Carsten Dominik | 2005-11-18 16:08:29 +0000 |
| commit | e0e66b8ec4f60e5f98020ec537bc0a2164d9dc93 (patch) | |
| tree | 17ed374253b00630ac2fbf7131e297385cdd4022 | |
| parent | 2e0bea68fab0abb20615f84be2faaeaf141f42fe (diff) | |
| download | emacs-e0e66b8ec4f60e5f98020ec537bc0a2164d9dc93.tar.gz emacs-e0e66b8ec4f60e5f98020ec537bc0a2164d9dc93.zip | |
(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'.
| -rw-r--r-- | lisp/textmodes/org.el | 653 |
1 files changed, 443 insertions, 210 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el index ef1c66bf166..0dcde3d69d5 100644 --- a/lisp/textmodes/org.el +++ b/lisp/textmodes/org.el | |||
| @@ -1,11 +1,11 @@ | |||
| 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 | ;; |
| @@ -80,6 +80,20 @@ | |||
| 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 | ;; |
| @@ -220,7 +234,7 @@ | |||
| 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) |
| @@ -530,7 +544,7 @@ moved to the new date." | |||
| 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)) |
| @@ -1128,6 +1142,17 @@ See also the variable `org-table-auto-blank-field'." | |||
| 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 |
| @@ -1313,7 +1338,28 @@ or use the +OPTION lines for a per-file setting." | |||
| 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 | ||
| @@ -1347,6 +1393,30 @@ 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) |
| 1349 | 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) | ||
| 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 |
| @@ -1874,19 +1944,8 @@ The following commands are available: | |||
| 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") |
| @@ -1918,12 +1977,6 @@ The following commands are available: | |||
| 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 | 1979 | ||
| 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 | |||
| 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 | ||
| @@ -4230,34 +4283,53 @@ Needed to avoid empty dates which mess up holiday display." | |||
| 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'. |
| @@ -6300,7 +6372,7 @@ Optional argument NEW may specify text to replace the current field content." | |||
| 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) |
| @@ -6308,20 +6380,25 @@ Before doing so, re-align the table if necessary." | |||
| 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. |
| @@ -6472,6 +6549,7 @@ 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) |
| @@ -6490,7 +6568,7 @@ However, when FORCE is non-nil, create new columns if necessary." | |||
| 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) |
| @@ -6498,6 +6576,13 @@ If TABLE-TYPE is non-nil, also chack for table.el-type tables." | |||
| 6498 | org-table-line-regexp))) | 6576 | org-table-line-regexp))) |
| 6499 | nil)) | 6577 | nil)) |
| 6500 | 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)))) | ||
| 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 |
| @@ -6524,15 +6609,6 @@ If TABLE-TYPE is non-nil, also chack for table.el-type tables." | |||
| 6524 | nil) | 6609 | nil) |
| 6525 | nil)) | 6610 | nil)) |
| 6526 | 6611 | ||
| 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 | |||
| 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 |
| @@ -6745,6 +6821,49 @@ With prefix ARG, insert above the current line." | |||
| 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." |
| @@ -8013,6 +8132,7 @@ to execute outside of tables." | |||
| 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)) |
| @@ -8063,6 +8183,7 @@ to execute outside of tables." | |||
| 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" |
| @@ -8838,7 +8959,8 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 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)) |
| @@ -8859,6 +8981,10 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 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) |
| @@ -8875,6 +9001,7 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 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 | ||
| @@ -8899,16 +9026,19 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 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"))) |
| @@ -8959,8 +9089,8 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 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 | )))) |
| @@ -8973,15 +9103,30 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 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) |
| @@ -8991,121 +9136,145 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 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) |
| 9001 | (progn | 9146 | (setq start (- (match-end 0) 2)) |
| 9002 | (let ((l (match-string 1 line))) | 9147 | (setq type (match-string 1 line)) |
| 9003 | (while (string-match " " l) | 9148 | (cond |
| 9004 | (setq l (replace-match " " t t l))) | 9149 | ((member type '("http" "https" "ftp" "mailto" "news")) |
| 9005 | (insert "\n<span style='font-family:Courier'>" | 9150 | ;; standard URL |
| 9006 | l "</span>" | 9151 | (setq line (replace-match |
| 9007 | (if (and lines | ||
| 9008 | (not (string-match "^[ \t]+\\(:.*\\)" | ||
| 9009 | (car lines)))) | ||
| 9010 | "<br>\n" "\n")))) | ||
| 9011 | |||
| 9012 | (setq start 0) | ||
| 9013 | (while (string-match org-protected-link-regexp line start) | ||
| 9014 | (setq start (- (match-end 0) 2)) | ||
| 9015 | (setq type (match-string 1 line)) | ||
| 9016 | (cond | ||
| 9017 | ((member type '("http" "https" "ftp" "mailto" "news")) | ||
| 9018 | ;; standard URL | ||
| 9019 | (setq line (replace-match | ||
| 9020 | ; "<a href=\"\\1:\\2\"><\\1:\\2></a>" | 9152 | ; "<a href=\"\\1:\\2\"><\\1:\\2></a>" |
| 9021 | "<a href=\"\\1:\\2\">\\1:\\2</a>" | 9153 | "<a href=\"\\1:\\2\">\\1:\\2</a>" |
| 9022 | nil nil line))) | 9154 | nil nil line))) |
| 9023 | ((string= type "file") | 9155 | ((string= type "file") |
| 9024 | ;; FILE link | 9156 | ;; FILE link |
| 9025 | (let* ((filename (match-string 2 line)) | 9157 | (let* ((filename (match-string 2 line)) |
| 9026 | (abs-p (file-name-absolute-p filename)) | 9158 | (abs-p (file-name-absolute-p filename)) |
| 9027 | (thefile (if abs-p (expand-file-name filename) filename)) | 9159 | (thefile (if abs-p (expand-file-name filename) filename)) |
| 9028 | (thefile (save-match-data | 9160 | (thefile (save-match-data |
| 9029 | (if (string-match ":[0-9]+$" thefile) | 9161 | (if (string-match ":[0-9]+$" thefile) |
| 9030 | (replace-match "" t t thefile) | 9162 | (replace-match "" t t thefile) |
| 9031 | thefile))) | 9163 | thefile))) |
| 9032 | (file-is-image-p | 9164 | (file-is-image-p |
| 9033 | (save-match-data | 9165 | (save-match-data |
| 9034 | (string-match (org-image-file-name-regexp) thefile)))) | 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) | ||
| 9035 | (setq line (replace-match | 9182 | (setq line (replace-match |
| 9036 | (if (and org-export-html-inline-images | 9183 | "<span style='color:green'>\\2</span>" |
| 9037 | file-is-image-p) | 9184 | nil nil line 2)) |
| 9038 | (concat "<img src=\"" thefile "\"/>") | 9185 | (setq line (replace-match "<span style='color:red'>\\2</span>" |
| 9039 | (concat "<a href=\"" thefile "\">\\1:\\2</a>")) | 9186 | nil nil line 2)))) |
| 9040 | nil nil line)))) | ||
| 9041 | 9187 | ||
| 9042 | ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell")) | 9188 | ;; DEADLINES |
| 9043 | (setq line (replace-match | 9189 | (if (string-match org-deadline-line-regexp line) |
| 9044 | "<i><\\1:\\2></i>" nil nil line))))) | 9190 | (progn |
| 9045 | 9191 | (if (save-match-data | |
| 9046 | ;; TODO items | 9192 | (string-match "<a href" |
| 9047 | (if (and (string-match org-todo-line-regexp line) | 9193 | (substring line 0 (match-beginning 0)))) |
| 9048 | (match-beginning 2)) | 9194 | nil ; Don't do the replacement - it is inside a link |
| 9049 | (if (equal (match-string 2 line) org-done-string) | 9195 | (setq line (replace-match "<span style='color:red'>\\&</span>" |
| 9050 | (setq line (replace-match | 9196 | nil nil line 1))))) |
| 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 | 9197 | ||
| 9198 | (cond | ||
| 9199 | ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) | ||
| 9200 | ;; This is a headline | ||
| 9201 | (setq level (- (match-end 1) (match-beginning 1)) | ||
| 9202 | txt (match-string 2 line)) | ||
| 9203 | (if (<= level umax) (setq head-count (+ head-count 1))) | ||
| 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)) | ||
| 9066 | 9250 | ||
| 9067 | (cond | 9251 | (cond |
| 9068 | ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) | 9252 | ((and starter |
| 9069 | ;; This is a headline | 9253 | (or (not in-local-list) |
| 9070 | (setq level (- (match-end 1) (match-beginning 1)) | 9254 | (> ind (car local-list-indent))) |
| 9071 | txt (match-string 2 line)) | 9255 | (< (length local-list-indent) |
| 9072 | (if (<= level umax) (setq head-count (+ head-count 1))) | 9256 | org-export-local-list-max-depth)) |
| 9073 | (org-html-level-start level txt umax | 9257 | ;; Start new (level of ) list |
| 9074 | (and org-export-with-toc (<= level umax)) | 9258 | (insert (if start-is-num "<ol>\n<li>\n" "<ul>\n<li>\n")) |
| 9075 | head-count) | 9259 | (push start-is-num local-list-num) |
| 9076 | ;; QUOTES | 9260 | (push ind local-list-indent) |
| 9077 | (when (string-match quote-re line) | 9261 | (setq in-local-list t)) |
| 9078 | (insert "<pre>") | 9262 | (starter |
| 9079 | (setq inquote t))) | 9263 | ;; continue current list |
| 9080 | 9264 | (insert "<li>\n"))) | |
| 9081 | ((and org-export-with-tables | 9265 | (setq line (substring line (match-beginning 5)))) |
| 9082 | (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line)) | 9266 | ;; Empty lines start a new paragraph. If hand-formatted lists |
| 9083 | (if (not table-open) | 9267 | ;; are not fully interpreted, lines starting with "-", "+", "*" |
| 9084 | ;; New table starts | 9268 | ;; also start a new paragraph. |
| 9085 | (setq table-open t table-buffer nil table-orig-buffer nil)) | 9269 | (if (string-match "^ [-+*]-\\|^[ \t]*$" line) (insert "<p>")) |
| 9086 | ;; Accumulate lines | 9270 | (insert line (if org-export-preserve-breaks "<br>\n" "\n")))) |
| 9087 | (setq table-buffer (cons line table-buffer) | 9271 | )) |
| 9088 | table-orig-buffer (cons origline table-orig-buffer)) | 9272 | (if org-export-html-with-timestamp |
| 9089 | (when (or (not lines) | 9273 | (insert org-export-html-html-helper-timestamp)) |
| 9090 | (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" | 9274 | (insert "</body>\n</html>\n") |
| 9091 | (car lines)))) | 9275 | (normal-mode) |
| 9092 | (setq table-open nil | 9276 | (save-buffer) |
| 9093 | table-buffer (nreverse table-buffer) | 9277 | (goto-char (point-min))))) |
| 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." |
| @@ -9235,18 +9404,28 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used." | |||
| 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)))) |
| @@ -9446,9 +9625,6 @@ When LEVEL is non-nil, increase section numbers on that level." | |||
| 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 |
| @@ -9496,7 +9672,7 @@ file and store it under the name `org-combined-agenda-icalendar-file'." | |||
| 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)) |
| @@ -9540,7 +9716,7 @@ When COMBINE is non nil, add the category to each line." | |||
| 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"))) |
| @@ -9693,10 +9869,12 @@ a time), or the day by one (if it does not contain a time)." | |||
| 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) |
| @@ -9807,7 +9985,7 @@ COMMANDS is a list of alternating OLDDEF NEWDEF command names." | |||
| 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 |
| @@ -10044,6 +10222,7 @@ See the individual commands for more information." | |||
| 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" |
| @@ -10185,8 +10364,9 @@ With optional NODE, go directly to that node." | |||
| 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 | ||
| @@ -10243,6 +10423,58 @@ With optional NODE, go directly to that node." | |||
| 10243 | (goto-char pos) | 10423 | (goto-char pos) |
| 10244 | (move-to-column col))) | 10424 | (move-to-column col))) |
| 10245 | 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)) ?\ ))) | ||
| 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 () |
| @@ -10474,3 +10706,4 @@ Show the heading too, if it is currently invisible." | |||
| 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 | |||