org-compat.el 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. ;;; org-compat.el --- Compatibility Code for Older Emacsen -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2004-2017 Free Software Foundation, Inc.
  3. ;; Author: Carsten Dominik <carsten at orgmode dot org>
  4. ;; Keywords: outlines, hypermedia, calendar, wp
  5. ;; Homepage: http://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 <http://www.gnu.org/licenses/>.
  19. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  20. ;;
  21. ;;; Commentary:
  22. ;; This file contains code needed for compatibility with older
  23. ;; versions of GNU Emacs.
  24. ;;; Code:
  25. (require 'cl-lib)
  26. (require 'org-macs)
  27. (declare-function org-at-table.el-p "org" (&optional table-type))
  28. (declare-function org-element-at-point "org-element" ())
  29. (declare-function org-element-type "org-element" (element))
  30. (declare-function org-link-set-parameters "org" (type &rest rest))
  31. (declare-function org-table-end (&optional table-type))
  32. (declare-function table--at-cell-p "table" (position &optional object at-column))
  33. (defvar org-table-any-border-regexp)
  34. (defvar org-table-dataline-regexp)
  35. (defvar org-table-tab-recognizes-table.el)
  36. (defvar org-table1-hline-regexp)
  37. ;;; Emacs < 25.1 compatibility
  38. (when (< emacs-major-version 25)
  39. (defalias 'outline-hide-entry 'hide-entry)
  40. (defalias 'outline-hide-sublevels 'hide-sublevels)
  41. (defalias 'outline-hide-subtree 'hide-subtree)
  42. (defalias 'outline-show-all 'show-all)
  43. (defalias 'outline-show-branches 'show-branches)
  44. (defalias 'outline-show-children 'show-children)
  45. (defalias 'outline-show-entry 'show-entry)
  46. (defalias 'outline-show-subtree 'show-subtree)
  47. (defalias 'xref-find-definitions 'find-tag)
  48. (defalias 'format-message 'format)
  49. (defalias 'gui-get-selection 'x-get-selection))
  50. (unless (fboundp 'directory-name-p)
  51. (defun directory-name-p (name)
  52. "Return non-nil if NAME ends with a directory separator character."
  53. (let ((len (length name))
  54. (lastc ?.))
  55. (if (> len 0)
  56. (setq lastc (aref name (1- len))))
  57. (or (= lastc ?/)
  58. (and (memq system-type '(windows-nt ms-dos))
  59. (= lastc ?\\))))))
  60. (unless (fboundp 'directory-files-recursively)
  61. (defun directory-files-recursively (dir regexp &optional include-directories)
  62. "Return list of all files under DIR that have file names matching REGEXP.
  63. This function works recursively. Files are returned in \"depth first\"
  64. order, and files from each directory are sorted in alphabetical order.
  65. Each file name appears in the returned list in its absolute form.
  66. Optional argument INCLUDE-DIRECTORIES non-nil means also include in the
  67. output directories whose names match REGEXP."
  68. (let ((result nil)
  69. (files nil)
  70. ;; When DIR is "/", remote file names like "/method:" could
  71. ;; also be offered. We shall suppress them.
  72. (tramp-mode (and tramp-mode (file-remote-p (expand-file-name dir)))))
  73. (dolist (file (sort (file-name-all-completions "" dir)
  74. 'string<))
  75. (unless (member file '("./" "../"))
  76. (if (directory-name-p file)
  77. (let* ((leaf (substring file 0 (1- (length file))))
  78. (full-file (expand-file-name leaf dir)))
  79. ;; Don't follow symlinks to other directories.
  80. (unless (file-symlink-p full-file)
  81. (setq result
  82. (nconc result (directory-files-recursively
  83. full-file regexp include-directories))))
  84. (when (and include-directories
  85. (string-match regexp leaf))
  86. (setq result (nconc result (list full-file)))))
  87. (when (string-match regexp file)
  88. (push (expand-file-name file dir) files)))))
  89. (nconc result (nreverse files)))))
  90. ;;; Obsolete aliases (remove them once the next major release is released).
  91. ;;;; XEmacs compatibility, now removed.
  92. (define-obsolete-function-alias 'org-activate-mark 'activate-mark)
  93. (define-obsolete-function-alias 'org-add-hook 'add-hook "Org 9.0")
  94. (define-obsolete-function-alias 'org-bound-and-true-p 'bound-and-true-p "Org 9.0")
  95. (define-obsolete-function-alias 'org-decompose-region 'decompose-region "Org 9.0")
  96. (define-obsolete-function-alias 'org-defvaralias 'defvaralias "Org 9.0")
  97. (define-obsolete-function-alias 'org-detach-overlay 'delete-overlay "Org 9.0")
  98. (define-obsolete-function-alias 'org-file-equal-p 'file-equal-p "Org 9.0")
  99. (define-obsolete-function-alias 'org-float-time 'float-time "Org 9.0")
  100. (define-obsolete-function-alias 'org-indent-line-to 'indent-line-to "Org 9.0")
  101. (define-obsolete-function-alias 'org-indent-to-column 'indent-to-column "Org 9.0")
  102. (define-obsolete-function-alias 'org-looking-at-p 'looking-at-p "Org 9.0")
  103. (define-obsolete-function-alias 'org-looking-back 'looking-back "Org 9.0")
  104. (define-obsolete-function-alias 'org-match-string-no-properties 'match-string-no-properties "Org 9.0")
  105. (define-obsolete-function-alias 'org-propertize 'propertize "Org 9.0")
  106. (define-obsolete-function-alias 'org-select-frame-set-input-focus 'select-frame-set-input-focus "Org 9.0")
  107. (defmacro org-re (s)
  108. "Replace posix classes in regular expression S."
  109. (declare (debug (form))
  110. (obsolete "you can safely remove it." "Org 9.0"))
  111. s)
  112. ;;;; Functions from cl-lib that Org used to have its own implementation of.
  113. (define-obsolete-function-alias 'org-count 'cl-count "Org 9.0")
  114. (define-obsolete-function-alias 'org-every 'cl-every "Org 9.0")
  115. (define-obsolete-function-alias 'org-find-if 'cl-find-if "Org 9.0")
  116. (define-obsolete-function-alias 'org-reduce 'cl-reduce "Org 9.0")
  117. (define-obsolete-function-alias 'org-remove-if 'cl-remove-if "Org 9.0")
  118. (define-obsolete-function-alias 'org-remove-if-not 'cl-remove-if-not "Org 9.0")
  119. (define-obsolete-function-alias 'org-some 'cl-some "Org 9.0")
  120. (define-obsolete-function-alias 'org-floor* 'cl-floor "Org 9.0")
  121. (defun org-sublist (list start end)
  122. "Return a section of LIST, from START to END.
  123. Counting starts at 1."
  124. (cl-subseq list (1- start) end))
  125. (make-obsolete 'org-sublist
  126. "use cl-subseq (note the 0-based counting)."
  127. "Org 9.0")
  128. ;;;; Functions available since Emacs 24.3
  129. (define-obsolete-function-alias 'org-buffer-narrowed-p 'buffer-narrowed-p "Org 9.0")
  130. (define-obsolete-function-alias 'org-called-interactively-p 'called-interactively-p "Org 9.0")
  131. (define-obsolete-function-alias 'org-char-to-string 'char-to-string "Org 9.0")
  132. (define-obsolete-function-alias 'org-delete-directory 'delete-directory "Org 9.0")
  133. (define-obsolete-function-alias 'org-format-seconds 'format-seconds "Org 9.0")
  134. (define-obsolete-function-alias 'org-link-escape-browser 'url-encode-url "Org 9.0")
  135. (define-obsolete-function-alias 'org-no-warnings 'with-no-warnings "Org 9.0")
  136. (define-obsolete-function-alias 'org-number-sequence 'number-sequence "Org 9.0")
  137. (define-obsolete-function-alias 'org-pop-to-buffer-same-window 'pop-to-buffer-same-window "Org 9.0")
  138. (define-obsolete-function-alias 'org-string-match-p 'string-match-p "Org 9.0")
  139. ;;;; Functions and variables from previous releases now obsolete.
  140. (define-obsolete-function-alias 'org-element-remove-indentation
  141. 'org-remove-indentation "Org 9.0")
  142. (define-obsolete-variable-alias 'org-latex-create-formula-image-program
  143. 'org-preview-latex-default-process "Org 9.0")
  144. (define-obsolete-variable-alias 'org-latex-preview-ltxpng-directory
  145. 'org-preview-latex-image-directory "Org 9.0")
  146. (define-obsolete-function-alias 'org-table-p 'org-at-table-p "Org 9.0")
  147. (define-obsolete-function-alias 'org-on-heading-p 'org-at-heading-p "Org 9.0")
  148. (define-obsolete-function-alias 'org-at-regexp-p 'org-in-regexp "Org 8.3")
  149. (define-obsolete-function-alias 'org-image-file-name-regexp
  150. 'image-file-name-regexp "Org 9.0")
  151. (define-obsolete-function-alias 'org-completing-read-no-i
  152. 'completing-read "Org 9.0")
  153. (define-obsolete-function-alias 'org-icompleting-read
  154. 'completing-read "Org 9.0")
  155. (define-obsolete-function-alias 'org-iread-file-name 'read-file-name "Org 9.0")
  156. (define-obsolete-function-alias 'org-days-to-time
  157. 'org-time-stamp-to-now "Org 8.2")
  158. (define-obsolete-variable-alias 'org-agenda-ignore-drawer-properties
  159. 'org-agenda-ignore-properties "Org 9.0")
  160. (define-obsolete-function-alias 'org-preview-latex-fragment
  161. 'org-toggle-latex-fragment "Org 8.3")
  162. (define-obsolete-function-alias 'org-export-get-genealogy
  163. 'org-element-lineage "Org 9.0")
  164. (define-obsolete-variable-alias 'org-latex-with-hyperref
  165. 'org-latex-hyperref-template "Org 9.0")
  166. (define-obsolete-variable-alias 'hfy-optimisations 'hfy-optimizations "Org 9.0")
  167. (define-obsolete-variable-alias 'org-export-htmlized-org-css-url
  168. 'org-org-htmlized-css-url "Org 8.2")
  169. (define-obsolete-function-alias 'org-list-parse-list 'org-list-to-lisp "Org 9.0")
  170. (define-obsolete-function-alias 'org-agenda-todayp
  171. 'org-agenda-today-p "Org 9.0")
  172. (define-obsolete-function-alias 'org-babel-examplize-region
  173. 'org-babel-examplify-region "Org 9.0")
  174. (define-obsolete-function-alias 'org-babel-trim 'org-trim "Org 9.0")
  175. (define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4")
  176. (define-obsolete-function-alias 'org-insert-columns-dblock
  177. 'org-columns-insert-dblock "Org 9.0")
  178. (define-obsolete-variable-alias 'org-export-babel-evaluate
  179. 'org-export-use-babel "Org 9.1")
  180. (defun org-in-fixed-width-region-p ()
  181. "Non-nil if point in a fixed-width region."
  182. (save-match-data
  183. (eq 'fixed-width (org-element-type (org-element-at-point)))))
  184. (make-obsolete 'org-in-fixed-width-region-p
  185. "use `org-element' library"
  186. "Org 9.0")
  187. (defun org-compatible-face (inherits specs)
  188. "Make a compatible face specification.
  189. If INHERITS is an existing face and if the Emacs version supports
  190. it, just inherit the face. If INHERITS is not given and SPECS
  191. is, use SPECS to define the face."
  192. (declare (indent 1))
  193. (if (facep inherits)
  194. (list (list t :inherit inherits))
  195. specs))
  196. (make-obsolete 'org-compatible-face "you can remove it." "Org 9.0")
  197. (defun org-add-link-type (type &optional follow export)
  198. "Add a new TYPE link.
  199. FOLLOW and EXPORT are two functions.
  200. FOLLOW should take the link path as the single argument and do whatever
  201. is necessary to follow the link, for example find a file or display
  202. a mail message.
  203. EXPORT should format the link path for export to one of the export formats.
  204. It should be a function accepting three arguments:
  205. path the path of the link, the text after the prefix (like \"http:\")
  206. desc the description of the link, if any
  207. format the export format, a symbol like `html' or `latex' or `ascii'.
  208. The function may use the FORMAT information to return different values
  209. depending on the format. The return value will be put literally into
  210. the exported file. If the return value is nil, this means Org should
  211. do what it normally does with links which do not have EXPORT defined.
  212. Org mode has a built-in default for exporting links. If you are happy with
  213. this default, there is no need to define an export function for the link
  214. type. For a simple example of an export function, see `org-bbdb.el'.
  215. If TYPE already exists, update it with the arguments.
  216. See `org-link-parameters' for documentation on the other parameters."
  217. (org-link-set-parameters type :follow follow :export export)
  218. (message "Created %s link." type))
  219. (make-obsolete 'org-add-link-type "use `org-link-set-parameters' instead." "Org 9.0")
  220. (defun org-table-recognize-table.el ()
  221. "If there is a table.el table nearby, recognize it and move into it."
  222. (when (and org-table-tab-recognizes-table.el (org-at-table.el-p))
  223. (beginning-of-line)
  224. (unless (or (looking-at org-table-dataline-regexp)
  225. (not (looking-at org-table1-hline-regexp)))
  226. (forward-line)
  227. (when (looking-at org-table-any-border-regexp)
  228. (forward-line -2)))
  229. (if (re-search-forward "|" (org-table-end t) t)
  230. (progn
  231. (require 'table)
  232. (if (table--at-cell-p (point)) t
  233. (message "recognizing table.el table...")
  234. (table-recognize-table)
  235. (message "recognizing table.el table...done")))
  236. (error "This should not happen"))))
  237. ;; Not used by Org core since commit 6d1e3082, Feb 2010.
  238. (make-obsolete 'org-table-recognize-table.el
  239. "please notify the org mailing list if you use this function."
  240. "Org 9.0")
  241. (defun org-remove-angle-brackets (s)
  242. (org-unbracket-string "<" ">" s))
  243. (make-obsolete 'org-remove-angle-brackets 'org-unbracket-string "Org 9.0")
  244. (defun org-remove-double-quotes (s)
  245. (org-unbracket-string "\"" "\"" s))
  246. (make-obsolete 'org-remove-double-quotes 'org-unbracket-string "Org 9.0")
  247. (defcustom org-publish-sitemap-file-entry-format "%t"
  248. "Format string for site-map file entry.
  249. You could use brackets to delimit on what part the link will be.
  250. %t is the title.
  251. %a is the author.
  252. %d is the date formatted using `org-publish-sitemap-date-format'."
  253. :group 'org-export-publish
  254. :type 'string)
  255. (make-obsolete-variable
  256. 'org-publish-sitemap-file-entry-format
  257. "set `:sitemap-format-entry' in `org-publish-project-alist' instead."
  258. "Org 9.1")
  259. ;;;; Obsolete link types
  260. (eval-after-load 'org
  261. '(progn
  262. (org-link-set-parameters "file+emacs") ;since Org 9.0
  263. (org-link-set-parameters "file+sys"))) ;since Org 9.0
  264. ;;; Miscellaneous functions
  265. (defun org-version-check (version feature level)
  266. (let* ((v1 (mapcar 'string-to-number (split-string version "[.]")))
  267. (v2 (mapcar 'string-to-number (split-string emacs-version "[.]")))
  268. (rmaj (or (nth 0 v1) 99))
  269. (rmin (or (nth 1 v1) 99))
  270. (rbld (or (nth 2 v1) 99))
  271. (maj (or (nth 0 v2) 0))
  272. (min (or (nth 1 v2) 0))
  273. (bld (or (nth 2 v2) 0)))
  274. (if (or (< maj rmaj)
  275. (and (= maj rmaj)
  276. (< min rmin))
  277. (and (= maj rmaj)
  278. (= min rmin)
  279. (< bld rbld)))
  280. (if (eq level :predicate)
  281. ;; just return if we have the version
  282. nil
  283. (let ((msg (format "Emacs %s or greater is recommended for %s"
  284. version feature)))
  285. (display-warning 'org msg level)
  286. t))
  287. t)))
  288. (defun org-get-x-clipboard (value)
  289. "Get the value of the X or Windows clipboard."
  290. (cond ((and (eq window-system 'x)
  291. (fboundp 'gui-get-selection)) ;Silence byte-compiler.
  292. (org-no-properties
  293. (ignore-errors
  294. (or (gui-get-selection value 'UTF8_STRING)
  295. (gui-get-selection value 'COMPOUND_TEXT)
  296. (gui-get-selection value 'STRING)
  297. (gui-get-selection value 'TEXT)))))
  298. ((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
  299. (w32-get-clipboard-data))))
  300. (defun org-add-props (string plist &rest props)
  301. "Add text properties to entire string, from beginning to end.
  302. PLIST may be a list of properties, PROPS are individual properties and values
  303. that will be added to PLIST. Returns the string that was modified."
  304. (add-text-properties
  305. 0 (length string) (if props (append plist props) plist) string)
  306. string)
  307. (put 'org-add-props 'lisp-indent-function 2)
  308. (defun org-fit-window-to-buffer (&optional window max-height min-height
  309. shrink-only)
  310. "Fit WINDOW to the buffer, but only if it is not a side-by-side window.
  311. WINDOW defaults to the selected window. MAX-HEIGHT and MIN-HEIGHT are
  312. passed through to `fit-window-to-buffer'. If SHRINK-ONLY is set, call
  313. `shrink-window-if-larger-than-buffer' instead, the height limit is
  314. ignored in this case."
  315. (cond ((if (fboundp 'window-full-width-p)
  316. (not (window-full-width-p window))
  317. ;; do nothing if another window would suffer
  318. (> (frame-width) (window-width window))))
  319. ((and (fboundp 'fit-window-to-buffer) (not shrink-only))
  320. (fit-window-to-buffer window max-height min-height))
  321. ((fboundp 'shrink-window-if-larger-than-buffer)
  322. (shrink-window-if-larger-than-buffer window)))
  323. (or window (selected-window)))
  324. ;; `set-transient-map' is only in Emacs >= 24.4
  325. (defalias 'org-set-transient-map
  326. (if (fboundp 'set-transient-map)
  327. 'set-transient-map
  328. 'set-temporary-overlay-map))
  329. ;;; Region compatibility
  330. (defvar org-ignore-region nil
  331. "Non-nil means temporarily disable the active region.")
  332. (defun org-region-active-p ()
  333. "Non-nil when the region active.
  334. Unlike to `use-region-p', this function also checks
  335. `org-ignore-region'."
  336. (and (not org-ignore-region) (use-region-p)))
  337. (defun org-cursor-to-region-beginning ()
  338. (when (and (org-region-active-p)
  339. (> (point) (region-beginning)))
  340. (exchange-point-and-mark)))
  341. ;;; Invisibility compatibility
  342. (defun org-remove-from-invisibility-spec (arg)
  343. "Remove elements from `buffer-invisibility-spec'."
  344. (if (fboundp 'remove-from-invisibility-spec)
  345. (remove-from-invisibility-spec arg)
  346. (if (consp buffer-invisibility-spec)
  347. (setq buffer-invisibility-spec
  348. (delete arg buffer-invisibility-spec)))))
  349. (defun org-in-invisibility-spec-p (arg)
  350. "Is ARG a member of `buffer-invisibility-spec'?"
  351. (if (consp buffer-invisibility-spec)
  352. (member arg buffer-invisibility-spec)))
  353. (defun org-move-to-column (column &optional force _buffer)
  354. "Move to column COLUMN.
  355. Pass COLUMN and FORCE to `move-to-column'."
  356. (let ((buffer-invisibility-spec
  357. (if (listp buffer-invisibility-spec)
  358. (remove '(org-filtered) buffer-invisibility-spec)
  359. buffer-invisibility-spec)))
  360. (move-to-column column force)))
  361. (defmacro org-find-library-dir (library)
  362. `(file-name-directory (or (locate-library ,library) "")))
  363. (defun org-count-lines (s)
  364. "How many lines in string S?"
  365. (let ((start 0) (n 1))
  366. (while (string-match "\n" s start)
  367. (setq start (match-end 0) n (1+ n)))
  368. (if (and (> (length s) 0) (= (aref s (1- (length s))) ?\n))
  369. (setq n (1- n)))
  370. n))
  371. (defun org-kill-new (string &rest args)
  372. (remove-text-properties 0 (length string) '(line-prefix t wrap-prefix t)
  373. string)
  374. (apply 'kill-new string args))
  375. ;; `font-lock-ensure' is only available from 24.4.50 on
  376. (defalias 'org-font-lock-ensure
  377. (if (fboundp 'font-lock-ensure)
  378. #'font-lock-ensure
  379. (lambda (&optional _beg _end)
  380. (with-no-warnings (font-lock-fontify-buffer)))))
  381. (defmacro org-no-popups (&rest body)
  382. "Suppress popup windows.
  383. Let-bind some variables to nil around BODY to achieve the desired
  384. effect, which variables to use depends on the Emacs version."
  385. (if (org-version-check "24.2.50" "" :predicate)
  386. `(let (pop-up-frames display-buffer-alist)
  387. ,@body)
  388. `(let (pop-up-frames special-display-buffer-names special-display-regexps special-display-function)
  389. ,@body)))
  390. ;;;###autoload
  391. (defmacro org-check-version ()
  392. "Try very hard to provide sensible version strings."
  393. (let* ((org-dir (org-find-library-dir "org"))
  394. (org-version.el (concat org-dir "org-version.el"))
  395. (org-fixup.el (concat org-dir "../mk/org-fixup.el")))
  396. (if (require 'org-version org-version.el 'noerror)
  397. '(progn
  398. (autoload 'org-release "org-version.el")
  399. (autoload 'org-git-version "org-version.el"))
  400. (if (require 'org-fixup org-fixup.el 'noerror)
  401. '(org-fixup)
  402. ;; provide fallback definitions and complain
  403. (warn "Could not define org version correctly. Check installation!")
  404. '(progn
  405. (defun org-release () "N/A")
  406. (defun org-git-version () "N/A !!check installation!!"))))))
  407. (defmacro org-with-silent-modifications (&rest body)
  408. (if (fboundp 'with-silent-modifications)
  409. `(with-silent-modifications ,@body)
  410. `(org-unmodified ,@body)))
  411. (def-edebug-spec org-with-silent-modifications (body))
  412. ;; Functions for Emacs < 24.4 compatibility
  413. (defun org-define-error (name message)
  414. "Define NAME as a new error signal.
  415. MESSAGE is a string that will be output to the echo area if such
  416. an error is signaled without being caught by a `condition-case'.
  417. Implements `define-error' for older emacsen."
  418. (if (fboundp 'define-error) (define-error name message)
  419. (put name 'error-conditions
  420. (copy-sequence (cons name (get 'error 'error-conditions))))))
  421. (unless (fboundp 'string-suffix-p)
  422. ;; From Emacs subr.el.
  423. (defun string-suffix-p (suffix string &optional ignore-case)
  424. "Return non-nil if SUFFIX is a suffix of STRING.
  425. If IGNORE-CASE is non-nil, the comparison is done without paying
  426. attention to case differences."
  427. (let ((start-pos (- (length string) (length suffix))))
  428. (and (>= start-pos 0)
  429. (eq t (compare-strings suffix nil nil
  430. string start-pos nil ignore-case))))))
  431. (provide 'org-compat)
  432. ;;; org-compat.el ends here