org-compat.el 58 KB

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