chiark / gitweb /
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 91283d9a80dff576dfe70f504c3ab87eac9bd527..e50d77383b09645a62464209bcd56629ecb015c6 100644 (file)
@@ -333,6 +333,14 @@ (defun mdw-todo (&optional when)
                                (nth 2 when))))))))
     (eq w d)))
 
                                (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
 ;; Fighting with Org-mode's evil key maps.
 
 (defvar mdw-evil-keymap-keys