]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-compat.el
Merge from emacs-24; up to 2014-06-25T10:17:41Z!rgm@gnu.org
[gnu-emacs] / lisp / org / org-compat.el
index a3eb960e134780b73338f2c6b1f8d238801f7ac3..c3ccf062db90d025eaa39539f3efa0bef6fe64b5 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)))))
 
@@ -337,10 +343,25 @@ 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* ((with-bracket-link
+         (save-excursion
+           (forward-line 0)
+           (looking-at (concat "^.*" org-bracket-link-regexp))))
+        (buffer-invisibility-spec
+         (cond
+          ((or (not (derived-mode-p 'org-mode))
+               (and with-bracket-link (org-invisible-p2)))
+           (remove '(org-link) buffer-invisibility-spec))
+          (with-bracket-link
+           (remove t buffer-invisibility-spec))
+          (t 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)
@@ -468,6 +489,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."