org-compat.el 59 KB

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