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