aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2010-08-18 20:45:46 -0700
committerGlenn Morris2010-08-18 20:45:46 -0700
commite720ae53ac68e4d6f8b0f582fd1cd979942185a4 (patch)
treef0b2db1127cd25068fb17f5a68dcdfbda7029e5b
parentb2a15250f652d800838f66abc1f877f0cad0d323 (diff)
downloademacs-e720ae53ac68e4d6f8b0f582fd1cd979942185a4.tar.gz
emacs-e720ae53ac68e4d6f8b0f582fd1cd979942185a4.zip
Fix previous Org change.
* org.el (org-outline-overlay-data, org-set-outline-overlay-data) (org-save-outline-visibility): Move to org-macs. * org-macs.el (org-outline-overlay-data, org-set-outline-overlay-data) (org-save-outline-visibility): Move here from org.el. (show-all): Autoload it. * ob.el: Don't require org when compiling.
-rw-r--r--lisp/org/ChangeLog9
-rw-r--r--lisp/org/ob.el3
-rw-r--r--lisp/org/org-macs.el60
-rw-r--r--lisp/org/org.el56
4 files changed, 70 insertions, 58 deletions
diff --git a/lisp/org/ChangeLog b/lisp/org/ChangeLog
index 5b650492442..c0b3fa567c6 100644
--- a/lisp/org/ChangeLog
+++ b/lisp/org/ChangeLog
@@ -1,3 +1,12 @@
12010-08-19 Glenn Morris <rgm@gnu.org>
2
3 * org.el (org-outline-overlay-data, org-set-outline-overlay-data)
4 (org-save-outline-visibility): Move to org-macs.
5 * org-macs.el (org-outline-overlay-data, org-set-outline-overlay-data)
6 (org-save-outline-visibility): Move here from org.el.
7 (show-all): Autoload it.
8 * ob.el: Don't require org when compiling.
9
12010-08-18 Glenn Morris <rgm@gnu.org> 102010-08-18 Glenn Morris <rgm@gnu.org>
2 11
3 * ob.el: Require org when compiling. 12 * ob.el: Require org when compiling.
diff --git a/lisp/org/ob.el b/lisp/org/ob.el
index 4ae3e4f662c..a58fb4eca8a 100644
--- a/lisp/org/ob.el
+++ b/lisp/org/ob.el
@@ -30,8 +30,7 @@
30 30
31;;; Code: 31;;; Code:
32(eval-when-compile 32(eval-when-compile
33 (require 'cl) 33 (require 'cl))
34 (require 'org)) ; org-save-outline-visibility macro
35(require 'org-macs) 34(require 'org-macs)
36 35
37(defvar org-babel-call-process-region-original) 36(defvar org-babel-call-process-region-original)
diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index abcdcdc94eb..212fae4fcc9 100644
--- a/lisp/org/org-macs.el
+++ b/lisp/org/org-macs.el
@@ -300,6 +300,66 @@ The number of levels is controlled by `org-inlinetask-min-level'"
300 (nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level))) 300 (nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level)))
301 (format "\\*\\{1,%d\\} " nstars)))) 301 (format "\\*\\{1,%d\\} " nstars))))
302 302
303
304;;; Saving and restoring visibility
305
306(defun org-outline-overlay-data (&optional use-markers)
307 "Return a list of the locations of all outline overlays.
308The are overlays with the `invisible' property value `outline'.
309The return values is a list of cons cells, with start and stop
310positions for each overlay.
311If USE-MARKERS is set, return the positions as markers."
312 (let (beg end)
313 (save-excursion
314 (save-restriction
315 (widen)
316 (delq nil
317 (mapcar (lambda (o)
318 (when (eq (overlay-get o 'invisible) 'outline)
319 (setq beg (overlay-start o)
320 end (overlay-end o))
321 (and beg end (> end beg)
322 (if use-markers
323 (cons (move-marker (make-marker) beg)
324 (move-marker (make-marker) end))
325 (cons beg end)))))
326 (overlays-in (point-min) (point-max))))))))
327
328(autoload 'show-all "outline" nil t)
329
330(defun org-set-outline-overlay-data (data)
331 "Create visibility overlays for all positions in DATA.
332DATA should have been made by `org-outline-overlay-data'."
333 (let (o)
334 (save-excursion
335 (save-restriction
336 (widen)
337 (show-all)
338 (mapc (lambda (c)
339 (setq o (make-overlay (car c) (cdr c)))
340 (overlay-put o 'invisible 'outline))
341 data)))))
342
343(defmacro org-save-outline-visibility (use-markers &rest body)
344 "Save and restore outline visibility around BODY.
345If USE-MARKERS is non-nil, use markers for the positions.
346This means that the buffer may change while running BODY,
347but it also means that the buffer should stay alive
348during the operation, because otherwise all these markers will
349point nowhere."
350 (declare (indent 1))
351 `(let ((data (org-outline-overlay-data ,use-markers)))
352 (unwind-protect
353 (progn
354 ,@body
355 (org-set-outline-overlay-data data))
356 (when ,use-markers
357 (mapc (lambda (c)
358 (and (markerp (car c)) (move-marker (car c) nil))
359 (and (markerp (cdr c)) (move-marker (cdr c) nil)))
360 data)))))
361
362
303(provide 'org-macs) 363(provide 'org-macs)
304 364
305;; arch-tag: 7e6a73ce-aac9-4fc0-9b30-ce6f89dc6668 365;; arch-tag: 7e6a73ce-aac9-4fc0-9b30-ce6f89dc6668
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 5b37e0aa260..a2965e87d22 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -6190,62 +6190,6 @@ Optional argument N means put the headline into the Nth line of the window."
6190 (beginning-of-line) 6190 (beginning-of-line)
6191 (recenter (prefix-numeric-value N)))) 6191 (recenter (prefix-numeric-value N))))
6192 6192
6193;;; Saving and restoring visibility
6194
6195(defun org-outline-overlay-data (&optional use-markers)
6196 "Return a list of the locations of all outline overlays.
6197The are overlays with the `invisible' property value `outline'.
6198The return values is a list of cons cells, with start and stop
6199positions for each overlay.
6200If USE-MARKERS is set, return the positions as markers."
6201 (let (beg end)
6202 (save-excursion
6203 (save-restriction
6204 (widen)
6205 (delq nil
6206 (mapcar (lambda (o)
6207 (when (eq (overlay-get o 'invisible) 'outline)
6208 (setq beg (overlay-start o)
6209 end (overlay-end o))
6210 (and beg end (> end beg)
6211 (if use-markers
6212 (cons (move-marker (make-marker) beg)
6213 (move-marker (make-marker) end))
6214 (cons beg end)))))
6215 (overlays-in (point-min) (point-max))))))))
6216
6217(defun org-set-outline-overlay-data (data)
6218 "Create visibility overlays for all positions in DATA.
6219DATA should have been made by `org-outline-overlay-data'."
6220 (let (o)
6221 (save-excursion
6222 (save-restriction
6223 (widen)
6224 (show-all)
6225 (mapc (lambda (c)
6226 (setq o (make-overlay (car c) (cdr c)))
6227 (overlay-put o 'invisible 'outline))
6228 data)))))
6229
6230(defmacro org-save-outline-visibility (use-markers &rest body)
6231 "Save and restore outline visibility around BODY.
6232If USE-MARKERS is non-nil, use markers for the positions.
6233This means that the buffer may change while running BODY,
6234but it also means that the buffer should stay alive
6235during the operation, because otherwise all these markers will
6236point nowhere."
6237 (declare (indent 1))
6238 `(let ((data (org-outline-overlay-data ,use-markers)))
6239 (unwind-protect
6240 (progn
6241 ,@body
6242 (org-set-outline-overlay-data data))
6243 (when ,use-markers
6244 (mapc (lambda (c)
6245 (and (markerp (car c)) (move-marker (car c) nil))
6246 (and (markerp (cdr c)) (move-marker (cdr c) nil)))
6247 data)))))
6248
6249 6193
6250;;; Folding of blocks 6194;;; Folding of blocks
6251 6195