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