]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-compat.el
Simplify use of current-time and friends.
[gnu-emacs] / lisp / org / org-compat.el
index a3eb960e134780b73338f2c6b1f8d238801f7ac3..122658970f5d3c605a3406cfb4a895d40cd18487 100644 (file)
@@ -1,6 +1,6 @@
 ;;; org-compat.el --- Compatibility code for Org-mode
 
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2014 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -260,6 +260,12 @@ ignored in this case."
                  next (+ from (* n inc)))))
        (nreverse seq)))))
 
+;; `set-transient-map' is only in Emacs >= 24.4
+(defalias 'org-set-transient-map
+  (if (fboundp 'set-transient-map)
+      'set-transient-map
+    'set-temporary-overlay-map))
+
 ;; Region compatibility
 
 (defvar org-ignore-region nil
@@ -289,7 +295,7 @@ Works on both Emacs and XEmacs."
       (setq mark-active t)
       (when (and (boundp 'transient-mark-mode)
                 (not transient-mark-mode))
-       (setq transient-mark-mode 'lambda))
+       (set (make-local-variable 'transient-mark-mode) 'lambda))
       (when (boundp 'zmacs-regions)
        (setq zmacs-regions t)))))
 
@@ -306,8 +312,7 @@ Works on both Emacs and XEmacs."
 (defun org-in-invisibility-spec-p (arg)
   "Is ARG a member of `buffer-invisibility-spec'?"
   (if (consp buffer-invisibility-spec)
-      (member arg buffer-invisibility-spec)
-    nil))
+      (member arg buffer-invisibility-spec)))
 
 (defmacro org-xemacs-without-invisibility (&rest body)
   "Turn off extents with invisibility while executing BODY."
@@ -337,10 +342,15 @@ Works on both Emacs and XEmacs."
       (org-xemacs-without-invisibility (indent-line-to column))
     (indent-line-to column)))
 
-(defun org-move-to-column (column &optional force buffer ignore-invisible)
-  (let ((buffer-invisibility-spec ignore-invisible))
+(defun org-move-to-column (column &optional force buffer)
+  "Move to column COLUMN.
+Pass COLUMN and FORCE to `move-to-column'.
+Pass BUFFER to the XEmacs version of `move-to-column'."
+  (let ((buffer-invisibility-spec
+        (remove '(org-filtered) buffer-invisibility-spec)))
     (if (featurep 'xemacs)
-       (org-xemacs-without-invisibility (move-to-column column force buffer))
+       (org-xemacs-without-invisibility
+        (move-to-column column force buffer))
       (move-to-column column force))))
 
 (defun org-get-x-clipboard-compat (value)
@@ -401,12 +411,10 @@ Works on both Emacs and XEmacs."
         (when focus-follows-mouse
           (set-mouse-position frame (1- (frame-width frame)) 0)))))
 
-(defun org-float-time (&optional time)
+(defalias 'org-float-time
+  (if (featurep 'xemacs) 'time-to-seconds 'float-time)
   "Convert time value TIME to a floating point number.
-TIME defaults to the current time."
-  (if (featurep 'xemacs)
-      (time-to-seconds (or time (current-time)))
-    (float-time time)))
+TIME defaults to the current time.")
 
 ;; `user-error' is only available from 24.2.50 on
 (unless (fboundp 'user-error)
@@ -468,6 +476,11 @@ LIMIT."
              (looking-at (concat "\\(?:"  regexp "\\)\\'")))))
       (not (null pos)))))
 
+(defalias 'org-font-lock-ensure
+  (if (fboundp 'org-font-lock-ensure)
+      #'font-lock-ensure
+    (lambda (_beg _end) (font-lock-fontify-buffer))))
+
 (defun org-floor* (x &optional y)
   "Return a list of the floor of X and the fractional part of X.
 With two arguments, return floor and remainder of their quotient."