diff options
| author | Carsten Dominik | 2006-02-23 10:54:29 +0000 |
|---|---|---|
| committer | Carsten Dominik | 2006-02-23 10:54:29 +0000 |
| commit | 272dfec25a333681630e84a85ce10344fd018fc2 (patch) | |
| tree | 9966bf737dc4b0819654bdd47b3b7657542d4931 | |
| parent | 1caf01c286458e837ce7388b79c7e46223ae7795 (diff) | |
| download | emacs-272dfec25a333681630e84a85ce10344fd018fc2.tar.gz emacs-272dfec25a333681630e84a85ce10344fd018fc2.zip | |
(org-cleaned-string-for-export, org-solidify-link-text):
New function.
(org-add-hook): Use `add-local-hook' instead of `make-local-hook'
for XEmacs, just to silence the compiler.
(org-export-as-ascii, org-export-as-html-and-open): Use
`org-cleaned-string-for-export' and create internal links.
(org-follow-mhe-link): Require mh-e, use folder.
| -rw-r--r-- | lisp/textmodes/org.el | 100 |
1 files changed, 88 insertions, 12 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el index 4b62eeb87a7..ab06318e0e5 100644 --- a/lisp/textmodes/org.el +++ b/lisp/textmodes/org.el | |||
| @@ -5,7 +5,7 @@ | |||
| 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, wp | 6 | ;; Keywords: outlines, hypermedia, calendar, wp |
| 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ | 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ |
| 8 | ;; Version: 4.05 | 8 | ;; Version: 4.06 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -81,6 +81,10 @@ | |||
| 81 | ;; | 81 | ;; |
| 82 | ;; Changes since version 4.00: | 82 | ;; Changes since version 4.00: |
| 83 | ;; --------------------------- | 83 | ;; --------------------------- |
| 84 | ;; Version 4.06 | ||
| 85 | ;; - HTML exporter treats targeted internal links. | ||
| 86 | ;; - Bug fixes. | ||
| 87 | ;; | ||
| 84 | ;; Version 4.05 | 88 | ;; Version 4.05 |
| 85 | ;; - Changes to internal link system (thanks to David Wainberg for ideas). | 89 | ;; - Changes to internal link system (thanks to David Wainberg for ideas). |
| 86 | ;; - in-file links: [[Search String]] instead of <file:::Search String> | 90 | ;; - in-file links: [[Search String]] instead of <file:::Search String> |
| @@ -126,7 +130,7 @@ | |||
| 126 | 130 | ||
| 127 | ;;; Customization variables | 131 | ;;; Customization variables |
| 128 | 132 | ||
| 129 | (defvar org-version "4.05" | 133 | (defvar org-version "4.06" |
| 130 | "The version number of the file org.el.") | 134 | "The version number of the file org.el.") |
| 131 | (defun org-version () | 135 | (defun org-version () |
| 132 | (interactive) | 136 | (interactive) |
| @@ -7211,11 +7215,12 @@ onto the ring." | |||
| 7211 | (defun org-follow-mhe-link (folder article) | 7215 | (defun org-follow-mhe-link (folder article) |
| 7212 | "Follow an MHE link to FOLDER and ARTICLE." | 7216 | "Follow an MHE link to FOLDER and ARTICLE." |
| 7213 | (setq article (org-add-angle-brackets article)) | 7217 | (setq article (org-add-angle-brackets article)) |
| 7214 | ;; (require 'mh-e) | 7218 | (require 'mh-e) |
| 7215 | (mh-rmail) ;; mh-e is standard with emacs 22 | 7219 | (mh-find-path) |
| 7216 | (let* ((show-buf (concat "show-" folder))) | 7220 | (let* ((show-buf (concat "show-" folder))) |
| 7221 | (mh-visit-folder folder) | ||
| 7217 | (get-buffer-create show-buf) | 7222 | (get-buffer-create show-buf) |
| 7218 | (mh-display-msg | 7223 | (mh-show-msg |
| 7219 | (string-to-number | 7224 | (string-to-number |
| 7220 | (car (split-string | 7225 | (car (split-string |
| 7221 | (with-temp-buffer | 7226 | (with-temp-buffer |
| @@ -7226,8 +7231,7 @@ onto the ring." | |||
| 7226 | "--message-id" | 7231 | "--message-id" |
| 7227 | article) | 7232 | article) |
| 7228 | (buffer-string)) | 7233 | (buffer-string)) |
| 7229 | "\n"))) | 7234 | "\n")))) |
| 7230 | folder) | ||
| 7231 | (pop-to-buffer show-buf))) | 7235 | (pop-to-buffer show-buf))) |
| 7232 | 7236 | ||
| 7233 | (defun org-open-file (path &optional in-emacs line search) | 7237 | (defun org-open-file (path &optional in-emacs line search) |
| @@ -10440,6 +10444,45 @@ The list contains HTML entities for Latin-1, Greek and other symbols. | |||
| 10440 | It is supplemented by a number of commonly used TeX macros with appropriate | 10444 | It is supplemented by a number of commonly used TeX macros with appropriate |
| 10441 | translations. There is currently no way for users to extend this.") | 10445 | translations. There is currently no way for users to extend this.") |
| 10442 | 10446 | ||
| 10447 | (defun org-cleaned-string-for-export (string) | ||
| 10448 | "Cleanup a buffer substring so that links can be created safely." | ||
| 10449 | (interactive) | ||
| 10450 | (let* ((cb (current-buffer)) | ||
| 10451 | (re-radio (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)")) | ||
| 10452 | rtn) | ||
| 10453 | (save-excursion | ||
| 10454 | (set-buffer (get-buffer-create " org-mode-tmp")) | ||
| 10455 | (erase-buffer) | ||
| 10456 | (insert string) | ||
| 10457 | (org-mode) | ||
| 10458 | ;; Find targets in comments and move them out of comments | ||
| 10459 | (goto-char (point-min)) | ||
| 10460 | (while (re-search-forward "^#.*?\\(<<<?[^>\r\n]+>>>?\\).*" nil t) | ||
| 10461 | (replace-match "\\1")) | ||
| 10462 | ;; Find matches for radio targets and turn them into links | ||
| 10463 | (goto-char (point-min)) | ||
| 10464 | (while (re-search-forward re-radio nil t) | ||
| 10465 | (replace-match "\\1[[\\2]]")) | ||
| 10466 | ;; Find all links that contain a newline and put them into a single line | ||
| 10467 | (goto-char (point-min)) | ||
| 10468 | (while (re-search-forward "\\(\\[\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\]\\)" nil t) | ||
| 10469 | (replace-match "\\1 \\2") | ||
| 10470 | (goto-char (match-beginning 0))) | ||
| 10471 | ;; Remove comments | ||
| 10472 | (goto-char (point-min)) | ||
| 10473 | (while (re-search-forward "^#.*\n?" nil t) | ||
| 10474 | (replace-match "")) | ||
| 10475 | (setq rtn (buffer-string))) | ||
| 10476 | (kill-buffer " org-mode-tmp") | ||
| 10477 | rtn)) | ||
| 10478 | |||
| 10479 | (defun org-solidify-link-text (s) | ||
| 10480 | "Take link text and make a safe target out of it." | ||
| 10481 | (save-match-data | ||
| 10482 | (mapconcat | ||
| 10483 | 'identity | ||
| 10484 | (org-split-string s "[ \t\r\n]+") "--"))) | ||
| 10485 | |||
| 10443 | (defvar org-last-level nil) ; dynamically scoped variable | 10486 | (defvar org-last-level nil) ; dynamically scoped variable |
| 10444 | 10487 | ||
| 10445 | (defun org-export-as-ascii (arg) | 10488 | (defun org-export-as-ascii (arg) |
| @@ -10454,7 +10497,10 @@ underlined headlines. The default is 3." | |||
| 10454 | (if (org-region-active-p) (region-beginning) (point-min)) | 10497 | (if (org-region-active-p) (region-beginning) (point-min)) |
| 10455 | (if (org-region-active-p) (region-end) (point-max)))) | 10498 | (if (org-region-active-p) (region-end) (point-max)))) |
| 10456 | (lines (org-export-find-first-heading-line | 10499 | (lines (org-export-find-first-heading-line |
| 10457 | (org-skip-comments (org-split-string region "[\r\n]")))) | 10500 | (org-skip-comments |
| 10501 | (org-split-string | ||
| 10502 | (org-cleaned-string-for-export region) | ||
| 10503 | "[\r\n]")))) | ||
| 10458 | (org-startup-with-deadline-check nil) | 10504 | (org-startup-with-deadline-check nil) |
| 10459 | (level 0) line txt | 10505 | (level 0) line txt |
| 10460 | (umax nil) | 10506 | (umax nil) |
| @@ -10543,6 +10589,14 @@ underlined headlines. The default is 3." | |||
| 10543 | (while (setq line (pop lines)) | 10589 | (while (setq line (pop lines)) |
| 10544 | ;; Remove the quoted HTML tags. | 10590 | ;; Remove the quoted HTML tags. |
| 10545 | (setq line (org-html-expand-for-ascii line)) | 10591 | (setq line (org-html-expand-for-ascii line)) |
| 10592 | ;; Remove targets | ||
| 10593 | (while (string-match "<<<?[^<>]*>>>?[ \t]*\n?" line) | ||
| 10594 | (setq line (replace-match "" t t line))) | ||
| 10595 | ;; Replace internal links | ||
| 10596 | (while (string-match org-bracket-link-regexp line) | ||
| 10597 | (setq line (replace-match | ||
| 10598 | (if (match-end 3) "[\\3]" "[\\1]") | ||
| 10599 | t nil line))) | ||
| 10546 | (cond | 10600 | (cond |
| 10547 | ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) | 10601 | ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) |
| 10548 | ;; a Headline | 10602 | ;; a Headline |
| @@ -10781,7 +10835,9 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 10781 | (if region-p (region-beginning) (point-min)) | 10835 | (if region-p (region-beginning) (point-min)) |
| 10782 | (if region-p (region-end) (point-max)))) | 10836 | (if region-p (region-end) (point-max)))) |
| 10783 | (all_lines | 10837 | (all_lines |
| 10784 | (org-skip-comments (org-split-string region "[\r\n]"))) | 10838 | (org-skip-comments (org-split-string |
| 10839 | (org-cleaned-string-for-export region) | ||
| 10840 | "[\r\n]"))) | ||
| 10785 | (lines (org-export-find-first-heading-line all_lines)) | 10841 | (lines (org-export-find-first-heading-line all_lines)) |
| 10786 | (level 0) (line "") (origline "") txt todo | 10842 | (level 0) (line "") (origline "") txt todo |
| 10787 | (umax nil) | 10843 | (umax nil) |
| @@ -10944,7 +11000,26 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 10944 | (insert "</pre>\n")) | 11000 | (insert "</pre>\n")) |
| 10945 | (throw 'nextline nil)) | 11001 | (throw 'nextline nil)) |
| 10946 | 11002 | ||
| 10947 | ;; Protect the links | 11003 | |
| 11004 | ;; make targets to anchors | ||
| 11005 | (while (string-match "<<<?\\([^<>]*\\)>>>?[ \t]*\n?" line) | ||
| 11006 | (setq line (replace-match | ||
| 11007 | (concat "@<a name=\"" | ||
| 11008 | (org-solidify-link-text (match-string 1 line)) | ||
| 11009 | "\">\\nbsp@</a>") | ||
| 11010 | t t line))) | ||
| 11011 | ;; Replace internal links | ||
| 11012 | (while (string-match org-bracket-link-regexp line) | ||
| 11013 | (setq line (replace-match | ||
| 11014 | (concat | ||
| 11015 | "@<a href=\"#" | ||
| 11016 | (org-solidify-link-text (match-string 1 line)) | ||
| 11017 | "\">" | ||
| 11018 | (match-string (if (match-end 3) 3 1) line) | ||
| 11019 | "@</a>") | ||
| 11020 | t t line))) | ||
| 11021 | |||
| 11022 | ;; Protect the external links | ||
| 10948 | (setq start 0) | 11023 | (setq start 0) |
| 10949 | (while (string-match org-link-maybe-angles-regexp line start) | 11024 | (while (string-match org-link-maybe-angles-regexp line start) |
| 10950 | (setq start (match-end 0)) | 11025 | (setq start (match-end 0)) |
| @@ -12363,8 +12438,9 @@ work correctly." | |||
| 12363 | 12438 | ||
| 12364 | (defun org-add-hook (hook function &optional append local) | 12439 | (defun org-add-hook (hook function &optional append local) |
| 12365 | "Add-hook, compatible with both Emacsen." | 12440 | "Add-hook, compatible with both Emacsen." |
| 12366 | (if (and local org-xemacs-p) (make-local-hook hook)) ;; Needed for XEmacs | 12441 | (if (and local org-xemacs-p) |
| 12367 | (add-hook hook function append local)) | 12442 | (add-local-hook hook function append) |
| 12443 | (add-hook hook function append local))) | ||
| 12368 | 12444 | ||
| 12369 | (defun org-region-active-p () | 12445 | (defun org-region-active-p () |
| 12370 | "Is `transient-mark-mode' on and the region active? | 12446 | "Is `transient-mark-mode' on and the region active? |