um-date-separator and build um-date-re from it using rx
This commit is contained in:
parent
cce48501c0
commit
c9adc0a23a
1 changed files with 25 additions and 6 deletions
31
elisp/um.el
31
elisp/um.el
|
|
@ -42,7 +42,12 @@
|
|||
:type '(string)
|
||||
)
|
||||
|
||||
(defcustom um-date-format "%Y-%m-%d"
|
||||
(defcustom um-date-separator "-"
|
||||
"Seperator used in date strings, used by `um-date-format' and `um-date-re'."
|
||||
:type '(string)
|
||||
)
|
||||
|
||||
(defcustom um-date-format (concat "%Y" um-date-separator "%m" um-date-separator "%d")
|
||||
"Format passed to `format-time-string' when creating `um-journal-header'. Defaults to ISO8601."
|
||||
:type '(string)
|
||||
)
|
||||
|
|
@ -50,15 +55,28 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; faces
|
||||
|
||||
(defconst um-date-re "^: \\([[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+$\\)" "um date regexp")
|
||||
;; TODO: doesn't currently respect um-date-format:
|
||||
(defconst um-date-re (rx
|
||||
line-start
|
||||
(literal ": ")
|
||||
(group (repeat 4 digit)
|
||||
(literal um-date-separator)
|
||||
(repeat 1 2 digit)
|
||||
(literal um-date-separator)
|
||||
(repeat 1 2 digit))
|
||||
line-end
|
||||
)
|
||||
"um date regexp. built from `um-date-separator'. NOTE: currently assumes ISO8601.")
|
||||
|
||||
;; NOTE: regexp-opt wraps the whole expression in (), so I can't omit the -.
|
||||
(defcustom um-locale-re (regexp-opt '(
|
||||
"- Brooklyn"
|
||||
"- Fool's Bluff"
|
||||
)) "um locale regexp")
|
||||
"- home"
|
||||
"- away"
|
||||
))
|
||||
"um locale regexp. Add your custom places within a `regexp-opt' or make it general.")
|
||||
|
||||
(defconst um-tag-re "^\\+ \\([[:alpha:]\\_\\-]+$\\)" "um tag regexp")
|
||||
(defconst um-tag-re "^\\+ \\([[:alpha:]\\_\\-]+$\\)"
|
||||
"um tag regexp. Allows hypens and underscores within the tag.")
|
||||
|
||||
(defface font-lock-um-date-face
|
||||
`((((type tty) (class mono)))
|
||||
|
|
@ -82,6 +100,7 @@
|
|||
"um tag face")
|
||||
|
||||
;; TODO: should this be a user setup hook?
|
||||
;; TODO: these matchers should be functions which only match against the header.
|
||||
(font-lock-add-keywords 'markdown-mode
|
||||
`(
|
||||
(,um-date-re 1 'font-lock-um-date-face)
|
||||
|
|
|
|||
Loading…
Reference in a new issue