From 3a556afca64956820fe043b49e855b15da1a737f Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 27 Jan 2018 16:41:20 +0100 Subject: [PATCH] =?UTF-8?q?[Dired]=20Inline=20custom=20function=20from=20?= =?UTF-8?q?=E2=80=98db-utils=E2=80=99=20into=20init.el?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.el | 26 ++++++++++++++++++++++++-- site-lisp/db-utils.el | 39 --------------------------------------- 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/init.el b/init.el index b29b0b0..98f0bab 100644 --- a/init.el +++ b/init.el @@ -820,6 +820,30 @@ Certificates are assumed to be of the form *.crt." (setq ls-lisp-use-insert-directory-program t)) (dired-quick-sort-setup) + (defun dired-back-to-top () + "Jump to first non-trivial line in dired." + (interactive) + (goto-char (point-min)) + (dired-next-line 2)) + + (defun dired-jump-to-bottom () + "Jump to last non-trivial line in dired." + (interactive) + (goto-char (point-max)) + (dired-next-line -1)) + + (defun dired-get-size () ; from emacswiki, via oremacs + "print size of all files marked in the current dired buffer." + (interactive) + (let ((files (dired-get-marked-files))) + (with-temp-buffer + (apply 'call-process "/usr/bin/du" nil t nil "-sch" files) + (message + "size of all marked files: %s" + (progn + (re-search-backward "\\(^[0-9.,]+[a-za-z]+\\).*total$") + (match-string 1)))))) + (bind-key [remap beginning-of-buffer] #'dired-back-to-top dired-mode-map) (bind-key [remap end-of-buffer] @@ -872,8 +896,6 @@ Certificates are assumed to be of the form *.crt." (bind-key "C-i" 'helm-execute-persistent-action helm-map) (bind-key "C-z" 'helm-select-action helm-map) - (require 'db-utils) - (setq helm-mini-default-sources '(helm-source-buffers-list helm-source-recentf db/helm-frequently-used-features diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index 4beb4de..0362476 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -199,45 +199,6 @@ lispy." (eq this-command 'pp-eval-expression))) (lispy-mode 1))) - -;;; dired - -(defun dired-back-to-top () - "Jump to first non-trivial line in dired." - (interactive) - (goto-char (point-min)) - (dired-next-line 2)) - -(defun dired-jump-to-bottom () - "Jump to last non-trivial line in dired." - (interactive) - (goto-char (point-max)) - (dired-next-line -1)) - -(defun dired-get-size () ; from emacswiki, via oremacs - "print size of all files marked in the current dired buffer." - (interactive) - (let ((files (dired-get-marked-files))) - (with-temp-buffer - (apply 'call-process "/usr/bin/du" nil t nil "-sch" files) - (message - "size of all marked files: %s" - (progn - (re-search-backward "\\(^[0-9.,]+[a-za-z]+\\).*total$") - (match-string 1)))))) - -(defun dired-open-term () ; from oremacs - "Open an `ansi-term' that corresponds to current directory." - (interactive) - (let ((current-dir (dired-current-directory))) - (term-send-string - (db/ansi-term) - (if (file-remote-p current-dir) - (let ((v (tramp-dissect-file-name current-dir t))) - (format "ssh %s@%s\n" - (aref v 1) (aref v 2))) - (format "cd '%s'\n" current-dir))))) - ;;; helm configuration