summaryrefslogtreecommitdiffstats
path: root/lisp/init-editing.el
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-08-21 13:28:51 +0200
committerMartin Polden <mpolden@mpolden.no>2020-08-21 13:28:51 +0200
commit135ba0f7db348f8987d2621710f8c43bfd87c987 (patch)
treeb8742aaf7180dab07bcf704a8236273a6ce49fd4 /lisp/init-editing.el
parenta691dc1e2be0d91974999e58df0758aa07d0dea2 (diff)
editing: Replace snippets with crux functions
Diffstat (limited to 'lisp/init-editing.el')
-rw-r--r--lisp/init-editing.el39
1 files changed, 6 insertions, 33 deletions
diff --git a/lisp/init-editing.el b/lisp/init-editing.el
index af015e1..62ec16e 100644
--- a/lisp/init-editing.el
+++ b/lisp/init-editing.el
@@ -15,43 +15,16 @@
:bind (("C-h C-f" . find-function-other-window)
("C-h C-k" . find-function-on-key)))
-(defun show-file-name ()
- "Show the full path file name in the minibuffer and add it to the kill ring."
- (interactive)
- (when buffer-file-name
- (message buffer-file-name)
- (kill-new (file-truename buffer-file-name))))
-
-;; source:
-;; http://emacsredux.com/blog/2013/05/04/rename-file-and-buffer/
-;; https://github.com/bbatsov/crux/blob/dcd693c258ae4d867b18d9a028a828ef6c42a4a6/crux.el#L406
-(defun rename-buffer-and-file ()
- "Rename current buffer and if the buffer is visiting a file, rename it too."
- (interactive)
- (let ((filename (buffer-file-name)))
- (if (not (and filename (file-exists-p filename)))
- (rename-buffer (read-from-minibuffer "New name: " (buffer-name)))
- (let* ((new-name (read-from-minibuffer "New name: " filename))
- (containing-dir (file-name-directory new-name)))
- (make-directory containing-dir t)
- (cond
- ((vc-backend filename) (vc-rename-file filename new-name))
- (t
- (rename-file filename new-name t)
- (set-visited-file-name new-name t t)))))))
+(use-package crux
+ :ensure t
+ :bind (("M-j" . crux-top-join-line)
+ ("C-c n" . crux-rename-file-and-buffer)
+ ("C-c w" . crux-kill-buffer-truename)
+ ("C-c D" . crux-duplicate-current-line-or-region)))
;; C-x k kills current buffer
(global-set-key (kbd "C-x k") 'kill-this-buffer)
-;; C-c w shows the path of the current file
-(global-set-key (kbd "C-c w") 'show-file-name)
-
-;; join line
-(global-set-key (kbd "M-j") (lambda () (interactive) (join-line -1)))
-
-;; C-c n renames the current buffer and file
-(global-set-key (kbd "C-c n") 'rename-buffer-and-file)
-
;; C-- undoes
(global-set-key (kbd "C--") 'undo)