diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index 36bd2e5..81019f2 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -1,11 +1,19 @@ (package-initialize) (require 'package) +(require 'cl) ;; Nope function (defun nope () (interactive) (message "Nope!")) +;; Helper function +(defun string-ends-with-p (string suffix) + "Return t if STRING ends with SUFFIX." + (and (string-match (rx-to-string `(: ,suffix eos) t) + string) + t)) + ;; Quote (setq initial-scratch-message (concat ";; Simplicity and elegance are unpopular because\n" @@ -174,13 +182,23 @@ (use-package heroku-theme :ensure t) +;; Open .org files in org directory +(defun my/counsel-org-agenda () + "Open .org files in org directory" + (interactive) + (find-file (concat (file-name-as-directory org-directory) + (ivy-read "Org files: " + (remove-if-not + (lambda (e) (string-ends-with-p e ".org")) + (directory-files org-directory)))))) + ;; Org-mode (use-package org :ensure t :config (setq org-directory "~/org") (setq org-agenda-files "~/org/agenda") - (global-set-key (kbd "") 'org-agenda) + (global-set-key (kbd "") 'my/counsel-org-agenda) (setq org-todo-keywords '((sequence "TODO" "WORKING" "BLOCKED" "REVIEW" "|" "ABANDONED" "DONE"))) (setq org-todo-keyword-faces '(("TODO" . "firebrick2")