From 417479238bc936b2b5020178877b5582c4270b75 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 17 Jul 2018 11:41:58 +0200 Subject: [PATCH] org-macs: Move a macro --- lisp/org-macs.el | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index ae81fec24..48f1f6a71 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 @@ -1035,23 +1045,6 @@ move it back by one char before doing this check." (backward-char 1)) (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