summaryrefslogtreecommitdiff
path: root/lisp/org-macs.el
diff options
context:
space:
mode:
authorSebastien Delafond <seb@debian.org>2013-08-11 16:27:56 +0200
committerSébastien Delafond <sdelafond@gmail.com>2014-07-13 13:35:27 +0200
commit53b246b7d66bfa03ab9bcf47d4647913b401e3d6 (patch)
treeb5ea4e732c2219456d13048feb05b37b22a76391 /lisp/org-macs.el
parent8606e2621fc00fd8b334a06924aeef3aab7a2e4d (diff)
parente32a45ed36d6000db4b39171149072d11b77af72 (diff)
Imported Debian patch 8.0.7-1
Diffstat (limited to 'lisp/org-macs.el')
-rw-r--r--lisp/org-macs.el80
1 files changed, 27 insertions, 53 deletions
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index e999917..cc837d0 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -1,6 +1,6 @@
;;; org-macs.el --- Top-level definitions for Org-mode
-;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
@@ -63,14 +63,6 @@
`(interactive-p))))
(def-edebug-spec org-called-interactively-p (&optional ("quote" symbolp)))
-(when (and (not (fboundp 'with-silent-modifications))
- (or (< emacs-major-version 23)
- (and (= emacs-major-version 23)
- (< emacs-minor-version 2))))
- (defmacro with-silent-modifications (&rest body)
- `(org-unmodified ,@body))
- (def-edebug-spec with-silent-modifications (body)))
-
(defmacro org-bound-and-true-p (var)
"Return the value of symbol VAR if it is bound, else nil."
`(and (boundp (quote ,var)) ,var))
@@ -87,16 +79,6 @@
Otherwise return nil."
(and v (not (equal v "nil")) v))
-(defmacro org-unmodified (&rest body)
- "Execute body without changing `buffer-modified-p'.
-Also, do not record undo information."
- `(set-buffer-modified-p
- (prog1 (buffer-modified-p)
- (let ((buffer-undo-list t)
- before-change-functions after-change-functions)
- ,@body))))
-(def-edebug-spec org-unmodified (body))
-
(defun org-substitute-posix-classes (re)
"Substitute posix classes in regular expression RE."
(let ((ss re))
@@ -126,6 +108,19 @@ Also, do not record undo information."
(org-move-to-column ,col)))))
(def-edebug-spec org-preserve-lc (body))
+;; Use `org-with-silent-modifications' to ignore cosmetic changes and
+;; `org-unmodified' to ignore real text modifications
+(defmacro org-unmodified (&rest body)
+ "Run BODY while preserving the buffer's `buffer-modified-p' state."
+ (org-with-gensyms (was-modified)
+ `(let ((,was-modified (buffer-modified-p)))
+ (unwind-protect
+ (let ((buffer-undo-list t)
+ (inhibit-modification-hooks t))
+ ,@body)
+ (set-buffer-modified-p ,was-modified)))))
+(def-edebug-spec org-unmodified (body))
+
(defmacro org-without-partial-completion (&rest body)
`(if (and (boundp 'partial-completion-mode)
partial-completion-mode
@@ -167,46 +162,17 @@ We use a macro so that the test can happen at compilation time."
(cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body))
(def-edebug-spec org-no-warnings (body))
-(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))
-(def-edebug-spec org-if-unprotected (body))
-
-(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))
-(def-edebug-spec org-if-unprotected-1 (body))
-
-(defmacro org-if-unprotected-at (pos &rest body)
- "Execute BODY if there is no `org-protected' text property at POS."
- `(unless (get-text-property ,pos 'org-protected)
- ,@body))
-(def-edebug-spec org-if-unprotected-at (form body))
-(put 'org-if-unprotected-at 'lisp-indent-function 1)
-
-(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))))))
-
-;; FIXME: Normalize argument names
-(defmacro org-with-remote-undo (_buffer &rest _body)
+(defmacro org-with-remote-undo (buffer &rest body)
"Execute BODY while recording undo information in two buffers."
(org-with-gensyms (cline cmd buf1 buf2 undo1 undo2 c1 c2)
`(let ((,cline (org-current-line))
(,cmd this-command)
(,buf1 (current-buffer))
- (,buf2 ,_buffer)
+ (,buf2 ,buffer)
(,undo1 buffer-undo-list)
- (,undo2 (with-current-buffer ,_buffer buffer-undo-list))
+ (,undo2 (with-current-buffer ,buffer buffer-undo-list))
,c1 ,c2)
- ,@_body
+ ,@body
(when org-agenda-allow-remote-undo
(setq ,c1 (org-verify-change-for-undo
,undo1 (with-current-buffer ,buf1 buffer-undo-list))
@@ -254,7 +220,8 @@ in `org-rm-props'."
(cond ((eq key t) t)
((eq option t) t)
((assoc key option) (cdr (assoc key option)))
- (t (cdr (assq 'default option)))))
+ (t (let ((r (cdr (assq 'default option))))
+ (if (listp r) (delq nil r) r)))))
(defsubst org-check-external-command (cmd &optional use no-error)
"Check if external program CMD for USE exists, error if not.
@@ -417,6 +384,13 @@ the value in cdr."
(cons (list (car flat) (cadr flat))
(org-make-parameter-alist (cddr flat)))))
+;;;###autoload
+(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)))
+
(provide 'org-macs)
;;; org-macs.el ends here