summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-07-17 11:41:58 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-07-17 11:41:58 +0200
commit417479238bc936b2b5020178877b5582c4270b75 (patch)
tree85d3976fd7381c64d387c93208d7c7a6b3f516e4
parenta2636b5286a41f093eab917650b2ee1836b8a50b (diff)
downloadorg-mode-417479238bc936b2b5020178877b5582c4270b75.tar.gz
org-macs: Move a macro
-rw-r--r--lisp/org-macs.el27
1 files changed, 10 insertions, 17 deletions
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index ae81fec..48f1f6a 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -200,6 +200,16 @@ because otherwise all these markers will point to nowhere."
`(let (pop-up-frames display-buffer-alist)
,@body))
+(defmacro org-table-with-shrunk-field (&rest body)
+ "Save field shrunk state, execute BODY and restore state."
+ (declare (debug (body)))
+ (org-with-gensyms (end shrunk size)
+ `(let* ((,shrunk (save-match-data (org-table--shrunk-field)))
+ (,end (and ,shrunk (copy-marker (overlay-end ,shrunk) t)))
+ (,size (and ,shrunk (- ,end (overlay-start ,shrunk)))))
+ (when ,shrunk (delete-overlay ,shrunk))
+ (unwind-protect (progn ,@body)
+ (when ,shrunk (move-overlay ,shrunk (- ,end ,size) ,end))))))
;;; Buffer and windows
@@ -1036,23 +1046,6 @@ move it back by one char before doing this check."
(org-invisible-p)))
-;;; Tables
-
-;; This macro is placed here because it is used in org.el.
-;; org-table.el requires org.el. So, if we put this macro in its
-;; natural place (org-table), a require loop would result.
-(defmacro org-table-with-shrunk-field (&rest body)
- "Save field shrunk state, execute BODY and restore state."
- (declare (debug (body)))
- (org-with-gensyms (end shrunk size)
- `(let* ((,shrunk (save-match-data (org-table--shrunk-field)))
- (,end (and ,shrunk (copy-marker (overlay-end ,shrunk) t)))
- (,size (and ,shrunk (- ,end (overlay-start ,shrunk)))))
- (when ,shrunk (delete-overlay ,shrunk))
- (unwind-protect (progn ,@body)
- (when ,shrunk (move-overlay ,shrunk (- ,end ,size) ,end))))))
-
-
;;; Time
(defun org-2ft (s)