mirror of
https://github.com/pestctrl/emacs-config.git
synced 2026-02-16 16:24:18 +00:00
Taiwan related helpers
This commit is contained in:
parent
eff3ef4e9b
commit
30abfbcf1c
1 changed files with 40 additions and 0 deletions
40
lisp/taiwan.el
Normal file
40
lisp/taiwan.el
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
(defun my/convert-to-format ()
|
||||
(interactive)
|
||||
(cl-flet ((add-drawer (regex label)
|
||||
(save-excursion
|
||||
(when (re-search-forward regex nil t)
|
||||
(goto-char (line-beginning-position))
|
||||
(insert ":" label ": ")))))
|
||||
(re-search-forward "^\\*\\*\\*\\* ")
|
||||
(goto-char (line-beginning-position))
|
||||
(org-narrow-to-subtree)
|
||||
(add-drawer "^https://goo.gl" "GOOGLE_MAPS_URL")
|
||||
(add-drawer (rx line-start (+ digit) "." (+ digit) ", ")
|
||||
"COORDINATES")
|
||||
(add-drawer "Tainan City"
|
||||
"ADDRESS")
|
||||
(add-drawer "^http"
|
||||
"WEBSITE")
|
||||
(add-drawer "^English:"
|
||||
"ENGLISH")
|
||||
(goto-char (line-end-position))
|
||||
(insert "\n:PROPERTIES:")
|
||||
(re-search-forward "goo.gl" nil t)
|
||||
(goto-char (line-end-position))
|
||||
(insert "\n:END:")
|
||||
(widen)))
|
||||
|
||||
(defun my/populate-taiwan-fields (address website maps-url coordinates)
|
||||
(interactive
|
||||
(list
|
||||
(read-string "Address? ")
|
||||
(read-string "Website? ")
|
||||
(read-string "Google Maps URL? ")
|
||||
(read-string "Coordinates? ")))
|
||||
(cl-flet ((add-valid (key value)
|
||||
(when (not (string-empty-p value))
|
||||
(org-entry-put (point) key value))))
|
||||
(add-valid "ADDRESS" address)
|
||||
(add-valid "COORDINATES" coordinates)
|
||||
(add-valid "WEBSITE" website)
|
||||
(add-valid "GOOGLE_MAPS_URL" maps-url)))
|
||||
Loading…
Reference in a new issue