org-compat.el 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. ;;; org-compat.el --- Compatibility Code for Older Emacsen -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
  3. ;; Author: Carsten Dominik <carsten at orgmode dot org>
  4. ;; Keywords: outlines, hypermedia, calendar, wp
  5. ;; Homepage: https://orgmode.org
  6. ;;
  7. ;; This file is part of GNU Emacs.
  8. ;;
  9. ;; GNU Emacs is free software: you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation, either version 3 of the License, or
  12. ;; (at your option) any later version.
  13. ;; GNU Emacs is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  20. ;;
  21. ;;; Commentary:
  22. ;; This file contains code needed for compatibility with older
  23. ;; versions of GNU Emacs and integration with other packages.
  24. ;;; Code:
  25. (require 'cl-lib)
  26. (require 'org-macs)
  27. (declare-function org-agenda-diary-entry "org-agenda")
  28. (declare-function org-agenda-maybe-redo "org-agenda" ())
  29. (declare-function org-agenda-remove-restriction-lock "org-agenda" (&optional noupdate))
  30. (declare-function org-align-tags "org" (&optional all))
  31. (declare-function org-at-heading-p "org" (&optional ignored))
  32. (declare-function org-at-table.el-p "org" ())
  33. (declare-function org-element-at-point "org-element" ())
  34. (declare-function org-element-context "org-element" (&optional element))
  35. (declare-function org-element-lineage "org-element" (blob &optional types with-self))
  36. (declare-function org-element-type "org-element" (element))
  37. (declare-function org-element-property "org-element" (property element))
  38. (declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
  39. (declare-function org-get-heading "org" (&optional no-tags no-todo no-priority no-comment))
  40. (declare-function org-get-tags "org" (&optional pos local))
  41. (declare-function org-link-display-format "ol" (s))
  42. (declare-function org-link-set-parameters "ol" (type &rest rest))
  43. (declare-function org-log-into-drawer "org" ())
  44. (declare-function org-make-tag-string "org" (tags))
  45. (declare-function org-reduced-level "org" (l))
  46. (declare-function org-show-context "org" (&optional key))
  47. (declare-function org-table-end "org-table" (&optional table-type))
  48. (declare-function outline-next-heading "outline" ())
  49. (declare-function speedbar-line-directory "speedbar" (&optional depth))
  50. (declare-function table--at-cell-p "table" (position &optional object at-column))
  51. (defvar calendar-mode-map)
  52. (defvar org-complex-heading-regexp)
  53. (defvar org-agenda-diary-file)
  54. (defvar org-agenda-overriding-restriction)
  55. (defvar org-agenda-restriction-lock-overlay)
  56. (defvar org-table-any-border-regexp)
  57. (defvar org-table-dataline-regexp)
  58. (defvar org-table-tab-recognizes-table.el)
  59. (defvar org-table1-hline-regexp)
  60. ;;; Emacs < 27.1 compatibility
  61. (unless (fboundp 'pcomplete-uniquify-list)
  62. ;; The misspelled variant was made obsolete in Emacs 27.1
  63. (defalias 'pcomplete-uniquify-list 'pcomplete-uniqify-list))
  64. (defun org-current-time-as-list ()
  65. "Compatibility wrapper for `current-time'.
  66. As of Emacs 27.1, `current-time' callers should not assume a list
  67. return value."
  68. (or (ignore-errors (encode-time nil 'list))
  69. (current-time)))
  70. ;;; Emacs < 26.1 compatibility
  71. (if (fboundp 'line-number-display-width)
  72. (defalias 'org-line-number-display-width 'line-number-display-width)
  73. (defun org-line-number-display-width (&rest _) 0))
  74. (if (fboundp 'buffer-hash)
  75. (defalias 'org-buffer-hash 'buffer-hash)
  76. (defun org-buffer-hash () (md5 (current-buffer))))
  77. (unless (fboundp 'file-attribute-modification-time)
  78. (defsubst file-attribute-modification-time (attributes)
  79. "The modification time in ATTRIBUTES returned by `file-attributes'.
  80. This is the time of the last change to the file's contents, and
  81. is a list of integers (HIGH LOW USEC PSEC) in the same style
  82. as (current-time)."
  83. (nth 5 attributes)))
  84. (unless (fboundp 'file-attribute-size)
  85. (defsubst file-attribute-size (attributes)
  86. "The size (in bytes) in ATTRIBUTES returned by `file-attributes'.
  87. This is a floating point number if the size is too large for an integer."
  88. (nth 7 attributes)))
  89. ;;; Emacs < 25.1 compatibility
  90. (when (< emacs-major-version 25)
  91. (defalias 'outline-hide-entry 'hide-entry)
  92. (defalias 'outline-hide-sublevels 'hide-sublevels)
  93. (defalias 'outline-hide-subtree 'hide-subtree)
  94. (defalias 'outline-show-branches 'show-branches)
  95. (defalias 'outline-show-children 'show-children)
  96. (defalias 'outline-show-entry 'show-entry)
  97. (defalias 'outline-show-subtree 'show-subtree)
  98. (defalias 'xref-find-definitions 'find-tag)
  99. (defalias 'format-message 'format)
  100. (defalias 'gui-get-selection 'x-get-selection))
  101. (unless (fboundp 'directory-name-p)
  102. (defun directory-name-p (name)
  103. "Return non-nil if NAME ends with a directory separator character."
  104. (let ((len (length name))
  105. (lastc ?.))
  106. (if (> len 0)
  107. (setq lastc (aref name (1- len))))
  108. (or (= lastc ?/)
  109. (and (memq system-type '(windows-nt ms-dos))
  110. (= lastc ?\\))))))
  111. ;; `string-collate-lessp' is new in Emacs 25.
  112. (if (fboundp 'string-collate-lessp)
  113. (defalias 'org-string-collate-lessp
  114. 'string-collate-lessp)
  115. (defun org-string-collate-lessp (s1 s2 &rest _)
  116. "Return non-nil if STRING1 is less than STRING2 in lexicographic order.
  117. Case is significant."
  118. (string< s1 s2)))
  119. ;;; Obsolete aliases (remove them after the next major release).
  120. ;;;; XEmacs compatibility, now removed.
  121. (define-obsolete-function-alias 'org-activate-mark 'activate-mark "Org 9.0")
  122. (define-obsolete-function-alias 'org-add-hook 'add-hook "Org 9.0")
  123. (define-obsolete-function-alias 'org-bound-and-true-p 'bound-and-true-p "Org 9.0")
  124. (define-obsolete-function-alias 'org-decompose-region 'decompose-region "Org 9.0")
  125. (define-obsolete-function-alias 'org-defvaralias 'defvaralias "Org 9.0")
  126. (define-obsolete-function-alias 'org-detach-overlay 'delete-overlay "Org 9.0")
  127. (define-obsolete-function-alias 'org-file-equal-p 'file-equal-p "Org 9.0")
  128. (define-obsolete-function-alias 'org-float-time 'float-time "Org 9.0")
  129. (define-obsolete-function-alias 'org-indent-line-to 'indent-line-to "Org 9.0")
  130. (define-obsolete-function-alias 'org-indent-to-column 'indent-to-column "Org 9.0")
  131. (define-obsolete-function-alias 'org-looking-at-p 'looking-at-p "Org 9.0")
  132. (define-obsolete-function-alias 'org-looking-back 'looking-back "Org 9.0")
  133. (define-obsolete-function-alias 'org-match-string-no-properties 'match-string-no-properties "Org 9.0")
  134. (define-obsolete-function-alias 'org-propertize 'propertize "Org 9.0")
  135. (define-obsolete-function-alias 'org-select-frame-set-input-focus 'select-frame-set-input-focus "Org 9.0")
  136. (define-obsolete-function-alias 'org-file-remote-p 'file-remote-p "Org 9.2")
  137. (defmacro org-re (s)
  138. "Replace posix classes in regular expression S."
  139. (declare (debug (form))
  140. (obsolete "you can safely remove it." "Org 9.0"))
  141. s)
  142. ;;;; Functions from cl-lib that Org used to have its own implementation of.
  143. (define-obsolete-function-alias 'org-count 'cl-count "Org 9.0")
  144. (define-obsolete-function-alias 'org-every 'cl-every "Org 9.0")
  145. (define-obsolete-function-alias 'org-find-if 'cl-find-if "Org 9.0")
  146. (define-obsolete-function-alias 'org-reduce 'cl-reduce "Org 9.0")
  147. (define-obsolete-function-alias 'org-remove-if 'cl-remove-if "Org 9.0")
  148. (define-obsolete-function-alias 'org-remove-if-not 'cl-remove-if-not "Org 9.0")
  149. (define-obsolete-function-alias 'org-some 'cl-some "Org 9.0")
  150. (define-obsolete-function-alias 'org-floor* 'cl-floor "Org 9.0")
  151. (defun org-sublist (list start end)
  152. "Return a section of LIST, from START to END.
  153. Counting starts at 1."
  154. (cl-subseq list (1- start) end))
  155. (make-obsolete 'org-sublist
  156. "use cl-subseq (note the 0-based counting)."
  157. "Org 9.0")
  158. ;;;; Functions available since Emacs 24.3
  159. (define-obsolete-function-alias 'org-buffer-narrowed-p 'buffer-narrowed-p "Org 9.0")
  160. (define-obsolete-function-alias 'org-called-interactively-p 'called-interactively-p "Org 9.0")
  161. (define-obsolete-function-alias 'org-char-to-string 'char-to-string "Org 9.0")
  162. (define-obsolete-function-alias 'org-delete-directory 'delete-directory "Org 9.0")
  163. (define-obsolete-function-alias 'org-format-seconds 'format-seconds "Org 9.0")
  164. (define-obsolete-function-alias 'org-link-escape-browser 'url-encode-url "Org 9.0")
  165. (define-obsolete-function-alias 'org-no-warnings 'with-no-warnings "Org 9.0")
  166. (define-obsolete-function-alias 'org-number-sequence 'number-sequence "Org 9.0")
  167. (define-obsolete-function-alias 'org-pop-to-buffer-same-window 'pop-to-buffer-same-window "Org 9.0")
  168. (define-obsolete-function-alias 'org-string-match-p 'string-match-p "Org 9.0")
  169. ;;;; Functions and variables from previous releases now obsolete.
  170. (define-obsolete-function-alias 'org-element-remove-indentation
  171. 'org-remove-indentation "Org 9.0")
  172. (define-obsolete-variable-alias 'org-latex-create-formula-image-program
  173. 'org-preview-latex-default-process "Org 9.0")
  174. (define-obsolete-variable-alias 'org-latex-preview-ltxpng-directory
  175. 'org-preview-latex-image-directory "Org 9.0")
  176. (define-obsolete-function-alias 'org-table-p 'org-at-table-p "Org 9.0")
  177. (define-obsolete-function-alias 'org-on-heading-p 'org-at-heading-p "Org 9.0")
  178. (define-obsolete-function-alias 'org-at-regexp-p 'org-in-regexp "Org 8.3")
  179. (define-obsolete-function-alias 'org-image-file-name-regexp
  180. 'image-file-name-regexp "Org 9.0")
  181. (define-obsolete-function-alias 'org-completing-read-no-i
  182. 'completing-read "Org 9.0")
  183. (define-obsolete-function-alias 'org-icompleting-read
  184. 'completing-read "Org 9.0")
  185. (define-obsolete-function-alias 'org-iread-file-name 'read-file-name "Org 9.0")
  186. (define-obsolete-function-alias 'org-days-to-time
  187. 'org-time-stamp-to-now "Org 8.2")
  188. (define-obsolete-variable-alias 'org-agenda-ignore-drawer-properties
  189. 'org-agenda-ignore-properties "Org 9.0")
  190. (define-obsolete-function-alias 'org-preview-latex-fragment
  191. 'org-toggle-latex-fragment "Org 8.3")
  192. (define-obsolete-function-alias 'org-export-get-genealogy
  193. 'org-element-lineage "Org 9.0")
  194. (define-obsolete-variable-alias 'org-latex-with-hyperref
  195. 'org-latex-hyperref-template "Org 9.0")
  196. (define-obsolete-variable-alias 'hfy-optimisations 'hfy-optimizations "Org 9.0")
  197. (define-obsolete-variable-alias 'org-export-htmlized-org-css-url
  198. 'org-org-htmlized-css-url "Org 8.2")
  199. (define-obsolete-function-alias 'org-list-parse-list 'org-list-to-lisp "Org 9.0")
  200. (define-obsolete-function-alias 'org-agenda-todayp
  201. 'org-agenda-today-p "Org 9.0")
  202. (define-obsolete-function-alias 'org-babel-examplize-region
  203. 'org-babel-examplify-region "Org 9.0")
  204. (define-obsolete-variable-alias 'org-babel-capitalize-example-region-markers
  205. 'org-babel-uppercase-example-markers "Org 9.1")
  206. (define-obsolete-function-alias 'org-babel-trim 'org-trim "Org 9.0")
  207. (define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4")
  208. (define-obsolete-function-alias 'org-insert-columns-dblock
  209. 'org-columns-insert-dblock "Org 9.0")
  210. (define-obsolete-variable-alias 'org-export-babel-evaluate
  211. 'org-export-use-babel "Org 9.1")
  212. (define-obsolete-function-alias 'org-activate-bracket-links
  213. 'org-activate-links "Org 9.0")
  214. (define-obsolete-function-alias 'org-activate-plain-links 'ignore "Org 9.0")
  215. (define-obsolete-function-alias 'org-activate-angle-links 'ignore "Org 9.0")
  216. (define-obsolete-function-alias 'org-remove-double-quotes 'org-strip-quotes "Org 9.0")
  217. (define-obsolete-function-alias 'org-get-indentation
  218. 'current-indentation "Org 9.2")
  219. (define-obsolete-function-alias 'org-capture-member 'org-capture-get "Org 9.2")
  220. (define-obsolete-function-alias 'org-remove-from-invisibility-spec
  221. 'remove-from-invisibility-spec "Org 9.2")
  222. (define-obsolete-variable-alias 'org-effort-durations 'org-duration-units
  223. "Org 9.2")
  224. (define-obsolete-function-alias 'org-toggle-latex-fragment 'org-latex-preview
  225. "Org 9.3")
  226. (define-obsolete-function-alias 'org-remove-latex-fragment-image-overlays
  227. 'org-clear-latex-preview "Org 9.3")
  228. (defun org-in-fixed-width-region-p ()
  229. "Non-nil if point in a fixed-width region."
  230. (save-match-data
  231. (eq 'fixed-width (org-element-type (org-element-at-point)))))
  232. (make-obsolete 'org-in-fixed-width-region-p
  233. "use `org-element' library"
  234. "Org 9.0")
  235. (defun org-compatible-face (inherits specs)
  236. "Make a compatible face specification.
  237. If INHERITS is an existing face and if the Emacs version supports
  238. it, just inherit the face. If INHERITS is not given and SPECS
  239. is, use SPECS to define the face."
  240. (declare (indent 1))
  241. (if (facep inherits)
  242. (list (list t :inherit inherits))
  243. specs))
  244. (make-obsolete 'org-compatible-face "you can remove it." "Org 9.0")
  245. (defun org-add-link-type (type &optional follow export)
  246. "Add a new TYPE link.
  247. FOLLOW and EXPORT are two functions.
  248. FOLLOW should take the link path as the single argument and do whatever
  249. is necessary to follow the link, for example find a file or display
  250. a mail message.
  251. EXPORT should format the link path for export to one of the export formats.
  252. It should be a function accepting three arguments:
  253. path the path of the link, the text after the prefix (like \"http:\")
  254. desc the description of the link, if any
  255. format the export format, a symbol like `html' or `latex' or `ascii'.
  256. The function may use the FORMAT information to return different values
  257. depending on the format. The return value will be put literally into
  258. the exported file. If the return value is nil, this means Org should
  259. do what it normally does with links which do not have EXPORT defined.
  260. Org mode has a built-in default for exporting links. If you are happy with
  261. this default, there is no need to define an export function for the link
  262. type. For a simple example of an export function, see `org-bbdb.el'.
  263. If TYPE already exists, update it with the arguments.
  264. See `org-link-parameters' for documentation on the other parameters."
  265. (org-link-set-parameters type :follow follow :export export)
  266. (message "Created %s link." type))
  267. (make-obsolete 'org-add-link-type "use `org-link-set-parameters' instead." "Org 9.0")
  268. ;;;; Functions unused in Org core.
  269. (defun org-table-recognize-table.el ()
  270. "If there is a table.el table nearby, recognize it and move into it."
  271. (when (org-at-table.el-p)
  272. (beginning-of-line)
  273. (unless (or (looking-at org-table-dataline-regexp)
  274. (not (looking-at org-table1-hline-regexp)))
  275. (forward-line)
  276. (when (looking-at org-table-any-border-regexp)
  277. (forward-line -2)))
  278. (if (re-search-forward "|" (org-table-end t) t)
  279. (progn
  280. (require 'table)
  281. (if (table--at-cell-p (point)) t
  282. (message "recognizing table.el table...")
  283. (table-recognize-table)
  284. (message "recognizing table.el table...done")))
  285. (error "This should not happen"))))
  286. ;; Not used since commit 6d1e3082, Feb 2010.
  287. (make-obsolete 'org-table-recognize-table.el
  288. "please notify Org mailing list if you use this function."
  289. "Org 9.0")
  290. (defmacro org-preserve-lc (&rest body)
  291. (declare (debug (body))
  292. (obsolete "please notify Org mailing list if you use this function."
  293. "Org 9.2"))
  294. (org-with-gensyms (line col)
  295. `(let ((,line (org-current-line))
  296. (,col (current-column)))
  297. (unwind-protect
  298. (progn ,@body)
  299. (org-goto-line ,line)
  300. (org-move-to-column ,col)))))
  301. (defun org-version-check (version &rest _)
  302. "Non-nil if VERSION is lower (older) than `emacs-version'."
  303. (declare (obsolete "use `version<' or `fboundp' instead."
  304. "Org 9.2"))
  305. (version< version emacs-version))
  306. (defun org-remove-angle-brackets (s)
  307. (org-unbracket-string "<" ">" s))
  308. (make-obsolete 'org-remove-angle-brackets 'org-unbracket-string "Org 9.0")
  309. (defcustom org-publish-sitemap-file-entry-format "%t"
  310. "Format string for site-map file entry.
  311. You could use brackets to delimit on what part the link will be.
  312. %t is the title.
  313. %a is the author.
  314. %d is the date formatted using `org-publish-sitemap-date-format'."
  315. :group 'org-export-publish
  316. :type 'string)
  317. (make-obsolete-variable
  318. 'org-publish-sitemap-file-entry-format
  319. "set `:sitemap-format-entry' in `org-publish-project-alist' instead."
  320. "Org 9.1")
  321. (defvar org-agenda-skip-regexp)
  322. (defun org-agenda-skip-entry-when-regexp-matches ()
  323. "Check if the current entry contains match for `org-agenda-skip-regexp'.
  324. If yes, it returns the end position of this entry, causing agenda commands
  325. to skip the entry but continuing the search in the subtree. This is a
  326. function that can be put into `org-agenda-skip-function' for the duration
  327. of a command."
  328. (declare (obsolete "use `org-agenda-skip-if' instead." "Org 9.1"))
  329. (let ((end (save-excursion (org-end-of-subtree t)))
  330. skip)
  331. (save-excursion
  332. (setq skip (re-search-forward org-agenda-skip-regexp end t)))
  333. (and skip end)))
  334. (defun org-agenda-skip-subtree-when-regexp-matches ()
  335. "Check if the current subtree contains match for `org-agenda-skip-regexp'.
  336. If yes, it returns the end position of this tree, causing agenda commands
  337. to skip this subtree. This is a function that can be put into
  338. `org-agenda-skip-function' for the duration of a command."
  339. (declare (obsolete "use `org-agenda-skip-if' instead." "Org 9.1"))
  340. (let ((end (save-excursion (org-end-of-subtree t)))
  341. skip)
  342. (save-excursion
  343. (setq skip (re-search-forward org-agenda-skip-regexp end t)))
  344. (and skip end)))
  345. (defun org-agenda-skip-entry-when-regexp-matches-in-subtree ()
  346. "Check if the current subtree contains match for `org-agenda-skip-regexp'.
  347. If yes, it returns the end position of the current entry (NOT the tree),
  348. causing agenda commands to skip the entry but continuing the search in
  349. the subtree. This is a function that can be put into
  350. `org-agenda-skip-function' for the duration of a command. An important
  351. use of this function is for the stuck project list."
  352. (declare (obsolete "use `org-agenda-skip-if' instead." "Org 9.1"))
  353. (let ((end (save-excursion (org-end-of-subtree t)))
  354. (entry-end (save-excursion (outline-next-heading) (1- (point))))
  355. skip)
  356. (save-excursion
  357. (setq skip (re-search-forward org-agenda-skip-regexp end t)))
  358. (and skip entry-end)))
  359. (define-obsolete-function-alias 'org-minutes-to-clocksum-string
  360. 'org-duration-from-minutes "Org 9.1")
  361. (define-obsolete-function-alias 'org-hh:mm-string-to-minutes
  362. 'org-duration-to-minutes "Org 9.1")
  363. (define-obsolete-function-alias 'org-duration-string-to-minutes
  364. 'org-duration-to-minutes "Org 9.1")
  365. (make-obsolete-variable 'org-time-clocksum-format
  366. "set `org-duration-format' instead." "Org 9.1")
  367. (make-obsolete-variable 'org-time-clocksum-use-fractional
  368. "set `org-duration-format' instead." "Org 9.1")
  369. (make-obsolete-variable 'org-time-clocksum-fractional-format
  370. "set `org-duration-format' instead." "Org 9.1")
  371. (make-obsolete-variable 'org-time-clocksum-use-effort-durations
  372. "set `org-duration-units' instead." "Org 9.1")
  373. (define-obsolete-function-alias 'org-babel-number-p
  374. 'org-babel--string-to-number "Org 9.0")
  375. (define-obsolete-variable-alias 'org-usenet-links-prefer-google
  376. 'org-gnus-prefer-web-links "Org 9.1")
  377. (define-obsolete-variable-alias 'org-texinfo-def-table-markup
  378. 'org-texinfo-table-default-markup "Org 9.1")
  379. (define-obsolete-variable-alias 'org-agenda-overriding-columns-format
  380. 'org-overriding-columns-format "Org 9.2.2")
  381. (define-obsolete-variable-alias 'org-doi-server-url
  382. 'org-link-doi-server-url "Org 9.3")
  383. (define-obsolete-variable-alias 'org-email-link-description-format
  384. 'org-link-email-description-format "Org 9.3")
  385. (define-obsolete-variable-alias 'org-make-link-description-function
  386. 'org-link-make-description-function "Org 9.3")
  387. (define-obsolete-variable-alias 'org-from-is-user-regexp
  388. 'org-link-from-user-regexp "Org 9.3")
  389. (define-obsolete-variable-alias 'org-descriptive-links
  390. 'org-link-descriptive "Org 9.3")
  391. (define-obsolete-variable-alias 'org-context-in-file-links
  392. 'org-link-context-for-files "Org 9.3")
  393. (define-obsolete-variable-alias 'org-keep-stored-link-after-insertion
  394. 'org-link-keep-stored-after-insertion "Org 9.3")
  395. (define-obsolete-variable-alias 'org-display-internal-link-with-indirect-buffer
  396. 'org-link-use-indirect-buffer-for-internals "Org 9.3")
  397. (define-obsolete-variable-alias 'org-confirm-shell-link-function
  398. 'org-link-shell-confirm-function "Org 9.3")
  399. (define-obsolete-variable-alias 'org-confirm-shell-link-not-regexp
  400. 'org-link-shell-skip-confirm-regexp "Org 9.3")
  401. (define-obsolete-variable-alias 'org-confirm-elisp-link-function
  402. 'org-link-elisp-confirm-function "Org 9.3")
  403. (define-obsolete-variable-alias 'org-confirm-elisp-link-not-regexp
  404. 'org-link-elisp-skip-confirm-regexp "Org 9.3")
  405. (define-obsolete-function-alias 'org-file-complete-link
  406. 'org-link-complete-file "Org 9.3")
  407. (define-obsolete-function-alias 'org-email-link-description
  408. 'org-link-email-description "Org 9.3")
  409. (define-obsolete-function-alias 'org-make-link-string
  410. 'org-link-make-string "Org 9.3")
  411. (define-obsolete-function-alias 'org-store-link-props
  412. 'org-link-store-props "Org 9.3")
  413. (define-obsolete-function-alias 'org-add-link-props
  414. 'org-link-add-props "Org 9.3")
  415. (define-obsolete-function-alias 'org-make-org-heading-search-string
  416. 'org-link-heading-search-string "Org 9.3")
  417. (define-obsolete-function-alias 'org-make-link-regexps
  418. 'org-link-make-regexps "Org 9.3")
  419. (define-obsolete-variable-alias 'org-angle-link-re
  420. 'org-link-angle-re "Org 9.3")
  421. (define-obsolete-variable-alias 'org-plain-link-re
  422. 'org-link-plain-re "Org 9.3")
  423. (define-obsolete-variable-alias 'org-bracket-link-regexp
  424. 'org-link-bracket-re "Org 9.3")
  425. (define-obsolete-variable-alias 'org-bracket-link-analytic-regexp
  426. 'org-link-bracket-re "Org 9.3")
  427. (define-obsolete-variable-alias 'org-any-link-re
  428. 'org-link-any-re "Org 9.3")
  429. (define-obsolete-function-alias 'org-open-link-from-string
  430. 'org-link-open-from-string "Org 9.3")
  431. (define-obsolete-function-alias 'org-add-angle-brackets
  432. 'org-link-add-angle-brackets "Org 9.3")
  433. ;; The function was made obsolete by commit 65399674d5 of 2013-02-22.
  434. ;; This make-obsolete call was added 2016-09-01.
  435. (make-obsolete 'org-capture-import-remember-templates
  436. "use the `org-capture-templates' variable instead."
  437. "Org 9.0")
  438. (defun org-show-block-all ()
  439. "Unfold all blocks in the current buffer."
  440. (interactive)
  441. (remove-overlays nil nil 'invisible 'org-hide-block))
  442. (make-obsolete 'org-show-block-all
  443. "use `org-show-all' instead."
  444. "Org 9.2")
  445. (define-obsolete-function-alias 'org-get-tags-at 'org-get-tags "Org 9.2")
  446. (defun org-get-local-tags ()
  447. "Get a list of tags defined in the current headline."
  448. (declare (obsolete "use `org-get-tags' instead." "Org 9.2"))
  449. (org-get-tags nil 'local))
  450. (defun org-get-local-tags-at (&optional pos)
  451. "Get a list of tags defined in the current headline."
  452. (declare (obsolete "use `org-get-tags' instead." "Org 9.2"))
  453. (org-get-tags pos 'local))
  454. (defun org-get-tags-string ()
  455. "Get the TAGS string in the current headline."
  456. (declare (obsolete "use `org-make-tag-string' instead." "Org 9.2"))
  457. (org-make-tag-string (org-get-tags nil t)))
  458. (define-obsolete-function-alias 'org-set-tags-to 'org-set-tags "Org 9.2")
  459. (defun org-align-all-tags ()
  460. "Align the tags in all headings."
  461. (declare (obsolete "use `org-align-tags' instead." "Org 9.2"))
  462. (org-align-tags t))
  463. (defmacro org-with-silent-modifications (&rest body)
  464. (declare (obsolete "use `with-silent-modifications' instead." "Org 9.2")
  465. (debug (body)))
  466. `(with-silent-modifications ,@body))
  467. (define-obsolete-function-alias 'org-babel-strip-quotes
  468. 'org-strip-quotes "Org 9.2")
  469. ;;;; Obsolete link types
  470. (eval-after-load 'ol
  471. '(progn
  472. (org-link-set-parameters "file+emacs") ;since Org 9.0
  473. (org-link-set-parameters "file+sys"))) ;since Org 9.0
  474. ;;; Miscellaneous functions
  475. (defun org-get-x-clipboard (value)
  476. "Get the value of the X or Windows clipboard."
  477. (cond ((and (eq window-system 'x)
  478. (fboundp 'gui-get-selection)) ;Silence byte-compiler.
  479. (org-no-properties
  480. (ignore-errors
  481. (or (gui-get-selection value 'UTF8_STRING)
  482. (gui-get-selection value 'COMPOUND_TEXT)
  483. (gui-get-selection value 'STRING)
  484. (gui-get-selection value 'TEXT)))))
  485. ((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
  486. (w32-get-clipboard-data))))
  487. ;; `set-transient-map' is only in Emacs >= 24.4
  488. (defalias 'org-set-transient-map
  489. (if (fboundp 'set-transient-map)
  490. 'set-transient-map
  491. 'set-temporary-overlay-map))
  492. ;;; Region compatibility
  493. (defvar org-ignore-region nil
  494. "Non-nil means temporarily disable the active region.")
  495. (defun org-region-active-p ()
  496. "Non-nil when the region active.
  497. Unlike to `use-region-p', this function also checks
  498. `org-ignore-region'."
  499. (and (not org-ignore-region) (use-region-p)))
  500. (defun org-cursor-to-region-beginning ()
  501. (when (and (org-region-active-p)
  502. (> (point) (region-beginning)))
  503. (exchange-point-and-mark)))
  504. ;;; Invisibility compatibility
  505. (defun org-in-invisibility-spec-p (arg)
  506. "Is ARG a member of `buffer-invisibility-spec'?"
  507. (when (consp buffer-invisibility-spec)
  508. (member arg buffer-invisibility-spec)))
  509. (defun org-move-to-column (column &optional force _buffer)
  510. "Move to column COLUMN.
  511. Pass COLUMN and FORCE to `move-to-column'."
  512. (let ((buffer-invisibility-spec
  513. (if (listp buffer-invisibility-spec)
  514. (remove '(org-filtered) buffer-invisibility-spec)
  515. buffer-invisibility-spec)))
  516. (move-to-column column force)))
  517. (defmacro org-find-library-dir (library)
  518. `(file-name-directory (or (locate-library ,library) "")))
  519. (defun org-count-lines (s)
  520. "How many lines in string S?"
  521. (let ((start 0) (n 1))
  522. (while (string-match "\n" s start)
  523. (setq start (match-end 0) n (1+ n)))
  524. (when (and (> (length s) 0) (= (aref s (1- (length s))) ?\n))
  525. (setq n (1- n)))
  526. n))
  527. (defun org-kill-new (string &rest args)
  528. (remove-text-properties 0 (length string) '(line-prefix t wrap-prefix t)
  529. string)
  530. (apply 'kill-new string args))
  531. ;; `font-lock-ensure' is only available from 24.4.50 on
  532. (defalias 'org-font-lock-ensure
  533. (if (fboundp 'font-lock-ensure)
  534. #'font-lock-ensure
  535. (lambda (&optional _beg _end)
  536. (with-no-warnings (font-lock-fontify-buffer)))))
  537. ;; `file-local-name' was added in Emacs 26.1.
  538. (defalias 'org-babel-local-file-name
  539. (if (fboundp 'file-local-name)
  540. 'file-local-name
  541. (lambda (file)
  542. "Return the local name component of FILE."
  543. (or (file-remote-p file 'localname) file))))
  544. ;;;###autoload
  545. (defmacro org-check-version ()
  546. "Try very hard to provide sensible version strings."
  547. (let* ((org-dir (org-find-library-dir "org"))
  548. (org-version.el (concat org-dir "org-version.el"))
  549. (org-fixup.el (concat org-dir "../mk/org-fixup.el")))
  550. (if (require 'org-version org-version.el 'noerror)
  551. '(progn
  552. (autoload 'org-release "org-version.el")
  553. (autoload 'org-git-version "org-version.el"))
  554. (if (require 'org-fixup org-fixup.el 'noerror)
  555. '(org-fixup)
  556. ;; provide fallback definitions and complain
  557. (warn "Could not define org version correctly. Check installation!")
  558. '(progn
  559. (defun org-release () "N/A")
  560. (defun org-git-version () "N/A !!check installation!!"))))))
  561. ;;; Functions for Emacs < 24.4 compatibility
  562. (defun org-define-error (name message)
  563. "Define NAME as a new error signal.
  564. MESSAGE is a string that will be output to the echo area if such
  565. an error is signaled without being caught by a `condition-case'.
  566. Implements `define-error' for older emacsen."
  567. (if (fboundp 'define-error) (define-error name message)
  568. (put name 'error-conditions
  569. (copy-sequence (cons name (get 'error 'error-conditions))))))
  570. (unless (fboundp 'string-suffix-p)
  571. ;; From Emacs subr.el.
  572. (defun string-suffix-p (suffix string &optional ignore-case)
  573. "Return non-nil if SUFFIX is a suffix of STRING.
  574. If IGNORE-CASE is non-nil, the comparison is done without paying
  575. attention to case differences."
  576. (let ((start-pos (- (length string) (length suffix))))
  577. (and (>= start-pos 0)
  578. (eq t (compare-strings suffix nil nil
  579. string start-pos nil ignore-case))))))
  580. (unless (fboundp 'proper-list-p)
  581. ;; `proper-list-p' was added in Emacs 27.1. The function below is
  582. ;; taken from Emacs subr.el 200195e824b^.
  583. (defun proper-list-p (object)
  584. "Return OBJECT's length if it is a proper list, nil otherwise.
  585. A proper list is neither circular nor dotted (i.e., its last cdr
  586. is nil)."
  587. (and (listp object) (ignore-errors (length object)))))
  588. ;;; Integration with and fixes for other packages
  589. (defgroup org-imenu-and-speedbar nil
  590. "Options concerning imenu and speedbar in Org mode."
  591. :tag "Org Imenu and Speedbar"
  592. :group 'org-structure)
  593. (defcustom org-imenu-depth 2
  594. "The maximum level for Imenu access to Org headlines.
  595. This also applied for speedbar access."
  596. :group 'org-imenu-and-speedbar
  597. :type 'integer)
  598. ;;;; Imenu
  599. (defvar-local org-imenu-markers nil
  600. "All markers currently used by Imenu.")
  601. (defun org-imenu-get-tree ()
  602. "Produce the index for Imenu."
  603. (dolist (x org-imenu-markers) (move-marker x nil))
  604. (setq org-imenu-markers nil)
  605. (org-with-wide-buffer
  606. (goto-char (point-max))
  607. (let* ((re (concat "^" (org-get-limited-outline-regexp)))
  608. (subs (make-vector (1+ org-imenu-depth) nil))
  609. (last-level 0))
  610. (while (re-search-backward re nil t)
  611. (let ((level (org-reduced-level (funcall outline-level)))
  612. (headline (org-no-properties
  613. (org-link-display-format (org-get-heading t t t t)))))
  614. (when (and (<= level org-imenu-depth) (org-string-nw-p headline))
  615. (let* ((m (point-marker))
  616. (item (propertize headline 'org-imenu-marker m 'org-imenu t)))
  617. (push m org-imenu-markers)
  618. (if (>= level last-level)
  619. (push (cons item m) (aref subs level))
  620. (push (cons item
  621. (cl-mapcan #'identity (cl-subseq subs (1+ level))))
  622. (aref subs level))
  623. (cl-loop for i from (1+ level) to org-imenu-depth
  624. do (aset subs i nil)))
  625. (setq last-level level)))))
  626. (aref subs 1))))
  627. (eval-after-load "imenu"
  628. '(progn
  629. (add-hook 'imenu-after-jump-hook
  630. (lambda ()
  631. (when (derived-mode-p 'org-mode)
  632. (org-show-context 'org-goto))))
  633. (add-hook 'org-mode-hook
  634. (lambda ()
  635. (setq imenu-create-index-function 'org-imenu-get-tree)))))
  636. ;;;; Speedbar
  637. (defvar org-speedbar-restriction-lock-overlay (make-overlay 1 1)
  638. "Overlay marking the agenda restriction line in speedbar.")
  639. (overlay-put org-speedbar-restriction-lock-overlay
  640. 'face 'org-agenda-restriction-lock)
  641. (overlay-put org-speedbar-restriction-lock-overlay
  642. 'help-echo "Agendas are currently limited to this item.")
  643. (delete-overlay org-speedbar-restriction-lock-overlay)
  644. (defun org-speedbar-set-agenda-restriction ()
  645. "Restrict future agenda commands to the location at point in speedbar.
  646. If there is already a restriction lock at the location, remove it.
  647. To get rid of the restriction, use `\\[org-agenda-remove-restriction-lock]'."
  648. (interactive)
  649. (require 'org-agenda)
  650. (let (p m tp np dir txt)
  651. (cond
  652. ((setq p (text-property-any (point-at-bol) (point-at-eol)
  653. 'org-imenu t))
  654. (setq m (get-text-property p 'org-imenu-marker))
  655. (with-current-buffer (marker-buffer m)
  656. (goto-char m)
  657. (if (and org-agenda-overriding-restriction
  658. (member org-agenda-restriction-lock-overlay
  659. (overlays-at (point))))
  660. (org-agenda-remove-restriction-lock 'noupdate)
  661. (org-agenda-set-restriction-lock 'subtree))))
  662. ((setq p (text-property-any (point-at-bol) (point-at-eol)
  663. 'speedbar-function 'speedbar-find-file))
  664. (setq tp (previous-single-property-change
  665. (1+ p) 'speedbar-function)
  666. np (next-single-property-change
  667. tp 'speedbar-function)
  668. dir (speedbar-line-directory)
  669. txt (buffer-substring-no-properties (or tp (point-min))
  670. (or np (point-max))))
  671. (with-current-buffer (find-file-noselect
  672. (let ((default-directory dir))
  673. (expand-file-name txt)))
  674. (unless (derived-mode-p 'org-mode)
  675. (user-error "Cannot restrict to non-Org mode file"))
  676. (org-agenda-set-restriction-lock 'file)))
  677. (t (user-error "Don't know how to restrict Org mode agenda")))
  678. (move-overlay org-speedbar-restriction-lock-overlay
  679. (point-at-bol) (point-at-eol))
  680. (setq current-prefix-arg nil)
  681. (org-agenda-maybe-redo)))
  682. (defvar speedbar-file-key-map)
  683. (declare-function speedbar-add-supported-extension "speedbar" (extension))
  684. (eval-after-load "speedbar"
  685. '(progn
  686. (speedbar-add-supported-extension ".org")
  687. (define-key speedbar-file-key-map "<" 'org-speedbar-set-agenda-restriction)
  688. (define-key speedbar-file-key-map "\C-c\C-x<" 'org-speedbar-set-agenda-restriction)
  689. (define-key speedbar-file-key-map ">" 'org-agenda-remove-restriction-lock)
  690. (define-key speedbar-file-key-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
  691. (add-hook 'speedbar-visiting-tag-hook
  692. (lambda () (and (derived-mode-p 'org-mode) (org-show-context 'org-goto))))))
  693. ;;;; Add Log
  694. (defun org-add-log-current-headline ()
  695. "Return current headline or nil.
  696. This function ignores inlinetasks. It is meant to be used as
  697. `add-log-current-defun-function' value."
  698. (org-with-limited-levels (org-get-heading t t t t)))
  699. ;;;; Flyspell
  700. (defun org--flyspell-object-check-p (element)
  701. "Non-nil when Flyspell can check object at point.
  702. ELEMENT is the element at point."
  703. (let ((object (save-excursion
  704. (when (looking-at-p "\\>") (backward-char))
  705. (org-element-context element))))
  706. (cl-case (org-element-type object)
  707. ;; Prevent checks in links due to keybinding conflict with
  708. ;; Flyspell.
  709. ((code entity export-snippet inline-babel-call
  710. inline-src-block line-break latex-fragment link macro
  711. statistics-cookie target timestamp verbatim)
  712. nil)
  713. (footnote-reference
  714. ;; Only in inline footnotes, within the definition.
  715. (and (eq (org-element-property :type object) 'inline)
  716. (< (save-excursion
  717. (goto-char (org-element-property :begin object))
  718. (search-forward ":" nil t 2))
  719. (point))))
  720. (otherwise t))))
  721. (defun org-mode-flyspell-verify ()
  722. "Function used for `flyspell-generic-check-word-predicate'."
  723. (if (org-at-heading-p)
  724. ;; At a headline or an inlinetask, check title only. This is
  725. ;; faster than relying on `org-element-at-point'.
  726. (and (save-excursion (beginning-of-line)
  727. (and (let ((case-fold-search t))
  728. (not (looking-at-p "\\*+ END[ \t]*$")))
  729. (let ((case-fold-search nil))
  730. (looking-at org-complex-heading-regexp))))
  731. (match-beginning 4)
  732. (>= (point) (match-beginning 4))
  733. (or (not (match-beginning 5))
  734. (< (point) (match-beginning 5))))
  735. (let* ((element (org-element-at-point))
  736. (post-affiliated (org-element-property :post-affiliated element)))
  737. (cond
  738. ;; Ignore checks in all affiliated keywords but captions.
  739. ((< (point) post-affiliated)
  740. (and (save-excursion
  741. (beginning-of-line)
  742. (let ((case-fold-search t)) (looking-at "[ \t]*#\\+CAPTION:")))
  743. (> (point) (match-end 0))
  744. (org--flyspell-object-check-p element)))
  745. ;; Ignore checks in LOGBOOK (or equivalent) drawer.
  746. ((let ((log (org-log-into-drawer)))
  747. (and log
  748. (let ((drawer (org-element-lineage element '(drawer))))
  749. (and drawer
  750. (eq (compare-strings
  751. log nil nil
  752. (org-element-property :drawer-name drawer) nil nil t)
  753. t)))))
  754. nil)
  755. (t
  756. (cl-case (org-element-type element)
  757. ((comment quote-section) t)
  758. (comment-block
  759. ;; Allow checks between block markers, not on them.
  760. (and (> (line-beginning-position) post-affiliated)
  761. (save-excursion
  762. (end-of-line)
  763. (skip-chars-forward " \r\t\n")
  764. (< (point) (org-element-property :end element)))))
  765. ;; Arbitrary list of keywords where checks are meaningful.
  766. ;; Make sure point is on the value part of the element.
  767. (keyword
  768. (and (member (org-element-property :key element)
  769. '("DESCRIPTION" "TITLE"))
  770. (save-excursion
  771. (search-backward ":" (line-beginning-position) t))))
  772. ;; Check is globally allowed in paragraphs verse blocks and
  773. ;; table rows (after affiliated keywords) but some objects
  774. ;; must not be affected.
  775. ((paragraph table-row verse-block)
  776. (let ((cbeg (org-element-property :contents-begin element))
  777. (cend (org-element-property :contents-end element)))
  778. (and cbeg (>= (point) cbeg) (< (point) cend)
  779. (org--flyspell-object-check-p element))))))))))
  780. (put 'org-mode 'flyspell-mode-predicate 'org-mode-flyspell-verify)
  781. (defun org-remove-flyspell-overlays-in (beg end)
  782. "Remove flyspell overlays in region."
  783. (and (bound-and-true-p flyspell-mode)
  784. (fboundp 'flyspell-delete-region-overlays)
  785. (flyspell-delete-region-overlays beg end)))
  786. (defvar flyspell-delayed-commands)
  787. (eval-after-load "flyspell"
  788. '(add-to-list 'flyspell-delayed-commands 'org-self-insert-command))
  789. ;;;; Bookmark
  790. (defun org-bookmark-jump-unhide ()
  791. "Unhide the current position, to show the bookmark location."
  792. (and (derived-mode-p 'org-mode)
  793. (or (org-invisible-p)
  794. (save-excursion (goto-char (max (point-min) (1- (point))))
  795. (org-invisible-p)))
  796. (org-show-context 'bookmark-jump)))
  797. ;; Make `bookmark-jump' shows the jump location if it was hidden.
  798. (eval-after-load "bookmark"
  799. '(if (boundp 'bookmark-after-jump-hook)
  800. ;; We can use the hook
  801. (add-hook 'bookmark-after-jump-hook 'org-bookmark-jump-unhide)
  802. ;; Hook not available, use advice
  803. (defadvice bookmark-jump (after org-make-visible activate)
  804. "Make the position visible."
  805. (org-bookmark-jump-unhide))))
  806. ;;;; Calendar
  807. (defcustom org-calendar-to-agenda-key 'default
  808. "Key to be installed in `calendar-mode-map' for switching to the agenda.
  809. The command `org-calendar-goto-agenda' will be bound to this key.
  810. When set to `default', bind the function to `c', but only if it is
  811. available in the Calendar keymap. This is the default choice because
  812. `c' can then be used to switch back and forth between agenda and calendar.
  813. When nil, `org-calendar-goto-agenda' is not bound to any key."
  814. :group 'org-agenda
  815. :type '(choice
  816. (const :tag "Bind to `c' if available" default)
  817. (key-sequence :tag "Other binding")
  818. (const :tag "No binding" nil))
  819. :safe (lambda (v) (or (symbolp v) (stringp v)))
  820. :package-version '(Org . "9.2"))
  821. (defcustom org-calendar-insert-diary-entry-key [?i]
  822. "The key to be installed in `calendar-mode-map' for adding diary entries.
  823. This option is irrelevant until `org-agenda-diary-file' has been configured
  824. to point to an Org file. When that is the case, the command
  825. `org-agenda-diary-entry' will be bound to the key given here, by default
  826. `i'. In the calendar, `i' normally adds entries to `diary-file'. So
  827. if you want to continue doing this, you need to change this to a different
  828. key."
  829. :group 'org-agenda
  830. :type 'sexp)
  831. (defun org--setup-calendar-bindings ()
  832. "Bind Org functions in Calendar keymap."
  833. (pcase org-calendar-to-agenda-key
  834. (`nil nil)
  835. ((and key (pred stringp))
  836. (local-set-key (kbd key) #'org-calendar-goto-agenda))
  837. ((guard (not (lookup-key calendar-mode-map "c")))
  838. (local-set-key "c" #'org-calendar-goto-agenda))
  839. (_ nil))
  840. (unless (eq org-agenda-diary-file 'diary-file)
  841. (local-set-key org-calendar-insert-diary-entry-key
  842. #'org-agenda-diary-entry)))
  843. (eval-after-load "calendar"
  844. '(add-hook 'calendar-mode-hook #'org--setup-calendar-bindings))
  845. ;;;; Saveplace
  846. ;; Make sure saveplace shows the location if it was hidden
  847. (eval-after-load "saveplace"
  848. '(defadvice save-place-find-file-hook (after org-make-visible activate)
  849. "Make the position visible."
  850. (org-bookmark-jump-unhide)))
  851. ;;;; Ecb
  852. ;; Make sure ecb shows the location if it was hidden
  853. (eval-after-load "ecb"
  854. '(defadvice ecb-method-clicked (after esf/org-show-context activate)
  855. "Make hierarchy visible when jumping into location from ECB tree buffer."
  856. (when (derived-mode-p 'org-mode)
  857. (org-show-context))))
  858. ;;;; Simple
  859. (defun org-mark-jump-unhide ()
  860. "Make the point visible with `org-show-context' after jumping to the mark."
  861. (when (and (derived-mode-p 'org-mode)
  862. (org-invisible-p))
  863. (org-show-context 'mark-goto)))
  864. (eval-after-load "simple"
  865. '(defadvice pop-to-mark-command (after org-make-visible activate)
  866. "Make the point visible with `org-show-context'."
  867. (org-mark-jump-unhide)))
  868. (eval-after-load "simple"
  869. '(defadvice exchange-point-and-mark (after org-make-visible activate)
  870. "Make the point visible with `org-show-context'."
  871. (org-mark-jump-unhide)))
  872. (eval-after-load "simple"
  873. '(defadvice pop-global-mark (after org-make-visible activate)
  874. "Make the point visible with `org-show-context'."
  875. (org-mark-jump-unhide)))
  876. ;;;; Session
  877. ;; Make "session.el" ignore our circular variable.
  878. (defvar session-globals-exclude)
  879. (eval-after-load "session"
  880. '(add-to-list 'session-globals-exclude 'org-mark-ring))
  881. (provide 'org-compat)
  882. ;;; org-compat.el ends here