mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-23 07:18:53 +00:00
Allow limited length prefix format specifier %n.mc
This commit is contained in:
parent
174f53cad8
commit
e409fbeff9
@ -1,3 +1,9 @@
|
||||
2009-10-06 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org-agenda.el (org-prefix-category-max-length): New variable.
|
||||
(org-format-agenda-item): Use `org-prefix-category-max-length'.
|
||||
(org-compile-prefix-format): Set `org-prefix-category-max-length'.
|
||||
|
||||
2009-10-03 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org-mobile.el (org-mobile-create-index-file): Improve the
|
||||
|
@ -4468,6 +4468,8 @@ The flag is set if the currently compiled format contains a `%T'.")
|
||||
The flag is set if the currently compiled format contains a `%e'.")
|
||||
(defvar org-prefix-category-length nil
|
||||
"Used by `org-compile-prefix-format' to remember the category field widh.")
|
||||
(defvar org-prefix-category-max-length nil
|
||||
"Used by `org-compile-prefix-format' to remember the category field widh.")
|
||||
|
||||
(defun org-format-agenda-item (extra txt &optional category tags dotime
|
||||
noprefix remove-re)
|
||||
@ -4585,15 +4587,19 @@ Any match of REMOVE-RE will be removed from TXT."
|
||||
(t ""))
|
||||
extra (or extra "")
|
||||
category (if (symbolp category) (symbol-name category) category))
|
||||
(when (string-match org-bracket-link-regexp category)
|
||||
(setq l (if (match-end 3)
|
||||
(- (match-end 3) (match-beginning 3))
|
||||
(- (match-end 1) (match-beginning 1))))
|
||||
(when (< l (or org-prefix-category-length 0))
|
||||
(setq category (copy-sequence category))
|
||||
(org-add-props category nil
|
||||
'extra-space (make-string
|
||||
(- org-prefix-category-length l 1) ?\ ))))
|
||||
(if (string-match org-bracket-link-regexp category)
|
||||
(progn
|
||||
(setq l (if (match-end 3)
|
||||
(- (match-end 3) (match-beginning 3))
|
||||
(- (match-end 1) (match-beginning 1))))
|
||||
(when (< l (or org-prefix-category-length 0))
|
||||
(setq category (copy-sequence category))
|
||||
(org-add-props category nil
|
||||
'extra-space (make-string
|
||||
(- org-prefix-category-length l 1) ?\ ))))
|
||||
(if (and org-prefix-category-max-length
|
||||
(>= (length category) org-prefix-category-max-length))
|
||||
(setq category (substring category 0 (1- org-prefix-category-max-length)))))
|
||||
;; Evaluate the compiled format
|
||||
(setq rtn (concat (eval org-prefix-format-compiled) txt)))
|
||||
|
||||
@ -4701,10 +4707,15 @@ The resulting form is returned and stored in the variable
|
||||
(if (equal var 'time) (setq org-prefix-has-time t))
|
||||
(if (equal var 'tag) (setq org-prefix-has-tag t))
|
||||
(if (equal var 'effort) (setq org-prefix-has-effort t))
|
||||
(if (equal var 'category)
|
||||
(setq org-prefix-category-length
|
||||
(abs (string-to-number (match-string 2 s)))))
|
||||
(setq f (concat "%" (match-string 2 s) "s"))
|
||||
(when (equal var 'category)
|
||||
(setq org-prefix-category-length
|
||||
(floor (abs (string-to-number (match-string 2 s)))))
|
||||
(setq org-prefix-category-max-length
|
||||
(let ((x (match-string 2 s)))
|
||||
(save-match-data
|
||||
(if (string-match "\\.[0-9]+" x)
|
||||
(string-to-number (substring (match-string 0 x) 1)))))))
|
||||
(if opt
|
||||
(setq varform
|
||||
`(if (equal "" ,var)
|
||||
|
Loading…
Reference in New Issue
Block a user