summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2017-02-18 14:51:46 -0800
committerFranck Cuny <franck.cuny@gmail.com>2017-02-18 14:51:46 -0800
commit483ae72926ec9e66ef0f2c3abe103c61f499950c (patch)
tree3527de2be293bd29061c492270d3ad55828b83c8
parent[notes] up (diff)
downloademacs.d-483ae72926ec9e66ef0f2c3abe103c61f499950c.tar.gz
[Emacs] Move all the configuration related to twitter to it's own file
The configuration for the style checker; the functions to create remote files on nest; etc. All are now living in a file with all things related to twitter.
Diffstat (limited to '')
-rw-r--r--emacs.d/init.el44
-rw-r--r--emacs.d/lib/funcs.el23
-rw-r--r--emacs.d/lib/twitter.el84
3 files changed, 90 insertions, 61 deletions
diff --git a/emacs.d/init.el b/emacs.d/init.el
index d22df22..75d4474 100644
--- a/emacs.d/init.el
+++ b/emacs.d/init.el
@@ -166,13 +166,9 @@
:config
(progn
- (use-package flycheck-twitter-python-style
- :load-path (lambda () (expand-file-name "~/src/flycheck-twitter-python-style.el/")))
(add-hook 'prog-mode-hook 'flycheck-mode)
- (flycheck-twitter-python-style-setup)
-
(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))
(setq flycheck-highlighting-mode 'lines)
(setq flycheck-check-syntax-automatically '(mode-enabled save))))
@@ -373,17 +369,9 @@
(use-package midnight
;; clean old buffers at midnight
- :ensure t)
-
-(use-package pants
- ;; interface to pants
- :load-path (lambda () (expand-file-name "~/src/pants.el/"))
-
+ :ensure t
:config
- (setq pants-completion-system 'ivy
- pants-source-tree-root "/Users/fcuny/src/source"
- pants-bury-compilation-buffer t
- pants-extra-args "-q")
+ (midnight-mode t))
:bind (("C-c b" . pants-find-build-file)
("C-c r" . pants-run-binary)
@@ -423,21 +411,6 @@
projectile-cache-file (expand-file-name "var/projectile.cache" user-emacs-directory))
(add-to-list 'projectile-globally-ignored-files ".DS_Store"))
-(use-package puppet-mode
- ;; mode to support puppet and work with puppet
- :ensure t
-
- :mode ("\\.pp\\'" . puppet-mode)
-
- :init (add-hook 'puppet-mode-hook 'flycheck-mode)
-
- :config
- (when (memq window-system '(mac ns x))
- (dolist (var '("GEM_HOME" "GEM_PATH" "MY_RUBY_HOME"))
- (unless (getenv var)
- (exec-path-from-shell-copy-env var))))
- (setq flycheck-puppet-lint-rc "/Users/fcuny/src/twitter-ops/utilities/puppet/.puppet-lint.rc"))
-
(use-package python
;; configuration for Python
:mode(("\\.aurora$" . python-mode)
@@ -518,15 +491,6 @@
:action (lambda (x) (switch-to-buffer x))
:caller 'fc/find-term-buffers)))))
-(use-package thrift
- ;; mode to work with thrift files
- :ensure t
-
- :mode ("\\.thrift\\'" . thrift-mode)
-
- :config
- (setq thrift-indent-level 2))
-
(use-package tramp
;; configuration for tramp
:config
@@ -553,4 +517,8 @@
:mode ("\\.ya?ml\\'" . yaml-mode))
+(use-package twitter
+ ;; finish by loading twitter's modules
+ :load-path (lambda () (expand-file-name "lib" user-emacs-directory)))
+
(add-hook 'emacs-startup-hook #'fc/load-time)
diff --git a/emacs.d/lib/funcs.el b/emacs.d/lib/funcs.el
index bb7d211..81330f6 100644
--- a/emacs.d/lib/funcs.el
+++ b/emacs.d/lib/funcs.el
@@ -87,32 +87,9 @@ Visit the file after creation."
(interactive "sName of temporary file: ")
(fc/start--file (expand-file-name (format "/tmp/%s" file-name))))
-(defun fc/start-nest-tmp-file (file-name)
- "Create a file in ~/tmp on nest for the give file name."
- (interactive "sName of the temporary file: ")
- (fc/start--file (expand-file-name (format "/nest.smfc.twitter.com:~/tmp/%s" file-name))))
-
;; open dired buffer with tramp on remote host
(defun fc/remote--dired (host)
"Open dired on a remote host."
(dired (concat "/" host ":")))
-(defun fc/remote-nest-dired ()
- "Open dired on nest."
- (interactive)
- (fc/remote--dired "nest.smfc.twitter.com"))
-
-;; un/monitor hosts by running mth remotely
-(defun fc/silence-host (host)
- (interactive "sHostname: ")
- (let ((default-directory "/ssh:nest.smfc.twitter.com:"))
- (start-file-process "mth" (get-buffer-create "*mth*")
- "/usr/local/bin/mth" "silence" host "99 years")))
-
-(defun fc/unsilence-host (host)
- (interactive "sHostname: ")
- (let ((default-directory "/ssh:nest.smfc.twitter.com:"))
- (start-file-process "mth" (get-buffer-create "*mth*")
- "/usr/local/bin/mth" "unsilence" host)))
-
(provide 'funcs)
diff --git a/emacs.d/lib/twitter.el b/emacs.d/lib/twitter.el
new file mode 100644
index 0000000..fcf3383
--- /dev/null
+++ b/emacs.d/lib/twitter.el
@@ -0,0 +1,84 @@
+;; packages that are needed only for twitter
+
+(use-package pants
+ ;; interface to pants
+ :load-path (lambda () (expand-file-name "~/src/pants.el/"))
+
+ :config
+ (setq pants-completion-system 'ivy
+ pants-source-tree-root "/Users/fcuny/src/source"
+ pants-bury-compilation-buffer t
+ pants-extra-args "-q")
+
+ :bind (("C-c b" . pants-find-build-file)
+ ("C-c r" . pants-run-binary)
+ ("C-c t" . pants-run-test)))
+
+(use-package puppet-mode
+ ;; mode to support puppet and work with puppet
+ :ensure t
+
+ :mode ("\\.pp\\'" . puppet-mode)
+
+ :init (add-hook 'puppet-mode-hook 'flycheck-mode)
+
+ :config
+ (when (memq window-system '(mac ns x))
+ (dolist (var '("GEM_HOME" "GEM_PATH" "MY_RUBY_HOME"))
+ (unless (getenv var)
+ (exec-path-from-shell-copy-env var))))
+ (setq flycheck-puppet-lint-rc "/Users/fcuny/src/twitter-ops/utilities/puppet/.puppet-lint.rc"))
+
+(use-package thrift
+ ;; mode to work with thrift files
+ :ensure t
+
+ :mode ("\\.thrift\\'" . thrift-mode)
+
+ :config
+ (setq thrift-indent-level 2))
+
+;; custom functions
+
+(defun fc/check-source-p ()
+ ;; predicate for checking style only on python files
+ (and (executable-find "check.pex")
+ (buffer-file-name)
+ (string-match "src/source/.*\.py$" (buffer-file-name))))
+
+;;; errors are reported like this:
+;;; E241:ERROR <file name>:<line> <message>
+(flycheck-define-checker source-check
+ "A syntax checker for python source code in Source, using `check.pex'"
+ :command ("check.pex" source)
+ :error-patterns ((error line-start (id (1+ nonl)) ":ERROR" (1+ nonl) ":" line (message) line-end)
+ (warning line-start (id (1+ nonl)) ":WARNING" (1+ nonl) ":" line (message) line-end))
+ :predicate fc/check-source-p
+ :modes (python-mode))
+
+(add-to-list 'flycheck-checkers 'source-check)
+
+(defun fc/start-nest-tmp-file (file-name)
+ "Create a file in ~/tmp on nest for the give file name."
+ (interactive "sName of the temporary file: ")
+ (fc/start--file (expand-file-name (format "/nest.smfc.twitter.com:~/tmp/%s" file-name))))
+
+(defun fc/remote-nest-dired ()
+ "Open dired on nest."
+ (interactive)
+ (fc/remote--dired "nest.smfc.twitter.com"))
+
+;; un/monitor hosts by running mth remotely
+(defun fc/silence-host (host)
+ (interactive "sHostname: ")
+ (let ((default-directory "/ssh:nest.smfc.twitter.com:"))
+ (start-file-process "mth" (get-buffer-create "*mth*")
+ "/usr/local/bin/mth" "silence" host "99 years")))
+
+(defun fc/unsilence-host (host)
+ (interactive "sHostname: ")
+ (let ((default-directory "/ssh:nest.smfc.twitter.com:"))
+ (start-file-process "mth" (get-buffer-create "*mth*")
+ "/usr/local/bin/mth" "unsilence" host)))
+
+(provide 'twitter)