Skip to content

Instantly share code, notes, and snippets.

@pqnelson
Last active January 16, 2017 23:37
Show Gist options
  • Save pqnelson/10269900 to your computer and use it in GitHub Desktop.
Save pqnelson/10269900 to your computer and use it in GitHub Desktop.
Emacs config file
;; set 72 character width
(setq-default fill-column 72)
(setq auto-fill-mode t)
(setq-default auto-fill-function 'do-auto-fill)
(global-font-lock-mode 1)
(add-hook 'shell-mode-hook
'(lambda () (auto-fill-mode nil)))
;; font face
(set-default-font "Monospace-9")
;; indent should be soft
(setq-default indent-tabs-mode nil)
;; show column number
(setq column-number-mode t)
;; match parentheses
(show-paren-mode 1)
;; more visually pleasing color scheme
;; using https://github.com/sellout/emacs-color-theme-solarized
(add-to-list 'custom-theme-load-path "~/.emacs.d/emacs-color-theme-solarized/")
(require 'color-theme)
;; (require 'color-theme-solarized)
(color-theme-initialize)
(load-theme 'solarized t)
(set-frame-parameter nil 'background-mode 'dark)
(when (not (display-graphic-p))
(set-terminal-parameter nil 'background-mode 'dark))
;; Call enable-theme to pick up the change to 'background-mode.
(enable-theme 'solarized)
;; journal to keep track of my reading notes, etc.
(defun journal ()
(interactive)
(find-file "~/.emacs.d/journalData.tex")
(end-of-buffer)
(insert "\n\n\\entry{")
(insert (format-time-string "%A %B %e, %Y at %l:%M%p"))
(insert "}\n"))
;; clojure related niceties
(require 'rainbow-delimiters)
(add-hook 'clojure-mode-hook 'rainbow-delimiters-mode)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(rainbow-delimiters-depth-1-face ((((background dark)) (:foreground "white"))))
'(rainbow-delimiters-depth-2-face ((((background dark)) (:foreground "orange"))))
'(rainbow-delimiters-depth-3-face ((((background dark)) (:foreground "darkcyan"))))
'(rainbow-delimiters-depth-4-face ((((background dark)) (:foreground "purple"))))
'(rainbow-delimiters-depth-5-face ((((background dark)) (:foreground "yellow"))))
'(rainbow-delimiters-depth-6-face ((((background dark)) (:foreground "brown"))))
'(rainbow-delimiters-depth-7-face ((((background dark)) (:foreground "darkgreen"))))
'(rainbow-delimiters-depth-8-face ((((background dark)) (:foreground "blue"))))
'(rainbow-delimiters-depth-9-face ((((background dark)) (:foreground "red"))))
'(tooltip ((t (:background "white" :foreground "blue" :foundry "fixed")))))
(add-to-list 'load-path "~/.emacs.d/cider/")
(add-to-list 'load-path "~/.emacs.d/dash.el/")
(load "~/.emacs.d/dash.el/dash.elc")
(load "~/.emacs.d/dash.el/dash-functional.elc")
(require 'cider)
(add-hook 'cider-mode-hook 'cider-turn-on-eldoc-mode)
(add-hook 'cider-repl-mode-hook 'paredit-mode)
(add-hook 'cider-repl-mode-hook 'rainbow-delimiters-mode)
(setq cider-repl-wrap-history t)
(add-hook 'clojure-mode-hook
'(lambda ()
(local-set-key [f12] 'cider-eval-buffer)))
(add-hook 'clojure-mode-hook
'(lambda ()
(local-set-key [f2] 'cider-jack-in)))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;; org-mode for random notes, to-do lists, etc
(push '("\\.org\\'" . org-mode) auto-mode-alist)
(push '("\\.org\\.txt\\'" . org-mode) auto-mode-alist)
(defun open-log ()
(interactive)
(find-file "~/.emacs.d/log.org"))
(setq org-export-html-style-extra "")
(setq org-src-fontify-natively t)
(setq org-html-postamble nil)
(add-hook 'org-mode-hook 'turn-on-font-lock)
(setq org-export-htmlize-output-type 'css)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(coffee-args-compile (quote ("-cm")))
'(org-confirm-babel-evaluate nil)
'(org-emphasis-alist (quote (("*" bold) ("/" italic) ("_" underline) ("`" org-code verbatim) ("~" org-verbatim verbatim) ("+" (:strike-through t)))))
'(org-src-fontify-natively t))
(require 'org-latex)
(add-to-list 'org-export-latex-classes
'("org-article"
"\\documentclass{article}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
;; markdown
;; https://github.com/jrblevin/markdown-mode
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;;;;; news related macros
(load-file "~/src/dsf-news/dsf-news.el")
(require 'dsf-news)
(defun load-news-notes ()
"Opens up the running notes on the news"
(interactive)
(find-file "~/news/news.org"))
(global-set-key [f5] 'load-news-notes)
(add-hook 'org-mode-hook
'(lambda ()
(local-set-key [f2] 'expand-citations)))
(add-to-list 'load-path "~/.emacs.d/elfeed/")
(load-file "~/.emacs.d/elfeed/elfeed.el")
(require 'elfeed)
(setq elfeed-feeds
'(("http://rss.nytimes.com/services/xml/rss/nyt/World.xml" world)
("http://feeds.bbci.co.uk/news/uk/rss.xml" world uk)
("http://feeds.bbci.co.uk/news/world/rss.xml" world)
("http://www.economist.com/sections/china/rss.xml" world china)
("http://www.economist.com/sections/europe/rss.xml" world europe)
("http://www.economist.com/sections/asia/rss.xml" world asia)
("http://www.economist.com/sections/britain/rss.xml" world uk)
("http://www.economist.com/sections/middle-east-africa/rss.xml" world)
;; News from Washington
("http://feeds.washingtonpost.com/rss/politics" us)
("http://feeds.washingtonpost.com/rss/national" us)
("http://rss.nytimes.com/services/xml/rss/nyt/Politics.xml" us)
("https://www.nytimes.com/svc/collections/v1/publish/http://www.nytimes.com/section/us/rss.xml" us)
("http://www.politico.com/rss/congress.xml" us)
("http://www.politico.com/rss/politics08.xml" us)
("http://www.politico.com/rss/politicoinfluence.xml" us)
("http://www.politico.com/rss/playbook.xml" us)
("http://www.politico.com/rss/huddle.xml" us)
("http://www.rollcall.com/rss/tag/rss-feed/all-news" us)
("http://thehill.com/rss/syndicator/19109" us)
("http://www.economist.com/blogs/democracyinamerica/index.xml" us)
("http://www.economist.com/sections/united-states/rss.xml" us)
("http://www.latimes.com/nation/politics/rss2.0.xml" us)
;; California
("http://www.sacbee.com/news/investigations/lobbying-influence/?widgetName=rssfeed&widgetContentId=713546&getXmlFeed=true" ca)
("http://www.sacbee.com/news/politics-government/capitol-alert/?widgetName=rssfeed&widgetContentId=713546&getXmlFeed=true" ca)
("http://capitolweekly.net/feed/" ca)
("http://www.politico.com/states/rss/politicocalifornia" ca)
("http://www.economist.com/topics/california-politics/index.xml" ca)
("http://www.mercurynews.com/news/california-news/feed/" ca)
("http://www.ocregister.com/common/rss/rss.php?catID=18808" ca)
("http://www.ocregister.com/common/rss/rss.php?catID=18805" ca)
("http://www.capitolbasement.com/rss.php?_c=10h5g5p944kp5pw" ca)
("http://www.therepublic.com/category/state/california/feed/" ca)
;; Colorado
("http://www.economist.com/topics/colorado-politics/index.xml" co)
("http://www.denverpost.com/politics/local/feed/" co)
("http://www.denverpost.com/politics/colorado-legislature/feed/" co)
;; DC city news
("http://feeds.washingtonpost.com/rss/local/dc-politics" dc)
;; Florida
("http://www.politico.com/states/rss/politicoflorida" fl)
("http://www.miamiherald.com/news/politics-government/state-politics/?widgetName=rssfeed&widgetContentId=712015&getXmlFeed=true" fl)
("http://orlando-politics.com/feed/" fl)
("http://floridapolitics.com/feed" fl)
;; Massachusetts
("http://www.bostonherald.com/taxonomy/term/8/feed" ma)
("http://www.statehousenews.com/rss/rss_stories.aspx" ma)
("http://www.telegram.com/news/government?template=rss&mime=xml" ma)
("http://www.bostonherald.com/taxonomy/term/8/feed" ma)
("http://pretiminahan.blogspot.com/feeds/posts/default" ma)
("http://www.thecapitolviewlive.com/feeds/posts/default" ma)
("http://www.therepublic.com/category/state/massachusetts/feed/" ma)
;; Maryland
("http://feeds.washingtonpost.com/rss/local/md-politics" md)
("http://www.baltimoresun.com/news/maryland/politics/rss2.0.xml" md)
;; North Carolina
("http://capitaltonightnc.twcnews.com/feed/" nc)
("http://www.newsobserver.com/news/politics-government/state-politics/?widgetName=rssfeed&widgetContentId=8173866&getXmlFeed=true" nc)
;; Nevada
("http://www.reviewjournal.com/politics/nevada-legislature/feed" nv)
;; New Jersey
("http://www.economist.com/topics/new-jersey-politics/index.xml" nj)
("http://www.politico.com/states/rss/politiconewjersey" nj)
("http://observer.com/new-jersey-politics/feed/" nj)
("http://www.njspotlight.com/rss/" nj)
;; New York
("http://www.nystateofpolitics.com/feed/" ny)
("http://www.economist.com/topics/new-york-state-politics/index.xml" ny)
("http://www.timesunion.com/news/feed/Capitol-State-News-210.php" ny)
("http://www.therepublic.com/category/state/new-york/feed/" ny)
("http://www.politico.com/states/rss/politiconewyork" ny)
;; ("http://legislativegazette.com/archives/category/politics/feed" ny) ;; broken, for now
;; Pennsylvania
("http://www.phillyrecord.com/feed/" pa)
;; Texas
("http://capitalroundup.twcnews.com/feed/" tx)
("https://www.texastribune.org/feeds/sections/politics/" tx)
("http://www.star-telegram.com/news/politics-government/state-politics/?widgetName=rssfeed&widgetContentId=714290&getXmlFeed=true" tx)
("http://www.texasinsider.org/feed/atom/" tx)
("http://www.dallasnews.com/news/texas-politics.rss" tx)
("http://www.dallasnews.com/news/politics.rss" tx)
("http://feeds.feedburner.com/bigjollypolitics/feed" tx)
("http://gov.texas.gov/rss/" tx)
("http://www.therepublic.com/category/state/texas/feed/" tx)
("https://www.texasobserver.org/topics/politics/feed/" tx)
;; ("http://www.capitolinside.com/" tx) ;; no rss, paywalled
;; Virginia
("http://www.richmond.com/search/?q=&t=article&l=25&d=&d1=&d2=&s=start_time&sd=desc&c=news/virginia/government-politics*&f=rss" va)
("http://www.roanoke.com/search/?q=&t=article&l=25&d=&d1=&d2=&s=start_time&sd=desc&c=news/virginia*&f=rss" va)
("http://blogs.nbc12.com/decisionvirginia/atom.xml" va)
("http://www.therepublic.com/category/state/virginia/feed/" va)
("http://feeds.washingtonpost.com/rss/local/va-politics" va)))
(global-set-key (kbd "C-x w") 'elfeed)
(add-hook 'elfeed-new-entry-hook
(elfeed-make-tagger :before "2 weeks ago"
:remove 'unread))
(defun strip-prefix (prefix s)
(if (string-prefix-p prefix s)
(substring s (length prefix))
s))
(defun strip-feeds-prefix (url-domain)
(strip-prefix "feeds." url-domain))
(defun strip-rss-prefix (url-domain)
(strip-prefix "rss." url-domain))
(defadvice elfeed-search-update (before nullprogram activate)
(dolist (feed-entry elfeed-feeds)
(let* ((url (if (stringp feed-entry)
feed-entry
(car feed-entry)))
(feed (elfeed-db-get-feed url)))
(setf (elfeed-feed-title feed)
(strip-rss-prefix
(strip-feeds-prefix
(url-domain url)))))))
;; normalize tags
(dsf-tag-alias "roy_cooper" "roy_a_cooper")
(dsf-tag-alias "donald_trump" "donald_j_trump")
(dsf-tag-alias "president_donald_trump" "donald_j_trump")
(dsf-tag-alias "donald_trump_presidency" "donald_j_trump")
(dsf-tag-alias "president_barack_obama" "barack_obama")
(dsf-tag-alias "fbi" "federal_bureau_of_investiation")
(dsf-tag-alias "governors_us" "us_governors")
(dsf-tag-alias "vladimir_v_putin" "vladimir_putin")
(dsf-tag-alias "vladimir_v_putin_v" "vladimir_putin")
;; update the RSS feed every 15 minutes
(run-with-timer 0 (* 60 15) 'elfeed-search-fetch nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment