Mercurial > emacs
comparison lisp/textmodes/org.el @ 71506:727524ec34f8
(org-context): New contexts :item-bullet,
:latex-fragment, :latex-preview.
(org-overlays-at, org-overlay-start, org-overlay-end): New
compatibility functions.
(org-inside-LaTeX-fragment-p): More accurate matching, using the
exact regexp that will be used during export.
(org-latex-regexps): New variable.
(org-cdlatex-mode): Improved advice for `texmathp'.
(turn-on-org-cdlatex): New function.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Wed, 28 Jun 2006 09:47:29 +0000 |
parents | 525b50d438b5 |
children | d408779d0af3 |
comparison
equal
deleted
inserted
replaced
71505:9591ee84e734 | 71506:727524ec34f8 |
---|---|
3 ;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. | 3 ;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. |
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, 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.39 | 8 ;; Version: 4.40 |
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 |
88 ;; excellent reference card made by Philip Rooke. This card can be found | 88 ;; excellent reference card made by Philip Rooke. This card can be found |
89 ;; in the etc/ directory of Emacs 22. | 89 ;; in the etc/ directory of Emacs 22. |
90 ;; | 90 ;; |
91 ;; Recent changes | 91 ;; Recent changes |
92 ;; -------------- | 92 ;; -------------- |
93 ;; Version 4.40 | |
94 ;; - Bug fixes. | |
95 ;; | |
93 ;; Version 4.39 | 96 ;; Version 4.39 |
94 ;; - Special tag ARCHIVE keeps a subtree closed and away from agenda lists. | 97 ;; - Special tag ARCHIVE keeps a subtree closed and away from agenda lists. |
95 ;; - LaTeX code in Org-mode files can be converted to images for HTML. | 98 ;; - LaTeX code in Org-mode files can be converted to images for HTML. |
96 ;; - Bug fixes. | 99 ;; - Bug fixes. |
97 ;; - CDLaTeX-mode features can be used in Org-mode to help inserting | 100 ;; - CDLaTeX-mode features can be used in Org-mode to help inserting |
194 (require 'time-date) | 197 (require 'time-date) |
195 (require 'easymenu) | 198 (require 'easymenu) |
196 | 199 |
197 ;;; Customization variables | 200 ;;; Customization variables |
198 | 201 |
199 (defvar org-version "4.39" | 202 (defvar org-version "4.40" |
200 "The version number of the file org.el.") | 203 "The version number of the file org.el.") |
201 (defun org-version () | 204 (defun org-version () |
202 (interactive) | 205 (interactive) |
203 (message "Org-mode version %s" org-version)) | 206 (message "Org-mode version %s" org-version)) |
204 | 207 |
1777 :background the background color, or \"Transparent\". | 1780 :background the background color, or \"Transparent\". |
1778 :scale a scaling factor for the size of the images | 1781 :scale a scaling factor for the size of the images |
1779 :matchers a list indicating which matchers should be used to | 1782 :matchers a list indicating which matchers should be used to |
1780 find LaTeX fragments. Valid members of this list are: | 1783 find LaTeX fragments. Valid members of this list are: |
1781 \"begin\" find environments | 1784 \"begin\" find environments |
1782 \"$\" find mathc expressions surrounded by $...$ | 1785 \"$\" find math expressions surrounded by $...$ |
1783 \"$$\" find math expressions surrounded by $$....$$ | 1786 \"$$\" find math expressions surrounded by $$....$$ |
1784 \"\\(\" find math expressions surrounded by \\(...\\) | 1787 \"\\(\" find math expressions surrounded by \\(...\\) |
1785 \"\\[\" find math expressions surrounded by \\[...\\]" | 1788 \"\\ [\" find math expressions surrounded by \\ [...\\]" |
1786 :group 'org-latex | 1789 :group 'org-latex |
1787 :type 'plist) | 1790 :type 'plist) |
1788 | 1791 |
1789 (defgroup org-export nil | 1792 (defgroup org-export nil |
1790 "Options for exporting org-listings." | 1793 "Options for exporting org-listings." |
2851 (defvar annotation) ; from remember.el, dynamically scoped in `remember-mode' | 2854 (defvar annotation) ; from remember.el, dynamically scoped in `remember-mode' |
2852 (defvar initial) ; from remember.el, dynamically scoped in `remember-mode' | 2855 (defvar initial) ; from remember.el, dynamically scoped in `remember-mode' |
2853 (defvar orgtbl-mode) ; defined later in this file | 2856 (defvar orgtbl-mode) ; defined later in this file |
2854 (defvar Info-current-file) ; from info.el | 2857 (defvar Info-current-file) ; from info.el |
2855 (defvar Info-current-node) ; from info.el | 2858 (defvar Info-current-node) ; from info.el |
2859 (defvar texmathp-why) ; from texmathp.el | |
2860 (defvar org-latex-regexps) | |
2856 | 2861 |
2857 ;;; Define the mode | 2862 ;;; Define the mode |
2858 | 2863 |
2859 (defvar org-mode-map | 2864 (defvar org-mode-map |
2860 (if (and (not (keymapp outline-mode-map)) (featurep 'allout)) | 2865 (if (and (not (keymapp outline-mode-map)) (featurep 'allout)) |
5206 (move-overlay ovl beg end buffer))) | 5211 (move-overlay ovl beg end buffer))) |
5207 (defun org-overlay-put (ovl prop value) | 5212 (defun org-overlay-put (ovl prop value) |
5208 (if (featurep 'xemacs) | 5213 (if (featurep 'xemacs) |
5209 (set-extent-property ovl prop value) | 5214 (set-extent-property ovl prop value) |
5210 (overlay-put ovl prop value))) | 5215 (overlay-put ovl prop value))) |
5216 (defun org-overlays-at (pos) | |
5217 (if (featurep 'xemacs) (extents-at pos) (overlays-at pos))) | |
5218 (defun org-overlay-start (o) | |
5219 (if (featurep 'xemacs) (extent-start-position o) (overlay-start o))) | |
5220 (defun org-overlay-end (o) | |
5221 (if (featurep 'xemacs) (extent-end-position o) (overlay-end o))) | |
5211 | 5222 |
5212 (defvar org-occur-highlights nil) | 5223 (defvar org-occur-highlights nil) |
5213 (make-variable-buffer-local 'org-occur-highlights) | 5224 (make-variable-buffer-local 'org-occur-highlights) |
5214 (defun org-highlight-new-match (beg end) | 5225 (defun org-highlight-new-match (beg end) |
5215 "Highlight from BEG to END and mark the highlight is an occur headline." | 5226 "Highlight from BEG to END and mark the highlight is an occur headline." |
12071 (if lispp x (concat "(" x ")")) | 12082 (if lispp x (concat "(" x ")")) |
12072 t t form))) | 12083 t t form))) |
12073 ;; Insert ranges in current column | 12084 ;; Insert ranges in current column |
12074 (while (string-match "\\&[-I0-9]+" form) | 12085 (while (string-match "\\&[-I0-9]+" form) |
12075 (setq form (replace-match | 12086 (setq form (replace-match |
12076 (save-match-data | 12087 (save-match-data |
12077 (org-table-get-vertical-vector (match-string 0 form) | 12088 (org-table-get-vertical-vector (match-string 0 form) |
12078 nil n0)) | 12089 nil n0)) |
12079 t t form))) | 12090 t t form))) |
12080 (if lispp | 12091 (if lispp |
12081 (setq ev (eval (eval (read form))) | 12092 (setq ev (eval (eval (read form))) |
12082 ev (if (numberp ev) (number-to-string ev) ev)) | 12093 ev (if (numberp ev) (number-to-string ev) ev)) |
12083 (setq ev (calc-eval (cons form modes) | 12094 (setq ev (calc-eval (cons form modes) |
12084 (if org-table-formula-numbers-only 'num)))) | 12095 (if org-table-formula-numbers-only 'num)))) |
13171 (org-format-latex | 13182 (org-format-latex |
13172 (concat "ltxpng/" (file-name-sans-extension | 13183 (concat "ltxpng/" (file-name-sans-extension |
13173 (file-name-nondirectory | 13184 (file-name-nondirectory |
13174 org-current-export-file))) | 13185 org-current-export-file))) |
13175 org-current-export-dir nil "Creating LaTeX image %s")) | 13186 org-current-export-dir nil "Creating LaTeX image %s")) |
13176 (message "Expriting...") | 13187 (message "Exporting...") |
13177 | 13188 |
13178 ;; Normalize links: Convert angle and plain links into bracket links | 13189 ;; Normalize links: Convert angle and plain links into bracket links |
13179 (goto-char (point-min)) | 13190 (goto-char (point-min)) |
13180 (while (re-search-forward re-plain-link nil t) | 13191 (while (re-search-forward re-plain-link nil t) |
13181 (replace-match | 13192 (replace-match |
14814 (define-minor-mode org-cdlatex-mode | 14825 (define-minor-mode org-cdlatex-mode |
14815 "Toggle the minor `org-cdlatex-mode'. | 14826 "Toggle the minor `org-cdlatex-mode'. |
14816 This mode supports entering LaTeX environment and math in LaTeX fragments | 14827 This mode supports entering LaTeX environment and math in LaTeX fragments |
14817 in Org-mode. | 14828 in Org-mode. |
14818 \\{org-cdlatex-mode-map}" | 14829 \\{org-cdlatex-mode-map}" |
14819 nil " CDLtx" nil | 14830 nil " OCDL" nil |
14820 (when org-cdlatex-mode (require 'cdlatex)) | 14831 (when org-cdlatex-mode (require 'cdlatex)) |
14821 (unless org-cdlatex-texmathp-advice-is-done | 14832 (unless org-cdlatex-texmathp-advice-is-done |
14822 (setq org-cdlatex-texmathp-advice-is-done t) | 14833 (setq org-cdlatex-texmathp-advice-is-done t) |
14823 (defadvice texmathp (around org-math-always-on activate) | 14834 (defadvice texmathp (around org-math-always-on activate) |
14824 "Always return t in org-mode buffers. | 14835 "Always return t in org-mode buffers. |
14825 This is because we want to insert math symbols without dollars even outside | 14836 This is because we want to insert math symbols without dollars even outside |
14826 the LaTeX math segments. | 14837 the LaTeX math segments. If Orgmode thinks that point is actually inside |
14838 en embedded LaTeX fragement, let texmathp do its job. | |
14827 \\[org-cdlatex-mode-map]" | 14839 \\[org-cdlatex-mode-map]" |
14828 (interactive) | 14840 (interactive) |
14829 (if (or (not (eq major-mode 'org-mode)) | 14841 (let (p) |
14830 (org-inside-LaTeX-fragment-p)) | 14842 (cond |
14831 ad-do-it | 14843 ((not (eq major-mode 'org-mode)) ad-do-it) |
14832 (if (eq this-command 'cdlatex-math-symbol) | 14844 ((eq this-command 'cdlatex-math-symbol) |
14833 (setq ad-return-value t)))))) | 14845 (setq ad-return-value t |
14846 texmathp-why '("cdlatex-math-symbol in org-mode" . 0))) | |
14847 (t | |
14848 (let ((p (org-inside-LaTeX-fragment-p))) | |
14849 (if (and p (member (car p) (plist-get org-format-latex-options :matchers))) | |
14850 (setq ad-return-value t | |
14851 texmathp-why '("Org-mode embedded math" . 0)) | |
14852 (if p ad-do-it))))))))) | |
14853 | |
14854 (defun turn-on-org-cdlatex () | |
14855 "Unconditionally turn on `org-cdlatex-mode'." | |
14856 (org-cdlatex-mode 1)) | |
14834 | 14857 |
14835 (defun org-inside-LaTeX-fragment-p () | 14858 (defun org-inside-LaTeX-fragment-p () |
14836 "Test if point is inside a LaTeX fragment. I.e. after a \\begin, \\(, \\[, $, or $$, withoout the corresponding closing | 14859 "Test if point is inside a LaTeX fragment. |
14837 sequence appearing also before point." | 14860 I.e. after a \\begin, \\(, \\[, $, or $$, without the corresponding closing |
14838 (let ((pos (point)) | 14861 sequence appearing also before point. |
14839 (lim (progn | 14862 Even though the matchers for math are configurable, this function assumes |
14840 (re-search-backward (concat "^\\(" paragraph-start "\\)") nil t) | 14863 that \\begin, \\(, \\[, and $$ are always used. Only the single dollar |
14841 (point))) | 14864 delimiters are skipped when they have been removed by customization. |
14842 dollar-on p1) | 14865 The return value is nil, or a cons cell with the delimiter and |
14843 (goto-char pos) | 14866 and the position of this delimiter. |
14844 (if (re-search-backward "\\(\\\\begin{\\|\\\\(\\|\\\\\\[\\)\\|\\(\\\\end{\\|\\\\)\\|\\\\\\]\\)\\|\\(\\$\\)" lim t) | 14867 |
14845 (progn | 14868 This function does a reasonably good job, but can locally be fooled by |
14846 (goto-char pos) | 14869 for example currency specifications. For example it will assume being in |
14870 inline math after \"$22.34\". The LaTeX fragment formatter will only format | |
14871 fragments that are properly closed, but during editing, we have to live | |
14872 with the uncertainty caused by missing closing delimiters. This function | |
14873 looks only before point, not after." | |
14874 (catch 'exit | |
14875 (let ((pos (point)) | |
14876 (dodollar (member "$" (plist-get org-format-latex-options :matchers))) | |
14877 (lim (progn | |
14878 (re-search-backward (concat "^\\(" paragraph-start "\\)") nil t) | |
14879 (point))) | |
14880 dd-on str (start 0) m re) | |
14881 (goto-char pos) | |
14882 (when dodollar | |
14883 (setq str (concat (buffer-substring lim (point)) "\000 X$.") | |
14884 re (nth 1 (assoc "$" org-latex-regexps))) | |
14885 (while (string-match re str start) | |
14847 (cond | 14886 (cond |
14848 ((match-beginning 1) (match-beginning 0)) | 14887 ((= (match-end 0) (length str)) |
14849 ((match-beginning 2) nil) | 14888 (throw 'exit (cons "$" (+ lim (match-beginning 0))))) |
14850 (t (while (re-search-backward "\\$" lim t) | 14889 ((= (match-end 0) (- (length str) 5)) |
14851 (setq dollar-on (not dollar-on)) | 14890 (throw 'exit nil)) |
14852 (if (= (char-before) ?$) (backward-char 1)) | 14891 (t (setq start (match-end 0)))))) |
14853 (setq p1 (or p1 (point)))) | 14892 (when (setq m (re-search-backward "\\(\\\\begin{[^}]*}\\|\\\\(\\|\\\\\\[\\)\\|\\(\\\\end{[^}]*}\\|\\\\)\\|\\\\\\]\\)\\|\\(\\$\\$\\)" lim t)) |
14854 (goto-char pos) | 14893 (goto-char pos) |
14855 (if dollar-on p1)))) | 14894 (and (match-beginning 1) (throw 'exit (cons (match-string 1) m))) |
14856 (goto-char pos) | 14895 (and (match-beginning 2) (throw 'exit nil)) |
14857 nil))) | 14896 ;; count $$ |
14897 (while (re-search-backward "\\$\\$" lim t) | |
14898 (setq dd-on (not dd-on))) | |
14899 (goto-char pos) | |
14900 (if dd-on (cons "$$" m)))))) | |
14901 | |
14858 | 14902 |
14859 (defun org-try-cdlatex-tab () | 14903 (defun org-try-cdlatex-tab () |
14860 "Check if it makes sense to execute `cdlatex-tab', and do it if yes. | 14904 "Check if it makes sense to execute `cdlatex-tab', and do it if yes. |
14861 It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is | 14905 It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is |
14862 - inside a LaTeX fragment, or | 14906 - inside a LaTeX fragment, or |
14925 (org-back-to-heading) | 14969 (org-back-to-heading) |
14926 (setq beg (point) end (org-end-of-subtree) | 14970 (setq beg (point) end (org-end-of-subtree) |
14927 msg "Creating images for subtree...%s")) | 14971 msg "Creating images for subtree...%s")) |
14928 (t | 14972 (t |
14929 (if (setq at (org-inside-LaTeX-fragment-p)) | 14973 (if (setq at (org-inside-LaTeX-fragment-p)) |
14930 (goto-char (max (point-min) (- at 2))) | 14974 (goto-char (max (point-min) (- (cdr at) 2))) |
14931 (org-back-to-heading)) | 14975 (org-back-to-heading)) |
14932 (setq beg (point) end (progn (outline-next-heading) (point)) | 14976 (setq beg (point) end (progn (outline-next-heading) (point)) |
14933 msg (if at "Creating image...%s" | 14977 msg (if at "Creating image...%s" |
14934 "Creating images for entry...%s")))) | 14978 "Creating images for entry...%s")))) |
14935 (message msg "") | 14979 (message msg "") |
14939 (file-name-nondirectory | 14983 (file-name-nondirectory |
14940 buffer-file-name))) | 14984 buffer-file-name))) |
14941 default-directory 'overlays msg at) | 14985 default-directory 'overlays msg at) |
14942 (message msg "done. Use `C-c C-c' to remove images."))))) | 14986 (message msg "done. Use `C-c C-c' to remove images."))))) |
14943 | 14987 |
14988 (defvar org-latex-regexps | |
14989 '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t) | |
14990 ;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([ .,?;:'\")]\\|$\\)" 2 nil) | |
14991 ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p | |
14992 ("$" "\\([^$]\\)\\(\\(\\$\\([^ \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \r\n,.$]\\)\\$\\)\\)\\([ .,?;:'\")\000]\\|$\\)" 2 nil) | |
14993 ("\\(" "\\\\([^\000]*?\\\\)" 0 nil) | |
14994 ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 t) | |
14995 ("$$" "\\$\\$[^\000]*?\\$\\$" 0 t)) | |
14996 "Regular expressions for matching embedded LaTeX.") | |
14997 | |
14944 (defun org-format-latex (prefix &optional dir overlays msg at) | 14998 (defun org-format-latex (prefix &optional dir overlays msg at) |
14945 "Replace LaTeX fragments with links to an image, and produce images." | 14999 "Replace LaTeX fragments with links to an image, and produce images." |
14946 (if (and overlays (fboundp 'clear-image-cache)) (clear-image-cache)) | 15000 (if (and overlays (fboundp 'clear-image-cache)) (clear-image-cache)) |
14947 (let* ((prefixnodir (file-name-nondirectory prefix)) | 15001 (let* ((prefixnodir (file-name-nondirectory prefix)) |
14948 (absprefix (expand-file-name prefix dir)) | 15002 (absprefix (expand-file-name prefix dir)) |
14949 (todir (file-name-directory absprefix)) | 15003 (todir (file-name-directory absprefix)) |
14950 (opt org-format-latex-options) | 15004 (opt org-format-latex-options) |
14951 (matchers (plist-get opt :matchers)) | 15005 (matchers (plist-get opt :matchers)) |
14952 (re-list | 15006 (re-list org-latex-regexps) |
14953 '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t) | |
14954 ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([ .,?;:'\")]\\|$\\)" 2 nil) | |
14955 ("\\(" "\\\\([^\000]*?\\\\)" 0 nil) | |
14956 ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 t) | |
14957 ("$$" "\\$\\$[^\000]*?\\$\\$" 0 t))) | |
14958 (cnt 0) txt link beg end re e oldfiles | 15007 (cnt 0) txt link beg end re e oldfiles |
14959 m n block linkfile movefile ov) | 15008 m n block linkfile movefile ov) |
14960 ;; Make sure the directory exists | 15009 ;; Make sure the directory exists |
14961 (or (file-directory-p todir) (make-directory todir)) | 15010 (or (file-directory-p todir) (make-directory todir)) |
14962 ;; Check if there are old images files with this prefix, and remove them | 15011 ;; Check if there are old images files with this prefix, and remove them |
14969 (setq m (car e) re (nth 1 e) n (nth 2 e) | 15018 (setq m (car e) re (nth 1 e) n (nth 2 e) |
14970 block (if (nth 3 e) "\n\n" "")) | 15019 block (if (nth 3 e) "\n\n" "")) |
14971 (when (member m matchers) | 15020 (when (member m matchers) |
14972 (goto-char (point-min)) | 15021 (goto-char (point-min)) |
14973 (while (re-search-forward re nil t) | 15022 (while (re-search-forward re nil t) |
14974 (when (or (not at) (equal at (match-beginning n))) | 15023 (when (or (not at) (equal (cdr at) (match-beginning n))) |
14975 (setq txt (match-string n) | 15024 (setq txt (match-string n) |
14976 beg (match-beginning n) end (match-end n) | 15025 beg (match-beginning n) end (match-end n) |
14977 cnt (1+ cnt) | 15026 cnt (1+ cnt) |
14978 linkfile (format "%s_%04d.png" prefix cnt) | 15027 linkfile (format "%s_%04d.png" prefix cnt) |
14979 movefile (format "%s_%04d.png" absprefix cnt) | 15028 movefile (format "%s_%04d.png" absprefix cnt) |
15800 :headline-stars on the leading stars in a headline | 15849 :headline-stars on the leading stars in a headline |
15801 :todo-keyword on a TODO keyword (including DONE) in a headline | 15850 :todo-keyword on a TODO keyword (including DONE) in a headline |
15802 :tags on the TAGS in a headline | 15851 :tags on the TAGS in a headline |
15803 :priority on the priority cookie in a headline | 15852 :priority on the priority cookie in a headline |
15804 :item on the first line of a plain list item | 15853 :item on the first line of a plain list item |
15854 :item-bullet on the bullet/number of a plain list item | |
15805 :checkbox on the checkbox in a plain list item | 15855 :checkbox on the checkbox in a plain list item |
15806 :table in an org-mode table | 15856 :table in an org-mode table |
15807 :table-special on a special filed in a table | 15857 :table-special on a special filed in a table |
15808 :table-table in a table.el table | 15858 :table-table in a table.el table |
15809 :link on a hyperline | 15859 :link on a hyperline |
15810 :keyword on a keyword: SCHEDULED, DEADLINE, CLOSE,COMMENT, QUOTE. | 15860 :keyword on a keyword: SCHEDULED, DEADLINE, CLOSE,COMMENT, QUOTE. |
15811 :target on a <<target>> | 15861 :target on a <<target>> |
15812 :radio-target on a <<<radio-target>>> | 15862 :radio-target on a <<<radio-target>>> |
15863 :latex-fragment on a LaTeX fragment | |
15864 :latex-preview on a LaTeX fragment with overlayed preview image | |
15813 | 15865 |
15814 This function expects the position to be visible because it uses font-lock | 15866 This function expects the position to be visible because it uses font-lock |
15815 faces as a help to recognize the following contexts: :table-special, :link, | 15867 faces as a help to recognize the following contexts: :table-special, :link, |
15816 and :keyword." | 15868 and :keyword." |
15817 (let* ((f (get-text-property (point) 'face)) | 15869 (let* ((f (get-text-property (point) 'face)) |
15818 (faces (if (listp f) f (list f))) | 15870 (faces (if (listp f) f (list f))) |
15819 (p (point)) clist) | 15871 (p (point)) clist o) |
15820 ;; First the large context | 15872 ;; First the large context |
15821 (cond | 15873 (cond |
15822 ((org-on-heading-p) | 15874 ((org-on-heading-p) |
15823 (push (list :headline (point-at-bol) (point-at-eol)) clist) | 15875 (push (list :headline (point-at-bol) (point-at-eol)) clist) |
15824 (when (progn | 15876 (when (progn |
15831 (skip-chars-backward "^[\n\r \t") (or (eobp) (backward-char 1)) | 15883 (skip-chars-backward "^[\n\r \t") (or (eobp) (backward-char 1)) |
15832 (if (looking-at "\\[#[A-Z]\\]") | 15884 (if (looking-at "\\[#[A-Z]\\]") |
15833 (push (org-point-in-group p 0 :priority) clist))) | 15885 (push (org-point-in-group p 0 :priority) clist))) |
15834 | 15886 |
15835 ((org-at-item-p) | 15887 ((org-at-item-p) |
15888 (push (org-point-in-group p 2 :item-bullet) clist) | |
15836 (push (list :item (point-at-bol) | 15889 (push (list :item (point-at-bol) |
15837 (save-excursion (org-end-of-item) (point))) | 15890 (save-excursion (org-end-of-item) (point))) |
15838 clist) | 15891 clist) |
15839 (and (org-at-item-checkbox-p) | 15892 (and (org-at-item-checkbox-p) |
15840 (push (org-point-in-group p 0 :checkbox) clist))) | 15893 (push (org-point-in-group p 0 :checkbox) clist))) |
15864 ((org-on-target-p) | 15917 ((org-on-target-p) |
15865 (push (org-point-in-group p 0 :target) clist) | 15918 (push (org-point-in-group p 0 :target) clist) |
15866 (goto-char (1- (match-beginning 0))) | 15919 (goto-char (1- (match-beginning 0))) |
15867 (if (looking-at org-radio-target-regexp) | 15920 (if (looking-at org-radio-target-regexp) |
15868 (push (org-point-in-group p 0 :radio-target) clist)) | 15921 (push (org-point-in-group p 0 :radio-target) clist)) |
15869 (goto-char p))) | 15922 (goto-char p)) |
15923 ((setq o (car (delq nil | |
15924 (mapcar | |
15925 (lambda (x) | |
15926 (if (memq x org-latex-fragment-image-overlays) x)) | |
15927 (org-overlays-at (point)))))) | |
15928 (push (list :latex-fragment | |
15929 (org-overlay-start o) (org-overlay-end o)) clist) | |
15930 (push (list :latex-preview | |
15931 (org-overlay-start o) (org-overlay-end o)) clist)) | |
15932 ((org-inside-LaTeX-fragment-p) | |
15933 ;; FIXME: positions wring. | |
15934 (push (list :latex-fragment (point) (point)) clist))) | |
15870 | 15935 |
15871 (setq clist (nreverse (delq nil clist))) | 15936 (setq clist (nreverse (delq nil clist))) |
15872 clist)) | 15937 clist)) |
15873 | 15938 |
15874 (defun org-point-in-group (point group &optional context) | 15939 (defun org-point-in-group (point group &optional context) |