summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <fcuny@twitter.com>2019-09-14 10:37:45 -0700
committerFranck Cuny <fcuny@twitter.com>2019-09-14 10:37:45 -0700
commitc64bb64544a48a797aa54b5cac19ac1be553abfb (patch)
treee1adb8028be8dad6e68cf88c2a44ee2e3e867171
parent[emacs] update hydra menu for go-mode (diff)
downloademacs.d-c64bb64544a48a797aa54b5cac19ac1be553abfb.tar.gz
[emacs] add a couple more functions.
* `fcuny/gocs` is to use twitter's internal code search engine.
* `fcuny/uniqify-region-lines` is to remove duplicated lines (useful
  when lines are sorted)
* `fcuny/org-journal-date-format-func` is to set the correct title of
  the journal file
Diffstat (limited to '')
-rw-r--r--emacs.d/custom/fcuny-defuns.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/emacs.d/custom/fcuny-defuns.el b/emacs.d/custom/fcuny-defuns.el
index 88e73a3..cb117f4 100644
--- a/emacs.d/custom/fcuny-defuns.el
+++ b/emacs.d/custom/fcuny-defuns.el
@@ -299,4 +299,31 @@ For instance, given the string:    What's all this then?
   (interactive)
   (fcuny/org-refile-subtree-to-file org-default-technical-dir))
 
+(defun fcuny/org-journal-date-format-func (time)
+  "Custom function to insert journal date header.
+
+  When buffer is empty prepend a header in front the entry header."
+  (concat (when (= (buffer-size) 0)
+            (concat
+             (pcase org-journal-file-type
+               (`daily "#+TITLE: Daily Journal")
+               (`weekly "#+TITLE: Weekly Journal")
+               (`monthly "#+TITLE: Monthly Journal")
+               (`yearly "#+TITLE: Yearly Journal"))))
+          org-journal-date-prefix
+          (format-time-string "%x (%A)" time)))
+
+(defun fcuny/uniquify-region-lines (beg end)
+  "Remove duplicate adjacent lines in region."
+  (interactive "*r")
+  (save-excursion
+    (goto-char beg)
+    (while (re-search-forward "^\\(.*\n\\)\\1+" end t)
+      (replace-match "\\1"))))
+
+(defun fcuny/gocs ()
+  (interactive)
+  (let ((text (read-string "Search for: " (thing-at-point 'word))))
+    (browse-url (format "http://go/cs/%s" text))))
+
 (provide 'fcuny-defuns)