summaryrefslogtreecommitdiff
path: root/lisp/org-colview.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/org-colview.el')
-rw-r--r--lisp/org-colview.el52
1 files changed, 23 insertions, 29 deletions
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 3838531..359c46a 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -548,7 +548,7 @@ Where possible, use the standard interface for changing this line."
(condition-case nil (org-no-warnings (next-line 1)) (error nil))
(setq hidep (org-at-heading-p 1)))
(eval form)
- (and hidep (hide-entry))))
+ (and hidep (outline-hide-entry))))
(defun org-columns-previous-allowed-value ()
"Switch to the previous allowed value for this column."
@@ -1193,47 +1193,41 @@ This function updates `org-columns-current-fmt-compiled'."
;;; Dynamic block for Column view
-(defvar org-heading-regexp) ; defined in org.el
-(defvar org-heading-keyword-regexp-format) ; defined in org.el
(defun org-columns-capture-view (&optional maxlevel skip-empty-rows)
"Get the column view of the current buffer or subtree.
-The first optional argument MAXLEVEL sets the level limit. A
-second optional argument SKIP-EMPTY-ROWS tells whether to skip
+The first optional argument MAXLEVEL sets the level limit.
+A second optional argument SKIP-EMPTY-ROWS tells whether to skip
empty rows, an empty row being one where all the column view
-specifiers except ITEM are empty. This function returns a list
+specifiers but ITEM are empty. This function returns a list
containing the title row and all other rows. Each row is a list
of fields."
(save-excursion
- (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled))
- (re-archive (concat ".*:" org-archive-tag ":"))
- (n (length title)) row tbl)
+ (let* ((title (mapcar #'cadr org-columns-current-fmt-compiled))
+ (has-item? (member "ITEM" title))
+ (n (length title))
+ tbl)
(goto-char (point-min))
- (while (re-search-forward org-heading-regexp nil t)
+ (while (re-search-forward org-outline-regexp-bol nil t)
(catch 'next
(when (and (or (null maxlevel)
- (>= maxlevel
- (if org-odd-levels-only
- (/ (1+ (length (match-string 1))) 2)
- (length (match-string 1)))))
+ (>= maxlevel (org-reduced-level (org-outline-level))))
(get-char-property (match-beginning 0) 'org-columns-key))
(when (or (org-in-commented-heading-p t)
- (save-excursion
- (beginning-of-line)
- (looking-at re-archive)))
+ (member org-archive-tag (org-get-tags)))
(org-end-of-subtree t)
(throw 'next t))
- (setq row nil)
- (loop for i from 0 to (1- n) do
- (push
- (org-quote-vert
- (or (get-char-property (+ (match-beginning 0) i) 'org-columns-value-modified)
- (get-char-property (+ (match-beginning 0) i) 'org-columns-value)
- ""))
- row))
- (setq row (nreverse row))
- (unless (and skip-empty-rows
- (eq 1 (length (delete "" (delete-dups (copy-sequence row))))))
- (push row tbl)))))
+ (let (row)
+ (dotimes (i n)
+ (let ((col (+ (line-beginning-position) i)))
+ (push (org-quote-vert
+ (or (get-char-property col 'org-columns-value-modified)
+ (get-char-property col 'org-columns-value)
+ ""))
+ row)))
+ (unless (and skip-empty-rows
+ (let ((r (delete-dups (remove "" row))))
+ (or (null r) (and has-item? (= (length r) 1)))))
+ (push (nreverse row) tbl))))))
(append (list title 'hline) (nreverse tbl)))))
;;;###autoload