2008-03-22 11:52:18 -04:00
|
|
|
;;; org-macs.el --- Top-level definitions for Org-mode
|
|
|
|
|
2016-01-09 17:12:03 -05:00
|
|
|
;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
|
|
|
;; Keywords: outlines, hypermedia, calendar, wp
|
|
|
|
;; Homepage: http://orgmode.org
|
|
|
|
;;
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
;;
|
2008-05-06 08:45:52 -04:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2008-03-22 11:52:18 -04:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:45:52 -04:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 08:45:52 -04:00
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2008-03-22 11:52:18 -04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;
|
|
|
|
;;; Commentary:
|
|
|
|
|
2008-04-04 17:44:48 -04:00
|
|
|
;; This file contains macro definitions, defsubst definitions, other
|
|
|
|
;; stuff needed for compilation and top-level forms in Org-mode, as well
|
|
|
|
;; lots of small functions that are not org-mode specific but simply
|
|
|
|
;; generally useful stuff.
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2009-06-07 16:14:33 -04:00
|
|
|
(eval-and-compile
|
|
|
|
(unless (fboundp 'declare-function)
|
2015-05-04 11:32:43 -04:00
|
|
|
(defmacro declare-function (fn file &optional _arglist _fileonly)
|
2013-06-01 05:21:48 -04:00
|
|
|
`(autoload ',fn ,file)))
|
|
|
|
|
2010-11-21 05:20:40 -05:00
|
|
|
(if (>= emacs-major-version 23)
|
|
|
|
(defsubst org-char-to-string(c)
|
|
|
|
"Defsubst to decode UTF-8 character values in emacs 23 and beyond."
|
|
|
|
(char-to-string c))
|
|
|
|
(defsubst org-char-to-string (c)
|
|
|
|
"Defsubst to decode UTF-8 character values in emacs 22."
|
|
|
|
(string (decode-char 'ucs c)))))
|
2009-06-07 16:14:33 -04:00
|
|
|
|
2009-06-07 11:07:07 -04:00
|
|
|
(declare-function org-add-props "org-compat" (string plist &rest props))
|
2016-05-14 22:56:53 -04:00
|
|
|
(declare-function org-string-match-p "org-compat"
|
|
|
|
(regexp string &optional start))
|
2009-06-07 11:07:07 -04:00
|
|
|
|
2011-08-10 01:28:41 -04:00
|
|
|
(defmacro org-with-gensyms (symbols &rest body)
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (sexp body)) (indent 1))
|
2011-08-10 01:28:41 -04:00
|
|
|
`(let ,(mapcar (lambda (s)
|
2015-05-04 11:32:43 -04:00
|
|
|
`(,s (make-symbol (concat "--" (symbol-name ',s)))))
|
|
|
|
symbols)
|
2011-08-10 01:28:41 -04:00
|
|
|
,@body))
|
|
|
|
|
2010-10-25 07:26:27 -04:00
|
|
|
(defmacro org-called-interactively-p (&optional kind)
|
2015-05-21 13:04:45 -04:00
|
|
|
(declare (debug (&optional ("quote" symbolp)))) ;Why not just t?
|
2011-06-29 18:25:09 -04:00
|
|
|
(if (featurep 'xemacs)
|
2012-08-11 13:10:44 -04:00
|
|
|
`(interactive-p)
|
|
|
|
(if (or (> emacs-major-version 23)
|
|
|
|
(and (>= emacs-major-version 23)
|
|
|
|
(>= emacs-minor-version 2)))
|
|
|
|
;; defined with no argument in <=23.1
|
|
|
|
`(with-no-warnings (called-interactively-p ,kind))
|
|
|
|
`(interactive-p))))
|
2010-10-25 07:26:27 -04:00
|
|
|
|
2008-03-22 11:52:18 -04:00
|
|
|
(defmacro org-bound-and-true-p (var)
|
|
|
|
"Return the value of symbol VAR if it is bound, else nil."
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (symbolp)))
|
2008-03-22 11:52:18 -04:00
|
|
|
`(and (boundp (quote ,var)) ,var))
|
|
|
|
|
2010-07-20 01:54:11 -04:00
|
|
|
(defun org-string-nw-p (s)
|
2015-02-26 09:14:40 -05:00
|
|
|
"Return S if S is a string containing a non-blank character.
|
|
|
|
Otherwise, return nil."
|
2010-07-20 01:54:11 -04:00
|
|
|
(and (stringp s)
|
2015-02-26 09:14:40 -05:00
|
|
|
(org-string-match-p "[^ \r\t\n]" s)
|
2010-07-20 01:54:11 -04:00
|
|
|
s))
|
|
|
|
|
2010-06-25 03:00:19 -04:00
|
|
|
(defun org-not-nil (v)
|
2010-06-26 01:54:07 -04:00
|
|
|
"If V not nil, and also not the string \"nil\", then return V.
|
|
|
|
Otherwise return nil."
|
|
|
|
(and v (not (equal v "nil")) v))
|
2010-06-25 03:00:19 -04:00
|
|
|
|
2011-08-10 01:49:02 -04:00
|
|
|
(defun org-substitute-posix-classes (re)
|
|
|
|
"Substitute posix classes in regular expression RE."
|
|
|
|
(let ((ss re))
|
|
|
|
(save-match-data
|
|
|
|
(while (string-match "\\[:alnum:\\]" ss)
|
|
|
|
(setq ss (replace-match "a-zA-Z0-9" t t ss)))
|
|
|
|
(while (string-match "\\[:word:\\]" ss)
|
|
|
|
(setq ss (replace-match "a-zA-Z0-9" t t ss)))
|
|
|
|
(while (string-match "\\[:alpha:\\]" ss)
|
|
|
|
(setq ss (replace-match "a-zA-Z" t t ss)))
|
|
|
|
(while (string-match "\\[:punct:\\]" ss)
|
|
|
|
(setq ss (replace-match "\001-@[-`{-~" t t ss)))
|
|
|
|
ss)))
|
|
|
|
|
2008-03-22 11:52:18 -04:00
|
|
|
(defmacro org-re (s)
|
|
|
|
"Replace posix classes in regular expression."
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (form)))
|
2011-08-10 01:49:02 -04:00
|
|
|
(if (featurep 'xemacs) `(org-substitute-posix-classes ,s) s))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(defmacro org-preserve-lc (&rest body)
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (body)))
|
2011-08-10 01:33:43 -04:00
|
|
|
(org-with-gensyms (line col)
|
|
|
|
`(let ((,line (org-current-line))
|
|
|
|
(,col (current-column)))
|
|
|
|
(unwind-protect
|
|
|
|
(progn ,@body)
|
|
|
|
(org-goto-line ,line)
|
|
|
|
(org-move-to-column ,col)))))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
2013-02-25 05:47:01 -05:00
|
|
|
;; Use `org-with-silent-modifications' to ignore cosmetic changes and
|
|
|
|
;; `org-unmodified' to ignore real text modifications
|
2013-02-23 05:44:24 -05:00
|
|
|
(defmacro org-unmodified (&rest body)
|
2012-12-29 19:21:27 -05:00
|
|
|
"Run BODY while preserving the buffer's `buffer-modified-p' state."
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (body)))
|
2012-12-29 19:21:27 -05:00
|
|
|
(org-with-gensyms (was-modified)
|
|
|
|
`(let ((,was-modified (buffer-modified-p)))
|
|
|
|
(unwind-protect
|
2013-02-23 05:44:24 -05:00
|
|
|
(let ((buffer-undo-list t)
|
|
|
|
(inhibit-modification-hooks t))
|
|
|
|
,@body)
|
|
|
|
(set-buffer-modified-p ,was-modified)))))
|
2012-12-29 19:21:27 -05:00
|
|
|
|
2008-03-22 11:52:18 -04:00
|
|
|
(defmacro org-without-partial-completion (&rest body)
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (body)))
|
2011-07-02 06:15:20 -04:00
|
|
|
`(if (and (boundp 'partial-completion-mode)
|
2011-07-02 10:51:55 -04:00
|
|
|
partial-completion-mode
|
2011-07-02 06:15:20 -04:00
|
|
|
(fboundp 'partial-completion-mode))
|
2012-08-11 13:10:44 -04:00
|
|
|
(unwind-protect
|
|
|
|
(progn
|
|
|
|
(partial-completion-mode -1)
|
|
|
|
,@body)
|
|
|
|
(partial-completion-mode 1))
|
2011-07-02 06:15:20 -04:00
|
|
|
,@body))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
2012-08-11 13:10:44 -04:00
|
|
|
;; FIXME: Slated for removal. Current Org mode does not support Emacs < 22
|
2008-03-22 11:52:18 -04:00
|
|
|
(defmacro org-maybe-intangible (props)
|
2015-09-21 00:24:12 -04:00
|
|
|
"Add \\='(intangible t) to PROPS if Emacs version is earlier than Emacs 22.
|
2010-07-16 17:23:01 -04:00
|
|
|
In Emacs 21, invisible text is not avoided by the command loop, so the
|
2008-03-22 11:52:18 -04:00
|
|
|
intangible property is needed to make sure point skips this text.
|
|
|
|
In Emacs 22, this is not necessary. The intangible text property has
|
|
|
|
led to problems with flyspell. These problems are fixed in flyspell.el,
|
|
|
|
but we still avoid setting the property in Emacs 22 and later.
|
|
|
|
We use a macro so that the test can happen at compilation time."
|
2009-04-14 06:35:32 -04:00
|
|
|
(if (< emacs-major-version 22)
|
2008-03-22 11:52:18 -04:00
|
|
|
`(append '(intangible t) ,props)
|
|
|
|
props))
|
|
|
|
|
|
|
|
(defmacro org-with-point-at (pom &rest body)
|
|
|
|
"Move to buffer and point of point-or-marker POM for the duration of BODY."
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (form body)) (indent 1))
|
2011-08-10 01:33:43 -04:00
|
|
|
(org-with-gensyms (mpom)
|
|
|
|
`(let ((,mpom ,pom))
|
2011-02-25 13:30:33 -05:00
|
|
|
(save-excursion
|
2011-08-10 01:33:43 -04:00
|
|
|
(if (markerp ,mpom) (set-buffer (marker-buffer ,mpom)))
|
2014-06-14 22:50:07 -04:00
|
|
|
(org-with-wide-buffer
|
|
|
|
(goto-char (or ,mpom (point)))
|
|
|
|
,@body)))))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(defmacro org-no-warnings (&rest body)
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (body)))
|
2008-03-22 11:52:18 -04:00
|
|
|
(cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body))
|
|
|
|
|
2013-04-10 08:32:55 -04:00
|
|
|
(defmacro org-with-remote-undo (buffer &rest body)
|
2008-03-22 11:52:18 -04:00
|
|
|
"Execute BODY while recording undo information in two buffers."
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (form body)) (indent 1))
|
2011-08-10 01:33:43 -04:00
|
|
|
(org-with-gensyms (cline cmd buf1 buf2 undo1 undo2 c1 c2)
|
|
|
|
`(let ((,cline (org-current-line))
|
|
|
|
(,cmd this-command)
|
|
|
|
(,buf1 (current-buffer))
|
2013-04-10 08:32:55 -04:00
|
|
|
(,buf2 ,buffer)
|
2011-08-10 01:33:43 -04:00
|
|
|
(,undo1 buffer-undo-list)
|
2013-04-10 08:32:55 -04:00
|
|
|
(,undo2 (with-current-buffer ,buffer buffer-undo-list))
|
2011-08-10 01:33:43 -04:00
|
|
|
,c1 ,c2)
|
2013-04-10 08:32:55 -04:00
|
|
|
,@body
|
2011-08-10 01:33:43 -04:00
|
|
|
(when org-agenda-allow-remote-undo
|
|
|
|
(setq ,c1 (org-verify-change-for-undo
|
|
|
|
,undo1 (with-current-buffer ,buf1 buffer-undo-list))
|
|
|
|
,c2 (org-verify-change-for-undo
|
|
|
|
,undo2 (with-current-buffer ,buf2 buffer-undo-list)))
|
|
|
|
(when (or ,c1 ,c2)
|
|
|
|
;; make sure there are undo boundaries
|
|
|
|
(and ,c1 (with-current-buffer ,buf1 (undo-boundary)))
|
|
|
|
(and ,c2 (with-current-buffer ,buf2 (undo-boundary)))
|
|
|
|
;; remember which buffer to undo
|
|
|
|
(push (list ,cmd ,cline ,buf1 ,c1 ,buf2 ,c2)
|
|
|
|
org-agenda-undo-list))))))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(defmacro org-no-read-only (&rest body)
|
|
|
|
"Inhibit read-only for BODY."
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (body)))
|
2008-03-22 11:52:18 -04:00
|
|
|
`(let ((inhibit-read-only t)) ,@body))
|
|
|
|
|
|
|
|
(defconst org-rm-props '(invisible t face t keymap t intangible t mouse-face t
|
2010-06-03 18:13:19 -04:00
|
|
|
rear-nonsticky t mouse-map t fontified t
|
|
|
|
org-emphasis t)
|
2008-03-22 11:52:18 -04:00
|
|
|
"Properties to remove when a string without properties is wanted.")
|
|
|
|
|
|
|
|
(defsubst org-match-string-no-properties (num &optional string)
|
|
|
|
(if (featurep 'xemacs)
|
|
|
|
(let ((s (match-string num string)))
|
2008-04-20 02:10:18 -04:00
|
|
|
(and s (remove-text-properties 0 (length s) org-rm-props s))
|
2008-03-22 11:52:18 -04:00
|
|
|
s)
|
|
|
|
(match-string-no-properties num string)))
|
|
|
|
|
2012-08-15 03:35:21 -04:00
|
|
|
(defsubst org-no-properties (s &optional restricted)
|
|
|
|
"Remove all text properties from string S.
|
|
|
|
When RESTRICTED is non-nil, only remove the properties listed
|
|
|
|
in `org-rm-props'."
|
2008-03-22 11:52:18 -04:00
|
|
|
(if (fboundp 'set-text-properties)
|
|
|
|
(set-text-properties 0 (length s) nil s)
|
2012-08-15 03:35:21 -04:00
|
|
|
(if restricted
|
|
|
|
(remove-text-properties 0 (length s) org-rm-props s)
|
|
|
|
(set-text-properties 0 (length s) nil s)))
|
2008-03-22 11:52:18 -04:00
|
|
|
s)
|
|
|
|
|
|
|
|
(defsubst org-get-alist-option (option key)
|
|
|
|
(cond ((eq key t) t)
|
|
|
|
((eq option t) t)
|
|
|
|
((assoc key option) (cdr (assoc key option)))
|
2013-02-27 02:46:26 -05:00
|
|
|
(t (let ((r (cdr (assq 'default option))))
|
|
|
|
(if (listp r) (delq nil r) r)))))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
2009-04-30 16:50:47 -04:00
|
|
|
(defsubst org-check-external-command (cmd &optional use no-error)
|
2009-11-12 07:39:29 -05:00
|
|
|
"Check if external program CMD for USE exists, error if not.
|
2009-08-15 02:16:38 -04:00
|
|
|
When the program does exist, return its path.
|
2009-04-30 16:50:47 -04:00
|
|
|
When it does not exist and NO-ERROR is set, return nil.
|
|
|
|
Otherwise, throw an error. The optional argument USE can describe what this
|
|
|
|
program is needed for, so that the error message can be more informative."
|
|
|
|
(or (executable-find cmd)
|
|
|
|
(if no-error
|
|
|
|
nil
|
|
|
|
(error "Can't find `%s'%s" cmd
|
|
|
|
(if use (format " (%s)" use) "")))))
|
|
|
|
|
2008-03-22 11:52:18 -04:00
|
|
|
(defsubst org-inhibit-invisibility ()
|
|
|
|
"Modified `buffer-invisibility-spec' for Emacs 21.
|
|
|
|
Some ops with invisible text do not work correctly on Emacs 21. For these
|
|
|
|
we turn off invisibility temporarily. Use this in a `let' form."
|
|
|
|
(if (< emacs-major-version 22) nil buffer-invisibility-spec))
|
|
|
|
|
|
|
|
(defsubst org-set-local (var value)
|
|
|
|
"Make VAR local in current buffer and set it to VALUE."
|
2009-07-06 11:00:03 -04:00
|
|
|
(set (make-local-variable var) value))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(defsubst org-last (list)
|
|
|
|
"Return the last element of LIST."
|
|
|
|
(car (last list)))
|
|
|
|
|
|
|
|
(defun org-let (list &rest body)
|
|
|
|
(eval (cons 'let (cons list body))))
|
|
|
|
(put 'org-let 'lisp-indent-function 1)
|
|
|
|
|
|
|
|
(defun org-let2 (list1 list2 &rest body)
|
|
|
|
(eval (cons 'let (cons list1 (list (cons 'let (cons list2 body)))))))
|
|
|
|
(put 'org-let2 'lisp-indent-function 2)
|
|
|
|
|
|
|
|
(defsubst org-call-with-arg (command arg)
|
2008-05-09 00:08:45 -04:00
|
|
|
"Call COMMAND interactively, but pretend prefix arg was ARG."
|
2008-03-22 11:52:18 -04:00
|
|
|
(let ((current-prefix-arg arg)) (call-interactively command)))
|
|
|
|
|
|
|
|
(defsubst org-current-line (&optional pos)
|
|
|
|
(save-excursion
|
|
|
|
(and pos (goto-char pos))
|
|
|
|
;; works also in narrowed buffer, because we start at 1, not point-min
|
|
|
|
(+ (if (bolp) 1 0) (count-lines 1 (point)))))
|
|
|
|
|
2009-08-27 04:24:09 -04:00
|
|
|
(defsubst org-goto-line (N)
|
|
|
|
(save-restriction
|
|
|
|
(widen)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line (1- N))))
|
|
|
|
|
2009-01-21 07:14:07 -05:00
|
|
|
(defsubst org-current-line-string (&optional to-here)
|
|
|
|
(buffer-substring (point-at-bol) (if to-here (point) (point-at-eol))))
|
|
|
|
|
2008-03-22 11:52:18 -04:00
|
|
|
(defsubst org-pos-in-match-range (pos n)
|
|
|
|
(and (match-beginning n)
|
|
|
|
(<= (match-beginning n) pos)
|
|
|
|
(>= (match-end n) pos)))
|
|
|
|
|
2008-04-10 08:48:59 -04:00
|
|
|
(defun org-match-line (re)
|
2008-04-03 11:58:13 -04:00
|
|
|
"Looking-at at the beginning of the current line."
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-at-bol))
|
|
|
|
(looking-at re)))
|
|
|
|
|
2008-04-04 17:44:48 -04:00
|
|
|
(defun org-plist-delete (plist property)
|
|
|
|
"Delete PROPERTY from PLIST.
|
|
|
|
This is in contrast to merely setting it to 0."
|
|
|
|
(let (p)
|
|
|
|
(while plist
|
|
|
|
(if (not (eq property (car plist)))
|
|
|
|
(setq p (plist-put p (car plist) (nth 1 plist))))
|
|
|
|
(setq plist (cddr plist)))
|
|
|
|
p))
|
|
|
|
|
2009-06-07 10:11:14 -04:00
|
|
|
(defun org-replace-match-keep-properties (newtext &optional fixedcase
|
|
|
|
literal string)
|
|
|
|
"Like `replace-match', but add the text properties found original text."
|
|
|
|
(setq newtext (org-add-props newtext (text-properties-at
|
|
|
|
(match-beginning 0) string)))
|
|
|
|
(replace-match newtext fixedcase literal string))
|
|
|
|
|
2010-08-27 10:18:32 -04:00
|
|
|
(defmacro org-save-outline-visibility (use-markers &rest body)
|
|
|
|
"Save and restore outline visibility around BODY.
|
|
|
|
If USE-MARKERS is non-nil, use markers for the positions.
|
|
|
|
This means that the buffer may change while running BODY,
|
|
|
|
but it also means that the buffer should stay alive
|
|
|
|
during the operation, because otherwise all these markers will
|
|
|
|
point nowhere."
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (form body)) (indent 1))
|
2011-08-10 01:33:43 -04:00
|
|
|
(org-with-gensyms (data rtn)
|
|
|
|
`(let ((,data (org-outline-overlay-data ,use-markers))
|
|
|
|
,rtn)
|
|
|
|
(unwind-protect
|
|
|
|
(progn
|
|
|
|
(setq ,rtn (progn ,@body))
|
|
|
|
(org-set-outline-overlay-data ,data))
|
|
|
|
(when ,use-markers
|
|
|
|
(mapc (lambda (c)
|
|
|
|
(and (markerp (car c)) (move-marker (car c) nil))
|
|
|
|
(and (markerp (cdr c)) (move-marker (cdr c) nil)))
|
|
|
|
,data)))
|
|
|
|
,rtn)))
|
2010-08-27 10:18:32 -04:00
|
|
|
|
2011-03-05 05:01:28 -05:00
|
|
|
(defmacro org-with-wide-buffer (&rest body)
|
2012-08-11 13:10:44 -04:00
|
|
|
"Execute body while temporarily widening the buffer."
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (body)))
|
2012-08-11 13:10:44 -04:00
|
|
|
`(save-excursion
|
|
|
|
(save-restriction
|
2011-03-09 04:56:47 -05:00
|
|
|
(widen)
|
|
|
|
,@body)))
|
2011-03-05 05:01:28 -05:00
|
|
|
|
2009-07-19 03:42:22 -04:00
|
|
|
(defmacro org-with-limited-levels (&rest body)
|
|
|
|
"Execute BODY with limited number of outline levels."
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (body)))
|
|
|
|
`(progn
|
|
|
|
(defvar org-called-with-limited-levels)
|
|
|
|
(defvar org-outline-regexp)
|
|
|
|
(defvar outline-regexp)
|
|
|
|
(defvar org-outline-regexp-bol)
|
|
|
|
(let* ((org-called-with-limited-levels t)
|
|
|
|
(org-outline-regexp (org-get-limited-outline-regexp))
|
|
|
|
(outline-regexp org-outline-regexp)
|
|
|
|
(org-outline-regexp-bol (concat "^" org-outline-regexp)))
|
|
|
|
,@body)))
|
2009-07-19 03:42:22 -04:00
|
|
|
|
2011-07-18 13:25:10 -04:00
|
|
|
(defvar org-outline-regexp) ; defined in org.el
|
2009-07-20 03:16:28 -04:00
|
|
|
(defvar org-odd-levels-only) ; defined in org.el
|
|
|
|
(defvar org-inlinetask-min-level) ; defined in org-inlinetask.el
|
2009-07-19 03:42:22 -04:00
|
|
|
(defun org-get-limited-outline-regexp ()
|
|
|
|
"Return outline-regexp with limited number of levels.
|
2010-07-16 17:23:01 -04:00
|
|
|
The number of levels is controlled by `org-inlinetask-min-level'"
|
2014-07-22 12:29:00 -04:00
|
|
|
(cond ((not (derived-mode-p 'org-mode))
|
|
|
|
outline-regexp)
|
|
|
|
((not (featurep 'org-inlinetask))
|
|
|
|
org-outline-regexp)
|
|
|
|
(t
|
|
|
|
(let* ((limit-level (1- org-inlinetask-min-level))
|
|
|
|
(nstars (if org-odd-levels-only
|
|
|
|
(1- (* limit-level 2))
|
|
|
|
limit-level)))
|
|
|
|
(format "\\*\\{1,%d\\} " nstars)))))
|
2009-08-03 11:30:30 -04:00
|
|
|
|
2011-07-03 07:23:09 -04:00
|
|
|
(defun org-format-seconds (string seconds)
|
2012-07-30 04:08:15 -04:00
|
|
|
"Compatibility function replacing format-seconds."
|
2011-07-03 07:23:09 -04:00
|
|
|
(if (fboundp 'format-seconds)
|
|
|
|
(format-seconds string seconds)
|
|
|
|
(format-time-string string (seconds-to-time seconds))))
|
|
|
|
|
2011-08-10 01:43:10 -04:00
|
|
|
(defmacro org-eval-in-environment (environment form)
|
2015-05-04 11:32:43 -04:00
|
|
|
(declare (debug (form form)) (indent 1))
|
2011-08-10 01:43:10 -04:00
|
|
|
`(eval (list 'let ,environment ',form)))
|
|
|
|
|
2011-08-10 02:14:26 -04:00
|
|
|
(defun org-make-parameter-alist (flat)
|
|
|
|
"Return alist based on FLAT.
|
2012-08-11 13:10:44 -04:00
|
|
|
FLAT is a list with alternating symbol names and values. The
|
2011-08-10 02:14:26 -04:00
|
|
|
returned alist is a list of lists with the symbol name in car and
|
|
|
|
the value in cdr."
|
|
|
|
(when flat
|
|
|
|
(cons (list (car flat) (cadr flat))
|
2012-08-11 13:10:44 -04:00
|
|
|
(org-make-parameter-alist (cddr flat)))))
|
2011-08-10 02:14:26 -04:00
|
|
|
|
2013-01-10 18:43:26 -05:00
|
|
|
;;;###autoload
|
2013-01-06 12:24:56 -05:00
|
|
|
(defmacro org-load-noerror-mustsuffix (file)
|
|
|
|
"Load FILE with optional arguments NOERROR and MUSTSUFFIX. Drop the MUSTSUFFIX argument for XEmacs, which doesn't recognize it."
|
|
|
|
(if (featurep 'xemacs)
|
|
|
|
`(load ,file 'noerror)
|
|
|
|
`(load ,file 'noerror nil nil 'mustsuffix)))
|
|
|
|
|
2008-03-22 11:52:18 -04:00
|
|
|
(provide 'org-macs)
|
|
|
|
|
|
|
|
;;; org-macs.el ends here
|