Skip to content

Instantly share code, notes, and snippets.

@lijigang
Created May 5, 2020 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lijigang/c865a2a4d075c75b4aeb61fe0f9102b6 to your computer and use it in GitHub Desktop.
Save lijigang/c865a2a4d075c75b4aeb61fe0f9102b6 to your computer and use it in GitHub Desktop.
orgmode configuration of agenda (sunrise and sunset)
;; learn from https://github.com/AbstProcDo/Master-Emacs-From-Scrach-with-Solid-Procedures/blob/master/05.Emacs-as-a-Agenda-by-Org.org
(setq org-agenda-include-diary t)
(setq org-agenda-diary-file "your/path/to/standard-diary")
(setq diary-file "your/path/to/standard-diary")
;; 设置本地经纬度坐标
(setq calendar-latitude 39.9042)
(setq calendar-longitude 116.4074)
;;Sunrise and Sunset
;;日出而作, 日落而息
(defun diary-sunrise ()
(let ((dss (diary-sunrise-sunset)))
(with-temp-buffer
(insert dss)
(goto-char (point-min))
(while (re-search-forward " ([^)]*)" nil t)
(replace-match "" nil nil))
(goto-char (point-min))
(search-forward ",")
(buffer-substring (point-min) (match-beginning 0)))))
(defun diary-sunset ()
(let ((dss (diary-sunrise-sunset))
start end)
(with-temp-buffer
(insert dss)
(goto-char (point-min))
(while (re-search-forward " ([^)]*)" nil t)
(replace-match "" nil nil))
(goto-char (point-min))
(search-forward ", ")
(setq start (match-end 0))
(search-forward " at")
(setq end (match-beginning 0))
(goto-char start)
(capitalize-word 1)
(buffer-substring start end))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment