2008-03-22 11:52:18 -04:00
|
|
|
;;; org-macs.el --- Top-level definitions for Org-mode
|
|
|
|
|
2012-01-03 12:47:01 -05:00
|
|
|
;; Copyright (C) 2004-2012 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)
|
2010-11-21 05:20:40 -05:00
|
|
|
(defmacro declare-function (fn file &optional arglist fileonly)))
|
|
|
|
(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))
|
2010-07-20 01:54:11 -04:00
|
|
|
(declare-function org-string-match-p "org-compat" (&rest args))
|
2009-06-07 11:07:07 -04:00
|
|
|
|
2011-08-10 01:28:41 -04:00
|
|
|
(defmacro org-with-gensyms (symbols &rest body)
|
|
|
|
`(let ,(mapcar (lambda (s)
|
|
|
|
`(,s (make-symbol (concat "--" (symbol-name ',s))))) symbols)
|
|
|
|
,@body))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-with-gensyms (sexp body))
|
2011-08-10 01:28:41 -04:00
|
|
|
(put 'org-with-gensyms 'lisp-indent-function 1)
|
|
|
|
|
2010-10-25 07:26:27 -04:00
|
|
|
(defmacro org-called-interactively-p (&optional kind)
|
2011-06-29 18:25:09 -04:00
|
|
|
(if (featurep 'xemacs)
|
|
|
|
`(interactive-p)
|
2010-10-25 07:26:27 -04:00
|
|
|
(if (or (> emacs-major-version 23)
|
|
|
|
(and (>= emacs-major-version 23)
|
|
|
|
(>= emacs-minor-version 2)))
|
2011-06-29 18:25:09 -04:00
|
|
|
`(with-no-warnings (called-interactively-p ,kind)) ;; defined with no argument in <=23.1
|
|
|
|
`(interactive-p))))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-called-interactively-p (&optional ("quote" symbolp)))
|
2010-10-25 07:26:27 -04:00
|
|
|
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(when (and (not (fboundp 'with-silent-modifications))
|
2010-12-03 14:53:34 -05:00
|
|
|
(or (< emacs-major-version 23)
|
|
|
|
(and (= emacs-major-version 23)
|
|
|
|
(< emacs-minor-version 2))))
|
|
|
|
(defmacro with-silent-modifications (&rest body)
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
`(org-unmodified ,@body))
|
|
|
|
(def-edebug-spec with-silent-modifications (body)))
|
2010-11-18 20:37:01 -05: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."
|
|
|
|
`(and (boundp (quote ,var)) ,var))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-bound-and-true-p (symbolp))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
2010-07-20 01:54:11 -04:00
|
|
|
(defun org-string-nw-p (s)
|
|
|
|
"Is S a string with a non-white character?"
|
|
|
|
(and (stringp s)
|
|
|
|
(org-string-match-p "\\S-" s)
|
|
|
|
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
|
|
|
|
2008-03-22 11:52:18 -04:00
|
|
|
(defmacro org-unmodified (&rest body)
|
2009-08-03 05:03:37 -04:00
|
|
|
"Execute body without changing `buffer-modified-p'.
|
|
|
|
Also, do not record undo information."
|
2008-03-22 11:52:18 -04:00
|
|
|
`(set-buffer-modified-p
|
2009-07-18 02:14:03 -04:00
|
|
|
(prog1 (buffer-modified-p)
|
2009-08-03 05:03:37 -04:00
|
|
|
(let ((buffer-undo-list t)
|
|
|
|
before-change-functions after-change-functions)
|
2009-07-18 02:14:03 -04:00
|
|
|
,@body))))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-unmodified (body))
|
2008-03-22 11:52:18 -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."
|
2011-08-10 01:49:02 -04:00
|
|
|
(if (featurep 'xemacs) `(org-substitute-posix-classes ,s) s))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-re (form))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(defmacro org-preserve-lc (&rest 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)))))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-preserve-lc (body))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(defmacro org-without-partial-completion (&rest 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))
|
2008-03-22 11:52:18 -04:00
|
|
|
(unwind-protect
|
|
|
|
(progn
|
2011-07-02 05:25:56 -04:00
|
|
|
(partial-completion-mode -1)
|
2008-03-22 11:52:18 -04:00
|
|
|
,@body)
|
2011-07-02 06:15:20 -04:00
|
|
|
(partial-completion-mode 1))
|
|
|
|
,@body))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-without-partial-completion (body))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -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)
|
2008-12-16 11:23:08 -05: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."
|
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)))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (or ,mpom (point)))
|
|
|
|
,@body)))))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-with-point-at (form body))
|
2009-09-12 01:05:21 -04:00
|
|
|
(put 'org-with-point-at 'lisp-indent-function 1)
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(defmacro org-no-warnings (&rest body)
|
|
|
|
(cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-no-warnings (body))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(defmacro org-if-unprotected (&rest body)
|
|
|
|
"Execute BODY if there is no `org-protected' text property at point."
|
|
|
|
`(unless (get-text-property (point) 'org-protected)
|
|
|
|
,@body))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-if-unprotected (body))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
LaTeX export: Make quotes exported right before a footnote reference.
Matt Lundin writes:
I'm have a *minor* issue to report. It occurs when I export
an org file with footnotes to LaTeX. Specifically, it has to
do with the combination of American style quotation marks
and footnotes.
According to many American manuals of style, quotation marks
are to be placed after a sentence ending period if the
quoted passage is at the end of the sentence. E.g.
,----
| Here is "a quote."
|
| not
|
| Here is "a quote".
`----
When I use American style quotation in conjuction with a
footnote, the exporter does not convert the closing quote
marks into a two single quotation marks (i.e., LaTeX smart
quotes).
Thus, the following source snippet:
,----
| This is a footnote "with a quote."[fn:sample] And here
| is another footnote "with a quote".[fn:another]
|
| [fn:sample] Here is the sample footnote.
|
| [fn:another] Another footnote.
`----
Becomes
,----
| This is a footnote ``with a quote."\footnote{Here is
| the sample footnote. } And here is another footnote ``with
| a quote''.\footnote{Another footnote. }
`----
Notice the double quotation mark (rather than two single
apostrophes) at the end of the first sentence. Notice also
the correct quotation mark format appears in the second
sentence, where the period comes after the quotation mark.
This commit addresses this issue by checking of text
protection is off not after the quotation mark, but before.
2009-01-20 02:26:44 -05:00
|
|
|
(defmacro org-if-unprotected-1 (&rest body)
|
|
|
|
"Execute BODY if there is no `org-protected' text property at point-1."
|
|
|
|
`(unless (get-text-property (1- (point)) 'org-protected)
|
|
|
|
,@body))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-if-unprotected-1 (body))
|
LaTeX export: Make quotes exported right before a footnote reference.
Matt Lundin writes:
I'm have a *minor* issue to report. It occurs when I export
an org file with footnotes to LaTeX. Specifically, it has to
do with the combination of American style quotation marks
and footnotes.
According to many American manuals of style, quotation marks
are to be placed after a sentence ending period if the
quoted passage is at the end of the sentence. E.g.
,----
| Here is "a quote."
|
| not
|
| Here is "a quote".
`----
When I use American style quotation in conjuction with a
footnote, the exporter does not convert the closing quote
marks into a two single quotation marks (i.e., LaTeX smart
quotes).
Thus, the following source snippet:
,----
| This is a footnote "with a quote."[fn:sample] And here
| is another footnote "with a quote".[fn:another]
|
| [fn:sample] Here is the sample footnote.
|
| [fn:another] Another footnote.
`----
Becomes
,----
| This is a footnote ``with a quote."\footnote{Here is
| the sample footnote. } And here is another footnote ``with
| a quote''.\footnote{Another footnote. }
`----
Notice the double quotation mark (rather than two single
apostrophes) at the end of the first sentence. Notice also
the correct quotation mark format appears in the second
sentence, where the period comes after the quotation mark.
This commit addresses this issue by checking of text
protection is off not after the quotation mark, but before.
2009-01-20 02:26:44 -05:00
|
|
|
|
2009-02-17 16:23:50 -05:00
|
|
|
(defmacro org-if-unprotected-at (pos &rest body)
|
2009-09-28 15:35:49 -04:00
|
|
|
"Execute BODY if there is no `org-protected' text property at POS."
|
2009-02-17 16:23:50 -05:00
|
|
|
`(unless (get-text-property ,pos 'org-protected)
|
|
|
|
,@body))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-if-unprotected-at (form body))
|
2009-10-07 02:10:05 -04:00
|
|
|
(put 'org-if-unprotected-at 'lisp-indent-function 1)
|
|
|
|
|
2009-11-25 05:15:19 -05:00
|
|
|
(defun org-re-search-forward-unprotected (&rest args)
|
|
|
|
"Like re-search-forward, but stop only in unprotected places."
|
|
|
|
(catch 'exit
|
|
|
|
(while t
|
|
|
|
(unless (apply 're-search-forward args)
|
|
|
|
(throw 'exit nil))
|
|
|
|
(unless (get-text-property (match-beginning 0) 'org-protected)
|
|
|
|
(throw 'exit (point))))))
|
2009-02-17 16:23:50 -05:00
|
|
|
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
;; FIXME: Normalize argument names
|
2008-03-22 11:52:18 -04:00
|
|
|
(defmacro org-with-remote-undo (_buffer &rest _body)
|
|
|
|
"Execute BODY while recording undo information in two buffers."
|
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))
|
|
|
|
(,buf2 ,_buffer)
|
|
|
|
(,undo1 buffer-undo-list)
|
|
|
|
(,undo2 (with-current-buffer ,_buffer buffer-undo-list))
|
|
|
|
,c1 ,c2)
|
|
|
|
,@_body
|
|
|
|
(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))))))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-with-remote-undo (form body))
|
2011-02-27 07:50:02 -05:00
|
|
|
(put 'org-with-remote-undo 'lisp-indent-function 1)
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(defmacro org-no-read-only (&rest body)
|
|
|
|
"Inhibit read-only for BODY."
|
|
|
|
`(let ((inhibit-read-only t)) ,@body))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-no-read-only (body))
|
2008-03-22 11:52:18 -04:00
|
|
|
|
|
|
|
(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)))
|
|
|
|
|
|
|
|
(defsubst org-no-properties (s)
|
|
|
|
(if (fboundp 'set-text-properties)
|
|
|
|
(set-text-properties 0 (length s) nil s)
|
|
|
|
(remove-text-properties 0 (length s) org-rm-props s))
|
|
|
|
s)
|
|
|
|
|
|
|
|
(defsubst org-get-alist-option (option key)
|
|
|
|
(cond ((eq key t) t)
|
|
|
|
((eq option t) t)
|
|
|
|
((assoc key option) (cdr (assoc key option)))
|
|
|
|
(t (cdr (assq 'default option)))))
|
|
|
|
|
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)))
|
|
|
|
|
|
|
|
(defun org-autoload (file functions)
|
2008-05-09 00:08:45 -04:00
|
|
|
"Establish autoload for all FUNCTIONS in FILE, if not bound already."
|
2008-03-22 11:52:18 -04:00
|
|
|
(let ((d (format "Documentation will be available after `%s.el' is loaded."
|
|
|
|
file))
|
|
|
|
f)
|
|
|
|
(while (setq f (pop functions))
|
|
|
|
(or (fboundp f) (autoload f file d t)))))
|
|
|
|
|
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."
|
|
|
|
(declare (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)))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-save-outline-visibility (form body))
|
2010-08-27 10:18:32 -04:00
|
|
|
|
2011-03-05 05:01:28 -05:00
|
|
|
(defmacro org-with-wide-buffer (&rest body)
|
2011-03-09 04:56:47 -05:00
|
|
|
"Execute body while temporarily widening the buffer."
|
|
|
|
`(save-excursion
|
|
|
|
(save-restriction
|
|
|
|
(widen)
|
|
|
|
,@body)))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-with-wide-buffer (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."
|
2011-07-21 07:45:48 -04:00
|
|
|
`(let* ((org-outline-regexp (org-get-limited-outline-regexp))
|
2011-07-23 04:13:07 -04:00
|
|
|
(outline-regexp org-outline-regexp)
|
2011-07-21 07:45:48 -04:00
|
|
|
(org-outline-regexp-at-bol (concat "^" org-outline-regexp)))
|
2009-07-19 03:42:22 -04:00
|
|
|
,@body))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-with-limited-levels (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'"
|
Use (derived-mode-p 'org-mode) instead of (eq major-mode 'org-mode).
* org.el (org-show-hierarchy-above, org-cycle)
(org-global-cycle, org-files-list, org-store-link)
(org-link-search, org-open-file, org-display-outline-path)
(org-refile-get-location, org-update-all-dblocks)
(org-change-tag-in-region, org-entry-properties)
(org-save-all-org-buffers, org-revert-all-org-buffers)
(org-buffer-list, org-cdlatex-mode)
(org-install-agenda-files-menu, org-end-of-subtree)
(org-speedbar-set-agenda-restriction): Use (derived-mode-p
'org-mode) instead of (eq major-mode 'org-mode).
* org-timer.el (org-timer-set-timer): Ditto.
* org-table.el (orgtbl-mode, org-table-align, orgtbl-mode): Ditto.
* org-src.el (org-edit-src-exit, org-edit-src-code)
(org-edit-fixed-width-region, org-edit-src-exit): Ditto.
* org-remember.el (org-remember-handler): Ditto.
* org-mouse.el (dnd-open-file, org-mouse-insert-item): Ditto.
* org-macs.el (org-get-limited-outline-regexp): Ditto.
* org-lparse.el (org-replace-region-by): Ditto.
* org-latex.el (org-latex-to-pdf-process)
(org-replace-region-by-latex): Ditto.
* org-indent.el (org-indent-indent-buffer): Ditto.
* org-id.el (org-id-store-link, org-id-update-id-locations)
(org-id-store-link): Ditto.
* org-html.el (org-export-html-preprocess)
(org-replace-region-by-html): Ditto.
* org-footnote.el (org-footnote-normalize)
(org-footnote-goto-definition)
(org-footnote-create-definition, org-footnote-normalize): Ditto.
* org-docbook.el (org-replace-region-by-docbook): Ditto.
* org-ctags.el (find-tag): Ditto.
* org-colview.el (org-columns-redo)
(org-columns-display-here, org-columns-edit-value)
(org-columns-redo): Ditto.
* org-colview-xemacs.el (org-columns-redo)
(org-columns-display-here, org-columns-edit-value)
(org-columns-redo): Ditto.
* org-capture.el (org-capture-insert-template-here)
(org-capture, org-capture-finalize)
(org-capture-set-target-location)
(org-capture-insert-template-here): Ditto.
* org-ascii.el (org-replace-region-by-ascii): Ditto.
* org-archive.el (org-archive-subtree): Ditto.
* org-agenda.el (org-agenda)
(org-agenda-get-restriction-and-command)
(org-agenda-get-some-entry-text, org-search-view)
(org-tags-view, org-agenda-get-day-entries)
(org-agenda-format-item, org-agenda-goto, org-agenda-kill)
(org-agenda-archive-with, org-agenda-switch-to): Ditto.
2012-04-20 14:03:45 -04:00
|
|
|
(if (or (not (derived-mode-p 'org-mode)) (not (featurep 'org-inlinetask)))
|
Don't use `outline-regexp' anymore.
Use `org-outline-regexp' instead or `outline-regexp'. Also use the
new defconst `org-outline-regexp-bol' to match `org-outline-regexp'
at the beginning of line.
* org.el (org-outline-regexp-bol): New defconst.
(org-outline-level, org-set-font-lock-defaults, org-cycle)
(org-overview, org-content, org-flag-drawer)
(org-first-headline-recenter, org-insert-todo-heading)
(org-map-region, org-move-subtree-down, org-paste-subtree)
(org-kill-is-subtree-p, org-context-p, org-refile)
(org-refile-new-child, org-toggle-comment, org-todo)
(org-add-planning-info, org-add-log-setup, org-scan-tags)
(org-set-tags, org-insert-property-drawer)
(org-prepare-agenda-buffers, org-preview-latex-fragment)
(org-speed-command-default-hook, org-check-for-hidden)
(org-toggle-item, org-toggle-heading)
(org-indent-line-function, org-set-autofill-regexps)
(org-fill-paragraph, org-toggle-fixed-width-section)
(org-yank-generic, org-yank-folding-would-swallow-text)
(org-first-sibling-p, org-goto-sibling)
(org-goto-first-child, org-show-entry): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-remember.el (org-remember-handler): Use
`org-outline-regexp-bol'.
* org-mouse.el (org-mouse-match-todo-keyword, org-mode-hook)
(org-mouse-move-tree, org-mouse-transform-to-outline): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-macs.el (org-with-limited-levels)
(org-get-limited-outline-regexp): Use `org-outline-regexp'.
* org-indent.el (org-indent-outline-re)
(org-indent-refresh-section, org-indent-refresh-to): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-html.el (org-export-as-html): Use
`org-outline-regexp-bol'.
* org-footnote.el (org-footnote-at-definition-p)
(org-footnote-normalize): Use `org-outline-regexp' and
`org-outline-regexp-bol'.
* org-exp.el (org-export-preprocess-string): Don't redefine
`outline-regexp'.
* org-docbook.el (org-export-as-docbook): Use
`org-outline-regexp-bol'.
* org-colview.el (org-columns, org-columns-compute): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
* org-colview-xemacs.el (org-columns, org-columns-compute):
Use `org-outline-regexp-bol'.
* org-clock.el (org-clock-insert-selection-line)
(org-clock-in, org-clock-out, org-dblock-write:clocktable):
Use `org-outline-regexp' and `org-outline-regexp-bol'.
* org-ascii.el (org-export-as-ascii)
(org-export-ascii-push-links): Use `org-outline-regexp' and
`org-outline-regexp-bol'.
* org-archive.el (org-archive-to-archive-sibling)
(org-archive-all-done): Use `org-outline-regexp' and
`org-outline-regexp-bol'.
* org-agenda.el (org-agenda, org-search-view)
(org-agenda-list-stuck-projects, org-agenda-get-timestamps)
(org-agenda-get-progress, org-agenda-get-blocks): Use
`org-outline-regexp' and `org-outline-regexp-bol'.
2011-07-17 15:17:08 -04:00
|
|
|
org-outline-regexp
|
2009-07-19 03:42:22 -04:00
|
|
|
(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)
|
|
|
|
"Compatibility function replacing format-seconds"
|
|
|
|
(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)
|
|
|
|
`(eval (list 'let ,environment ',form)))
|
Provide edebug specifications for macros
* org-macs.el (org-with-gensyms, org-called-interactively-p)
(with-silent-modifications, org-bound-and-true-p)
(org-unmodified, org-re, org-preserve-lc)
(org-without-partial-completion, org-with-point-at)
(org-no-warnings, org-if-unprotected, org-if-unprotected-1)
(org-if-unprotected-at, org-with-remote-undo)
(org-no-read-only, org-save-outline-visibility)
(org-with-wide-buffer, org-with-limited-levels)
(org-eval-in-environment): Provide edebug specifications.
* org-src.el (org-src-do-at-code-block): Dto.
* org-publish.el (org-publish-with-aux-preprocess-maybe): Dto.
* org-compat.el (org-xemacs-without-invisibility): Dto.
* org-clock.el (org-with-clock-position, org-with-clock): Dto.
* org-agenda.el (org-agenda-with-point-at-orig-entry)
(org-batch-agenda, org-batch-agenda-csv)
(org-batch-store-agenda-views): Dto.
* ob.el (org-babel-do-in-edit-buffer)
(org-babel-map-src-blocks, org-babel-map-inline-src-blocks): Dto.
* ob-tangle.el (org-babel-with-temp-filebuffer): Dto.
* ob-table.el (sbe): Dto.
* ob-exp.el (org-babel-exp-in-export-file): Dto.
* ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Dto.
2011-08-11 02:57:25 -04:00
|
|
|
(def-edebug-spec org-eval-in-environment (form form))
|
2011-08-10 01:43:10 -04:00
|
|
|
(put 'org-eval-in-environment 'lisp-indent-function 1)
|
|
|
|
|
2011-08-10 02:14:26 -04:00
|
|
|
(defun org-make-parameter-alist (flat)
|
|
|
|
"Return alist based on FLAT.
|
|
|
|
FLAT is a list with alternating symbol names and values. The
|
|
|
|
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))
|
|
|
|
(org-make-parameter-alist (cddr flat)))))
|
|
|
|
|
2008-03-22 11:52:18 -04:00
|
|
|
(provide 'org-macs)
|
|
|
|
|
|
|
|
;;; org-macs.el ends here
|