summary refs log tree commit diff stats
path: root/tag-emacs
diff options
context:
space:
mode:
Diffstat (limited to 'tag-emacs')
-rw-r--r--tag-emacs/emacs.d/init.org70
1 files changed, 22 insertions, 48 deletions
diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org
index 4c4603d..0c384ee 100644
--- a/tag-emacs/emacs.d/init.org
+++ b/tag-emacs/emacs.d/init.org
@@ -304,6 +304,28 @@ Option/alt, then Control.
   (bind-key* "C-M-x" #'execute-extended-command)
   (set-register ?z `(file . ,(expand-file-name ".config/zsh/zshrc" "~")))
 #+END_SRC
+
+** Crux
+
+I can replace most of the simple helper/wrapper functions in my
+configuration with crux.el
+
+#+BEGIN_SRC emacs-lisp
+  (use-package crux
+	:bind (("C-o" . crux-smart-open-line-above)
+		   ("M-o" . crux-smart-open-line)
+
+		   ("C-x 4 t" . crux-transpose-windows)
+		   ("C-c e" . crux-eval-and-replace)
+		   ("C-c D" . crux-delete-file-and-buffer)
+		   ("C-c R" . crux-rename-file-and-buffer))
+	:init (progn
+			(defalias 'delete-current-buffer-file #'crux-delete-file-and-buffer)
+			(defalias 'rename-current-buffer-file #'crux-rename-file-and-buffer)))
+
+
+#+END_SRC
+
 * Projects
 
    #+BEGIN_SRC emacs-lisp
@@ -514,36 +536,6 @@ I often want to rename or delete the file that I’m currently visiting
 with a buffer.
 
 #+BEGIN_SRC emacs-lisp
-  (defun rename-current-buffer-file ()
-	"Renames current buffer and file it is visiting."
-	(interactive)
-	(let ((name (buffer-name))
-		  (filename (buffer-file-name)))
-	  (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)))
-		  (if (get-buffer new-name)
-			  (error "A buffer named '%s' already exists!" new-name)
-			(cond
-			 ((vc-backend filename) (vc-rename-file filename new-name))
-			 (t (rename-file filename new-name t)
-				(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 delete-current-buffer-file ()
-	"Removes file connected to current buffer and kills buffer."
-	(interactive)
-	(let ((filename (buffer-file-name)))
-	  (if (not (and filename (file-exists-p filename)))
-		  (kill-this-buffer)
-		(when (yes-or-no-p "Are you sure you want to remove this file? ")
-		  (delete-file filename)
-		  (kill-this-buffer)
-		  (message "File '%s' successfully removed" filename)))))
-
   (defun kill-or-delete-this-buffer-dwim (&optional arg)
 	"Kills current buffer.  With prefix arg, delete it."
 	(interactive "P")
@@ -1702,24 +1694,6 @@ Interactive elisp
 										(run-hooks 'lisp-mode-common-hook)))))
 #+END_SRC
 
-I don’t only use this in elisp.  It’s nice to do calculations in other
-buffers too: it’s faster than quickrun and the parens mean that I
-don’t have to worry about a selection.
-
-#+BEGIN_SRC emacs-lisp
-(defun eval-and-replace ()
-  "Replace the preceding sexp with its value."
-  (interactive)
-  (backward-kill-sexp)
-  (condition-case nil
-	  (prin1 (eval (read (current-kill 0)))
-			 (current-buffer))
-	(error (message "Invalid expression")
-		   (insert (current-kill 0)))))
-
-(bind-key "C-c e" #'eval-and-replace)
-#+END_SRC
-
 *** Scheme & Lisp
 
 I don’t work with these as often as I would like