summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2020-03-19 17:31:28 -0700
committerFranck Cuny <franck.cuny@gmail.com>2020-03-19 17:31:28 -0700
commit0c2de88b14994fa8fed3f662cc25c7a9e0ba3f45 (patch)
tree63e96035a0294636dd7b62f8b78c1ba2c9774f0c
parentelfeed: add support for hydra (diff)
downloademacs.d-0c2de88b14994fa8fed3f662cc25c7a9e0ba3f45.tar.gz
emacs: add custom libraries
These libraries are not specific to package configuration, they can be functions or others than I use in various places.
-rw-r--r--emacs.d/lisp/fcuny-commands.el27
-rw-r--r--emacs.d/lisp/fcuny-flycheck-py.el6
2 files changed, 33 insertions, 0 deletions
diff --git a/emacs.d/lisp/fcuny-commands.el b/emacs.d/lisp/fcuny-commands.el
new file mode 100644
index 0000000..a286e9f
--- /dev/null
+++ b/emacs.d/lisp/fcuny-commands.el
@@ -0,0 +1,27 @@
+(defun 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))))))))
+
+(defun 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"))))
+
+(provide 'fcuny-commands)
diff --git a/emacs.d/lisp/fcuny-flycheck-py.el b/emacs.d/lisp/fcuny-flycheck-py.el
new file mode 100644
index 0000000..68a5143
--- /dev/null
+++ b/emacs.d/lisp/fcuny-flycheck-py.el
@@ -0,0 +1,6 @@
+(defun fcuny/check-source-predicate-python-p ()
+ (and (executable-find "check.pex")
+ (buffer-file-name)
+ (string-match "src/source/.*\.py$" (buffer-file-name))))
+
+(provide 'fcuny-flycheck-py)