[Dired] Inline custom function from ‘db-utils’ into init.el

This commit is contained in:
Daniel - 2018-01-27 16:41:20 +01:00
parent 250a460a14
commit 3a556afca6
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
2 changed files with 24 additions and 41 deletions

26
init.el
View File

@ -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

View File

@ -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