el/dot-emacs.el: Trim leading spaces from diary entry strings.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 20 Mar 2016 19:42:15 +0000 (19:42 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 20 Mar 2016 19:42:15 +0000 (19:42 +0000)
el/dot-emacs.el

index 91283d9..e50d773 100644 (file)
@@ -333,6 +333,14 @@ as output rather than a string."
                                (nth 2 when))))))))
     (eq w d)))
 
+(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)))
+      (if (and str (string-match "^[ \t]+" str))
+         (let ((new (replace-match "" nil nil str)))
+           (ad-set-arg 1 new))))))
+
 ;; Fighting with Org-mode's evil key maps.
 
 (defvar mdw-evil-keymap-keys