Browse Source

org-table.el: Don't run table header mode with a timer

* lisp/org-table.el (org-table-header-set-header): Don't run
with a timer.
Bastien 5 months ago
parent
commit
99f5f0ce1e
1 changed files with 19 additions and 23 deletions
  1. 19 23
      lisp/org-table.el

+ 19 - 23
lisp/org-table.el

@@ -471,30 +471,25 @@ This may be useful when columns have been shrunk."
   "Display the header of the table at point."
   (when (overlayp org-table-header-overlay)
     (delete-overlay org-table-header-overlay))
-  (run-with-timer
-   0.01 nil
-   (lambda ()
-     (if (not (org-at-table-p))
-	 (when (overlayp org-table-header-overlay)
-	   (delete-overlay org-table-header-overlay))
-       (let* ((ws (window-start))
-	      (beg (save-excursion
-		     (goto-char (org-table-begin))
-		     (while (or (org-at-table-hline-p)
-				(looking-at-p ".*|\\s-+<[rcl]?\\([0-9]+\\)?>"))
-		       (move-beginning-of-line 2))
-		     (point)))
-	      (end (save-excursion (goto-char beg) (point-at-eol))))
-	 (when (not (pos-visible-in-window-p beg))
-	   (setq org-table-header-overlay
-		 (make-overlay ws (+ ws (- end beg))))
-	   (org-overlay-display
-	    org-table-header-overlay
-	    (org-table-row-get-visible-string beg)
-	    'org-table-header)))))))
+  (let* ((ws (window-start))
+	 (beg (save-excursion
+		(goto-char (org-table-begin))
+		(while (or (org-at-table-hline-p)
+			   (looking-at-p ".*|\\s-+<[rcl]?\\([0-9]+\\)?>"))
+		  (move-beginning-of-line 2))
+		(point)))
+	 (end (save-excursion (goto-char beg) (point-at-eol))))
+    (if (pos-visible-in-window-p beg)
+	(when (overlayp org-table-header-overlay)
+	  (delete-overlay org-table-header-overlay))
+      (setq org-table-header-overlay
+	    (make-overlay ws (+ ws (- end beg))))
+      (org-overlay-display
+       org-table-header-overlay
+       (org-table-row-get-visible-string beg)
+       'org-table-header))))
 
 ;;;###autoload
-(defvar-local org-table-header-line-mode nil)
 (define-minor-mode org-table-header-line-mode
   "Display the first row of the table at point in the header line."
   nil " TblHeader" nil
@@ -503,7 +498,8 @@ This may be useful when columns have been shrunk."
   (if org-table-header-line-mode
       (add-hook 'post-command-hook #'org-table-header-set-header nil t)
     (when (overlayp org-table-header-overlay)
-      (delete-overlay org-table-header-overlay))
+      (delete-overlay org-table-header-overlay)
+      (setq org-table-header-overlay nil))
     (remove-hook 'post-command-hook #'org-table-header-set-header t)))