Browse Source

org-table: Improve tables' speed in large buffers

* lisp/org-table.el (org-table-auto-recalculate-regexp):
(org-table-recalculate-regexp):
(org-table-calculate-mark-regexp):
(org-table-column-names):
(org-table-column-name-regexp):
(org-table-local-parameters):
(org-table-named-field-locations):
(org-table-current-line-types):
(org-table-current-begin-pos):
(org-table-current-ncol):
(org-table-dlines):
(org-table-hlines): Improve docstrings.

(org-table-current-begin-line): Remove variable.

(org-table-save-field): New macro.

(org-table-get-specials): Remove function.
(org-table-analyze): New function, renamed from
`org-table-get-specials'.

(org-table-find-row-type): Remove function.
(org-table--row-type): New function, renamed from
`org-table-find-row-type'.

(org-table-align): Use new macro.

(org-table-field-info):
(org-table-insert-column):
(org-table-delete-column):
(org-table-move-column):
(org-table-sort-lines):
(org-table-paste-rectangle):
(org-table-wrap-region):
(org-table-current-field-formula):
(org-table-get-formula):
(org-table-maybe-recalculate-line):
(org-table-eval-formula):
(org-table-get-range):
(org-table--descriptor-line):
(org-table-recalculate):
(org-table-expand-lhs-ranges):
(org-table-edit-formulas):
(org-table-show-reference):
(org-table-get-remote-range): Apply changes above.  Refactor code.

(org-table-check-inside-data-field):
(org-table-current-column):
(org-table-current-dline):
(org-table-line-to-dline):
(org-table-copy-region):
(org-table-rotate-recalc-marks):
(org-table-fedit-post-command):
(org-table-fedit-convert-buffer):
(org-table-highlight-rectangle): Refactor code.

(org-table-goto-field): New function.

* lisp/org-capture.el (org-capture-place-table-line): Apply change made
  to table internals.

The point of this commit is to remove dependency on `org-current-line'
and `org-goto-line', which are both expensive in large buffers.  Now,
lines are relative to the beginning of the current table instead of
global (i.e., relative to the beginning of the buffer).
Nicolas Goaziou 9 years ago
parent
commit
14d07c0e7d
2 changed files with 439 additions and 434 deletions
  1. 12 12
      lisp/org-capture.el
  2. 427 422
      lisp/org-table.el

+ 12 - 12
lisp/org-capture.el

@@ -1,6 +1,6 @@
 ;;; org-capture.el --- Fast note taking in Org-mode
 
-;; Copyright (C) 2010-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -53,7 +53,7 @@
 
 (declare-function org-datetree-find-date-create "org-datetree"
 		  (date &optional keep-restriction))
-(declare-function org-table-get-specials "org-table" ())
+(declare-function org-table-analyze "org-table" ())
 (declare-function org-table-goto-line "org-table" (N))
 (declare-function org-pop-to-buffer-same-window "org-compat"
 		  (&optional buffer-or-name norecord label))
@@ -64,6 +64,7 @@
 (defvar org-remember-default-headline)
 (defvar org-remember-templates)
 (defvar org-table-hlines)
+(defvar org-table-current-begin-pos)
 (defvar dired-buffers)
 
 (defvar org-capture-clock-was-started nil
@@ -1161,17 +1162,16 @@ may have been stored before."
      ((and table-line-pos
 	   (string-match "\\(I+\\)\\([-+][0-9]\\)" table-line-pos))
       ;; we have a complex line specification
-      (goto-char (point-min))
-      (let ((nh (- (match-end 1) (match-beginning 1)))
-	    (delta (string-to-number (match-string 2 table-line-pos)))
-	    ll)
+      (let ((ll (ignore-errors
+		  (save-match-data (org-table-analyze))
+		  (aref org-table-hlines
+			(- (match-end 1) (match-beginning 1)))))
+	    (delta (string-to-number (match-string 2 table-line-pos))))
 	;; The user wants a special position in the table
-	(org-table-get-specials)
-	(setq ll (ignore-errors (aref org-table-hlines nh)))
-	(unless ll (error "Invalid table line specification \"%s\""
-			  table-line-pos))
-	(setq ll (+ ll delta (if (< delta 0) 0 -1)))
-	(org-goto-line ll)
+	(unless ll
+	  (error "Invalid table line specification \"%s\"" table-line-pos))
+	(goto-char org-table-current-begin-pos)
+	(forward-line (+ ll delta (if (< delta 0) 0 -1)))
 	(org-table-insert-row 'below)
 	(beginning-of-line 1)
 	(delete-region (point) (1+ (point-at-eol)))

File diff suppressed because it is too large
+ 427 - 422
lisp/org-table.el


Some files were not shown because too many files changed in this diff