org-compat.el 57 KB

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