From 4007ca81e0105119c8ed754e654a731934f5154c Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 8 Apr 2018 16:13:12 -0700 Subject: [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. --- emacs.d/config/config-lib.el | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 emacs.d/config/config-lib.el (limited to 'emacs.d/config/config-lib.el') 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) -- cgit 1.4.1