From: Mark Wooding Date: Fri, 29 Apr 2016 11:01:54 +0000 (+0100) Subject: el/dot-emacs.el (diary-add-to-list): Fix for multiple appointments. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/2745469d77b0bfffd3f8ee5e046d42bd6fc225fa?hp=--cc el/dot-emacs.el (diary-add-to-list): Fix for multiple appointments. If a day has multiple appointments, we want to reformat them all. Iterate over the various transformations until convergence. The substitutions have been carefully (re-)designed to avoid gratuitous matching. --- 2745469d77b0bfffd3f8ee5e046d42bd6fc225fa 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 @@ (defadvice org-agenda-list (around mdw-preserve-links activate) (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.