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