X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/91f00aac2ba43d8a943f96ad66a851622b008d7d..2745469d77b0bfffd3f8ee5e046d42bd6fc225fa:/el/dot-emacs.el diff --git a/el/dot-emacs.el b/el/dot-emacs.el index a2989fe..5a7f08d 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -373,24 +373,29 @@ as output rather than a string." (defadvice diary-add-to-list (before mdw-trim-leading-space activate) "Trim leading space from the diary entry string." (save-match-data - (let ((str (ad-get-arg 1))) - (ad-set-arg 1 - (cond ((null str) nil) + (let ((str (ad-get-arg 1)) + (done nil) old) + (while (not done) + (setq old str) + (setq str (cond ((null str) nil) + ((string-match "\\(^\\|\n\\)[ \t]+" str) + (replace-match "\\1" nil nil str)) ((and mdw-diary-for-org-mode-p (string-match (concat - "^[ \t]*" + "\\(^\\|\n\\)" "\\(" diary-time-regexp "\\(-" diary-time-regexp "\\)?" - "\\)[ \t]+") + "\\)" + "\\(\t[ \t]*\\| [ \t]+\\)") str)) - (replace-match "\\1 " nil nil str)) - ((string-match "^[ \t]+" str) - (replace-match "" nil nil str)) + (replace-match "\\1\\2 " nil nil str)) ((and (not mdw-diary-for-org-mode-p) (string-match "\\[\\[[^][]*]\\[\\([^][]*\\)]]" str)) (replace-match "\\1" nil nil str)) - (t str)))))) + (t str))) + (if (equal str old) (setq done t))) + (ad-set-arg 1 str)))) ;; Fighting with Org-mode's evil key maps.