From b15788a78501d5370847626a507beaeb3bc77f6b Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 27 Dec 2010 11:51:34 +0100 Subject: [PATCH 02/10] org-agenda: remove prefix-length * org-mobile.el (org-mobile-write-agenda-for-mobile): Use org-heading rather than prefix-length. * org-colview-xemacs.el (org-columns-display-here): Use org-heading rather than prefix-length. * org-colview.el (org-columns-display-here): Use org-heading rather than prefix-length. * org-agenda.el (org-format-agenda-item): Do not set prefix-length text properties, rather set org-heading on the heading part. (org-agenda-highlight-todo, org-agenda-open-link) (org-agenda-change-all-lines): Use org-heading rather than prefix-length. Signed-off-by: Julien Danjou --- lisp/org-agenda.el | 47 ++++++++++++++++++++++--------------------- lisp/org-colview-xemacs.el | 4 ++- lisp/org-colview.el | 4 ++- lisp/org-mobile.el | 6 ++-- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 5cc402f..b963a73 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5230,6 +5230,9 @@ Any match of REMOVE-RE will be removed from TXT." (while (string-match remove-re txt) (setq txt (replace-match "" t t txt)))) + ;; Set org-heading property on `txt' + (setq txt (propertize txt 'org-heading t)) + ;; Create the final string (if noprefix (setq rtn txt) @@ -5270,7 +5273,6 @@ Any match of REMOVE-RE will be removed from TXT." 'tags (mapcar 'org-downcase-keep-props tags) 'org-highest-priority org-highest-priority 'org-lowest-priority org-lowest-priority - 'prefix-length (- (length rtn) (length txt)) 'time-of-day time-of-day 'duration duration 'effort effort @@ -5485,12 +5487,12 @@ could bind the variable in the options section of a custom command.") (defun org-agenda-highlight-todo (x) (let ((org-done-keywords org-done-keywords-for-agenda) (case-fold-search nil) - re pl) + re) (if (eq x 'line) (save-excursion (beginning-of-line 1) (setq re (org-get-at-bol 'org-todo-regexp)) - (goto-char (+ (point) (or (org-get-at-bol 'prefix-length) 0))) + (goto-char (or (text-property-any (point-at-bol) (point-at-eol) 'org-heading t) (point))) (when (looking-at (concat "[ \t]*\\.*\\(" re "\\) +")) (add-text-properties (match-beginning 0) (match-end 1) (list 'face (org-get-todo-face 1))) @@ -5498,21 +5500,21 @@ could bind the variable in the options section of a custom command.") (delete-region (match-beginning 1) (1- (match-end 0))) (goto-char (match-beginning 1)) (insert (format org-agenda-todo-keyword-format s))))) - (setq re (concat (get-text-property 0 'org-todo-regexp x)) - pl (get-text-property 0 'prefix-length x)) - (when (and re - (equal (string-match (concat "\\(\\.*\\)" re "\\( +\\)") - x (or pl 0)) pl)) - (add-text-properties - (or (match-end 1) (match-end 0)) (match-end 0) - (list 'face (org-get-todo-face (match-string 2 x))) + (let ((pl (text-property-any 0 (length x) 'org-heading t x))) + (setq re (concat (get-text-property 0 'org-todo-regexp x))) + (when (and re + (equal (string-match (concat "\\(\\.*\\)" re "\\( +\\)") + x (or pl 0)) pl)) + (add-text-properties + (or (match-end 1) (match-end 0)) (match-end 0) + (list 'face (org-get-todo-face (match-string 2 x))) x) - (when (match-end 1) - (setq x (concat (substring x 0 (match-end 1)) - (format org-agenda-todo-keyword-format - (match-string 2 x)) + (when (match-end 1) + (setq x (concat (substring x 0 (match-end 1)) + (format org-agenda-todo-keyword-format + (match-string 2 x)) (org-add-props " " (text-properties-at 0 x)) - (substring x (match-end 3)))))) + (substring x (match-end 3))))))) x))) (defsubst org-cmp-priority (a b) @@ -5565,8 +5567,8 @@ could bind the variable in the options section of a custom command.") (defsubst org-cmp-alpha (a b) "Compare the headlines, alphabetically." - (let* ((pla (get-text-property 0 'prefix-length a)) - (plb (get-text-property 0 'prefix-length b)) + (let* ((pla (text-property-any 0 (length a) 'org-heading t a)) + (plb (text-property-any 0 (length b) 'org-heading t b)) (ta (and pla (substring a pla))) (tb (and plb (substring b plb)))) (when pla @@ -6622,8 +6624,8 @@ at the text of the entry itself." (buffer (and marker (marker-buffer marker))) (prefix (buffer-substring (point-at-bol) - (+ (point-at-bol) - (or (org-get-at-bol 'prefix-length) 0))))) + (or (text-property-any (point-at-bol) (point-at-eol) 'org-heading t) + (point-at-bol))))) (cond (buffer (with-current-buffer buffer @@ -6940,11 +6942,10 @@ If FORCE-TAGS is non nil, the car of it returns the new tags." cat (org-get-at-bol 'org-category) tags thetags new (org-format-agenda-item "x" newhead cat tags dotime 'noprefix) - pl (org-get-at-bol 'prefix-length) + pl (text-property-any (point-at-bol) (point-at-eol) 'org-heading t) undone-face (org-get-at-bol 'undone-face) done-face (org-get-at-bol 'done-face)) - (goto-char (+ (point) pl)) - ;; (org-move-to-column pl) FIXME: does the above line work correctly? + (goto-char pl) (cond ((equal new "") (beginning-of-line 1) diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el index 06a1253..b7db3fc 100644 --- a/lisp/org-colview-xemacs.el +++ b/lisp/org-colview-xemacs.el @@ -322,7 +322,9 @@ This is the compiled version of the format.") (get-text-property (point-at-bol) 'face)) 'default) :foreground)))) (face (if (featurep 'xemacs) color (list color 'org-column))) - (pl (or (get-text-property (point-at-bol) 'prefix-length) 0)) + (pl (- (point) + (or (text-property-any (point-at-bol) (point-at-eol) 'org-heading t) + (point)))) (cphr (get-text-property (point-at-bol) 'org-complex-heading-regexp)) pom property ass width f string ov column val modval s2 title calc) ;; Check if the entry is in another buffer. diff --git a/lisp/org-colview.el b/lisp/org-colview.el index c4f18c7..bdd5928 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -171,7 +171,9 @@ This is the compiled version of the format.") (color (list :foreground (face-attribute ref-face :foreground))) (face (list color 'org-column ref-face)) (face1 (list color 'org-agenda-column-dateline ref-face)) - (pl (or (get-text-property (point-at-bol) 'prefix-length) 0)) + (pl (- (point) + (or (text-property-any (point-at-bol) (point-at-eol) 'org-heading t) + (point)))) (cphr (get-text-property (point-at-bol) 'org-complex-heading-regexp)) pom property ass width f string ov column val modval s2 title calc) ;; Check if the entry is in another buffer. diff --git a/lisp/org-mobile.el b/lisp/org-mobile.el index 4b16e2b..fbebed7 100644 --- a/lisp/org-mobile.el +++ b/lisp/org-mobile.el @@ -617,12 +617,12 @@ The table of checksums is written to the file mobile-checksums." (get-text-property (point) 'org-marker))) (setq sexp (member (get-text-property (point) 'type) '("diary" "sexp"))) - (if (setq pl (get-text-property (point) 'prefix-length)) + (if (setq pl (text-property-any (point) (point-at-eol) 'org-heading t)) (progn (setq prefix (org-trim (buffer-substring - (point) (+ (point) pl))) + (point) pl)) line (org-trim (buffer-substring - (+ (point) pl) + pl (point-at-eol)))) (delete-region (point-at-bol) (point-at-eol)) (insert line "" prefix "") -- 1.7.2.3