org-compat.el 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  1. ;;; org-compat.el --- Compatibility Code for Older Emacsen -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2004-2022 Free Software Foundation, Inc.
  3. ;; Author: Carsten Dominik <carsten.dominik@gmail.com>
  4. ;; Keywords: outlines, hypermedia, calendar, wp
  5. ;; URL: 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 'seq)
  27. (require 'org-macs)
  28. ;; We rely on org-compat when generating Org version. Checking Org
  29. ;; version here will interfere with Org build process.
  30. ;; (org-assert-version)
  31. (declare-function org-agenda-diary-entry "org-agenda")
  32. (declare-function org-agenda-maybe-redo "org-agenda" ())
  33. (declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type))
  34. (declare-function org-agenda-remove-restriction-lock "org-agenda" (&optional noupdate))
  35. (declare-function org-calendar-goto-agenda "org-agenda" ())
  36. (declare-function org-align-tags "org" (&optional all))
  37. (declare-function org-at-heading-p "org" (&optional ignored))
  38. (declare-function org-at-table.el-p "org" ())
  39. (declare-function org-element-at-point "org-element" (&optional pom cached-only))
  40. (declare-function org-element-at-point-no-context "org-element" (&optional pom))
  41. (declare-function org-element-context "org-element" (&optional element))
  42. (declare-function org-element-lineage "org-element" (blob &optional types with-self))
  43. (declare-function org-element-type "org-element" (element))
  44. (declare-function org-element-property "org-element" (property element))
  45. (declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
  46. (declare-function org-get-heading "org" (&optional no-tags no-todo no-priority no-comment))
  47. (declare-function org-get-tags "org" (&optional pos local))
  48. (declare-function org-fold-hide-block-toggle "org-fold" (&optional force no-error element))
  49. (declare-function org-link-display-format "ol" (s))
  50. (declare-function org-link-set-parameters "ol" (type &rest rest))
  51. (declare-function org-log-into-drawer "org" ())
  52. (declare-function org-make-tag-string "org" (tags))
  53. (declare-function org-reduced-level "org" (l))
  54. (declare-function org-return "org" (&optional indent arg interactive))
  55. (declare-function org-fold-show-context "org-fold" (&optional key))
  56. (declare-function org-table-end "org-table" (&optional table-type))
  57. (declare-function outline-next-heading "outline" ())
  58. (declare-function speedbar-line-directory "speedbar" (&optional depth))
  59. (declare-function table--at-cell-p "table" (position &optional object at-column))
  60. (declare-function org-fold-region "org-fold" (from to flag &optional spec))
  61. (declare-function org-fold-show-all "org-fold" (&optional types))
  62. (defvar calendar-mode-map)
  63. (defvar org-complex-heading-regexp)
  64. (defvar org-agenda-diary-file)
  65. (defvar org-agenda-overriding-restriction)
  66. (defvar org-agenda-restriction-lock-overlay)
  67. (defvar org-table-any-border-regexp)
  68. (defvar org-table-dataline-regexp)
  69. (defvar org-table-tab-recognizes-table.el)
  70. (defvar org-table1-hline-regexp)
  71. (defvar org-fold-core-style)
  72. ;;; Emacs < 29 compatibility
  73. (defvar org-file-has-changed-p--hash-table (make-hash-table :test #'equal)
  74. "Internal variable used by `org-file-has-changed-p'.")
  75. (if (fboundp 'file-has-changed-p)
  76. (defalias 'org-file-has-changed-p #'file-has-changed-p)
  77. (defun org-file-has-changed-p (file &optional tag)
  78. "Return non-nil if FILE has changed.
  79. The size and modification time of FILE are compared to the size
  80. and modification time of the same FILE during a previous
  81. invocation of `org-file-has-changed-p'. Thus, the first invocation
  82. of `org-file-has-changed-p' always returns non-nil when FILE exists.
  83. The optional argument TAG, which must be a symbol, can be used to
  84. limit the comparison to invocations with identical tags; it can be
  85. the symbol of the calling function, for example."
  86. (let* ((file (directory-file-name (expand-file-name file)))
  87. (remote-file-name-inhibit-cache t)
  88. (fileattr (file-attributes file 'integer))
  89. (attr (and fileattr
  90. (cons (file-attribute-size fileattr)
  91. (file-attribute-modification-time fileattr))))
  92. (sym (concat (symbol-name tag) "@" file))
  93. (cachedattr (gethash sym org-file-has-changed-p--hash-table)))
  94. (when (not (equal attr cachedattr))
  95. (puthash sym attr org-file-has-changed-p--hash-table)))))
  96. ;;; Emacs < 28.1 compatibility
  97. (if (fboundp 'file-name-concat)
  98. (defalias 'org-file-name-concat #'file-name-concat)
  99. (defun org-file-name-concat (directory &rest components)
  100. "Append COMPONENTS to DIRECTORY and return the resulting string.
  101. Elements in COMPONENTS must be a string or nil.
  102. DIRECTORY or the non-final elements in COMPONENTS may or may not end
  103. with a slash -- if they don't end with a slash, a slash will be
  104. inserted before contatenating."
  105. (save-match-data
  106. (mapconcat
  107. #'identity
  108. (delq nil
  109. (mapcar
  110. (lambda (str)
  111. (when (and str (not (seq-empty-p str))
  112. (string-match "\\(.+\\)/?" str))
  113. (match-string 1 str)))
  114. (cons directory components)))
  115. "/"))))
  116. (if (fboundp 'directory-empty-p)
  117. (defalias 'org-directory-empty-p #'directory-empty-p)
  118. (defun org-directory-empty-p (dir)
  119. "Return t if DIR names an existing directory containing no other files."
  120. (and (file-directory-p dir)
  121. (null (directory-files dir nil directory-files-no-dot-files-regexp t)))))
  122. ;;; Emacs < 27.1 compatibility
  123. (unless (fboundp 'combine-change-calls)
  124. ;; A stub when `combine-change-calls' was not yet there.
  125. (defmacro combine-change-calls (_beg _end &rest body)
  126. (declare (debug (form form def-body)) (indent 2))
  127. `(progn ,@body)))
  128. (if (version< emacs-version "27.1")
  129. (defsubst org-replace-buffer-contents (source &optional _max-secs _max-costs)
  130. (replace-buffer-contents source))
  131. (defalias 'org-replace-buffer-contents #'replace-buffer-contents))
  132. (unless (fboundp 'proper-list-p)
  133. ;; `proper-list-p' was added in Emacs 27.1. The function below is
  134. ;; taken from Emacs subr.el 200195e824b^.
  135. (defun proper-list-p (object)
  136. "Return OBJECT's length if it is a proper list, nil otherwise.
  137. A proper list is neither circular nor dotted (i.e., its last cdr
  138. is nil)."
  139. (and (listp object) (ignore-errors (length object)))))
  140. (if (fboundp 'xor)
  141. ;; `xor' was added in Emacs 27.1.
  142. (defalias 'org-xor #'xor)
  143. (defsubst org-xor (a b)
  144. "Exclusive `or'."
  145. (if a (not b) b)))
  146. (unless (fboundp 'pcomplete-uniquify-list)
  147. ;; The misspelled variant was made obsolete in Emacs 27.1
  148. (defalias 'pcomplete-uniquify-list 'pcomplete-uniqify-list))
  149. (if (fboundp 'time-convert)
  150. (progn
  151. (defsubst org-time-convert-to-integer (time)
  152. (time-convert time 'integer))
  153. (defsubst org-time-convert-to-list (time)
  154. (time-convert time 'list)))
  155. (defun org-time-convert-to-integer (time)
  156. (floor (float-time time)))
  157. (defun org-time-convert-to-list (time)
  158. (seconds-to-time (float-time time))))
  159. ;; `newline-and-indent' did not take a numeric argument before 27.1.
  160. (if (version< emacs-version "27")
  161. (defsubst org-newline-and-indent (&optional _arg)
  162. (newline-and-indent))
  163. (defalias 'org-newline-and-indent #'newline-and-indent))
  164. (defun org--set-faces-extend (faces extend-p)
  165. "Set the :extend attribute of FACES to EXTEND-P.
  166. This is a no-op for Emacs versions lower than 27, since face
  167. extension beyond end of line was not controllable."
  168. (when (fboundp 'set-face-extend)
  169. (mapc (lambda (f) (set-face-extend f extend-p)) faces)))
  170. (if (fboundp 'string-distance)
  171. (defalias 'org-string-distance 'string-distance)
  172. (defun org-string-distance (s1 s2)
  173. "Return the edit (levenshtein) distance between strings S1 S2."
  174. (let* ((l1 (length s1))
  175. (l2 (length s2))
  176. (dist (vconcat (mapcar (lambda (_) (make-vector (1+ l2) nil))
  177. (number-sequence 1 (1+ l1)))))
  178. (in (lambda (i j) (aref (aref dist i) j))))
  179. (setf (aref (aref dist 0) 0) 0)
  180. (dolist (j (number-sequence 1 l2))
  181. (setf (aref (aref dist 0) j) j))
  182. (dolist (i (number-sequence 1 l1))
  183. (setf (aref (aref dist i) 0) i)
  184. (dolist (j (number-sequence 1 l2))
  185. (setf (aref (aref dist i) j)
  186. (min
  187. (1+ (funcall in (1- i) j))
  188. (1+ (funcall in i (1- j)))
  189. (+ (if (equal (aref s1 (1- i)) (aref s2 (1- j))) 0 1)
  190. (funcall in (1- i) (1- j)))))))
  191. (funcall in l1 l2))))
  192. (define-obsolete-function-alias 'org-babel-edit-distance 'org-string-distance
  193. "9.5")
  194. (unless (fboundp 'with-connection-local-variables)
  195. ;; Added in Emacs 27: commit:21f54feee8, 2019-03-09.
  196. ;; Redefining it using the old function `with-connection-local-profiles'.
  197. (defmacro with-connection-local-variables (&rest body)
  198. "Apply connection-local variables according to `default-directory'.
  199. Execute BODY, and unwind connection-local variables."
  200. (declare (debug t))
  201. `(with-connection-local-profiles (connection-local-get-profiles)
  202. ,@body)))
  203. ;;; Emacs < 26.1 compatibility
  204. (if (fboundp 'line-number-display-width)
  205. (defalias 'org-line-number-display-width 'line-number-display-width)
  206. (defun org-line-number-display-width (&rest _) 0))
  207. (if (fboundp 'buffer-hash)
  208. (defalias 'org-buffer-hash 'buffer-hash)
  209. (defun org-buffer-hash () (md5 (current-buffer))))
  210. (unless (fboundp 'file-attribute-modification-time)
  211. (defsubst file-attribute-modification-time (attributes)
  212. "The modification time in ATTRIBUTES returned by `file-attributes'.
  213. This is the time of the last change to the file's contents, and
  214. is a list of integers (HIGH LOW USEC PSEC) in the same style
  215. as (current-time)."
  216. (nth 5 attributes)))
  217. (unless (fboundp 'file-attribute-size)
  218. (defsubst file-attribute-size (attributes)
  219. "The size (in bytes) in ATTRIBUTES returned by `file-attributes'.
  220. This is a floating point number if the size is too large for an integer."
  221. (nth 7 attributes)))
  222. ;;; Obsolete aliases (remove them after the next major release).
  223. ;;;; XEmacs compatibility, now removed.
  224. (define-obsolete-function-alias 'org-activate-mark 'activate-mark "9.0")
  225. (define-obsolete-function-alias 'org-add-hook 'add-hook "9.0")
  226. (define-obsolete-function-alias 'org-bound-and-true-p 'bound-and-true-p "9.0")
  227. (define-obsolete-function-alias 'org-decompose-region 'decompose-region "9.0")
  228. (define-obsolete-function-alias 'org-defvaralias 'defvaralias "9.0")
  229. (define-obsolete-function-alias 'org-detach-overlay 'delete-overlay "9.0")
  230. (define-obsolete-function-alias 'org-file-equal-p 'file-equal-p "9.0")
  231. (define-obsolete-function-alias 'org-float-time 'float-time "9.0")
  232. (define-obsolete-function-alias 'org-indent-line-to 'indent-line-to "9.0")
  233. (define-obsolete-function-alias 'org-indent-to-column 'indent-to-column "9.0")
  234. (define-obsolete-function-alias 'org-looking-at-p 'looking-at-p "9.0")
  235. (define-obsolete-function-alias 'org-looking-back 'looking-back "9.0")
  236. (define-obsolete-function-alias 'org-match-string-no-properties 'match-string-no-properties "9.0")
  237. (define-obsolete-function-alias 'org-propertize 'propertize "9.0")
  238. (define-obsolete-function-alias 'org-select-frame-set-input-focus 'select-frame-set-input-focus "9.0")
  239. (define-obsolete-function-alias 'org-file-remote-p 'file-remote-p "9.2")
  240. (define-obsolete-function-alias 'org-show-context 'org-fold-show-context "9.6")
  241. (define-obsolete-function-alias 'org-show-entry 'org-fold-show-entry "9.6")
  242. (define-obsolete-function-alias 'org-show-children 'org-fold-show-children "9.6")
  243. (defmacro org-re (s)
  244. "Replace posix classes in regular expression S."
  245. (declare (debug (form))
  246. (obsolete "you can safely remove it." "9.0"))
  247. s)
  248. ;;;; Functions from cl-lib that Org used to have its own implementation of.
  249. (define-obsolete-function-alias 'org-count 'cl-count "9.0")
  250. (define-obsolete-function-alias 'org-every 'cl-every "9.0")
  251. (define-obsolete-function-alias 'org-find-if 'cl-find-if "9.0")
  252. (define-obsolete-function-alias 'org-reduce 'cl-reduce "9.0")
  253. (define-obsolete-function-alias 'org-remove-if 'cl-remove-if "9.0")
  254. (define-obsolete-function-alias 'org-remove-if-not 'cl-remove-if-not "9.0")
  255. (define-obsolete-function-alias 'org-some 'cl-some "9.0")
  256. (define-obsolete-function-alias 'org-floor* 'cl-floor "9.0")
  257. (defun org-sublist (list start end)
  258. "Return a section of LIST, from START to END.
  259. Counting starts at 1."
  260. (cl-subseq list (1- start) end))
  261. (make-obsolete 'org-sublist
  262. "use cl-subseq (note the 0-based counting)."
  263. "9.0")
  264. ;;;; Functions available since Emacs 25.1
  265. (define-obsolete-function-alias 'org-string-collate-lessp 'string-collate-lessp "9.6")
  266. (define-obsolete-function-alias 'org-decode-time 'decode-time "9.6")
  267. (define-obsolete-function-alias 'org-format-time-string 'format-time-string "9.6")
  268. (define-obsolete-function-alias 'org-time-add 'time-add "9.6")
  269. (define-obsolete-function-alias 'org-time-subtract 'time-subtract "9.6")
  270. (define-obsolete-function-alias 'org-time-since 'time-since "9.6")
  271. (define-obsolete-function-alias 'org-time-less-p 'time-less-p "9.6")
  272. ;;;; Functions available since Emacs 24.3
  273. (define-obsolete-function-alias 'org-buffer-narrowed-p 'buffer-narrowed-p "9.0")
  274. (define-obsolete-function-alias 'org-called-interactively-p 'called-interactively-p "9.0")
  275. (define-obsolete-function-alias 'org-char-to-string 'char-to-string "9.0")
  276. (define-obsolete-function-alias 'org-delete-directory 'delete-directory "9.0")
  277. (define-obsolete-function-alias 'org-format-seconds 'format-seconds "9.0")
  278. (define-obsolete-function-alias 'org-link-escape-browser 'url-encode-url "9.0")
  279. (define-obsolete-function-alias 'org-no-warnings 'with-no-warnings "9.0")
  280. (define-obsolete-function-alias 'org-number-sequence 'number-sequence "9.0")
  281. (define-obsolete-function-alias 'org-pop-to-buffer-same-window 'pop-to-buffer-same-window "9.0")
  282. (define-obsolete-function-alias 'org-string-match-p 'string-match-p "9.0")
  283. ;;;; Functions and variables from previous releases now obsolete.
  284. (define-obsolete-variable-alias 'org-export-before-processing-hook
  285. 'org-export-before-processing-functions "Org 9.6")
  286. (define-obsolete-variable-alias 'org-export-before-parsing-hook
  287. 'org-export-before-parsing-functions "Org 9.6")
  288. (define-obsolete-function-alias 'org-element-remove-indentation
  289. 'org-remove-indentation "9.0")
  290. (define-obsolete-variable-alias 'org-latex-create-formula-image-program
  291. 'org-preview-latex-default-process "9.0")
  292. (define-obsolete-variable-alias 'org-latex-preview-ltxpng-directory
  293. 'org-preview-latex-image-directory "9.0")
  294. (define-obsolete-variable-alias 'org-latex-listings
  295. 'org-latex-src-block-backend "9.6")
  296. (define-obsolete-function-alias 'org-table-p 'org-at-table-p "9.0")
  297. (define-obsolete-function-alias 'org-on-heading-p 'org-at-heading-p "9.0")
  298. (define-obsolete-function-alias 'org-at-regexp-p 'org-in-regexp "8.3")
  299. (define-obsolete-function-alias 'org-image-file-name-regexp
  300. 'image-file-name-regexp "9.0")
  301. (define-obsolete-function-alias 'org-completing-read-no-i
  302. 'completing-read "9.0")
  303. (define-obsolete-function-alias 'org-icompleting-read
  304. 'completing-read "9.0")
  305. (define-obsolete-function-alias 'org-iread-file-name 'read-file-name "9.0")
  306. (define-obsolete-function-alias 'org-days-to-time
  307. 'org-time-stamp-to-now "8.2")
  308. (define-obsolete-variable-alias 'org-agenda-ignore-drawer-properties
  309. 'org-agenda-ignore-properties "9.0")
  310. (define-obsolete-function-alias 'org-preview-latex-fragment
  311. 'org-toggle-latex-fragment "8.3")
  312. (define-obsolete-function-alias 'org-export-get-genealogy
  313. 'org-element-lineage "9.0")
  314. (define-obsolete-variable-alias 'org-latex-with-hyperref
  315. 'org-latex-hyperref-template "9.0")
  316. (define-obsolete-variable-alias 'hfy-optimisations 'hfy-optimizations "9.0")
  317. (define-obsolete-variable-alias 'org-export-htmlized-org-css-url
  318. 'org-org-htmlized-css-url "8.2")
  319. (define-obsolete-function-alias 'org-list-parse-list 'org-list-to-lisp "9.0")
  320. (define-obsolete-function-alias 'org-agenda-todayp
  321. 'org-agenda-today-p "9.0")
  322. (define-obsolete-function-alias 'org-babel-examplize-region
  323. 'org-babel-examplify-region "9.0")
  324. (define-obsolete-variable-alias 'org-babel-capitalize-example-region-markers
  325. 'org-babel-uppercase-example-markers "9.1")
  326. (define-obsolete-function-alias 'org-babel-trim 'org-trim "9.0")
  327. (define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4")
  328. (define-obsolete-function-alias 'org-insert-columns-dblock
  329. 'org-columns-insert-dblock "9.0")
  330. (define-obsolete-variable-alias 'org-export-babel-evaluate
  331. 'org-export-use-babel "9.1")
  332. (define-obsolete-function-alias 'org-activate-bracket-links
  333. 'org-activate-links "9.0")
  334. (define-obsolete-function-alias 'org-activate-plain-links 'ignore "9.0")
  335. (define-obsolete-function-alias 'org-activate-angle-links 'ignore "9.0")
  336. (define-obsolete-function-alias 'org-remove-double-quotes 'org-strip-quotes "9.0")
  337. (define-obsolete-function-alias 'org-get-indentation
  338. 'current-indentation "9.2")
  339. (define-obsolete-function-alias 'org-capture-member 'org-capture-get "9.2")
  340. (define-obsolete-function-alias 'org-remove-from-invisibility-spec
  341. 'remove-from-invisibility-spec "9.2")
  342. (define-obsolete-variable-alias 'org-effort-durations 'org-duration-units
  343. "9.2")
  344. (define-obsolete-function-alias 'org-toggle-latex-fragment 'org-latex-preview
  345. "9.3")
  346. (define-obsolete-function-alias 'org-remove-latex-fragment-image-overlays
  347. 'org-clear-latex-preview "9.3")
  348. (define-obsolete-function-alias 'org-hide-archived-subtrees
  349. 'org-fold-hide-archived-subtrees "9.6")
  350. (define-obsolete-function-alias 'org-flag-region
  351. 'org-fold-region "9.6")
  352. (define-obsolete-function-alias 'org-flag-subtree
  353. 'org-fold-subtree "9.6")
  354. (define-obsolete-function-alias 'org-hide-entry
  355. 'org-fold-hide-entry "9.6")
  356. (define-obsolete-function-alias 'org-show-subtree
  357. 'org-fold-show-subtree "9.6")
  358. (define-obsolete-function-alias 'org--hide-wrapper-toggle
  359. 'org-fold--hide-wrapper-toggle "9.6")
  360. (define-obsolete-function-alias 'org-hide-block-toggle
  361. 'org-fold-hide-block-toggle "9.6")
  362. (define-obsolete-function-alias 'org-hide-drawer-toggle
  363. 'org-fold-hide-drawer-toggle "9.6")
  364. (define-obsolete-function-alias 'org--hide-drawers
  365. 'org-fold--hide-drawers "9.6")
  366. (define-obsolete-function-alias 'org-hide-block-all
  367. 'org-fold-hide-block-all "9.6")
  368. (define-obsolete-function-alias 'org-hide-drawer-all
  369. 'org-fold-hide-drawer-all "9.6")
  370. (define-obsolete-function-alias 'org-show-all
  371. 'org-fold-show-all "9.6")
  372. (define-obsolete-function-alias 'org-set-startup-visibility
  373. 'org-cycle-set-startup-visibility "9.6")
  374. (define-obsolete-function-alias 'org-show-set-visibility
  375. 'org-fold-show-set-visibility "9.6")
  376. (define-obsolete-function-alias 'org-check-before-invisible-edit
  377. 'org-fold-check-before-invisible-edit "9.6")
  378. (define-obsolete-function-alias 'org-flag-above-first-heading
  379. 'org-fold-flag-above-first-heading "9.6")
  380. (define-obsolete-function-alias 'org-show-branches-buffer
  381. 'org-fold-show-branches-buffer "9.6")
  382. (define-obsolete-function-alias 'org-show-siblings
  383. 'org-fold-show-siblings "9.6")
  384. (define-obsolete-function-alias 'org-show-hidden-entry
  385. 'org-fold-show-hidden-entry "9.6")
  386. (define-obsolete-function-alias 'org-flag-heading
  387. 'org-fold-heading "9.6")
  388. (define-obsolete-function-alias 'org-set-startup-visibility
  389. 'org-cycle-set-startup-visibility "9.6")
  390. (define-obsolete-function-alias 'org-set-visibility-according-to-property
  391. 'org-cycle-set-visibility-according-to-property "9.6")
  392. (define-obsolete-variable-alias 'org-scroll-position-to-restore
  393. 'org-cycle-scroll-position-to-restore "9.6")
  394. (define-obsolete-function-alias 'org-optimize-window-after-visibility-change
  395. 'org-cycle-optimize-window-after-visibility-change "9.6")
  396. (define-obsolete-function-alias 'org-force-cycle-archived
  397. 'org-cycle-force-archived "9.6")
  398. (define-obsolete-variable-alias 'org-attach-directory
  399. 'org-attach-id-dir "9.3")
  400. (make-obsolete 'org-attach-store-link "No longer used" "9.4")
  401. (make-obsolete 'org-attach-expand-link "No longer used" "9.4")
  402. (define-obsolete-function-alias 'org-file-url-p 'org-url-p "9.5")
  403. (define-obsolete-variable-alias 'org-show-context-detail
  404. 'org-fold-show-context-detail "9.6")
  405. (define-obsolete-variable-alias 'org-catch-invisible-edits
  406. 'org-fold-catch-invisible-edits "9.6")
  407. (define-obsolete-variable-alias 'org-reveal-start-hook
  408. 'org-fold-reveal-start-hook "9.6")
  409. (define-obsolete-function-alias 'org-file-url-p 'org-url-p "9.6")
  410. (define-obsolete-variable-alias 'org-plantuml-executable-args 'org-plantuml-args
  411. "Org 9.6")
  412. (defun org-in-fixed-width-region-p ()
  413. "Non-nil if point in a fixed-width region."
  414. (save-match-data
  415. (eq 'fixed-width (org-element-type (org-element-at-point)))))
  416. (make-obsolete 'org-in-fixed-width-region-p
  417. "use `org-element' library"
  418. "9.0")
  419. (defun org-compatible-face (inherits specs)
  420. "Make a compatible face specification.
  421. If INHERITS is an existing face and if the Emacs version supports
  422. it, just inherit the face. If INHERITS is not given and SPECS
  423. is, use SPECS to define the face."
  424. (declare (indent 1))
  425. (if (facep inherits)
  426. (list (list t :inherit inherits))
  427. specs))
  428. (make-obsolete 'org-compatible-face "you can remove it." "9.0")
  429. (defun org-add-link-type (type &optional follow export)
  430. "Add a new TYPE link.
  431. FOLLOW and EXPORT are two functions.
  432. FOLLOW should take the link path as the single argument and do whatever
  433. is necessary to follow the link, for example find a file or display
  434. a mail message.
  435. EXPORT should format the link path for export to one of the export formats.
  436. It should be a function accepting three arguments:
  437. path the path of the link, the text after the prefix (like \"http:\")
  438. desc the description of the link, if any
  439. format the export format, a symbol like `html' or `latex' or `ascii'.
  440. The function may use the FORMAT information to return different values
  441. depending on the format. The return value will be put literally into
  442. the exported file. If the return value is nil, this means Org should
  443. do what it normally does with links which do not have EXPORT defined.
  444. Org mode has a built-in default for exporting links. If you are happy with
  445. this default, there is no need to define an export function for the link
  446. type. For a simple example of an export function, see `org-bbdb.el'.
  447. If TYPE already exists, update it with the arguments.
  448. See `org-link-parameters' for documentation on the other parameters."
  449. (org-link-set-parameters type :follow follow :export export)
  450. (message "Created %s link." type))
  451. (make-obsolete 'org-add-link-type "use `org-link-set-parameters' instead." "9.0")
  452. ;;;; Functions unused in Org core.
  453. (defun org-table-recognize-table.el ()
  454. "If there is a table.el table nearby, recognize it and move into it."
  455. (when (org-at-table.el-p)
  456. (beginning-of-line)
  457. (unless (or (looking-at org-table-dataline-regexp)
  458. (not (looking-at org-table1-hline-regexp)))
  459. (forward-line)
  460. (when (looking-at org-table-any-border-regexp)
  461. (forward-line -2)))
  462. (if (re-search-forward "|" (org-table-end t) t)
  463. (progn
  464. (require 'table)
  465. (if (table--at-cell-p (point)) t
  466. (message "recognizing table.el table...")
  467. (table-recognize-table)
  468. (message "recognizing table.el table...done")))
  469. (error "This should not happen"))))
  470. ;; Not used since commit 6d1e3082, Feb 2010.
  471. (make-obsolete 'org-table-recognize-table.el
  472. "please notify Org mailing list if you use this function."
  473. "9.0")
  474. (defmacro org-preserve-lc (&rest body)
  475. (declare (debug (body))
  476. (obsolete "please notify Org mailing list if you use this function."
  477. "9.2"))
  478. (org-with-gensyms (line col)
  479. `(let ((,line (org-current-line))
  480. (,col (current-column)))
  481. (unwind-protect
  482. (progn ,@body)
  483. (org-goto-line ,line)
  484. (org-move-to-column ,col)))))
  485. (defun org-version-check (version &rest _)
  486. "Non-nil if VERSION is lower (older) than `emacs-version'."
  487. (declare (obsolete "use `version<' or `fboundp' instead."
  488. "9.2"))
  489. (version< version emacs-version))
  490. (defun org-remove-angle-brackets (s)
  491. (org-unbracket-string "<" ">" s))
  492. (make-obsolete 'org-remove-angle-brackets 'org-unbracket-string "9.0")
  493. (defcustom org-publish-sitemap-file-entry-format "%t"
  494. "Format string for site-map file entry.
  495. You could use brackets to delimit on what part the link will be.
  496. %t is the title.
  497. %a is the author.
  498. %d is the date formatted using `org-publish-sitemap-date-format'."
  499. :group 'org-export-publish
  500. :type 'string)
  501. (make-obsolete-variable
  502. 'org-publish-sitemap-file-entry-format
  503. "set `:sitemap-format-entry' in `org-publish-project-alist' instead."
  504. "9.1")
  505. (defvar org-agenda-skip-regexp)
  506. (defun org-agenda-skip-entry-when-regexp-matches ()
  507. "Check if the current entry contains match for `org-agenda-skip-regexp'.
  508. If yes, it returns the end position of this entry, causing agenda commands
  509. to skip the entry but continuing the search in the subtree. This is a
  510. function that can be put into `org-agenda-skip-function' for the duration
  511. of a command."
  512. (declare (obsolete "use `org-agenda-skip-if' instead." "9.1"))
  513. (let ((end (save-excursion (org-end-of-subtree t)))
  514. skip)
  515. (save-excursion
  516. (setq skip (re-search-forward org-agenda-skip-regexp end t)))
  517. (and skip end)))
  518. (defun org-agenda-skip-subtree-when-regexp-matches ()
  519. "Check if the current subtree contains match for `org-agenda-skip-regexp'.
  520. If yes, it returns the end position of this tree, causing agenda commands
  521. to skip this subtree. This is a function that can be put into
  522. `org-agenda-skip-function' for the duration of a command."
  523. (declare (obsolete "use `org-agenda-skip-if' instead." "9.1"))
  524. (let ((end (save-excursion (org-end-of-subtree t)))
  525. skip)
  526. (save-excursion
  527. (setq skip (re-search-forward org-agenda-skip-regexp end t)))
  528. (and skip end)))
  529. (defun org-agenda-skip-entry-when-regexp-matches-in-subtree ()
  530. "Check if the current subtree contains match for `org-agenda-skip-regexp'.
  531. If yes, it returns the end position of the current entry (NOT the tree),
  532. causing agenda commands to skip the entry but continuing the search in
  533. the subtree. This is a function that can be put into
  534. `org-agenda-skip-function' for the duration of a command. An important
  535. use of this function is for the stuck project list."
  536. (declare (obsolete "use `org-agenda-skip-if' instead." "9.1"))
  537. (let ((end (save-excursion (org-end-of-subtree t)))
  538. (entry-end (save-excursion (outline-next-heading) (1- (point))))
  539. skip)
  540. (save-excursion
  541. (setq skip (re-search-forward org-agenda-skip-regexp end t)))
  542. (and skip entry-end)))
  543. (define-obsolete-function-alias 'org-minutes-to-clocksum-string
  544. 'org-duration-from-minutes "9.1")
  545. (define-obsolete-function-alias 'org-hh:mm-string-to-minutes
  546. 'org-duration-to-minutes "9.1")
  547. (define-obsolete-function-alias 'org-duration-string-to-minutes
  548. 'org-duration-to-minutes "9.1")
  549. (make-obsolete-variable 'org-time-clocksum-format
  550. "set `org-duration-format' instead." "9.1")
  551. (make-obsolete-variable 'org-time-clocksum-use-fractional
  552. "set `org-duration-format' instead." "9.1")
  553. (make-obsolete-variable 'org-time-clocksum-fractional-format
  554. "set `org-duration-format' instead." "9.1")
  555. (make-obsolete-variable 'org-time-clocksum-use-effort-durations
  556. "set `org-duration-units' instead." "9.1")
  557. (define-obsolete-function-alias 'org-babel-number-p
  558. 'org-babel--string-to-number "9.0")
  559. (define-obsolete-variable-alias 'org-usenet-links-prefer-google
  560. 'org-gnus-prefer-web-links "9.1")
  561. (define-obsolete-variable-alias 'org-texinfo-def-table-markup
  562. 'org-texinfo-table-default-markup "9.1")
  563. (define-obsolete-variable-alias 'org-agenda-overriding-columns-format
  564. 'org-overriding-columns-format "9.2.2")
  565. (define-obsolete-variable-alias 'org-doi-server-url
  566. 'org-link-doi-server-url "9.3")
  567. (define-obsolete-variable-alias 'org-email-link-description-format
  568. 'org-link-email-description-format "9.3")
  569. (define-obsolete-variable-alias 'org-make-link-description-function
  570. 'org-link-make-description-function "9.3")
  571. (define-obsolete-variable-alias 'org-from-is-user-regexp
  572. 'org-link-from-user-regexp "9.3")
  573. (define-obsolete-variable-alias 'org-descriptive-links
  574. 'org-link-descriptive "9.3")
  575. (define-obsolete-variable-alias 'org-context-in-file-links
  576. 'org-link-context-for-files "9.3")
  577. (define-obsolete-variable-alias 'org-keep-stored-link-after-insertion
  578. 'org-link-keep-stored-after-insertion "9.3")
  579. (define-obsolete-variable-alias 'org-display-internal-link-with-indirect-buffer
  580. 'org-link-use-indirect-buffer-for-internals "9.3")
  581. (define-obsolete-variable-alias 'org-confirm-shell-link-function
  582. 'org-link-shell-confirm-function "9.3")
  583. (define-obsolete-variable-alias 'org-confirm-shell-link-not-regexp
  584. 'org-link-shell-skip-confirm-regexp "9.3")
  585. (define-obsolete-variable-alias 'org-confirm-elisp-link-function
  586. 'org-link-elisp-confirm-function "9.3")
  587. (define-obsolete-variable-alias 'org-confirm-elisp-link-not-regexp
  588. 'org-link-elisp-skip-confirm-regexp "9.3")
  589. (define-obsolete-function-alias 'org-file-complete-link
  590. 'org-link-complete-file "9.3")
  591. (define-obsolete-function-alias 'org-email-link-description
  592. 'org-link-email-description "9.3")
  593. (define-obsolete-function-alias 'org-make-link-string
  594. 'org-link-make-string "9.3")
  595. (define-obsolete-function-alias 'org-store-link-props
  596. 'org-link-store-props "9.3")
  597. (define-obsolete-function-alias 'org-add-link-props
  598. 'org-link-add-props "9.3")
  599. (define-obsolete-function-alias 'org-make-org-heading-search-string
  600. 'org-link-heading-search-string "9.3")
  601. (define-obsolete-function-alias 'org-make-link-regexps
  602. 'org-link-make-regexps "9.3")
  603. (define-obsolete-function-alias 'org-property-global-value
  604. 'org-property-global-or-keyword-value "9.3")
  605. (make-obsolete-variable 'org-file-properties 'org-keyword-properties "9.3")
  606. (define-obsolete-variable-alias 'org-angle-link-re
  607. 'org-link-angle-re "9.3")
  608. (define-obsolete-variable-alias 'org-plain-link-re
  609. 'org-link-plain-re "9.3")
  610. (define-obsolete-variable-alias 'org-bracket-link-regexp
  611. 'org-link-bracket-re "9.3")
  612. (define-obsolete-variable-alias 'org-bracket-link-analytic-regexp
  613. 'org-link-bracket-re "9.3")
  614. (define-obsolete-variable-alias 'org-any-link-re
  615. 'org-link-any-re "9.3")
  616. (define-obsolete-function-alias 'org-open-link-from-string
  617. 'org-link-open-from-string "9.3")
  618. (define-obsolete-function-alias 'org-add-angle-brackets
  619. 'org-link-add-angle-brackets "9.3")
  620. ;; The function was made obsolete by commit 65399674d5 of 2013-02-22.
  621. ;; This make-obsolete call was added 2016-09-01.
  622. (make-obsolete 'org-capture-import-remember-templates
  623. "use the `org-capture-templates' variable instead."
  624. "9.0")
  625. (defun org-show-block-all ()
  626. "Unfold all blocks in the current buffer."
  627. (interactive)
  628. (org-fold-show-all '(blocks)))
  629. (make-obsolete 'org-show-block-all
  630. "use `org-show-all' instead."
  631. "9.2")
  632. (define-obsolete-function-alias 'org-get-tags-at 'org-get-tags "9.2")
  633. (defun org-get-local-tags ()
  634. "Get a list of tags defined in the current headline."
  635. (declare (obsolete "use `org-get-tags' instead." "9.2"))
  636. (org-get-tags nil 'local))
  637. (defun org-get-local-tags-at (&optional pos)
  638. "Get a list of tags defined in the current headline."
  639. (declare (obsolete "use `org-get-tags' instead." "9.2"))
  640. (org-get-tags pos 'local))
  641. (defun org-get-tags-string ()
  642. "Get the TAGS string in the current headline."
  643. (declare (obsolete "use `org-make-tag-string' instead." "9.2"))
  644. (org-make-tag-string (org-get-tags nil t)))
  645. (define-obsolete-function-alias 'org-set-tags-to 'org-set-tags "9.2")
  646. (defun org-align-all-tags ()
  647. "Align the tags in all headings."
  648. (declare (obsolete "use `org-align-tags' instead." "9.2"))
  649. (org-align-tags t))
  650. (define-obsolete-function-alias
  651. 'org-at-property-block-p 'org-at-property-drawer-p "9.4")
  652. (defun org-flag-drawer (flag &optional element beg end)
  653. "When FLAG is non-nil, hide the drawer we are at.
  654. Otherwise make it visible.
  655. When optional argument ELEMENT is a parsed drawer, as returned by
  656. `org-element-at-point', hide or show that drawer instead.
  657. When buffer positions BEG and END are provided, hide or show that
  658. region as a drawer without further ado."
  659. (declare (obsolete "use `org-hide-drawer-toggle' instead." "9.4"))
  660. (if (and beg end) (org-fold-region beg end flag (if (eq org-fold-core-style 'text-properties) 'drawer 'outline))
  661. (let ((drawer
  662. (or element
  663. (and (save-excursion
  664. (beginning-of-line)
  665. (looking-at-p "^[ \t]*:\\(\\(?:\\w\\|[-_]\\)+\\):[ \t]*$"))
  666. (org-element-at-point)))))
  667. (when (memq (org-element-type drawer) '(drawer property-drawer))
  668. (let ((post (org-element-property :post-affiliated drawer)))
  669. (org-fold-region
  670. (save-excursion (goto-char post) (line-end-position))
  671. (save-excursion (goto-char (org-element-property :end drawer))
  672. (skip-chars-backward " \t\n")
  673. (line-end-position))
  674. flag (if (eq org-fold-core-style 'text-properties) 'drawer 'outline))
  675. ;; When the drawer is hidden away, make sure point lies in
  676. ;; a visible part of the buffer.
  677. (when (invisible-p (max (1- (point)) (point-min)))
  678. (goto-char post)))))))
  679. (defun org-hide-block-toggle-maybe ()
  680. "Toggle visibility of block at point.
  681. Unlike to `org-hide-block-toggle', this function does not throw
  682. an error. Return a non-nil value when toggling is successful."
  683. (declare (obsolete "use `org-hide-block-toggle' instead." "9.4"))
  684. (interactive)
  685. (org-fold-hide-block-toggle nil t))
  686. (defun org-hide-block-toggle-all ()
  687. "Toggle the visibility of all blocks in the current buffer."
  688. (declare (obsolete "please notify Org mailing list if you use this function."
  689. "9.4"))
  690. (let ((start (point-min))
  691. (end (point-max)))
  692. (save-excursion
  693. (goto-char start)
  694. (while (and (< (point) end)
  695. (re-search-forward "^[ \t]*#\\+begin_?\
  696. \\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_?\\1[ \t]*$" end t))
  697. (save-excursion
  698. (save-match-data
  699. (goto-char (match-beginning 0))
  700. (org-fold-hide-block-toggle)))))))
  701. (defun org-return-indent ()
  702. "Goto next table row or insert a newline and indent.
  703. Calls `org-table-next-row' or `newline-and-indent', depending on
  704. context. See the individual commands for more information."
  705. (declare (obsolete "use `org-return' with INDENT set to t instead."
  706. "9.4"))
  707. (interactive)
  708. (org-return t))
  709. (defmacro org-with-silent-modifications (&rest body)
  710. (declare (obsolete "use `with-silent-modifications' instead." "9.2")
  711. (debug (body)))
  712. `(with-silent-modifications ,@body))
  713. (define-obsolete-function-alias 'org-babel-strip-quotes
  714. 'org-strip-quotes "9.2")
  715. (define-obsolete-variable-alias 'org-sort-agenda-notime-is-late
  716. 'org-agenda-sort-notime-is-late "9.4")
  717. (define-obsolete-variable-alias 'org-sort-agenda-noeffort-is-high
  718. 'org-agenda-sort-noeffort-is-high "9.4")
  719. (defconst org-maybe-keyword-time-regexp
  720. (concat "\\(\\<\\(\\(?:CLO\\(?:CK\\|SED\\)\\|DEADLINE\\|SCHEDULED\\):\\)\\)?"
  721. " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*[]>]"
  722. "\\|"
  723. "<%%([^\r\n>]*>\\)")
  724. "Matches a timestamp, possibly preceded by a keyword.")
  725. (make-obsolete-variable
  726. 'org-maybe-keyword-time-regexp
  727. "use `org-planning-line-re', followed by `org-ts-regexp-both' instead."
  728. "9.4")
  729. (define-obsolete-function-alias 'org-copy 'org-refile-copy "9.4")
  730. (define-obsolete-function-alias 'org-get-last-sibling 'org-get-previous-sibling "9.4")
  731. (define-obsolete-function-alias 'org-publish-cache-ctime-of-src
  732. 'org-publish-cache-mtime-of-src "9.6")
  733. (define-obsolete-function-alias 'org-truely-invisible-p
  734. 'org-truly-invisible-p "9.6"
  735. "Compatibility alias for legacy misspelling of `org-truly-invisible-p'.")
  736. (defconst org-latex-babel-language-alist
  737. '(("af" . "afrikaans")
  738. ("bg" . "bulgarian")
  739. ("ca" . "catalan")
  740. ("cs" . "czech")
  741. ("cy" . "welsh")
  742. ("da" . "danish")
  743. ("de" . "germanb")
  744. ("de-at" . "naustrian")
  745. ("de-de" . "ngerman")
  746. ("el" . "greek")
  747. ("en" . "english")
  748. ("en-au" . "australian")
  749. ("en-ca" . "canadian")
  750. ("en-gb" . "british")
  751. ("en-ie" . "irish")
  752. ("en-nz" . "newzealand")
  753. ("en-us" . "american")
  754. ("es" . "spanish")
  755. ("et" . "estonian")
  756. ("eu" . "basque")
  757. ("fi" . "finnish")
  758. ("fr" . "french")
  759. ("fr-ca" . "canadien")
  760. ("gl" . "galician")
  761. ("hr" . "croatian")
  762. ("hu" . "hungarian")
  763. ("id" . "indonesian")
  764. ("is" . "icelandic")
  765. ("it" . "italian")
  766. ("la" . "latin")
  767. ("ms" . "malay")
  768. ("nl" . "dutch")
  769. ("nb" . "norsk")
  770. ("nn" . "nynorsk")
  771. ("no" . "norsk")
  772. ("pl" . "polish")
  773. ("pt" . "portuguese")
  774. ("pt-br" . "brazilian")
  775. ("ro" . "romanian")
  776. ("ru" . "russian")
  777. ("sa" . "sanskrit")
  778. ("sb" . "uppersorbian")
  779. ("sk" . "slovak")
  780. ("sl" . "slovene")
  781. ("sq" . "albanian")
  782. ("sr" . "serbian")
  783. ("sv" . "swedish")
  784. ("ta" . "tamil")
  785. ("tr" . "turkish")
  786. ("uk" . "ukrainian"))
  787. "Alist between language code and corresponding Babel option.")
  788. (defconst org-latex-polyglossia-language-alist
  789. '(("am" "amharic")
  790. ("ar" "arabic")
  791. ("ast" "asturian")
  792. ("bg" "bulgarian")
  793. ("bn" "bengali")
  794. ("bo" "tibetan")
  795. ("br" "breton")
  796. ("ca" "catalan")
  797. ("cop" "coptic")
  798. ("cs" "czech")
  799. ("cy" "welsh")
  800. ("da" "danish")
  801. ("de" "german" "german")
  802. ("de-at" "german" "austrian")
  803. ("de-de" "german" "german")
  804. ("dsb" "lsorbian")
  805. ("dv" "divehi")
  806. ("el" "greek")
  807. ("en" "english" "usmax")
  808. ("en-au" "english" "australian")
  809. ("en-gb" "english" "uk")
  810. ("en-nz" "english" "newzealand")
  811. ("en-us" "english" "usmax")
  812. ("eo" "esperanto")
  813. ("es" "spanish")
  814. ("et" "estonian")
  815. ("eu" "basque")
  816. ("fa" "farsi")
  817. ("fi" "finnish")
  818. ("fr" "french")
  819. ("fu" "friulan")
  820. ("ga" "irish")
  821. ("gd" "scottish")
  822. ("gl" "galician")
  823. ("he" "hebrew")
  824. ("hi" "hindi")
  825. ("hr" "croatian")
  826. ("hsb" "usorbian")
  827. ("hu" "magyar")
  828. ("hy" "armenian")
  829. ("ia" "interlingua")
  830. ("id" "bahasai")
  831. ("is" "icelandic")
  832. ("it" "italian")
  833. ("kn" "kannada")
  834. ("la" "latin" "modern")
  835. ("la-classic" "latin" "classic")
  836. ("la-medieval" "latin" "medieval")
  837. ("la-modern" "latin" "modern")
  838. ("lo" "lao")
  839. ("lt" "lithuanian")
  840. ("lv" "latvian")
  841. ("ml" "malayalam")
  842. ("mr" "maranthi")
  843. ("nb" "norsk")
  844. ("nko" "nko")
  845. ("nl" "dutch")
  846. ("nn" "nynorsk")
  847. ("no" "norsk")
  848. ("oc" "occitan")
  849. ("pl" "polish")
  850. ("pms" "piedmontese")
  851. ("pt" "portuges")
  852. ("pt-br" "brazilian")
  853. ("rm" "romansh")
  854. ("ro" "romanian")
  855. ("ru" "russian")
  856. ("sa" "sanskrit")
  857. ("se" "samin")
  858. ("sk" "slovak")
  859. ("sl" "slovenian")
  860. ("sq" "albanian")
  861. ("sr" "serbian")
  862. ("sv" "swedish")
  863. ("syr" "syriac")
  864. ("ta" "tamil")
  865. ("te" "telugu")
  866. ("th" "thai")
  867. ("tk" "turkmen")
  868. ("tr" "turkish")
  869. ("uk" "ukrainian")
  870. ("ur" "urdu")
  871. ("vi" "vietnamese"))
  872. "Alist between language code and corresponding Polyglossia option.")
  873. (make-obsolete-variable 'org-latex-babel-language-alist
  874. "set `org-latex-language-alist' instead." "9.6")
  875. (make-obsolete-variable 'org-latex-polyglossia-language-alist
  876. "set `org-latex-language-alist' instead." "9.6")
  877. ;;;; Obsolete link types
  878. (eval-after-load 'ol
  879. '(progn
  880. (org-link-set-parameters "file+emacs") ;since Org 9.0
  881. (org-link-set-parameters "file+sys"))) ;since Org 9.0
  882. ;;; Miscellaneous functions
  883. (defun org-get-x-clipboard (value)
  884. "Get the value of the X or Windows clipboard."
  885. (cond ((and (eq window-system 'x)
  886. (fboundp 'gui-get-selection)) ;Silence byte-compiler.
  887. (org-no-properties
  888. (ignore-errors
  889. (or (gui-get-selection value 'UTF8_STRING)
  890. (gui-get-selection value 'COMPOUND_TEXT)
  891. (gui-get-selection value 'STRING)
  892. (gui-get-selection value 'TEXT)))))
  893. ((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
  894. (w32-get-clipboard-data))))
  895. ;;; Region compatibility
  896. (defvar org-ignore-region nil
  897. "Non-nil means temporarily disable the active region.")
  898. (defun org-region-active-p ()
  899. "Non-nil when the region active.
  900. Unlike to `use-region-p', this function also checks
  901. `org-ignore-region'."
  902. (and (not org-ignore-region) (use-region-p)))
  903. (defun org-cursor-to-region-beginning ()
  904. (when (and (org-region-active-p)
  905. (> (point) (region-beginning)))
  906. (exchange-point-and-mark)))
  907. ;;; Invisibility compatibility
  908. (defun org-in-invisibility-spec-p (arg)
  909. "Is ARG a member of `buffer-invisibility-spec'?"
  910. (when (consp buffer-invisibility-spec)
  911. (member arg buffer-invisibility-spec)))
  912. (defun org-move-to-column (column &optional force _buffer)
  913. "Move to column COLUMN.
  914. Pass COLUMN and FORCE to `move-to-column'."
  915. (let ((buffer-invisibility-spec
  916. (if (listp buffer-invisibility-spec)
  917. (remove '(org-filtered) buffer-invisibility-spec)
  918. buffer-invisibility-spec)))
  919. (move-to-column column force)))
  920. (defmacro org-find-library-dir (library)
  921. `(file-name-directory (or (locate-library ,library) "")))
  922. (defun org-count-lines (s)
  923. "How many lines in string S?"
  924. (let ((start 0) (n 1))
  925. (while (string-match "\n" s start)
  926. (setq start (match-end 0) n (1+ n)))
  927. (when (and (> (length s) 0) (= (aref s (1- (length s))) ?\n))
  928. (setq n (1- n)))
  929. n))
  930. (defun org-kill-new (string &rest args)
  931. (remove-text-properties 0 (length string) '(line-prefix t wrap-prefix t)
  932. string)
  933. (apply 'kill-new string args))
  934. ;; `file-local-name' was added in Emacs 26.1.
  935. (defalias 'org-babel-local-file-name
  936. (if (fboundp 'file-local-name)
  937. 'file-local-name
  938. (lambda (file)
  939. "Return the local name component of FILE."
  940. (or (file-remote-p file 'localname) file))))
  941. ;;;###autoload
  942. (defmacro org-check-version ()
  943. "Try very hard to provide sensible version strings."
  944. (let* ((org-dir (org-find-library-dir "org"))
  945. (org-version.el (concat org-dir "org-version.el"))
  946. (org-fixup.el (concat org-dir "../mk/org-fixup.el")))
  947. (if (require 'org-version org-version.el 'noerror)
  948. '(progn
  949. (autoload 'org-release "org-version.el")
  950. (autoload 'org-git-version "org-version.el"))
  951. (if (require 'org-fixup org-fixup.el 'noerror)
  952. '(org-fixup)
  953. ;; provide fallback definitions and complain
  954. (warn "Could not define org version correctly. Check installation!")
  955. '(progn
  956. (defun org-release () "N/A")
  957. (defun org-git-version () "N/A !!check installation!!"))))))
  958. (define-obsolete-function-alias 'org-define-error #'define-error "9.6")
  959. (define-obsolete-function-alias 'org-without-partial-completion 'progn "9.6")
  960. ;;; Integration with and fixes for other packages
  961. (defgroup org-imenu-and-speedbar nil
  962. "Options concerning imenu and speedbar in Org mode."
  963. :tag "Org Imenu and Speedbar"
  964. :group 'org-structure)
  965. (defcustom org-imenu-depth 2
  966. "The maximum level for Imenu access to Org headlines.
  967. This also applied for speedbar access."
  968. :type 'integer)
  969. ;;;; Imenu
  970. (defvar-local org-imenu-markers nil
  971. "All markers currently used by Imenu.")
  972. (defun org-imenu-get-tree ()
  973. "Produce the index for Imenu."
  974. (dolist (x org-imenu-markers) (move-marker x nil))
  975. (setq org-imenu-markers nil)
  976. (org-with-wide-buffer
  977. (goto-char (point-max))
  978. (let* ((re (concat "^" (org-get-limited-outline-regexp)))
  979. (subs (make-vector (1+ org-imenu-depth) nil))
  980. (last-level 0))
  981. (while (re-search-backward re nil t)
  982. (let ((level (org-reduced-level (funcall outline-level)))
  983. (headline (org-no-properties
  984. (org-link-display-format (org-get-heading t t t t)))))
  985. (when (and (<= level org-imenu-depth) (org-string-nw-p headline))
  986. (let* ((m (point-marker))
  987. (item (propertize headline 'org-imenu-marker m 'org-imenu t)))
  988. (push m org-imenu-markers)
  989. (if (>= level last-level)
  990. (push (cons item m) (aref subs level))
  991. (push (cons item
  992. (cl-mapcan #'identity (cl-subseq subs (1+ level))))
  993. (aref subs level))
  994. (cl-loop for i from (1+ level) to org-imenu-depth
  995. do (aset subs i nil)))
  996. (setq last-level level)))))
  997. (aref subs 1))))
  998. (eval-after-load 'imenu
  999. '(progn
  1000. (add-hook 'imenu-after-jump-hook
  1001. (lambda ()
  1002. (when (derived-mode-p 'org-mode)
  1003. (org-fold-show-context 'org-goto))))
  1004. (add-hook 'org-mode-hook
  1005. (lambda ()
  1006. (setq imenu-create-index-function 'org-imenu-get-tree)))))
  1007. ;;;; Speedbar
  1008. (defvar org-speedbar-restriction-lock-overlay (make-overlay 1 1)
  1009. "Overlay marking the agenda restriction line in speedbar.")
  1010. (overlay-put org-speedbar-restriction-lock-overlay
  1011. 'face 'org-agenda-restriction-lock)
  1012. (overlay-put org-speedbar-restriction-lock-overlay
  1013. 'help-echo "Agendas are currently limited to this item.")
  1014. (delete-overlay org-speedbar-restriction-lock-overlay)
  1015. (defun org-speedbar-set-agenda-restriction ()
  1016. "Restrict future agenda commands to the location at point in speedbar.
  1017. If there is already a restriction lock at the location, remove it.
  1018. To get rid of the restriction, use `\\[org-agenda-remove-restriction-lock]'."
  1019. (interactive)
  1020. (require 'org-agenda)
  1021. (let (p m tp np dir txt)
  1022. (cond
  1023. ((setq p (text-property-any (line-beginning-position) (line-end-position)
  1024. 'org-imenu t))
  1025. (setq m (get-text-property p 'org-imenu-marker))
  1026. (with-current-buffer (marker-buffer m)
  1027. (goto-char m)
  1028. (if (and org-agenda-overriding-restriction
  1029. (member org-agenda-restriction-lock-overlay
  1030. (overlays-at (point))))
  1031. (org-agenda-remove-restriction-lock 'noupdate)
  1032. (org-agenda-set-restriction-lock 'subtree))))
  1033. ((setq p (text-property-any (line-beginning-position) (line-end-position)
  1034. 'speedbar-function 'speedbar-find-file))
  1035. (setq tp (previous-single-property-change
  1036. (1+ p) 'speedbar-function)
  1037. np (next-single-property-change
  1038. tp 'speedbar-function)
  1039. dir (speedbar-line-directory)
  1040. txt (buffer-substring-no-properties (or tp (point-min))
  1041. (or np (point-max))))
  1042. (with-current-buffer (find-file-noselect
  1043. (let ((default-directory dir))
  1044. (expand-file-name txt)))
  1045. (unless (derived-mode-p 'org-mode)
  1046. (user-error "Cannot restrict to non-Org mode file"))
  1047. (org-agenda-set-restriction-lock 'file)))
  1048. (t (user-error "Don't know how to restrict Org mode agenda")))
  1049. (move-overlay org-speedbar-restriction-lock-overlay
  1050. (line-beginning-position) (line-end-position))
  1051. (setq current-prefix-arg nil)
  1052. (org-agenda-maybe-redo)))
  1053. (defvar speedbar-file-key-map)
  1054. (declare-function speedbar-add-supported-extension "speedbar" (extension))
  1055. (eval-after-load 'speedbar
  1056. '(progn
  1057. (speedbar-add-supported-extension ".org")
  1058. (define-key speedbar-file-key-map "<" 'org-speedbar-set-agenda-restriction)
  1059. (define-key speedbar-file-key-map "\C-c\C-x<" 'org-speedbar-set-agenda-restriction)
  1060. (define-key speedbar-file-key-map ">" 'org-agenda-remove-restriction-lock)
  1061. (define-key speedbar-file-key-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
  1062. (add-hook 'speedbar-visiting-tag-hook
  1063. (lambda () (and (derived-mode-p 'org-mode) (org-fold-show-context 'org-goto))))))
  1064. ;;;; Add Log
  1065. (defun org-add-log-current-headline ()
  1066. "Return current headline or nil.
  1067. This function ignores inlinetasks. It is meant to be used as
  1068. `add-log-current-defun-function' value."
  1069. (org-with-limited-levels (org-get-heading t t t t)))
  1070. ;;;; Flyspell
  1071. (defun org--flyspell-object-check-p (element)
  1072. "Non-nil when Flyspell can check object at point.
  1073. ELEMENT is the element at point."
  1074. (let ((object (save-excursion
  1075. (when (looking-at-p "\\>") (backward-char))
  1076. (org-element-context element))))
  1077. (cl-case (org-element-type object)
  1078. ;; Prevent checks in links due to keybinding conflict with
  1079. ;; Flyspell.
  1080. ((citation citation-reference code entity export-snippet inline-babel-call
  1081. inline-src-block line-break latex-fragment link macro
  1082. statistics-cookie target timestamp verbatim)
  1083. nil)
  1084. (footnote-reference
  1085. ;; Only in inline footnotes, within the definition.
  1086. (and (eq (org-element-property :type object) 'inline)
  1087. (< (save-excursion
  1088. (goto-char (org-element-property :begin object))
  1089. (search-forward ":" nil t 2))
  1090. (point))))
  1091. (otherwise t))))
  1092. (defun org-mode-flyspell-verify ()
  1093. "Function used for `flyspell-generic-check-word-predicate'."
  1094. (if (org-at-heading-p)
  1095. ;; At a headline or an inlinetask, check title only.
  1096. (and (save-excursion (beginning-of-line)
  1097. (and (let ((case-fold-search t))
  1098. (not (looking-at-p "\\*+ END[ \t]*$")))
  1099. (let ((case-fold-search nil))
  1100. (looking-at org-complex-heading-regexp))))
  1101. (match-beginning 4)
  1102. (>= (point) (match-beginning 4))
  1103. (or (not (match-beginning 5))
  1104. (< (point) (match-beginning 5)))
  1105. ;; Ignore checks in code, verbatim and others.
  1106. (org--flyspell-object-check-p (org-element-at-point-no-context)))
  1107. (let* ((element (org-element-at-point-no-context))
  1108. (post-affiliated (org-element-property :post-affiliated element)))
  1109. (cond
  1110. ;; Ignore checks in all affiliated keywords but captions.
  1111. ((< (point) post-affiliated)
  1112. (and (save-excursion
  1113. (beginning-of-line)
  1114. (let ((case-fold-search t)) (looking-at "[ \t]*#\\+CAPTION:")))
  1115. (> (point) (match-end 0))
  1116. (org--flyspell-object-check-p element)))
  1117. ;; Ignore checks in LOGBOOK (or equivalent) drawer.
  1118. ((let ((log (org-log-into-drawer)))
  1119. (and log
  1120. (let ((drawer (org-element-lineage element '(drawer))))
  1121. (and drawer
  1122. (eq (compare-strings
  1123. log nil nil
  1124. (org-element-property :drawer-name drawer) nil nil t)
  1125. t)))))
  1126. nil)
  1127. (t
  1128. (cl-case (org-element-type element)
  1129. ((comment quote-section) t)
  1130. (comment-block
  1131. ;; Allow checks between block markers, not on them.
  1132. (and (> (line-beginning-position) post-affiliated)
  1133. (save-excursion
  1134. (end-of-line)
  1135. (skip-chars-forward " \r\t\n")
  1136. (< (point) (org-element-property :end element)))))
  1137. ;; Arbitrary list of keywords where checks are meaningful.
  1138. ;; Make sure point is on the value part of the element.
  1139. (keyword
  1140. (and (member (org-element-property :key element)
  1141. '("DESCRIPTION" "TITLE"))
  1142. (save-excursion
  1143. (search-backward ":" (line-beginning-position) t))))
  1144. ;; Check is globally allowed in paragraphs verse blocks and
  1145. ;; table rows (after affiliated keywords) but some objects
  1146. ;; must not be affected.
  1147. ((paragraph table-row verse-block)
  1148. (let ((cbeg (org-element-property :contents-begin element))
  1149. (cend (org-element-property :contents-end element)))
  1150. (and cbeg (>= (point) cbeg) (< (point) cend)
  1151. (org--flyspell-object-check-p element))))))))))
  1152. (put 'org-mode 'flyspell-mode-predicate 'org-mode-flyspell-verify)
  1153. (defun org-remove-flyspell-overlays-in (beg end)
  1154. "Remove flyspell overlays in region."
  1155. (and (bound-and-true-p flyspell-mode)
  1156. (fboundp 'flyspell-delete-region-overlays)
  1157. (flyspell-delete-region-overlays beg end)))
  1158. (defvar flyspell-delayed-commands)
  1159. (eval-after-load 'flyspell
  1160. '(add-to-list 'flyspell-delayed-commands 'org-self-insert-command))
  1161. ;;;; Bookmark
  1162. (defun org-bookmark-jump-unhide (&rest _)
  1163. "Unhide the current position, to show the bookmark location."
  1164. (and (derived-mode-p 'org-mode)
  1165. (or (org-invisible-p)
  1166. (save-excursion (goto-char (max (point-min) (1- (point))))
  1167. (org-invisible-p)))
  1168. (org-fold-show-context 'bookmark-jump)))
  1169. ;; Make `bookmark-jump' shows the jump location if it was hidden.
  1170. (add-hook 'bookmark-after-jump-hook #'org-bookmark-jump-unhide)
  1171. ;;;; Calendar
  1172. (defcustom org-calendar-to-agenda-key 'default
  1173. "Key to be installed in `calendar-mode-map' for switching to the agenda.
  1174. The command `org-calendar-goto-agenda' will be bound to this key.
  1175. When set to `default', bind the function to `c', but only if it is
  1176. available in the Calendar keymap. This is the default choice because
  1177. `c' can then be used to switch back and forth between agenda and calendar.
  1178. When nil, `org-calendar-goto-agenda' is not bound to any key."
  1179. :group 'org-agenda
  1180. :type '(choice
  1181. (const :tag "Bind to `c' if available" default)
  1182. (key-sequence :tag "Other binding")
  1183. (const :tag "No binding" nil))
  1184. :safe (lambda (v) (or (symbolp v) (stringp v)))
  1185. :package-version '(Org . "9.2"))
  1186. (defcustom org-calendar-insert-diary-entry-key [?i]
  1187. "The key to be installed in `calendar-mode-map' for adding diary entries.
  1188. This option is irrelevant until `org-agenda-diary-file' has been configured
  1189. to point to an Org file. When that is the case, the command
  1190. `org-agenda-diary-entry' will be bound to the key given here, by default
  1191. `i'. In the calendar, `i' normally adds entries to `diary-file'. So
  1192. if you want to continue doing this, you need to change this to a different
  1193. key."
  1194. :group 'org-agenda
  1195. :type 'sexp)
  1196. (defun org--setup-calendar-bindings ()
  1197. "Bind Org functions in Calendar keymap."
  1198. (pcase org-calendar-to-agenda-key
  1199. (`nil nil)
  1200. ((and key (pred stringp))
  1201. (local-set-key (kbd key) #'org-calendar-goto-agenda))
  1202. ((guard (not (lookup-key calendar-mode-map "c")))
  1203. (local-set-key "c" #'org-calendar-goto-agenda))
  1204. (_ nil))
  1205. (when (and (boundp 'org-agenda-diary-file)
  1206. (not (eq org-agenda-diary-file 'diary-file)))
  1207. (local-set-key org-calendar-insert-diary-entry-key
  1208. #'org-agenda-diary-entry)))
  1209. (eval-after-load 'calendar
  1210. '(add-hook 'calendar-mode-hook #'org--setup-calendar-bindings))
  1211. ;;;; Saveplace
  1212. ;; Make sure saveplace shows the location if it was hidden
  1213. (advice-add 'save-place-find-file-hook :after #'org-bookmark-jump-unhide)
  1214. ;;;; Ecb
  1215. ;; Make sure ecb shows the location if it was hidden
  1216. (advice-add 'ecb-method-clicked :after #'org--ecb-show-context)
  1217. (defun org--ecb-show-context (&rest _)
  1218. "Make hierarchy visible when jumping into location from ECB tree buffer."
  1219. (when (derived-mode-p 'org-mode)
  1220. (org-fold-show-context)))
  1221. ;;;; Simple
  1222. (defun org-mark-jump-unhide (&rest _)
  1223. "Make the point visible with `org-show-context' after jumping to the mark."
  1224. (when (and (derived-mode-p 'org-mode)
  1225. (org-invisible-p))
  1226. (org-fold-show-context 'mark-goto)))
  1227. (advice-add 'pop-to-mark-command :after #'org-mark-jump-unhide)
  1228. (advice-add 'exchange-point-and-mark :after #'org-mark-jump-unhide)
  1229. (advice-add 'pop-global-mark :after #'org-mark-jump-unhide)
  1230. ;;;; Session
  1231. ;; Make "session.el" ignore our circular variable.
  1232. (defvar session-globals-exclude)
  1233. (eval-after-load 'session
  1234. '(add-to-list 'session-globals-exclude 'org-mark-ring))
  1235. ;;;; outline-mode
  1236. ;; Folding in outline-mode is not compatible with org-mode folding
  1237. ;; anymore. Working around to avoid breakage of external packages
  1238. ;; assuming the compatibility.
  1239. (define-advice outline-flag-region (:around (oldfun from to flag &rest extra) fix-for-org-fold)
  1240. "Run `org-fold-region' when in org-mode."
  1241. (if (derived-mode-p 'org-mode)
  1242. (org-fold-region (max from (point-min)) (min to (point-max)) flag 'headline)
  1243. ;; Apply EXTRA to avoid breakages if adviced function definition
  1244. ;; changes.
  1245. (apply oldfun from to flag extra)))
  1246. (define-advice outline-next-visible-heading (:around (oldfun arg &rest extra) fix-for-org-fold)
  1247. "Run `org-next-visible-heading' when in org-mode."
  1248. (if (derived-mode-p 'org-mode)
  1249. (org-next-visible-heading arg)
  1250. ;; Apply EXTRA to avoid breakages if adviced function definition
  1251. ;; changes.
  1252. (apply oldfun arg extra)))
  1253. (define-advice outline-back-to-heading (:around (oldfun &optional invisible-ok &rest extra) fix-for-org-fold)
  1254. "Run `org-back-to-heading' when in org-mode."
  1255. (if (derived-mode-p 'org-mode)
  1256. (progn
  1257. (beginning-of-line)
  1258. (or (org-at-heading-p (not invisible-ok))
  1259. (let (found)
  1260. (save-excursion
  1261. (while (not found)
  1262. (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)")
  1263. nil t)
  1264. (signal 'outline-before-first-heading nil))
  1265. (setq found (and (or invisible-ok (not (org-fold-folded-p)))
  1266. (point)))))
  1267. (goto-char found)
  1268. found)))
  1269. ;; Apply EXTRA to avoid breakages if adviced function definition
  1270. ;; changes.
  1271. (apply oldfun invisible-ok extra)))
  1272. (define-advice outline-on-heading-p (:around (oldfun &optional invisible-ok &rest extra) fix-for-org-fold)
  1273. "Run `org-at-heading-p' when in org-mode."
  1274. (if (derived-mode-p 'org-mode)
  1275. (org-at-heading-p (not invisible-ok))
  1276. ;; Apply EXTRA to avoid breakages if adviced function definition
  1277. ;; changes.
  1278. (apply oldfun invisible-ok extra)))
  1279. (define-advice outline-hide-sublevels (:around (oldfun levels &rest extra) fix-for-org-fold)
  1280. "Run `org-fold-hide-sublevels' when in org-mode."
  1281. (if (derived-mode-p 'org-mode)
  1282. (org-fold-hide-sublevels levels)
  1283. ;; Apply EXTRA to avoid breakages if adviced function definition
  1284. ;; changes.
  1285. (apply oldfun levels extra)))
  1286. (define-advice outline-toggle-children (:around (oldfun &rest extra) fix-for-org-fold)
  1287. "Run `org-fold-hide-sublevels' when in org-mode."
  1288. (if (derived-mode-p 'org-mode)
  1289. (save-excursion
  1290. (org-back-to-heading)
  1291. (if (not (org-fold-folded-p (line-end-position)))
  1292. (org-fold-hide-subtree)
  1293. (org-fold-show-children)
  1294. (org-fold-show-entry 'hide-drawers)))
  1295. ;; Apply EXTRA to avoid breakages if adviced function definition
  1296. ;; changes.
  1297. (apply oldfun extra)))
  1298. ;; TODO: outline-headers-as-kill
  1299. ;;;; Speed commands
  1300. (make-obsolete-variable 'org-speed-commands-user
  1301. "configure `org-speed-commands' instead." "9.5")
  1302. (provide 'org-compat)
  1303. ;; Local variables:
  1304. ;; generated-autoload-file: "org-loaddefs.el"
  1305. ;; End:
  1306. ;;; org-compat.el ends here