summary refs log tree commit diff
path: root/emacs.d/config/config-lib.el
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2018-04-08 16:13:12 -0700
committerFranck Cuny <franck.cuny@gmail.com>2018-04-08 16:13:12 -0700
commit4007ca81e0105119c8ed754e654a731934f5154c (patch)
tree41ba9d60f64866c8a098e631e8e32bf4249931fa /emacs.d/config/config-lib.el
parent[emacs] fix some path after directories reorg (diff)
downloademacs.d-4007ca81e0105119c8ed754e654a731934f5154c.tar.gz
[emacs] Large refactoring.
At first I wanted to add support for java, and then I realized that
maintaining a giant file with all the packages was not working as I
was expected.

The configuration is broken down to multiple files now, with each
major mode in a separate file, and the main modules in their own too.

This should make it easier to maintain and organize.
Diffstat (limited to 'emacs.d/config/config-lib.el')
-rw-r--r--emacs.d/config/config-lib.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/emacs.d/config/config-lib.el b/emacs.d/config/config-lib.el
new file mode 100644
index 0000000..5148ff7
--- /dev/null
+++ b/emacs.d/config/config-lib.el
@@ -0,0 +1,34 @@
+(require 'config-package)
+
+;; rename a buffer
+(defun fc/rename-this-buffer-and-file ()
+  "Renames current buffer and file it is visiting."
+  (interactive)
+  (let ((name (buffer-name))
+        (filename (buffer-file-name))
+        (read-file-name-function 'read-file-name-default))
+    (if (not (and filename (file-exists-p filename)))
+        (error "Buffer '%s' is not visiting a file!" name)
+      (let ((new-name (read-file-name "New name: " filename)))
+        (cond ((get-buffer new-name)
+               (error "A buffer named '%s' already exists!" new-name))
+              (t
+               (rename-file filename new-name 1)
+               (rename-buffer new-name)
+               (set-visited-file-name new-name)
+               (set-buffer-modified-p nil)
+               (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name))))))))
+
+
+;; predicate for checking style only on python files
+(defun fc/check-source-p ()
+  "Finds if the current python file is in the `source' repository."
+  (and (executable-find "check.pex")
+       (buffer-file-name)
+       (string-match "src/source/.*\.py$" (buffer-file-name))))
+
+(defun fc/check-gcp-puppet-p ()
+  "Finds if the current file is in GCP's puppet repository."
+  (string-match "gcp-puppet-manifest/.*$" (buffer-file-name)))
+
+(provide 'config-lib)